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:
@@ -0,0 +1,34 @@
|
||||
using Content.Client.Construction.UI;
|
||||
using Content.Client.Gameplay;
|
||||
using Content.Client.UserInterface.Controls;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.UserInterface.Controllers;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Client.UserInterface.Systems.Crafting;
|
||||
|
||||
[UsedImplicitly]
|
||||
public sealed class CraftingUIController : UIController, IOnStateChanged<GameplayState>
|
||||
{
|
||||
private ConstructionMenuPresenter? _presenter;
|
||||
private MenuButton? _craftingButton;
|
||||
|
||||
public void OnStateEntered(GameplayState state)
|
||||
{
|
||||
DebugTools.Assert(_presenter == null);
|
||||
_presenter = new ConstructionMenuPresenter();
|
||||
_craftingButton = UIManager.GetActiveUIWidget<MenuBar.Widgets.GameTopMenuBar>().CraftingButton;
|
||||
_craftingButton.OnToggled += _presenter.OnHudCraftingButtonToggled;
|
||||
}
|
||||
|
||||
public void OnStateExited(GameplayState state)
|
||||
{
|
||||
if (_presenter == null)
|
||||
return;
|
||||
_craftingButton!.Pressed = false;
|
||||
_craftingButton!.OnToggled -= _presenter.OnHudCraftingButtonToggled;
|
||||
_craftingButton = null;
|
||||
_presenter.Dispose();
|
||||
_presenter = null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user