diff --git a/Content.Client/GameTicking/Managers/ClientGameTicker.cs b/Content.Client/GameTicking/Managers/ClientGameTicker.cs index f62f99c6df..309db2eb4e 100644 --- a/Content.Client/GameTicking/Managers/ClientGameTicker.cs +++ b/Content.Client/GameTicking/Managers/ClientGameTicker.cs @@ -7,7 +7,7 @@ using Content.Shared.GameWindow; using JetBrains.Annotations; using Robust.Client.Graphics; using Robust.Client.State; -using Robust.Shared.Utility; +using Robust.Client.UserInterface; namespace Content.Client.GameTicking.Managers { @@ -18,16 +18,11 @@ namespace Content.Client.GameTicking.Managers [Dependency] private readonly IClientAdminManager _admin = default!; [Dependency] private readonly IClyde _clyde = default!; [Dependency] private readonly SharedMapSystem _map = default!; + [Dependency] private readonly IUserInterfaceManager _userInterfaceManager = default!; - [ViewVariables] private bool _initialized; private Dictionary> _jobsAvailable = new(); private Dictionary _stationNames = new(); - /// - /// The current round-end window. Could be used to support re-opening the window after closing it. - /// - private RoundEndSummaryWindow? _window; - [ViewVariables] public bool AreWeReady { get; private set; } [ViewVariables] public bool IsGameStarted { get; private set; } [ViewVariables] public string? RestartSound { get; private set; } @@ -152,12 +147,7 @@ namespace Content.Client.GameTicking.Managers // Force an update in the event of this song being the same as the last. RestartSound = message.RestartSound; - // Don't open duplicate windows (mainly for replays). - if (_window?.RoundId == message.RoundId) - return; - - //This is not ideal at all, but I don't see an immediately better fit anywhere else. - _window = new RoundEndSummaryWindow(message.GamemodeTitle, message.RoundEndText, message.RoundDuration, message.RoundId, message.AllPlayersEndInfo, EntityManager); + _userInterfaceManager.GetUIController().OpenRoundEndSummaryWindow(message); } } } diff --git a/Content.Client/Input/ContentContexts.cs b/Content.Client/Input/ContentContexts.cs index 2e888b3df9..8a7ca3b773 100644 --- a/Content.Client/Input/ContentContexts.cs +++ b/Content.Client/Input/ContentContexts.cs @@ -38,6 +38,7 @@ namespace Content.Client.Input common.AddFunction(ContentKeyFunctions.ZoomIn); common.AddFunction(ContentKeyFunctions.ResetZoom); common.AddFunction(ContentKeyFunctions.InspectEntity); + common.AddFunction(ContentKeyFunctions.ToggleRoundEndSummaryWindow); // Not in engine, because engine cannot check for sanbox/admin status before starting placement. common.AddFunction(ContentKeyFunctions.EditorCopyObject); diff --git a/Content.Client/Options/UI/Tabs/KeyRebindTab.xaml.cs b/Content.Client/Options/UI/Tabs/KeyRebindTab.xaml.cs index aca9efcfe2..a575f1ba51 100644 --- a/Content.Client/Options/UI/Tabs/KeyRebindTab.xaml.cs +++ b/Content.Client/Options/UI/Tabs/KeyRebindTab.xaml.cs @@ -215,6 +215,7 @@ namespace Content.Client.Options.UI.Tabs AddButton(ContentKeyFunctions.OpenInventoryMenu); AddButton(ContentKeyFunctions.OpenAHelp); AddButton(ContentKeyFunctions.OpenActionsMenu); + AddButton(ContentKeyFunctions.ToggleRoundEndSummaryWindow); AddButton(ContentKeyFunctions.OpenEntitySpawnWindow); AddButton(ContentKeyFunctions.OpenSandboxWindow); AddButton(ContentKeyFunctions.OpenTileSpawnWindow); diff --git a/Content.Client/RoundEnd/RoundEndSummaryUIController.cs b/Content.Client/RoundEnd/RoundEndSummaryUIController.cs new file mode 100644 index 0000000000..cf824833ef --- /dev/null +++ b/Content.Client/RoundEnd/RoundEndSummaryUIController.cs @@ -0,0 +1,51 @@ +using Content.Client.GameTicking.Managers; +using Content.Shared.GameTicking; +using Content.Shared.Input; +using JetBrains.Annotations; +using Robust.Client.Input; +using Robust.Client.UserInterface.Controllers; +using Robust.Shared.Input.Binding; +using Robust.Shared.Player; + +namespace Content.Client.RoundEnd; + +[UsedImplicitly] +public sealed class RoundEndSummaryUIController : UIController, + IOnSystemLoaded +{ + [Dependency] private readonly IInputManager _input = default!; + + private RoundEndSummaryWindow? _window; + + private void ToggleScoreboardWindow(ICommonSession? session = null) + { + if (_window == null) + return; + + if (_window.IsOpen) + { + _window.Close(); + } + else + { + _window.OpenCenteredRight(); + _window.MoveToFront(); + } + } + + public void OpenRoundEndSummaryWindow(RoundEndMessageEvent message) + { + // Don't open duplicate windows (mainly for replays). + if (_window?.RoundId == message.RoundId) + return; + + _window = new RoundEndSummaryWindow(message.GamemodeTitle, message.RoundEndText, + message.RoundDuration, message.RoundId, message.AllPlayersEndInfo, EntityManager); + } + + public void OnSystemLoaded(ClientGameTicker system) + { + _input.SetInputCommand(ContentKeyFunctions.ToggleRoundEndSummaryWindow, + InputCmdHandler.FromDelegate(ToggleScoreboardWindow)); + } +} diff --git a/Content.Client/RoundEnd/RoundEndSummaryWindow.cs b/Content.Client/RoundEnd/RoundEndSummaryWindow.cs index 5b73c77934..9c9f83a427 100644 --- a/Content.Client/RoundEnd/RoundEndSummaryWindow.cs +++ b/Content.Client/RoundEnd/RoundEndSummaryWindow.cs @@ -2,7 +2,6 @@ using System.Linq; using System.Numerics; using Content.Client.Message; using Content.Shared.GameTicking; -using Robust.Client.GameObjects; using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.CustomControls; using Robust.Shared.Utility; diff --git a/Content.Shared/Input/ContentKeyFunctions.cs b/Content.Shared/Input/ContentKeyFunctions.cs index cf874434ec..886a0d5d3a 100644 --- a/Content.Shared/Input/ContentKeyFunctions.cs +++ b/Content.Shared/Input/ContentKeyFunctions.cs @@ -42,6 +42,7 @@ namespace Content.Shared.Input public static readonly BoundKeyFunction MovePulledObject = "MovePulledObject"; public static readonly BoundKeyFunction ReleasePulledObject = "ReleasePulledObject"; public static readonly BoundKeyFunction MouseMiddle = "MouseMiddle"; + public static readonly BoundKeyFunction ToggleRoundEndSummaryWindow = "ToggleRoundEndSummaryWindow"; public static readonly BoundKeyFunction OpenEntitySpawnWindow = "OpenEntitySpawnWindow"; public static readonly BoundKeyFunction OpenSandboxWindow = "OpenSandboxWindow"; public static readonly BoundKeyFunction OpenTileSpawnWindow = "OpenTileSpawnWindow"; diff --git a/Resources/Locale/en-US/escape-menu/ui/options-menu.ftl b/Resources/Locale/en-US/escape-menu/ui/options-menu.ftl index 416d87f7c5..1c0c0005b4 100644 --- a/Resources/Locale/en-US/escape-menu/ui/options-menu.ftl +++ b/Resources/Locale/en-US/escape-menu/ui/options-menu.ftl @@ -173,6 +173,7 @@ ui-options-function-open-crafting-menu = Open crafting menu ui-options-function-open-inventory-menu = Open inventory ui-options-function-open-a-help = Open admin help ui-options-function-open-abilities-menu = Open action menu +ui-options-function-toggle-round-end-summary-window = Toggle round end summary window ui-options-function-open-entity-spawn-window = Open entity spawn menu ui-options-function-open-sandbox-window = Open sandbox menu ui-options-function-open-tile-spawn-window = Open tile spawn menu diff --git a/Resources/keybinds.yml b/Resources/keybinds.yml index 886fec35de..b08f4cb4ed 100644 --- a/Resources/keybinds.yml +++ b/Resources/keybinds.yml @@ -452,6 +452,9 @@ binds: - function: OpenDecalSpawnWindow type: State key: F8 +- function: OpenScoreboardWindow + type: State + key: F9 - function: OpenSandboxWindow type: State key: B