diff --git a/Content.Client/Labels/UI/HandLabelerBoundUserInterface.cs b/Content.Client/Labels/UI/HandLabelerBoundUserInterface.cs
index 95d5cc7ab32..8cab1a42664 100644
--- a/Content.Client/Labels/UI/HandLabelerBoundUserInterface.cs
+++ b/Content.Client/Labels/UI/HandLabelerBoundUserInterface.cs
@@ -32,10 +32,10 @@ namespace Content.Client.Labels.UI
}
_window.OnLabelChanged += OnLabelChanged;
+ _window.OnLabelSelected += OnLabelSelected; // Starlight
Reload();
_window.SetInitialLabelState(); // Must be after Reload() has set the label text
}
-
private void OnLabelChanged(string newLabel)
{
// Focus moment
@@ -45,7 +45,17 @@ namespace Content.Client.Labels.UI
SendPredictedMessage(new HandLabelerLabelChangedMessage(newLabel));
}
-
+ // Starlight start
+ private void OnLabelSelected(string label)
+ {
+ // Update UI and send message to sync with server
+ if (_window != null)
+ {
+ _window.SetCurrentLabel(label);
+ }
+ SendPredictedMessage(new HandLabelerLabelChangedMessage(label));
+ }
+ // Starlight End
public void Reload()
{
if (_window == null || !_entManager.TryGetComponent(Owner, out HandLabelerComponent? component))
diff --git a/Content.Client/Labels/UI/HandLabelerWindow.xaml b/Content.Client/Labels/UI/HandLabelerWindow.xaml
index 7bbadb843d6..4a00420aeef 100644
--- a/Content.Client/Labels/UI/HandLabelerWindow.xaml
+++ b/Content.Client/Labels/UI/HandLabelerWindow.xaml
@@ -1,8 +1,10 @@
+ MinWidth="150"
+ SetHeight="400">
@@ -10,5 +12,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Content.Client/Labels/UI/HandLabelerWindow.xaml.cs b/Content.Client/Labels/UI/HandLabelerWindow.xaml.cs
index 32c9d980a4b..e95eba185ec 100644
--- a/Content.Client/Labels/UI/HandLabelerWindow.xaml.cs
+++ b/Content.Client/Labels/UI/HandLabelerWindow.xaml.cs
@@ -1,13 +1,19 @@
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.XAML;
+using Robust.Client.UserInterface.Controls; // Starlight
+using Robust.Shared.Configuration; // Starlight
+using Content.Shared.Starlight.CCVar; // Starlight
namespace Content.Client.Labels.UI
{
[GenerateTypedNameReferences]
public sealed partial class HandLabelerWindow : DefaultWindow
{
+ [Dependency] private readonly IConfigurationManager _cfg = default!; // Starlight
+
public event Action? OnLabelChanged;
+ public event Action? OnLabelSelected; // Starlight
///
/// Is the user currently entering text into the control?
@@ -17,10 +23,14 @@ namespace Content.Client.Labels.UI
private string _label = string.Empty;
private string _initialLabel = string.Empty;
+ private bool _deleteMode = false; // Starlight
+ private List _savedLabels = []; // Starlight
public HandLabelerWindow()
{
RobustXamlLoader.Load(this);
+ IoCManager.InjectDependencies(this); // Starlight
+ LoadSavedLabelsFromCVar(); // Starlight
LabelLineEdit.OnTextChanged += e =>
{
@@ -37,6 +47,42 @@ namespace Content.Client.Labels.UI
};
ResetLabelButton.OnPressed += _ => LabelLineEdit.SetText(_initialLabel, true);
ClearLabelButton.OnPressed += _ => LabelLineEdit.SetText("", true);
+
+ // Starlight Begin
+ SaveLabelButton.OnPressed += _ =>
+ {
+ if (!string.IsNullOrWhiteSpace(_label) && !_savedLabels.Contains(_label))
+ {
+ _savedLabels.Add(_label);
+ SaveSavedLabelsToCVar();
+ UpdateSavedLabels(_savedLabels);
+ }
+ };
+
+ DeleteLabelButton.OnPressed += _ =>
+ {
+ _deleteMode = !_deleteMode;
+ DeleteLabelButton.Pressed = _deleteMode;
+ UpdateButtons();
+ };
+
+ SavedLabelsList.OnItemSelected += args =>
+ {
+ if (_deleteMode)
+ {
+ _savedLabels.RemoveAt(args.ItemIndex);
+ SaveSavedLabelsToCVar();
+ UpdateSavedLabels(_savedLabels);
+ UpdateButtons();
+ }
+ else
+ {
+ if (SavedLabelsList[args.ItemIndex].Metadata is string label)
+ {
+ OnLabelSelected?.Invoke(label);
+ }
+ }
+ }; // Starlight End
}
protected override void Opened()
@@ -70,15 +116,68 @@ namespace Content.Client.Labels.UI
UpdateButtons();
}
+ // Starlight begin
+ public void UpdateSavedLabels(List labels)
+ {
+ var items = new List();
+ foreach (var label in labels)
+ {
+ var item = new ItemList.Item(SavedLabelsList)
+ {
+ Text = label,
+ Metadata = label
+ };
+ items.Add(item);
+ }
+ SavedLabelsList.SetItems(items);
+ UpdateButtons();
+ }
+ // Starlight end
+
public void UpdateButtons()
{
ResetLabelButton.Disabled = (LabelLineEdit.Text == _initialLabel);
ClearLabelButton.Disabled = (LabelLineEdit.Text == "");
- }
+ // Starlight begin
+ var labelExists = false;
+ foreach (var item in SavedLabelsList)
+ {
+ if ((item.Metadata as string) == _label.Trim())
+ {
+ labelExists = true;
+ break;
+ }
+ }
+ SaveLabelButton.Disabled = string.IsNullOrWhiteSpace(_label) || labelExists;
+
+ DeleteLabelButton.Text = _deleteMode
+ ? Loc.GetString("hand-labeler-delete-mode-text")
+ : Loc.GetString("hand-labeler-delete-label-text");
+
+ // Starlight end
+ }
public void SetMaxLabelLength(int maxLength)
{
LabelLineEdit.IsValid = s => s.Length <= maxLength;
}
+ // Starlight begin
+ private void LoadSavedLabelsFromCVar()
+ {
+ var savedLabelsStr = _cfg.GetCVar(StarlightCCVars.HandLabelerSavedLabels);
+ if (!string.IsNullOrEmpty(savedLabelsStr))
+ {
+ _savedLabels = new List(savedLabelsStr.Split('\n', StringSplitOptions.RemoveEmptyEntries));
+ UpdateSavedLabels(_savedLabels);
+ }
+ }
+
+ private void SaveSavedLabelsToCVar()
+ {
+ var savedLabelsStr = string.Join('\n', _savedLabels);
+ _cfg.SetCVar(StarlightCCVars.HandLabelerSavedLabels, savedLabelsStr);
+ _cfg.SaveToFile();
+ }
+ // Starlight end
}
}
diff --git a/Content.Shared/Labels/EntitySystems/LabelSystem.cs b/Content.Shared/Labels/EntitySystems/LabelSystem.cs
index 59edeba6744..2e51963573c 100644
--- a/Content.Shared/Labels/EntitySystems/LabelSystem.cs
+++ b/Content.Shared/Labels/EntitySystems/LabelSystem.cs
@@ -90,7 +90,7 @@ public sealed partial class LabelSystem : EntitySystem
private void OnRefreshNameModifiers(Entity entity, ref RefreshNameModifiersEvent args)
{
if (!string.IsNullOrEmpty(entity.Comp.CurrentLabel))
- args.AddModifier("comp-label-format", extraArgs: ("label", entity.Comp.CurrentLabel));
+ args.AddModifier("comp-label-format", 100, extraArgs: ("label", entity.Comp.CurrentLabel)); // Coyote: add priority of 100 to reverse order of label and baseName
}
private void OnComponentInit(Entity ent, ref ComponentInit args)
diff --git a/Content.Shared/_Starlight/CCVar/StarlightCCVar.cs b/Content.Shared/_Starlight/CCVar/StarlightCCVar.cs
new file mode 100644
index 00000000000..baa6003bade
--- /dev/null
+++ b/Content.Shared/_Starlight/CCVar/StarlightCCVar.cs
@@ -0,0 +1,10 @@
+using Robust.Shared.Configuration;
+using Content.Shared.CCVar.CVarAccess;
+using Content.Shared.Administration;
+
+namespace Content.Shared.Starlight.CCVar;
+
+[CVarDefs]
+public sealed partial class StarlightCCVars
+{
+}
diff --git a/Content.Shared/_Starlight/CCVar/StarlightCCVars.Interface.cs b/Content.Shared/_Starlight/CCVar/StarlightCCVars.Interface.cs
new file mode 100644
index 00000000000..b0667a6a10d
--- /dev/null
+++ b/Content.Shared/_Starlight/CCVar/StarlightCCVars.Interface.cs
@@ -0,0 +1,13 @@
+using Robust.Shared.Configuration;
+
+namespace Content.Shared.Starlight.CCVar;
+
+public sealed partial class StarlightCCVars
+{
+ ///
+ /// A newline-separated list of saved labels for the hand labeler tool
+ ///
+ public static readonly CVarDef HandLabelerSavedLabels =
+ CVarDef.Create("interface.hand_labeler_saved_labels", "", CVar.CLIENTONLY | CVar.ARCHIVE);
+
+}
diff --git a/Resources/Locale/en-US/_Starlight/hand-labeler/hand-labeler.ftl b/Resources/Locale/en-US/_Starlight/hand-labeler/hand-labeler.ftl
new file mode 100644
index 00000000000..02b44c52a78
--- /dev/null
+++ b/Resources/Locale/en-US/_Starlight/hand-labeler/hand-labeler.ftl
@@ -0,0 +1,12 @@
+hand-labeler-saved-labels = Saved Labels:
+
+
+# The text on the button in the ui to save a label to the saved label list.
+hand-labeler-save-label-text = Save Label
+
+# The text on the button in the ui to delete a label from the saved label list.
+hand-labeler-delete-label-text = Delete Label
+
+# The text on the button when in delete mode.
+hand-labeler-delete-mode-text = Deleting...
+
diff --git a/Resources/Locale/en-US/label/label-component.ftl b/Resources/Locale/en-US/label/label-component.ftl
index ff3a250c7b8..940fbbe09d0 100644
--- a/Resources/Locale/en-US/label/label-component.ftl
+++ b/Resources/Locale/en-US/label/label-component.ftl
@@ -1 +1,2 @@
-comp-label-format = {$baseName} ({$label})
+# Coyote: reverse order of label and baseName
+comp-label-format = {$label} ({$baseName})