Gladdy-TBC/Modules/Diminishings.lua

807 lines
30 KiB
Lua
Raw Normal View History

2021-05-17 16:49:54 +02:00
local select = select
local pairs,ipairs,tbl_sort,tinsert,format,rand = pairs,ipairs,table.sort,tinsert,format,math.random
2021-05-17 16:49:54 +02:00
local GetSpellInfo = GetSpellInfo
local CreateFrame = CreateFrame
local GetTime = GetTime
local Gladdy = LibStub("Gladdy")
local DRData = LibStub("DRData-1.0-BCC")
2021-05-17 16:49:54 +02:00
local L = Gladdy.L
local function defaultCategories()
local categories = {}
local indexList = {}
for k,v in pairs(DRData:GetSpells()) do
tinsert(indexList, {spellID = k, category = v})
end
tbl_sort(indexList, function(a, b) return a.spellID < b.spellID end)
2021-07-29 15:53:34 +02:00
for _,v in ipairs(indexList) do
2021-05-17 16:49:54 +02:00
if not categories[v.category] then
categories[v.category] = {
enabled = true,
forceIcon = false,
icon = select(3, GetSpellInfo(v.spellID))
}
end
end
return categories
end
local Diminishings = Gladdy:NewModule("Diminishings", nil, {
drFont = "DorisPP",
drFontColor = { r = 1, g = 1, b = 0, a = 1 },
drFontScale = 1,
2022-01-11 00:29:17 +01:00
drGrowDirection = "RIGHT",
2021-05-17 16:49:54 +02:00
drXOffset = 0,
drYOffset = 0,
drIconSize = 36,
drEnabled = true,
drBorderStyle = "Interface\\AddOns\\Gladdy\\Images\\Border_Gloss",
drBorderColor = { r = 1, g = 1, b = 1, a = 1 },
drDisableCircle = false,
drCooldownAlpha = 1,
drBorderColorsEnabled = true,
drIconPadding = 1,
drHalfColor = {r = 1, g = 1, b = 0, a = 1 },
drQuarterColor = {r = 1, g = 0.7, b = 0, a = 1 },
drNullColor = {r = 1, g = 0, b = 0, a = 1 },
2021-09-27 13:40:02 +02:00
drLevelTextEnabled = false,
drLevelTextFont = "DorisPP",
drLevelTextFontScale = 1,
2021-05-17 16:49:54 +02:00
drWidthFactor = 1,
2021-07-29 13:33:43 +02:00
drCategories = defaultCategories(),
2022-01-11 00:29:17 +01:00
drDuration = 18,
2021-05-17 16:49:54 +02:00
})
local function getDiminishColor(dr)
if dr == 0.5 then
return Gladdy.db.drHalfColor.r, Gladdy.db.drHalfColor.g, Gladdy.db.drHalfColor.b, Gladdy.db.drHalfColor.a
elseif dr == 0.25 then
return Gladdy.db.drQuarterColor.r, Gladdy.db.drQuarterColor.g, Gladdy.db.drQuarterColor.b, Gladdy.db.drQuarterColor.a
else
return Gladdy.db.drNullColor.r, Gladdy.db.drNullColor.g, Gladdy.db.drNullColor.b, Gladdy.db.drNullColor.a
end
end
2021-09-27 13:40:02 +02:00
local function getDiminishText(dr)
if dr == 0.5 then
return "½"
elseif dr == 0.25 then
return "¼"
else
return "ø"
end
end
2021-05-17 16:49:54 +02:00
function Diminishings:Initialize()
self.frames = {}
2021-05-18 16:39:43 +02:00
self:RegisterMessage("UNIT_DEATH", "ResetUnit", "AURA_FADE", "UNIT_DESTROYED")
2021-05-17 16:49:54 +02:00
end
function Diminishings:CreateFrame(unit)
local drFrame = CreateFrame("Frame", nil, Gladdy.buttons[unit])
2021-05-19 19:30:32 +02:00
drFrame:EnableMouse(false)
2021-09-24 15:51:24 +02:00
drFrame:SetMovable(true)
2021-05-17 16:49:54 +02:00
for i = 1, 16 do
local icon = CreateFrame("Frame", "GladdyDr" .. unit .. "Icon" .. i, drFrame)
icon:Hide()
icon:EnableMouse(false)
icon:SetFrameLevel(3)
icon.texture = icon:CreateTexture(nil, "BACKGROUND")
2021-05-19 14:57:29 +02:00
icon.texture:SetMask("Interface\\AddOns\\Gladdy\\Images\\mask")
2021-05-17 16:49:54 +02:00
icon.texture:SetAllPoints(icon)
icon:SetScript("OnUpdate", function(self, elapsed)
if (self.active) then
if (self.timeLeft <= 0) then
if (self.factor == drFrame.tracked[self.dr]) then
drFrame.tracked[self.dr] = 0
end
self.active = false
self.dr = nil
self.diminishing = 1.0
self.texture:SetTexture("")
self.text:SetText("")
self:Hide()
Diminishings:Positionate(unit)
else
self.timeLeft = self.timeLeft - elapsed
Gladdy:FormatTimer(self.text, self.timeLeft, self.timeLeft < 5)
2021-05-17 16:49:54 +02:00
end
end
end)
icon.cooldown = CreateFrame("Cooldown", nil, icon, "CooldownFrameTemplate")
icon.cooldown.noCooldownCount = true --Gladdy.db.trinketDisableOmniCC
icon.cooldown:SetHideCountdownNumbers(true)
icon.cooldown:SetFrameLevel(4)
icon.cooldownFrame = CreateFrame("Frame", nil, icon)
icon.cooldownFrame:ClearAllPoints()
icon.cooldownFrame:SetPoint("TOPLEFT", icon, "TOPLEFT")
icon.cooldownFrame:SetPoint("BOTTOMRIGHT", icon, "BOTTOMRIGHT")
icon.cooldownFrame:SetFrameLevel(5)
--icon.overlay = CreateFrame("Frame", nil, icon)
--icon.overlay:SetAllPoints(icon)
icon.border = icon.cooldownFrame:CreateTexture(nil, "OVERLAY")
icon.border:SetTexture("Interface\\AddOns\\Gladdy\\Images\\Border_rounded_blp")
icon.border:SetAllPoints(icon)
icon.text = icon.cooldownFrame:CreateFontString(nil, "OVERLAY")
icon.text:SetDrawLayer("OVERLAY")
2021-09-14 23:55:17 +02:00
icon.text:SetFont(Gladdy:SMFetch("font", "drFont"), 10, "OUTLINE")
2021-05-17 16:49:54 +02:00
icon.text:SetTextColor(Gladdy.db.drFontColor.r, Gladdy.db.drFontColor.g, Gladdy.db.drFontColor.b, Gladdy.db.drFontColor.a)
icon.text:SetShadowOffset(1, -1)
icon.text:SetShadowColor(0, 0, 0, 1)
icon.text:SetJustifyH("CENTER")
icon.text:SetPoint("CENTER")
icon.timeText = icon.cooldownFrame:CreateFontString(nil, "OVERLAY")
icon.timeText:SetDrawLayer("OVERLAY")
2021-09-14 23:55:17 +02:00
icon.timeText:SetFont(Gladdy:SMFetch("font", "drFont"), 10, "OUTLINE")
2021-05-17 16:49:54 +02:00
icon.timeText:SetTextColor(Gladdy.db.drFontColor.r, Gladdy.db.drFontColor.g, Gladdy.db.drFontColor.b, Gladdy.db.drFontColor.a)
icon.timeText:SetShadowOffset(1, -1)
icon.timeText:SetShadowColor(0, 0, 0, 1)
icon.timeText:SetJustifyH("CENTER")
icon.timeText:SetPoint("CENTER", icon, "CENTER", 0, 1)
2021-09-27 13:40:02 +02:00
icon.drLevelText = icon.cooldownFrame:CreateFontString(nil, "OVERLAY")
icon.drLevelText:SetDrawLayer("OVERLAY")
icon.drLevelText:SetFont(Gladdy:SMFetch("font", "drLevelTextFont"), 10, "OUTLINE")
icon.drLevelText:SetTextColor(getDiminishColor(1))
icon.drLevelText:SetShadowOffset(1, -1)
icon.drLevelText:SetShadowColor(0, 0, 0, 1)
icon.drLevelText:SetJustifyH("CENTER")
icon.drLevelText:SetPoint("BOTTOM", icon, "BOTTOM", 0, 0)
2021-05-17 16:49:54 +02:00
icon.diminishing = 1
drFrame["icon" .. i] = icon
end
drFrame.tracked = {}
Gladdy.buttons[unit].drFrame = drFrame
self.frames[unit] = drFrame
self:ResetUnit(unit)
end
function Diminishings:UpdateFrame(unit)
local drFrame = self.frames[unit]
if (not drFrame) then
return
end
if (Gladdy.db.drEnabled == false) then
drFrame:Hide()
return
else
drFrame:Show()
end
2022-01-11 00:29:17 +01:00
drFrame:SetWidth(Gladdy.db.drIconSize)
2021-05-17 16:49:54 +02:00
drFrame:SetHeight(Gladdy.db.drIconSize)
2022-01-11 00:29:17 +01:00
Gladdy:SetPosition(drFrame, unit, "drXOffset", "drYOffset", Diminishings:LegacySetPosition(drFrame, unit), Diminishings)
2021-09-24 15:51:24 +02:00
if (unit == "arena1") then
2022-01-11 00:29:17 +01:00
Gladdy:CreateMover(drFrame,"drXOffset", "drYOffset", L["Diminishings"],
Gladdy.db.drGrowDirection == "RIGHT" and {"TOPLEFT", "TOPLEFT"} or {"TOPRIGHT", "TOPRIGHT"},
Gladdy.db.drIconSize * Gladdy.db.drWidthFactor,
2021-09-25 14:03:57 +02:00
Gladdy.db.drIconSize,
2022-01-11 00:29:17 +01:00
0,
0)
2021-09-24 15:51:24 +02:00
end
2021-05-17 16:49:54 +02:00
for i = 1, 16 do
local icon = drFrame["icon" .. i]
icon:SetWidth(Gladdy.db.drIconSize * Gladdy.db.drWidthFactor)
icon:SetHeight(Gladdy.db.drIconSize)
2021-09-14 23:55:17 +02:00
icon.text:SetFont(Gladdy:SMFetch("font", "drFont"), (Gladdy.db.drIconSize/2 - 1) * Gladdy.db.drFontScale, "OUTLINE")
2021-05-17 16:49:54 +02:00
icon.text:SetTextColor(Gladdy.db.drFontColor.r, Gladdy.db.drFontColor.g, Gladdy.db.drFontColor.b, Gladdy.db.drFontColor.a)
2021-09-14 23:55:17 +02:00
icon.timeText:SetFont(Gladdy:SMFetch("font", "drFont"), (Gladdy.db.drIconSize/2 - 1) * Gladdy.db.drFontScale, "OUTLINE")
2021-05-17 16:49:54 +02:00
icon.timeText:SetTextColor(Gladdy.db.drFontColor.r, Gladdy.db.drFontColor.g, Gladdy.db.drFontColor.b, Gladdy.db.drFontColor.a)
2021-09-27 13:40:02 +02:00
icon.drLevelText:SetFont(Gladdy:SMFetch("font", "drLevelTextFont"), (Gladdy.db.drIconSize/2 - 1) * Gladdy.db.drLevelTextFontScale, "OUTLINE")
2021-05-17 16:49:54 +02:00
icon.cooldown:SetWidth(icon:GetWidth() - icon:GetWidth()/16)
icon.cooldown:SetHeight(icon:GetHeight() - icon:GetHeight()/16)
icon.cooldown:ClearAllPoints()
icon.cooldown:SetPoint("CENTER", icon, "CENTER")
if Gladdy.db.drDisableCircle then
icon.cooldown:SetAlpha(0)
else
icon.cooldown:SetAlpha(Gladdy.db.drCooldownAlpha)
end
if Gladdy.db.drBorderColorsEnabled then
icon.border:SetVertexColor(getDiminishColor(icon.diminishing))
else
icon.border:SetVertexColor(Gladdy.db.drBorderColor.r, Gladdy.db.drBorderColor.g, Gladdy.db.drBorderColor.b, Gladdy.db.drBorderColor.a)
end
2021-09-27 13:40:02 +02:00
if Gladdy.db.drLevelTextEnabled then
icon.drLevelText:Show()
else
icon.drLevelText:Hide()
end
2021-05-17 16:49:54 +02:00
icon:ClearAllPoints()
2022-01-11 00:29:17 +01:00
if (Gladdy.db.drGrowDirection == "LEFT") then
2021-05-17 16:49:54 +02:00
if (i == 1) then
2022-01-11 00:29:17 +01:00
icon:SetPoint("TOPRIGHT", drFrame, "TOPRIGHT")
2021-05-17 16:49:54 +02:00
else
icon:SetPoint("RIGHT", drFrame["icon" .. (i - 1)], "LEFT", -Gladdy.db.drIconPadding, 0)
end
else
if (i == 1) then
2022-01-11 00:29:17 +01:00
icon:SetPoint("TOPLEFT", drFrame, "TOPLEFT")
2021-05-17 16:49:54 +02:00
else
icon:SetPoint("LEFT", drFrame["icon" .. (i - 1)], "RIGHT", Gladdy.db.drIconPadding, 0)
end
end
if Gladdy.db.drBorderStyle == "Interface\\AddOns\\Gladdy\\Images\\Border_Gloss" then
icon.border:SetTexture("Interface\\AddOns\\Gladdy\\Images\\Border_rounded_blp")
else
icon.border:SetTexture(Gladdy.db.drBorderStyle)
end
2021-05-19 14:57:29 +02:00
--icon.texture:SetTexCoord(.1, .9, .1, .9)
--icon.texture:SetPoint("TOPLEFT", icon, "TOPLEFT", 2, -2)
--icon.texture:SetPoint("BOTTOMRIGHT", icon, "BOTTOMRIGHT", -2, 2)
2021-05-17 16:49:54 +02:00
end
end
function Diminishings:ResetUnit(unit)
local drFrame = self.frames[unit]
if (not drFrame) then
return
end
drFrame.tracked = {}
for i = 1, 16 do
local icon = drFrame["icon" .. i]
icon.active = false
icon.timeLeft = 0
icon.texture:SetTexture("")
icon.text:SetText("")
icon.timeText:SetText("")
icon:Hide()
end
end
2021-05-18 16:39:43 +02:00
function Diminishings:UNIT_DESTROYED(unit)
Diminishings:ResetUnit(unit)
end
2021-05-17 16:49:54 +02:00
function Diminishings:Test(unit)
if Gladdy.db.drEnabled then
local enabledCategories = {}
for cat,val in pairs(Gladdy.db.drCategories) do
if (val.enabled) then
tinsert(enabledCategories, {cat = cat , spellIDs = {}})
enabledCategories[cat] = #enabledCategories
end
end
for spellId,cat in pairs(DRData:GetSpells()) do
if enabledCategories[cat] then
tinsert(enabledCategories[enabledCategories[cat]].spellIDs, spellId)
end
end
--shuffle
for i = #enabledCategories, 2, -1 do
local j = rand(i)
enabledCategories[i], enabledCategories[j] = enabledCategories[j], enabledCategories[i]
end
--execute test
local index, amount = 0,0
for i=1, (#enabledCategories < 4 and #enabledCategories) or 4 do
amount = rand(1,3)
index = rand(1, #enabledCategories[i].spellIDs)
for _=1, amount do
self:AuraFade(unit, enabledCategories[i].spellIDs[index])
2021-05-17 16:49:54 +02:00
end
end
end
end
function Diminishings:AuraFade(unit, spellID)
local drFrame = self.frames[unit]
local drCat = DRData:GetSpellCategory(spellID)
if (not drFrame or not drCat) then
return
end
if not Gladdy.db.drCategories[drCat].enabled then
return
end
local lastIcon
for i = 1, 16 do
local icon = drFrame["icon" .. i]
if (icon.active and icon.dr and icon.dr == drCat) then
lastIcon = icon
break
elseif not icon.active and not lastIcon then
lastIcon = icon
lastIcon.diminishing = 1.0
end
end
if not lastIcon then return end
2021-05-17 16:49:54 +02:00
lastIcon.dr = drCat
2021-07-29 13:33:43 +02:00
lastIcon.timeLeft = Gladdy.db.drDuration
2021-05-17 16:49:54 +02:00
lastIcon.diminishing = DRData:NextDR(lastIcon.diminishing)
if Gladdy.db.drBorderColorsEnabled then
lastIcon.border:SetVertexColor(getDiminishColor(lastIcon.diminishing))
else
lastIcon.border:SetVertexColor(Gladdy.db.drBorderColor.r, Gladdy.db.drBorderColor.g, Gladdy.db.drBorderColor.b, Gladdy.db.drBorderColor.a)
end
2021-07-29 13:33:43 +02:00
lastIcon.cooldown:SetCooldown(GetTime(), Gladdy.db.drDuration)
2021-05-17 16:49:54 +02:00
if Gladdy.db.drCategories[drCat].forceIcon then
lastIcon.texture:SetTexture(Gladdy.db.drCategories[drCat].icon)
else
lastIcon.texture:SetTexture(select(3, GetSpellInfo(spellID)))
end
lastIcon.active = true
self:Positionate(unit)
lastIcon:Show()
2022-01-11 00:02:21 +01:00
lastIcon.drLevelText:SetText(getDiminishText(lastIcon.diminishing))
lastIcon.drLevelText:SetTextColor(getDiminishColor(lastIcon.diminishing))
2021-05-17 16:49:54 +02:00
end
function Diminishings:Positionate(unit)
local drFrame = self.frames[unit]
if (not drFrame) then
return
end
local lastIcon
for i = 1, 16 do
local icon = drFrame["icon" .. i]
if (icon.active) then
icon:ClearAllPoints()
2022-01-11 00:29:17 +01:00
if (Gladdy.db.newLayout and Gladdy.db.drGrowDirection == "LEFT"
or not Gladdy.db.newLayout and Gladdy.db.drCooldownPos == "LEFT") then
2021-05-17 16:49:54 +02:00
if (not lastIcon) then
icon:SetPoint("TOPRIGHT")
else
icon:SetPoint("RIGHT", lastIcon, "LEFT", -Gladdy.db.drIconPadding, 0)
end
2022-01-11 00:29:17 +01:00
elseif (Gladdy.db.newLayout and Gladdy.db.drGrowDirection == "RIGHT"
or not Gladdy.db.newLayout and Gladdy.db.drCooldownPos == "RIGHT") then
2021-05-17 16:49:54 +02:00
if (not lastIcon) then
icon:SetPoint("TOPLEFT")
else
icon:SetPoint("LEFT", lastIcon, "RIGHT", Gladdy.db.drIconPadding, 0)
end
end
lastIcon = icon
end
end
end
function Diminishings:GetOptions()
return {
headerDiminishings = {
type = "header",
name = L["Diminishings"],
order = 2,
},
drEnabled = Gladdy:option({
type = "toggle",
2021-05-24 12:41:21 +02:00
name = L["Enabled"],
2021-05-17 16:49:54 +02:00
desc = L["Enabled DR module"],
order = 3,
}),
2021-07-29 13:33:43 +02:00
drDuration = Gladdy:option({
type = "range",
name = L["DR Duration"],
desc = L["Change the DR Duration in seconds (DR is dynamic between 15-20s)"],
order = 4,
min = 15,
max = 20,
step = .1,
}),
2021-05-17 16:49:54 +02:00
group = {
type = "group",
childGroups = "tree",
2021-05-24 12:41:21 +02:00
name = L["Frame"],
2021-07-29 13:33:43 +02:00
order = 5,
2021-05-17 16:49:54 +02:00
args = {
icon = {
type = "group",
name = L["Icon"],
order = 1,
args = {
headerDiminishingsFrame = {
type = "header",
name = L["Icon"],
order = 4,
},
drIconSize = Gladdy:option({
type = "range",
name = L["Icon Size"],
desc = L["Size of the DR Icons"],
order = 5,
min = 5,
2021-06-17 16:40:19 +02:00
max = 80,
2021-05-17 16:49:54 +02:00
step = 1,
2021-06-15 09:06:50 +02:00
width = "full",
2021-05-17 16:49:54 +02:00
}),
drWidthFactor = Gladdy:option({
type = "range",
name = L["Icon Width Factor"],
desc = L["Stretches the icon"],
order = 6,
min = 0.5,
max = 2,
step = 0.05,
2021-06-15 09:06:50 +02:00
width = "full",
2021-05-17 16:49:54 +02:00
}),
drIconPadding = Gladdy:option({
type = "range",
name = L["Icon Padding"],
desc = L["Space between Icons"],
order = 7,
min = 0,
max = 10,
step = 0.1,
2021-06-15 09:06:50 +02:00
width = "full",
2021-05-17 16:49:54 +02:00
}),
},
},
cooldown = {
type = "group",
name = L["Cooldown"],
order = 2,
args = {
headerDiminishingsFrame = {
type = "header",
name = L["Cooldown"],
order = 4,
},
drDisableCircle = Gladdy:option({
type = "toggle",
name = L["No Cooldown Circle"],
order = 8,
2021-05-24 12:41:21 +02:00
width = "full",
2021-05-17 16:49:54 +02:00
}),
drCooldownAlpha = Gladdy:option({
type = "range",
name = L["Cooldown circle alpha"],
min = 0,
max = 1,
step = 0.1,
order = 9,
2021-06-15 09:06:50 +02:00
width = "full",
2021-05-17 16:49:54 +02:00
}),
2021-09-18 15:00:34 +02:00
drCooldownNumberAlpha = {
type = "range",
name = L["Cooldown number alpha"],
min = 0,
max = 1,
step = 0.1,
order = 10,
width = "full",
set = function(info, value)
Gladdy.db.drFontColor.a = value
Gladdy:UpdateFrame()
end,
get = function(info)
return Gladdy.db.drFontColor.a
end,
},
2021-05-17 16:49:54 +02:00
},
},
font = {
type = "group",
name = L["Font"],
order = 3,
args = {
headerFont = {
type = "header",
name = L["Font"],
order = 10,
},
drFont = Gladdy:option({
type = "select",
name = L["Font"],
desc = L["Font of the cooldown"],
order = 11,
dialogControl = "LSM30_Font",
values = AceGUIWidgetLSMlists.font,
}),
drFontColor = Gladdy:colorOption({
type = "color",
name = L["Font color"],
desc = L["Color of the text"],
order = 13,
hasAlpha = true,
}),
drFontScale = Gladdy:option({
type = "range",
name = L["Font scale"],
desc = L["Scale of the text"],
order = 12,
min = 0.1,
max = 2,
step = 0.1,
2021-06-15 09:06:50 +02:00
width = "full",
2021-05-17 16:49:54 +02:00
}),
}
},
position = {
type = "group",
name = L["Position"],
order = 4,
args = {
headerPosition = {
type = "header",
name = L["Position"],
order = 20,
},
2022-01-11 00:29:17 +01:00
drGrowDirection = Gladdy:option({
2021-05-17 16:49:54 +02:00
type = "select",
2022-01-11 00:29:17 +01:00
name = L["DR Grow Direction"],
desc = L["Grow Direction of the dr icons"],
2021-05-17 16:49:54 +02:00
order = 21,
values = {
["LEFT"] = L["Left"],
["RIGHT"] = L["Right"],
},
}),
drXOffset = Gladdy:option({
type = "range",
name = L["Horizontal offset"],
order = 23,
min = -400,
max = 400,
step = 0.1,
2021-06-15 09:06:50 +02:00
width = "full",
2021-05-17 16:49:54 +02:00
}),
drYOffset = Gladdy:option({
type = "range",
name = L["Vertical offset"],
order = 24,
min = -400,
max = 400,
step = 0.1,
2021-06-15 09:06:50 +02:00
width = "full",
2021-05-17 16:49:54 +02:00
}),
},
},
2021-09-27 13:40:02 +02:00
level = {
type = "group",
name = L["Level Text"],
order = 5,
args = {
headerBorder = {
type = "header",
name = L["DR Level"],
order = 1,
},
drLevelTextEnabled = Gladdy:option({
type = "toggle",
name = L["DR Level Text Enabled"],
desc = L["Shows the current DR Level on the DR icon."],
order = 2,
width = "full",
}),
drLevelTextFont = Gladdy:option({
type = "select",
name = L["Font"],
desc = L["Font of the cooldown"],
order = 3,
dialogControl = "LSM30_Font",
values = AceGUIWidgetLSMlists.font,
}),
drLevelTextFontScale = Gladdy:option({
type = "range",
name = L["Font scale"],
desc = L["Scale of the text"],
order = 4,
min = 0.1,
max = 2,
step = 0.1,
width = "full",
}),
},
},
2021-05-17 16:49:54 +02:00
border = {
type = "group",
name = L["Border"],
2021-09-27 13:40:02 +02:00
order = 6,
2021-05-17 16:49:54 +02:00
args = {
headerBorder = {
type = "header",
name = L["Border"],
order = 30,
},
drBorderStyle = Gladdy:option({
type = "select",
name = L["Border style"],
order = 31,
values = Gladdy:GetIconStyles()
}),
drBorderColor = Gladdy:colorOption({
type = "color",
name = L["Border color"],
desc = L["Color of the border"],
order = 32,
hasAlpha = true,
}),
headerBorderColors = {
type = "header",
name = L["DR Border Colors"],
order = 40,
},
drBorderColorsEnabled = Gladdy:option({
type = "toggle",
name = L["Dr Border Colors Enabled"],
desc = L["Colors borders of DRs in respective DR-color below"],
order = 41,
width = "full",
}),
drHalfColor = Gladdy:colorOption({
type = "color",
name = L["Half"],
desc = L["Color of the border"],
order = 42,
hasAlpha = true,
}),
drQuarterColor = Gladdy:colorOption({
type = "color",
name = L["Quarter"],
desc = L["Color of the border"],
order = 43,
hasAlpha = true,
}),
drNullColor = Gladdy:colorOption({
type = "color",
name = L["Immune"],
desc = L["Color of the border"],
order = 44,
hasAlpha = true,
}),
}
},
},
},
categories = {
type = "group",
name = L["Categories"],
order = 6,
args = Diminishings:CategoryOptions(),
},
}
end
function Diminishings:CategoryOptions()
local categories = {
checkAll = {
order = 1,
width = "0.7",
name = L["Check All"],
type = "execute",
func = function()
for k,_ in pairs(defaultCategories()) do
Gladdy.db.drCategories[k].enabled = true
end
end,
},
uncheckAll = {
order = 2,
width = "0.7",
name = L["Uncheck All"],
type = "execute",
func = function()
for k,_ in pairs(defaultCategories()) do
Gladdy.db.drCategories[k].enabled = false
end
end,
},
}
2021-05-17 16:49:54 +02:00
local indexList = {}
2021-07-29 15:53:34 +02:00
for k,_ in pairs(DRData:GetCategories()) do
2021-05-17 16:49:54 +02:00
tinsert(indexList, k)
end
tbl_sort(indexList)
2021-07-29 15:53:34 +02:00
for i,k in ipairs(indexList) do
2021-05-17 16:49:54 +02:00
categories[k] = {
type = "group",
2021-09-15 00:29:12 +02:00
name = L[DRData:GetCategoryName(k)],
2021-05-17 16:49:54 +02:00
order = i,
icon = Gladdy.db.drCategories[k].icon,
args = {
enabled = {
type = "toggle",
name = L["Enabled"],
order = 1,
2021-07-29 15:53:34 +02:00
get = function()
2021-05-17 16:49:54 +02:00
return Gladdy.db.drCategories[k].enabled
end,
2021-07-29 15:53:34 +02:00
set = function(_, value)
2021-05-17 16:49:54 +02:00
Gladdy.db.drCategories[k].enabled = value
end,
},
forceIcon = {
type = "toggle",
name = L["Force Icon"],
order = 2,
2021-07-29 15:53:34 +02:00
get = function()
2021-05-17 16:49:54 +02:00
return Gladdy.db.drCategories[k].forceIcon
end,
2021-07-29 15:53:34 +02:00
set = function(_, value)
2021-05-17 16:49:54 +02:00
Gladdy.db.drCategories[k].forceIcon = value
end,
},
icon = {
type = "select",
name = L["Icon"],
desc = L["Icon of the DR"],
order = 4,
values = Diminishings:GetDRIcons(k),
2021-07-29 15:53:34 +02:00
get = function()
2021-05-17 16:49:54 +02:00
return Gladdy.db.drCategories[k].icon
end,
2021-07-29 15:53:34 +02:00
set = function(_, value)
2021-05-17 16:49:54 +02:00
Gladdy.db.drCategories[k].icon = value
Gladdy.options.args.Diminishings.args.categories.args[k].icon = value
end,
}
}
}
end
return categories
end
function Diminishings:GetDRIcons(category)
local icons = {}
for k,v in pairs(DRData:GetSpells()) do
if v == category then
icons[select(3, GetSpellInfo(k))] = format("|T%s:20|t %s", select(3, GetSpellInfo(k)), select(1, GetSpellInfo(k)))
end
end
return icons
end
2022-01-11 00:29:17 +01:00
---------------------------
-- LAGACY HANDLER
---------------------------
function Diminishings:LegacySetPosition(drFrame, unit)
if Gladdy.db.newLayout then
return Gladdy.db.newLayout
end
drFrame:ClearAllPoints()
local horizontalMargin = (Gladdy.db.highlightInset and 0 or Gladdy.db.highlightBorderSize) + Gladdy.db.padding
if (Gladdy.db.drCooldownPos == "LEFT") then
Gladdy.db.drGrowDirection = "LEFT"
local anchor = Gladdy:GetAnchor(unit, "LEFT")
if anchor == Gladdy.buttons[unit].healthBar then
drFrame:SetPoint("RIGHT", anchor, "LEFT", -horizontalMargin + Gladdy.db.drXOffset, Gladdy.db.drYOffset)
else
drFrame:SetPoint("RIGHT", anchor, "LEFT", -Gladdy.db.padding + Gladdy.db.drXOffset, Gladdy.db.drYOffset)
end
end
if (Gladdy.db.drCooldownPos == "RIGHT") then
Gladdy.db.drGrowDirection = "RIGHT"
local anchor = Gladdy:GetAnchor(unit, "RIGHT")
if anchor == Gladdy.buttons[unit].healthBar then
drFrame:SetPoint("LEFT", anchor, "RIGHT", horizontalMargin + Gladdy.db.drXOffset, Gladdy.db.drYOffset)
else
drFrame:SetPoint("LEFT", anchor, "RIGHT", Gladdy.db.padding + Gladdy.db.drXOffset, Gladdy.db.drYOffset)
end
end
return Gladdy.db.newLayout
end