cooldown refactor + positioning

This commit is contained in:
Sumsebrum 2022-03-03 23:37:42 +01:00
parent 051571f4ef
commit 27573b7530
4 changed files with 268 additions and 94 deletions

View File

@ -13,6 +13,34 @@ tbl_sort(Gladdy.CLASSES)
Gladdy.RACES = {"Scourge", "BloodElf", "Tauren", "Orc", "Troll", "NightElf", "Draenei", "Human", "Gnome", "Dwarf"} Gladdy.RACES = {"Scourge", "BloodElf", "Tauren", "Orc", "Troll", "NightElf", "Draenei", "Human", "Gnome", "Dwarf"}
tbl_sort(Gladdy.RACES) tbl_sort(Gladdy.RACES)
local RACE_ICON_TCOORDS = {
["HUMAN_MALE"] = {0, 0.125, 0, 0.25},
["DWARF_MALE"] = {0.125, 0.25, 0, 0.25},
["GNOME_MALE"] = {0.25, 0.375, 0, 0.25},
["NIGHTELF_MALE"] = {0.375, 0.5, 0, 0.25},
["TAUREN_MALE"] = {0, 0.125, 0.25, 0.5},
["SCOURGE_MALE"] = {0.125, 0.25, 0.25, 0.5},
["TROLL_MALE"] = {0.25, 0.375, 0.25, 0.5},
["ORC_MALE"] = {0.375, 0.5, 0.25, 0.5},
["HUMAN_FEMALE"] = {0, 0.125, 0.5, 0.75},
["DWARF_FEMALE"] = {0.125, 0.25, 0.5, 0.75},
["GNOME_FEMALE"] = {0.25, 0.375, 0.5, 0.75},
["NIGHTELF_FEMALE"] = {0.375, 0.5, 0.5, 0.75},
["TAUREN_FEMALE"] = {0, 0.125, 0.75, 1.0},
["SCOURGE_FEMALE"] = {0.125, 0.25, 0.75, 1.0},
["TROLL_FEMALE"] = {0.25, 0.375, 0.75, 1.0},
["ORC_FEMALE"] = {0.375, 0.5, 0.75, 1.0},
["BLOODELF_MALE"] = {0.5, 0.625, 0.25, 0.5},
["BLOODELF_FEMALE"] = {0.5, 0.625, 0.75, 1.0},
["DRAENEI_MALE"] = {0.5, 0.625, 0, 0.25},
["DRAENEI_FEMALE"] = {0.5, 0.625, 0.5, 0.75},
}
local specBuffs = { local specBuffs = {
-- DRUID -- DRUID
[GetSpellInfo(45283)] = L["Restoration"], -- Natural Perfection [GetSpellInfo(45283)] = L["Restoration"], -- Natural Perfection
@ -958,23 +986,28 @@ local cooldownList = {
[19503] = 30, -- Scatter Shot [19503] = 30, -- Scatter Shot
[14327] = 30, -- Scare Beast [14327] = 30, -- Scare Beast
[19263] = 300, -- Deterrence; not on BM but can't do 2 specs [19263] = 300, -- Deterrence; not on BM but can't do 2 specs
[14311] = { cd = 30, -- Freezing Trap
sharedCD = {
[13809] = true, -- Frost Trap
[34600] = true, -- Snake Trap
},
},
[13809] = { cd = 30, -- Frost Trap [13809] = { cd = 30, -- Frost Trap
sharedCD = { sharedCD = {
[14311] = true, -- Freezing Trap [14311] = true, -- Freezing Trap
[34600] = true, -- Snake Trap [34600] = true, -- Snake Trap
}, },
icon = select(3, GetSpellInfo(14311)),
},
[14311] = { cd = 30, -- Freezing Trap
sharedCD = {
[13809] = true, -- Frost Trap
[34600] = true, -- Snake Trap
},
icon = select(3, GetSpellInfo(14311)),
}, },
[34600] = { cd = 30, -- Snake Trap [34600] = { cd = 30, -- Snake Trap
sharedCD = { sharedCD = {
[14311] = true, -- Freezing Trap [14311] = true, -- Freezing Trap
[13809] = true, -- Frost Trap [13809] = true, -- Frost Trap
}, },
icon = select(3, GetSpellInfo(14311)),
}, },
[34490] = { cd = 20, spec = L["Marksmanship"], }, -- Silencing Shot [34490] = { cd = 20, spec = L["Marksmanship"], }, -- Silencing Shot
[19386] = { cd = 60, spec = L["Survival"], }, -- Wyvern Sting [19386] = { cd = 60, spec = L["Survival"], }, -- Wyvern Sting
@ -1024,19 +1057,19 @@ local cooldownList = {
}, },
["NightElf"] = { ["NightElf"] = {
[2651] = { cd = 180, spec = L["Discipline"], }, -- Elune's Grace [2651] = { cd = 180, spec = L["Discipline"], class = "PRIEST"}, -- Elune's Grace
[10797] = { cd = 30, spec = L["Discipline"], }, -- Star Shards [10797] = { cd = 30, spec = L["Discipline"], class = "PRIEST"}, -- Star Shards
}, },
["Draenei"] = { ["Draenei"] = {
[32548] = { cd = 300, spec = L["Discipline"], }, -- Hymn of Hope [32548] = { cd = 300, spec = L["Discipline"], class = "PRIEST"}, -- Hymn of Hope
}, },
["Human"] = { ["Human"] = {
[13908] = { cd = 600, spec = L["Discipline"], }, -- Desperate Prayer [13908] = { cd = 600, spec = L["Discipline"], class = "PRIEST"}, -- Desperate Prayer
}, },
["Gnome"] = { ["Gnome"] = {
}, },
["Dwarf"] = { ["Dwarf"] = {
[13908] = { cd = 600, spec = L["Discipline"], }, -- Desperate Prayer [13908] = { cd = 600, spec = L["Discipline"], class = "PRIEST"}, -- Desperate Prayer
}, },
} }
function Gladdy:GetCooldownList() function Gladdy:GetCooldownList()

BIN
Images/downarrow.blp Normal file

Binary file not shown.

BIN
Images/uparrow.blp Normal file

Binary file not shown.

View File

@ -1,52 +1,49 @@
local type, pairs, ipairs, ceil, tonumber, mod, tostring, upper, select, tinsert, tremove = type, pairs, ipairs, ceil, tonumber, mod, tostring, string.upper, select, tinsert, tremove local type, pairs, ipairs, ceil, tonumber, mod, tostring, upper, select, tinsert, tremove = type, pairs, ipairs, ceil, tonumber, mod, tostring, string.upper, select, tinsert, tremove
local tbl_sort = table.sort
local GetTime = GetTime local GetTime = GetTime
local CreateFrame = CreateFrame local CreateFrame = CreateFrame
local RACE_ICON_TCOORDS = {
["HUMAN_MALE"] = {0, 0.125, 0, 0.25},
["DWARF_MALE"] = {0.125, 0.25, 0, 0.25},
["GNOME_MALE"] = {0.25, 0.375, 0, 0.25},
["NIGHTELF_MALE"] = {0.375, 0.5, 0, 0.25},
["TAUREN_MALE"] = {0, 0.125, 0.25, 0.5},
["SCOURGE_MALE"] = {0.125, 0.25, 0.25, 0.5},
["TROLL_MALE"] = {0.25, 0.375, 0.25, 0.5},
["ORC_MALE"] = {0.375, 0.5, 0.25, 0.5},
["HUMAN_FEMALE"] = {0, 0.125, 0.5, 0.75},
["DWARF_FEMALE"] = {0.125, 0.25, 0.5, 0.75},
["GNOME_FEMALE"] = {0.25, 0.375, 0.5, 0.75},
["NIGHTELF_FEMALE"] = {0.375, 0.5, 0.5, 0.75},
["TAUREN_FEMALE"] = {0, 0.125, 0.75, 1.0},
["SCOURGE_FEMALE"] = {0.125, 0.25, 0.75, 1.0},
["TROLL_FEMALE"] = {0.25, 0.375, 0.75, 1.0},
["ORC_FEMALE"] = {0.375, 0.5, 0.75, 1.0},
["BLOODELF_MALE"] = {0.5, 0.625, 0.25, 0.5},
["BLOODELF_FEMALE"] = {0.5, 0.625, 0.75, 1.0},
["DRAENEI_MALE"] = {0.5, 0.625, 0, 0.25},
["DRAENEI_FEMALE"] = {0.5, 0.625, 0.5, 0.75},
}
local GetSpellInfo = GetSpellInfo local GetSpellInfo = GetSpellInfo
local Gladdy = LibStub("Gladdy") local Gladdy = LibStub("Gladdy")
local L = Gladdy.L local L = Gladdy.L
local function tableLength(tbl)
local getN = 0
for n in pairs(tbl) do
getN = getN + 1
end
return getN
end
local function getDefaultCooldown() local function getDefaultCooldown()
local cooldowns = {} local cooldowns = {}
for _,spellTable in pairs(Gladdy:GetCooldownList()) do local cooldownsOrder = {}
for spellId,_ in pairs(spellTable) do for class,spellTable in pairs(Gladdy:GetCooldownList()) do
if not spellTable.class and not cooldownsOrder[class] then
cooldownsOrder[class] = {}
end
for spellId,val in pairs(spellTable) do
local spellName = GetSpellInfo(spellId) local spellName = GetSpellInfo(spellId)
if spellName then if spellName then
cooldowns[tostring(spellId)] = true cooldowns[tostring(spellId)] = true
if type(val) == "table" and val.class then
if val.class and not cooldownsOrder[val.class] then
cooldownsOrder[val.class] = {}
end
if not cooldownsOrder[val.class][tostring(spellId)] then
cooldownsOrder[val.class][tostring(spellId)] = tableLength(cooldownsOrder[val.class]) + 1
end
else
if not cooldownsOrder[class][tostring(spellId)] then
cooldownsOrder[class][tostring(spellId)] = tableLength(cooldownsOrder[class]) + 1
end
end
else else
Gladdy:Debug("ERROR", "spellid does not exist " .. spellId) Gladdy:Debug("ERROR", "spellid does not exist " .. spellId)
end end
end end
end end
return cooldowns return cooldowns, cooldownsOrder
end end
local Cooldowns = Gladdy:NewModule("Cooldowns", nil, { local Cooldowns = Gladdy:NewModule("Cooldowns", nil, {
@ -67,17 +64,24 @@ local Cooldowns = Gladdy:NewModule("Cooldowns", nil, {
cooldownDisableCircle = false, cooldownDisableCircle = false,
cooldownCooldownAlpha = 1, cooldownCooldownAlpha = 1,
cooldownCooldowns = getDefaultCooldown(), cooldownCooldowns = getDefaultCooldown(),
cooldownCooldownsOrder = select(2, getDefaultCooldown()),
cooldownFrameStrata = "MEDIUM", cooldownFrameStrata = "MEDIUM",
cooldownFrameLevel = 3, cooldownFrameLevel = 3,
cooldownGroup = false,
cooldownGroupDirection = "DOWN"
}) })
function Cooldowns:Initialize() function Cooldowns:Initialize()
self.frames = {}
self.cooldownSpellIds = {} self.cooldownSpellIds = {}
self.spellTextures = {} self.spellTextures = {}
self.iconCache = {} self.iconCache = {}
for _,spellTable in pairs(Gladdy:GetCooldownList()) do for _,spellTable in pairs(Gladdy:GetCooldownList()) do
for spellId,_ in pairs(spellTable) do for spellId,val in pairs(spellTable) do
local spellName, _, texture = GetSpellInfo(spellId) local spellName, _, texture = GetSpellInfo(spellId)
if type(val) == "table" and val.icon then
texture = val.icon
end
if spellName then if spellName then
self.cooldownSpellIds[spellName] = spellId self.cooldownSpellIds[spellName] = spellId
self.spellTextures[spellId] = texture self.spellTextures[spellId] = texture
@ -106,6 +110,7 @@ function Cooldowns:CreateFrame(unit)
spellCooldownFrame:SetFrameLevel(Gladdy.db.cooldownFrameLevel) spellCooldownFrame:SetFrameLevel(Gladdy.db.cooldownFrameLevel)
spellCooldownFrame.icons = {} spellCooldownFrame.icons = {}
button.spellCooldownFrame = spellCooldownFrame button.spellCooldownFrame = spellCooldownFrame
self.frames[unit] = spellCooldownFrame
end end
function Cooldowns:CreateIcon() -- returns iconFrame function Cooldowns:CreateIcon() -- returns iconFrame
@ -167,7 +172,15 @@ function Cooldowns:UpdateIcon(icon)
end end
function Cooldowns:IconsSetPoint(button) function Cooldowns:IconsSetPoint(button)
for i,icon in ipairs(button.spellCooldownFrame.icons) do local orderedIcons = {}
for _,icon in pairs(button.spellCooldownFrame.icons) do
tinsert(orderedIcons, icon)
end
tbl_sort(orderedIcons, function(a, b)
return Gladdy.db.cooldownCooldownsOrder[button.class][tostring(a.spellId)] < Gladdy.db.cooldownCooldownsOrder[button.class][tostring(b.spellId)]
end)
for i,icon in ipairs(orderedIcons) do
icon:SetParent(button.spellCooldownFrame) icon:SetParent(button.spellCooldownFrame)
icon:ClearAllPoints() icon:ClearAllPoints()
if (Gladdy.db.cooldownXGrowDirection == "LEFT") then if (Gladdy.db.cooldownXGrowDirection == "LEFT") then
@ -175,12 +188,12 @@ function Cooldowns:IconsSetPoint(button)
icon:SetPoint("LEFT", button.spellCooldownFrame, "LEFT", 0, 0) icon:SetPoint("LEFT", button.spellCooldownFrame, "LEFT", 0, 0)
elseif (mod(i-1,Gladdy.db.cooldownMaxIconsPerLine) == 0) then elseif (mod(i-1,Gladdy.db.cooldownMaxIconsPerLine) == 0) then
if (Gladdy.db.cooldownYGrowDirection == "DOWN") then if (Gladdy.db.cooldownYGrowDirection == "DOWN") then
icon:SetPoint("TOP", button.spellCooldownFrame.icons[i-Gladdy.db.cooldownMaxIconsPerLine], "BOTTOM", 0, -Gladdy.db.cooldownIconPadding) icon:SetPoint("TOP", orderedIcons[i-Gladdy.db.cooldownMaxIconsPerLine], "BOTTOM", 0, -Gladdy.db.cooldownIconPadding)
else else
icon:SetPoint("BOTTOM", button.spellCooldownFrame.icons[i-Gladdy.db.cooldownMaxIconsPerLine], "TOP", 0, Gladdy.db.cooldownIconPadding) icon:SetPoint("BOTTOM", orderedIcons[i-Gladdy.db.cooldownMaxIconsPerLine], "TOP", 0, Gladdy.db.cooldownIconPadding)
end end
else else
icon:SetPoint("RIGHT", button.spellCooldownFrame.icons[i-1], "LEFT", -Gladdy.db.cooldownIconPadding, 0) icon:SetPoint("RIGHT", orderedIcons[i-1], "LEFT", -Gladdy.db.cooldownIconPadding, 0)
end end
end end
if (Gladdy.db.cooldownXGrowDirection == "RIGHT") then if (Gladdy.db.cooldownXGrowDirection == "RIGHT") then
@ -188,12 +201,12 @@ function Cooldowns:IconsSetPoint(button)
icon:SetPoint("LEFT", button.spellCooldownFrame, "LEFT", 0, 0) icon:SetPoint("LEFT", button.spellCooldownFrame, "LEFT", 0, 0)
elseif (mod(i-1,Gladdy.db.cooldownMaxIconsPerLine) == 0) then elseif (mod(i-1,Gladdy.db.cooldownMaxIconsPerLine) == 0) then
if (Gladdy.db.cooldownYGrowDirection == "DOWN") then if (Gladdy.db.cooldownYGrowDirection == "DOWN") then
icon:SetPoint("TOP", button.spellCooldownFrame.icons[i-Gladdy.db.cooldownMaxIconsPerLine], "BOTTOM", 0, -Gladdy.db.cooldownIconPadding) icon:SetPoint("TOP", orderedIcons[i-Gladdy.db.cooldownMaxIconsPerLine], "BOTTOM", 0, -Gladdy.db.cooldownIconPadding)
else else
icon:SetPoint("BOTTOM", button.spellCooldownFrame.icons[i-Gladdy.db.cooldownMaxIconsPerLine], "TOP", 0, Gladdy.db.cooldownIconPadding) icon:SetPoint("BOTTOM", orderedIcons[i-Gladdy.db.cooldownMaxIconsPerLine], "TOP", 0, Gladdy.db.cooldownIconPadding)
end end
else else
icon:SetPoint("LEFT", button.spellCooldownFrame.icons[i-1], "RIGHT", Gladdy.db.cooldownIconPadding, 0) icon:SetPoint("LEFT", orderedIcons[i-1], "RIGHT", Gladdy.db.cooldownIconPadding, 0)
end end
end end
end end
@ -221,6 +234,15 @@ function Cooldowns:UpdateFrame(unit)
{"TOPLEFT", "TOPLEFT"}, {"TOPLEFT", "TOPLEFT"},
Gladdy.db.cooldownSize * Gladdy.db.cooldownWidthFactor, Gladdy.db.cooldownSize, 0, 0, "cooldown") Gladdy.db.cooldownSize * Gladdy.db.cooldownWidthFactor, Gladdy.db.cooldownSize, 0, 0, "cooldown")
end end
if (Gladdy.db.cooldownGroup) then
if (unit ~= "arena1") then
local previousUnit = "arena" .. string.gsub(unit, "arena", "") - 1
self.frames[unit]:ClearAllPoints()
self.frames[unit]:SetPoint("TOP", self.frames[previousUnit], "BOTTOM", 0, -Gladdy.db.cooldownIconPadding)
end
end
-- Update each cooldown icon -- Update each cooldown icon
for _,icon in pairs(button.spellCooldownFrame.icons) do for _,icon in pairs(button.spellCooldownFrame.icons) do
self:UpdateIcon(icon) self:UpdateIcon(icon)
@ -275,13 +297,15 @@ end
--------------------- ---------------------
function Cooldowns:Test(unit) function Cooldowns:Test(unit)
local button = Gladdy.buttons[unit] if Gladdy.frame.testing then
if Gladdy.db.cooldown then local button = Gladdy.buttons[unit]
button.spellCooldownFrame:Show() if Gladdy.db.cooldown then
else button.spellCooldownFrame:Show()
button.spellCooldownFrame:Hide() else
button.spellCooldownFrame:Hide()
end
self:UpdateTestCooldowns(unit)
end end
self:UpdateTestCooldowns(unit)
end end
function Cooldowns:UpdateTestCooldowns(unit) function Cooldowns:UpdateTestCooldowns(unit)
@ -455,6 +479,7 @@ function Cooldowns:AddCooldown(spellID, value, button)
for _,icon in pairs(button.spellCooldownFrame.icons) do for _,icon in pairs(button.spellCooldownFrame.icons) do
if (icon.spellId == spellId) then if (icon.spellId == spellId) then
sharedCD = true sharedCD = true
break
end end
end end
end end
@ -462,6 +487,7 @@ function Cooldowns:AddCooldown(spellID, value, button)
for _,icon in pairs(button.spellCooldownFrame.icons) do for _,icon in pairs(button.spellCooldownFrame.icons) do
if (icon and icon.spellId == spellID) then if (icon and icon.spellId == spellID) then
sharedCD = true sharedCD = true
break
end end
end end
if (not sharedCD) then if (not sharedCD) then
@ -493,7 +519,7 @@ function Cooldowns:UpdateCooldowns(button)
end end
end end
end end
for k, v in pairs(Gladdy:GetCooldownList()[button.race]) do for k, v in pairs(Gladdy:GetCooldownList()[race]) do
if Gladdy.db.cooldownCooldowns[tostring(k)] then if Gladdy.db.cooldownCooldowns[tostring(k)] then
if (type(v) ~= "table" or (type(v) == "table" and v.spec == nil)) then if (type(v) ~= "table" or (type(v) == "table" and v.spec == nil)) then
Cooldowns:AddCooldown(k, v, button) Cooldowns:AddCooldown(k, v, button)
@ -527,6 +553,7 @@ function Cooldowns:GetOptions()
childGroups = "tree", childGroups = "tree",
name = L["Frame"], name = L["Frame"],
order = 3, order = 3,
disabled = function() return not Gladdy.db.cooldown end,
args = { args = {
icon = { icon = {
type = "group", type = "group",
@ -774,11 +801,14 @@ function Cooldowns:GetOptions()
childGroups = "tree", childGroups = "tree",
name = L["Cooldowns"], name = L["Cooldowns"],
order = 4, order = 4,
disabled = function() return not Gladdy.db.cooldown end,
args = Cooldowns:GetCooldownOptions(), args = Cooldowns:GetCooldownOptions(),
}, },
} }
end end
function Cooldowns:GetCooldownOptions() function Cooldowns:GetCooldownOptions()
local group = {} local group = {}
@ -792,52 +822,163 @@ function Cooldowns:GetCooldownOptions()
iconCoords = CLASS_ICON_TCOORDS[class], iconCoords = CLASS_ICON_TCOORDS[class],
args = {} args = {}
} }
local o = 1 local tblLength = tableLength(Gladdy.db.cooldownCooldownsOrder[class])
for spellId,cooldown in pairs(Gladdy:GetCooldownList()[class]) do for spellId,cooldown in pairs(Gladdy:GetCooldownList()[class]) do
group[class].args[tostring(spellId)] = { group[class].args[tostring(spellId)] = {
type = "toggle", name = "",
name = select(1, GetSpellInfo(spellId)) .. (type(cooldown) == "table" and cooldown.spec and (" - " .. cooldown.spec) or ""), type = "group",
order = o, inline = true,
width = "full", order = Gladdy.db.cooldownCooldownsOrder[class][tostring(spellId)],
image = select(3, GetSpellInfo(spellId)), args = {
get = function() toggle = {
return Gladdy.db.cooldownCooldowns[tostring(spellId)] type = "toggle",
end, name = select(1, GetSpellInfo(spellId)) .. (type(cooldown) == "table" and cooldown.spec and (" - " .. cooldown.spec) or ""),
set = function(_, value) order = 1,
Gladdy.db.cooldownCooldowns[tostring(spellId)] = value width = 1.1,
Gladdy:UpdateFrame() image = select(3, GetSpellInfo(spellId)),
end get = function()
return Gladdy.db.cooldownCooldowns[tostring(spellId)]
end,
set = function(_, value)
Gladdy.db.cooldownCooldowns[tostring(spellId)] = value
for unit in pairs(Gladdy.buttons) do
Cooldowns:ResetUnit(unit)
Cooldowns:Test(unit)
end
Gladdy:UpdateFrame()
end
},
uparrow = {
type = "execute",
name = "",
order = 2,
width = 0.1,
image = "Interface\\Addons\\Gladdy\\Images\\uparrow",
imageWidth = 20,
imageHeight = 20,
func = function()
if (Gladdy.db.cooldownCooldownsOrder[class][tostring(spellId)] > 1) then
local current = Gladdy.db.cooldownCooldownsOrder[class][tostring(spellId)]
local next
for k,v in pairs(Gladdy.db.cooldownCooldownsOrder[class]) do
if v == current - 1 then
next = k
end
end
Gladdy.db.cooldownCooldownsOrder[class][tostring(spellId)] = Gladdy.db.cooldownCooldownsOrder[class][tostring(spellId)] - 1
Gladdy.db.cooldownCooldownsOrder[class][next] = Gladdy.db.cooldownCooldownsOrder[class][next] + 1
Gladdy.options.args["Cooldowns"].args.cooldowns.args[class].args[tostring(spellId)].order = Gladdy.db.cooldownCooldownsOrder[class][tostring(spellId)]
Gladdy.options.args["Cooldowns"].args.cooldowns.args[class].args[next].order = Gladdy.db.cooldownCooldownsOrder[class][next]
Gladdy:UpdateFrame()
end
end,
},
downarrow = {
type = "execute",
name = "",
order = 3,
width = 0.1,
image = "Interface\\Addons\\Gladdy\\Images\\downarrow",
imageWidth = 20,
imageHeight = 20,
func = function()
if (Gladdy.db.cooldownCooldownsOrder[class][tostring(spellId)] < tblLength) then
local current = Gladdy.db.cooldownCooldownsOrder[class][tostring(spellId)]
local next
for k,v in pairs(Gladdy.db.cooldownCooldownsOrder[class]) do
if v == current + 1 then
next = k
end
end
Gladdy.db.cooldownCooldownsOrder[class][tostring(spellId)] = Gladdy.db.cooldownCooldownsOrder[class][tostring(spellId)] + 1
Gladdy.db.cooldownCooldownsOrder[class][next] = Gladdy.db.cooldownCooldownsOrder[class][next] - 1
Gladdy.options.args["Cooldowns"].args.cooldowns.args[class].args[tostring(spellId)].order = Gladdy.db.cooldownCooldownsOrder[class][tostring(spellId)]
Gladdy.options.args["Cooldowns"].args.cooldowns.args[class].args[next].order = Gladdy.db.cooldownCooldownsOrder[class][next]
Gladdy:UpdateFrame()
end
end,
}
}
} }
o = o + 1
end end
p = p + i p = p + i
end end
for i,race in ipairs(Gladdy.RACES) do for i,race in ipairs(Gladdy.RACES) do
group[race] = {
type = "group",
name = L[race],
order = i + p,
icon = "Interface\\Glues\\CharacterCreate\\UI-CharacterCreate-Races",
iconCoords = RACE_ICON_TCOORDS[upper(race) .. "_FEMALE"],
args = {}
}
local o = 1
for spellId,cooldown in pairs(Gladdy:GetCooldownList()[race]) do for spellId,cooldown in pairs(Gladdy:GetCooldownList()[race]) do
group[race].args[tostring(spellId)] = { local tblLength = tableLength(Gladdy.db.cooldownCooldownsOrder[cooldown.class])
type = "toggle", local class = cooldown.class
name = select(1, GetSpellInfo(spellId)) .. (type(cooldown) == "table" and cooldown.spec and (" - " .. cooldown.spec) or ""), group[class].args[tostring(spellId)] = {
order = o, name = "",
width = "full", type = "group",
image = select(3, GetSpellInfo(spellId)), inline = true,
get = function() order = Gladdy.db.cooldownCooldownsOrder[class][tostring(spellId)],
return Gladdy.db.cooldownCooldowns[tostring(spellId)] args = {
end, toggle = {
set = function(_, value) type = "toggle",
Gladdy.db.cooldownCooldowns[tostring(spellId)] = value name = select(1, GetSpellInfo(spellId)) .. (type(cooldown) == "table" and cooldown.spec and (" - " .. cooldown.spec) or ""),
Gladdy:UpdateFrame() order = 1,
end width = 1.1,
image = select(3, GetSpellInfo(spellId)),
get = function()
return Gladdy.db.cooldownCooldowns[tostring(spellId)]
end,
set = function(_, value)
Gladdy.db.cooldownCooldowns[tostring(spellId)] = value
Gladdy:UpdateFrame()
end
},
uparrow = {
type = "execute",
name = "",
order = 2,
width = 0.1,
image = "Interface\\Addons\\Gladdy\\Images\\uparrow",
imageWidth = 20,
imageHeight = 20,
func = function()
if (Gladdy.db.cooldownCooldownsOrder[class][tostring(spellId)] > 1) then
local current = Gladdy.db.cooldownCooldownsOrder[class][tostring(spellId)]
local next
for k,v in pairs(Gladdy.db.cooldownCooldownsOrder[class]) do
if v == current - 1 then
next = k
end
end
Gladdy.db.cooldownCooldownsOrder[class][tostring(spellId)] = Gladdy.db.cooldownCooldownsOrder[class][tostring(spellId)] - 1
Gladdy.db.cooldownCooldownsOrder[class][next] = Gladdy.db.cooldownCooldownsOrder[class][next] + 1
Gladdy.options.args["Cooldowns"].args.cooldowns.args[class].args[tostring(spellId)].order = Gladdy.db.cooldownCooldownsOrder[class][tostring(spellId)]
Gladdy.options.args["Cooldowns"].args.cooldowns.args[class].args[next].order = Gladdy.db.cooldownCooldownsOrder[class][next]
Gladdy:UpdateFrame()
end
end,
},
downarrow = {
type = "execute",
name = "",
order = 3,
width = 0.1,
image = "Interface\\Addons\\Gladdy\\Images\\downarrow",
imageWidth = 20,
imageHeight = 20,
func = function()
if (Gladdy.db.cooldownCooldownsOrder[class][tostring(spellId)] < tblLength) then
local current = Gladdy.db.cooldownCooldownsOrder[class][tostring(spellId)]
local next
for k,v in pairs(Gladdy.db.cooldownCooldownsOrder[class]) do
if v == current + 1 then
next = k
end
end
Gladdy.db.cooldownCooldownsOrder[class][tostring(spellId)] = Gladdy.db.cooldownCooldownsOrder[class][tostring(spellId)] + 1
Gladdy.db.cooldownCooldownsOrder[class][next] = Gladdy.db.cooldownCooldownsOrder[class][next] - 1
Gladdy.options.args["Cooldowns"].args.cooldowns.args[class].args[tostring(spellId)].order = Gladdy.db.cooldownCooldownsOrder[class][tostring(spellId)]
Gladdy.options.args["Cooldowns"].args.cooldowns.args[class].args[next].order = Gladdy.db.cooldownCooldownsOrder[class][next]
Gladdy:UpdateFrame()
end
end,
}
}
} }
o = o + 1
end end
end end
return group return group