mirror of
https://codeberg.org/Duvelcorp/MetaHunt.git
synced 2026-09-22 15:46:59 +00:00
66ff1ae711
- Shared FX toolkit in fx-celebrate.lua: mth_shake tween type, MTH_FX_Flash glow helper, MTH_CelebrateRunaway red shaking banner, gold title reset. - pet.runaway, pet.happiness, pet.loyaltyup, pet.feed - combat.ammoswap, combat.rangedswap, combat.mmprocs - ui.zbar, ui.stable, ui.minimapping, ui.optionsclose - book.model, book.search - Options > Animations panel now uses a balanced two-column layout. - CHANGELOG Animations entry expanded (no version bump).
186 lines
6.0 KiB
Lua
186 lines
6.0 KiB
Lua
-- MetaHunt: "Animations" options panel.
|
|
-- Global enable/disable plus a per-animation checkbox for each effect, grouped
|
|
-- into sections (Pet, Book, ...). The animation registry lives in fx-celebrate.lua
|
|
-- (MTH_FX_ANIM_SECTIONS / MTH_FX_ANIM_DEFS) so both the effects and this panel
|
|
-- stay in sync.
|
|
|
|
local MTH_ANIM_READY = MTH_OptionsRequire and MTH_OptionsRequire("options-animations", {
|
|
"MTH_GetFrame",
|
|
"MTH_ClearContainer",
|
|
"MTH_CreateCheckbox",
|
|
})
|
|
|
|
-- DEBUG: load-path tracer, global so /mth fxdebug can dump it. TEMP diagnostic.
|
|
MTH_ANIM_DBG = {
|
|
ready = tostring(MTH_ANIM_READY),
|
|
reqType = type(MTH_OptionsRequire),
|
|
getFrameType = type(MTH_GetFrame),
|
|
clearType = type(MTH_ClearContainer),
|
|
checkboxType = type(MTH_CreateCheckbox),
|
|
step = "1-top",
|
|
}
|
|
|
|
local MTH_ANIM_LINK = "https://codeberg.org/Pizzahawaii/PizzaSauce"
|
|
local MTH_ANIM_CTRL = {}
|
|
|
|
local function MTH_ANIM_L(key, default)
|
|
if MTH and MTH.GetLocalization then
|
|
return MTH:GetLocalization(key, default)
|
|
end
|
|
return default or key
|
|
end
|
|
|
|
local function MTH_ANIM_InsertLink(url)
|
|
local link = tostring(url or "")
|
|
if link == "" then return end
|
|
if type(MTH_InsertLinkToChat) == "function" and MTH_InsertLinkToChat(link) then
|
|
if MTH and MTH.Print then
|
|
MTH:Print(MTH_ANIM_L("ANIM_LINK_INSERTED", "Link inserted in chat: ") .. link)
|
|
end
|
|
return
|
|
end
|
|
if MTH and MTH.Print then
|
|
MTH:Print(MTH_ANIM_L("ANIM_LINK_FALLBACK", "Link: ") .. link)
|
|
end
|
|
end
|
|
|
|
local function MTH_ANIM_UpdateChildStates()
|
|
local master = MTH_FX_AnimationsEnabled()
|
|
local i = 1
|
|
while i <= table.getn(MTH_ANIM_CTRL) do
|
|
local cb = MTH_ANIM_CTRL[i]
|
|
if cb then
|
|
cb:SetChecked(MTH_FX_GetFlag(cb.mthKey))
|
|
if master then
|
|
cb:Enable()
|
|
else
|
|
cb:Disable()
|
|
end
|
|
end
|
|
i = i + 1
|
|
end
|
|
end
|
|
|
|
function MTH_SetupAnimationsOptions()
|
|
MTH_ANIM_DBG.setupCalled = true
|
|
MTH_ANIM_DBG.fxEnabledType = type(MTH_FX_AnimationsEnabled)
|
|
if not MTH_ANIM_READY then
|
|
MTH_ANIM_DBG.setupResult = "abort-not-ready"
|
|
return
|
|
end
|
|
if type(MTH_FX_AnimationsEnabled) ~= "function" then
|
|
MTH_ANIM_DBG.setupResult = "abort-no-fx-globals"
|
|
return
|
|
end
|
|
|
|
local container = MTH_GetFrame("MetaHuntOptionsAnimations")
|
|
MTH_ANIM_DBG.containerType = type(container)
|
|
if not container then
|
|
MTH_ANIM_DBG.setupResult = "abort-no-container"
|
|
return
|
|
end
|
|
|
|
MTH_ClearContainer(container)
|
|
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())
|
|
MTH_ANIM_UpdateChildStates()
|
|
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 },
|
|
}
|
|
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
|
|
|
|
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
|
|
end
|
|
d = d + 1
|
|
end
|
|
col.y = col.y - sectionGap
|
|
s = s + 1
|
|
end
|
|
|
|
MTH_ANIM_UpdateChildStates()
|
|
MTH_ANIM_DBG.setupResult = "ok"
|
|
end
|
|
|
|
-- DEBUG: mark that the whole file finished loading. TEMP diagnostic.
|
|
MTH_ANIM_DBG.step = "2-complete"
|
|
MTH_ANIM_DBG.hasSetup = type(MTH_SetupAnimationsOptions)
|