Unify all option panels through MTH_Layout engine

Add reusable MTH_Layout box/column layout engine (api/options-layout.lua) and route every option panel through it (shell, general, zButtons per-button config, zBar, chronometer, auto buy, profiles, credits, etc.) for consistent, auto-sizing layout. Restore realm gate. README note.
This commit is contained in:
DuvelCorp
2026-09-10 23:59:37 +02:00
parent adb21c336c
commit ccf9d8b0b6
16 changed files with 1770 additions and 1861 deletions
+47 -78
View File
@@ -80,102 +80,71 @@ function MTH_SetupAnimationsOptions()
return
end
MTH_ClearContainer(container)
local panel = MTH_Layout.Panel(container)
panel:Title(MTH_ANIM_L("ANIM_TITLE", "Animations"))
panel:Note(MTH_ANIM_L("ANIM_CREDIT",
"Animations are powered by PizzaSauce, a WoW 1.12 animation library kindly made and shared by Pizzahawaii. Thank you!"),
{ color = MTH_Layout.Theme.colText, lines = 2 })
panel:Link("MetaHuntOptionsAnimLink", MTH_ANIM_LINK, function() MTH_ANIM_InsertLink(MTH_ANIM_LINK) end)
MTH_ANIM_CTRL = {}
local title = container:CreateFontString("MetaHuntOptionsAnimationsTitle", "ARTWORK", "GameFontNormal")
title:SetPoint("TOPLEFT", container, "TOPLEFT", 10, -10)
title:SetText(MTH_ANIM_L("ANIM_TITLE", "Animations"))
title:SetTextColor(1.00, 0.82, 0.00)
local credit = container:CreateFontString(nil, "ARTWORK", "GameFontNormalSmall")
credit:SetPoint("TOPLEFT", title, "BOTTOMLEFT", 0, -8)
credit:SetWidth(460)
credit:SetJustifyH("LEFT")
credit:SetText(MTH_ANIM_L("ANIM_CREDIT",
"Animations are powered by PizzaSauce, a WoW 1.12 animation library kindly made and shared by Pizzahawaii. Thank you!"))
credit:SetTextColor(0.93, 0.93, 0.93)
local link = CreateFrame("Button", nil, container)
link:SetPoint("TOPLEFT", credit, "BOTTOMLEFT", 0, -4)
link:SetHeight(16)
link:SetWidth(460)
local linkText = link:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall")
linkText:SetPoint("LEFT", link, "LEFT", 0, 0)
linkText:SetJustifyH("LEFT")
linkText:SetText(MTH_ANIM_LINK)
linkText:SetTextColor(0.40, 0.75, 1.00)
link:SetScript("OnClick", function() MTH_ANIM_InsertLink(MTH_ANIM_LINK) end)
link:SetScript("OnEnter", function() linkText:SetTextColor(0.60, 0.90, 1.00) end)
link:SetScript("OnLeave", function() linkText:SetTextColor(0.40, 0.75, 1.00) end)
-- Global master toggle.
local master = MTH_CreateCheckbox(container, "MetaHuntOptionsAnimMaster",
MTH_ANIM_L("ANIM_ENABLE_ALL", "Enable animations"), -70)
if master then
master:SetChecked(MTH_FX_AnimationsEnabled())
master:SetScript("OnClick", function()
MTH_FX_SetAnimationsEnabled(master:GetChecked())
-- Global master toggle (full width, above the columns).
panel:TopCheckbox("MetaHuntOptionsAnimMaster",
MTH_ANIM_L("ANIM_ENABLE_ALL", "Enable animations"), {
checked = MTH_FX_AnimationsEnabled,
onClick = function()
local cb = getglobal("MetaHuntOptionsAnimMaster")
MTH_FX_SetAnimationsEnabled(cb:GetChecked())
MTH_ANIM_UpdateChildStates()
end)
end
end,
})
-- Per-animation checkboxes, grouped by section, laid out in two columns.
-- Each whole section is placed into whichever column is currently shorter
-- (largest remaining Y), so the two columns stay balanced as defs grow.
local rowStep = 26
local sectionGap = 12
local columns = {
{ headerX = 15, cbX = 28, y = -104 },
{ headerX = 300, cbX = 313, y = -104 },
}
-- Per-animation checkboxes: each section is a self-sizing box, dropped into
-- whichever column currently has the most room so the two stay balanced.
local s = 1
while MTH_FX_ANIM_SECTIONS and s <= table.getn(MTH_FX_ANIM_SECTIONS) do
local sec = MTH_FX_ANIM_SECTIONS[s]
-- Pick the shorter column (the one whose cursor is nearest the top).
local col = columns[1]
if columns[2].y > columns[1].y then
col = columns[2]
end
local header = container:CreateFontString(nil, "ARTWORK", "GameFontNormal")
header:SetPoint("TOPLEFT", container, "TOPLEFT", col.headerX, col.y)
header:SetText(MTH_ANIM_L(sec.titleKey, sec.title))
header:SetTextColor(1.00, 0.82, 0.00)
col.y = col.y - 22
-- Collect this section's defs in order.
local secDefs = {}
local d = 1
while MTH_FX_ANIM_DEFS and d <= table.getn(MTH_FX_ANIM_DEFS) do
local def = MTH_FX_ANIM_DEFS[d]
if def.section == sec.id then
local cbName = "MetaHuntOptionsAnim_" .. string.gsub(def.key, "%.", "_")
local cb = MTH_CreateCheckbox(container, cbName, MTH_ANIM_L(def.labelKey, def.label), col.y, col.cbX)
if cb then
cb.mthKey = def.key
cb:SetChecked(MTH_FX_GetFlag(def.key))
cb:SetScript("OnClick", function()
MTH_FX_SetFlag(cb.mthKey, cb:GetChecked())
end)
if def.tooltip and def.tooltip ~= "" then
cb.mthTooltip = MTH_ANIM_L(def.tooltipKey, def.tooltip)
cb:SetScript("OnEnter", function()
GameTooltip:SetOwner(cb, "ANCHOR_RIGHT")
GameTooltip:SetText(cb.mthTooltip, 1, 1, 1, 1, true)
GameTooltip:Show()
end)
cb:SetScript("OnLeave", function() GameTooltip:Hide() end)
end
table.insert(MTH_ANIM_CTRL, cb)
col.y = col.y - rowStep
end
table.insert(secDefs, def)
end
d = d + 1
end
col.y = col.y - sectionGap
local count = table.getn(secDefs)
if count > 0 then
local box = panel:Box(panel:ShorterSide(),
"MetaHuntOptionsAnimBox_" .. tostring(sec.id),
MTH_ANIM_L(sec.titleKey, sec.title))
local di = 1
while di <= count do
local def = secDefs[di]
local cbName = "MetaHuntOptionsAnim_" .. string.gsub(def.key, "%.", "_")
local cb = box:Checkbox(cbName, MTH_ANIM_L(def.labelKey, def.label), {
checked = function() return MTH_FX_GetFlag(def.key) end,
tooltip = (def.tooltip and def.tooltip ~= "") and MTH_ANIM_L(def.tooltipKey, def.tooltip) or nil,
})
if cb then
cb.mthKey = def.key
cb:SetScript("OnClick", function()
MTH_FX_SetFlag(cb.mthKey, cb:GetChecked())
end)
table.insert(MTH_ANIM_CTRL, cb)
end
di = di + 1
end
end
s = s + 1
end
panel:Finish()
MTH_ANIM_UpdateChildStates()
MTH_ANIM_DBG.setupResult = "ok"
end