1
0

GroupExamineComponent.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. using Robust.Shared.Serialization;
  2. using Robust.Shared.Utility;
  3. namespace Content.Shared.Examine
  4. {
  5. /// <summary>
  6. /// This component groups examine messages together
  7. /// </summary>
  8. [RegisterComponent]
  9. public sealed partial class GroupExamineComponent : Component
  10. {
  11. /// <summary>
  12. /// A list of ExamineGroups.
  13. /// </summary>
  14. [DataField]
  15. public List<ExamineGroup> Group = new()
  16. {
  17. // TODO Remove hardcoded component names.
  18. new ExamineGroup()
  19. {
  20. Components = new()
  21. {
  22. "Armor",
  23. "ClothingSpeedModifier",
  24. },
  25. },
  26. };
  27. }
  28. [DataDefinition]
  29. public sealed partial class ExamineGroup
  30. {
  31. /// <summary>
  32. /// The title of the Examine Group. Localized string that gets added to the examine tooltip.
  33. /// </summary>
  34. [DataField]
  35. [ViewVariables(VVAccess.ReadWrite)]
  36. public string? Title;
  37. /// <summary>
  38. /// A list of ExamineEntries, containing which component it belongs to, which priority it has, and what FormattedMessage it holds.
  39. /// </summary>
  40. [DataField]
  41. public List<ExamineEntry> Entries = new();
  42. // TODO custom type serializer, or just make this work via some other automatic grouping process that doesn't
  43. // rely on manually specifying component names in yaml.
  44. /// <summary>
  45. /// A list of all components this ExamineGroup encompasses.
  46. /// </summary>
  47. [DataField]
  48. public List<string> Components = new();
  49. /// <summary>
  50. /// The icon path for the Examine Group.
  51. /// </summary>
  52. [DataField]
  53. public SpriteSpecifier Icon = new SpriteSpecifier.Texture(new("/Textures/Interface/examine-star.png"));
  54. /// <summary>
  55. /// The text shown in the context verb menu.
  56. /// </summary>
  57. [DataField]
  58. public LocId ContextText = "verb-examine-group-other";
  59. /// <summary>
  60. /// Details shown when hovering over the button.
  61. /// </summary>
  62. [DataField]
  63. public string HoverMessage = string.Empty;
  64. }
  65. /// <summary>
  66. /// An entry used when showing examine details
  67. /// </summary>
  68. [Serializable, NetSerializable, DataDefinition]
  69. public sealed partial class ExamineEntry
  70. {
  71. /// <summary>
  72. /// Which component does this entry relate to?
  73. /// </summary>
  74. [DataField(required: true)]
  75. public string Component;
  76. /// <summary>
  77. /// What priority has this entry - entries are sorted high to low.
  78. /// </summary>
  79. [DataField]
  80. public float Priority = 0f;
  81. /// <summary>
  82. /// The FormattedMessage of this entry.
  83. /// </summary>
  84. [DataField(required: true)]
  85. public FormattedMessage Message;
  86. /// <param name="component">Should be set to _componentFactory.GetComponentName(component.GetType()) to properly function.</param>
  87. public ExamineEntry(string component, float priority, FormattedMessage message)
  88. {
  89. Component = component;
  90. Priority = priority;
  91. Message = message;
  92. }
  93. private ExamineEntry()
  94. {
  95. // parameterless ctor is required for data-definition serialization
  96. Message = default!;
  97. Component = default!;
  98. }
  99. }
  100. }