]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix hud theme selection (#19106)
authorc4llv07e <38111072+c4llv07e@users.noreply.github.com>
Fri, 15 Sep 2023 02:05:55 +0000 (02:05 +0000)
committerGitHub <noreply@github.com>
Fri, 15 Sep 2023 02:05:55 +0000 (22:05 -0400)
* Fix hud theme selection

Signed-off-by: c4llv07e <kseandi@gmail.com>
* Remove iterator indexing in the theme configuration

Signed-off-by: c4llv07e <kseandi@gmail.com>
---------

Signed-off-by: c4llv07e <kseandi@gmail.com>
Content.Client/Entry/EntryPoint.cs
Content.Client/Options/UI/Tabs/GraphicsTab.xaml.cs
Resources/Prototypes/hud.yml

index a66925438d0b492daac7283042a74807a7753749..5e6852ff2373b64716abba071e70144b6d5e9804 100644 (file)
@@ -158,6 +158,7 @@ namespace Content.Client.Entry
             _euiManager.Initialize();
             _voteManager.Initialize();
             _userInterfaceManager.SetDefaultTheme("SS14DefaultTheme");
+            _userInterfaceManager.SetActiveTheme(_configManager.GetCVar(CVars.InterfaceTheme));
             _documentParsingManager.Initialize();
 
             _baseClient.RunLevelChanged += (_, args) =>
index 87adbd1ca89b96e7cf7a1eded9848395776f7f25..99076c853d72337c5301f5a6fc410182ceee7806 100644 (file)
@@ -26,6 +26,8 @@ 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!;
 
@@ -56,6 +58,7 @@ namespace Content.Client.Options.UI.Tabs
             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;
 
@@ -109,7 +112,7 @@ namespace Content.Client.Options.UI.Tabs
             FullscreenCheckBox.Pressed = ConfigIsFullscreen;
             LightingPresetOption.SelectId(GetConfigLightingQuality());
             UIScaleOption.SelectId(GetConfigUIScalePreset(ConfigUIScale));
-            HudThemeOption.SelectId(_cfg.GetCVar(CCVars.HudTheme));
+            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;
@@ -145,9 +148,13 @@ namespace Content.Client.Options.UI.Tabs
         {
             _cfg.SetCVar(CVars.DisplayVSync, VSyncCheckBox.Pressed);
             SetConfigLightingQuality(LightingPresetOption.SelectedId);
-            if (HudThemeOption.SelectedId != _cfg.GetCVar(CCVars.HudTheme)) // Don't unnecessarily redraw the HUD
+
+            foreach (var theme in _prototypeManager.EnumeratePrototypes<HudThemePrototype>())
             {
-                _cfg.SetCVar(CCVars.HudTheme, HudThemeOption.SelectedId);
+                if (hudThemeIdToIndex[theme.ID] != HudThemeOption.SelectedId)
+                    continue;
+                _cfg.SetCVar(CVars.InterfaceTheme, theme.ID);
+                break;
             }
 
             _cfg.SetCVar(CVars.DisplayWindowMode,
@@ -189,7 +196,7 @@ 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 == _cfg.GetCVar(CCVars.HudTheme);
+            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);
index 0443f9f54ac01e31b992d9f41e24258dcc87297f..dd4ba5a172a2cace252afe98bcd6f7f7246834f7 100644 (file)
@@ -1,14 +1,14 @@
 - type: hudTheme
-  id: 0
+  id: SS14DefaultTheme
   name: ui-options-hud-theme-default
   path: Default
 
 - type: hudTheme
-  id: 1
+  id: SS14ModernizedTheme
   name: ui-options-hud-theme-modernized
   path: Modernized
 
 - type: hudTheme
-  id: 2
+  id: SS14ClassicTheme
   name: ui-options-hud-theme-classic
   path: Classic