diff --git a/Content.Client/Administration/UI/Logs/AdminLogsControl.xaml b/Content.Client/Administration/UI/Logs/AdminLogsControl.xaml
new file mode 100644
index 0000000000..fc091c9999
--- /dev/null
+++ b/Content.Client/Administration/UI/Logs/AdminLogsControl.xaml
@@ -0,0 +1,68 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Content.Client/Administration/UI/Logs/AdminLogsControl.xaml.cs b/Content.Client/Administration/UI/Logs/AdminLogsControl.xaml.cs
new file mode 100644
index 0000000000..eb0167fbab
--- /dev/null
+++ b/Content.Client/Administration/UI/Logs/AdminLogsControl.xaml.cs
@@ -0,0 +1,432 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Content.Client.Administration.UI.CustomControls;
+using Content.Shared.Administration.Logs;
+using Content.Shared.Database;
+using Robust.Client.AutoGenerated;
+using Robust.Client.UserInterface;
+using Robust.Client.UserInterface.Controls;
+using Robust.Client.UserInterface.XAML;
+using Robust.Shared.Localization;
+using static Robust.Client.UserInterface.Controls.BaseButton;
+using static Robust.Client.UserInterface.Controls.LineEdit;
+
+namespace Content.Client.Administration.UI.Logs;
+
+[GenerateTypedNameReferences]
+public partial class AdminLogsControl : Control
+{
+ private readonly Comparer _adminLogTypeButtonComparer =
+ Comparer.Create((a, b) =>
+ string.Compare(a.Type.ToString(), b.Type.ToString(), StringComparison.Ordinal));
+
+ private readonly Comparer _adminLogPlayerButtonComparer =
+ Comparer.Create((a, b) =>
+ string.Compare(a.Text, b.Text, StringComparison.Ordinal));
+
+ public AdminLogsControl()
+ {
+ RobustXamlLoader.Load(this);
+
+ TypeSearch.OnTextChanged += TypeSearchChanged;
+ PlayerSearch.OnTextChanged += PlayerSearchChanged;
+ LogSearch.OnTextChanged += LogSearchChanged;
+
+ SelectAllTypesButton.OnPressed += SelectAllTypes;
+ SelectNoTypesButton.OnPressed += SelectNoTypes;
+
+ SelectAllPlayersButton.OnPressed += SelectAllPlayers;
+ SelectNoPlayersButton.OnPressed += SelectNoPlayers;
+
+ RoundSpinBox.IsValid = i => i > 0 && i <= CurrentRound;
+ RoundSpinBox.ValueChanged += RoundSpinBoxChanged;
+ RoundSpinBox.InitDefaultButtons();
+
+ ResetRoundButton.OnPressed += ResetRoundPressed;
+
+ SetImpacts(Enum.GetValues().OrderBy(impact => impact).ToArray());
+ SetTypes(Enum.GetValues());
+ }
+
+ private int CurrentRound { get; set; }
+
+ public int SelectedRoundId => RoundSpinBox.Value;
+
+ public HashSet SelectedTypes { get; } = new();
+
+ public HashSet SelectedPlayers { get; } = new();
+
+ public HashSet SelectedImpacts { get; } = new();
+
+ public void SetCurrentRound(int round)
+ {
+ CurrentRound = round;
+ ResetRoundButton.Text = Loc.GetString("admin-logs-reset-with-id", ("id", round));
+ UpdateResetButton();
+ }
+
+ public void SetRoundSpinBox(int round)
+ {
+ RoundSpinBox.Value = round;
+ UpdateResetButton();
+ }
+
+ private void RoundSpinBoxChanged(object? sender, ValueChangedEventArgs args)
+ {
+ UpdateResetButton();
+ }
+
+ private void UpdateResetButton()
+ {
+ ResetRoundButton.Disabled = RoundSpinBox.Value == CurrentRound;
+ }
+
+ private void ResetRoundPressed(ButtonEventArgs args)
+ {
+ RoundSpinBox.Value = CurrentRound;
+ }
+
+ private void TypeSearchChanged(LineEditEventArgs args)
+ {
+ UpdateTypes();
+ }
+
+ private void PlayerSearchChanged(LineEditEventArgs args)
+ {
+ UpdatePlayers();
+ }
+
+ private void LogSearchChanged(LineEditEventArgs args)
+ {
+ UpdateLogs();
+ }
+
+ private void SelectAllTypes(ButtonEventArgs args)
+ {
+ SelectedTypes.Clear();
+
+ foreach (var control in TypesContainer.Children)
+ {
+ if (control is not AdminLogTypeButton type)
+ {
+ continue;
+ }
+
+ type.Pressed = true;
+ SelectedTypes.Add(type.Type);
+ }
+
+ UpdateLogs();
+ }
+
+ private void SelectNoTypes(ButtonEventArgs args)
+ {
+ SelectedTypes.Clear();
+
+ foreach (var control in TypesContainer.Children)
+ {
+ if (control is not AdminLogTypeButton type)
+ {
+ continue;
+ }
+
+ type.Pressed = false;
+ type.Visible = ShouldShowType(type);
+ }
+
+ UpdateLogs();
+ }
+
+ private void SelectAllPlayers(ButtonEventArgs args)
+ {
+ SelectedPlayers.Clear();
+
+ foreach (var control in PlayersContainer.Children)
+ {
+ if (control is not AdminLogPlayerButton player)
+ {
+ continue;
+ }
+
+ player.Pressed = true;
+ SelectedPlayers.Add(player.Id);
+ }
+
+ UpdateLogs();
+ }
+
+ private void SelectNoPlayers(ButtonEventArgs args)
+ {
+ SelectedPlayers.Clear();
+
+ foreach (var control in PlayersContainer.Children)
+ {
+ if (control is not AdminLogPlayerButton player)
+ {
+ continue;
+ }
+
+ player.Pressed = false;
+ }
+
+ UpdateLogs();
+ }
+
+ public void UpdateTypes()
+ {
+ foreach (var control in TypesContainer.Children)
+ {
+ if (control is not AdminLogTypeButton type)
+ {
+ continue;
+ }
+
+ type.Visible = ShouldShowType(type);
+ }
+ }
+
+ private void UpdatePlayers()
+ {
+ foreach (var control in PlayersContainer.Children)
+ {
+ if (control is not AdminLogPlayerButton player)
+ {
+ continue;
+ }
+
+ player.Visible = ShouldShowPlayer(player);
+ }
+ }
+
+ private void UpdateLogs()
+ {
+ foreach (var child in LogsContainer.Children)
+ {
+ if (child is not AdminLogLabel log)
+ {
+ continue;
+ }
+
+ child.Visible = ShouldShowLog(log);
+ }
+ }
+
+ private bool ShouldShowType(AdminLogTypeButton button)
+ {
+ return button.Text != null &&
+ button.Text.Contains(TypeSearch.Text, StringComparison.OrdinalIgnoreCase);
+ }
+
+ private bool ShouldShowPlayer(AdminLogPlayerButton button)
+ {
+ return button.Text != null &&
+ button.Text.Contains(PlayerSearch.Text, StringComparison.OrdinalIgnoreCase);
+ }
+
+ private bool ShouldShowLog(AdminLogLabel label)
+ {
+ return SelectedTypes.Contains(label.Log.Type) &&
+ (SelectedPlayers.Count + label.Log.Players.Length == 0 || SelectedPlayers.Overlaps(label.Log.Players)) &&
+ SelectedImpacts.Contains(label.Log.Impact) &&
+ label.Log.Message.Contains(LogSearch.Text, StringComparison.OrdinalIgnoreCase);
+ }
+
+ private void TypeButtonPressed(ButtonEventArgs args)
+ {
+ var button = (AdminLogTypeButton) args.Button;
+ if (button.Pressed)
+ {
+ SelectedTypes.Add(button.Type);
+ }
+ else
+ {
+ SelectedTypes.Remove(button.Type);
+ }
+
+ UpdateLogs();
+ }
+
+ private void PlayerButtonPressed(ButtonEventArgs args)
+ {
+ var button = (AdminLogPlayerButton) args.Button;
+ if (button.Pressed)
+ {
+ SelectedPlayers.Add(button.Id);
+ }
+ else
+ {
+ SelectedPlayers.Remove(button.Id);
+ }
+
+ UpdateLogs();
+ }
+
+ private void ImpactButtonPressed(ButtonEventArgs args)
+ {
+ var button = (AdminLogImpactButton) args.Button;
+ if (button.Pressed)
+ {
+ SelectedImpacts.Add(button.Impact);
+ }
+ else
+ {
+ SelectedImpacts.Remove(button.Impact);
+ }
+
+ UpdateLogs();
+ }
+
+ private void SetImpacts(LogImpact[] impacts)
+ {
+ LogImpactContainer.RemoveAllChildren();
+
+ foreach (var impact in impacts)
+ {
+ var button = new AdminLogImpactButton(impact)
+ {
+ Text = impact.ToString()
+ };
+
+ SelectedImpacts.Add(impact);
+ button.OnPressed += ImpactButtonPressed;
+
+ LogImpactContainer.AddChild(button);
+ }
+
+ switch (impacts.Length)
+ {
+ case 0:
+ return;
+ case 1:
+ LogImpactContainer.GetChild(0).StyleClasses.Add("OpenRight");
+ return;
+ }
+
+ for (var i = 0; i < impacts.Length - 1; i++)
+ {
+ LogImpactContainer.GetChild(i).StyleClasses.Add("ButtonSquare");
+ }
+
+ LogImpactContainer.GetChild(LogImpactContainer.ChildCount - 1).StyleClasses.Add("OpenLeft");
+ }
+
+ private void SetTypes(LogType[] types)
+ {
+ var newTypes = types.ToHashSet();
+ var buttons = new SortedSet(_adminLogTypeButtonComparer);
+
+ foreach (var control in TypesContainer.Children.ToArray())
+ {
+ if (control is not AdminLogTypeButton type ||
+ !newTypes.Remove(type.Type))
+ {
+ continue;
+ }
+
+ buttons.Add(type);
+ }
+
+ foreach (var type in newTypes)
+ {
+ var button = new AdminLogTypeButton(type)
+ {
+ Text = type.ToString(),
+ Pressed = true
+ };
+
+ SelectedTypes.Add(type);
+ button.OnPressed += TypeButtonPressed;
+
+ buttons.Add(button);
+ }
+
+ TypesContainer.RemoveAllChildren();
+
+ foreach (var type in buttons)
+ {
+ TypesContainer.AddChild(type);
+ }
+
+ UpdateLogs();
+ }
+
+ public void SetPlayers(Dictionary players)
+ {
+ var buttons = new SortedSet(_adminLogPlayerButtonComparer);
+
+ foreach (var control in PlayersContainer.Children.ToArray())
+ {
+ if (control is not AdminLogPlayerButton player ||
+ !players.Remove(player.Id))
+ {
+ continue;
+ }
+
+ buttons.Add(player);
+ }
+
+ foreach (var (id, name) in players)
+ {
+ var button = new AdminLogPlayerButton(id)
+ {
+ Text = name,
+ Pressed = true
+ };
+
+ SelectedPlayers.Add(id);
+ button.OnPressed += PlayerButtonPressed;
+
+ buttons.Add(button);
+ }
+
+ PlayersContainer.RemoveAllChildren();
+
+ foreach (var player in buttons)
+ {
+ PlayersContainer.AddChild(player);
+ }
+
+ UpdateLogs();
+ }
+
+ public void AddLogs(SharedAdminLog[] logs)
+ {
+ for (var i = 0; i < logs.Length; i++)
+ {
+ ref var log = ref logs[i];
+ var separator = new HSeparator();
+ var label = new AdminLogLabel(ref log, separator);
+ label.Visible = ShouldShowLog(label);
+
+ LogsContainer.AddChild(label);
+ LogsContainer.AddChild(separator);
+ }
+ }
+
+ public void SetLogs(SharedAdminLog[] logs)
+ {
+ LogsContainer.RemoveAllChildren();
+ AddLogs(logs);
+ }
+
+ protected override void Dispose(bool disposing)
+ {
+ base.Dispose(disposing);
+
+ TypeSearch.OnTextChanged -= TypeSearchChanged;
+ PlayerSearch.OnTextChanged -= PlayerSearchChanged;
+ LogSearch.OnTextChanged -= LogSearchChanged;
+
+ SelectAllTypesButton.OnPressed -= SelectAllTypes;
+ SelectNoTypesButton.OnPressed -= SelectNoTypes;
+
+ SelectAllPlayersButton.OnPressed -= SelectAllPlayers;
+ SelectNoPlayersButton.OnPressed -= SelectNoPlayers;
+
+ RoundSpinBox.IsValid = null;
+ RoundSpinBox.ValueChanged -= RoundSpinBoxChanged;
+
+ ResetRoundButton.OnPressed -= ResetRoundPressed;
+ }
+}
diff --git a/Content.Client/Administration/UI/Logs/AdminLogsEui.cs b/Content.Client/Administration/UI/Logs/AdminLogsEui.cs
index 5f4c57c63b..0cddd65ae2 100644
--- a/Content.Client/Administration/UI/Logs/AdminLogsEui.cs
+++ b/Content.Client/Administration/UI/Logs/AdminLogsEui.cs
@@ -20,32 +20,22 @@ public class AdminLogsEui : BaseEui
public AdminLogsEui()
{
- var monitor = _clyde.EnumerateMonitors().First();
-
- ClydeWindow = _clyde.CreateWindow(new WindowCreateParameters
- {
- Maximized = true,
- Title = "Admin Logs",
- Monitor = monitor
- });
-
- ClydeWindow.RequestClosed += OnRequestClosed;
- ClydeWindow.DisposeOnClose = true;
-
LogsWindow = new AdminLogsWindow();
- LogsWindow.LogSearch.OnTextEntered += _ => RequestLogs();
- LogsWindow.RefreshButton.OnPressed += _ => RequestLogs();
- LogsWindow.NextButton.OnPressed += _ => NextLogs();
+ LogsControl = LogsWindow.Logs;
- Root = _uiManager.CreateWindowRoot(ClydeWindow);
- Root.AddChild(LogsWindow);
+ LogsControl.LogSearch.OnTextEntered += _ => RequestLogs();
+ LogsControl.RefreshButton.OnPressed += _ => RequestLogs();
+ LogsControl.NextButton.OnPressed += _ => NextLogs();
+ LogsControl.PopOutButton.OnPressed += _ => PopOut();
}
- private WindowRoot Root { get; }
+ private WindowRoot? Root { get; set; }
- private IClydeWindow ClydeWindow { get; }
+ private IClydeWindow? ClydeWindow { get; set; }
- private AdminLogsWindow LogsWindow { get; }
+ private AdminLogsWindow? LogsWindow { get; set; }
+
+ private AdminLogsControl LogsControl { get; }
private bool FirstState { get; set; } = true;
@@ -57,12 +47,12 @@ public class AdminLogsEui : BaseEui
private void RequestLogs()
{
var request = new LogsRequest(
- LogsWindow.SelectedRoundId,
- LogsWindow.SelectedTypes.ToList(),
+ LogsControl.SelectedRoundId,
+ LogsControl.SelectedTypes.ToList(),
null,
null,
null,
- LogsWindow.SelectedPlayers.ToArray(),
+ LogsControl.SelectedPlayers.ToArray(),
null,
null,
DateOrder.Descending);
@@ -76,6 +66,38 @@ public class AdminLogsEui : BaseEui
SendMessage(request);
}
+ private void PopOut()
+ {
+ if (LogsWindow == null)
+ {
+ return;
+ }
+
+ LogsControl.Orphan();
+ LogsWindow.Dispose();
+ LogsWindow = null;
+
+ var monitor = _clyde.EnumerateMonitors().First();
+
+ ClydeWindow = _clyde.CreateWindow(new WindowCreateParameters
+ {
+ Maximized = false,
+ Title = "Admin Logs",
+ Monitor = monitor,
+ Width = 1000,
+ Height = 400
+ });
+
+ ClydeWindow.RequestClosed += OnRequestClosed;
+ ClydeWindow.DisposeOnClose = true;
+
+ Root = _uiManager.CreateWindowRoot(ClydeWindow);
+ Root.AddChild(LogsControl);
+
+ LogsControl.PopOutButton.Disabled = true;
+ LogsControl.PopOutButton.Visible = false;
+ }
+
private bool TrySetFirstState(AdminLogsEuiState state)
{
if (!FirstState)
@@ -84,8 +106,8 @@ public class AdminLogsEui : BaseEui
}
FirstState = false;
- LogsWindow.SetCurrentRound(state.RoundId);
- LogsWindow.SetRoundSpinBox(state.RoundId);
+ LogsControl.SetCurrentRound(state.RoundId);
+ LogsControl.SetRoundSpinBox(state.RoundId);
return true;
}
@@ -100,8 +122,8 @@ public class AdminLogsEui : BaseEui
return;
}
- LogsWindow.SetCurrentRound(s.RoundId);
- LogsWindow.SetPlayers(s.Players);
+ LogsControl.SetCurrentRound(s.RoundId);
+ LogsControl.SetPlayers(s.Players);
if (first)
{
@@ -116,22 +138,33 @@ public class AdminLogsEui : BaseEui
switch (msg)
{
case NewLogs {Replace: true} newLogs:
- LogsWindow.SetLogs(newLogs.Logs);
+ LogsControl.SetLogs(newLogs.Logs);
break;
case NewLogs {Replace: false} newLogs:
- LogsWindow.AddLogs(newLogs.Logs);
+ LogsControl.AddLogs(newLogs.Logs);
break;
}
}
+ public override void Opened()
+ {
+ base.Opened();
+
+ LogsWindow?.OpenCentered();
+ }
+
public override void Closed()
{
base.Closed();
- ClydeWindow.RequestClosed -= OnRequestClosed;
+ if (ClydeWindow != null)
+ {
+ ClydeWindow.RequestClosed -= OnRequestClosed;
+ }
- LogsWindow.Dispose();
- Root.Dispose();
- ClydeWindow.Dispose();
+ LogsControl.Dispose();
+ LogsWindow?.Dispose();
+ Root?.Dispose();
+ ClydeWindow?.Dispose();
}
}
diff --git a/Content.Client/Administration/UI/Logs/AdminLogsWindow.xaml b/Content.Client/Administration/UI/Logs/AdminLogsWindow.xaml
index c52e9d8076..6e1f52a558 100644
--- a/Content.Client/Administration/UI/Logs/AdminLogsWindow.xaml
+++ b/Content.Client/Administration/UI/Logs/AdminLogsWindow.xaml
@@ -1,64 +1,7 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
diff --git a/Content.Client/Administration/UI/Logs/AdminLogsWindow.xaml.cs b/Content.Client/Administration/UI/Logs/AdminLogsWindow.xaml.cs
index 7f589ea415..765eb142bd 100644
--- a/Content.Client/Administration/UI/Logs/AdminLogsWindow.xaml.cs
+++ b/Content.Client/Administration/UI/Logs/AdminLogsWindow.xaml.cs
@@ -1,432 +1,14 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using Content.Client.Administration.UI.CustomControls;
-using Content.Shared.Administration.Logs;
-using Content.Shared.Database;
-using Robust.Client.AutoGenerated;
-using Robust.Client.UserInterface;
-using Robust.Client.UserInterface.Controls;
+using Robust.Client.AutoGenerated;
+using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;
-using Robust.Shared.Localization;
-using static Robust.Client.UserInterface.Controls.BaseButton;
-using static Robust.Client.UserInterface.Controls.LineEdit;
namespace Content.Client.Administration.UI.Logs;
[GenerateTypedNameReferences]
-public partial class AdminLogsWindow : Control
+public partial class AdminLogsWindow : SS14Window
{
- private readonly Comparer _adminLogTypeButtonComparer =
- Comparer.Create((a, b) =>
- string.Compare(a.Type.ToString(), b.Type.ToString(), StringComparison.Ordinal));
-
- private readonly Comparer _adminLogPlayerButtonComparer =
- Comparer.Create((a, b) =>
- string.Compare(a.Text, b.Text, StringComparison.Ordinal));
-
public AdminLogsWindow()
{
RobustXamlLoader.Load(this);
-
- TypeSearch.OnTextChanged += TypeSearchChanged;
- PlayerSearch.OnTextChanged += PlayerSearchChanged;
- LogSearch.OnTextChanged += LogSearchChanged;
-
- SelectAllTypesButton.OnPressed += SelectAllTypes;
- SelectNoTypesButton.OnPressed += SelectNoTypes;
-
- SelectAllPlayersButton.OnPressed += SelectAllPlayers;
- SelectNoPlayersButton.OnPressed += SelectNoPlayers;
-
- RoundSpinBox.IsValid = i => i > 0 && i <= CurrentRound;
- RoundSpinBox.ValueChanged += RoundSpinBoxChanged;
- RoundSpinBox.InitDefaultButtons();
-
- ResetRoundButton.OnPressed += ResetRoundPressed;
-
- SetImpacts(Enum.GetValues().OrderBy(impact => impact).ToArray());
- SetTypes(Enum.GetValues());
- }
-
- private int CurrentRound { get; set; }
-
- public int SelectedRoundId => RoundSpinBox.Value;
-
- public HashSet SelectedTypes { get; } = new();
-
- public HashSet SelectedPlayers { get; } = new();
-
- public HashSet SelectedImpacts { get; } = new();
-
- public void SetCurrentRound(int round)
- {
- CurrentRound = round;
- ResetRoundButton.Text = Loc.GetString("admin-logs-reset-with-id", ("id", round));
- UpdateResetButton();
- }
-
- public void SetRoundSpinBox(int round)
- {
- RoundSpinBox.Value = round;
- UpdateResetButton();
- }
-
- private void RoundSpinBoxChanged(object? sender, ValueChangedEventArgs args)
- {
- UpdateResetButton();
- }
-
- private void UpdateResetButton()
- {
- ResetRoundButton.Disabled = RoundSpinBox.Value == CurrentRound;
- }
-
- private void ResetRoundPressed(ButtonEventArgs args)
- {
- RoundSpinBox.Value = CurrentRound;
- }
-
- private void TypeSearchChanged(LineEditEventArgs args)
- {
- UpdateTypes();
- }
-
- private void PlayerSearchChanged(LineEditEventArgs args)
- {
- UpdatePlayers();
- }
-
- private void LogSearchChanged(LineEditEventArgs args)
- {
- UpdateLogs();
- }
-
- private void SelectAllTypes(ButtonEventArgs args)
- {
- SelectedTypes.Clear();
-
- foreach (var control in TypesContainer.Children)
- {
- if (control is not AdminLogTypeButton type)
- {
- continue;
- }
-
- type.Pressed = true;
- SelectedTypes.Add(type.Type);
- }
-
- UpdateLogs();
- }
-
- private void SelectNoTypes(ButtonEventArgs args)
- {
- SelectedTypes.Clear();
-
- foreach (var control in TypesContainer.Children)
- {
- if (control is not AdminLogTypeButton type)
- {
- continue;
- }
-
- type.Pressed = false;
- type.Visible = ShouldShowType(type);
- }
-
- UpdateLogs();
- }
-
- private void SelectAllPlayers(ButtonEventArgs args)
- {
- SelectedPlayers.Clear();
-
- foreach (var control in PlayersContainer.Children)
- {
- if (control is not AdminLogPlayerButton player)
- {
- continue;
- }
-
- player.Pressed = true;
- SelectedPlayers.Add(player.Id);
- }
-
- UpdateLogs();
- }
-
- private void SelectNoPlayers(ButtonEventArgs args)
- {
- SelectedPlayers.Clear();
-
- foreach (var control in PlayersContainer.Children)
- {
- if (control is not AdminLogPlayerButton player)
- {
- continue;
- }
-
- player.Pressed = false;
- }
-
- UpdateLogs();
- }
-
- public void UpdateTypes()
- {
- foreach (var control in TypesContainer.Children)
- {
- if (control is not AdminLogTypeButton type)
- {
- continue;
- }
-
- type.Visible = ShouldShowType(type);
- }
- }
-
- private void UpdatePlayers()
- {
- foreach (var control in PlayersContainer.Children)
- {
- if (control is not AdminLogPlayerButton player)
- {
- continue;
- }
-
- player.Visible = ShouldShowPlayer(player);
- }
- }
-
- private void UpdateLogs()
- {
- foreach (var child in LogsContainer.Children)
- {
- if (child is not AdminLogLabel log)
- {
- continue;
- }
-
- child.Visible = ShouldShowLog(log);
- }
- }
-
- private bool ShouldShowType(AdminLogTypeButton button)
- {
- return button.Text != null &&
- button.Text.Contains(TypeSearch.Text, StringComparison.OrdinalIgnoreCase);
- }
-
- private bool ShouldShowPlayer(AdminLogPlayerButton button)
- {
- return button.Text != null &&
- button.Text.Contains(PlayerSearch.Text, StringComparison.OrdinalIgnoreCase);
- }
-
- private bool ShouldShowLog(AdminLogLabel label)
- {
- return SelectedTypes.Contains(label.Log.Type) &&
- (SelectedPlayers.Count + label.Log.Players.Length == 0 || SelectedPlayers.Overlaps(label.Log.Players)) &&
- SelectedImpacts.Contains(label.Log.Impact) &&
- label.Log.Message.Contains(LogSearch.Text, StringComparison.OrdinalIgnoreCase);
- }
-
- private void TypeButtonPressed(ButtonEventArgs args)
- {
- var button = (AdminLogTypeButton) args.Button;
- if (button.Pressed)
- {
- SelectedTypes.Add(button.Type);
- }
- else
- {
- SelectedTypes.Remove(button.Type);
- }
-
- UpdateLogs();
- }
-
- private void PlayerButtonPressed(ButtonEventArgs args)
- {
- var button = (AdminLogPlayerButton) args.Button;
- if (button.Pressed)
- {
- SelectedPlayers.Add(button.Id);
- }
- else
- {
- SelectedPlayers.Remove(button.Id);
- }
-
- UpdateLogs();
- }
-
- private void ImpactButtonPressed(ButtonEventArgs args)
- {
- var button = (AdminLogImpactButton) args.Button;
- if (button.Pressed)
- {
- SelectedImpacts.Add(button.Impact);
- }
- else
- {
- SelectedImpacts.Remove(button.Impact);
- }
-
- UpdateLogs();
- }
-
- private void SetImpacts(LogImpact[] impacts)
- {
- LogImpactContainer.RemoveAllChildren();
-
- foreach (var impact in impacts)
- {
- var button = new AdminLogImpactButton(impact)
- {
- Text = impact.ToString()
- };
-
- SelectedImpacts.Add(impact);
- button.OnPressed += ImpactButtonPressed;
-
- LogImpactContainer.AddChild(button);
- }
-
- switch (impacts.Length)
- {
- case 0:
- return;
- case 1:
- LogImpactContainer.GetChild(0).StyleClasses.Add("OpenRight");
- return;
- }
-
- for (var i = 0; i < impacts.Length - 1; i++)
- {
- LogImpactContainer.GetChild(i).StyleClasses.Add("ButtonSquare");
- }
-
- LogImpactContainer.GetChild(LogImpactContainer.ChildCount - 1).StyleClasses.Add("OpenLeft");
- }
-
- private void SetTypes(LogType[] types)
- {
- var newTypes = types.ToHashSet();
- var buttons = new SortedSet(_adminLogTypeButtonComparer);
-
- foreach (var control in TypesContainer.Children.ToArray())
- {
- if (control is not AdminLogTypeButton type ||
- !newTypes.Remove(type.Type))
- {
- continue;
- }
-
- buttons.Add(type);
- }
-
- foreach (var type in newTypes)
- {
- var button = new AdminLogTypeButton(type)
- {
- Text = type.ToString(),
- Pressed = true
- };
-
- SelectedTypes.Add(type);
- button.OnPressed += TypeButtonPressed;
-
- buttons.Add(button);
- }
-
- TypesContainer.RemoveAllChildren();
-
- foreach (var type in buttons)
- {
- TypesContainer.AddChild(type);
- }
-
- UpdateLogs();
- }
-
- public void SetPlayers(Dictionary players)
- {
- var buttons = new SortedSet(_adminLogPlayerButtonComparer);
-
- foreach (var control in PlayersContainer.Children.ToArray())
- {
- if (control is not AdminLogPlayerButton player ||
- !players.Remove(player.Id))
- {
- continue;
- }
-
- buttons.Add(player);
- }
-
- foreach (var (id, name) in players)
- {
- var button = new AdminLogPlayerButton(id)
- {
- Text = name,
- Pressed = true
- };
-
- SelectedPlayers.Add(id);
- button.OnPressed += PlayerButtonPressed;
-
- buttons.Add(button);
- }
-
- PlayersContainer.RemoveAllChildren();
-
- foreach (var player in buttons)
- {
- PlayersContainer.AddChild(player);
- }
-
- UpdateLogs();
- }
-
- public void AddLogs(SharedAdminLog[] logs)
- {
- for (var i = 0; i < logs.Length; i++)
- {
- ref var log = ref logs[i];
- var separator = new HSeparator();
- var label = new AdminLogLabel(ref log, separator);
- label.Visible = ShouldShowLog(label);
-
- LogsContainer.AddChild(label);
- LogsContainer.AddChild(separator);
- }
- }
-
- public void SetLogs(SharedAdminLog[] logs)
- {
- LogsContainer.RemoveAllChildren();
- AddLogs(logs);
- }
-
- protected override void Dispose(bool disposing)
- {
- base.Dispose(disposing);
-
- TypeSearch.OnTextChanged -= TypeSearchChanged;
- PlayerSearch.OnTextChanged -= PlayerSearchChanged;
- LogSearch.OnTextChanged -= LogSearchChanged;
-
- SelectAllTypesButton.OnPressed -= SelectAllTypes;
- SelectNoTypesButton.OnPressed -= SelectNoTypes;
-
- SelectAllPlayersButton.OnPressed -= SelectAllPlayers;
- SelectNoPlayersButton.OnPressed -= SelectNoPlayers;
-
- RoundSpinBox.IsValid = null;
- RoundSpinBox.ValueChanged -= RoundSpinBoxChanged;
-
- ResetRoundButton.OnPressed -= ResetRoundPressed;
}
}
diff --git a/Content.Server/Administration/Commands/OpenAdminLogsCommand.cs b/Content.Server/Administration/Commands/OpenAdminLogsCommand.cs
index 4dc1e241f9..3bbbf8a375 100644
--- a/Content.Server/Administration/Commands/OpenAdminLogsCommand.cs
+++ b/Content.Server/Administration/Commands/OpenAdminLogsCommand.cs
@@ -1,5 +1,4 @@
using Content.Server.Administration.Logs;
-using Content.Server.Administration.UI;
using Content.Server.EUI;
using Content.Shared.Administration;
using Robust.Server.Player;
diff --git a/Content.Server/Administration/Logs/AdminLogsEui.cs b/Content.Server/Administration/Logs/AdminLogsEui.cs
index eb89b0f57e..02e66232ef 100644
--- a/Content.Server/Administration/Logs/AdminLogsEui.cs
+++ b/Content.Server/Administration/Logs/AdminLogsEui.cs
@@ -26,7 +26,6 @@ public sealed class AdminLogsEui : BaseEui
private readonly ISawmill _sawmill;
private readonly AdminLogSystem _logSystem;
- private readonly GameTicker _gameTicker;
private int _clientBatchSize;
private bool _isLoading = true;
@@ -43,7 +42,6 @@ public sealed class AdminLogsEui : BaseEui
_configuration.OnValueChanged(CCVars.AdminLogsClientBatchSize, ClientBatchSizeChanged, true);
_logSystem = EntitySystem.Get();
- _gameTicker = EntitySystem.Get();
_filter = new LogFilter
{
diff --git a/Resources/Locale/en-US/administration/ui/admin-logs.ftl b/Resources/Locale/en-US/administration/ui/admin-logs.ftl
index 0763fa68e8..64f7d8c834 100644
--- a/Resources/Locale/en-US/administration/ui/admin-logs.ftl
+++ b/Resources/Locale/en-US/administration/ui/admin-logs.ftl
@@ -1,4 +1,5 @@
admin-logs-title = Admin Logs Panel
+admin-logs-pop-out = Pop Out
# Round
admin-logs-round = Round{" "}