Hud refactor (#7202)
Co-authored-by: DrSmugleaf <DrSmugleaf@users.noreply.github.com> Co-authored-by: Jezithyr <jmaster9999@gmail.com> Co-authored-by: Jezithyr <Jezithyr@gmail.com> Co-authored-by: Visne <39844191+Visne@users.noreply.github.com> Co-authored-by: wrexbe <wrexbe@protonmail.com> Co-authored-by: wrexbe <81056464+wrexbe@users.noreply.github.com>
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
using Content.Client.Gameplay;
|
||||
using Content.Client.HUD;
|
||||
using Content.Client.Info;
|
||||
using Content.Client.Links;
|
||||
using Content.Client.UserInterface.Controls;
|
||||
using Content.Client.UserInterface.Systems.Info;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.Console;
|
||||
using Robust.Client.Input;
|
||||
@@ -20,18 +20,20 @@ public sealed class EscapeUIController : UIController, IOnStateEntered<GameplayS
|
||||
{
|
||||
[Dependency] private readonly IClientConsoleHost _console = default!;
|
||||
[Dependency] private readonly IUriOpener _uri = default!;
|
||||
[Dependency] private readonly IGameHud _gameHud = default!;
|
||||
|
||||
private Options.UI.EscapeMenu? _escapeWindow;
|
||||
|
||||
private MenuButton? _escapeButton;
|
||||
|
||||
public void OnStateEntered(GameplayState state)
|
||||
{
|
||||
DebugTools.Assert(_escapeWindow == null);
|
||||
_gameHud.EscapeButtonToggled += GameHudOnEscapeButtonToggled;
|
||||
_escapeButton = UIManager.GetActiveUIWidget<MenuBar.Widgets.GameTopMenuBar>().EscapeButton;
|
||||
_escapeButton.OnPressed += EscapeButtonOnOnPressed;
|
||||
|
||||
_escapeWindow = UIManager.CreateWindow<Options.UI.EscapeMenu>();
|
||||
_escapeWindow.OnClose += () => { _gameHud.EscapeButtonDown = false; };
|
||||
_escapeWindow.OnOpen += () => { _gameHud.EscapeButtonDown = true; };
|
||||
_escapeWindow.OnClose += () => { _escapeButton.Pressed = false; };
|
||||
_escapeWindow.OnOpen += () => { _escapeButton.Pressed = true; };
|
||||
|
||||
_escapeWindow.ChangelogButton.OnPressed += _ =>
|
||||
{
|
||||
@@ -43,7 +45,7 @@ public sealed class EscapeUIController : UIController, IOnStateEntered<GameplayS
|
||||
_escapeWindow.RulesButton.OnPressed += _ =>
|
||||
{
|
||||
CloseEscapeWindow();
|
||||
new RulesAndInfoWindow().Open();
|
||||
UIManager.GetUIController<InfoUIController>().OpenWindow();
|
||||
};
|
||||
|
||||
_escapeWindow.DisconnectButton.OnPressed += _ =>
|
||||
@@ -75,11 +77,6 @@ public sealed class EscapeUIController : UIController, IOnStateEntered<GameplayS
|
||||
.Register<EscapeUIController>();
|
||||
}
|
||||
|
||||
private void GameHudOnEscapeButtonToggled(bool obj)
|
||||
{
|
||||
ToggleWindow();
|
||||
}
|
||||
|
||||
public void OnStateExited(GameplayState state)
|
||||
{
|
||||
if (_escapeWindow != null)
|
||||
@@ -87,12 +84,22 @@ public sealed class EscapeUIController : UIController, IOnStateEntered<GameplayS
|
||||
_escapeWindow.Dispose();
|
||||
_escapeWindow = null;
|
||||
}
|
||||
_gameHud.EscapeButtonToggled -= GameHudOnEscapeButtonToggled;
|
||||
_gameHud.EscapeButtonDown = false;
|
||||
|
||||
if (_escapeButton != null)
|
||||
{
|
||||
_escapeButton.OnPressed -= EscapeButtonOnOnPressed;
|
||||
_escapeButton.Pressed = false;
|
||||
_escapeButton = null;
|
||||
}
|
||||
|
||||
CommandBinds.Unregister<EscapeUIController>();
|
||||
}
|
||||
|
||||
private void EscapeButtonOnOnPressed(ButtonEventArgs obj)
|
||||
{
|
||||
ToggleWindow();
|
||||
}
|
||||
|
||||
private void CloseEscapeWindow()
|
||||
{
|
||||
_escapeWindow?.Close();
|
||||
@@ -110,6 +117,7 @@ public sealed class EscapeUIController : UIController, IOnStateEntered<GameplayS
|
||||
else
|
||||
{
|
||||
_escapeWindow.OpenCentered();
|
||||
_escapeButton!.Pressed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user