From 7929600def16076a289ca5be8f4411f65d8ade1b Mon Sep 17 00:00:00 2001 From: DrSmugleaf Date: Wed, 8 Dec 2021 23:03:08 +0100 Subject: [PATCH] Move admin logs into their own separate window --- .../Administration/UI/Logs/AdminLogsEui.cs | 72 ++++++++---- .../UI/Logs/AdminLogsWindow.xaml | 109 +++++++++--------- .../UI/Logs/AdminLogsWindow.xaml.cs | 4 +- 3 files changed, 109 insertions(+), 76 deletions(-) diff --git a/Content.Client/Administration/UI/Logs/AdminLogsEui.cs b/Content.Client/Administration/UI/Logs/AdminLogsEui.cs index 00cc21671d..5f4c57c63b 100644 --- a/Content.Client/Administration/UI/Logs/AdminLogsEui.cs +++ b/Content.Client/Administration/UI/Logs/AdminLogsEui.cs @@ -4,6 +4,10 @@ using Content.Shared.Administration; using Content.Shared.Administration.Logs; using Content.Shared.Eui; using JetBrains.Annotations; +using Robust.Client.Graphics; +using Robust.Client.UserInterface; +using Robust.Client.UserInterface.Controls; +using Robust.Shared.IoC; using static Content.Shared.Administration.AdminLogsEuiMsg; namespace Content.Client.Administration.UI.Logs; @@ -11,28 +15,54 @@ namespace Content.Client.Administration.UI.Logs; [UsedImplicitly] public class AdminLogsEui : BaseEui { + [Dependency] private readonly IClyde _clyde = default!; + [Dependency] private readonly IUserInterfaceManager _uiManager = default!; + public AdminLogsEui() { - Window = new AdminLogsWindow(); - Window.OnClose += () => SendMessage(new Close()); - Window.LogSearch.OnTextEntered += _ => RequestLogs(); - Window.RefreshButton.OnPressed += _ => RequestLogs(); - Window.NextButton.OnPressed += _ => NextLogs(); + 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(); + + Root = _uiManager.CreateWindowRoot(ClydeWindow); + Root.AddChild(LogsWindow); } - private AdminLogsWindow Window { get; } + private WindowRoot Root { get; } + + private IClydeWindow ClydeWindow { get; } + + private AdminLogsWindow LogsWindow { get; } private bool FirstState { get; set; } = true; + private void OnRequestClosed(WindowRequestClosedEventArgs args) + { + SendMessage(new Close()); + } + private void RequestLogs() { var request = new LogsRequest( - Window.SelectedRoundId, - Window.SelectedTypes.ToList(), + LogsWindow.SelectedRoundId, + LogsWindow.SelectedTypes.ToList(), null, null, null, - Window.SelectedPlayers.ToArray(), + LogsWindow.SelectedPlayers.ToArray(), null, null, DateOrder.Descending); @@ -54,16 +84,11 @@ public class AdminLogsEui : BaseEui } FirstState = false; - Window.SetCurrentRound(state.RoundId); - Window.SetRoundSpinBox(state.RoundId); + LogsWindow.SetCurrentRound(state.RoundId); + LogsWindow.SetRoundSpinBox(state.RoundId); return true; } - public override void Opened() - { - Window.OpenCentered(); - } - public override void HandleState(EuiStateBase state) { var s = (AdminLogsEuiState) state; @@ -75,8 +100,8 @@ public class AdminLogsEui : BaseEui return; } - Window.SetCurrentRound(s.RoundId); - Window.SetPlayers(s.Players); + LogsWindow.SetCurrentRound(s.RoundId); + LogsWindow.SetPlayers(s.Players); if (first) { @@ -91,10 +116,10 @@ public class AdminLogsEui : BaseEui switch (msg) { case NewLogs {Replace: true} newLogs: - Window.SetLogs(newLogs.Logs); + LogsWindow.SetLogs(newLogs.Logs); break; case NewLogs {Replace: false} newLogs: - Window.AddLogs(newLogs.Logs); + LogsWindow.AddLogs(newLogs.Logs); break; } } @@ -103,7 +128,10 @@ public class AdminLogsEui : BaseEui { base.Closed(); - Window.Close(); - Window.Dispose(); + ClydeWindow.RequestClosed -= OnRequestClosed; + + 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 1b47d0ee02..c52e9d8076 100644 --- a/Content.Client/Administration/UI/Logs/AdminLogsWindow.xaml +++ b/Content.Client/Administration/UI/Logs/AdminLogsWindow.xaml @@ -1,59 +1,64 @@ - - - - -