From 627a282e1ae60a61d39c5fbb737aca9101966d6a Mon Sep 17 00:00:00 2001 From: Morb <14136326+Morb0@users.noreply.github.com> Date: Mon, 28 Aug 2023 13:01:45 +0300 Subject: [PATCH] Improve flavor UI (#19600) Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> --- Content.Client/FlavorText/FlavorText.xaml | 2 +- Content.Client/FlavorText/FlavorText.xaml.cs | 7 +++++-- .../Preferences/UI/HumanoidProfileEditor.xaml.cs | 4 ++-- Resources/Locale/en-US/preferences/ui/flavor-text.ftl | 1 + 4 files changed, 9 insertions(+), 5 deletions(-) create mode 100644 Resources/Locale/en-US/preferences/ui/flavor-text.ftl diff --git a/Content.Client/FlavorText/FlavorText.xaml b/Content.Client/FlavorText/FlavorText.xaml index f837702686..37d4b5fda0 100644 --- a/Content.Client/FlavorText/FlavorText.xaml +++ b/Content.Client/FlavorText/FlavorText.xaml @@ -1,5 +1,5 @@  - + diff --git a/Content.Client/FlavorText/FlavorText.xaml.cs b/Content.Client/FlavorText/FlavorText.xaml.cs index f9eadca314..ffcf653f11 100644 --- a/Content.Client/FlavorText/FlavorText.xaml.cs +++ b/Content.Client/FlavorText/FlavorText.xaml.cs @@ -1,6 +1,7 @@ using Robust.Client.AutoGenerated; using Robust.Client.UserInterface; using Robust.Client.UserInterface.XAML; +using Robust.Shared.Utility; namespace Content.Client.FlavorText { @@ -14,12 +15,14 @@ namespace Content.Client.FlavorText RobustXamlLoader.Load(this); IoCManager.InjectDependencies(this); - CFlavorTextInput.OnTextChanged += _ => FlavorTextChanged(); + var loc = IoCManager.Resolve(); + CFlavorTextInput.Placeholder = new Rope.Leaf(loc.GetString("flavor-text-placeholder")); + CFlavorTextInput.OnKeyBindDown += _ => FlavorTextChanged(); } public void FlavorTextChanged() { - OnFlavorTextChanged?.Invoke(CFlavorTextInput.Text); + OnFlavorTextChanged?.Invoke(Rope.Collapse(CFlavorTextInput.TextRope).Trim()); } } } diff --git a/Content.Client/Preferences/UI/HumanoidProfileEditor.xaml.cs b/Content.Client/Preferences/UI/HumanoidProfileEditor.xaml.cs index 6d1d808905..f25251c8ac 100644 --- a/Content.Client/Preferences/UI/HumanoidProfileEditor.xaml.cs +++ b/Content.Client/Preferences/UI/HumanoidProfileEditor.xaml.cs @@ -60,7 +60,7 @@ namespace Content.Client.Preferences.UI private LineEdit _ageEdit => CAgeEdit; private LineEdit _nameEdit => CNameEdit; - private LineEdit _flavorTextEdit = null!; + private TextEdit _flavorTextEdit = null!; private Button _nameRandomButton => CNameRandomize; private Button _randomizeEverythingButton => CRandomizeEverything; private RichTextLabel _warningLabel => CWarningLabel; @@ -858,7 +858,7 @@ namespace Content.Client.Preferences.UI { if(_flavorTextEdit != null) { - _flavorTextEdit.Text = Profile?.FlavorText ?? ""; + _flavorTextEdit.TextRope = new Rope.Leaf(Profile?.FlavorText ?? ""); } } diff --git a/Resources/Locale/en-US/preferences/ui/flavor-text.ftl b/Resources/Locale/en-US/preferences/ui/flavor-text.ftl new file mode 100644 index 0000000000..e7172c1528 --- /dev/null +++ b/Resources/Locale/en-US/preferences/ui/flavor-text.ftl @@ -0,0 +1 @@ +flavor-text-placeholder = An outer description of your character that others can get by looking at them...