Co-authored-by: DrSmugleaf <DrSmugleaf@users.noreply.github.com> Co-authored-by: Jezithyr <jmaster9999@gmail.com> Co-authored-by: Jezithyr <Jezithyr@gmail.com> Co-authored-by: Visne <39844191+Visne@users.noreply.github.com> Co-authored-by: wrexbe <wrexbe@protonmail.com> Co-authored-by: wrexbe <81056464+wrexbe@users.noreply.github.com>
52 lines
1.9 KiB
C#
52 lines
1.9 KiB
C#
using Content.Shared.CCVar;
|
|
using Robust.Client.AutoGenerated;
|
|
using Robust.Client.UserInterface.Controls;
|
|
using Robust.Client.UserInterface.CustomControls;
|
|
using Robust.Client.UserInterface.XAML;
|
|
using Robust.Shared.Configuration;
|
|
using Robust.Shared.Timing;
|
|
using Robust.Shared.Utility;
|
|
|
|
namespace Content.Client.UserInterface.Systems.Ghost.Controls.Roles
|
|
{
|
|
[GenerateTypedNameReferences]
|
|
public sealed partial class GhostRoleRulesWindow : DefaultWindow
|
|
{
|
|
[Dependency] private readonly IConfigurationManager _cfg = IoCManager.Resolve<IConfigurationManager>();
|
|
private float _timer;
|
|
|
|
public GhostRoleRulesWindow(string rules, Action<BaseButton.ButtonEventArgs> requestAction)
|
|
{
|
|
RobustXamlLoader.Load(this);
|
|
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);
|
|
if (!RequestButton.Disabled) return;
|
|
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");
|
|
}
|
|
}
|
|
}
|
|
}
|