From a4fea8825c513df04cbba4174f558be3337ec07a Mon Sep 17 00:00:00 2001 From: robertthepie Date: Fri, 29 Mar 2024 18:46:13 +0000 Subject: [PATCH] Support Dev And Hidden Modoptions --- .../chobby/components/configuration.lua | 1 + LuaMenu/widgets/chobby/i18n/chililobby.lua | 2 + LuaMenu/widgets/gui_modoptions_panel.lua | 74 ++++++++++++++----- LuaMenu/widgets/gui_settings_window.lua | 1 + 4 files changed, 58 insertions(+), 20 deletions(-) diff --git a/LuaMenu/widgets/chobby/components/configuration.lua b/LuaMenu/widgets/chobby/components/configuration.lua index b0da0bd06..9897c6954 100644 --- a/LuaMenu/widgets/chobby/components/configuration.lua +++ b/LuaMenu/widgets/chobby/components/configuration.lua @@ -283,6 +283,7 @@ function Configuration:init() self.simplifiedSkirmishSetup = false self.debugMode = false self.devMode = (VFS.FileExists("devmode.txt") and true) or false + self.ShowhiddenModopions = false self.enableProfiler = false self.enableInspector = false self.enableCacheRapidPool = true diff --git a/LuaMenu/widgets/chobby/i18n/chililobby.lua b/LuaMenu/widgets/chobby/i18n/chililobby.lua index 5818cc029..58f13e181 100644 --- a/LuaMenu/widgets/chobby/i18n/chililobby.lua +++ b/LuaMenu/widgets/chobby/i18n/chililobby.lua @@ -215,6 +215,8 @@ return { keep_queues = "Stay in MM queues on launch", simplifiedSkirmishSetup = "Simple skirmish setup", debugMode = "Debug mode", + ShowhiddenModopions = "Show Hidden Modoptions", + ShowhiddenTooltip = "WARNING: Hidden options may not work. Rearranges Tabs", animate_lobby = "Lobby animations", animate_lobby_tooltip = "Toggles lobby animations, it doesnt do very much, best to ignore this unless you are experiencing issues", account = "Account", diff --git a/LuaMenu/widgets/gui_modoptions_panel.lua b/LuaMenu/widgets/gui_modoptions_panel.lua index f776ecc10..38f33be98 100644 --- a/LuaMenu/widgets/gui_modoptions_panel.lua +++ b/LuaMenu/widgets/gui_modoptions_panel.lua @@ -588,6 +588,59 @@ local modoptionsDisplay local ModoptionsPanel = {} +function ModoptionsPanel.RefreshModoptions() + if not (modoptions and battleLobby) then + return + end + local showHidden = WG.Chobby.Configuration.ShowhiddenModopions + local devmode = WG.Chobby.Configuration.devMode + local postpendHiddenOptions = {} + modoptionStructure = { + sectionTitles = {}, + sections = {} + } + + -- Populate the sections + for i = 1, #modoptions do + local data = modoptions[i] + if data.type == "section" then + modoptionStructure.sectionTitles[data.key] = data.name + else + if data.section then + if data.hidden ~= true then + modoptionStructure.sections[data.section] = modoptionStructure.sections[data.section] or { + title = data.section, + options = {} + } + + local options = modoptionStructure.sections[data.section].options + options[#options + 1] = data + elseif showHidden and devmode then + if not data.name:find("(HIDDEN)") then + data.name = "(HIDDEN) "..data.name + end + postpendHiddenOptions[#postpendHiddenOptions + 1] = data + end + end + end + end + + if not devmode then + modoptionStructure.sections["dev"] = nil + end + if showHidden and devmode then + for i = 1, #postpendHiddenOptions do + local data = postpendHiddenOptions[i] + modoptionStructure.sections[data.section] = modoptionStructure.sections[data.section] or { + title = data.section, + options = {} + } + local options = modoptionStructure.sections[data.section].options + options[#options + 1] = data + end + end +end + function ModoptionsPanel.LoadModoptions(gameName, newBattleLobby) battleLobby = newBattleLobby @@ -603,10 +656,6 @@ function ModoptionsPanel.LoadModoptions(gameName, newBattleLobby) modoptions = VFS.UseArchive(gameName, LoadModOptions) modoptionDefaults = {} - modoptionStructure = { - sectionTitles = {}, - sections = {} - } if not modoptions then return end @@ -627,22 +676,7 @@ function ModoptionsPanel.LoadModoptions(gameName, newBattleLobby) end -- Populate the sections - for i = 1, #modoptions do - local data = modoptions[i] - if data.type == "section" then - modoptionStructure.sectionTitles[data.key] = data.name - else - if data.section and data.hidden ~= true then - modoptionStructure.sections[data.section] = modoptionStructure.sections[data.section] or { - title = data.section, - options = {} - } - - local options = modoptionStructure.sections[data.section].options - options[#options + 1] = data - end - end - end + ModoptionsPanel.RefreshModoptions() end -- call after LoadModoptions diff --git a/LuaMenu/widgets/gui_settings_window.lua b/LuaMenu/widgets/gui_settings_window.lua index 18b26935e..f9be7ab56 100644 --- a/LuaMenu/widgets/gui_settings_window.lua +++ b/LuaMenu/widgets/gui_settings_window.lua @@ -1253,6 +1253,7 @@ local function GetVoidTabControls() children[#children + 1], offset = AddCheckboxSetting(offset, i18n("debugMode"), "debugMode", false) + children[#children + 1], offset = AddCheckboxSetting(offset, i18n("ShowhiddenModopions"), "ShowhiddenModopions", false, WG.ModoptionsPanel.RefreshModoptions, i18n("ShowhiddenTooltip")) children[#children + 1], offset = AddCheckboxSetting(offset, "Debug Auto Win", "debugAutoWin", false) children[#children + 1], offset = AddCheckboxSetting(offset, "Enable Profiler", "enableProfiler", false, EnableProfilerFunc) local cbInspector