Make admin ahelp window remember its last position (#14209)
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user