Files
wwdpublic/Content.Client/Administration/UI/AdminRemarks/AdminMessagePopupWindow.xaml.cs
ilmenwe 432042e945 Logger Sawmill Cleanup (#2413)
# Description
Cleaned up Logger obsolete compiler warnings in non robust code.
Should probably be changed to a ISawmill reference in classes to avoid
repeated lookups in heavy logging logic.
---

# Changelog

🆑

- tweak: Logger to Logger.GetSawmill("name");

---------

Co-authored-by: ilmenwe <no@mail.com>

(cherry picked from commit 2e8ffd971716d38dc6d5a520bebdf88b743045a3)
2025-05-10 01:00:05 +03:00

93 lines
2.3 KiB
C#

using Content.Client.Stylesheets;
using Content.Shared.Administration.Notes;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Timing;
using Robust.Shared.Utility;
namespace Content.Client.Administration.UI.AdminRemarks;
[GenerateTypedNameReferences]
public sealed partial class AdminMessagePopupWindow : Control
{
private float _timer = float.MaxValue;
public event Action? OnDismissPressed;
public event Action? OnAcceptPressed;
public AdminMessagePopupWindow()
{
RobustXamlLoader.Load(this);
Stylesheet = IoCManager.Resolve<IStylesheetManager>().SheetSpace;
AcceptButton.OnPressed += OnAcceptButtonPressed;
DismissButton.OnPressed += OnDismissButtonPressed;
}
public float Timer
{
get => _timer;
private set
{
WaitLabel.Text = Loc.GetString("admin-notes-message-wait", ("time", MathF.Floor(value)));
_timer = value;
}
}
public void SetState(AdminMessageEuiState state)
{
Timer = (float) state.Time.TotalSeconds;
MessageContainer.RemoveAllChildren();
foreach (var message in state.Messages)
{
MessageContainer.AddChild(new AdminMessagePopupMessage(message));
}
try
{
Description.SetMessage(FormattedMessage.FromMarkupOrThrow(Loc.GetString("admin-notes-message-desc", ("count", state.Messages.Length))));
}
catch (Exception e)
{
Description.SetMessage(e.Message);
}
}
private void OnDismissButtonPressed(BaseButton.ButtonEventArgs obj)
{
OnDismissPressed?.Invoke();
}
private void OnAcceptButtonPressed(BaseButton.ButtonEventArgs obj)
{
OnAcceptPressed?.Invoke();
}
protected override void FrameUpdate(FrameEventArgs args)
{
base.FrameUpdate(args);
if (!AcceptButton.Disabled)
return;
if (Timer > 0.0)
{
if (Timer - args.DeltaSeconds < 0)
Timer = 0;
else
Timer -= args.DeltaSeconds;
}
else
{
AcceptButton.Disabled = false;
DismissButton.Disabled = false;
}
}
}