Skip to content

Commit

Permalink
Support Dev And Hidden Modoptions
Browse files Browse the repository at this point in the history
  • Loading branch information
robertthepie committed Mar 29, 2024
1 parent c903f7e commit a4fea88
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 20 deletions.
1 change: 1 addition & 0 deletions LuaMenu/widgets/chobby/components/configuration.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions LuaMenu/widgets/chobby/i18n/chililobby.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
74 changes: 54 additions & 20 deletions LuaMenu/widgets/gui_modoptions_panel.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -603,10 +656,6 @@ function ModoptionsPanel.LoadModoptions(gameName, newBattleLobby)
modoptions = VFS.UseArchive(gameName, LoadModOptions)

modoptionDefaults = {}
modoptionStructure = {
sectionTitles = {},
sections = {}
}
if not modoptions then
return
end
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions LuaMenu/widgets/gui_settings_window.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a4fea88

Please sign in to comment.