Gladdy-TBC/Options.lua

898 lines
44 KiB
Lua
Raw Normal View History

local type, pairs, tinsert, tsort = type, pairs, table.insert, table.sort
local tostring, str_match, tonumber, string_format = tostring, string.match, tonumber, string.format
local ceil, floor = ceil, floor
2021-05-17 16:49:54 +02:00
local InterfaceOptionsFrame_OpenToFrame = InterfaceOptionsFrame_OpenToFrame
local GetSpellInfo = GetSpellInfo
local LOCALIZED_CLASS_NAMES_MALE = LOCALIZED_CLASS_NAMES_MALE
local CLASS_ICON_TCOORDS = CLASS_ICON_TCOORDS
2021-05-18 18:31:03 +02:00
local AURA_TYPE_DEBUFF, AURA_TYPE_BUFF = AURA_TYPE_DEBUFF, AURA_TYPE_BUFF
2021-05-17 16:49:54 +02:00
2021-05-17 16:49:54 +02:00
local Gladdy = LibStub("Gladdy")
local LibClassAuras = LibStub("LibClassAuras-1.0")
local L = Gladdy.L
Gladdy.TIMER_FORMAT = { tenths = "tenths", seconds = "seconds",
values = {
["tenths"] = "xx:xx Miliseconds",
["seconds"] = "xx Seconds"
}}
function Gladdy:FormatTimer(fontString, timeLeft, milibreakpoint, showSeconds)
if timeLeft < 0 then
fontString:SetText("")
return
end
local time = timeLeft >= 0.0 and timeLeft or 0.0
if Gladdy.db.timerFormat == Gladdy.TIMER_FORMAT.tenths and milibreakpoint then
fontString:SetFormattedText("%.1f", time)
else
if time >= 60 then
if showSeconds then
fontString:SetText(floor(timeLeft / 60) .. ":" .. string_format("%02.f", floor(timeLeft - floor(timeLeft / 60) * 60)))
else
fontString:SetText(ceil(ceil(time / 60)) .. "m")
end
else
fontString:SetFormattedText("%d", ceil(time))
end
end
end
2021-05-17 16:49:54 +02:00
Gladdy.defaults = {
profile = {
locked = false,
2021-06-15 09:06:32 +02:00
hideBlizzard = "arena",
2021-05-17 16:49:54 +02:00
x = 0,
y = 0,
growUp = false,
2021-05-22 13:41:42 +02:00
growDirection = "BOTTOM",
2021-05-17 16:49:54 +02:00
frameScale = 1,
2021-05-22 13:41:42 +02:00
padding = 1,
2021-05-17 16:49:54 +02:00
barWidth = 180,
2021-05-22 13:41:42 +02:00
bottomMargin = 2,
statusbarBorderOffset = 6,
2021-07-26 17:30:46 +02:00
timerFormat = Gladdy.TIMER_FORMAT.tenths,
backgroundColor = {r = 0, g = 0, b = 0, a = 0},
2021-05-17 16:49:54 +02:00
},
}
SLASH_GLADDY1 = "/gladdy"
SlashCmdList["GLADDY"] = function(msg)
2021-05-19 19:33:13 +02:00
if (str_match(msg, "test[1-5]")) then
local _, num = str_match(msg, "(test)([1-5])")
Gladdy:ToggleFrame(tonumber(num))
elseif (msg == "test") then
2021-05-17 16:49:54 +02:00
Gladdy:ToggleFrame(3)
elseif (msg == "ui" or msg == "options" or msg == "config") then
LibStub("AceConfigDialog-3.0"):Open("Gladdy")
elseif (msg == "reset") then
Gladdy.dbi:ResetProfile()
elseif (msg == "hide") then
Gladdy:Reset()
Gladdy:HideFrame()
else
Gladdy:Print(L["Valid slash commands are:"])
Gladdy:Print("/gladdy ui")
2021-05-19 19:33:13 +02:00
Gladdy:Print("/gladdy test")
Gladdy:Print("/gladdy test1-5")
2021-05-17 16:49:54 +02:00
Gladdy:Print("/gladdy hide")
Gladdy:Print("/gladdy reset")
end
end
function Gladdy:option(params)
local defaults = {
get = function(info)
local key = info.arg or info[#info]
return Gladdy.dbi.profile[key]
end,
set = function(info, value)
local key = info.arg or info[#info]
Gladdy.dbi.profile[key] = value
Gladdy:UpdateFrame()
end,
}
for k, v in pairs(params) do
defaults[k] = v
end
return defaults
end
function Gladdy:colorOption(params)
local defaults = {
get = function(info)
local key = info.arg or info[#info]
return Gladdy.dbi.profile[key].r, Gladdy.dbi.profile[key].g, Gladdy.dbi.profile[key].b, Gladdy.dbi.profile[key].a
end,
set = function(info, r, g, b, a)
local key = info.arg or info[#info]
Gladdy.dbi.profile[key].r, Gladdy.dbi.profile[key].g, Gladdy.dbi.profile[key].b, Gladdy.dbi.profile[key].a = r, g, b, a
Gladdy:UpdateFrame()
end,
}
for k, v in pairs(params) do
defaults[k] = v
end
return defaults
end
local function getOpt(info)
local key = info.arg or info[#info]
return Gladdy.dbi.profile[key]
end
local function setOpt(info, value)
local key = info.arg or info[#info]
Gladdy.dbi.profile[key] = value
Gladdy:UpdateFrame()
2021-06-15 09:06:32 +02:00
if Gladdy.db.hideBlizzard == "always" then
SetCVar("showArenaEnemyFrames", 0)
elseif Gladdy.db.hideBlizzard == "never" then
SetCVar("showArenaEnemyFrames", 1)
end
2021-05-17 16:49:54 +02:00
end
local function getColorOpt(info)
local key = info.arg or info[#info]
return Gladdy.dbi.profile[key].r, Gladdy.dbi.profile[key].g, Gladdy.dbi.profile[key].b, Gladdy.dbi.profile[key].a
end
local function setColorOpt(info, r, g, b, a)
local key = info.arg or info[#info]
Gladdy.dbi.profile[key].r, Gladdy.dbi.profile[key].g, Gladdy.dbi.profile[key].b, Gladdy.dbi.profile[key].a = r, g, b, a
Gladdy:UpdateFrame()
end
function Gladdy:SetupModule(name, module, order)
local options = module:GetOptions()
if options then
self.options.args[name] = {
type = "group",
name = L[name],
2021-05-24 12:41:21 +02:00
desc = L[name] .. " " .. L["settings"],
2021-05-17 16:49:54 +02:00
childGroups = "tab",
order = order,
args = {},
}
if (type(options) == "table") then
self.options.args[name].args = options
self.options.args[name].args.reset = {
type = "execute",
name = L["Reset module"],
desc = L["Reset module to defaults"],
order = 1,
func = function()
for k, v in pairs(module.defaults) do
self.dbi.profile[k] = v
end
Gladdy:UpdateFrame()
Gladdy:SetupModule(name, module, order) -- For example click names are not reset by default
end
}
else
self.options.args[name].args.nothing = {
type = "description",
name = L["No settings"],
desc = L["Module has no settings"],
order = 1,
}
end
end
end
local function pairsByKeys(t)
local a = {}
for k in pairs(t) do
tinsert(a, k)
end
2021-05-24 12:41:21 +02:00
tsort(a, function(a, b) return L[a] < L[b] end)
2021-05-17 16:49:54 +02:00
local i = 0
return function()
i = i + 1
if (a[i] ~= nil) then
return a[i], t[a[i]]
else
return nil
end
end
end
function Gladdy:SetupOptions()
self.options = {
type = "group",
name = "Gladdy",
plugins = {},
childGroups = "tree",
get = getOpt,
set = setOpt,
args = {
2021-09-03 01:56:38 +02:00
test = {
order = 1,
width = "0.7",
name = L["Test"],
type = "execute",
func = function()
Gladdy:ToggleFrame(3)
end,
},
hide = {
order = 2,
width = "0.7",
name = L["Hide"],
type = "execute",
func = function()
Gladdy:Reset()
Gladdy:HideFrame()
end,
},
2021-05-17 16:49:54 +02:00
general = {
type = "group",
name = L["General"],
desc = L["General settings"],
childGroups = "tab",
2021-09-03 01:56:38 +02:00
order = 3,
2021-05-17 16:49:54 +02:00
args = {
locked = {
type = "toggle",
name = L["Lock frame"],
desc = L["Toggle if frame can be moved"],
order = 1,
},
2021-05-22 13:41:42 +02:00
growDirection = {
type = "select",
name = L["Grow Direction"],
order = 3,
values = {
["BOTTOM"] = L["Down"],
["TOP"] = L["Up"],
["LEFT"] = L["Left"],
["RIGHT"] = L["Right"],
}
},
2021-06-15 09:06:32 +02:00
hideBlizzard = {
type = "select",
name = L["Hide Blizzard"],
values = {
["arena"] = L["Arena only"],
["never"] = L["Never"],
["always"] = L["Always"],
},
order = 4,
},
2021-05-17 16:49:54 +02:00
group = {
type = "group",
2021-05-24 12:41:21 +02:00
name = L["General"],
2021-06-15 09:06:32 +02:00
order = 5,
2021-05-17 16:49:54 +02:00
childGroups = "tree",
args = {
frameGeneral = {
type = "group",
name = L["Frame General"],
order = 3,
args = {
headerFrame = {
type = "header",
name = L["Frame General"],
order = 3,
},
frameScale = {
type = "range",
name = L["Frame scale"],
desc = L["Scale of the frame"],
order = 4,
min = .1,
max = 2,
2021-07-29 13:34:10 +02:00
step = .01,
2021-05-17 16:49:54 +02:00
},
padding = {
type = "range",
name = L["Frame padding"],
desc = L["Padding of the frame"],
order = 5,
min = 0,
max = 20,
step = 1,
},
barWidth = {
type = "range",
name = L["Frame width"],
desc = L["Width of the bars"],
order = 6,
min = 10,
max = 500,
step = 5,
},
bottomMargin = {
type = "range",
2021-05-22 13:41:42 +02:00
name = L["Margin"],
2021-05-17 16:49:54 +02:00
desc = L["Margin between each button"],
order = 7,
2021-05-22 13:41:42 +02:00
min = -200,
max = 200,
2021-05-17 16:49:54 +02:00
step = 1,
},
2021-07-26 17:30:46 +02:00
backgroundColor = {
type = "color",
name = L["Background color"],
desc = L["Background Color of the frame"],
order = 8,
hasAlpha = true,
get = getColorOpt,
set = setColorOpt,
},
2021-05-17 16:49:54 +02:00
}
},
cooldownGeneral = {
type = "group",
name = L["Cooldown General"],
order = 4,
args = {
headerCooldown = {
type = "header",
name = L["Cooldown General"],
order = 8,
},
disableCooldownCircle = {
type = "toggle",
name = L["No Cooldown Circle"],
order = 9,
get = function(info)
local a = Gladdy.db.auraDisableCircle
local b = Gladdy.db.cooldownDisableCircle
local c = Gladdy.db.trinketDisableCircle
local d = Gladdy.db.drDisableCircle
local e = Gladdy.db.buffsDisableCircle
local f = Gladdy.db.racialDisableCircle
if (a == b and a == c and a == d and a == e and a == f) then
2021-05-17 16:49:54 +02:00
return a
else
return ""
end
end,
set = function(info, value)
Gladdy.db.auraDisableCircle = value
Gladdy.db.cooldownDisableCircle = value
Gladdy.db.trinketDisableCircle = value
Gladdy.db.drDisableCircle = value
Gladdy.db.buffsDisableCircle = value
Gladdy.db.racialDisableCircle = value
2021-05-17 16:49:54 +02:00
Gladdy:UpdateFrame()
end,
width= "full",
},
cooldownCircleAlpha = {
type = "range",
name = L["Cooldown circle alpha"],
order = 10,
min = 0,
max = 1,
step = 0.1,
get = function(info)
local a = Gladdy.db.cooldownCooldownAlpha
local b = Gladdy.db.drCooldownAlpha
local c = Gladdy.db.auraCooldownAlpha
local d = Gladdy.db.trinketCooldownAlpha
local e = Gladdy.db.buffsCooldownAlpha
local f = Gladdy.db.racialCooldownAlpha
if (a == b and a == c and a == d and a == e and a == f) then
2021-05-17 16:49:54 +02:00
return a
else
return ""
end
end,
set = function(info, value)
Gladdy.db.cooldownCooldownAlpha = value
Gladdy.db.drCooldownAlpha = value
Gladdy.db.auraCooldownAlpha = value
Gladdy.db.trinketCooldownAlpha = value
Gladdy.db.buffsCooldownAlpha = value
Gladdy.db.racialCooldownAlpha = value
2021-05-17 16:49:54 +02:00
Gladdy:UpdateFrame()
end
},
timerFormat = Gladdy:option({
type = "select",
name = L["Timer Format"],
order = 11,
values = Gladdy.TIMER_FORMAT.values
})
2021-05-17 16:49:54 +02:00
},
},
fontGeneral = {
type = "group",
name = L["Font General"],
order = 4,
args = {
headerFont = {
type = "header",
name = L["Font General"],
order = 10,
},
font = {
type = "select",
name = L["Font"],
desc = L["General Font"],
order = 11,
dialogControl = "LSM30_Font",
values = AceGUIWidgetLSMlists.font,
get = function(info)
local a = Gladdy.db.auraFont
local b = Gladdy.db.buffsFont
local c = Gladdy.db.castBarFont
2021-05-17 16:49:54 +02:00
local d = Gladdy.db.cooldownFont
local e = Gladdy.db.drFont
local f = Gladdy.db.healthBarFont
local g = Gladdy.db.petHealthBarFont
local h = Gladdy.db.powerBarFont
local i = Gladdy.db.racialFont
local j = Gladdy.db.npTremorFont
local k = Gladdy.db.trinketFont
if (a == b and a == c and a == d and a == e and a == f
and a == g and a == h and a == i and a == j and a == k) then
2021-05-17 16:49:54 +02:00
return a
else
return ""
end
end,
set = function(info, value)
Gladdy.db.auraFont = value
Gladdy.db.buffsFont = value
2021-05-17 16:49:54 +02:00
Gladdy.db.castBarFont = value
Gladdy.db.cooldownFont = value
Gladdy.db.drFont = value
Gladdy.db.healthBarFont = value
Gladdy.db.petHealthBarFont = value
Gladdy.db.powerBarFont = value
Gladdy.db.racialFont = value
Gladdy.db.npTremorFont = value
Gladdy.db.trinketFont = value
2021-05-17 16:49:54 +02:00
Gladdy:UpdateFrame()
end,
},
fontColor = {
type = "color",
name = L["Font color text"],
2021-05-17 16:49:54 +02:00
desc = L["Color of the text"],
order = 12,
hasAlpha = true,
get = function(info)
local a = Gladdy.db.healthBarFontColor
local b = Gladdy.db.powerBarFontColor
local c = Gladdy.db.castBarFontColor
local d = Gladdy.db.petHealthBarFontColor
2021-05-17 16:49:54 +02:00
if (a.r == b.r and a.g == b.g and a.b == b.b and a.a == b.a
and a.r == c.r and a.g == c.g and a.b == c.b and a.a == c.a
and a.r == d.r and a.g == d.g and a.b == d.b and a.a == d.a) then
2021-05-17 16:49:54 +02:00
return a.r, a.g, a.b, a.a
else
return { r = 0, g = 0, b = 0, a = 0 }
end
end,
set = function(info, r, g, b, a)
local rgb = {r = r, g = g, b = b, a = a}
Gladdy.db.healthBarFontColor = rgb
Gladdy.db.powerBarFontColor = rgb
Gladdy.db.castBarFontColor = rgb
Gladdy.db.petHealthBarFontColor = rgb
Gladdy:UpdateFrame()
end,
},
fontColorCD = {
type = "color",
name = L["Font color timer"],
desc = L["Color of the timers"],
order = 12,
hasAlpha = true,
get = function(info)
local a = Gladdy.db.auraFontColor
local b = Gladdy.db.buffsFontColor
local c = Gladdy.db.cooldownFontColor
local d = Gladdy.db.drFontColor
if (a.r == b.r and a.g == b.g and a.b == b.b and a.a == b.a
and a.r == c.r and a.g == c.g and a.b == c.b and a.a == c.a
and a.r == d.r and a.g == d.g and a.b == d.b and a.a == d.a) then
return a.r, a.g, a.b, a.a
else
return { r = 0, g = 0, b = 0, a = 0 }
end
end,
set = function(info, r, g, b, a)
local rgb = {r = r, g = g, b = b, a = a}
Gladdy.db.auraFontColor = rgb
Gladdy.db.buffsFontColor = rgb
Gladdy.db.cooldownFontColor = rgb
Gladdy.db.drFontColor = rgb
2021-05-17 16:49:54 +02:00
Gladdy:UpdateFrame()
end,
},
},
},
iconsGeneral = {
type = "group",
name = L["Icons General"],
order = 5,
args = {
headerIcon = {
type = "header",
name = L["Icons General"],
order = 13,
},
buttonBorderStyle = {
type = "select",
name = L["Icon border style"],
desc = L["This changes the border style of all icons"],
order = 14,
values = Gladdy:GetIconStyles(),
get = function(info)
if (Gladdy.db.auraBorderStyle == Gladdy.db.buffsBorderStyle
and Gladdy.db.auraBorderStyle == Gladdy.db.castBarIconStyle
and Gladdy.db.auraBorderStyle == Gladdy.db.classIconBorderStyle
and Gladdy.db.auraBorderStyle == Gladdy.db.cooldownBorderStyle
and Gladdy.db.auraBorderStyle == Gladdy.db.ciBorderStyle
and Gladdy.db.auraBorderStyle == Gladdy.db.cooldownBorderStyle
and Gladdy.db.auraBorderStyle == Gladdy.db.drBorderStyle
and Gladdy.db.auraBorderStyle == Gladdy.db.racialBorderStyle
and Gladdy.db.auraBorderStyle == Gladdy.db.npTotemPlatesBorderStyle
and Gladdy.db.auraBorderStyle == Gladdy.db.petPortraitBorderStyle
and Gladdy.db.auraBorderStyle == Gladdy.db.trinketBorderStyle) then
return Gladdy.db.auraBorderStyle
2021-05-17 16:49:54 +02:00
else
return ""
end
end,
set = function(info, value)
Gladdy.db.auraBorderStyle = value
Gladdy.db.buffsBorderStyle = value
Gladdy.db.castBarIconStyle = value
Gladdy.db.classIconBorderStyle = value
Gladdy.db.ciBorderStyle = value
Gladdy.db.cooldownBorderStyle = value
2021-05-17 16:49:54 +02:00
Gladdy.db.drBorderStyle = value
Gladdy.db.racialBorderStyle = value
Gladdy.db.npTotemPlatesBorderStyle = value
Gladdy.db.petPortraitBorderStyle = value
Gladdy.db.trinketBorderStyle = value
2021-05-17 16:49:54 +02:00
Gladdy:UpdateFrame()
end,
},
buttonBorderColor = {
type = "color",
name = L["Icon border color"],
desc = L["This changes the border color of all icons"],
order = 15,
hasAlpha = true,
get = function(info)
local a = Gladdy.db.auraBuffBorderColor
local b = Gladdy.db.auraDebuffBorderColor
local c = Gladdy.db.buffsBorderColor
local d = Gladdy.db.castBarIconColor
local e = Gladdy.db.classIconBorderColor
local f = Gladdy.db.ciBorderColor
local g = Gladdy.db.cooldownBorderColor
local h = Gladdy.db.drBorderColor
local i = Gladdy.db.trinketBorderColor
local j = Gladdy.db.racialBorderColor
2021-05-17 16:49:54 +02:00
if (a.r == b.r and a.g == b.g and a.b == b.b and a.a == b.a
and a.r == c.r and a.g == c.g and a.b == c.b and a.a == c.a
and a.r == d.r and a.g == d.g and a.b == d.b and a.a == d.a
and a.r == e.r and a.g == e.g and a.b == e.b and a.a == e.a
and a.r == f.r and a.g == f.g and a.b == f.b and a.a == f.a
and a.r == g.r and a.g == g.g and a.b == g.b and a.a == g.a
and a.r == h.r and a.g == h.g and a.b == h.b and a.a == h.a
and a.r == i.r and a.g == i.g and a.b == i.b and a.a == i.a
and a.r == j.r and a.g == j.g and a.b == j.b and a.a == j.a) then
2021-05-17 16:49:54 +02:00
return a.r, a.g, a.b, a.a
else
return { r = 0, g = 0, b = 0, a = 0 }
end
end,
set = function(info, r, g, b, a)
local rgb = {r = r, g = g, b = b, a = a}
Gladdy.db.auraBuffBorderColor = rgb
Gladdy.db.auraDebuffBorderColor = rgb
Gladdy.db.buffsBorderColor = rgb
2021-05-17 16:49:54 +02:00
Gladdy.db.castBarIconColor = rgb
Gladdy.db.classIconBorderColor = rgb
Gladdy.db.ciBorderColor = rgb
2021-05-17 16:49:54 +02:00
Gladdy.db.cooldownBorderColor = rgb
Gladdy.db.drBorderColor = rgb
Gladdy.db.trinketBorderColor = rgb
Gladdy.db.racialBorderColor = rgb
2021-05-17 16:49:54 +02:00
Gladdy:UpdateFrame()
end,
},
},
},
statusbarGeneral = {
type = "group",
name = L["Statusbar General"],
order = 6,
args = {
headerStatusbar = {
type = "header",
name = L["Statusbar General"],
order = 47,
},
statusbarTexture = {
type = "select",
name = L["Statusbar texture"],
desc = L["This changes the texture of all statusbar frames"],
order = 48,
dialogControl = "LSM30_Statusbar",
values = AceGUIWidgetLSMlists.statusbar,
get = function(info)
local a = Gladdy.db.healthBarTexture
local b = Gladdy.db.powerBarTexture
local c = Gladdy.db.castBarTexture
local d = Gladdy.db.petHealthBarTexture
if (a == b and a == c and a == d) then
2021-05-17 16:49:54 +02:00
return a
else
return ""
end
end,
set = function(info, value)
Gladdy.db.healthBarTexture = value
Gladdy.db.powerBarTexture = value
Gladdy.db.castBarTexture = value
Gladdy.db.petHealthBarTexture = value
2021-05-17 16:49:54 +02:00
Gladdy:UpdateFrame()
end,
width= "full",
},
statusbarBorderStyle = {
type = "select",
name = L["Statusbar border style"],
desc = L["This changes the border style of all statusbar frames"],
order = 49,
dialogControl = "LSM30_Border",
values = AceGUIWidgetLSMlists.border,
get = function(info)
local a = Gladdy.db.healthBarBorderStyle
local b = Gladdy.db.powerBarBorderStyle
local c = Gladdy.db.castBarBorderStyle
local d = Gladdy.db.petHealthBarBorderStyle
if (a == b and a == c and a == d) then
2021-05-17 16:49:54 +02:00
return a
else
return ""
end
end,
set = function(info, value)
Gladdy.db.healthBarBorderStyle = value
Gladdy.db.powerBarBorderStyle = value
Gladdy.db.castBarBorderStyle = value
Gladdy.db.petHealthBarBorderStyle = value
2021-05-17 16:49:54 +02:00
Gladdy:UpdateFrame()
end,
},
statusbarBorderOffset = Gladdy:option({
type = "range",
name = L["Statusbar border offset divider (smaller is higher offset)"],
desc = L["Offset of border to statusbar (in case statusbar shows beyond the border)"],
min = 1,
max = 20,
step = 0.1,
}),
statusbarBorderColor = {
type = "color",
name = L["Statusbar border color"],
desc = L["This changes the border color of all statusbar frames"],
order = 50,
hasAlpha = true,
get = function(info)
local a = Gladdy.db.castBarBorderColor
local b = Gladdy.db.healthBarBorderColor
local c = Gladdy.db.powerBarBorderColor
local d = Gladdy.db.petHealthBarBorderColor
2021-05-17 16:49:54 +02:00
if (a.r == b.r and a.g == b.g and a.b == b.b and a.a == b.a
and a.r == c.r and a.g == c.g and a.b == c.b and a.a == c.a
and a.r == d.r and a.g == d.g and a.b == d.b and a.a == d.a) then
2021-05-17 16:49:54 +02:00
return a.r, a.g, a.b, a.a
else
return { r = 0, g = 0, b = 0, a = 0 }
end
end,
set = function(info, r, g, b, a)
local rgb = {r = r, g = g, b = b, a = a}
Gladdy.db.castBarBorderColor = rgb
Gladdy.db.healthBarBorderColor = rgb
Gladdy.db.powerBarBorderColor = rgb
Gladdy.db.petHealthBarBorderColor = rgb
2021-05-17 16:49:54 +02:00
Gladdy:UpdateFrame()
end,
},
},
},
},
},
},
},
},
}
2021-09-03 01:56:38 +02:00
local order = 4
2021-05-17 16:49:54 +02:00
for k, v in pairsByKeys(self.modules) do
self:SetupModule(k, v, order)
order = order + 1
end
local options = {
name = "Gladdy",
type = "group",
args = {
load = {
name = "Load configuration",
desc = "Load configuration options",
type = "execute",
func = function()
HideUIPanel(InterfaceOptionsFrame)
HideUIPanel(GameMenuFrame)
LibStub("AceConfigDialog-3.0"):Open("Gladdy")
end,
},
},
}
self.options.plugins.profiles = { profiles = LibStub("AceDBOptions-3.0"):GetOptionsTable(self.dbi) }
LibStub("AceConfig-3.0"):RegisterOptionsTable("Gladdy_blizz", options)
LibStub("AceConfigDialog-3.0"):AddToBlizOptions("Gladdy_blizz", "Gladdy")
LibStub("AceConfig-3.0"):RegisterOptionsTable("Gladdy", self.options)
end
function Gladdy:ShowOptions()
InterfaceOptionsFrame_OpenToFrame("Gladdy")
end
function Gladdy:GetAuras(auraType)
local spells = {
ckeckAll = {
order = 1,
width = "0.7",
name = "Check All",
type = "execute",
func = function(info)
2021-05-18 18:31:03 +02:00
if auraType == AURA_TYPE_DEBUFF then
for k,v in pairs(Gladdy.defaults.profile.trackedDebuffs) do
Gladdy.dbi.profile.trackedDebuffs[k] = true
end
else
for k,v in pairs(Gladdy.defaults.profile.trackedBuffs) do
Gladdy.dbi.profile.trackedBuffs[k] = true
end
2021-05-17 16:49:54 +02:00
end
end,
},
uncheckAll = {
order = 2,
width = "0.7",
name = "Uncheck All",
type = "execute",
func = function(info)
2021-05-18 18:31:03 +02:00
if auraType == AURA_TYPE_DEBUFF then
for k,v in pairs(Gladdy.defaults.profile.trackedDebuffs) do
Gladdy.dbi.profile.trackedDebuffs[k] = false
end
else
for k,v in pairs(Gladdy.defaults.profile.trackedBuffs) do
Gladdy.dbi.profile.trackedBuffs[k] = false
end
2021-05-17 16:49:54 +02:00
end
end,
},
druid = {
order = 3,
type = "group",
name = LOCALIZED_CLASS_NAMES_MALE["DRUID"],
icon = "Interface\\Glues\\CharacterCreate\\UI-CharacterCreate-Classes",
iconCoords = CLASS_ICON_TCOORDS["DRUID"],
args = {},
},
hunter = {
order = 4,
type = "group",
name = LOCALIZED_CLASS_NAMES_MALE["HUNTER"],
icon = "Interface\\Glues\\CharacterCreate\\UI-CharacterCreate-Classes",
iconCoords = CLASS_ICON_TCOORDS["HUNTER"],
args = {},
},
mage = {
order = 5,
type = "group",
name = LOCALIZED_CLASS_NAMES_MALE["MAGE"],
icon = "Interface\\Glues\\CharacterCreate\\UI-CharacterCreate-Classes",
iconCoords = CLASS_ICON_TCOORDS["MAGE"],
args = {},
},
paladin = {
order = 6,
type = "group",
name = LOCALIZED_CLASS_NAMES_MALE["PALADIN"],
icon = "Interface\\Glues\\CharacterCreate\\UI-CharacterCreate-Classes",
iconCoords = CLASS_ICON_TCOORDS["PALADIN"],
args = {},
},
priest = {
order = 7,
type = "group",
name = LOCALIZED_CLASS_NAMES_MALE["PRIEST"],
icon = "Interface\\Glues\\CharacterCreate\\UI-CharacterCreate-Classes",
iconCoords = CLASS_ICON_TCOORDS["PRIEST"],
args = {},
},
rogue = {
order = 8,
type = "group",
name = LOCALIZED_CLASS_NAMES_MALE["ROGUE"],
icon = "Interface\\Glues\\CharacterCreate\\UI-CharacterCreate-Classes",
iconCoords = CLASS_ICON_TCOORDS["ROGUE"],
args = {},
},
shaman = {
order = 9,
type = "group",
name = LOCALIZED_CLASS_NAMES_MALE["SHAMAN"],
icon = "Interface\\Glues\\CharacterCreate\\UI-CharacterCreate-Classes",
iconCoords = CLASS_ICON_TCOORDS["SHAMAN"],
args = {},
},
warlock = {
order = 10,
type = "group",
name = LOCALIZED_CLASS_NAMES_MALE["WARLOCK"],
icon = "Interface\\Glues\\CharacterCreate\\UI-CharacterCreate-Classes",
iconCoords = CLASS_ICON_TCOORDS["WARLOCK"],
args = {},
},
warrior = {
order = 10,
type = "group",
name = LOCALIZED_CLASS_NAMES_MALE["WARRIOR"],
icon = "Interface\\Glues\\CharacterCreate\\UI-CharacterCreate-Classes",
iconCoords = CLASS_ICON_TCOORDS["WARRIOR"],
args = {},
},
}
local defaultDebuffs = {}
local assignForClass = function(class)
local args = {}
2021-05-18 18:31:03 +02:00
local classSpells = auraType == AURA_TYPE_DEBUFF and LibClassAuras.GetClassDebuffs(class) or LibClassAuras.GetClassBuffs(class)
2021-05-17 16:49:54 +02:00
table.sort(classSpells, function(a, b)
return a.name:upper() < b.name:upper()
end)
for i=1, #classSpells do
2021-05-18 18:31:03 +02:00
local _, _, texture = GetSpellInfo(classSpells[i].id[#classSpells[i].id])
2021-05-17 16:49:54 +02:00
if classSpells[i].texture then
texture = classSpells[i].texture
end
args[tostring(classSpells[i].id[1])] = {
2021-05-17 16:49:54 +02:00
order = i,
name = classSpells[i].name,
type = "toggle",
image = texture,
width = "full",
2021-05-18 18:31:03 +02:00
arg = tostring(classSpells[i].id[1])
2021-05-17 16:49:54 +02:00
}
defaultDebuffs[tostring(classSpells[i].id[1])] = true
2021-05-17 16:49:54 +02:00
end
return args
end
spells.druid.args = assignForClass("DRUID")
spells.hunter.args = assignForClass("HUNTER")
spells.mage.args = assignForClass("MAGE")
spells.paladin.args = assignForClass("PALADIN")
spells.priest.args = assignForClass("PRIEST")
spells.rogue.args = assignForClass("ROGUE")
spells.shaman.args = assignForClass("SHAMAN")
spells.warlock.args = assignForClass("WARLOCK")
spells.warrior.args = assignForClass("WARRIOR")
return spells, defaultDebuffs
end