From d776c4b392a082dba7539d77cfa20fc904ed4091 Mon Sep 17 00:00:00 2001 From: Pieter-Jan Briers Date: Thu, 21 Mar 2024 16:15:46 +0100 Subject: [PATCH] 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. --- .../UI/AdminRemarks/AdminMessageEui.cs | 18 +- .../AdminMessagePopupMessage.xaml | 6 + .../AdminMessagePopupMessage.xaml.cs | 23 + .../AdminRemarks/AdminMessagePopupWindow.xaml | 42 +- .../AdminMessagePopupWindow.xaml.cs | 44 +- ...0318022005_AdminMessageDismiss.Designer.cs | 1768 +++++++++++++++++ .../20240318022005_AdminMessageDismiss.cs | 40 + .../PostgresServerDbContextModelSnapshot.cs | 9 +- ...0318021959_AdminMessageDismiss.Designer.cs | 1699 ++++++++++++++++ .../20240318021959_AdminMessageDismiss.cs | 40 + .../SqliteServerDbContextModelSnapshot.cs | 9 +- Content.Server.Database/Model.cs | 14 + .../Administration/Notes/AdminMessageEui.cs | 46 +- .../Administration/Notes/AdminNotesManager.cs | 4 +- .../Administration/Notes/AdminNotesSystem.cs | 21 +- .../Notes/IAdminNotesManager.cs | 10 +- Content.Server/Database/DatabaseRecords.cs | 3 +- Content.Server/Database/ServerDbBase.cs | 7 +- Content.Server/Database/ServerDbManager.cs | 14 +- .../Notes/AdminMessageEuiState.cs | 31 +- .../en-US/administration/ui/admin-notes.ftl | 8 +- 21 files changed, 3748 insertions(+), 108 deletions(-) create mode 100644 Content.Client/Administration/UI/AdminRemarks/AdminMessagePopupMessage.xaml create mode 100644 Content.Client/Administration/UI/AdminRemarks/AdminMessagePopupMessage.xaml.cs create mode 100644 Content.Server.Database/Migrations/Postgres/20240318022005_AdminMessageDismiss.Designer.cs create mode 100644 Content.Server.Database/Migrations/Postgres/20240318022005_AdminMessageDismiss.cs create mode 100644 Content.Server.Database/Migrations/Sqlite/20240318021959_AdminMessageDismiss.Designer.cs create mode 100644 Content.Server.Database/Migrations/Sqlite/20240318021959_AdminMessageDismiss.cs diff --git a/Content.Client/Administration/UI/AdminRemarks/AdminMessageEui.cs b/Content.Client/Administration/UI/AdminRemarks/AdminMessageEui.cs index 06eace118d..502c56a5a6 100644 --- a/Content.Client/Administration/UI/AdminRemarks/AdminMessageEui.cs +++ b/Content.Client/Administration/UI/AdminRemarks/AdminMessageEui.cs @@ -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(); } } diff --git a/Content.Client/Administration/UI/AdminRemarks/AdminMessagePopupMessage.xaml b/Content.Client/Administration/UI/AdminRemarks/AdminMessagePopupMessage.xaml new file mode 100644 index 0000000000..9a60a6f72a --- /dev/null +++ b/Content.Client/Administration/UI/AdminRemarks/AdminMessagePopupMessage.xaml @@ -0,0 +1,6 @@ + + + + + + diff --git a/Content.Client/Administration/UI/AdminRemarks/AdminMessagePopupMessage.xaml.cs b/Content.Client/Administration/UI/AdminRemarks/AdminMessagePopupMessage.xaml.cs new file mode 100644 index 0000000000..7bb425f618 --- /dev/null +++ b/Content.Client/Administration/UI/AdminRemarks/AdminMessagePopupMessage.xaml.cs @@ -0,0 +1,23 @@ +using Content.Shared.Administration.Notes; +using Robust.Client.AutoGenerated; +using Robust.Client.UserInterface; +using Robust.Client.UserInterface.XAML; +using Robust.Shared.Utility; + +namespace Content.Client.Administration.UI.AdminRemarks; + +[GenerateTypedNameReferences] +public sealed partial class AdminMessagePopupMessage : Control +{ + public AdminMessagePopupMessage(AdminMessageEuiState.Message message) + { + RobustXamlLoader.Load(this); + + Admin.SetMessage(FormattedMessage.FromMarkup(Loc.GetString( + "admin-notes-message-admin", + ("admin", message.AdminName), + ("date", message.AddedOn.ToLocalTime())))); + + Message.SetMessage(message.Text); + } +} diff --git a/Content.Client/Administration/UI/AdminRemarks/AdminMessagePopupWindow.xaml b/Content.Client/Administration/UI/AdminRemarks/AdminMessagePopupWindow.xaml index 311829e8b2..cc5207bb3a 100644 --- a/Content.Client/Administration/UI/AdminRemarks/AdminMessagePopupWindow.xaml +++ b/Content.Client/Administration/UI/AdminRemarks/AdminMessagePopupWindow.xaml @@ -1,22 +1,36 @@ - - - - -