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
@@ -1,39 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Content.Shared.Eui;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Administration.Notes;
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class AdminMessageEuiState : EuiStateBase
|
||||
public sealed class AdminMessageEuiState(TimeSpan time, AdminMessageEuiState.Message[] messages) : EuiStateBase
|
||||
{
|
||||
public float Time { get; set; }
|
||||
public string Message { get; set; }
|
||||
public string AdminName { get; set; }
|
||||
public DateTime AddedOn { get; set; }
|
||||
public TimeSpan Time { get; } = time;
|
||||
public Message[] Messages { get; } = messages;
|
||||
|
||||
public AdminMessageEuiState(float time, string message, string adminName, DateTime addedOn)
|
||||
[Serializable]
|
||||
public sealed class Message(string text, string adminName, DateTime addedOn)
|
||||
{
|
||||
Message = message;
|
||||
Time = time;
|
||||
AdminName = adminName;
|
||||
AddedOn = addedOn;
|
||||
public string Text = text;
|
||||
public string AdminName = adminName;
|
||||
public DateTime AddedOn = addedOn;
|
||||
}
|
||||
}
|
||||
|
||||
public static class AdminMessageEuiMsg
|
||||
{
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class Accept : EuiMessageBase
|
||||
{
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class Dismiss : EuiMessageBase
|
||||
public sealed class Dismiss(bool permanent) : EuiMessageBase
|
||||
{
|
||||
public bool Permanent { get; } = permanent;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user