Fix filtering mismatch when using the None players button
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Content.Client.Eui;
|
||||
using System.Linq;
|
||||
using Content.Client.Eui;
|
||||
using Content.Shared.Administration;
|
||||
using Content.Shared.Administration.Logs;
|
||||
using Content.Shared.Eui;
|
||||
@@ -25,17 +26,13 @@ public class AdminLogsEui : BaseEui
|
||||
|
||||
private void RequestLogs()
|
||||
{
|
||||
var round = Window.GetSelectedRoundId();
|
||||
var types = Window.GetSelectedLogTypes();
|
||||
var players = Window.GetSelectedPlayerIds();
|
||||
|
||||
var request = new LogsRequest(
|
||||
round,
|
||||
types,
|
||||
Window.SelectedRoundId,
|
||||
Window.SelectedTypes.ToList(),
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
players,
|
||||
Window.SelectedPlayers.ToArray(),
|
||||
null,
|
||||
null,
|
||||
DateOrder.Descending);
|
||||
|
||||
@@ -33,8 +33,8 @@ public partial class AdminLogsWindow : SS14Window
|
||||
LogSearch.OnTextChanged += LogSearchChanged;
|
||||
|
||||
SelectAllTypesButton.OnPressed += SelectAllTypes;
|
||||
|
||||
SelectNoTypesButton.OnPressed += SelectNoTypes;
|
||||
|
||||
SelectNoPlayersButton.OnPressed += SelectNoPlayers;
|
||||
|
||||
RoundSpinBox.IsValid = i => i > 0 && i <= CurrentRound;
|
||||
@@ -49,11 +49,13 @@ public partial class AdminLogsWindow : SS14Window
|
||||
|
||||
private int CurrentRound { get; set; }
|
||||
|
||||
private HashSet<LogType> SelectedTypes { get; } = new();
|
||||
public int SelectedRoundId => RoundSpinBox.Value;
|
||||
|
||||
private HashSet<Guid> SelectedPlayers { get; } = new();
|
||||
public HashSet<LogType> SelectedTypes { get; } = new();
|
||||
|
||||
private HashSet<LogImpact> SelectedImpacts { get; } = new();
|
||||
public HashSet<Guid> SelectedPlayers { get; } = new();
|
||||
|
||||
public HashSet<LogImpact> SelectedImpacts { get; } = new();
|
||||
|
||||
public void SetCurrentRound(int round)
|
||||
{
|
||||
@@ -100,6 +102,8 @@ public partial class AdminLogsWindow : SS14Window
|
||||
|
||||
private void SelectAllTypes(ButtonEventArgs obj)
|
||||
{
|
||||
SelectedTypes.Clear();
|
||||
|
||||
foreach (var control in TypesContainer.Children)
|
||||
{
|
||||
if (control is not AdminLogTypeButton type)
|
||||
@@ -108,6 +112,7 @@ public partial class AdminLogsWindow : SS14Window
|
||||
}
|
||||
|
||||
type.Pressed = true;
|
||||
SelectedTypes.Add(type.Type);
|
||||
}
|
||||
|
||||
UpdateLogs();
|
||||
@@ -115,6 +120,8 @@ public partial class AdminLogsWindow : SS14Window
|
||||
|
||||
private void SelectNoTypes(ButtonEventArgs obj)
|
||||
{
|
||||
SelectedTypes.Clear();
|
||||
|
||||
foreach (var control in TypesContainer.Children)
|
||||
{
|
||||
if (control is not AdminLogTypeButton type)
|
||||
@@ -131,6 +138,8 @@ public partial class AdminLogsWindow : SS14Window
|
||||
|
||||
private void SelectNoPlayers(ButtonEventArgs obj)
|
||||
{
|
||||
SelectedPlayers.Clear();
|
||||
|
||||
foreach (var control in PlayersContainer.Children)
|
||||
{
|
||||
if (control is not AdminLogPlayerButton player)
|
||||
@@ -379,45 +388,6 @@ public partial class AdminLogsWindow : SS14Window
|
||||
AddLogs(logs);
|
||||
}
|
||||
|
||||
public int GetSelectedRoundId()
|
||||
{
|
||||
return RoundSpinBox.Value;
|
||||
}
|
||||
|
||||
public List<LogType> GetSelectedLogTypes()
|
||||
{
|
||||
var types = new List<LogType>();
|
||||
|
||||
foreach (var control in TypesContainer.Children)
|
||||
{
|
||||
if (control is not AdminLogTypeButton {Text: { }, Pressed: true} type)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
types.Add(Enum.Parse<LogType>(type.Text));
|
||||
}
|
||||
|
||||
return types;
|
||||
}
|
||||
|
||||
public Guid[] GetSelectedPlayerIds()
|
||||
{
|
||||
var players = new List<Guid>();
|
||||
|
||||
foreach (var control in PlayersContainer.Children)
|
||||
{
|
||||
if (control is not AdminLogPlayerButton {Pressed: true} player)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
players.Add(player.Id);
|
||||
}
|
||||
|
||||
return players.ToArray();
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
|
||||
Reference in New Issue
Block a user