diff --git a/OpenRA.Mods.Common/Widgets/Logic/Settings/SettingsLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Settings/SettingsLogic.cs index 93139f3f99..64dd525655 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Settings/SettingsLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Settings/SettingsLogic.cs @@ -22,6 +22,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic void RegisterSettingsPanel(string panelID, string label, Func> init, Func reset); } + [IncludeChromeLogicArgsFluentReferences(nameof(DynamicFluentReferences))] public class SettingsLogic : ChromeLogic, ISettingsLogic { [FluentReference] @@ -57,6 +58,13 @@ namespace OpenRA.Mods.Common.Widgets.Logic [FluentReference] const string ResetCancel = "dialog-settings-reset.cancel"; + public static IEnumerable<(string Key, FluentReferenceAttribute Reference)> DynamicFluentReferences(Dictionary logicArgs) + { + if (logicArgs.TryGetValue("Panels", out var settingsPanels)) + foreach (var node in settingsPanels.Nodes) + yield return (node.Value.Value, new FluentReferenceAttribute()); + } + readonly Dictionary> leavePanelActions = []; readonly Dictionary resetPanelActions = []; @@ -97,7 +105,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic { { "settingsLogic", this }, { "panelID", panel.Key }, - { "label", panel.Value } + { "label", FluentProvider.GetMessage(panel.Value) } }); } } @@ -164,11 +172,6 @@ namespace OpenRA.Mods.Common.Widgets.Logic leavePanelActions.Add(panelID, init(panel)); resetPanelActions.Add(panelID, reset(panel)); - AddSettingsTab(panelID, label); - } - - ButtonWidget AddSettingsTab(string id, string label) - { var tab = tabTemplate.Clone(); var lastButton = buttons.LastOrDefault(); if (lastButton != null) @@ -177,20 +180,18 @@ namespace OpenRA.Mods.Common.Widgets.Logic tab.Bounds.Y = lastButton.Bounds.Y + buttonStride.Y; } - tab.Id = id; + tab.Id = panelID; tab.GetText = () => label; - tab.IsHighlighted = () => activePanel == id; + tab.IsHighlighted = () => activePanel == panelID; tab.OnClick = () => { needsRestart |= leavePanelActions[activePanel](); Game.Settings.Save(); - activePanel = id; + activePanel = panelID; }; tabContainer.AddChild(tab); buttons.Add(tab); - - return tab; } } } diff --git a/mods/cnc/chrome/settings.yaml b/mods/cnc/chrome/settings.yaml index 9bcd6f5112..6f3dc7eefe 100644 --- a/mods/cnc/chrome/settings.yaml +++ b/mods/cnc/chrome/settings.yaml @@ -2,12 +2,12 @@ Container@SETTINGS_PANEL: Logic: SettingsLogic ButtonStride: 0, 45 Panels: - GAMEPLAY_PANEL: Gameplay - INPUT_PANEL: Input - DISPLAY_PANEL: Display - AUDIO_PANEL: Audio - HOTKEYS_PANEL: Hotkeys - ADVANCED_PANEL: Advanced + GAMEPLAY_PANEL: button-panel-gameplay + INPUT_PANEL: button-panel-input + DISPLAY_PANEL: button-panel-display + AUDIO_PANEL: button-panel-audio + HOTKEYS_PANEL: button-panel-hotkeys + ADVANCED_PANEL: button-panel-advanced X: (WINDOW_WIDTH - WIDTH) / 2 Y: (WINDOW_HEIGHT - HEIGHT) / 2 Width: 640 diff --git a/mods/cnc/fluent/chrome.ftl b/mods/cnc/fluent/chrome.ftl index 613a9573a8..cad3765583 100644 --- a/mods/cnc/fluent/chrome.ftl +++ b/mods/cnc/fluent/chrome.ftl @@ -754,6 +754,12 @@ label-ui-scrollspeed-slider-container-scroll-speed = UI Scroll Speed: ## settings.yaml button-settings-panel-reset = Reset +button-panel-gameplay = Gameplay +button-panel-input = Input +button-panel-display = Display +button-panel-audio = Audio +button-panel-hotkeys = Hotkeys +button-panel-advanced = Advanced ## tooltips.yaml label-latency-tooltip-prefix = Latency: diff --git a/mods/common/chrome/settings.yaml b/mods/common/chrome/settings.yaml index 985cfab842..883c11e512 100644 --- a/mods/common/chrome/settings.yaml +++ b/mods/common/chrome/settings.yaml @@ -2,12 +2,12 @@ Background@SETTINGS_PANEL: Logic: SettingsLogic ButtonStride: 0, 35 Panels: - GAMEPLAY_PANEL: Gameplay - INPUT_PANEL: Input - DISPLAY_PANEL: Display - AUDIO_PANEL: Audio - HOTKEYS_PANEL: Hotkeys - ADVANCED_PANEL: Advanced + GAMEPLAY_PANEL: button-panel-gameplay + INPUT_PANEL: button-panel-input + DISPLAY_PANEL: button-panel-display + AUDIO_PANEL: button-panel-audio + HOTKEYS_PANEL: button-panel-hotkeys + ADVANCED_PANEL: button-panel-advanced X: (WINDOW_WIDTH - WIDTH) / 2 Y: (WINDOW_HEIGHT - HEIGHT) / 2 Width: 900 diff --git a/mods/common/fluent/chrome.ftl b/mods/common/fluent/chrome.ftl index 82590eb3f5..e4b61c7736 100644 --- a/mods/common/fluent/chrome.ftl +++ b/mods/common/fluent/chrome.ftl @@ -565,6 +565,12 @@ label-ui-scrollspeed-slider-container-scroll-speed = UI Scroll Speed: ## settings.yaml button-settings-panel-reset = Reset +button-panel-gameplay = Gameplay +button-panel-input = Input +button-panel-display = Display +button-panel-audio = Audio +button-panel-hotkeys = Hotkeys +button-panel-advanced = Advanced ## tooltips.yaml label-latency-tooltip-prefix = Latency: