Screen load event for GameplayState (#14316)

Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
Flipp Syder
2023-03-10 19:25:56 -08:00
committed by GitHub
parent 20eb8f9178
commit 3eb8f70985
9 changed files with 141 additions and 49 deletions

View File

@@ -10,6 +10,7 @@ using Content.Client.UserInterface.Controls;
using Content.Client.UserInterface.Systems.Actions.Controls;
using Content.Client.UserInterface.Systems.Actions.Widgets;
using Content.Client.UserInterface.Systems.Actions.Windows;
using Content.Client.UserInterface.Systems.Gameplay;
using Content.Shared.Actions;
using Content.Shared.Actions.ActionTypes;
using Content.Shared.Input;
@@ -87,6 +88,25 @@ public sealed class ActionUIController : UIController, IOnStateChanged<GameplayS
}
}
public override void Initialize()
{
base.Initialize();
var gameplayStateLoad = UIManager.GetUIController<GameplayStateLoadController>();
gameplayStateLoad.OnScreenLoad += OnScreenLoad;
gameplayStateLoad.OnScreenUnload += OnScreenUnload;
}
private void OnScreenLoad()
{
LoadGui();
}
private void OnScreenUnload()
{
UnloadGui();
}
public void OnStateEntered(GameplayState state)
{
DebugTools.Assert(_window == null);

View File

@@ -1,6 +1,7 @@
using Content.Client.Alerts;
using Content.Client.Gameplay;
using Content.Client.UserInterface.Systems.Alerts.Widgets;
using Content.Client.UserInterface.Systems.Gameplay;
using Content.Shared.Alert;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controllers;
@@ -13,6 +14,19 @@ public sealed class AlertsUIController : UIController, IOnStateEntered<GameplayS
private AlertsUI? UI => UIManager.GetActiveUIWidgetOrNull<AlertsUI>();
public override void Initialize()
{
base.Initialize();
var gameplayStateLoad = UIManager.GetUIController<GameplayStateLoadController>();
gameplayStateLoad.OnScreenLoad += OnScreenLoad;
}
private void OnScreenLoad()
{
SyncAlerts();
}
private void OnAlertPressed(object? sender, AlertType e)
{
_alertsSystem?.AlertClicked(e);

View File

@@ -11,6 +11,7 @@ using Content.Client.Ghost;
using Content.Client.Lobby.UI;
using Content.Client.UserInterface.Screens;
using Content.Client.UserInterface.Systems.Chat.Widgets;
using Content.Client.UserInterface.Systems.Gameplay;
using Content.Shared.Administration;
using Content.Shared.CCVar;
using Content.Shared.Chat;
@@ -183,6 +184,23 @@ public sealed class ChatUIController : UIController
_input.SetInputCommand(ContentKeyFunctions.CycleChatChannelBackward,
InputCmdHandler.FromDelegate(_ => CycleChatChannel(false)));
var gameplayStateLoad = UIManager.GetUIController<GameplayStateLoadController>();
gameplayStateLoad.OnScreenLoad += OnScreenLoad;
gameplayStateLoad.OnScreenUnload += OnScreenUnload;
}
public void OnScreenLoad()
{
SetMainChat(true);
var viewportContainer = UIManager.ActiveScreen!.FindControl<LayoutContainer>("ViewportContainer");
SetSpeechBubbleRoot(viewportContainer);
}
public void OnScreenUnload()
{
SetMainChat(false);
}
public void SetMainChat(bool setting)

View File

@@ -0,0 +1,30 @@
using Content.Client.Gameplay;
using Robust.Client.UserInterface.Controllers;
namespace Content.Client.UserInterface.Systems.Gameplay;
public sealed class GameplayStateLoadController : UIController, IOnStateChanged<GameplayState>
{
public Action? OnScreenLoad;
public Action? OnScreenUnload;
public void OnStateEntered(GameplayState state)
{
LoadScreen();
}
public void OnStateExited(GameplayState state)
{
UnloadScreen();
}
public void UnloadScreen()
{
OnScreenUnload?.Invoke();
}
public void LoadScreen()
{
OnScreenLoad?.Invoke();
}
}

View File

@@ -1,5 +1,6 @@
using Content.Client.Gameplay;
using Content.Client.Ghost;
using Content.Client.UserInterface.Systems.Gameplay;
using Content.Client.UserInterface.Systems.Ghost.Widgets;
using Content.Shared.Ghost;
using Robust.Client.UserInterface;
@@ -16,6 +17,25 @@ public sealed class GhostUIController : UIController, IOnSystemChanged<GhostSyst
private GhostGui? Gui => UIManager.GetActiveUIWidgetOrNull<GhostGui>();
public override void Initialize()
{
base.Initialize();
var gameplayStateLoad = UIManager.GetUIController<GameplayStateLoadController>();
gameplayStateLoad.OnScreenLoad += OnScreenLoad;
gameplayStateLoad.OnScreenUnload += OnScreenUnload;
}
private void OnScreenLoad()
{
LoadGui();
}
private void OnScreenUnload()
{
UnloadGui();
}
public void OnSystemLoaded(GhostSystem system)
{
system.PlayerRemoved += OnPlayerRemoved;

View File

@@ -1,4 +1,5 @@
using Content.Client.UserInterface.Systems.Hands;
using Content.Client.UserInterface.Systems.Gameplay;
using Content.Client.UserInterface.Systems.Hands;
using Content.Client.UserInterface.Systems.Hands.Controls;
using Content.Client.UserInterface.Systems.Hotbar.Widgets;
using Content.Client.UserInterface.Systems.Inventory;
@@ -13,6 +14,19 @@ public sealed class HotbarUIController : UIController
private InventoryUIController? _inventory;
private HandsUIController? _hands;
public override void Initialize()
{
base.Initialize();
var gameplayStateLoad = UIManager.GetUIController<GameplayStateLoadController>();
gameplayStateLoad.OnScreenLoad += OnScreenLoad;
}
private void OnScreenLoad()
{
ReloadHotbar();
}
public void Setup(HandsContainer handsContainer, ItemSlotButtonContainer inventoryBar, ItemStatusPanel handStatus)
{
_inventory = UIManager.GetUIController<InventoryUIController>();

View File

@@ -5,6 +5,7 @@ using Content.Client.UserInterface.Systems.Bwoink;
using Content.Client.UserInterface.Systems.Character;
using Content.Client.UserInterface.Systems.Crafting;
using Content.Client.UserInterface.Systems.EscapeMenu;
using Content.Client.UserInterface.Systems.Gameplay;
using Content.Client.UserInterface.Systems.Inventory;
using Content.Client.UserInterface.Systems.MenuBar.Widgets;
using Content.Client.UserInterface.Systems.Sandbox;
@@ -25,6 +26,15 @@ public sealed class GameTopMenuBarUIController : UIController
private GameTopMenuBar? GameTopMenuBar => UIManager.GetActiveUIWidgetOrNull<GameTopMenuBar>();
public override void Initialize()
{
base.Initialize();
var gameplayStateLoad = UIManager.GetUIController<GameplayStateLoadController>();
gameplayStateLoad.OnScreenLoad += LoadButtons;
gameplayStateLoad.OnScreenUnload += UnloadButtons;
}
public void UnloadButtons()
{
_escape.UnloadButton();

View File

@@ -1,4 +1,5 @@
using Content.Client.UserInterface.Controls;
using Content.Client.UserInterface.Systems.Gameplay;
using Content.Shared.CCVar;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
@@ -25,6 +26,14 @@ public sealed class ViewportUIController : UIController
_configurationManager.OnValueChanged(CCVars.ViewportMinimumWidth, _ => UpdateViewportRatio());
_configurationManager.OnValueChanged(CCVars.ViewportMaximumWidth, _ => UpdateViewportRatio());
_configurationManager.OnValueChanged(CCVars.ViewportWidth, _ => UpdateViewportRatio());
var gameplayStateLoad = UIManager.GetUIController<GameplayStateLoadController>();
gameplayStateLoad.OnScreenLoad += OnScreenLoad;
}
private void OnScreenLoad()
{
ReloadViewport();
}
private void UpdateViewportRatio()