Skip to content

Commit

Permalink
Minor refactor & fix chat commands
Browse files Browse the repository at this point in the history
  • Loading branch information
Anonomit committed Dec 8, 2023
1 parent eafe781 commit 3dd48e9
Show file tree
Hide file tree
Showing 10 changed files with 1,058 additions and 292 deletions.
141 changes: 0 additions & 141 deletions Config/GUI.lua

This file was deleted.

148 changes: 113 additions & 35 deletions Config/OptionsTables.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,53 +8,49 @@ local L = LibStub("AceLocale-3.0"):GetLocale(ADDON_NAME)




-- █████╗ ██████╗ ██████╗ ██████╗ ███╗ ██╗ ██████╗ ██████╗ ████████╗██╗ ██████╗ ███╗ ██╗███████╗
-- ██╔══██╗██╔══██╗██╔══██╗██╔═══██╗███╗ ██ ██╔═══██╗██╔══██╗╚══██╔══╝██║██╔═══██╗████╗ ██║██╔════╝
-- ███████║██ ██║██║ ██║██║ ██║██╔██╗ ██║ ██║ ██║██████╔╝ ██║ ██║██║ ██║████╗ ██║███████╗
-- ██╔══██║██║ ██║██║ ██║██║ ██║██║╚██╗██║ ██║ ██║██╔═══╝ ██║ ██║██║ ██║██║╚████║╚════██║
-- ██║ ██║██████╔╝██████╔╝╚██████╔╝██║ ╚████║ ╚██████╔╝██║ ██║ ██║╚██████╔╝██║ ╚████║███████║
-- ╚═╝ ╚═╝╚═════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝╚══════╝

function Addon:MakeAddonOptions(chatCmd)
local title = format("%s v%s (/%s)", ADDON_NAME, tostring(self:GetOption"version"), chatCmd)
local title = format("%s", ADDON_NAME)
local panel = self:CreateOptionsCategory(nil, function()
-- ██████╗ ███████╗███╗ ██╗███████╗██████╗ █████╗ ██╗ ██████╗ ██████╗ ████████╗██╗ ██████╗ ███╗ ██╗███████╗
-- ██╔════╝ ██╔════╝████╗ ██║██╔════╝██╔══██╗██╔══██╗██║ ██╔═══██╗██╔══██╗╚══██╔══╝██║██╔═══██╗████╗ ██║██╔════╝
-- ██║ ███╗█████╗ ██╔██╗ ██║█████╗ ██████╔╝███████║██║ ██║ ██║██████╔██║ ██║██║ ██║██╔██╗ ██║███████╗
-- ██║ ██║██╔══╝ ██║╚██╗██║██╔══╝ ██╔══██╗██╔══██║██║ ██║ ██║██╔═══ ██║ ██║██║ ██║██║╚██╗██║╚════██║
-- ╚██████╔╝███████╗██║ ╚████║███████╗██║ ██║██║ ██║███████╗ ╚██████╔╝██║ ██║ ██║╚██████╔╝██║ ╚████║███████║
-- ╚═════╝ ╚══════╝╚═╝ ╚═══╝╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝╚══════╝

local function MakeGeneralOptions(opts)
local self = Addon
local GUI = self.GUI
local opts = GUI:CreateGroup(opts, ADDON_NAME, ADDON_NAME)


local GUI = self.GUI:ResetOrder()
local opts = GUI:CreateGroupTop(title, "tab")
GUI:SetDBType"Global"

local option = GUI:CreateToggle(opts, {"UsePersistentStorage"}, L["Use Persistent Storage"], L["If enabled, cache will be stored on logout. This may slightly increase loading time.|n|nIf disabled, cache will be rebuilt during each session. This will result in dramatically more cache misses."])

GUI:CreateNewline(opts)
local option = GUI:CreateToggle(opts, {"..", "global", "UsePersistentStorage"}, L["Use Persistent Storage"], L["If enabled, cache will be stored on logout. This may slightly increase loading time.|n|nIf disabled, cache will be rebuilt during each session. This will result in dramatically more cache misses."])
option.set = function(info, val) self:SetGlobalOption(val, "UsePersistentStorage") end
option.get = function(info) return self:GetGlobalOption"UsePersistentStorage" end
GUI:ResetDBType()

return opts
end)
function self:OpenAddonOptions() return self:OpenConfig(panel) end
end






-- ██████╗ ███████╗██████╗ ██╗ ██╗ ██████╗ ██████╗ ██████╗ ████████╗██╗ ██████╗ ███╗ ██╗███████╗
-- ██╔══██╗██╔════╝██╔══██╗██║ ██║██╔════╝ ██╔═══██╗██╔══██╗╚══██╔══╝██║██╔═══██╗████╗ ██║██╔════╝
-- ██║ ██║█████╗ ██████╔╝██║ ██║██║ ███╗ ██║ ██║██████╔╝ ██║ ██║██║ ██║██╔██╗ ██║███████╗
-- ██║ ██║██╔══╝ ██╔══██╗██║ ██║██║ ██║ ██║ ██║██╔═══╝ ██║ ██║██║ ██║██║╚██╗██║╚════██║
-- ██████╔╝███████╗██████╔╝╚██████╔╝╚██████╔╝ ╚██████╔╝██║ ██║ ██║╚██████╔╝██║ ╚████║███████║
-- ╚═════╝ ╚══════╝╚═════╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝╚══════╝

function Addon:MakeDebugOptions(categoryName, chatCmd, arg1, ...)
local title = format("%s v%s > %s (/%s %s)", ADDON_NAME, tostring(self:GetOption"version"), categoryName, chatCmd, arg1)
local title = format("%s", categoryName)
local panel = self:CreateOptionsCategory(categoryName, function()
local function MakeDebugOptions(opts, categoryName)
local self = Addon
local GUI = self.GUI

if not self:IsDebugEnabled() then return end

local GUI = self.GUI:ResetOrder()
local opts = GUI:CreateGroupTop(title, "tab")
GUI:SetDBType"Global"
local opts = GUI:CreateGroup(opts, categoryName, categoryName)

GUI:CreateExecute(opts, "reload", self.L["Reload UI"], nil, ReloadUI)

-- Enable
do
Expand All @@ -64,15 +60,20 @@ function Addon:MakeDebugOptions(categoryName, chatCmd, arg1, ...)
local opts = GUI:CreateGroupBox(opts, "Debug")
GUI:CreateToggle(opts, {"debug"}, self.L["Enable"])
GUI:CreateNewline(opts)
GUI:CreateExecute(opts, "reload", self.L["Reload UI"], nil, ReloadUI)

GUI:CreateToggle(opts, {"debugShowLuaErrors"}, self.L["Display Lua Errors"], nil).width = 2
GUI:CreateNewline(opts)

local disabled = not self:GetGlobalOption"debugShowLuaErrors"
GUI:CreateToggle(opts, {"debugShowLuaWarnings"}, self.L["Lua Warning"], nil, disabled).width = 2
end
end

-- Debug Output
do
local opts = GUI:CreateGroup(opts, GUI:Order(), "Output")

local disabled = not self:GetOption"debug"
local disabled = not self:GetGlobalOption"debug"

do
local opts = GUI:CreateGroupBox(opts, "Suppress All")
Expand All @@ -83,16 +84,93 @@ function Addon:MakeDebugOptions(categoryName, chatCmd, arg1, ...)
do
local opts = GUI:CreateGroupBox(opts, "Message Types")

local disabled = disabled or self:GetOption("debugOutput", "suppressAll")
local disabled = disabled or self:GetGlobalOption("debugOutput", "suppressAll")

GUI:CreateToggle(opts, {"debugOutput", "luaError"}, "Lua Error", nil, disabled).width = 2
for i, data in ipairs{
{"optionSet", "Option Set"},
} do
if i ~= 1 then
GUI:CreateNewline(opts)
end
GUI:CreateToggle(opts, {"debugOutput", data[1]}, data[2], nil, disabled).width = 2
end
end
end

GUI:ResetDBType()

return opts
end)
local function OpenOptions() return self:OpenConfig(panel) end
for _, arg in ipairs{arg1, ...} do
self.chatArgs[arg] = OpenOptions
end





-- █████╗ ██████╗ ██████╗ ██████╗ ███╗ ██╗ ██████╗ ██████╗ ████████╗██╗ ██████╗ ███╗ ██╗███████╗
-- ██╔══██╗██╔══██╗██╔══██╗██╔═══██╗████╗ ██║ ██╔═══██╗██╔══██╗╚══██╔══╝██║██╔═══██╗████╗ ██║██╔════╝
-- ███████║██║ ██║██║ ██║██║ ██║██╔██╗ ██║ ██║ ██║██████╔╝ ██║ ██║██║ ██║██╔██╗ ██║███████╗
-- ██╔══██║██║ ██║██║ ██║██║ ██║██║╚██╗██║ ██║ ██║██╔═══╝ ██║ ██║██║ ██║██║╚██╗██║╚════██║
-- ██║ ██║██████╔╝██████╔╝╚██████╔╝██║ ╚████║ ╚██████╔╝██║ ██║ ██║╚██████╔╝██║ ╚████║███████║
-- ╚═╝ ╚═╝╚═════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝╚══════╝

function Addon:MakeAddonOptions(chatCmd)
local title = format("%s v%s (/%s)", ADDON_NAME, tostring(self:GetOption"version"), chatCmd)

local sections = {}
for _, data in ipairs{
{MakeGeneralOptions, nil},
{MakeDebugOptions, self.L["Debug"], "debug", "db"},
} do

local func = data[1]
local name = data[2]
local args = {unpack(data, 3)}

tinsert(sections, function(opts) return func(opts, name) end)

local function OpenOptions() return self:OpenConfig(name) end
if name == self.L["Debug"] then
local OpenOptions_Old = OpenOptions
OpenOptions = function(...)
if not self:GetGlobalOption"debug" then
self:SetGlobalOption(true, "debug")
self:Debug("Debug mode enabled")
end
return OpenOptions_Old(...)
end
end

for _, arg in ipairs(args) do
self:RegisterChatArgAliases(arg, OpenOptions)
end
end

self.AceConfig:RegisterOptionsTable(ADDON_NAME, function()
local GUI = self.GUI:ResetOrder()
local opts = GUI:CreateOpts(title, "tab")

for _, func in ipairs(sections) do
func(opts)
end

return opts
end)

self.AceConfigDialog:SetDefaultSize(ADDON_NAME, 700, 800)
end


function Addon:MakeBlizzardOptions(chatCmd)
local title = format("%s v%s (/%s)", ADDON_NAME, tostring(self:GetOption"version"), chatCmd)
local panel = self:CreateBlizzardOptionsCategory(function()
local GUI = self.GUI:ResetOrder()
local opts = GUI:CreateOpts(title, "tab")

GUI:CreateExecute(opts, "key", ADDON_NAME .. " " .. self.L["Options"], nil, function()
self:OpenConfig(ADDON_NAME)
self:CloseBlizzardConfig()
end)

return opts
end)
end
13 changes: 8 additions & 5 deletions Config/Settings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,22 @@ local Addon = LibStub("AceAddon-3.0"):GetAddon(ADDON_NAME)
function Addon:MakeDefaultOptions()
local fakeAddon = {
db = {
profile = {
profile = {},

global = {
UsePersistentStorage = true,


-- Debug options
debug = false,

debugShowLuaErrors = true,
debugShowLuaWarnings = true,

debugOutput = {
["*"] = false,
},
},

global = {
UsePersistentStorage = true,
},
},
}
return fakeAddon.db
Expand Down
1 change: 0 additions & 1 deletion Config/_config.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<Ui xsi:schemaLocation="http://www.blizzard.com/wow/ui/ ..\FrameXML\UI.xsd">

<Script file="Settings.lua"/>
<Script file="GUI.lua"/>
<Script file="OptionsTables.lua"/>
</Ui>
Loading

0 comments on commit 3dd48e9

Please sign in to comment.