AdminNotesEui.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. using Content.Client.Eui;
  2. using Content.Shared.Administration.Notes;
  3. using Content.Shared.Eui;
  4. using JetBrains.Annotations;
  5. using static Content.Shared.Administration.Notes.AdminNoteEuiMsg;
  6. namespace Content.Client.Administration.UI.Notes;
  7. [UsedImplicitly]
  8. public sealed class AdminNotesEui : BaseEui
  9. {
  10. public AdminNotesEui()
  11. {
  12. NoteWindow = new AdminNotesWindow();
  13. NoteControl = NoteWindow.Notes;
  14. NoteControl.NoteChanged += (id, type, text, severity, secret, expiryTime) => SendMessage(new EditNoteRequest(id, type, text, severity, secret, expiryTime));
  15. NoteControl.NewNoteEntered += (type, text, severity, secret, expiryTime) => SendMessage(new CreateNoteRequest(type, text, severity, secret, expiryTime));
  16. NoteControl.NoteDeleted += (id, type) => SendMessage(new DeleteNoteRequest(id, type));
  17. NoteWindow.OnClose += () => SendMessage(new CloseEuiMessage());
  18. }
  19. public override void Closed()
  20. {
  21. base.Closed();
  22. NoteWindow.Close();
  23. }
  24. private AdminNotesWindow NoteWindow { get; }
  25. private AdminNotesControl NoteControl { get; }
  26. public override void HandleState(EuiStateBase state)
  27. {
  28. if (state is not AdminNotesEuiState s)
  29. {
  30. return;
  31. }
  32. NoteWindow.SetTitlePlayer(s.NotedPlayerName);
  33. NoteControl.SetPlayerName(s.NotedPlayerName);
  34. NoteControl.SetNotes(s.Notes);
  35. NoteControl.SetPermissions(s.CanCreate, s.CanDelete, s.CanEdit);
  36. }
  37. public override void Opened()
  38. {
  39. NoteWindow.OpenCentered();
  40. }
  41. }