Skip to content

Commit

Permalink
Fix options menu
Browse files Browse the repository at this point in the history
Restore Profile options and intended category order
  • Loading branch information
Anonomit committed Jun 23, 2023
1 parent 6686f74 commit 929ec77
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 26 deletions.
32 changes: 16 additions & 16 deletions Config/OptionsTables.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions Config/Settings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@ function Addon:MakeDefaultOptions()

-- Debug options
debug = false,

debugShowLuaErrors = true,

debugView = {
["*"] = false,
Expand Down
10 changes: 8 additions & 2 deletions Init/Init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions Operations/ManageConstructors.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions Operations/RebuildTooltip.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Operations/ScanTooltip.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 929ec77

Please sign in to comment.