Skip to content

Commit

Permalink
Merge pull request #619 from robertthepie/modoptionsSort
Browse files Browse the repository at this point in the history
Add Tab Weights Support
  • Loading branch information
Damgam authored Apr 1, 2024
2 parents 29842ad + aba033b commit ffa85ec
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion LuaMenu/widgets/gui_modoptions_panel.lua
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ local function CreateModoptionWindow()

for key, data in pairs(modoptionStructure.sections) do
local caption = modoptionStructure.sectionTitles[data.title] or data.title
local weight = modoptionStructure.sectionWeights[data.title] or -#tabs
local fontSize = 2
local tooltip = data.desc
local origCaption = caption
Expand All @@ -379,10 +380,13 @@ local function CreateModoptionWindow()
caption = caption,
tooltip = tooltip,
objectOverrideFont = WG.Chobby.Configuration:GetFont(fontSize),
children = PopulateTab(data.options)
children = PopulateTab(data.options),
weight = data.weight or weight
}
end

table.sort(tabs, function(a,b) return a.weight > b.weight end)

local tabPanel = Chili.DetachableTabPanel:New {
x = 4,
right = 4,
Expand Down Expand Up @@ -597,6 +601,7 @@ function ModoptionsPanel.RefreshModoptions()
local postpendHiddenOptions = {}
modoptionStructure = {
sectionTitles = {},
sectionWeights = {},
sections = {}
}

Expand All @@ -605,6 +610,7 @@ function ModoptionsPanel.RefreshModoptions()
local data = modoptions[i]
if data.type == "section" then
modoptionStructure.sectionTitles[data.key] = data.name
modoptionStructure.sectionWeights[data.key] = data.weight
else
if data.section then
if data.hidden ~= true then
Expand Down

0 comments on commit ffa85ec

Please sign in to comment.