Localize preset labels on chem dispenser (#24617)
This commit is contained in:
@@ -7,12 +7,17 @@ namespace Content.Server.Labels.Components
|
||||
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; }
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ namespace Content.Server.Labels
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<LabelComponent, ExaminedEvent>(OnExamine);
|
||||
SubscribeLocalEvent<LabelComponent, MapInitEvent>(OnLabelCompMapInit);
|
||||
SubscribeLocalEvent<PaperLabelComponent, ComponentInit>(OnComponentInit);
|
||||
SubscribeLocalEvent<PaperLabelComponent, ComponentRemove>(OnComponentRemove);
|
||||
SubscribeLocalEvent<PaperLabelComponent, EntInsertedIntoContainerMessage>(OnContainerModified);
|
||||
@@ -34,6 +35,12 @@ namespace Content.Server.Labels
|
||||
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>
|
||||
|
||||
Reference in New Issue
Block a user