Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 94 additions & 10 deletions Options/Options.lua
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ local soundModule
local configFrame, isPluginOpen

local showToggleOptions, getAdvancedToggleOption = nil, nil
local toggleOptionsStatusTable = {}
local toggleOptionsStatusTable, lastOptionsTab = {}, nil

local C_EncounterJournal_GetSectionInfo = loader.isClassic and function(key)
local info = loader.isCata and C_EncounterJournal.GetSectionInfo(key)
Expand Down Expand Up @@ -1067,6 +1067,34 @@ local function statsFirstLabelOnEnter(self)
bwTooltip:Show()
end

local function toggleOptionsTabSelected(widget, callback, tab)
widget:PauseLayout()
widget:ReleaseChildren()

local module = widget:GetUserData("module")
local scrollFrame = widget:GetUserData("scrollFrame")
local dropdown = widget:GetUserData("dropdown")
local tabOptions = widget:GetUserData("tabOptions")
for i, option in next, tabOptions[tab] do
local o = option
if type(o) == "table" then o = option[1] end
if module.optionHeaders and module.optionHeaders[o] then
local header = AceGUI:Create("Heading")
header:SetText(module.optionHeaders[o])
header:SetFullWidth(true)
widget:AddChild(header)
end
widget:AddChildren(getDefaultToggleOption(scrollFrame, dropdown, module, option))
end

-- Store last active tab
lastOptionsTab = tab

widget:ResumeLayout()
scrollFrame:PerformLayout()
widget:PerformLayout()
end

local function populateToggleOptions(widget, module)
visibleSpellDescriptionWidgets = {}
local scrollFrame = widget:GetUserData("parent")
Expand Down Expand Up @@ -1235,16 +1263,71 @@ local function populateToggleOptions(widget, module)
end

if module.SetupOptions then module:SetupOptions() end
for i, option in next, module.toggleOptions do
local o = option
if type(o) == "table" then o = option[1] end
if module.optionHeaders and module.optionHeaders[o] then
local header = AceGUI:Create("Heading")
header:SetText(module.optionHeaders[o])
header:SetFullWidth(true)
scrollFrame:AddChild(header)

local tabs = {}
if module.optionHeaders then -- Pre check if there's any tabs setup in optionHeaders
for i, optionHeader in next, module.optionHeaders do
if type(optionHeader) == "table" and optionHeader.tabName then
table.insert(tabs, optionHeader)
end
end
end

if #tabs > 0 then -- tabs!
local generalTabExists = false
local tabbedOptions = {}
local tabInfo, tabsCreated, tabOptions = {}, {}, {}
for i, tab in next, tabs do
local text = tab.tabName
if text == "general" then
generalTabExists = true
end
local options = tab[1]
table.insert(tabInfo, { text = text, value = text })
tabOptions[text] = options
for i, option in next, options do
tabbedOptions[option] = true
end
end

for i, option in next, module.toggleOptions do
local o = option
if type(o) == "table" then o = option[1] end
if not tabbedOptions[o] then -- not mapped
if not generalTabExists then -- Any non-mapped options will go to the general tab
local CL = BigWigsAPI:GetLocale("BigWigs: Common")
table.insert(tabInfo, 1, { text = CL.general, value = "general" })
generalTabExists = true
end
tabOptions["general"] = tabOptions["general"] or {}
table.insert(tabOptions["general"], option)
end
end

local tabs = AceGUI:Create("TabGroup")
tabs:SetLayout("Flow")
tabs:SetTabs(tabInfo)
tabs:SetFullWidth(true)
tabs:SetCallback("OnGroupSelected", toggleOptionsTabSelected)
tabs:SetUserData("module", module)
tabs:SetUserData("scrollFrame", scrollFrame)
tabs:SetUserData("dropdown", widget)
tabs:SetUserData("tabOptions", tabOptions)
tabs:SelectTab(lastOptionsTab and lastOptionsTab or tabInfo[1].value)

scrollFrame:AddChild(tabs)
else -- no tabs
for i, option in next, module.toggleOptions do
local o = option
if type(o) == "table" then o = option[1] end
if module.optionHeaders and module.optionHeaders[o] then
local header = AceGUI:Create("Heading")
header:SetText(module.optionHeaders[o])
header:SetFullWidth(true)
scrollFrame:AddChild(header)
end
scrollFrame:AddChildren(getDefaultToggleOption(scrollFrame, widget, module, option))
end
scrollFrame:AddChildren(getDefaultToggleOption(scrollFrame, widget, module, option))
end

local list = AceGUI:Create("Button")
Expand All @@ -1264,6 +1347,7 @@ function showToggleOptions(widget, event, group, noScrollReset)
if not noScrollReset then
toggleOptionsStatusTable.restore_offset = nil
toggleOptionsStatusTable.restore_scrollvalue = nil
lastOptionsTab = nil
end
toggleOptionsStatusTable.offset = toggleOptionsStatusTable.restore_offset
toggleOptionsStatusTable.scrollvalue = toggleOptionsStatusTable.restore_scrollvalue
Expand Down
13 changes: 11 additions & 2 deletions gen_option_values.lua
Original file line number Diff line number Diff line change
Expand Up @@ -526,8 +526,17 @@ local function parseGetOptions(file_name, lines, start, special_options)
end
end
if headers then
for key in next, headers do
if not options[key] then
for key, header in next, headers do
if type(header) == "table" then
if not header.tabName then
error(string.format(" %s:%d: Missing tabName for a tab", file_name, start, tostring(key)))
end
for _, optionInTab in next, header[1] do
if not options[optionInTab] then
error(string.format(" %s:%d: Invalid option key %q in tab", file_name, start, tostring(optionInTab)))
end
end
elseif not options[key] then
error(string.format(" %s:%d: Invalid option header key %q", file_name, start, tostring(key)))
end
end
Expand Down