CriminalRecordsUi.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. using Content.Shared.Security;
  2. using Content.Shared.StationRecords;
  3. using Robust.Shared.Serialization;
  4. namespace Content.Shared.CriminalRecords;
  5. [Serializable, NetSerializable]
  6. public enum CriminalRecordsConsoleKey : byte
  7. {
  8. Key
  9. }
  10. /// <summary>
  11. /// Criminal records console state. There are a few states:
  12. /// - SelectedKey null, Record null, RecordListing null
  13. /// - The station record database could not be accessed.
  14. /// - SelectedKey null, Record null, RecordListing non-null
  15. /// - Records are populated in the database, or at least the station has
  16. /// the correct component.
  17. /// - SelectedKey non-null, Record null, RecordListing non-null
  18. /// - The selected key does not have a record tied to it.
  19. /// - SelectedKey non-null, Record non-null, RecordListing non-null
  20. /// - The selected key has a record tied to it, and the record has been sent.
  21. ///
  22. /// - there is added new filters and so added new states
  23. /// -SelectedKey null, Record null, RecordListing null, filters non-null
  24. /// the station may have data, but they all did not pass through the filters
  25. ///
  26. /// Other states are erroneous.
  27. /// </summary>
  28. [Serializable, NetSerializable]
  29. public sealed class CriminalRecordsConsoleState : BoundUserInterfaceState
  30. {
  31. /// <summary>
  32. /// Currently selected crewmember record key.
  33. /// </summary>
  34. public uint? SelectedKey = null;
  35. public CriminalRecord? CriminalRecord = null;
  36. public GeneralStationRecord? StationRecord = null;
  37. public SecurityStatus FilterStatus = SecurityStatus.None;
  38. public readonly Dictionary<uint, string>? RecordListing;
  39. public readonly StationRecordsFilter? Filter;
  40. public CriminalRecordsConsoleState(Dictionary<uint, string>? recordListing, StationRecordsFilter? newFilter)
  41. {
  42. RecordListing = recordListing;
  43. Filter = newFilter;
  44. }
  45. /// <summary>
  46. /// Default state for opening the console
  47. /// </summary>
  48. public CriminalRecordsConsoleState() : this(null, null)
  49. {
  50. }
  51. public bool IsEmpty() => SelectedKey == null && StationRecord == null && CriminalRecord == null && RecordListing == null;
  52. }
  53. /// <summary>
  54. /// Used to change status, respecting the wanted/reason nullability rules in <see cref="CriminalRecord"/>.
  55. /// </summary>
  56. [Serializable, NetSerializable]
  57. public sealed class CriminalRecordChangeStatus : BoundUserInterfaceMessage
  58. {
  59. public readonly SecurityStatus Status;
  60. public readonly string? Reason;
  61. public CriminalRecordChangeStatus(SecurityStatus status, string? reason)
  62. {
  63. Status = status;
  64. Reason = reason;
  65. }
  66. }
  67. /// <summary>
  68. /// Used to add a single line to the record's crime history.
  69. /// </summary>
  70. [Serializable, NetSerializable]
  71. public sealed class CriminalRecordAddHistory : BoundUserInterfaceMessage
  72. {
  73. public readonly string Line;
  74. public CriminalRecordAddHistory(string line)
  75. {
  76. Line = line;
  77. }
  78. }
  79. /// <summary>
  80. /// Used to delete a single line from the crime history, by index.
  81. /// </summary>
  82. [Serializable, NetSerializable]
  83. public sealed class CriminalRecordDeleteHistory : BoundUserInterfaceMessage
  84. {
  85. public readonly uint Index;
  86. public CriminalRecordDeleteHistory(uint index)
  87. {
  88. Index = index;
  89. }
  90. }
  91. /// <summary>
  92. /// Used to set what status to filter by index.
  93. ///
  94. /// </summary>
  95. ///
  96. [Serializable, NetSerializable]
  97. public sealed class CriminalRecordSetStatusFilter : BoundUserInterfaceMessage
  98. {
  99. public readonly SecurityStatus FilterStatus;
  100. public CriminalRecordSetStatusFilter(SecurityStatus newFilterStatus)
  101. {
  102. FilterStatus = newFilterStatus;
  103. }
  104. }