using Robust.Shared.Serialization;
using Robust.Shared.Utility;
namespace Content.Shared.Examine
{
///
/// This component groups examine messages together
///
[RegisterComponent]
public sealed class GroupExamineComponent : Component
{
///
/// A list of ExamineGroups.
///
[DataField("group")]
public List ExamineGroups = new()
{
// TODO Remove hardcoded component names.
new ExamineGroup()
{
Components = new()
{
"Armor",
"ClothingSpeedModifier",
},
},
};
}
[DataDefinition]
public sealed class ExamineGroup
{
///
/// The title of the Examine Group. Localized string that gets added to the examine tooltip.
///
[DataField("title")]
[ViewVariables(VVAccess.ReadWrite)]
public string? Title;
///
/// A list of ExamineEntries, containing which component it belongs to, which priority it has, and what FormattedMessage it holds.
///
[DataField("entries")]
public List Entries = new();
// TODO custom type serializer, or just make this work via some other automatic grouping process that doesn't
// rely on manually specifying component names in yaml.
///
/// A list of all components this ExamineGroup encompasses.
///
[DataField("components")]
public List Components = new();
///
/// The icon path for the Examine Group.
///
[DataField("icon")]
public SpriteSpecifier Icon = new SpriteSpecifier.Texture(new("/Textures/Interface/examine-star.png"));
///
/// The text shown in the context verb menu.
///
[DataField("contextText")]
public string ContextText = "verb-examine-group-other";
///
/// Details shown when hovering over the button.
///
[DataField("hoverMessage")]
public string HoverMessage = string.Empty;
}
///
/// An entry used when showing examine details
///
[Serializable, NetSerializable, DataDefinition]
public sealed class ExamineEntry
{
///
/// Which component does this entry relate to?
///
[DataField("component", required: true)]
public string ComponentName;
///
/// What priority has this entry - entries are sorted high to low.
///
[DataField("priority")]
public float Priority = 0f;
///
/// The FormattedMessage of this entry.
///
[DataField("message", required: true)]
public FormattedMessage Message;
/// Should be set to _componentFactory.GetComponentName(component.GetType()) to properly function.
public ExamineEntry(string componentName, float priority, FormattedMessage message)
{
ComponentName = componentName;
Priority = priority;
Message = message;
}
private ExamineEntry()
{
// parameterless ctor is required for data-definition serialization
Message = default!;
ComponentName = default!;
}
}
}