mirror of
https://codeberg.org/Duvelcorp/MetaHunt.git
synced 2026-09-22 15:46:59 +00:00
060fc555fe
Collapse all legacy/scattered SavedVariables from absorbed standalone
addons (FeedOMatic, ZHunter/zButtons, SmartAmmo, AutoQuest, AntiDaze,
AutoStrip, MinimapButton) into two persisted globals with clean per-module
nesting under .modules.<id>.
Migration engine (api/savedvariables.lua):
- MTH_SV_EnsureSchema() with schemaVersion gate, idempotent + non-destructive
- Per-module migrators map old locations -> canonical nested stores
- Driven by an ADDON_LOADED("MetaHunt") handler so it runs only AFTER WoW
loads the real SavedVariables (fixes announce-every-session bug that ran
the migration on empty pre-load defaults)
- One-time player-facing chat announce, gated on real legacy data present
Framework/config:
- core-framework InitSavedVariables no longer runs migration at file-load;
unconditionally strips account-root module aliases
- config.lua stops re-creating root[module] aliases (was duplicating data
onto disk); canonical store stays under .modules.<id>
Modules:
- feedomatic: bind FOM_* globals as runtime aliases into nested store,
drop persisted duplicates and .legacy blob
- zhunter: ZHunterMod_Saved re-pointed at .modules.zhunter
- smartammo/autoquest/antidaze/autostrip/minimapbutton read nested store
TOC trimmed to MTH_SavedVariables + MTH_CharSavedVariables only.
Profiles unchanged (already snapshot/apply the nested .modules structure).
Also includes pet-scan refinements: canonical pet key derivation and
level-independent pet signature (schema v3).
233 lines
7.6 KiB
Lua
233 lines
7.6 KiB
Lua
local MTH_AQ_READY = MTH_OptionsRequire and MTH_OptionsRequire("options-autoquest", {
|
|
"MTH_GetFrame",
|
|
"MTH_ClearContainer",
|
|
"MTH_CreateCheckbox",
|
|
})
|
|
|
|
local function MTH_AQ_IsChecked(control)
|
|
if not control or type(control.GetChecked) ~= "function" then
|
|
return false
|
|
end
|
|
local checked = control:GetChecked()
|
|
return checked == 1 or checked == true
|
|
end
|
|
|
|
local function MTH_AQ_EnsureStore()
|
|
if type(MTH_CharSavedVariables) ~= "table" then
|
|
MTH_CharSavedVariables = {}
|
|
end
|
|
local store = nil
|
|
if MTH and MTH.GetModuleCharSavedVariables then
|
|
store = MTH:GetModuleCharSavedVariables("autoquest")
|
|
end
|
|
if type(store) ~= "table" then
|
|
if type(MTH_CharSavedVariables.modules) ~= "table" then
|
|
MTH_CharSavedVariables.modules = {}
|
|
end
|
|
if type(MTH_CharSavedVariables.modules.autoquest) ~= "table" then
|
|
MTH_CharSavedVariables.modules.autoquest = {}
|
|
end
|
|
store = MTH_CharSavedVariables.modules.autoquest
|
|
end
|
|
if type(store.settings) ~= "table" then
|
|
store.settings = {}
|
|
end
|
|
local settings = store.settings
|
|
if settings.scorpokDrazial == nil then
|
|
settings.scorpokDrazial = false
|
|
end
|
|
if settings.arrowsForSissies == nil then
|
|
settings.arrowsForSissies = false
|
|
end
|
|
return settings
|
|
end
|
|
|
|
function MTH_SetupAutoQuestOptions()
|
|
if not MTH_AQ_READY then return end
|
|
|
|
local container = MTH_GetFrame("MetaHuntOptionsAutoQuest")
|
|
if not container then return end
|
|
|
|
MTH_ClearContainer(container)
|
|
|
|
local title = container:CreateFontString("MetaHuntOptionsAutoQuestTitle", "ARTWORK", "GameFontHighlight")
|
|
title:SetPoint("TOPLEFT", container, "TOPLEFT", 20, -10)
|
|
title:SetText("Auto Quest")
|
|
|
|
local body = container:CreateFontString("MetaHuntOptionsAutoQuestBody", "ARTWORK", "GameFontNormalSmall")
|
|
body:SetPoint("TOPLEFT", container, "TOPLEFT", 20, -30)
|
|
body:SetWidth(560)
|
|
body:SetJustifyH("LEFT")
|
|
body:SetJustifyV("TOP")
|
|
body:SetTextColor(0.45, 0.75, 1)
|
|
body:SetText("Automation for specific quest interactions.")
|
|
|
|
local moduleEnabled = true
|
|
if MTH and MTH.GetModule then
|
|
local module = MTH:GetModule("autoquest")
|
|
if type(module) == "table" and module.enabled ~= nil then
|
|
moduleEnabled = module.enabled and true or false
|
|
elseif MTH and MTH.IsModuleEnabled then
|
|
moduleEnabled = MTH:IsModuleEnabled("autoquest", false) and true or false
|
|
end
|
|
elseif MTH and MTH.IsModuleEnabled then
|
|
moduleEnabled = MTH:IsModuleEnabled("autoquest", false) and true or false
|
|
end
|
|
local moduleToggle = MTH_CreateCheckbox(container, "MetaHuntOptionsAutoQuestModuleToggle", "Enable Auto Quest module", -70, 20)
|
|
if moduleToggle then
|
|
moduleToggle:SetChecked(moduleEnabled and true or false)
|
|
moduleToggle:SetScript("OnClick", function()
|
|
if not this then return end
|
|
local enabled = MTH_AQ_IsChecked(this)
|
|
if MTH and MTH.SetModuleEnabled then
|
|
local ok, err = MTH:SetModuleEnabled("autoquest", enabled)
|
|
if not ok and MTH and MTH.Print then
|
|
MTH:Print("Failed to change Auto Quest module state: " .. tostring(err), "error")
|
|
end
|
|
end
|
|
local module = MTH and MTH.GetModule and MTH:GetModule("autoquest") or nil
|
|
local actual = (type(module) == "table" and module.enabled ~= nil) and (module.enabled and true or false) or enabled
|
|
this:SetChecked(actual and true or false)
|
|
end)
|
|
end
|
|
|
|
local store = MTH_AQ_EnsureStore()
|
|
if store.scorpokTooltip == nil then
|
|
store.scorpokTooltip = false
|
|
end
|
|
|
|
local sectionWidth = (container:GetWidth() or 600) - 40
|
|
if sectionWidth < 360 then
|
|
sectionWidth = 360
|
|
end
|
|
|
|
local function ensureSection(name, sectionTitle, yOffset, height)
|
|
local section = getglobal(name)
|
|
if not section then
|
|
section = CreateFrame("Frame", name, container, "OptionFrameBoxTemplate")
|
|
end
|
|
if not section then
|
|
return nil
|
|
end
|
|
section:SetParent(container)
|
|
section:ClearAllPoints()
|
|
section:SetPoint("TOPLEFT", container, "TOPLEFT", 20, yOffset)
|
|
section:SetWidth(sectionWidth)
|
|
section:SetHeight(height)
|
|
section:Show()
|
|
|
|
local titleFrame = getglobal(name .. "Title")
|
|
if titleFrame then
|
|
titleFrame:SetText(sectionTitle)
|
|
end
|
|
return section
|
|
end
|
|
|
|
local function ensureCheckbox(section, name, label, yOffset, checked)
|
|
local check = getglobal(name)
|
|
if not check then
|
|
check = CreateFrame("CheckButton", name, section, "OptionsCheckButtonTemplate")
|
|
end
|
|
if not check then
|
|
return nil
|
|
end
|
|
check:SetParent(section)
|
|
check:ClearAllPoints()
|
|
check:SetPoint("TOPLEFT", section, "TOPLEFT", 12, yOffset)
|
|
check:SetChecked(checked and true or false)
|
|
check:Show()
|
|
|
|
local text = getglobal(name .. "Text")
|
|
if text then
|
|
text:SetText(label)
|
|
end
|
|
return check
|
|
end
|
|
|
|
local scorpokSection = ensureSection("MetaHuntAutoQuestScorpokBox", "Salt of the Scorpok", -130, 112)
|
|
if scorpokSection then
|
|
local scorpokToggle = ensureCheckbox(
|
|
scorpokSection,
|
|
"MetaHuntOptionsAutoQuestScorpokToggle",
|
|
"Enable SHIFT-rightclick for Bloodmage Drazial",
|
|
-10,
|
|
store.scorpokDrazial and true or false
|
|
)
|
|
if scorpokToggle then
|
|
scorpokToggle:SetScript("OnClick", function()
|
|
local enabled = MTH_AQ_IsChecked(this)
|
|
store.scorpokDrazial = enabled and true or false
|
|
if MTH and MTH.GetModuleCharSavedVariables then
|
|
local moduleStore = MTH:GetModuleCharSavedVariables("autoquest")
|
|
if type(moduleStore) == "table" then
|
|
moduleStore.scorpokDrazial = store.scorpokDrazial and true or false
|
|
end
|
|
end
|
|
local module = MTH and MTH.GetModule and MTH:GetModule("autoquest")
|
|
if module and module.SetScorpokDrazialEnabled then
|
|
module:SetScorpokDrazialEnabled(enabled)
|
|
end
|
|
end)
|
|
end
|
|
|
|
local tooltipToggle = ensureCheckbox(
|
|
scorpokSection,
|
|
"MetaHuntOptionsAutoQuestScorpokTooltipToggle",
|
|
"Enhance Tooltip on Drazial and related beasts (requires Tooltips module enabled)",
|
|
-42,
|
|
store.scorpokTooltip and true or false
|
|
)
|
|
if tooltipToggle then
|
|
tooltipToggle:SetScript("OnClick", function()
|
|
local enabled = MTH_AQ_IsChecked(this)
|
|
store.scorpokTooltip = enabled and true or false
|
|
if MTH and MTH.GetModuleCharSavedVariables then
|
|
local moduleStore = MTH:GetModuleCharSavedVariables("autoquest")
|
|
if type(moduleStore) == "table" then
|
|
moduleStore.scorpokTooltip = store.scorpokTooltip and true or false
|
|
end
|
|
end
|
|
end)
|
|
end
|
|
end
|
|
|
|
local sissiesSection = ensureSection("MetaHuntAutoQuestSissiesBox", "Arrows Are For Sissies", -255, 108)
|
|
if sissiesSection then
|
|
local sissiesNote = getglobal("MetaHuntOptionsAutoQuestSissiesNote")
|
|
if not sissiesNote then
|
|
sissiesNote = sissiesSection:CreateFontString("MetaHuntOptionsAutoQuestSissiesNote", "ARTWORK", "GameFontNormalSmall")
|
|
end
|
|
sissiesNote:ClearAllPoints()
|
|
sissiesNote:SetPoint("TOPLEFT", sissiesSection, "TOPLEFT", 14, -10)
|
|
sissiesNote:SetWidth(sectionWidth - 28)
|
|
sissiesNote:SetJustifyH("LEFT")
|
|
sissiesNote:SetTextColor(0.45, 0.75, 1)
|
|
sissiesNote:SetText("Note that you should not activate this if you are using LazyPig")
|
|
sissiesNote:Show()
|
|
|
|
local sissiesToggle = ensureCheckbox(
|
|
sissiesSection,
|
|
"MetaHuntOptionsAutoQuestSissiesToggle",
|
|
"Enable SHIFT-rightclick for Artilleryman Sheldonore",
|
|
-40,
|
|
store.arrowsForSissies and true or false
|
|
)
|
|
if sissiesToggle then
|
|
sissiesToggle:SetScript("OnClick", function()
|
|
local enabled = MTH_AQ_IsChecked(this)
|
|
store.arrowsForSissies = enabled and true or false
|
|
if MTH and MTH.GetModuleCharSavedVariables then
|
|
local moduleStore = MTH:GetModuleCharSavedVariables("autoquest")
|
|
if type(moduleStore) == "table" then
|
|
moduleStore.arrowsForSissies = store.arrowsForSissies and true or false
|
|
end
|
|
end
|
|
local module = MTH and MTH.GetModule and MTH:GetModule("autoquest")
|
|
if module and module.SetArrowsForSissiesEnabled then
|
|
module:SetArrowsForSissiesEnabled(enabled)
|
|
end
|
|
end)
|
|
end
|
|
end
|
|
end
|