mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 10:21:18 +03:00
* Add AFK kicks back in Fixes the previous issues and also makes it a big window so users can close it / manually mark themselves as not being AFK now. * review * scar but im too lazy to apply suggestions and mess with commits * sane minimums * asd * review * augh * Fix afk minimum + requested admin bump * airhorn
42 lines
1.1 KiB
C#
42 lines
1.1 KiB
C#
using Robust.Client.AutoGenerated;
|
|
using Robust.Client.UserInterface.CustomControls;
|
|
using Robust.Client.UserInterface.XAML;
|
|
using Robust.Shared.Timing;
|
|
|
|
namespace Content.Client.Afk;
|
|
|
|
[GenerateTypedNameReferences]
|
|
public sealed partial class AfkConfirmWindow : DefaultWindow
|
|
{
|
|
[Dependency] private IGameTiming _timing = default!;
|
|
|
|
private TimeSpan _deadline;
|
|
|
|
public event Action? OnConfirm;
|
|
|
|
public AfkConfirmWindow()
|
|
{
|
|
RobustXamlLoader.Load(this);
|
|
IoCManager.InjectDependencies(this);
|
|
|
|
ConfirmButton.OnPressed += _ => OnConfirm?.Invoke();
|
|
}
|
|
|
|
public void SetTimeRemaining(TimeSpan timeRemaining)
|
|
{
|
|
_deadline = _timing.RealTime + timeRemaining;
|
|
UpdateTimer();
|
|
}
|
|
|
|
protected override void FrameUpdate(FrameEventArgs args)
|
|
{
|
|
base.FrameUpdate(args);
|
|
UpdateTimer();
|
|
}
|
|
|
|
private void UpdateTimer()
|
|
{
|
|
var remaining = Math.Max(0, (int)Math.Ceiling((_deadline - _timing.RealTime).TotalSeconds));
|
|
TimerLabel.Text = Loc.GetString("afk-confirm-window-seconds", ("seconds", remaining));
|
|
}
|
|
}
|