CatStation/Content.Client/Afk/AfkConfirmWindow.cs
metalgearsloth 093fc24dda
Add AFK kicks back in (#44353)
* 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
2026-06-28 04:15:18 +00:00

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));
}
}