Minor UI refactor (#11212)
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
using Robust.Shared.Timing;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
using Content.Shared.CCVar;
|
||||
using Robust.Shared.Configuration;
|
||||
|
||||
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");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user