]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Move HUD options to general options tab (#22884)
authorNemanja <98561806+EmoGarbage404@users.noreply.github.com>
Sat, 23 Dec 2023 06:32:56 +0000 (01:32 -0500)
committerGitHub <noreply@github.com>
Sat, 23 Dec 2023 06:32:56 +0000 (23:32 -0700)
Content.Client/Options/UI/Tabs/GraphicsTab.xaml
Content.Client/Options/UI/Tabs/GraphicsTab.xaml.cs
Content.Client/Options/UI/Tabs/MiscTab.xaml
Content.Client/Options/UI/Tabs/MiscTab.xaml.cs
Content.Shared/HUD/HudThemePrototype.cs
Resources/Locale/en-US/escape-menu/ui/options-menu.ftl
Resources/Prototypes/hud.yml

index 74a0c78c526df1f3cf0b67b6fb6bcebb2e272422..118b85b87baba11d7c42a357efcd8991d8a94d88 100644 (file)
                 <Control MinSize="4 0" />
                 <OptionButton Name="UIScaleOption" />
             </BoxContainer>
-            <BoxContainer Orientation="Horizontal">
-                <Label Text="{Loc 'ui-options-hud-theme'}" />
-                <Control MinSize="4 0" />
-                <OptionButton Name="HudThemeOption" />
-            </BoxContainer>
             <BoxContainer Orientation="Horizontal">
                 <CheckBox Name="ViewportStretchCheckBox" Text="{Loc 'ui-options-vp-stretch'}" />
                 <BoxContainer Name="ViewportScaleBox" Orientation="Horizontal">
                         Rounded="True"
                         MinWidth="200" />
             </BoxContainer>
-            <BoxContainer Orientation="Horizontal">
-                <Label Text="{Loc 'ui-options-hud-layout'}" />
-                <Control MinSize="4 0" />
-                <OptionButton Name="HudLayoutOption" />
-            </BoxContainer>
             <CheckBox Name="IntegerScalingCheckBox"
                       Text="{Loc 'ui-options-vp-integer-scaling'}"
                       ToolTip="{Loc 'ui-options-vp-integer-scaling-tooltip'}" />
index 1773b2abe5dc98027dc9b995cd5dffe8c8bd2f39..3113e644bac9671ed12b4619872a20d7a0711054 100644 (file)
@@ -1,6 +1,4 @@
-using Content.Client.UserInterface.Screens;
 using Content.Shared.CCVar;
-using Content.Shared.HUD;
 using Robust.Client.AutoGenerated;
 using Robust.Client.Graphics;
 using Robust.Client.UserInterface;
@@ -8,7 +6,6 @@ using Robust.Client.UserInterface.Controls;
 using Robust.Client.UserInterface.XAML;
 using Robust.Shared;
 using Robust.Shared.Configuration;
-using Robust.Shared.Prototypes;
 
 namespace Content.Client.Options.UI.Tabs
 {
@@ -26,10 +23,7 @@ namespace Content.Client.Options.UI.Tabs
             2f
         };
 
-        private Dictionary<string, int> hudThemeIdToIndex = new();
-
         [Dependency] private readonly IConfigurationManager _cfg = default!;
-        [Dependency] private readonly IPrototypeManager _prototypeManager = default!;
 
         public GraphicsTab()
         {
@@ -55,34 +49,6 @@ namespace Content.Client.Options.UI.Tabs
             UIScaleOption.AddItem(Loc.GetString("ui-options-scale-200"));
             UIScaleOption.OnItemSelected += OnUIScaleChanged;
 
-            foreach (var gear in _prototypeManager.EnumeratePrototypes<HudThemePrototype>())
-            {
-                HudThemeOption.AddItem(Loc.GetString(gear.Name));
-                hudThemeIdToIndex.Add(gear.ID, HudThemeOption.GetItemId(HudThemeOption.ItemCount - 1));
-            }
-            HudThemeOption.OnItemSelected += OnHudThemeChanged;
-
-            var hudLayout = _cfg.GetCVar(CCVars.UILayout);
-            var id = 0;
-            foreach (var layout in Enum.GetValues(typeof(ScreenType)))
-            {
-                var name = layout.ToString()!;
-                HudLayoutOption.AddItem(name, id);
-                if (name == hudLayout)
-                {
-                    HudLayoutOption.SelectId(id);
-                }
-                HudLayoutOption.SetItemMetadata(id, name);
-
-                id++;
-            }
-
-            HudLayoutOption.OnItemSelected += args =>
-            {
-                HudLayoutOption.SelectId(args.Id);
-                UpdateApplyButton();
-            };
-
             ViewportStretchCheckBox.OnToggled += _ =>
             {
                 UpdateViewportScale();
@@ -110,7 +76,6 @@ namespace Content.Client.Options.UI.Tabs
             FullscreenCheckBox.Pressed = ConfigIsFullscreen;
             LightingPresetOption.SelectId(GetConfigLightingQuality());
             UIScaleOption.SelectId(GetConfigUIScalePreset(ConfigUIScale));
-            HudThemeOption.SelectId(hudThemeIdToIndex.GetValueOrDefault(_cfg.GetCVar(CVars.InterfaceTheme), 0));
             ViewportScaleSlider.Value = _cfg.GetCVar(CCVars.ViewportFixedScaleFactor);
             ViewportStretchCheckBox.Pressed = _cfg.GetCVar(CCVars.ViewportStretch);
             IntegerScalingCheckBox.Pressed = _cfg.GetCVar(CCVars.ViewportSnapToleranceMargin) != 0;
@@ -134,25 +99,11 @@ namespace Content.Client.Options.UI.Tabs
             UpdateApplyButton();
         }
 
-        private void OnHudThemeChanged(OptionButton.ItemSelectedEventArgs args)
-        {
-            HudThemeOption.SelectId(args.Id);
-            UpdateApplyButton();
-        }
-
         private void OnApplyButtonPressed(BaseButton.ButtonEventArgs args)
         {
             _cfg.SetCVar(CVars.DisplayVSync, VSyncCheckBox.Pressed);
             SetConfigLightingQuality(LightingPresetOption.SelectedId);
 
-            foreach (var theme in _prototypeManager.EnumeratePrototypes<HudThemePrototype>())
-            {
-                if (hudThemeIdToIndex[theme.ID] != HudThemeOption.SelectedId)
-                    continue;
-                _cfg.SetCVar(CVars.InterfaceTheme, theme.ID);
-                break;
-            }
-
             _cfg.SetCVar(CVars.DisplayWindowMode,
                          (int) (FullscreenCheckBox.Pressed ? WindowMode.Fullscreen : WindowMode.Windowed));
             _cfg.SetCVar(CVars.DisplayUIScale, UIScaleOptions[UIScaleOption.SelectedId]);
@@ -165,11 +116,6 @@ namespace Content.Client.Options.UI.Tabs
             _cfg.SetCVar(CCVars.HudFpsCounterVisible, FpsCounterCheckBox.Pressed);
             _cfg.SetCVar(CCVars.ViewportWidth, (int) ViewportWidthSlider.Value);
 
-            if (HudLayoutOption.SelectedMetadata is string opt)
-            {
-                _cfg.SetCVar(CCVars.UILayout, opt);
-            }
-
             _cfg.SaveToFile();
             UpdateApplyButton();
         }
@@ -190,7 +136,6 @@ namespace Content.Client.Options.UI.Tabs
             var isVSyncSame = VSyncCheckBox.Pressed == _cfg.GetCVar(CVars.DisplayVSync);
             var isFullscreenSame = FullscreenCheckBox.Pressed == ConfigIsFullscreen;
             var isLightingQualitySame = LightingPresetOption.SelectedId == GetConfigLightingQuality();
-            var isHudThemeSame = HudThemeOption.SelectedId == hudThemeIdToIndex.GetValueOrDefault(_cfg.GetCVar(CVars.InterfaceTheme), 0);
             var isUIScaleSame = MathHelper.CloseToPercent(UIScaleOptions[UIScaleOption.SelectedId], ConfigUIScale);
             var isVPStretchSame = ViewportStretchCheckBox.Pressed == _cfg.GetCVar(CCVars.ViewportStretch);
             var isVPScaleSame = (int) ViewportScaleSlider.Value == _cfg.GetCVar(CCVars.ViewportFixedScaleFactor);
@@ -199,7 +144,6 @@ namespace Content.Client.Options.UI.Tabs
             var isPLQSame = ParallaxLowQualityCheckBox.Pressed == _cfg.GetCVar(CCVars.ParallaxLowQuality);
             var isFpsCounterVisibleSame = FpsCounterCheckBox.Pressed == _cfg.GetCVar(CCVars.HudFpsCounterVisible);
             var isWidthSame = (int) ViewportWidthSlider.Value == _cfg.GetCVar(CCVars.ViewportWidth);
-            var isLayoutSame = HudLayoutOption.SelectedMetadata is string opt && opt == _cfg.GetCVar(CCVars.UILayout);
 
             ApplyButton.Disabled = isVSyncSame &&
                                    isFullscreenSame &&
@@ -210,10 +154,8 @@ namespace Content.Client.Options.UI.Tabs
                                    isIntegerScalingSame &&
                                    isVPResSame &&
                                    isPLQSame &&
-                                   isHudThemeSame &&
                                    isFpsCounterVisibleSame &&
-                                   isWidthSame &&
-                                   isLayoutSame;
+                                   isWidthSame;
         }
 
         private bool ConfigIsFullscreen =>
index 8097578d8e836eb757cdb0930d7125a1c77bec5a..34712e5e2f2f570259aa0602fd887c71cc70d55f 100644 (file)
@@ -5,6 +5,19 @@
                   xmlns:s="clr-namespace:Content.Client.Stylesheets">
     <BoxContainer Orientation="Vertical">
         <BoxContainer Orientation="Vertical" Margin="8 8 8 8" VerticalExpand="True">
+            <Label Text="{Loc 'ui-options-general-ui-style'}"
+                   FontColorOverride="{xNamespace:Static s:StyleNano.NanoGold}"
+                   StyleClasses="LabelKeyText"/>
+            <BoxContainer Orientation="Horizontal">
+                <Label Text="{Loc 'ui-options-hud-theme'}" />
+                <Control MinSize="4 0" />
+                <OptionButton Name="HudThemeOption" />
+            </BoxContainer>
+            <BoxContainer Orientation="Horizontal">
+                <Label Text="{Loc 'ui-options-hud-layout'}" />
+                <Control MinSize="4 0" />
+                <OptionButton Name="HudLayoutOption" />
+            </BoxContainer>
             <Label Text="{Loc 'ui-options-general-discord'}"
                    FontColorOverride="{xNamespace:Static s:StyleNano.NanoGold}"
                    StyleClasses="LabelKeyText"/>
index e870bcb622a198e955a1503c415c30b7b6b80d39..cdf8df4ee77db3ce2a95ba50259eb092b2ea548a 100644 (file)
@@ -1,25 +1,60 @@
-using Content.Shared.CCVar;
+using System.Linq;
+using Content.Client.UserInterface.Screens;
+using Content.Shared.CCVar;
+using Content.Shared.HUD;
 using Robust.Client.AutoGenerated;
 using Robust.Client.UserInterface;
 using Robust.Client.UserInterface.Controls;
 using Robust.Client.UserInterface.XAML;
 using Robust.Shared;
 using Robust.Shared.Configuration;
-using Robust.Shared.Input;
+using Robust.Shared.Prototypes;
 
 namespace Content.Client.Options.UI.Tabs
 {
     [GenerateTypedNameReferences]
     public sealed partial class MiscTab : Control
     {
-
         [Dependency] private readonly IConfigurationManager _cfg = default!;
+        [Dependency] private readonly IPrototypeManager _prototypeManager = default!;
+
+        private readonly Dictionary<string, int> _hudThemeIdToIndex = new();
 
         public MiscTab()
         {
             RobustXamlLoader.Load(this);
             IoCManager.InjectDependencies(this);
 
+            var themes = _prototypeManager.EnumeratePrototypes<HudThemePrototype>().ToList();
+            themes.Sort();
+            foreach (var gear in themes)
+            {
+                HudThemeOption.AddItem(Loc.GetString(gear.Name));
+                _hudThemeIdToIndex.Add(gear.ID, HudThemeOption.GetItemId(HudThemeOption.ItemCount - 1));
+            }
+
+            var hudLayout = _cfg.GetCVar(CCVars.UILayout);
+            var id = 0;
+            foreach (var layout in Enum.GetValues(typeof(ScreenType)))
+            {
+                var name = layout.ToString()!;
+                HudLayoutOption.AddItem(name, id);
+                if (name == hudLayout)
+                {
+                    HudLayoutOption.SelectId(id);
+                }
+                HudLayoutOption.SetItemMetadata(id, name);
+
+                id++;
+            }
+
+            HudLayoutOption.OnItemSelected += args =>
+            {
+                HudLayoutOption.SelectId(args.Id);
+                UpdateApplyButton();
+            };
+
+            HudThemeOption.OnItemSelected += OnHudThemeChanged;
             DiscordRich.OnToggled += OnCheckBoxToggled;
             ShowLoocAboveHeadCheckBox.OnToggled += OnCheckBoxToggled;
             ShowHeldItemCheckBox.OnToggled += OnCheckBoxToggled;
@@ -30,6 +65,7 @@ namespace Content.Client.Options.UI.Tabs
             // ToggleWalk.OnToggled += OnCheckBoxToggled;
             StaticStorageUI.OnToggled += OnCheckBoxToggled;
 
+            HudThemeOption.SelectId(_hudThemeIdToIndex.GetValueOrDefault(_cfg.GetCVar(CVars.InterfaceTheme), 0));
             DiscordRich.Pressed = _cfg.GetCVar(CVars.DiscordEnabled);
             ShowLoocAboveHeadCheckBox.Pressed = _cfg.GetCVar(CCVars.LoocAboveHeadShow);
             ShowHeldItemCheckBox.Pressed = _cfg.GetCVar(CCVars.HudHeldItemShow);
@@ -50,8 +86,22 @@ namespace Content.Client.Options.UI.Tabs
             UpdateApplyButton();
         }
 
+        private void OnHudThemeChanged(OptionButton.ItemSelectedEventArgs args)
+        {
+            HudThemeOption.SelectId(args.Id);
+            UpdateApplyButton();
+        }
+
         private void OnApplyButtonPressed(BaseButton.ButtonEventArgs args)
         {
+            foreach (var theme in _prototypeManager.EnumeratePrototypes<HudThemePrototype>())
+            {
+                if (_hudThemeIdToIndex[theme.ID] != HudThemeOption.SelectedId)
+                    continue;
+                _cfg.SetCVar(CVars.InterfaceTheme, theme.ID);
+                break;
+            }
+
             _cfg.SetCVar(CVars.DiscordEnabled, DiscordRich.Pressed);
             _cfg.SetCVar(CCVars.HudHeldItemShow, ShowHeldItemCheckBox.Pressed);
             _cfg.SetCVar(CCVars.CombatModeIndicatorsPointShow, ShowCombatModeIndicatorsCheckBox.Pressed);
@@ -62,12 +112,19 @@ namespace Content.Client.Options.UI.Tabs
             // _cfg.SetCVar(CCVars.ToggleWalk, ToggleWalk.Pressed);
             _cfg.SetCVar(CCVars.StaticStorageUI, StaticStorageUI.Pressed);
 
+            if (HudLayoutOption.SelectedMetadata is string opt)
+            {
+                _cfg.SetCVar(CCVars.UILayout, opt);
+            }
+
             _cfg.SaveToFile();
             UpdateApplyButton();
         }
 
         private void UpdateApplyButton()
         {
+            var isHudThemeSame = HudThemeOption.SelectedId == _hudThemeIdToIndex.GetValueOrDefault(_cfg.GetCVar(CVars.InterfaceTheme), 0);
+            var isLayoutSame = HudLayoutOption.SelectedMetadata is string opt && opt == _cfg.GetCVar(CCVars.UILayout);
             var isDiscordSame = DiscordRich.Pressed == _cfg.GetCVar(CVars.DiscordEnabled);
             var isShowHeldItemSame = ShowHeldItemCheckBox.Pressed == _cfg.GetCVar(CCVars.HudHeldItemShow);
             var isCombatModeIndicatorsSame = ShowCombatModeIndicatorsCheckBox.Pressed == _cfg.GetCVar(CCVars.CombatModeIndicatorsPointShow);
@@ -78,7 +135,9 @@ namespace Content.Client.Options.UI.Tabs
             // var isToggleWalkSame = ToggleWalk.Pressed == _cfg.GetCVar(CCVars.ToggleWalk);
             var isStaticStorageUISame = StaticStorageUI.Pressed == _cfg.GetCVar(CCVars.StaticStorageUI);
 
-            ApplyButton.Disabled = isDiscordSame &&
+            ApplyButton.Disabled = isHudThemeSame &&
+                                   isLayoutSame &&
+                                   isDiscordSame &&
                                    isShowHeldItemSame &&
                                    isCombatModeIndicatorsSame &&
                                    isOpaqueStorageWindow &&
index deb62c9b66c2364a6c48154deeafef1697480c0d..22fc8a8e7166ea0ffc3c91e1db9b8d30bdf96b2d 100644 (file)
@@ -3,7 +3,7 @@
 namespace Content.Shared.HUD
 {
     [Prototype("hudTheme")]
-    public sealed partial class HudThemePrototype : IPrototype
+    public sealed partial class HudThemePrototype : IPrototype, IComparable<HudThemePrototype>
     {
         [DataField("name", required: true)]
         public string Name { get; private set; } = string.Empty;
@@ -13,5 +13,16 @@ namespace Content.Shared.HUD
 
         [DataField("path", required: true)]
         public string Path { get; private set; } = string.Empty;
+
+        /// <summary>
+        /// An order for the themes to be displayed in the UI
+        /// </summary>
+        [DataField]
+        public int Order = 0;
+
+        public int CompareTo(HudThemePrototype? other)
+        {
+            return Order.CompareTo(other?.Order);
+        }
     }
 }
index d68e6f2e76daeb87c2295a738fc6042b89587535..b850d29b4c877e42eac70f1e866a231ae3340b35 100644 (file)
@@ -14,6 +14,7 @@ ui-options-default = Default
 # Misc/General menu
 
 ui-options-discordrich = Enable Discord Rich Presence
+ui-options-general-ui-style = UI Style
 ui-options-general-discord = Discord
 ui-options-general-cursor = Cursor
 ui-options-general-speech = Speech
@@ -38,7 +39,7 @@ ui-options-volume-percent = { TOSTRING($volume, "P0") }
 
 ui-options-show-held-item = Show held item next to cursor
 ui-options-show-combat-mode-indicators = Show combat mode indicators with cursor
-ui-options-opaque-storage-window = Enable opaque storage window
+ui-options-opaque-storage-window = Opaque storage window
 ui-options-show-looc-on-head = Show LOOC chat above characters head
 ui-options-fancy-speech = Show names in speech bubbles
 ui-options-fancy-name-background = Add background to speech bubble names
@@ -57,7 +58,7 @@ ui-options-scale-125 = 125%
 ui-options-scale-150 = 150%
 ui-options-scale-175 = 175%
 ui-options-scale-200 = 200%
-ui-options-hud-theme = HUD Theme:
+ui-options-hud-theme = HUD theme:
 ui-options-hud-theme-default = Default
 ui-options-hud-theme-plasmafire = Plasmafire
 ui-options-hud-theme-slimecore = Slimecore
@@ -127,7 +128,7 @@ ui-options-function-examine-entity = Examine
 ui-options-function-swap-hands = Swap hands
 ui-options-function-move-stored-item = Move stored item
 ui-options-function-rotate-stored-item = Rotate stored item
-ui-options-static-storage-ui = Static storage UI
+ui-options-static-storage-ui = Lock storage window to hotbar
 
 ui-options-function-smart-equip-backpack = Smart-equip to backpack
 ui-options-function-smart-equip-belt = Smart-equip to belt
index d88bebe6c76415ef8d06d864eb9a0cd103e59765..977c3c5f31c1779135647d8d22743d98764f7d3c 100644 (file)
@@ -2,33 +2,40 @@
   id: SS14DefaultTheme
   name: ui-options-hud-theme-default
   path: Default
+  order: -1
 
 - type: hudTheme
   id: SS14PlasmafireTheme
   name: ui-options-hud-theme-plasmafire
   path: Plasmafire
-  
+  order: 3
+
 - type: hudTheme
   id: SS14SlimecoreTheme
   name: ui-options-hud-theme-slimecore
   path: Slimecore
+  order: 2
 
 - type: hudTheme
   id: SS14ClockworkTheme
   name: ui-options-hud-theme-clockwork
   path: Clockwork
+  order: 4
 
 - type: hudTheme
   id: SS14RetroTheme
   name: ui-options-hud-theme-retro
   path: Retro
+  order: 6
 
 - type: hudTheme
   id: SS14MinimalistTheme
   name: ui-options-hud-theme-minimalist
   path: Minimalist
+  order: 1
 
 - type: hudTheme
   id: SS14ErisTheme
   name: ui-options-hud-theme-eris
   path: Eris
+  order: 5