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:
Jezithyr
2022-10-12 01:16:23 -07:00
committed by GitHub
parent d09fbc1849
commit 571dd4e6d5
168 changed files with 6940 additions and 7817 deletions

View File

@@ -1,8 +1,8 @@
using Content.Client.Gameplay;
using Content.Client.HUD;
using Content.Client.Markers;
using Content.Client.Sandbox;
using Content.Client.SubFloor;
using Content.Client.UserInterface.Controls;
using Content.Client.UserInterface.Systems.DecalPlacer;
using Content.Client.UserInterface.Systems.Sandbox.Windows;
using Content.Shared.Input;
@@ -13,11 +13,11 @@ using Robust.Client.Input;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controllers;
using Robust.Client.UserInterface.Controllers.Implementations;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.Input.Binding;
using Robust.Shared.Map;
using Robust.Shared.Players;
using Robust.Shared.Utility;
using static Robust.Client.UserInterface.Controls.BaseButton;
namespace Content.Client.UserInterface.Systems.Sandbox;
@@ -28,7 +28,6 @@ public sealed class SandboxUIController : UIController, IOnStateChanged<Gameplay
[Dependency] private readonly IEyeManager _eye = default!;
[Dependency] private readonly IInputManager _input = default!;
[Dependency] private readonly ILightManager _light = default!;
[Dependency] private readonly IGameHud _gameHud = default!;
[UISystemDependency] private readonly DebugPhysicsSystem _debugPhysics = default!;
[UISystemDependency] private readonly MarkerSystem _marker = default!;
@@ -42,11 +41,14 @@ public sealed class SandboxUIController : UIController, IOnStateChanged<Gameplay
private TileSpawningUIController TileSpawningController => UIManager.GetUIController<TileSpawningUIController>();
private DecalPlacerUIController DecalPlacerController => UIManager.GetUIController<DecalPlacerUIController>();
private MenuButton? _sandboxButton;
public void OnStateEntered(GameplayState state)
{
DebugTools.Assert(_window == null);
_sandboxButton = UIManager.GetActiveUIWidget<MenuBar.Widgets.GameTopMenuBar>().SandboxButton;
_sandboxButton.OnPressed += SandboxButtonPressed;
EnsureWindow();
_gameHud.SandboxButtonToggled += GameHudOnSandboxButtonToggled;
_input.SetInputCommand(ContentKeyFunctions.OpenEntitySpawnWindow,
InputCmdHandler.FromDelegate(_ => EntitySpawningController.ToggleWindow()));
@@ -67,8 +69,8 @@ public sealed class SandboxUIController : UIController, IOnStateChanged<Gameplay
if(_window is { Disposed: false })
return;
_window = UIManager.CreateWindow<SandboxWindow>();
_window.OnClose += () => { _gameHud.SandboxButtonDown = false; };
_window.OnOpen += () => { _gameHud.SandboxButtonDown = true; };
_window.OnOpen += () => { _sandboxButton!.Pressed = true; };
_window.OnClose += () => { _sandboxButton!.Pressed = false; };
_window.ToggleLightButton.Pressed = !_light.Enabled;
_window.ToggleFovButton.Pressed = !_eye.CurrentEye.DrawFov;
_window.ToggleShadowsButton.Pressed = !_light.DrawShadows;
@@ -105,8 +107,12 @@ public sealed class SandboxUIController : UIController, IOnStateChanged<Gameplay
_window = null;
}
_gameHud.SandboxButtonToggled -= GameHudOnSandboxButtonToggled;
_gameHud.SandboxButtonDown = false;
if (_sandboxButton != null)
{
_sandboxButton.Pressed = false;
_sandboxButton.OnPressed -= SandboxButtonPressed;
_sandboxButton = null;
}
CommandBinds.Unregister<SandboxSystem>();
}
@@ -121,6 +127,11 @@ public sealed class SandboxUIController : UIController, IOnStateChanged<Gameplay
system.SandboxDisabled -= CloseAll;
}
private void SandboxButtonPressed(ButtonEventArgs args)
{
ToggleWindow();
}
private void CloseAll()
{
_window?.Close();