public sealed partial class LabelComponent : Component
{
/// <summary>
- /// The actual text in the label
+ /// Current text on the label. If set before map init, during map init this string will be localized.
+ /// This permits localized preset labels with fallback to the text written on the label.
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
[DataField("currentLabel")]
public string? CurrentLabel { get; set; }
+ /// <summary>
+ /// The original name of the entity
+ /// Used for reverting the modified entity name when the label is removed
+ /// </summary>
[DataField("originalName")]
public string? OriginalName { get; set; }
}
base.Initialize();
SubscribeLocalEvent<LabelComponent, ExaminedEvent>(OnExamine);
+ SubscribeLocalEvent<LabelComponent, MapInitEvent>(OnLabelCompMapInit);
SubscribeLocalEvent<PaperLabelComponent, ComponentInit>(OnComponentInit);
SubscribeLocalEvent<PaperLabelComponent, ComponentRemove>(OnComponentRemove);
SubscribeLocalEvent<PaperLabelComponent, EntInsertedIntoContainerMessage>(OnContainerModified);
SubscribeLocalEvent<PaperLabelComponent, ExaminedEvent>(OnExamined);
}
+ private void OnLabelCompMapInit(EntityUid uid, LabelComponent component, MapInitEvent args)
+ {
+ if (!string.IsNullOrEmpty(component.CurrentLabel))
+ component.CurrentLabel = Loc.GetString(component.CurrentLabel);
+ }
+
/// <summary>
/// Apply or remove a label on an entity.
/// </summary>
noSpawn: true
components:
- type: Label
- currentLabel: carbon
+ currentLabel: reagent-name-carbon
- type: SolutionContainerManager
solutions:
beaker:
noSpawn: true
components:
- type: Label
- currentLabel: iodine
+ currentLabel: reagent-name-iodine
- type: SolutionContainerManager
solutions:
beaker:
noSpawn: true
components:
- type: Label
- currentLabel: fluorine
+ currentLabel: reagent-name-fluorine
- type: SolutionContainerManager
solutions:
beaker:
noSpawn: true
components:
- type: Label
- currentLabel: chlorine
+ currentLabel: reagent-name-chlorine
- type: SolutionContainerManager
solutions:
beaker:
noSpawn: true
components:
- type: Label
- currentLabel: aluminium
+ currentLabel: reagent-name-aluminium
- type: SolutionContainerManager
solutions:
beaker:
noSpawn: true
components:
- type: Label
- currentLabel: phosphorus
+ currentLabel: reagent-name-phosphorus
- type: SolutionContainerManager
solutions:
beaker:
noSpawn: true
components:
- type: Label
- currentLabel: sulfur
+ currentLabel: reagent-name-sulfur
- type: SolutionContainerManager
solutions:
beaker:
noSpawn: true
components:
- type: Label
- currentLabel: silicon
+ currentLabel: reagent-name-silicon
- type: SolutionContainerManager
solutions:
beaker:
noSpawn: true
components:
- type: Label
- currentLabel: hydrogen
+ currentLabel: reagent-name-hydrogen
- type: SolutionContainerManager
solutions:
beaker:
noSpawn: true
components:
- type: Label
- currentLabel: lithium
+ currentLabel: reagent-name-lithium
- type: SolutionContainerManager
solutions:
beaker:
noSpawn: true
components:
- type: Label
- currentLabel: sodium
+ currentLabel: reagent-name-sodium
- type: SolutionContainerManager
solutions:
beaker:
noSpawn: true
components:
- type: Label
- currentLabel: potassium
+ currentLabel: reagent-name-potassium
- type: SolutionContainerManager
solutions:
beaker:
noSpawn: true
components:
- type: Label
- currentLabel: radium
+ currentLabel: reagent-name-radium
- type: SolutionContainerManager
solutions:
beaker:
noSpawn: true
components:
- type: Label
- currentLabel: iron
+ currentLabel: reagent-name-iron
- type: SolutionContainerManager
solutions:
beaker:
noSpawn: true
components:
- type: Label
- currentLabel: copper
+ currentLabel: reagent-name-copper
- type: SolutionContainerManager
solutions:
beaker:
noSpawn: true
components:
- type: Label
- currentLabel: gold
+ currentLabel: reagent-name-gold
- type: SolutionContainerManager
solutions:
beaker:
noSpawn: true
components:
- type: Label
- currentLabel: mercury
+ currentLabel: reagent-name-mercury
- type: SolutionContainerManager
solutions:
beaker:
noSpawn: true
components:
- type: Label
- currentLabel: silver
+ currentLabel: reagent-name-silver
- type: SolutionContainerManager
solutions:
beaker:
noSpawn: true
components:
- type: Label
- currentLabel: ethanol
+ currentLabel: reagent-name-ethanol
- type: SolutionContainerManager
solutions:
beaker:
noSpawn: true
components:
- type: Label
- currentLabel: sugar
+ currentLabel: reagent-name-sugar
- type: SolutionContainerManager
solutions:
beaker:
noSpawn: true
components:
- type: Label
- currentLabel: nitrogen
+ currentLabel: reagent-name-nitrogen
- type: SolutionContainerManager
solutions:
beaker:
noSpawn: true
components:
- type: Label
- currentLabel: oxygen
+ currentLabel: reagent-name-oxygen
- type: SolutionContainerManager
solutions:
beaker:
noSpawn: true
components:
- type: Label
- currentLabel: Plant-B-Gone
+ currentLabel: reagent-name-plant-b-gone
- type: SolutionContainerManager
solutions:
beaker:
noSpawn: true
components:
- type: Label
- currentLabel: welding fuel
+ currentLabel: reagent-name-welding-fuel
- type: SolutionContainerManager
solutions:
beaker: