]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Added hotkey and controller to re-open end of round scoreboard (#25884)
authorwafehling <wafehling@users.noreply.github.com>
Fri, 26 Apr 2024 12:39:56 +0000 (05:39 -0700)
committerGitHub <noreply@github.com>
Fri, 26 Apr 2024 12:39:56 +0000 (14:39 +0200)
* Added keybind for scoreboard, starting work

* Fixed the window appearing

* Added loc text

* Updated namespace for ScoreboardUIController.cs

* Switched to UISystemDependency

"- UIControllers can use [Dependency] as normal for IoC services and other controllers, but must use [UISystemDependency] for entity systems, which may be null as controllers exist before entity systems do." Jezithyr — 10/12/2022 1:20 PM

* Reverted back to functional state

* Replace with UISystemDependency

* Move RoundEndSummaryWindow to ScoreboardUIController

* Convert to EntitySystem

* Clean up command bind

* Move to RoundEnd directory

* Remove Nukeops rule when no nukies

* Cleanup

* Change to toggle hotkey

* Cleanup

* Revert "Remove Nukeops rule when no nukies"

This reverts commit 5d4bbca09f45110b24a674d59b505be87b602b67.

* Cleanup

* Make the Toggle hotkey work in lobby

* Fix error

---------

Co-authored-by: SlamBamActionman <slambamactionman@gmail.com>
Co-authored-by: ShadowCommander <10494922+ShadowCommander@users.noreply.github.com>
Content.Client/GameTicking/Managers/ClientGameTicker.cs
Content.Client/Input/ContentContexts.cs
Content.Client/Options/UI/Tabs/KeyRebindTab.xaml.cs
Content.Client/RoundEnd/RoundEndSummaryUIController.cs [new file with mode: 0644]
Content.Client/RoundEnd/RoundEndSummaryWindow.cs
Content.Shared/Input/ContentKeyFunctions.cs
Resources/Locale/en-US/escape-menu/ui/options-menu.ftl
Resources/keybinds.yml

index f62f99c6dfb21f230f8397be34278863ce8268e2..309db2eb4e6a30148b6927f673aba4cccc13b4a5 100644 (file)
@@ -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<NetEntity, Dictionary<string, uint?>>  _jobsAvailable = new();
         private Dictionary<NetEntity, string> _stationNames = new();
 
-        /// <summary>
-        /// The current round-end window. Could be used to support re-opening the window after closing it.
-        /// </summary>
-        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<RoundEndSummaryUIController>().OpenRoundEndSummaryWindow(message);
         }
     }
 }
index 2e888b3df98f01d8bd5ee4d08eecde1218b1a85c..8a7ca3b77352c1f98c2a344f2cf8fe877e82198e 100644 (file)
@@ -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);
index aca9efcfe26acd48381d6b60b701f63cda298ff5..a575f1ba51c0d7eb3b94862f16038942f6ca260a 100644 (file)
@@ -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 (file)
index 0000000..cf82483
--- /dev/null
@@ -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<ClientGameTicker>
+{
+    [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));
+    }
+}
index 5b73c77934a3e5a1bcdd930faba693b150e0337f..9c9f83a4275a65b95d5cf319164c1605ea74f484 100644 (file)
@@ -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;
index cf874434ec93eabe98565f2e4bd65b1631b3df88..886a0d5d3a1663e998c80a1385106b5dfe8395f2 100644 (file)
@@ -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";
index 416d87f7c5125084b87b9ca75ee2529dd343c17c..1c0c0005b406939456bd1917f54fab46eecb38b1 100644 (file)
@@ -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
index 886fec35de86eca06b6988d28995da6ca9cc3a75..b08f4cb4ed02f8feb07551e614619d0300a8b53d 100644 (file)
@@ -452,6 +452,9 @@ binds:
 - function: OpenDecalSpawnWindow
   type: State
   key: F8
+- function: OpenScoreboardWindow
+  type: State
+  key: F9
 - function: OpenSandboxWindow
   type: State
   key: B