Files
tbd-station-14/Content.Client/Administration/UI/Notes/AdminNotesEui.cs
DrSmugleaf 5227d1a023 Admin notes (#7259)
Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
2022-04-16 20:57:50 +02:00

43 lines
1.2 KiB
C#

using Content.Client.Eui;
using Content.Shared.Administration.Notes;
using Content.Shared.Eui;
using JetBrains.Annotations;
using static Content.Shared.Administration.Notes.AdminNoteEuiMsg;
namespace Content.Client.Administration.UI.Notes;
[UsedImplicitly]
public sealed class AdminNotesEui : BaseEui
{
public AdminNotesEui()
{
NoteWindow = new AdminNotesWindow();
NoteControl = NoteWindow.Notes;
NoteControl.OnNoteChanged += (id, text) => SendMessage(new EditNoteRequest(id, text));
NoteControl.OnNewNoteEntered += text => SendMessage(new CreateNoteRequest(text));
NoteControl.OnNoteDeleted += id => SendMessage(new DeleteNoteRequest(id));
}
private AdminNotesWindow NoteWindow { get; }
private AdminNotesControl NoteControl { get; }
public override void HandleState(EuiStateBase state)
{
if (state is not AdminNotesEuiState s)
{
return;
}
NoteWindow.SetTitlePlayer(s.NotedPlayerName);
NoteControl.SetNotes(s.Notes);
NoteControl.SetPermissions(s.CanCreate, s.CanDelete, s.CanEdit);
}
public override void Opened()
{
NoteWindow.OpenCentered();
}
}