Make ghost timer a cvar (#8817)
Co-authored-by: Just-a-Unity-Dev <rnmangunay@addu.edu.ph> Co-authored-by: Just-a-Unity-Dev <just-a-unity-dev@users.noreply.github.com> Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
@@ -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<IConfigurationManager>();
|
||||
private float _timer;
|
||||
|
||||
public GhostRoleRulesWindow(string rules, Action<BaseButton.ButtonEventArgs> 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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user