Improve admin message seen/dismiss state. (#26223)
Fixes #26211 Admin messages now have separate "seen" and "dismissed" fields. The idea is that an admin should be able to tell whether a user pressed the "dismiss for now" button. Instead of using "seen" as "show this message to players when they join", "dismissed" is now used for this. Existing notes in the database will automatically be marked as dismissed on migration. A note cannot be dismissed without being seen (enforced via constraint in the database too, aren't I fancy). As part of this, it has become impossible for a player to play without dismissing the message in some form. Instead of a shitty popup window, the popup is now a fullscreen overlay that blocks clicks behind it, making the game unplayable. Also, if a user somehow has multiple messages they will be combined into one popup. Also I had enough respect for the codebase to make it look better and clean up the code somewhat. Yippee.
This commit is contained in:
committed by
GitHub
parent
f87480dd36
commit
d776c4b392
@@ -2,6 +2,7 @@ using Content.Client.Eui;
|
||||
using Content.Shared.Administration.Notes;
|
||||
using Content.Shared.Eui;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using static Content.Shared.Administration.Notes.AdminMessageEuiMsg;
|
||||
|
||||
namespace Content.Client.Administration.UI.AdminRemarks;
|
||||
@@ -14,9 +15,8 @@ public sealed class AdminMessageEui : BaseEui
|
||||
public AdminMessageEui()
|
||||
{
|
||||
_popup = new AdminMessagePopupWindow();
|
||||
_popup.OnAcceptPressed += () => SendMessage(new Accept());
|
||||
_popup.OnDismissPressed += () => SendMessage(new Dismiss());
|
||||
_popup.OnClose += () => SendMessage(new CloseEuiMessage());
|
||||
_popup.OnAcceptPressed += () => SendMessage(new Dismiss(true));
|
||||
_popup.OnDismissPressed += () => SendMessage(new Dismiss(false));
|
||||
}
|
||||
|
||||
public override void HandleState(EuiStateBase state)
|
||||
@@ -26,13 +26,17 @@ public sealed class AdminMessageEui : BaseEui
|
||||
return;
|
||||
}
|
||||
|
||||
_popup.SetMessage(s.Message);
|
||||
_popup.SetDetails(s.AdminName, s.AddedOn);
|
||||
_popup.Timer = s.Time;
|
||||
_popup.SetState(s);
|
||||
}
|
||||
|
||||
public override void Opened()
|
||||
{
|
||||
_popup.OpenCentered();
|
||||
_popup.UserInterfaceManager.WindowRoot.AddChild(_popup);
|
||||
LayoutContainer.SetAnchorPreset(_popup, LayoutContainer.LayoutPreset.Wide);
|
||||
}
|
||||
|
||||
public override void Closed()
|
||||
{
|
||||
_popup.Orphan();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user