diff --git a/Content.Client/Ghost/Roles/UI/GhostRoleRulesWindow.xaml.cs b/Content.Client/Ghost/Roles/UI/GhostRoleRulesWindow.xaml.cs index 915eb72db6..cd11f03b93 100644 --- a/Content.Client/Ghost/Roles/UI/GhostRoleRulesWindow.xaml.cs +++ b/Content.Client/Ghost/Roles/UI/GhostRoleRulesWindow.xaml.cs @@ -1,26 +1,38 @@ -using System; -using Content.Shared.Ghost.Roles; using Robust.Client.AutoGenerated; using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.CustomControls; using Robust.Client.UserInterface.XAML; -using Robust.Shared.Localization; using Robust.Shared.Timing; using Robust.Shared.Utility; +using Content.Shared.CCVar; +using Robust.Shared.Configuration; + namespace Content.Client.Ghost.Roles.UI { [GenerateTypedNameReferences] public sealed partial class GhostRoleRulesWindow : DefaultWindow { - private float _timer = 5.0f; + [Dependency] private readonly IConfigurationManager _cfg = IoCManager.Resolve(); + private float _timer; + public GhostRoleRulesWindow(string rules, Action requestAction) { RobustXamlLoader.Load(this); - TopBanner.SetMessage(FormattedMessage.FromMarkupPermissive(rules + "\n" + Loc.GetString("ghost-roles-window-rules-footer"))); + var ghostRoleTime = _cfg.GetCVar(CCVars.GhostRoleTime); + _timer = ghostRoleTime; + + if (ghostRoleTime > 0f) + { + RequestButton.Text = Loc.GetString("ghost-roles-window-request-role-button-timer", ("time", $"{_timer:0.0}")); + TopBanner.SetMessage(FormattedMessage.FromMarkupPermissive(rules + "\n" + Loc.GetString("ghost-roles-window-rules-footer", ("time", ghostRoleTime)))); + RequestButton.Disabled = true; + } + RequestButton.OnPressed += requestAction; } + protected override void FrameUpdate(FrameEventArgs args) { base.FrameUpdate(args); @@ -28,10 +40,12 @@ namespace Content.Client.Ghost.Roles.UI if (_timer > 0.0) { _timer -= args.DeltaSeconds; + RequestButton.Text = Loc.GetString("ghost-roles-window-request-role-button-timer", ("time", $"{_timer:0.0}")); } else { RequestButton.Disabled = false; + RequestButton.Text = Loc.GetString("ghost-roles-window-request-role-button"); } } } diff --git a/Content.Shared/CCVar/CCVars.cs b/Content.Shared/CCVar/CCVars.cs index 1a341e2c8e..392f6bde05 100644 --- a/Content.Shared/CCVar/CCVars.cs +++ b/Content.Shared/CCVar/CCVars.cs @@ -991,5 +991,15 @@ namespace Content.Shared.CCVar /// public static readonly CVarDef UpdateRestartDelay = CVarDef.Create("update.restart_delay", 20f, CVar.SERVERONLY); + + /* + * Ghost + */ + + /// + /// The time you must spend reading the rules, before the "Request" button is enabled + /// + public static readonly CVarDef GhostRoleTime = + CVarDef.Create("ghost.role_time", 3f, CVar.REPLICATED); } } diff --git a/Resources/Locale/en-US/ghost/ghost-gui.ftl b/Resources/Locale/en-US/ghost/ghost-gui.ftl index 51bc5529f6..0ec5f1dcac 100644 --- a/Resources/Locale/en-US/ghost/ghost-gui.ftl +++ b/Resources/Locale/en-US/ghost/ghost-gui.ftl @@ -7,7 +7,8 @@ ghost-target-window-current-button = Warp: {$name} ghost-roles-window-title = Ghost Roles ghost-roles-window-request-role-button = Request +ghost-roles-window-request-role-button-timer = Request ({$time}s) ghost-roles-window-follow-role-button = Follow ghost-roles-window-no-roles-available-label = There are currently no available ghost roles. -ghost-roles-window-rules-footer = The button will enable after 5 seconds (this delay is to make sure you read the rules). +ghost-roles-window-rules-footer = The button will enable after {$time} seconds (this delay is to make sure you read the rules).