]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Make admin ahelp window remember its last position (#14209)
authorDrSmugleaf <DrSmugleaf@users.noreply.github.com>
Tue, 21 Feb 2023 19:31:27 +0000 (20:31 +0100)
committerGitHub <noreply@github.com>
Tue, 21 Feb 2023 19:31:27 +0000 (20:31 +0100)
Content.Client/UserInterface/Systems/Bwoink/AHelpUIController.cs

index 9915361652b8ff7ae0d3f1efe429abc59aff8e13..2e1f86acd43f5c186a51a2d34a6c725fd8824da7 100644 (file)
@@ -2,12 +2,9 @@ using System.Diagnostics.CodeAnalysis;
 using System.Linq;
 using Content.Client.Administration.Managers;
 using Content.Client.Administration.Systems;
-using Content.Client.Administration.UI;
 using Content.Client.Administration.UI.Bwoink;
-using Content.Client.Administration.UI.CustomControls;
 using Content.Client.Gameplay;
 using Content.Client.UserInterface.Controls;
-using Content.Client.UserInterface.Systems.Info;
 using Content.Shared.Administration;
 using Content.Shared.Input;
 using JetBrains.Annotations;
@@ -22,7 +19,6 @@ using Robust.Shared.Input.Binding;
 using Robust.Shared.Network;
 using Robust.Shared.Player;
 using Robust.Shared.Utility;
-using BwoinkPanel = Content.Client.Administration.UI.Bwoink.BwoinkPanel;
 
 namespace Content.Client.UserInterface.Systems.Bwoink;
 
@@ -196,6 +192,7 @@ public sealed class AHelpUIController: UIController, IOnStateChanged<GameplaySta
         helper.Control.Orphan();
         helper.Window.Dispose();
         helper.Window = null;
+        helper.EverOpened = false;
 
         var monitor = _clyde.EnumerateMonitors().First();
 
@@ -220,7 +217,7 @@ public sealed class AHelpUIController: UIController, IOnStateChanged<GameplaySta
 }
 
 // please kill all this indirection
-public interface IAHelpUIHandler: IDisposable
+public interface IAHelpUIHandler : IDisposable
 {
     public bool IsAdmin { get; }
     public bool IsOpen { get; }
@@ -242,6 +239,7 @@ public sealed class AdminAHelpUIHandler : IAHelpUIHandler
     private readonly Dictionary<NetUserId, BwoinkPanel> _activePanelMap = new();
     public bool IsAdmin => true;
     public bool IsOpen => Window is { Disposed: false, IsOpen: true } || ClydeWindow is { IsDisposed: false };
+    public bool EverOpened;
 
     public BwoinkWindow? Window;
     public WindowRoot? WindowRoot;
@@ -282,13 +280,19 @@ public sealed class AdminAHelpUIHandler : IAHelpUIHandler
     public void ToggleWindow()
     {
         EnsurePanel(_ownerId);
+
         if (IsOpen)
         {
             Close();
         }
         else
         {
-            Window!.OpenCentered();
+            if (EverOpened)
+                Window!.Open();
+            else
+                Window!.OpenCentered();
+
+            EverOpened = true;
         }
     }
 
@@ -315,7 +319,11 @@ public sealed class AdminAHelpUIHandler : IAHelpUIHandler
         Window = new BwoinkWindow();
         Control = Window.Bwoink;
         Window.OnClose += () => { OnClose?.Invoke(); };
-        Window.OnOpen += () => { OnOpen?.Invoke(); };
+        Window.OnOpen += () =>
+        {
+            OnOpen?.Invoke();
+            EverOpened = true;
+        };
 
         // need to readd any unattached panels..
         foreach (var (_, panel) in _activePanelMap)
@@ -356,8 +364,10 @@ public sealed class AdminAHelpUIHandler : IAHelpUIHandler
         Window = null;
         Control = null;
         _activePanelMap.Clear();
+        EverOpened = false;
     }
 }
+
 public sealed class UserAHelpUIHandler : IAHelpUIHandler
 {
     private readonly NetUserId _ownerId;