-using Content.Client.Construction.UI;
using Content.Client.Hands;
using Content.Client.UserInterface.Controls;
using Content.Client.UserInterface.Screens;
-using Content.Client.UserInterface.Systems.Actions;
-using Content.Client.UserInterface.Systems.Alerts;
-using Content.Client.UserInterface.Systems.Chat;
-using Content.Client.UserInterface.Systems.Chat.Widgets;
-using Content.Client.UserInterface.Systems.Ghost;
-using Content.Client.UserInterface.Systems.Hands;
-using Content.Client.UserInterface.Systems.Hotbar;
-using Content.Client.UserInterface.Systems.Hotbar.Widgets;
-using Content.Client.UserInterface.Systems.Inventory;
-using Content.Client.UserInterface.Systems.MenuBar;
-using Content.Client.UserInterface.Systems.Viewport;
+using Content.Client.UserInterface.Systems.Gameplay;
using Content.Client.Viewport;
using Content.Shared.CCVar;
using Robust.Client.Graphics;
using Robust.Client.Input;
using Robust.Client.UserInterface;
-using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls;
using Robust.Shared.Configuration;
using Robust.Shared.Timing;
-using Robust.Client.Player;
-using Robust.Client.GameObjects;
namespace Content.Client.Gameplay
{
public MainViewport Viewport => _uiManager.ActiveScreen!.GetWidget<MainViewport>()!;
- private readonly GhostUIController _ghostController;
- private readonly ActionUIController _actionController;
- private readonly AlertsUIController _alertsController;
- private readonly HotbarUIController _hotbarController;
- private readonly ChatUIController _chatController;
- private readonly ViewportUIController _viewportController;
- private readonly GameTopMenuBarUIController _menuController;
+ private readonly GameplayStateLoadController _loadController;
public GameplayState()
{
IoCManager.InjectDependencies(this);
- _ghostController = _uiManager.GetUIController<GhostUIController>();
- _actionController = _uiManager.GetUIController<ActionUIController>();
- _alertsController = _uiManager.GetUIController<AlertsUIController>();
- _hotbarController = _uiManager.GetUIController<HotbarUIController>();
- _chatController = _uiManager.GetUIController<ChatUIController>();
- _viewportController = _uiManager.GetUIController<ViewportUIController>();
- _menuController = _uiManager.GetUIController<GameTopMenuBarUIController>();
+ _loadController = _uiManager.GetUIController<GameplayStateLoadController>();
}
protected override void Startup()
private void UnloadMainScreen()
{
- _chatController.SetMainChat(false);
- _menuController.UnloadButtons();
- _ghostController.UnloadGui();
- _actionController.UnloadGui();
+ _loadController.UnloadScreen();
_uiManager.UnloadScreen();
}
{
case ScreenType.Default:
_uiManager.LoadScreen<DefaultGameScreen>();
-
break;
case ScreenType.Separated:
_uiManager.LoadScreen<SeparatedChatGameScreen>();
break;
}
- _chatController.SetMainChat(true);
- _viewportController.ReloadViewport();
- _menuController.LoadButtons();
-
- // TODO: This could just be like, the equivalent of an event or something
- _ghostController.LoadGui();
- _actionController.LoadGui();
- _alertsController.SyncAlerts();
- _hotbarController.ReloadHotbar();
-
- var viewportContainer = _uiManager.ActiveScreen!.FindControl<LayoutContainer>("ViewportContainer");
- _chatController.SetSpeechBubbleRoot(viewportContainer);
+ _loadController.LoadScreen();
}
-
-
protected override void OnKeyBindStateChanged(ViewportBoundKeyEventArgs args)
{
if (args.Viewport == null)
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;
}
}
+ 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);
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;
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);
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;
_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)
--- /dev/null
+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();
+ }
+}
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;
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;
-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;
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>();
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;
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();
using Content.Client.UserInterface.Controls;
+using Content.Client.UserInterface.Systems.Gameplay;
using Content.Shared.CCVar;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
_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()