Oldchat fixes (#12009)

* various fixes

* whoops

* oops

* oop

* removes that call from escape button on unload instead of adding another one

also just moves escape window stuff into the state entered call, as only one is instantiated whenever the state is loaded (and is not dependent on the current screen)
This commit is contained in:
Flipp Syder
2022-10-17 18:01:28 -07:00
committed by GitHub
parent 2cd8bc8489
commit c828c53b91
4 changed files with 39 additions and 47 deletions

View File

@@ -106,6 +106,8 @@ namespace Content.Client.Gameplay
{
_chatController.SetMainChat(false);
_menuController.UnloadButtons();
_ghostController.UnloadGui();
_actionController.UnloadGui();
_uiManager.UnloadScreen();
}
@@ -132,8 +134,8 @@ namespace Content.Client.Gameplay
_menuController.LoadButtons();
// TODO: This could just be like, the equivalent of an event or something
_ghostController.UpdateGui();
_actionController.RegisterActionContainer();
_ghostController.LoadGui();
_actionController.LoadGui();
_alertsController.SyncAlerts();
_hotbarController.ReloadHotbar();

View File

@@ -51,7 +51,7 @@ public sealed class ActionUIController : UIController, IOnStateChanged<GameplayS
private readonly TextureRect _dragShadow;
private ActionsWindow? _window;
private ActionsBar? _actionsBar;
private ActionsBar? ActionsBar => UIManager.GetActiveUIWidgetOrNull<ActionsBar>();
private MenuButton? ActionButton => UIManager.GetActiveUIWidgetOrNull<MenuBar.Widgets.GameTopMenuBar>()?.ActionButton;
private ActionPage CurrentPage => _pages[_currentPageIndex];
@@ -88,7 +88,6 @@ public sealed class ActionUIController : UIController, IOnStateChanged<GameplayS
DebugTools.Assert(_window == null);
_window = UIManager.CreateWindow<ActionsWindow>();
_actionsBar = UIManager.GetActiveUIWidget<ActionsBar>();
LayoutContainer.SetAnchorPreset(_window, LayoutContainer.LayoutPreset.CenterTop);
_window.OnOpen += OnWindowOpened;
@@ -96,8 +95,7 @@ public sealed class ActionUIController : UIController, IOnStateChanged<GameplayS
_window.ClearButton.OnPressed += OnClearPressed;
_window.SearchBar.OnTextChanged += OnSearchChanged;
_window.FilterButton.OnItemSelected += OnFilterSelected;
_actionsBar.PageButtons.LeftArrow.OnPressed += OnLeftArrowPressed;
_actionsBar.PageButtons.RightArrow.OnPressed += OnRightArrowPressed;
if (_actionsSystem != null)
{
@@ -198,12 +196,6 @@ public sealed class ActionUIController : UIController, IOnStateChanged<GameplayS
_window = null;
}
if (_actionsBar != null)
{
_actionsBar.PageButtons.LeftArrow.OnPressed += OnLeftArrowPressed;
_actionsBar.PageButtons.RightArrow.OnPressed += OnRightArrowPressed;
}
CommandBinds.Unregister<ActionUIController>();
}
@@ -231,7 +223,7 @@ public sealed class ActionUIController : UIController, IOnStateChanged<GameplayS
var page = _pages[_currentPageIndex];
_container?.SetActionData(page);
_actionsBar!.PageButtons.Label.Text = $"{_currentPageIndex + 1}";
ActionsBar!.PageButtons.Label.Text = $"{_currentPageIndex + 1}";
}
private void OnLeftArrowPressed(ButtonEventArgs args)
@@ -621,25 +613,35 @@ public sealed class ActionUIController : UIController, IOnStateChanged<GameplayS
public void ReloadActionContainer()
{
RegisterActionContainer();
UnloadGui();
LoadGui();
}
public void RegisterActionContainer()
public void UnloadGui()
{
if (UIManager.ActiveScreen == null)
{
return;
}
var widget = UIManager.ActiveScreen.GetWidget<ActionsBar>();
if (widget == null)
{
return;
}
_actionsSystem?.UnlinkAllActions();
RegisterActionContainer(widget.ActionsContainer);
if (ActionsBar == null)
{
return;
}
ActionsBar.PageButtons.LeftArrow.OnPressed -= OnLeftArrowPressed;
ActionsBar.PageButtons.RightArrow.OnPressed -= OnRightArrowPressed;
}
public void LoadGui()
{
if (ActionsBar == null)
{
return;
}
ActionsBar.PageButtons.LeftArrow.OnPressed += OnLeftArrowPressed;
ActionsBar.PageButtons.RightArrow.OnPressed += OnRightArrowPressed;
RegisterActionContainer(ActionsBar.ActionsContainer);
_actionsSystem?.LinkAllActions();
}

View File

@@ -36,15 +36,7 @@ public sealed class EscapeUIController : UIController, IOnStateEntered<GameplayS
}
EscapeButton.Pressed = false;
EscapeButton.OnPressed += EscapeButtonOnOnPressed;
if (_escapeWindow == null)
{
return;
}
_escapeWindow.OnClose -= DeactivateButton;
_escapeWindow.OnOpen -= ActivateButton;
EscapeButton.OnPressed -= EscapeButtonOnOnPressed;
}
public void LoadButton()
@@ -55,14 +47,6 @@ public sealed class EscapeUIController : UIController, IOnStateEntered<GameplayS
}
EscapeButton.OnPressed += EscapeButtonOnOnPressed;
if (_escapeWindow == null)
{
return;
}
_escapeWindow.OnClose += DeactivateButton;
_escapeWindow.OnOpen += ActivateButton;
}
private void ActivateButton() => EscapeButton!.Pressed = true;
@@ -74,6 +58,9 @@ public sealed class EscapeUIController : UIController, IOnStateEntered<GameplayS
_escapeWindow = UIManager.CreateWindow<Options.UI.EscapeMenu>();
_escapeWindow.OnClose += DeactivateButton;
_escapeWindow.OnOpen += ActivateButton;
_escapeWindow.ChangelogButton.OnPressed += _ =>
{
CloseEscapeWindow();
@@ -144,6 +131,7 @@ public sealed class EscapeUIController : UIController, IOnStateEntered<GameplayS
if (_escapeWindow.IsOpen)
{
CloseEscapeWindow();
EscapeButton!.Pressed = false;
}
else
{

View File

@@ -8,7 +8,7 @@ using Robust.Client.UserInterface.Controllers;
namespace Content.Client.UserInterface.Systems.Ghost;
// TODO hud refactor BEFORE MERGE fix ghost gui being too far up
public sealed class GhostUIController : UIController, IOnStateChanged<GameplayState>, IOnSystemChanged<GhostSystem>
public sealed class GhostUIController : UIController, IOnSystemChanged<GhostSystem>
{
[Dependency] private readonly IEntityNetworkManager _net = default!;
@@ -91,7 +91,7 @@ public sealed class GhostUIController : UIController, IOnStateChanged<GameplaySt
_net.SendSystemNetworkMessage(msg);
}
public void OnStateEntered(GameplayState state)
public void LoadGui()
{
if (Gui == null)
return;
@@ -104,7 +104,7 @@ public sealed class GhostUIController : UIController, IOnStateChanged<GameplaySt
UpdateGui();
}
public void OnStateExited(GameplayState state)
public void UnloadGui()
{
if (Gui == null)
return;