1
0

NanoTaskUiState.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. using Robust.Shared.Serialization;
  2. namespace Content.Shared.CartridgeLoader.Cartridges;
  3. /// <summary>
  4. /// The priority assigned to a NanoTask item
  5. /// </summary>
  6. [Serializable, NetSerializable]
  7. public enum NanoTaskPriority : byte
  8. {
  9. High,
  10. Medium,
  11. Low,
  12. };
  13. /// <summary>
  14. /// The data relating to a single NanoTask item, but not its identifier
  15. /// </summary>
  16. [Serializable, NetSerializable, DataRecord]
  17. public sealed class NanoTaskItem
  18. {
  19. /// <summary>
  20. /// The maximum length of the Description and TaskIsFor fields
  21. /// </summary>
  22. public static int MaximumStringLength = 30;
  23. /// <summary>
  24. /// The task description, i.e. "Bake a cake"
  25. /// </summary>
  26. public readonly string Description;
  27. /// <summary>
  28. /// Who the task is for, i.e. "Cargo"
  29. /// </summary>
  30. public readonly string TaskIsFor;
  31. /// <summary>
  32. /// If the task is marked as done or not
  33. /// </summary>
  34. public readonly bool IsTaskDone;
  35. /// <summary>
  36. /// The task's marked priority
  37. /// </summary>
  38. public readonly NanoTaskPriority Priority;
  39. public NanoTaskItem(string description, string taskIsFor, bool isTaskDone, NanoTaskPriority priority)
  40. {
  41. Description = description;
  42. TaskIsFor = taskIsFor;
  43. IsTaskDone = isTaskDone;
  44. Priority = priority;
  45. }
  46. public bool Validate()
  47. {
  48. return Description.Length <= MaximumStringLength && TaskIsFor.Length <= MaximumStringLength;
  49. }
  50. };
  51. /// <summary>
  52. /// Pairs a NanoTask item and its identifier
  53. /// </summary>
  54. [Serializable, NetSerializable, DataRecord]
  55. public sealed class NanoTaskItemAndId
  56. {
  57. public readonly int Id;
  58. public readonly NanoTaskItem Data;
  59. public NanoTaskItemAndId(int id, NanoTaskItem data)
  60. {
  61. Id = id;
  62. Data = data;
  63. }
  64. };
  65. /// <summary>
  66. /// The UI state of the NanoTask
  67. /// </summary>
  68. [Serializable, NetSerializable]
  69. public sealed class NanoTaskUiState : BoundUserInterfaceState
  70. {
  71. public List<NanoTaskItemAndId> Tasks;
  72. public NanoTaskUiState(List<NanoTaskItemAndId> tasks)
  73. {
  74. Tasks = tasks;
  75. }
  76. }