From 929ec77503e54c484698b8a11738b71b7f14aa04 Mon Sep 17 00:00:00 2001 From: Anonomit Date: Fri, 23 Jun 2023 18:59:01 -0400 Subject: [PATCH] Fix options menu Restore Profile options and intended category order --- Config/OptionsTables.lua | 32 +++++++++++++++---------------- Config/Settings.lua | 2 ++ Init/Init.lua | 10 ++++++++-- Operations/ManageConstructors.lua | 6 +++--- Operations/RebuildTooltip.lua | 8 ++++---- Operations/ScanTooltip.lua | 2 +- 6 files changed, 34 insertions(+), 26 deletions(-) diff --git a/Config/OptionsTables.lua b/Config/OptionsTables.lua index 8e3eca8..9392849 100644 --- a/Config/OptionsTables.lua +++ b/Config/OptionsTables.lua @@ -277,14 +277,10 @@ function Addon:MakeAddonOptionsContainer(chatCmd) -- Profile Options do - local args = {"profiles", "profile", "prof", "pro", "pr", "p"} + local opts = GUI:CreateGroup(opts, GUI:Order(), GUI:Order()) local profileOptions = self.AceDBOptions:GetOptionsTable(self:GetDB()) - local categoryName = profileOptions.name - profileOptions.name = format("%s v%s > %s (/%s %s)", ADDON_NAME, tostring(self:GetOption"version"), profileOptions.name, self.chatCommands[1], args[1]) - local panel = self:CreateOptionsCategory(categoryName, profileOptions) - local function OpenOptions() return self:OpenConfig(panel) end - for _, arg in ipairs(args) do - self.chatArgs[arg] = OpenOptions + for k, v in pairs(profileOptions) do + opts[k] = v end end @@ -343,7 +339,7 @@ function Addon:MakeAddonOptions(chatCmd) local title = format("%s", ADDON_NAME) -- local panel = self:CreateOptionsCategory(nil, function() - local GUI = self.GUI:ResetOrder() + local GUI = self.GUI local opts = GUI:CreateGroupTop(title, "tab") do @@ -460,7 +456,7 @@ function Addon:MakeStatsOptions(categoryName, chatCmd, arg1, ...) local title = format("%s", categoryName) -- local panel = self:CreateOptionsCategory(categoryName, function() - local GUI = self.GUI:ResetOrder() + local GUI = self.GUI local opts = GUI:CreateGroupTop(title) CreateCombineStatsOption(opts) @@ -540,7 +536,7 @@ function Addon:MakePaddingOptions(categoryName, chatCmd, arg1, ...) local title = format("%s", categoryName) -- local panel = self:CreateOptionsCategory(categoryName, function() - local GUI = self.GUI:ResetOrder() + local GUI = self.GUI local opts = GUI:CreateGroupTop(title) CreateCombineStatsOption(opts) @@ -622,7 +618,7 @@ function Addon:MakeExtraOptions(categoryName, chatCmd, arg1, ...) local title = format("%s", categoryName) -- local panel = self:CreateOptionsCategory(categoryName, function() - local GUI = self.GUI:ResetOrder() + local GUI = self.GUI local opts = GUI:CreateGroupTop(title) local disabled -- just in case some other addon clobbers _G.disabled @@ -1792,7 +1788,7 @@ function Addon:MakeResetOptions(categoryName, chatCmd, arg1, ...) local title = format("%s", categoryName) -- local panel = self:CreateOptionsCategory(categoryName, function() - local GUI = self.GUI:ResetOrder() + local GUI = self.GUI local opts = GUI:CreateGroupTop(title) GUI:CreateDivider(opts) @@ -1838,7 +1834,7 @@ function Addon:MakeDebugOptions(categoryName, chatCmd, arg1, ...) local title = format("%s", categoryName) -- local panel = self:CreateOptionsCategory(categoryName, function() - local GUI = self.GUI:ResetOrder() + local GUI = self.GUI local opts = GUI:CreateGroupTop(title, "tab") -- Enable @@ -1849,6 +1845,10 @@ function Addon:MakeDebugOptions(categoryName, chatCmd, arg1, ...) local opts = GUI:CreateGroupBox(opts, "Debug") GUI:CreateToggle(opts, {"debug"}, self.L["Enable"]) GUI:CreateNewline(opts) + + GUI:CreateToggle(opts, {"debugShowLuaErrors"}, "Show Lua Errors", nil, disabled).width = 2 + GUI:CreateNewline(opts) + GUI:CreateExecute(opts, "reload", self.L["Reload UI"], nil, ReloadUI) end end @@ -1914,9 +1914,6 @@ function Addon:MakeDebugOptions(categoryName, chatCmd, arg1, ...) local disabled = disabled or self:GetOption("debugOutput", "suppressAll") - GUI:CreateToggle(opts, {"debugOutput", "luaError"}, "Lua Error", nil, disabled).width = 2 - GUI:CreateNewline(opts) - GUI:CreateToggle(opts, {"debugOutput", "tooltipMethodHook"}, "Tooltip Method Hook", nil, disabled).width = 2 GUI:CreateNewline(opts) @@ -1947,6 +1944,9 @@ function Addon:MakeDebugOptions(categoryName, chatCmd, arg1, ...) GUI:CreateToggle(opts, {"debugOutput", "constructorLineMove"}, "Constructor Moving Line", nil, disabled).width = 2 GUI:CreateNewline(opts) + GUI:CreateToggle(opts, {"debugOutput", "paddingDecisions"}, "Padding Decisions", nil, disabled).width = 2 + GUI:CreateNewline(opts) + GUI:CreateToggle(opts, {"debugOutput", "InterfaceOptionsFrameFix"}, "Interface Options Patch", nil, disabled).width = 2 end diff --git a/Config/Settings.lua b/Config/Settings.lua index da81c95..3afa1de 100644 --- a/Config/Settings.lua +++ b/Config/Settings.lua @@ -184,6 +184,8 @@ function Addon:MakeDefaultOptions() -- Debug options debug = false, + + debugShowLuaErrors = true, debugView = { ["*"] = false, diff --git a/Init/Init.lua b/Init/Init.lua index 913a176..9880cda 100644 --- a/Init/Init.lua +++ b/Init/Init.lua @@ -107,6 +107,12 @@ do function Addon:DebugfIf(keys, ...) return DebugIf(self, "Debugf", keys, ...) end + function Addon:DebugIfOutput(key, ...) + return DebugIf(self, "Debug", {"debugOutput", key}, ...) + end + function Addon:DebugfIfOutput(key, ...) + return DebugIf(self, "Debugf", {"debugOutput", key}, ...) + end function Addon:DebugData(t) local texts = {} @@ -134,7 +140,7 @@ do do local function GetErrorHandler(errFunc) - if Addon:IsDebugEnabled() and (not Addon:IsDBLoaded() or Addon:GetOption("debugOutput", "luaError")) then + if Addon:IsDebugEnabled() and (not Addon:IsDBLoaded() or Addon:GetOption"debugShowLuaErrors") then return function(...) geterrorhandler()(...) if errFunc then @@ -148,7 +154,7 @@ do return xpcall(func, GetErrorHandler(errFunc)) end function Addon:Throw(...) - if Addon:IsDebugEnabled() and (not Addon:IsDBLoaded() or Addon:GetOption("debugOutput", "luaError")) then + if Addon:IsDebugEnabled() and (not Addon:IsDBLoaded() or Addon:GetOption"debugShowLuaErrors") then local text = format(...) geterrorhandler()(...) end diff --git a/Operations/ManageConstructors.lua b/Operations/ManageConstructors.lua index b8bb04a..281b6be 100644 --- a/Operations/ManageConstructors.lua +++ b/Operations/ManageConstructors.lua @@ -13,7 +13,7 @@ local cacheSize = 0 local constructorCache = {} function Addon:WipeConstructorCache() for hash, timer in pairs(constructorCleanup) do - Addon:DebugfIf({"debugOutput", "constructorWiped"}, "Constructor wiped: %s", hash) + Addon:DebugfIfOutput("constructorWiped", "Constructor wiped: %s", hash) timer:Cancel() end wipe(constructorCache) @@ -82,7 +82,7 @@ local function GetHash(tooltip, methodName, link, ...) end local function Cleanup(hash) - Addon:DebugfIf({"debugOutput", "constructorWiped"}, "Constructor wiped: %s", hash) + Addon:DebugfIfOutput("constructorWiped", "Constructor wiped: %s", hash) if constructorCache[hash] then cacheSize = cacheSize - 1 @@ -119,7 +119,7 @@ function Addon:SetConstructor(constructor, tooltip, link, methodName, ...) StartCleanup(hash) if constructorCount[hash] >= self:GetOption("cache", "constructorMinSeenCount") and GetTime() - constructorClock[hash] >= self:GetOption("cache", "constructorMinSeenTime") then - self:DebugfIf({"debugOutput", "constructorCached"}, "Constructor cached: %s", hash) + self:DebugfIfOutput("constructorCached", "Constructor cached: %s", hash) if not constructorCache[hash] then cacheSize = cacheSize + 1 end diff --git a/Operations/RebuildTooltip.lua b/Operations/RebuildTooltip.lua index 14905aa..715aab3 100644 --- a/Operations/RebuildTooltip.lua +++ b/Operations/RebuildTooltip.lua @@ -115,7 +115,7 @@ local function MoveLine(fullDestructor, halfDestructor, tooltip, tooltipName, fr end end - Addon:DebugfIf({"debugOutput", "constructorLineMove"}, "Attaching line %s to line %s", source, dest) + Addon:DebugfIfOutput("constructorLineMove", "Attaching line %s to line %s", source, dest) -- attach the source line to the dest line, with padding offset local numPoints = frame:GetNumPoints() @@ -294,16 +294,16 @@ function Addon:ValidateConstructor(tooltip, constructor) for i = constructor.numLines, 1, -1 do local validation = constructor.validation[i] if not validation then - self:DebugfIf({"debugOutput", "constructorValidationFail"}, "Constructor validation failed. Line %d, Missing validation data", i) + self:DebugfIfOutput("constructorValidationFail", "Constructor validation failed. Line %d, Missing validation data", i) end local frame = _G[tooltipName.."TextLeft"..i] if not frame then - self:DebugfIf({"debugOutput", "constructorValidationFail"}, "Constructor validation failed. Line %d, Expected '%s', Could not find %s", i, validation, tooltipName.."TextLeft"..i) + self:DebugfIfOutput("constructorValidationFail", "Constructor validation failed. Line %d, Expected '%s', Could not find %s", i, validation, tooltipName.."TextLeft"..i) return false end if frame:GetText() ~= validation then - self:DebugfIf({"debugOutput", "constructorValidationFail"}, "Constructor validation failed. Line %d, Expected '%s', Found '%s'", i, validation, frame:GetText()) + self:DebugfIfOutput("constructorValidationFail", "Constructor validation failed. Line %d, Expected '%s', Found '%s'", i, validation, frame:GetText()) return false end end diff --git a/Operations/ScanTooltip.lua b/Operations/ScanTooltip.lua index 15ef25b..5ceff3e 100644 --- a/Operations/ScanTooltip.lua +++ b/Operations/ScanTooltip.lua @@ -31,7 +31,7 @@ function Addon:PrepareTooltip(tooltip, methodName, ...) end if methodName then tooltip[methodName](tooltip, unpack(args, 1, args.n)) - self:DebugfIf({"debugOutput", opt}, "Refreshing scanner tooltip: %s", tooltipName) + self:DebugfIfOutput(opt, "Refreshing scanner tooltip: %s", tooltipName) end end) end