Added hotkey and controller to re-open end of round scoreboard (#25884)

* 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>
This commit is contained in:
wafehling
2024-04-26 05:39:56 -07:00
committed by GitHub
parent 080b1b1e0c
commit 8febdc5fc4
8 changed files with 61 additions and 14 deletions

View File

@@ -7,7 +7,7 @@ using Content.Shared.GameWindow;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Client.Graphics; using Robust.Client.Graphics;
using Robust.Client.State; using Robust.Client.State;
using Robust.Shared.Utility; using Robust.Client.UserInterface;
namespace Content.Client.GameTicking.Managers namespace Content.Client.GameTicking.Managers
{ {
@@ -18,16 +18,11 @@ namespace Content.Client.GameTicking.Managers
[Dependency] private readonly IClientAdminManager _admin = default!; [Dependency] private readonly IClientAdminManager _admin = default!;
[Dependency] private readonly IClyde _clyde = default!; [Dependency] private readonly IClyde _clyde = default!;
[Dependency] private readonly SharedMapSystem _map = 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, Dictionary<string, uint?>> _jobsAvailable = new();
private Dictionary<NetEntity, string> _stationNames = 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 AreWeReady { get; private set; }
[ViewVariables] public bool IsGameStarted { get; private set; } [ViewVariables] public bool IsGameStarted { get; private set; }
[ViewVariables] public string? RestartSound { 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. // Force an update in the event of this song being the same as the last.
RestartSound = message.RestartSound; RestartSound = message.RestartSound;
// Don't open duplicate windows (mainly for replays). _userInterfaceManager.GetUIController<RoundEndSummaryUIController>().OpenRoundEndSummaryWindow(message);
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);
} }
} }
} }

View File

@@ -38,6 +38,7 @@ namespace Content.Client.Input
common.AddFunction(ContentKeyFunctions.ZoomIn); common.AddFunction(ContentKeyFunctions.ZoomIn);
common.AddFunction(ContentKeyFunctions.ResetZoom); common.AddFunction(ContentKeyFunctions.ResetZoom);
common.AddFunction(ContentKeyFunctions.InspectEntity); common.AddFunction(ContentKeyFunctions.InspectEntity);
common.AddFunction(ContentKeyFunctions.ToggleRoundEndSummaryWindow);
// Not in engine, because engine cannot check for sanbox/admin status before starting placement. // Not in engine, because engine cannot check for sanbox/admin status before starting placement.
common.AddFunction(ContentKeyFunctions.EditorCopyObject); common.AddFunction(ContentKeyFunctions.EditorCopyObject);

View File

@@ -215,6 +215,7 @@ namespace Content.Client.Options.UI.Tabs
AddButton(ContentKeyFunctions.OpenInventoryMenu); AddButton(ContentKeyFunctions.OpenInventoryMenu);
AddButton(ContentKeyFunctions.OpenAHelp); AddButton(ContentKeyFunctions.OpenAHelp);
AddButton(ContentKeyFunctions.OpenActionsMenu); AddButton(ContentKeyFunctions.OpenActionsMenu);
AddButton(ContentKeyFunctions.ToggleRoundEndSummaryWindow);
AddButton(ContentKeyFunctions.OpenEntitySpawnWindow); AddButton(ContentKeyFunctions.OpenEntitySpawnWindow);
AddButton(ContentKeyFunctions.OpenSandboxWindow); AddButton(ContentKeyFunctions.OpenSandboxWindow);
AddButton(ContentKeyFunctions.OpenTileSpawnWindow); AddButton(ContentKeyFunctions.OpenTileSpawnWindow);

View File

@@ -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));
}
}

View File

@@ -2,7 +2,6 @@ using System.Linq;
using System.Numerics; using System.Numerics;
using Content.Client.Message; using Content.Client.Message;
using Content.Shared.GameTicking; using Content.Shared.GameTicking;
using Robust.Client.GameObjects;
using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls; using Robust.Client.UserInterface.CustomControls;
using Robust.Shared.Utility; using Robust.Shared.Utility;

View File

@@ -42,6 +42,7 @@ namespace Content.Shared.Input
public static readonly BoundKeyFunction MovePulledObject = "MovePulledObject"; public static readonly BoundKeyFunction MovePulledObject = "MovePulledObject";
public static readonly BoundKeyFunction ReleasePulledObject = "ReleasePulledObject"; public static readonly BoundKeyFunction ReleasePulledObject = "ReleasePulledObject";
public static readonly BoundKeyFunction MouseMiddle = "MouseMiddle"; public static readonly BoundKeyFunction MouseMiddle = "MouseMiddle";
public static readonly BoundKeyFunction ToggleRoundEndSummaryWindow = "ToggleRoundEndSummaryWindow";
public static readonly BoundKeyFunction OpenEntitySpawnWindow = "OpenEntitySpawnWindow"; public static readonly BoundKeyFunction OpenEntitySpawnWindow = "OpenEntitySpawnWindow";
public static readonly BoundKeyFunction OpenSandboxWindow = "OpenSandboxWindow"; public static readonly BoundKeyFunction OpenSandboxWindow = "OpenSandboxWindow";
public static readonly BoundKeyFunction OpenTileSpawnWindow = "OpenTileSpawnWindow"; public static readonly BoundKeyFunction OpenTileSpawnWindow = "OpenTileSpawnWindow";

View 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-inventory-menu = Open inventory
ui-options-function-open-a-help = Open admin help ui-options-function-open-a-help = Open admin help
ui-options-function-open-abilities-menu = Open action menu 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-entity-spawn-window = Open entity spawn menu
ui-options-function-open-sandbox-window = Open sandbox menu ui-options-function-open-sandbox-window = Open sandbox menu
ui-options-function-open-tile-spawn-window = Open tile spawn menu ui-options-function-open-tile-spawn-window = Open tile spawn menu

View File

@@ -452,6 +452,9 @@ binds:
- function: OpenDecalSpawnWindow - function: OpenDecalSpawnWindow
type: State type: State
key: F8 key: F8
- function: OpenScoreboardWindow
type: State
key: F9
- function: OpenSandboxWindow - function: OpenSandboxWindow
type: State type: State
key: B key: B