From d9bb797d322698e1c6214c1f25af77a7bbf77a13 Mon Sep 17 00:00:00 2001 From: vitopigno <103512727+VitusVeit@users.noreply.github.com> Date: Wed, 4 Jun 2025 12:12:37 +0200 Subject: [PATCH] Add text highlighting (#31442) Heavy DeltaV modications by Vanessa Co-authored-by: ScarKy0 <106310278+ScarKy0@users.noreply.github.com> Co-authored-by: Hans Larsson Co-authored-by: Tobias Berger Co-authored-by: Vanessa --- .../Options/UI/OptionColorSlider.xaml | 0 .../Options/UI/OptionColorSlider.xaml.cs | 3 +- .../Options/UI/OptionsTabControlRow.xaml.cs | 65 ++++ .../Options/UI/Tabs/AccessibilityTab.xaml | 4 + .../Options/UI/Tabs/AccessibilityTab.xaml.cs | 2 + .../Chat/ChatUIController.Highlighting.cs | 164 ++++++++ .../Systems/Chat/ChatUIController.cs | 10 +- .../Chat/Controls/ChannelFilterPopup.xaml | 13 +- .../Chat/Controls/ChannelFilterPopup.xaml.cs | 30 +- .../Systems/Chat/Widgets/ChatBox.xaml.cs | 15 +- .../Options/UI/OptionsTabControlRow.xaml.cs | 20 - .../_DV/Options/UI/OptionsTabControls.cs | 56 --- .../_DV/Options/UI/Tabs/DeltaTab.xaml | 5 +- .../_DV/Options/UI/Tabs/DeltaTab.xaml.cs | 5 +- .../Systems/Chat/ChatUIController.cs | 151 +++----- .../Chat/Controls/ChannelFilterPopup.xaml.cs | 23 -- .../Chat/Controls/Widgets/ChatBox.xaml.cs | 9 - Content.Shared/CCVar/CCVars.Chat.cs | 19 + Content.Shared/_DV/CCVars/DCCVars.cs | 4 +- .../Locale/en-US/_DV/chat/highlights.ftl | 365 ++---------------- .../Locale/en-US/_DV/chat/ui/chat-box.ftl | 8 - .../en-US/_DV/escape-menu/options-menu.ftl | 5 - Resources/Locale/en-US/chat/highlights.ftl | 58 +++ Resources/Locale/en-US/chat/ui/chat-box.ftl | 9 + .../en-US/escape-menu/ui/options-menu.ftl | 3 + .../_DV/Catalog/Chat/highlights.yml | 329 ---------------- 26 files changed, 486 insertions(+), 889 deletions(-) rename Content.Client/{_DV => }/Options/UI/OptionColorSlider.xaml (100%) rename Content.Client/{_DV => }/Options/UI/OptionColorSlider.xaml.cs (91%) create mode 100644 Content.Client/UserInterface/Systems/Chat/ChatUIController.Highlighting.cs delete mode 100644 Content.Client/_DV/Options/UI/OptionsTabControlRow.xaml.cs delete mode 100644 Content.Client/_DV/Options/UI/OptionsTabControls.cs delete mode 100644 Content.Client/_DV/UserInterfaces/Systems/Chat/Controls/Widgets/ChatBox.xaml.cs create mode 100644 Resources/Locale/en-US/chat/highlights.ftl delete mode 100644 Resources/Prototypes/_DV/Catalog/Chat/highlights.yml diff --git a/Content.Client/_DV/Options/UI/OptionColorSlider.xaml b/Content.Client/Options/UI/OptionColorSlider.xaml similarity index 100% rename from Content.Client/_DV/Options/UI/OptionColorSlider.xaml rename to Content.Client/Options/UI/OptionColorSlider.xaml diff --git a/Content.Client/_DV/Options/UI/OptionColorSlider.xaml.cs b/Content.Client/Options/UI/OptionColorSlider.xaml.cs similarity index 91% rename from Content.Client/_DV/Options/UI/OptionColorSlider.xaml.cs rename to Content.Client/Options/UI/OptionColorSlider.xaml.cs index ec30ada818..6f8f46a3b4 100644 --- a/Content.Client/_DV/Options/UI/OptionColorSlider.xaml.cs +++ b/Content.Client/Options/UI/OptionColorSlider.xaml.cs @@ -1,7 +1,8 @@ +using Content.Client.Options.UI; using Robust.Client.AutoGenerated; using Robust.Client.UserInterface; -namespace Content.Client._DV.Options.UI; +namespace Content.Client.Options.UI; /// /// Standard UI control used for color sliders in the options menu. Intended for use with . diff --git a/Content.Client/Options/UI/OptionsTabControlRow.xaml.cs b/Content.Client/Options/UI/OptionsTabControlRow.xaml.cs index 31dd9897f4..ad262f94a2 100644 --- a/Content.Client/Options/UI/OptionsTabControlRow.xaml.cs +++ b/Content.Client/Options/UI/OptionsTabControlRow.xaml.cs @@ -121,6 +121,19 @@ public sealed partial class OptionsTabControlRow : Control return AddOption(new OptionSliderFloatCVar(this, _cfg, cVar, slider, min, max, scale, FormatPercent)); } + /// + /// Add a color slider option, backed by a simple string CVar. + /// + /// The CVar represented by the slider. + /// The UI control for the option. + /// The option instance backing the added option. + public OptionColorSliderCVar AddOptionColorSlider( + CVarDef cVar, + OptionColorSlider slider) + { + return AddOption(new OptionColorSliderCVar(this, _cfg, cVar, slider)); + } + /// /// Add a slider option, backed by a simple integer CVar. /// @@ -518,6 +531,58 @@ public sealed class OptionSliderFloatCVar : BaseOptionCVar } } +/// +/// Implementation of a CVar option that simply corresponds with a string . +/// +/// +public sealed class OptionColorSliderCVar : BaseOptionCVar +{ + private readonly OptionColorSlider _slider; + + protected override string Value + { + get => _slider.Slider.Color.ToHex(); + set + { + _slider.Slider.Color = Color.FromHex(value); + UpdateLabelColor(); + } + } + + /// + /// Creates a new instance of this type. + /// + /// + /// + /// It is generally more convenient to call overloads on + /// such as instead of instantiating this type directly. + /// + /// + /// The control row that owns this option. + /// The configuration manager to get and set values from. + /// The CVar that is being controlled by this option. + /// The UI control for the option. + public OptionColorSliderCVar( + OptionsTabControlRow controller, + IConfigurationManager cfg, + CVarDef cVar, + OptionColorSlider slider) : base(controller, cfg, cVar) + { + _slider = slider; + + slider.Slider.OnColorChanged += _ => + { + ValueChanged(); + UpdateLabelColor(); + }; + } + + private void UpdateLabelColor() + { + _slider.ExampleLabel.FontColorOverride = Color.FromHex(Value); + } +} + /// /// Implementation of a CVar option that simply corresponds with an integer . /// diff --git a/Content.Client/Options/UI/Tabs/AccessibilityTab.xaml b/Content.Client/Options/UI/Tabs/AccessibilityTab.xaml index 5041b498a0..41fac83c59 100644 --- a/Content.Client/Options/UI/Tabs/AccessibilityTab.xaml +++ b/Content.Client/Options/UI/Tabs/AccessibilityTab.xaml @@ -14,6 +14,10 @@ + +