init v1.0.3-Beta

This commit is contained in:
Sumsebrum
2021-05-17 16:49:54 +02:00
commit 07b87b2c12
138 changed files with 31713 additions and 0 deletions

282
Modules/Announcements.lua Normal file
View File

@ -0,0 +1,282 @@
local pairs = pairs
local floor = math.floor
local GetSpellInfo = GetSpellInfo
local RAID_CLASS_COLORS = RAID_CLASS_COLORS
local GetTime = GetTime
local SendChatMessage = SendChatMessage
local RaidNotice_AddMessage = RaidNotice_AddMessage
local RaidBossEmoteFrame = RaidBossEmoteFrame
local IsAddOnLoaded = IsAddOnLoaded
local IsInGroup = IsInGroup
local LE_PARTY_CATEGORY_HOME = LE_PARTY_CATEGORY_HOME
local LE_PARTY_CATEGORY_INSTANCE = LE_PARTY_CATEGORY_INSTANCE
local CombatText_AddMessage = CombatText_AddMessage
local UnitName = UnitName
local Gladdy = LibStub("Gladdy")
local L = Gladdy.L
local Announcements = Gladdy:NewModule("Announcements", nil, {
announcements = {
drinks = true,
resurrections = true,
enemy = false,
spec = false,
health = false,
healthThreshold = 20,
trinketUsed = true,
trinketReady = false,
dest = "self",
},
})
function Announcements:Initialize()
self.enemy = {}
self.throttled = {}
self.DRINK_AURA = GetSpellInfo(46755)
self.RES_SPELLS = {
[GetSpellInfo(20770)] = true,
[GetSpellInfo(20773)] = true,
[GetSpellInfo(20777)] = true,
}
self:RegisterMessage("CAST_START")
self:RegisterMessage("ENEMY_SPOTTED")
self:RegisterMessage("UNIT_SPEC")
self:RegisterMessage("UNIT_HEALTH")
self:RegisterMessage("TRINKET_USED")
self:RegisterMessage("TRINKET_READY")
end
function Announcements:Reset()
self.enemy = {}
self.throttled = {}
end
function Announcements:Test(unit)
local button = Gladdy.buttons[unit]
if (not button) then
return
end
if (unit == "arena1") then
self:UNIT_SPEC(unit, button.testSpec)
elseif (unit == "arena2") then
self:CheckDrink(unit, self.DRINK_AURA)
elseif (unit == "arena3") then
self:UNIT_HEALTH(unit, button.health, button.healthMax)
self:ENEMY_SPOTTED(unit)
end
end
function Announcements:CAST_START(unit, spell)
local button = Gladdy.buttons[unit]
if (not button or not Gladdy.db.announcements.resurrections) then
return
end
if (self.RES_SPELLS[spell]) then
self:Send(L["RESURRECTING: %s (%s)"]:format(button.name, button.classLoc), 3, RAID_CLASS_COLORS[button.class])
end
end
function Announcements:ENEMY_SPOTTED(unit)
local button = Gladdy.buttons[unit]
if (not button or not Gladdy.db.announcements.enemy) then
return
end
if (not self.enemy[unit]) then
if button.name == "Unknown" then
button.name = UnitName(unit)
end
self:Send("ENEMY SPOTTED:" .. ("%s (%s)"):format(button.name, button.classLoc), 0, RAID_CLASS_COLORS[button.class])
self.enemy[unit] = true
end
end
function Announcements:UNIT_SPEC(unit, spec)
local button = Gladdy.buttons[unit]
if (not button or not Gladdy.db.announcements.spec) then
return
end
if button.name == "Unknown" then
button.name = UnitName(unit)
end
self:Send(L["SPEC DETECTED: %s - %s (%s)"]:format(button.name, spec, button.classLoc), 0, RAID_CLASS_COLORS[button.class])
end
function Announcements:UNIT_HEALTH(unit, health, healthMax)
local button = Gladdy.buttons[unit]
if (not button or not Gladdy.db.announcements.health) then
return
end
local healthPercent = floor(health * 100 / healthMax)
if (healthPercent < Gladdy.db.announcements.healthThreshold) then
self:Send(L["LOW HEALTH: %s (%s)"]:format(button.name, button.classLoc), 10, RAID_CLASS_COLORS[button.class])
end
end
function Announcements:TRINKET_USED(unit)
local button = Gladdy.buttons[unit]
if (not button or not Gladdy.db.announcements.trinketUsed) then
return
end
self:Send(L["TRINKET USED: %s (%s)"]:format(button.name, button.classLoc), 0, RAID_CLASS_COLORS[button.class])
end
function Announcements:TRINKET_READY(unit)
local button = Gladdy.buttons[unit]
if (not button or not Gladdy.db.announcements.trinketReady) then
return
end
self:Send(L["TRINKET READY: %s (%s)"]:format(button.name, button.classLoc), 3, RAID_CLASS_COLORS[button.class])
end
function Announcements:CheckDrink(unit, aura)
local button = Gladdy.buttons[unit]
if (not button or not Gladdy.db.announcements.drinks) then
return
end
if (aura == self.DRINK_AURA) then
self:Send(L["DRINKING: %s (%s)"]:format(button.name, button.classLoc), 3, RAID_CLASS_COLORS[button.class])
end
end
function Announcements:Send(msg, throttle, color)
if (throttle and throttle > 0) then
if (not self.throttled[msg]) then
self.throttled[msg] = GetTime() + throttle
elseif (self.throttled[msg] < GetTime()) then
self.throttled[msg] = nil
else
return
end
end
local dest = Gladdy.db.announcements.dest
color = color or { r = 0, g = 1, b = 0 }
if (dest == "self") then
Gladdy:Print(msg)
elseif (dest == "party" and IsInGroup(LE_PARTY_CATEGORY_HOME)) then --(GetNumSubgroupMembers() > 0 or GetNumGroupMembers() > 0)) then
SendChatMessage(msg, "PARTY")
elseif dest == "party" and IsInGroup(LE_PARTY_CATEGORY_INSTANCE) then
SendChatMessage(msg, "INSTANCE_CHAT")
elseif (dest == "rw") then
RaidNotice_AddMessage(RaidBossEmoteFrame, msg, color)
elseif (dest == "fct" and IsAddOnLoaded("Blizzard_CombatText")) then
CombatText_AddMessage(msg, nil, color.r, color.g, color.b, "crit", 1)
--[[elseif (dest == "msbt" and IsAddOnLoaded("MikScrollingBattleText")) then
MikSBT.DisplayMessage(msg, MikSBT.DISPLAYTYPE_NOTIFICATION, true, color.r * 255, color.g * 255, color.b * 255)
elseif (dest == "sct" and IsAddOnLoaded("sct")) then
SCT:DisplayText(msg, color, true, "event", 1)
elseif (dest == "parrot" and IsAddOnLoaded("parrot")) then
Parrot:ShowMessage(msg, "Notification", true, color.r, color.g, color.b)--]]
end
end
local function option(params)
local defaults = {
get = function(info)
local key = info.arg or info[#info]
return Gladdy.dbi.profile.announcements[key]
end,
set = function(info, value)
local key = info.arg or info[#info]
Gladdy.dbi.profile.announcements[key] = value
end,
}
for k, v in pairs(params) do
defaults[k] = v
end
return defaults
end
function Announcements:GetOptions()
local destValues = {
["self"] = L["Self"],
["party"] = L["Party"],
["rw"] = L["Raid Warning"],
["fct"] = L["Blizzard's Floating Combat Text"],
--["msbt"] = L["MikScrollingBattleText"],
--["sct"] = L["Scrolling Combat Text"],
--["parrot"] = L["Parrot"],
}
return {
headerAnnouncements = {
type = "header",
name = L["Announcements"],
order = 2,
},
trinketUsed = option({
type = "toggle",
name = L["Trinket used"],
desc = L["Announce when an enemy's trinket is used"],
order = 3,
}),
trinketReady = option({
type = "toggle",
name = L["Trinket ready"],
desc = L["Announce when an enemy's trinket is ready again"],
order = 4,
}),
drinks = option({
type = "toggle",
name = L["Drinking"],
desc = L["Announces when enemies sit down to drink"],
order = 5,
}),
resurrections = option({
type = "toggle",
name = L["Resurrection"],
desc = L["Announces when an enemy tries to resurrect a teammate"],
order = 6,
}),
enemy = option({
type = "toggle",
name = L["New enemies"],
desc = L["Announces when new enemies are discovered"],
order = 7,
}),
spec = option({
type = "toggle",
name = L["Spec Detection"],
desc = L["Announces when the spec of an enemy was detected"],
order = 8,
}),
health = option({
type = "toggle",
name = L["Low health"],
desc = L["Announces when an enemy drops below a certain health threshold"],
order = 9,
}),
healthThreshold = option({
type = "range",
name = L["Low health threshold"],
desc = L["Choose how low an enemy must be before low health is announced"],
order = 10,
min = 1,
max = 100,
step = 1,
disabled = function()
return not Gladdy.dbi.profile.announcements.health
end,
}),
dest = option({
type = "select",
name = L["Destination"],
desc = L["Choose how your announcements are displayed"],
order = 11,
values = destValues,
}),
}
end

180
Modules/ArenaCountDown.lua Normal file
View File

@ -0,0 +1,180 @@
local select, floor, str_len, tostring, str_sub, str_find = select, math.floor, string.len, tostring, string.sub, string.find
local IsInInstance = IsInInstance
local Gladdy = LibStub("Gladdy")
local L = Gladdy.L
local ACDFrame = Gladdy:NewModule("Countdown", nil, {
countdown = true,
arenaCountdownSize = 256
})
function ACDFrame:Initialize()
self.hidden = false
self.countdown = -1
self.texturePath = "Interface\\AddOns\\Gladdy\\Images\\Countdown\\";
ACDFrame:RegisterEvent("CHAT_MSG_BG_SYSTEM_NEUTRAL")
ACDFrame:RegisterEvent("PLAYER_ENTERING_WORLD")
end
function ACDFrame:OnEvent(event, ...)
-- functions created in "object:method"-style have an implicit first parameter of "self", which points to object
self[event](self, ...) -- route event parameters to LoseControl:event methods
end
ACDFrame:SetScript("OnEvent", ACDFrame.OnEvent)
local ACDNumFrame = CreateFrame("Frame", "ACDNumFrame", UIParent)
ACDNumFrame:SetHeight(256)
ACDNumFrame:SetWidth(256)
ACDNumFrame:SetPoint("CENTER", 0, 128)
ACDNumFrame:Show()
local ACDNumTens = ACDNumFrame:CreateTexture("ACDNumTens", "HIGH")
ACDNumTens:SetWidth(256)
ACDNumTens:SetHeight(128)
ACDNumTens:SetPoint("CENTER", ACDNumFrame, "CENTER", -48, 0)
local ACDNumOnes = ACDNumFrame:CreateTexture("ACDNumOnes", "HIGH")
ACDNumOnes:SetWidth(256)
ACDNumOnes:SetHeight(128)
ACDNumOnes:SetPoint("CENTER", ACDNumFrame, "CENTER", 48, 0)
local ACDNumOne = ACDNumFrame:CreateTexture("ACDNumOne", "HIGH")
ACDNumOne:SetWidth(256)
ACDNumOne:SetHeight(128)
ACDNumOne:SetPoint("CENTER", ACDNumFrame, "CENTER", 0, 0)
function ACDFrame:PLAYER_ENTERING_WORLD()
local instanceType = select(2, IsInInstance())
if (( instanceType == "arena" )) then
ACDFrame:SetScript("OnUpdate", function(self, elapse)
if (self.countdown > 0 and Gladdy.db.countdown) then
self.hidden = false;
if ((floor(self.countdown) ~= floor(self.countdown - elapse)) and (floor(self.countdown - elapse) >= 0)) then
local str = tostring(floor(self.countdown - elapse));
if (floor(self.countdown - elapse) == 0) then
ACDNumTens:Hide();
ACDNumOnes:Hide();
ACDNumOne:Hide();
elseif (str_len(str) == 2) then
-- Display has 2 digits
ACDNumOne:Hide();
ACDNumTens:Show();
ACDNumOnes:Show();
ACDNumTens:SetTexture(self.texturePath .. str_sub(str, 0, 1));
ACDNumOnes:SetTexture(self.texturePath .. str_sub(str, 2, 2));
ACDNumFrame:SetScale(0.7)
elseif (str_len(str) == 1) then
-- Display has 1 digit
ACDNumOne:Show();
ACDNumOne:SetTexture(self.texturePath .. str_sub(str, 0, 1));
ACDNumOnes:Hide();
ACDNumTens:Hide();
ACDNumFrame:SetScale(1.0)
end
end
self.countdown = self.countdown - elapse;
else
self.hidden = true;
ACDNumTens:Hide();
ACDNumOnes:Hide();
ACDNumOne:Hide();
end
end)
end
end
function ACDFrame:CHAT_MSG_BG_SYSTEM_NEUTRAL(msg)
if (str_find(msg, "L'ar\195\168ne ouvre ses portes dans 60 secondes !")) then
self.countdown = 61
return
end
if (str_find(msg, "L'ar\195\168ne ouvre ses portes dans 30 secondes !")) then
self.countdown = 31
return
end
if (str_find(msg, "L'ar\195\168ne ouvre ses portes dans 15 secondes !")) then
self.countdown = 16
return
end
if (str_find(msg, "L'ar\195\168ne ouvre ses portes dans 10 secondes !")) then
self.countdown = 11
return
end
if (str_find(msg, "One minute until the Arena battle begins!")) then
self.countdown = 61
return
end
if (str_find(msg, "Thirty seconds until the Arena battle begins!")) then
self.countdown = 31
return
end
if (str_find(msg, "Fifteen seconds until the Arena battle begins!")) then
self.countdown = 16
return
end
if (str_find(msg, "Ten seconds until the Arena battle begins!")) then
self.countdown = 10
return
end
if (str_find(msg, "The Arena battle has begun!")) then
ACDFrame:SetScript("OnUpdate", nil)
return
end
end
function ACDFrame:UpdateFrame()
ACDNumFrame:SetHeight(Gladdy.db.arenaCountdownSize)
ACDNumFrame:SetWidth(Gladdy.db.arenaCountdownSize)
ACDNumFrame:SetPoint("CENTER", 0, 128)
ACDNumTens:SetWidth(Gladdy.db.arenaCountdownSize)
ACDNumTens:SetHeight(Gladdy.db.arenaCountdownSize/2)
ACDNumTens:SetPoint("CENTER", ACDNumFrame, "CENTER", -(Gladdy.db.arenaCountdownSize/8 + Gladdy.db.arenaCountdownSize/8/2), 0)
ACDNumOnes:SetWidth(Gladdy.db.arenaCountdownSize)
ACDNumOnes:SetHeight(Gladdy.db.arenaCountdownSize/2)
ACDNumOnes:SetPoint("CENTER", ACDNumFrame, "CENTER", (Gladdy.db.arenaCountdownSize/8 + Gladdy.db.arenaCountdownSize/8/2), 0)
ACDNumOne:SetWidth(Gladdy.db.arenaCountdownSize)
ACDNumOne:SetHeight(Gladdy.db.arenaCountdownSize/2)
ACDNumOne:SetPoint("CENTER", ACDNumFrame, "CENTER", 0, 0)
end
function ACDFrame:Test()
self.countdown = 30
end
function ACDFrame:Reset()
self.countdown = 0
end
function ACDFrame:GetOptions()
return {
headerArenaCountdown = {
type = "header",
name = L["Arena Countdown"],
order = 2,
},
countdown = Gladdy:option({
type = "toggle",
name = L["Turn on/off"],
desc = L["Turns countdown before the start of an arena match on/off."],
order = 3,
width = "full",
}),
arenaCountdownSize = Gladdy:option({
type = "range",
name = L["Size"],
order = 4,
min = 64,
max = 512,
step = 16,
}),
}
end

402
Modules/Auras.lua Normal file
View File

@ -0,0 +1,402 @@
local pairs, ipairs, select, tinsert, tbl_sort = pairs, ipairs, select, tinsert, table.sort
local GetSpellInfo = GetSpellInfo
local CreateFrame, GetTime = CreateFrame, GetTime
local AURA_TYPE_DEBUFF, AURA_TYPE_BUFF = AURA_TYPE_DEBUFF, AURA_TYPE_BUFF
local Gladdy = LibStub("Gladdy")
local L = Gladdy.L
local function defaultSpells(auraType)
local spells = {}
for k,v in pairs(Gladdy:GetImportantAuras()) do
if not auraType or auraType == v.track then
spells[k] = {}
spells[k].enabled = true
spells[k].priority = v.priority
end
end
return spells
end
local Auras = Gladdy:NewModule("Auras", nil, {
auraFont = "DorisPP",
auraFontSizeScale = 1,
auraFontColor = { r = 1, g = 1, b = 0, a = 1 },
auraBorderStyle = "Interface\\AddOns\\Gladdy\\Images\\Border_rounded_blp",
auraBuffBorderColor = { r = 1, g = 0, b = 0, a = 1 },
auraDebuffBorderColor = { r = 0, g = 1, b = 0, a = 1 },
auraDisableCircle = false,
auraCooldownAlpha = 1,
auraListDefault = defaultSpells()
})
function Auras:Initialize()
self.frames = {}
self.auras = Gladdy:GetImportantAuras()
self:RegisterMessage("JOINED_ARENA")
self:RegisterMessage("UNIT_DEATH")
self:RegisterMessage("AURA_GAIN")
self:RegisterMessage("AURA_FADE")
end
function Auras:CreateFrame(unit)
local auraFrame = CreateFrame("Frame", nil, Gladdy.modules.Classicon.frames[unit])
auraFrame:SetFrameStrata("MEDIUM")
auraFrame:SetFrameLevel(3)
auraFrame.cooldown = CreateFrame("Cooldown", nil, auraFrame, "CooldownFrameTemplate")
auraFrame.cooldown.noCooldownCount = true
auraFrame.cooldown:SetFrameStrata("MEDIUM")
auraFrame.cooldown:SetFrameLevel(4)
auraFrame.cooldown:SetReverse(true)
auraFrame.cooldown:SetHideCountdownNumbers(true)
auraFrame.cooldownFrame = CreateFrame("Frame", nil, auraFrame)
auraFrame.cooldownFrame:ClearAllPoints()
auraFrame.cooldownFrame:SetAllPoints(auraFrame)
auraFrame.cooldownFrame:SetFrameStrata("MEDIUM")
auraFrame.cooldownFrame:SetFrameLevel(5)
auraFrame.icon = auraFrame:CreateTexture(nil, "BACKGROUND")
auraFrame.icon:SetAllPoints(auraFrame)
auraFrame.icon.overlay = auraFrame.cooldownFrame:CreateTexture(nil, "OVERLAY")
auraFrame.icon.overlay:SetAllPoints(auraFrame)
auraFrame.icon.overlay:SetTexture(Gladdy.db.buttonBorderStyle)
local classIcon = Gladdy.modules.Classicon.frames[unit]
auraFrame:ClearAllPoints()
auraFrame:SetAllPoints(classIcon)
auraFrame:SetScript("OnUpdate", function(self, elapsed)
if (self.active) then
if (self.timeLeft <= 0) then
Auras:AURA_FADE(unit)
else
self.timeLeft = self.timeLeft - elapsed
self.text:SetFormattedText("%.1f", self.timeLeft)
end
end
end)
auraFrame.text = auraFrame.cooldownFrame:CreateFontString(nil, "OVERLAY")
auraFrame.text:SetFont(Gladdy.LSM:Fetch("font", Gladdy.db.auraFont), 10, "OUTLINE")
auraFrame.text:SetTextColor(Gladdy.db.auraFontColor.r, Gladdy.db.auraFontColor.g, Gladdy.db.auraFontColor.b, Gladdy.db.auraFontColor.a)
--auraFrame.text:SetShadowOffset(1, -1)
--auraFrame.text:SetShadowColor(0, 0, 0, 1)
auraFrame.text:SetJustifyH("CENTER")
auraFrame.text:SetPoint("CENTER")
auraFrame.unit = unit
self.frames[unit] = auraFrame
self:ResetUnit(unit)
end
function Auras:UpdateFrame(unit)
local auraFrame = self.frames[unit]
if (not auraFrame) then
return
end
local width, height = Gladdy.db.classIconSize * Gladdy.db.classIconWidthFactor, Gladdy.db.classIconSize
auraFrame:SetWidth(width)
auraFrame:SetHeight(height)
auraFrame:SetAllPoints(Gladdy.modules.Classicon.frames[unit])
auraFrame.cooldown:SetWidth(width - width/16)
auraFrame.cooldown:SetHeight(height - height/16)
auraFrame.cooldown:ClearAllPoints()
auraFrame.cooldown:SetPoint("CENTER", auraFrame, "CENTER")
auraFrame.cooldown:SetAlpha(Gladdy.db.auraCooldownAlpha)
auraFrame.text:SetFont(Gladdy.LSM:Fetch("font", Gladdy.db.auraFont), (width/2 - 1) * Gladdy.db.auraFontSizeScale, "OUTLINE")
auraFrame.text:SetTextColor(Gladdy.db.auraFontColor.r, Gladdy.db.auraFontColor.g, Gladdy.db.auraFontColor.b, Gladdy.db.auraFontColor.a)
auraFrame.icon.overlay:SetTexture(Gladdy.db.auraBorderStyle)
if auraFrame.track and auraFrame.track == AURA_TYPE_DEBUFF then
auraFrame.icon.overlay:SetVertexColor(Gladdy.db.auraDebuffBorderColor.r, Gladdy.db.auraDebuffBorderColor.g, Gladdy.db.auraDebuffBorderColor.b, Gladdy.db.auraDebuffBorderColor.a)
elseif auraFrame.track and auraFrame.track == AURA_TYPE_BUFF then
auraFrame.icon.overlay:SetVertexColor(Gladdy.db.auraBuffBorderColor.r, Gladdy.db.auraBuffBorderColor.g, Gladdy.db.auraBuffBorderColor.b, Gladdy.db.auraBuffBorderColor.a)
else
auraFrame.icon.overlay:SetVertexColor(0, 0, 0, 1)
end
if Gladdy.db.auraDisableCircle then
auraFrame.cooldown:SetAlpha(0)
end
end
function Auras:ResetUnit(unit)
self.frames[unit]:UnregisterAllEvents()
self:AURA_FADE(unit)
end
function Auras:Test(unit)
local aura, _, icon
if (unit == "arena1") then
aura, _, icon = GetSpellInfo(12826)
elseif (unit == "arena4") then
aura, _, icon = GetSpellInfo(6770)
elseif (unit == "arena3") then
aura, _, icon = GetSpellInfo(31224)
end
if (aura) then
--(unit, auraType, spellID, aura, icon, duration, expirationTime, count, debuffType)
self:AURA_GAIN(unit,nil, nil, aura, icon, self.auras[aura].duration, GetTime() + self.auras[aura].duration)
--self:AURA_FADE(unit)
end
end
function Auras:JOINED_ARENA()
for i=1, Gladdy.curBracket do
--self.frames["arena" .. i]:RegisterUnitEvent("UNIT_AURA", "arena" .. i)
--self.frames["arena" .. i]:SetScript("OnEvent", Auras.OnEvent)
end
end
function Auras:AURA_GAIN(unit, auraType, spellID, aura, icon, duration, expirationTime, count, debuffType)
if not Gladdy.db.auraListDefault[aura] or not Gladdy.db.auraListDefault[aura].enabled then
return
end
local auraFrame = self.frames[unit]
if (not auraFrame) then
return
end
if (auraFrame.priority and auraFrame.priority > Gladdy.db.auraListDefault[aura].priority) then
return
end
auraFrame.startTime = expirationTime - duration
auraFrame.endTime = expirationTime
auraFrame.name = aura
auraFrame.timeLeft = expirationTime - GetTime()
auraFrame.priority = Gladdy.db.auraListDefault[aura].priority
auraFrame.icon:SetTexture(icon)
auraFrame.track = self.auras[aura].track
auraFrame.active = true
auraFrame.icon.overlay:SetTexture(Gladdy.db.auraBorderStyle)
auraFrame.cooldownFrame:Show()
if auraFrame.track and auraFrame.track == AURA_TYPE_DEBUFF then
auraFrame.icon.overlay:SetVertexColor(Gladdy.db.auraDebuffBorderColor.r, Gladdy.db.auraDebuffBorderColor.g, Gladdy.db.auraDebuffBorderColor.b, Gladdy.db.auraDebuffBorderColor.a)
elseif auraFrame.track and auraFrame.track == AURA_TYPE_BUFF then
auraFrame.icon.overlay:SetVertexColor(Gladdy.db.auraBuffBorderColor.r, Gladdy.db.auraBuffBorderColor.g, Gladdy.db.auraBuffBorderColor.b, Gladdy.db.auraBuffBorderColor.a)
else
auraFrame.icon.overlay:SetVertexColor(Gladdy.db.frameBorderColor.r, Gladdy.db.frameBorderColor.g, Gladdy.db.frameBorderColor.b, Gladdy.db.frameBorderColor.a)
end
if not Gladdy.db.auraDisableCircle then
auraFrame.cooldown:Show()
auraFrame.cooldown:SetCooldown(auraFrame.startTime, duration)
end
end
function Auras:AURA_FADE(unit)
local auraFrame = self.frames[unit]
if (not auraFrame) then
return
end
if auraFrame.active then
auraFrame.cooldown:SetCooldown(GetTime(), 0)
end
auraFrame.cooldown:Hide()
auraFrame.active = false
auraFrame.name = nil
auraFrame.timeLeft = 0
auraFrame.priority = nil
auraFrame.startTime = nil
auraFrame.endTime = nil
auraFrame.icon:SetTexture("")
auraFrame.text:SetText("")
auraFrame.icon.overlay:SetTexture("")
auraFrame.cooldownFrame:Hide()
end
function Auras:GetOptions()
return {
header = {
type = "header",
name = L["Auras"],
order = 2,
},
group = {
type = "group",
childGroups = "tree",
name = "Frame",
order = 3,
args = {
cooldown = {
type = "group",
name = "Cooldown",
order = 1,
args = {
headerAuras = {
type = "header",
name = L["Cooldown"],
order = 2,
},
auraDisableCircle = Gladdy:option({
type = "toggle",
name = L["No Cooldown Circle"],
order = 3,
width = "full"
}),
auraCooldownAlpha = Gladdy:option({
type = "range",
name = L["Cooldown circle alpha"],
min = 0,
max = 1,
step = 0.1,
order = 4,
}),
auraFont = Gladdy:option({
type = "select",
name = L["Font"],
desc = L["Font of the cooldown"],
order = 5,
dialogControl = "LSM30_Font",
values = AceGUIWidgetLSMlists.font,
}),
auraFontSizeScale = Gladdy:option({
type = "range",
name = L["Font scale"],
desc = L["Scale of the text"],
order = 6,
min = 0.1,
max = 2,
step = 0.1,
}),
auraFontColor = Gladdy:colorOption({
type = "color",
name = L["Font color"],
desc = L["Color of the text"],
order = 7,
hasAlpha = true,
}),
}
},
border = {
type = "group",
name = "Border",
order = 2,
args = {
headerAuras = {
type = "header",
name = L["Border"],
order = 2,
},
auraBorderStyle = Gladdy:option({
type = "select",
name = L["Border style"],
order = 9,
values = Gladdy:GetIconStyles(),
}),
auraBuffBorderColor = Gladdy:colorOption({
type = "color",
name = L["Buff color"],
desc = L["Color of the text"],
order = 10,
hasAlpha = true,
width = "0.8",
}),
auraDebuffBorderColor = Gladdy:colorOption({
type = "color",
name = L["Debuff color"],
desc = L["Color of the text"],
order = 11,
hasAlpha = true,
width = "0.8",
}),
}
}
}
},
debuffList = {
type = "group",
childGroups = "tree",
name = "Debuffs",
order = 4,
args = Auras:GetAuraOptions(AURA_TYPE_DEBUFF)
},
buffList = {
type = "group",
childGroups = "tree",
name = "Buffs",
order = 5,
args = Auras:GetAuraOptions(AURA_TYPE_BUFF)
}
}
end
function Auras:GetAuraOptions(auraType)
local options = {
ckeckAll = {
order = 1,
width = "0.7",
name = "Check All",
type = "execute",
func = function(info)
for k,v in pairs(defaultSpells(auraType)) do
Gladdy.db.auraListDefault[k].enabled = true
end
end,
},
uncheckAll = {
order = 2,
width = "0.7",
name = "Uncheck All",
type = "execute",
func = function(info)
for k,v in pairs(defaultSpells(auraType)) do
Gladdy.db.auraListDefault[k].enabled = false
end
end,
},
}
local auras = {}
for k,v in pairs(Gladdy:GetImportantAuras()) do
if v.track == auraType then
tinsert(auras, k)
end
end
tbl_sort(auras)
for i,k in ipairs(auras) do
options[k] = {
type = "group",
name = k,
order = i+2,
icon = select(3, GetSpellInfo(Gladdy:GetImportantAuras()[k].spellID)),
args = {
enabled = {
order = 1,
name = L["Enabled"],
type = "toggle",
image = select(3, GetSpellInfo(Gladdy:GetImportantAuras()[k].spellID)),
width = "2",
set = function(info, value)
Gladdy.db.auraListDefault[k].enabled = value
end,
get = function(info)
return Gladdy.db.auraListDefault[k].enabled
end
},
priority = {
order = 2,
name = L["Priority"],
type = "range",
min = 0,
max = 50,
width = "2",
step = 1,
get = function(info)
return Gladdy.db.auraListDefault[k].priority
end,
set = function(info, value)
Gladdy.db.auraListDefault[k].priority = value
end,
}
}
}
end
return options
end

1057
Modules/BuffsDebuffs.lua Normal file

File diff suppressed because it is too large Load Diff

827
Modules/Castbar.lua Normal file
View File

@ -0,0 +1,827 @@
local pairs = pairs
local select = select
local CreateFrame = CreateFrame
local GetSpellInfo = GetSpellInfo
local UnitChannelInfo = UnitChannelInfo
local UnitCastingInfo = UnitCastingInfo
local GetTime = GetTime
local CASTING_BAR_ALPHA_STEP = CASTING_BAR_ALPHA_STEP
local BackdropTemplateMixin = BackdropTemplateMixin
---------------------------
-- CORE
---------------------------
local Gladdy = LibStub("Gladdy")
local L = Gladdy.L
local AceGUIWidgetLSMlists = AceGUIWidgetLSMlists
local Castbar = Gladdy:NewModule("Castbar", 70, {
castBarHeight = 20,
castBarWidth = 160,
castBarIconSize = 22,
castBarBorderSize = 8,
castBarFontSize = 12,
castBarTexture = "Smooth",
castBarIconStyle = "Interface\\AddOns\\Gladdy\\Images\\Border_rounded_blp",
castBarBorderStyle = "Gladdy Tooltip round",
castBarColor = { r = 1, g = 0.8, b = 0.2, a = 1 },
castBarBgColor = { r = 0, g = 0, b = 0, a = 0.4 },
castBarIconColor = { r = 0, g = 0, b = 0, a = 1 },
castBarBorderColor = { r = 0, g = 0, b = 0, a = 1 },
castBarFontColor = { r = 1, g = 1, b = 1, a = 1 },
castBarGuesses = true,
castBarPos = "LEFT",
castBarXOffset = 0,
castBarYOffset = 0,
castBarIconPos = "LEFT",
castBarFont = "DorisPP",
castBarTimerFormat = "LEFT",
castBarSparkEnabled = true,
castBarSparkColor = { r = 1, g = 1, b = 1, a = 1 },
})
function Castbar:Initialize()
self.frames = {}
self:RegisterMessage("UNIT_DEATH")
self:RegisterMessage("JOINED_ARENA")
end
---------------------------
-- FRAME SETUP
---------------------------
function Castbar:CreateFrame(unit)
local castBar = CreateFrame("Frame", nil, Gladdy.buttons[unit], BackdropTemplateMixin and "BackdropTemplate")
castBar.unit = unit
castBar:SetBackdrop({ edgeFile = Gladdy.LSM:Fetch("border", Gladdy.db.castBarBorderStyle),
edgeSize = Gladdy.db.castBarBorderSize })
castBar:SetBackdropBorderColor(Gladdy.db.castBarBorderColor.r, Gladdy.db.castBarBorderColor.g, Gladdy.db.castBarBorderColor.b, Gladdy.db.castBarBorderColor.a)
castBar:SetFrameLevel(1)
castBar.bar = CreateFrame("StatusBar", nil, castBar)
castBar.bar:SetStatusBarTexture(Gladdy.LSM:Fetch("statusbar", Gladdy.db.castBarTexture))
castBar.bar:SetStatusBarColor(Gladdy.db.castBarColor.r, Gladdy.db.castBarColor.g, Gladdy.db.castBarColor.b, Gladdy.db.castBarColor.a)
castBar.bar:SetMinMaxValues(0, 100)
castBar.bar:SetFrameLevel(0)
castBar.spark = castBar:CreateTexture(nil, "OVERLAY")
castBar.spark:SetTexture("Interface\\CastingBar\\UI-CastingBar-Spark")
castBar.spark:SetBlendMode("ADD")
castBar.spark:SetWidth(16)
castBar.spark:SetHeight(Gladdy.db.castBarHeight * 1.8)
castBar.spark.position = 0
castBar.bg = castBar.bar:CreateTexture(nil, "BACKGROUND")
castBar.bg:SetAlpha(1)
castBar.bg:SetTexture(Gladdy.LSM:Fetch("statusbar", Gladdy.db.castBarTexture))
castBar.bg:SetVertexColor(Gladdy.db.castBarBgColor.r, Gladdy.db.castBarBgColor.g, Gladdy.db.castBarBgColor.b, Gladdy.db.castBarBgColor.a)
castBar.bg:SetAllPoints(castBar.bar)
castBar.icon = CreateFrame("Frame", nil, castBar)
castBar.icon.texture = castBar.icon:CreateTexture(nil, "BACKGROUND")
castBar.icon.texture:SetAllPoints(castBar.icon)
castBar.icon.texture.overlay = castBar.icon:CreateTexture(nil, "BORDER")
castBar.icon.texture.overlay:SetAllPoints(castBar.icon.texture)
castBar.icon.texture.overlay:SetTexture(Gladdy.db.castBarIconStyle)
castBar.icon:ClearAllPoints()
if (Gladdy.db.castBarIconPos == "LEFT") then
castBar.icon:SetPoint("RIGHT", castBar, "LEFT", -3, 0) -- Icon of castbar
else
castBar.icon:SetPoint("LEFT", castBar, "RIGHT", 3, 0) -- Icon of castbar
end
castBar.spellText = castBar:CreateFontString(nil, "LOW")
castBar.spellText:SetFont(Gladdy.LSM:Fetch("font", Gladdy.db.auraFont), Gladdy.db.castBarFontSize)
castBar.spellText:SetTextColor(Gladdy.db.castBarFontColor.r, Gladdy.db.castBarFontColor.g, Gladdy.db.castBarFontColor.b, Gladdy.db.castBarFontColor.a)
castBar.spellText:SetShadowOffset(1, -1)
castBar.spellText:SetShadowColor(0, 0, 0, 1)
castBar.spellText:SetJustifyH("CENTER")
castBar.spellText:SetPoint("LEFT", 7, 0) -- Text of the spell
castBar.timeText = castBar:CreateFontString(nil, "LOW")
castBar.timeText:SetFont(Gladdy.LSM:Fetch("font", Gladdy.db.auraFont), Gladdy.db.castBarFontSize)
castBar.timeText:SetTextColor(Gladdy.db.castBarFontColor.r, Gladdy.db.castBarFontColor.g, Gladdy.db.castBarFontColor.b, Gladdy.db.castBarFontColor.a)
castBar.timeText:SetShadowOffset(1, -1)
castBar.timeText:SetShadowColor(0, 0, 0, 1)
castBar.timeText:SetJustifyH("CENTER")
castBar.timeText:SetPoint("RIGHT", -4, 0) -- text of cast timer
Gladdy.buttons[unit].castBar = castBar
self.frames[unit] = castBar
self:ResetUnit(unit)
end
function Castbar:UpdateFrame(unit)
local button = Gladdy.buttons[unit]
local castBar = self.frames[unit]
if (not castBar) then
return
end
castBar:SetWidth(Gladdy.db.castBarWidth)
castBar:SetHeight(Gladdy.db.castBarHeight)
castBar:SetBackdrop({ edgeFile = Gladdy.LSM:Fetch("border", Gladdy.db.castBarBorderStyle),
edgeSize = Gladdy.db.castBarBorderSize })
castBar:SetBackdropBorderColor(Gladdy.db.castBarBorderColor.r, Gladdy.db.castBarBorderColor.g, Gladdy.db.castBarBorderColor.b, Gladdy.db.castBarBorderColor.a)
castBar.bar:SetStatusBarTexture(Gladdy.LSM:Fetch("statusbar", Gladdy.db.castBarTexture))
castBar.bar:ClearAllPoints()
castBar.bar:SetStatusBarColor(Gladdy.db.castBarColor.r, Gladdy.db.castBarColor.g, Gladdy.db.castBarColor.b, Gladdy.db.castBarColor.a)
castBar.bar:SetPoint("TOPLEFT", castBar, "TOPLEFT", (Gladdy.db.castBarBorderSize/Gladdy.db.statusbarBorderOffset), -(Gladdy.db.castBarBorderSize/Gladdy.db.statusbarBorderOffset))
castBar.bar:SetPoint("BOTTOMRIGHT", castBar, "BOTTOMRIGHT", -(Gladdy.db.castBarBorderSize/Gladdy.db.statusbarBorderOffset), (Gladdy.db.castBarBorderSize/Gladdy.db.statusbarBorderOffset))
castBar.bg:SetTexture(Gladdy.LSM:Fetch("statusbar", Gladdy.db.castBarTexture))
castBar.bg:SetVertexColor(Gladdy.db.castBarBgColor.r, Gladdy.db.castBarBgColor.g, Gladdy.db.castBarBgColor.b, Gladdy.db.castBarBgColor.a)
if Gladdy.db.castBarSparkEnabled then
castBar.spark:SetHeight(Gladdy.db.castBarHeight * 1.8)
castBar.spark:SetVertexColor(Gladdy.db.castBarSparkColor.r, Gladdy.db.castBarSparkColor.g, Gladdy.db.castBarSparkColor.b, Gladdy.db.castBarSparkColor.a)
else
castBar.spark:SetAlpha(0)
end
castBar.icon:SetWidth(Gladdy.db.castBarIconSize)
castBar.icon:SetHeight(Gladdy.db.castBarIconSize)
castBar.icon.texture:SetAllPoints(castBar.icon)
castBar.icon:ClearAllPoints()
local rightMargin = 0
local leftMargin = 0
if (Gladdy.db.castBarIconPos == "LEFT") then
castBar.icon:SetPoint("RIGHT", castBar, "LEFT", -1, 0) -- Icon of castbar
rightMargin = Gladdy.db.castBarIconSize + 1
else
castBar.icon:SetPoint("LEFT", castBar, "RIGHT", 1, 0) -- Icon of castbar
leftMargin = Gladdy.db.castBarIconSize + 1
end
castBar:ClearAllPoints()
local horizontalMargin = Gladdy.db.highlightBorderSize + Gladdy.db.padding
local verticalMargin = -(Gladdy.db.powerBarHeight)/2
if (Gladdy.db.castBarPos == "LEFT") then
if (Gladdy.db.trinketPos == "LEFT" and Gladdy.db.trinketEnabled) then
horizontalMargin = horizontalMargin + (Gladdy.db.trinketSize * Gladdy.db.trinketWidthFactor) + Gladdy.db.padding
if (Gladdy.db.classIconPos == "LEFT") then
horizontalMargin = horizontalMargin + (Gladdy.db.classIconSize * Gladdy.db.classIconWidthFactor) + Gladdy.db.padding
end
elseif (Gladdy.db.classIconPos == "LEFT") then
horizontalMargin = horizontalMargin + (Gladdy.db.classIconSize * Gladdy.db.classIconWidthFactor) + Gladdy.db.padding
if (Gladdy.db.trinketPos == "LEFT" and Gladdy.db.trinketEnabled) then
horizontalMargin = horizontalMargin + (Gladdy.db.trinketSize * Gladdy.db.trinketWidthFactor) + Gladdy.db.padding
end
end
if (Gladdy.db.cooldownYPos == "LEFT" and Gladdy.db.cooldown) then
verticalMargin = verticalMargin + (Gladdy.db.cooldownSize/2 + Gladdy.db.padding/2)
end
if (Gladdy.db.drCooldownPos == "LEFT" and Gladdy.db.drEnabled) then
verticalMargin = verticalMargin + (Gladdy.db.drIconSize/2 + Gladdy.db.padding/2)
end
if (Gladdy.db.buffsCooldownPos == "LEFT" and Gladdy.db.buffsEnabled) then
verticalMargin = verticalMargin + Gladdy.db.buffsIconSize/2 + Gladdy.db.padding/2
end
castBar:SetPoint("RIGHT", button.healthBar, "LEFT", -horizontalMargin - leftMargin + Gladdy.db.castBarXOffset, Gladdy.db.castBarYOffset + verticalMargin)
end
if (Gladdy.db.castBarPos == "RIGHT") then
if (Gladdy.db.trinketPos == "RIGHT" and Gladdy.db.trinketEnabled) then
horizontalMargin = horizontalMargin + (Gladdy.db.trinketSize * Gladdy.db.trinketWidthFactor) + Gladdy.db.padding
if (Gladdy.db.classIconPos == "RIGHT") then
horizontalMargin = horizontalMargin + (Gladdy.db.classIconSize * Gladdy.db.classIconWidthFactor) + Gladdy.db.padding
end
elseif (Gladdy.db.classIconPos == "RIGHT") then
horizontalMargin = horizontalMargin + (Gladdy.db.classIconSize * Gladdy.db.classIconWidthFactor) + Gladdy.db.padding
if (Gladdy.db.trinketPos == "LEFT" and Gladdy.db.trinketEnabled) then
horizontalMargin = horizontalMargin + (Gladdy.db.trinketSize * Gladdy.db.trinketWidthFactor) + Gladdy.db.padding
end
end
if (Gladdy.db.cooldownYPos == "RIGHT" and Gladdy.db.cooldown) then
verticalMargin = verticalMargin + (Gladdy.db.cooldownSize/2 + Gladdy.db.padding/2)
end
if (Gladdy.db.drCooldownPos == "RIGHT" and Gladdy.db.drEnabled) then
verticalMargin = verticalMargin + (Gladdy.db.drIconSize/2 + Gladdy.db.padding/2)
end
if (Gladdy.db.buffsCooldownPos == "RIGHT" and Gladdy.db.buffsEnabled) then
verticalMargin = verticalMargin + Gladdy.db.buffsIconSize/2 + Gladdy.db.padding/2
end
castBar:SetPoint("LEFT", button.healthBar, "RIGHT", horizontalMargin + rightMargin + Gladdy.db.castBarXOffset, Gladdy.db.castBarYOffset + verticalMargin)
end
castBar.spellText:SetFont(Gladdy.LSM:Fetch("font", Gladdy.db.auraFont), Gladdy.db.castBarFontSize)
castBar.spellText:SetTextColor(Gladdy.db.castBarFontColor.r, Gladdy.db.castBarFontColor.g, Gladdy.db.castBarFontColor.b, Gladdy.db.castBarFontColor.a)
castBar.timeText:SetFont(Gladdy.LSM:Fetch("font", Gladdy.db.auraFont), Gladdy.db.castBarFontSize)
castBar.timeText:SetTextColor(Gladdy.db.castBarFontColor.r, Gladdy.db.castBarFontColor.g, Gladdy.db.castBarFontColor.b, Gladdy.db.castBarFontColor.a)
castBar.icon.texture.overlay:SetTexture(Gladdy.db.castBarIconStyle)
castBar.icon.texture.overlay:SetVertexColor(Gladdy.db.castBarIconColor.r, Gladdy.db.castBarIconColor.g, Gladdy.db.castBarIconColor.b, Gladdy.db.castBarIconColor.a)
end
---------------------------
-- EVENT HANDLING
---------------------------
Castbar.TimerFormatFunc = {}
Castbar.TimerFormatFunc.LEFT = function(castBar)
castBar.timeText:SetFormattedText("%.1f", castBar.casting and (castBar.maxValue - castBar.value) or castBar.value)
end
Castbar.TimerFormatFunc.TOTAL = function(castBar)
castBar.timeText:SetFormattedText("%.1f", castBar.maxValue)
end
Castbar.TimerFormatFunc.BOTH = function(castBar)
castBar.timeText:SetFormattedText("%.1f / %.1f", castBar.casting and (castBar.maxValue - castBar.value) or castBar.value, castBar.maxValue)
end
function Castbar.OnUpdate(castBar, elapsed)
if castBar.channeling or castBar.casting then
if ((castBar.casting and castBar.value >= castBar.maxValue) or (castBar.channeling and castBar.value <= 0)) then
-- cast timed out
castBar.holdTime = castBar.casting and (GetTime() + 0.25) or 0
castBar.fadeOut = castBar.casting
castBar.channeling = nil
castBar.casting = nil
Castbar:CAST_STOP(castBar.unit, 0, 1, 0, 1)
else
--cast active
castBar.value = castBar.value + (castBar.casting and elapsed or -elapsed)
castBar.bar:SetValue(castBar.value)
Castbar.TimerFormatFunc[Gladdy.db.castBarTimerFormat](castBar)
castBar.spark.position = ((castBar.value) / castBar.maxValue) * (castBar.bar:GetWidth() - (Gladdy.db.castBarBorderSize/Gladdy.db.statusbarBorderOffset)*2)
if ( castBar.spark.position < 0 ) then
castBar.spark.position = 0
end
castBar.spark:SetPoint("CENTER", castBar.bar, "LEFT", castBar.spark.position, 0)
castBar.spark:Show()
end
elseif ( GetTime() < castBar.holdTime ) then
castBar.timeText:Hide()
castBar.spark:Hide()
return
elseif castBar.fadeOut then
local alpha = castBar:GetAlpha() - CASTING_BAR_ALPHA_STEP;
if ( alpha > 0 ) then
castBar:SetAlpha(alpha)
else
castBar.fadeOut = nil;
castBar.timeText:Show()
castBar.spark:Show()
castBar:Hide();
end
end
end
Castbar.CastEventsFunc = {}
Castbar.CastEventsFunc["UNIT_SPELLCAST_START"] = function(castBar, event, ...)
local name, text, texture, startTime, endTime, isTradeSkill, castID = UnitCastingInfo(castBar.unit)
if ( not name or (not castBar.showTradeSkills and isTradeSkill)) then
castBar:Hide()
return
end
if ( castBar.spark ) then
castBar.spark:Show()
end
castBar.value = (GetTime() - (startTime / 1000));
castBar.maxValue = (endTime - startTime) / 1000;
castBar.holdTime = 0
castBar.casting = true
castBar.castID = castID
castBar.channeling = nil
castBar.fadeOut = nil
Castbar:CAST_START(castBar.unit, name, texture, castBar.value, castBar.maxValue)
end
Castbar.CastEventsFunc["UNIT_SPELLCAST_SUCCEEDED"] = function(castBar, event, ...)
if (castBar.casting and event == "UNIT_SPELLCAST_SUCCEEDED" and select(2, ...) == castBar.castID) then
if ( castBar.spark ) then
castBar.spark:Hide()
end
castBar.casting = nil
--castBar.spellText:SetText("Stopped")
castBar.flash = true
castBar.fadeOut = true
castBar.holdTime = GetTime() + 0.25
Castbar:CAST_STOP(castBar.unit, 0, 1, 0, 1)
end
end
Castbar.CastEventsFunc["UNIT_SPELLCAST_STOP"] = function(castBar, event, ...)
if ( not castBar:IsVisible() ) then
castBar:Hide()
end
if ( (castBar.casting and event == "UNIT_SPELLCAST_STOP" and select(2, ...) == castBar.castID) or
(castBar.channeling and event == "UNIT_SPELLCAST_CHANNEL_STOP") ) then
if ( castBar.spark ) then
castBar.spark:Hide()
end
if ( event == "UNIT_SPELLCAST_STOP" ) then
castBar.casting = nil
else
castBar.channeling = nil
end
castBar.spellText:SetText("Stopped")
castBar.flash = true
castBar.fadeOut = true
castBar.holdTime = GetTime() + 0.25
Castbar:CAST_STOP(castBar.unit, 1, 0, 0, 1)
end
end
Castbar.CastEventsFunc["UNIT_SPELLCAST_CHANNEL_STOP"] = Castbar.CastEventsFunc["UNIT_SPELLCAST_STOP"]
Castbar.CastEventsFunc["UNIT_SPELLCAST_FAILED"] = function(castBar, event, ...)
if ( castBar:IsShown() and
(castBar.casting and select(2, ...) == castBar.castID) and not castBar.fadeOut ) then
if ( castBar.spark ) then
castBar.spark:Hide()
end
if ( castBar.spellText ) then
if ( event == "UNIT_SPELLCAST_FAILED" ) then
castBar.spellText:SetText("Failed")
else
castBar.spellText:SetText("Interrupted")
end
end
castBar.bar:SetValue(castBar.maxValue)
castBar.casting = nil
castBar.channeling = nil
castBar.fadeOut = true
castBar.holdTime = GetTime() + 1
Castbar:CAST_STOP(castBar.unit, 1, 0, 0, 1)
end
end
Castbar.CastEventsFunc["UNIT_SPELLCAST_INTERRUPTED"] = Castbar.CastEventsFunc["UNIT_SPELLCAST_FAILED"]
Castbar.CastEventsFunc["UNIT_SPELLCAST_DELAYED"] = function(castBar, event, ...)
if ( castBar:IsShown() ) then
local name, text, texture, startTime, endTime, isTradeSkill, castID = UnitCastingInfo(castBar.unit)
if ( not name or (not castBar.showTradeSkills and isTradeSkill)) then
-- if there is no name, there is no bar
castBar:Hide()
return
end
castBar.value = (GetTime() - (startTime / 1000))
castBar.maxValue = (endTime - startTime) / 1000
castBar.bar:SetMinMaxValues(0, castBar.maxValue)
if ( not castBar.casting ) then
castBar.casting = true
castBar.channeling = nil
castBar.flash = nil
castBar.fadeOut = nil
end
end
end
Castbar.CastEventsFunc["UNIT_SPELLCAST_CHANNEL_START"] = function(castBar, event, ...)
local name, text, texture, startTime, endTime, isTradeSkill, spellID = UnitChannelInfo(castBar.unit)
if ( not name or (not castBar.showTradeSkills and isTradeSkill)) then
castBar:Hide()
return
end
if ( castBar.spark ) then
castBar.spark:Show()
end
castBar.value = (endTime / 1000) - GetTime()
castBar.maxValue = (endTime - startTime) / 1000
castBar.holdTime = 0
castBar.casting = nil
castBar.channeling = true
castBar.fadeOut = nil
Castbar:CAST_START(castBar.unit, name, texture, castBar.value, castBar.maxValue)
end
Castbar.CastEventsFunc["UNIT_SPELLCAST_CHANNEL_UPDATE"] = function(castBar, event, ...)
if ( castBar:IsShown() ) then
local name, text, texture, startTime, endTime, isTradeSkill = UnitChannelInfo(castBar.unit)
if ( not name or (not castBar.showTradeSkills and isTradeSkill)) then
castBar:Hide()
return
end
castBar.value = ((endTime / 1000) - GetTime())
castBar.maxValue = (endTime - startTime) / 1000
Castbar:CAST_START(castBar.unit, name, texture, castBar.value, castBar.maxValue)
end
end
function Castbar.OnEvent(self, event, ...)
local unit = ...
if ( unit ~= self.unit ) then
return
end
Castbar.CastEventsFunc[event](self, event, ...)
end
function Castbar:CAST_START(unit, spell, icon, value, maxValue, test)
local castBar = self.frames[unit]
if (not castBar) then
return
end
Gladdy:SendMessage("CAST_START", unit, spell)
if test then
castBar:SetScript("OnUpdate", Castbar.OnUpdate)
castBar.casting = test == "cast"
castBar.channeling = test == "channel"
end
castBar.bar:SetStatusBarColor(Gladdy.db.castBarColor.r, Gladdy.db.castBarColor.g, Gladdy.db.castBarColor.b, Gladdy.db.castBarColor.a)
castBar.value = value
castBar.maxValue = maxValue
castBar.bar:SetMinMaxValues(0, maxValue)
castBar.bar:SetValue(value)
castBar.icon.texture:SetTexture(icon)
castBar.spellText:SetText(spell)
castBar.timeText:SetText(maxValue)
castBar.bg:Show()
castBar:Show()
castBar:SetAlpha(1)
castBar.icon:Show()
end
function Castbar:CAST_STOP(unit, ...)
local castBar = self.frames[unit]
if (not castBar) then
return
end
if not castBar.fadeOut then
castBar.casting = nil
castBar.channeling = nil
castBar.value = 0
castBar.maxValue = 0
castBar.icon.texture:SetTexture("")
castBar.spellText:SetText("")
castBar.timeText:SetText("")
castBar.bar:SetValue(0)
castBar.bg:Hide()
castBar:Hide()
castBar.icon:Hide()
else
castBar.bar:SetStatusBarColor(...)
end
end
---------------------------
-- Gladdy Messages JOINED_ARENA / ResetUnit
---------------------------
function Castbar:JOINED_ARENA()
for i=1, Gladdy.curBracket do
local unit = "arena" .. i
local castBar = self.frames[unit]
castBar:RegisterEvent("UNIT_SPELLCAST_INTERRUPTED")
castBar:RegisterEvent("UNIT_SPELLCAST_DELAYED")
castBar:RegisterEvent("UNIT_SPELLCAST_CHANNEL_START")
castBar:RegisterEvent("UNIT_SPELLCAST_CHANNEL_UPDATE")
castBar:RegisterEvent("UNIT_SPELLCAST_CHANNEL_STOP")
castBar:RegisterUnitEvent("UNIT_SPELLCAST_START", unit)
castBar:RegisterUnitEvent("UNIT_SPELLCAST_STOP", unit)
castBar:RegisterUnitEvent("UNIT_SPELLCAST_FAILED", unit)
castBar:RegisterUnitEvent("UNIT_SPELLCAST_SUCCEEDED", unit)
castBar:SetScript("OnEvent", Castbar.OnEvent)
castBar:SetScript("OnUpdate", Castbar.OnUpdate)
castBar.fadeOut = nil
self:CAST_STOP(unit)
--Castbar.OnEvent(castBar, "PLAYER_ENTERING_WORLD")
end
end
function Castbar:ResetUnit(unit)
local castBar = self.frames[unit]
castBar:UnregisterEvent("UNIT_SPELLCAST_INTERRUPTED")
castBar:UnregisterEvent("UNIT_SPELLCAST_DELAYED")
castBar:UnregisterEvent("UNIT_SPELLCAST_CHANNEL_START")
castBar:UnregisterEvent("UNIT_SPELLCAST_CHANNEL_UPDATE")
castBar:UnregisterEvent("UNIT_SPELLCAST_CHANNEL_STOP")
castBar:UnregisterEvent("UNIT_SPELLCAST_START")
castBar:UnregisterEvent("UNIT_SPELLCAST_STOP")
castBar:UnregisterEvent("UNIT_SPELLCAST_FAILED")
castBar:SetScript("OnEvent", nil)
castBar:SetScript("OnUpdate", nil)
castBar.fadeOut = nil
self:CAST_STOP(unit)
end
---------------------------
-- TEST
---------------------------
function Castbar:Test(unit)
local spell, _, icon, value, maxValue, event, endTime, startTime
if (unit == "arena2") then
spell, _, icon = GetSpellInfo(27072)
value, maxValue, event = 0, 2, "cast"
elseif (unit == "arena1") then
spell, _, icon = GetSpellInfo(27220)
endTime = GetTime() * 1000 + 60*1000
startTime = GetTime() * 1000
value = (endTime / 1000) - GetTime()
maxValue = (endTime - startTime) / 1000
event = "channel"
elseif (unit == "arena3") then
spell, _, icon = GetSpellInfo(20770)
value, maxValue, event = 0, 60, "cast"
end
if (spell) then
self:CAST_START(unit, spell, icon, value, maxValue, event)
end
end
---------------------------
-- OPTIONS
---------------------------
local function 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.options.args.Castbar.args.group.args.barFrame.args.castBarBorderSize.max = Gladdy.db.castBarHeight/2
if Gladdy.db.castBarBorderSize > Gladdy.db.castBarHeight/2 then
Gladdy.db.castBarBorderSize = Gladdy.db.castBarHeight/2
end
Gladdy:UpdateFrame()
end,
}
for k, v in pairs(params) do
defaults[k] = v
end
return defaults
end
function Castbar:GetOptions()
return {
header = {
type = "header",
name = L["Cast Bar"],
order = 2,
},
group = {
type = "group",
childGroups = "tree",
name = "Frame",
order = 3,
args = {
barFrame = {
type = "group",
name = "Bar",
order = 1,
args = {
headerSize = {
type = "header",
name = L["Bar Size"],
order = 1,
},
castBarHeight = option({
type = "range",
name = L["Bar height"],
desc = L["Height of the bar"],
order = 3,
min = 0,
max = 50,
step = 1,
}),
castBarWidth = option({
type = "range",
name = L["Bar width"],
desc = L["Width of the bars"],
order = 4,
min = 0,
max = 300,
step = 1,
}),
headerTexture = {
type = "header",
name = L["Texture"],
order = 5,
},
castBarTexture = option({
type = "select",
name = L["Bar texture"],
desc = L["Texture of the bar"],
order = 9,
dialogControl = "LSM30_Statusbar",
values = AceGUIWidgetLSMlists.statusbar,
}),
castBarColor = Gladdy:colorOption({
type = "color",
name = L["Bar color"],
desc = L["Color of the cast bar"],
order = 10,
hasAlpha = true,
}),
castBarBgColor = Gladdy:colorOption({
type = "color",
name = L["Background color"],
desc = L["Color of the cast bar background"],
order = 11,
hasAlpha = true,
}),
headerBorder = {
type = "header",
name = L["Border"],
order = 12,
},
castBarBorderSize = option({
type = "range",
name = L["Border size"],
order = 13,
min = 0.5,
max = Gladdy.db.castBarHeight/2,
step = 0.5,
}),
castBarBorderStyle = option({
type = "select",
name = L["Status Bar border"],
order = 51,
dialogControl = "LSM30_Border",
values = AceGUIWidgetLSMlists.border,
}),
castBarBorderColor = Gladdy:colorOption({
type = "color",
name = L["Status Bar border color"],
order = 52,
hasAlpha = true,
}),
},
},
icon = {
type = "group",
name = "Icon",
order = 2,
args = {
headerSize = {
type = "header",
name = L["Icon Size"],
order = 1,
},
castBarIconSize = option({
type = "range",
name = L["Icon size"],
order = 21,
min = 0,
max = 100,
step = 1,
}),
headerBorder = {
type = "header",
name = L["Border"],
order = 30,
},
castBarIconStyle = option({
type = "select",
name = L["Icon border"],
order = 53,
values = Gladdy:GetIconStyles(),
}),
castBarIconColor = Gladdy:colorOption({
type = "color",
name = L["Icon border color"],
order = 54,
hasAlpha = true,
}),
},
},
spark = {
type = "group",
name = "Spark",
order = 3,
args = {
header = {
type = "header",
name = L["Spark"],
order = 1,
},
castBarSparkEnabled = option({
type = "toggle",
name = L["Spark enabled"],
order = 26,
}),
castBarSparkColor = Gladdy:colorOption({
type = "color",
name = L["Spark color"],
desc = L["Color of the cast bar spark"],
order = 27,
hasAlpha = true,
}),
},
},
font = {
type = "group",
name = "Font",
order = 4,
args = {
header = {
type = "header",
name = L["Font"],
order = 1,
},
castBarFont = option({
type = "select",
name = L["Font"],
desc = L["Font of the castbar"],
order = 2,
dialogControl = "LSM30_Font",
values = AceGUIWidgetLSMlists.font,
}),
castBarFontColor = Gladdy:colorOption({
type = "color",
name = L["Font color"],
desc = L["Color of the text"],
order = 3,
hasAlpha = true,
}),
castBarFontSize = option({
type = "range",
name = L["Font size"],
desc = L["Size of the text"],
order = 4,
min = 1,
max = 20,
}),
headerFormat = {
type = "header",
name = L["Format"],
order = 10,
},
castBarTimerFormat = option({
type = "select",
name = L["Timer Format"],
order = 11,
values = {
["LEFT"] = L["Remaining"],
["TOTAL"] = L["Total"],
["BOTH"] = L["Both"],
},
}),
}
},
position = {
type = "group",
name = "Position",
order = 5,
args = {
header = {
type = "header",
name = L["Position"],
order = 1,
},
castBarPos = option({
type = "select",
name = L["Castbar position"],
order = 2,
values = {
["LEFT"] = L["Left"],
["RIGHT"] = L["Right"],
},
}),
castBarIconPos = option( {
type = "select",
name = L["Icon position"],
order = 3,
values = {
["LEFT"] = L["Left"],
["RIGHT"] = L["Right"],
},
}),
headerOffset = {
type = "header",
name = L["Offsets"],
order = 10,
},
castBarXOffset = option({
type = "range",
name = L["Horizontal offset"],
order = 11,
min = -400,
max = 400,
step = 0.1,
}),
castBarYOffset = option({
type = "range",
name = L["Vertical offset"],
order = 12,
min = -400,
max = 400,
step = 0.1,
}),
}
},
},
},
}
end

202
Modules/Classicon.lua Normal file
View File

@ -0,0 +1,202 @@
local Gladdy = LibStub("Gladdy")
local CreateFrame = CreateFrame
local L = Gladdy.L
local Classicon = Gladdy:NewModule("Classicon", 80, {
classIconPos = "LEFT",
classIconSize = 60 + 20 + 1,
classIconWidthFactor = 0.9,
classIconBorderStyle = "Interface\\AddOns\\Gladdy\\Images\\Border_rounded_blp",
classIconBorderColor = { r = 0, g = 0, b = 0, a = 1 },
})
function Classicon:Initialize()
self.frames = {}
self:RegisterMessage("ENEMY_SPOTTED")
self:RegisterMessage("UNIT_DEATH")
end
function Classicon:CreateFrame(unit)
local classIcon = CreateFrame("Frame", nil, Gladdy.buttons[unit])
classIcon:SetFrameStrata("MEDIUM")
classIcon:SetFrameLevel(1)
classIcon.texture = classIcon:CreateTexture(nil, "BACKGROUND")
classIcon.texture:SetAllPoints(classIcon)
classIcon.texture.overlay = classIcon:CreateTexture(nil, "BORDER")
classIcon.texture.overlay:SetAllPoints(classIcon)
classIcon.texture.overlay:SetTexture(Gladdy.db.classIconBorderStyle)
classIcon:SetFrameStrata("MEDIUM")
classIcon:SetFrameLevel(2)
classIcon:ClearAllPoints()
if (Gladdy.db.classIconPos == "RIGHT") then
classIcon:SetPoint("TOPLEFT", Gladdy.buttons[unit].healthBar, "TOPRIGHT", 2, 2)
else
classIcon:SetPoint("TOPRIGHT", Gladdy.buttons[unit].healthBar, "TOPLEFT", -2, 2)
end
Gladdy.buttons[unit].classIcon = classIcon
self.frames[unit] = classIcon
end
function Classicon:UpdateFrame(unit)
local classIcon = self.frames[unit]
if (not classIcon) then
return
end
classIcon:SetWidth(Gladdy.db.classIconSize * Gladdy.db.classIconWidthFactor)
classIcon:SetHeight(Gladdy.db.classIconSize)
classIcon:ClearAllPoints()
local margin = Gladdy.db.highlightBorderSize + Gladdy.db.padding
if (Gladdy.db.classIconPos == "LEFT") then
classIcon:SetPoint("TOPRIGHT", Gladdy.buttons[unit].healthBar, "TOPLEFT", -margin, 0)
else
classIcon:SetPoint("TOPLEFT", Gladdy.buttons[unit], "TOPRIGHT", margin, 0)
end
classIcon.texture:ClearAllPoints()
classIcon.texture:SetAllPoints(classIcon)
classIcon.texture.overlay:SetTexture(Gladdy.db.classIconBorderStyle)
classIcon.texture.overlay:SetVertexColor(Gladdy.db.classIconBorderColor.r, Gladdy.db.classIconBorderColor.g, Gladdy.db.classIconBorderColor.b, Gladdy.db.classIconBorderColor.a)
end
function Classicon:Test(unit)
self:ENEMY_SPOTTED(unit)
end
function Classicon:ResetUnit(unit)
local classIcon = self.frames[unit]
if (not classIcon) then
return
end
classIcon.texture:SetTexture("")
end
function Classicon:GetOptions()
return {
headerClassicon = {
type = "header",
name = L["Class Icon"],
order = 2,
},
group = {
type = "group",
childGroups = "tree",
name = "Frame",
order = 3,
args = {
size = {
type = "group",
name = L["Icon size"],
order = 1,
args = {
classIconSize = Gladdy:option({
type = "range",
name = L["Icon size"],
min = 1,
max = 100,
step = 1,
order = 3,
}),
classIconWidthFactor = Gladdy:option({
type = "range",
name = L["Icon width factor"],
min = 0.5,
max = 2,
step = 0.05,
order = 4,
}),
},
},
position = {
type = "group",
name = L["Position"],
order = 1,
args = {
headerPosition = {
type = "header",
name = L["Position"],
order = 5,
},
classIconPos = Gladdy:option({
type = "select",
name = L["Icon position"],
desc = L["This changes positions with trinket"],
order = 6,
values = {
["LEFT"] = L["Left"],
["RIGHT"] = L["Right"],
},
}),
},
},
border = {
type = "group",
name = L["Border"],
order = 1,
args = {
headerBorder = {
type = "header",
name = L["Border"],
order = 10,
},
classIconBorderStyle = Gladdy:option({
type = "select",
name = L["Border style"],
order = 11,
values = Gladdy:GetIconStyles()
}),
classIconBorderColor = Gladdy:colorOption({
type = "color",
name = L["Border color"],
desc = L["Color of the border"],
order = 12,
hasAlpha = true,
}),
},
},
},
},
}
end
local function getClassIcon(class)
-- see https://wow.gamepedia.com/Class_icon
local classIcon = "Interface\\Addons\\Gladdy\\Images\\Classes\\"
if class == "DRUID" then
return classIcon .. "inv_misc_monsterclaw_04"
elseif class == "HUNTER" then
return classIcon .. "inv_weapon_bow_07"
elseif class == "MAGE" then
return classIcon .. "inv_staff_13"
elseif class == "PALADIN" then
return classIcon .. "inv_hammer_01"
elseif class == "PRIEST" then
return classIcon .. "inv_staff_30"
elseif class == "ROGUE" then
return classIcon .. "inv_throwingknife_04"
elseif class == "SHAMAN" then
return classIcon .. "inv_jewelry_talisman_04"
elseif class == "WARLOCK" then
return classIcon .. "spell_nature_drowsy"
elseif class == "WARRIOR" then
return classIcon .. "inv_sword_27"
end
end
function Classicon:ENEMY_SPOTTED(unit)
local classIcon = self.frames[unit]
if (not classIcon) then
return
end
classIcon.texture:SetTexture(getClassIcon(Gladdy.buttons[unit].class))
--classIcon.texture:SetTexCoord(unpack(CLASS_BUTTONS[Gladdy.buttons[unit].class]))
classIcon.texture:SetAllPoints(classIcon)
end

987
Modules/Cooldowns.lua Normal file
View File

@ -0,0 +1,987 @@
local type, pairs, ceil, tonumber, mod = type, pairs, ceil, tonumber, mod
local GetTime = GetTime
local CreateFrame = CreateFrame
local GetSpellInfo = GetSpellInfo
local Gladdy = LibStub("Gladdy")
local L = Gladdy.L
local Cooldowns = Gladdy:NewModule("Cooldowns", nil, {
cooldownFont = "DorisPP",
cooldownFontScale = 1,
cooldownFontColor = { r = 1, g = 1, b = 0, a = 1 },
cooldown = true,
cooldownYPos = "TOP",
cooldownXPos = "LEFT",
cooldownYOffset = 0,
cooldownXOffset = 0,
cooldownSize = 30,
cooldownWidthFactor = 1,
cooldownIconPadding = 1,
cooldownMaxIconsPerLine = 10,
cooldownBorderStyle = "Interface\\AddOns\\Gladdy\\Images\\Border_Gloss",
cooldownBorderColor = { r = 1, g = 1, b = 1, a = 1 },
cooldownDisableCircle = false,
cooldownCooldownAlpha = 1
})
function Cooldowns:Initialize()
self.cooldownSpellIds = {}
self.spellTextures = {}
for class, t in pairs(self.cooldownSpells) do
for k, v in pairs(t) do
local spellName, _, texture = GetSpellInfo(k)
if spellName then
self.cooldownSpellIds[spellName] = k
self.spellTextures[k] = texture
else
Gladdy:Print("spellid does not exist " .. k)
end
end
end
self:RegisterMessage("ENEMY_SPOTTED")
self:RegisterMessage("SPEC_DETECTED")
self:RegisterMessage("UNIT_DEATH")
end
function Cooldowns:CreateFrame(unit)
local button = Gladdy.buttons[unit]
-- Cooldown frame
local spellCooldownFrame = CreateFrame("Frame", nil, button)
for x = 1, 14 do
local icon = CreateFrame("Frame", nil, spellCooldownFrame)
icon:EnableMouse(false)
icon:SetFrameLevel(3)
icon.texture = icon:CreateTexture(nil, "BACKGROUND")
icon.texture:SetAllPoints(icon)
icon.cooldown = CreateFrame("Cooldown", nil, icon, "CooldownFrameTemplate")
icon.cooldown.noCooldownCount = true
icon.cooldown:SetFrameLevel(4)
icon.cooldown:SetReverse(false)
icon.cooldown:SetHideCountdownNumbers(true)
icon.cooldownFrame = CreateFrame("Frame", nil, icon)
icon.cooldownFrame:ClearAllPoints()
icon.cooldownFrame:SetAllPoints(icon)
icon.cooldownFrame:SetFrameLevel(5)
icon.border = icon.cooldownFrame:CreateTexture(nil, "OVERLAY")
icon.border:SetAllPoints(icon)
icon.border:SetTexture(Gladdy.db.cooldownBorderStyle)
icon.border:SetVertexColor(Gladdy.db.cooldownBorderColor.r, Gladdy.db.cooldownBorderColor.g, Gladdy.db.cooldownBorderColor.b, Gladdy.db.cooldownBorderColor.a)
icon.cooldownFont = icon.cooldownFrame:CreateFontString(nil, "OVERLAY")
icon.cooldownFont:SetFont(Gladdy.LSM:Fetch("font", Gladdy.db.cooldownFont), Gladdy.db.cooldownSize / 2 * Gladdy.db.cooldownFontScale, "OUTLINE")
icon.cooldownFont:SetTextColor(Gladdy.db.cooldownFontColor.r, Gladdy.db.cooldownFontColor.g, Gladdy.db.cooldownFontColor.b, Gladdy.db.cooldownFontColor.a)
icon.cooldownFont:SetAllPoints(icon)
spellCooldownFrame["icon" .. x] = icon
end
button.spellCooldownFrame = spellCooldownFrame
end
function Cooldowns:UpdateFrame(unit)
local button = Gladdy.buttons[unit]
-- Cooldown frame
if (Gladdy.db.cooldown) then
button.spellCooldownFrame:ClearAllPoints()
local verticalMargin = -(Gladdy.db.powerBarHeight)/2
if Gladdy.db.cooldownYPos == "TOP" then
if Gladdy.db.cooldownXPos == "RIGHT" then
button.spellCooldownFrame:SetPoint("BOTTOMRIGHT", button.healthBar, "TOPRIGHT", Gladdy.db.cooldownXOffset, Gladdy.db.highlightBorderSize + Gladdy.db.cooldownYOffset) -- needs to be properly anchored after trinket
else
button.spellCooldownFrame:SetPoint("BOTTOMLEFT", button.healthBar, "TOPLEFT", Gladdy.db.cooldownXOffset, Gladdy.db.highlightBorderSize + Gladdy.db.cooldownYOffset)
end
elseif Gladdy.db.cooldownYPos == "BOTTOM" then
if Gladdy.db.cooldownXPos == "RIGHT" then
button.spellCooldownFrame:SetPoint("TOPRIGHT", button.powerBar, "BOTTOMRIGHT", Gladdy.db.cooldownXOffset, -Gladdy.db.highlightBorderSize + Gladdy.db.cooldownYOffset) -- needs to be properly anchored after trinket
else
button.spellCooldownFrame:SetPoint("TOPLEFT", button.powerBar, "BOTTOMLEFT", Gladdy.db.cooldownXOffset, -Gladdy.db.highlightBorderSize + Gladdy.db.cooldownYOffset)
end
elseif Gladdy.db.cooldownYPos == "LEFT" then
local horizontalMargin = Gladdy.db.highlightBorderSize + Gladdy.db.padding
if (Gladdy.db.trinketPos == "LEFT" and Gladdy.db.trinketEnabled) then
horizontalMargin = horizontalMargin + (Gladdy.db.trinketSize * Gladdy.db.trinketWidthFactor) + Gladdy.db.padding
if (Gladdy.db.classIconPos == "LEFT") then
horizontalMargin = horizontalMargin + (Gladdy.db.classIconSize * Gladdy.db.classIconWidthFactor) + Gladdy.db.padding
end
elseif (Gladdy.db.classIconPos == "LEFT") then
horizontalMargin = horizontalMargin + (Gladdy.db.classIconSize * Gladdy.db.classIconWidthFactor) + Gladdy.db.padding
if (Gladdy.db.trinketPos == "LEFT" and Gladdy.db.trinketEnabled) then
horizontalMargin = horizontalMargin + (Gladdy.db.trinketSize * Gladdy.db.trinketWidthFactor) + Gladdy.db.padding
end
end
if (Gladdy.db.drCooldownPos == "LEFT" and Gladdy.db.drEnabled) then
verticalMargin = verticalMargin + Gladdy.db.drIconSize/2 + Gladdy.db.padding/2
end
if (Gladdy.db.castBarPos == "LEFT") then
verticalMargin = verticalMargin -
((Gladdy.db.castBarHeight < Gladdy.db.castBarIconSize) and Gladdy.db.castBarIconSize
or Gladdy.db.castBarHeight)/2 + Gladdy.db.padding/2
end
if (Gladdy.db.buffsCooldownPos == "LEFT" and Gladdy.db.buffsEnabled) then
verticalMargin = verticalMargin - (Gladdy.db.buffsIconSize/2 + Gladdy.db.padding/2)
end
button.spellCooldownFrame:SetPoint("RIGHT", button.healthBar, "LEFT", -horizontalMargin + Gladdy.db.cooldownXOffset, Gladdy.db.cooldownYOffset + verticalMargin)
elseif Gladdy.db.cooldownYPos == "RIGHT" then
verticalMargin = -(Gladdy.db.powerBarHeight)/2
local horizontalMargin = Gladdy.db.highlightBorderSize + Gladdy.db.padding
if (Gladdy.db.trinketPos == "RIGHT" and Gladdy.db.trinketEnabled) then
horizontalMargin = horizontalMargin + (Gladdy.db.trinketSize * Gladdy.db.trinketWidthFactor) + Gladdy.db.padding
if (Gladdy.db.classIconPos == "RIGHT") then
horizontalMargin = horizontalMargin + (Gladdy.db.classIconSize * Gladdy.db.classIconWidthFactor) + Gladdy.db.padding
end
elseif (Gladdy.db.classIconPos == "RIGHT") then
horizontalMargin = horizontalMargin + (Gladdy.db.classIconSize * Gladdy.db.classIconWidthFactor) + Gladdy.db.padding
if (Gladdy.db.trinketPos == "RIGHT" and Gladdy.db.trinketEnabled) then
horizontalMargin = horizontalMargin + (Gladdy.db.trinketSize * Gladdy.db.trinketWidthFactor) + Gladdy.db.padding
end
end
if (Gladdy.db.drCooldownPos == "RIGHT" and Gladdy.db.drEnabled) then
verticalMargin = verticalMargin + Gladdy.db.drIconSize/2 + Gladdy.db.padding/2
end
if (Gladdy.db.castBarPos == "RIGHT") then
verticalMargin = verticalMargin -
((Gladdy.db.castBarHeight < Gladdy.db.castBarIconSize) and Gladdy.db.castBarIconSize
or Gladdy.db.castBarHeight)/2 + Gladdy.db.padding/2
end
if (Gladdy.db.buffsCooldownPos == "RIGHT" and Gladdy.db.buffsEnabled) then
verticalMargin = verticalMargin - (Gladdy.db.buffsIconSize/2 + Gladdy.db.padding/2)
end
button.spellCooldownFrame:SetPoint("LEFT", button.healthBar, "RIGHT", horizontalMargin + Gladdy.db.cooldownXOffset, Gladdy.db.cooldownYOffset + verticalMargin)
end
button.spellCooldownFrame:SetHeight(Gladdy.db.cooldownSize)
button.spellCooldownFrame:SetWidth(1)
button.spellCooldownFrame:Show()
-- Update each cooldown icon
local o = 1
for j = 1, 14 do
local icon = button.spellCooldownFrame["icon" .. j]
icon:SetHeight(Gladdy.db.cooldownSize)
icon:SetWidth(Gladdy.db.cooldownSize * Gladdy.db.cooldownWidthFactor)
icon.cooldownFont:SetFont(Gladdy.LSM:Fetch("font", Gladdy.db.cooldownFont), Gladdy.db.cooldownSize / 2 * Gladdy.db.cooldownFontScale, "OUTLINE")
icon.cooldownFont:SetTextColor(Gladdy.db.cooldownFontColor.r, Gladdy.db.cooldownFontColor.g, Gladdy.db.cooldownFontColor.b, Gladdy.db.cooldownFontColor.a)
icon:ClearAllPoints()
if (Gladdy.db.cooldownXPos == "RIGHT") then
if (j == 1) then
icon:SetPoint("RIGHT", button.spellCooldownFrame, "RIGHT", 0, 0)
elseif (mod(j-1,Gladdy.db.cooldownMaxIconsPerLine) == 0) then
if (Gladdy.db.cooldownYPos == "BOTTOM" or Gladdy.db.cooldownYPos == "LEFT" or Gladdy.db.cooldownYPos == "RIGHT") then
icon:SetPoint("TOP", button.spellCooldownFrame["icon" .. o], "BOTTOM", 0, -Gladdy.db.cooldownIconPadding)
else
icon:SetPoint("BOTTOM", button.spellCooldownFrame["icon" .. o], "TOP", 0, Gladdy.db.cooldownIconPadding)
end
o = o + tonumber(Gladdy.db.cooldownMaxIconsPerLine)
else
icon:SetPoint("RIGHT", button.spellCooldownFrame["icon" .. j - 1], "LEFT", -Gladdy.db.cooldownIconPadding, 0)
end
end
if (Gladdy.db.cooldownXPos == "LEFT") then
if (j == 1) then
icon:SetPoint("LEFT", button.spellCooldownFrame, "LEFT", 0, 0)
elseif (mod(j-1,Gladdy.db.cooldownMaxIconsPerLine) == 0) then
if (Gladdy.db.cooldownYPos == "BOTTOM" or Gladdy.db.cooldownYPos == "LEFT" or Gladdy.db.cooldownYPos == "RIGHT") then
icon:SetPoint("TOP", button.spellCooldownFrame["icon" .. o], "BOTTOM", 0, -Gladdy.db.cooldownIconPadding)
else
icon:SetPoint("BOTTOM", button.spellCooldownFrame["icon" .. o], "TOP", 0, Gladdy.db.cooldownIconPadding)
end
o = o + tonumber(Gladdy.db.cooldownMaxIconsPerLine)
else
icon:SetPoint("LEFT", button.spellCooldownFrame["icon" .. j - 1], "RIGHT", Gladdy.db.cooldownIconPadding, 0)
end
end
if (icon.active) then
icon.active = false
icon.cooldown:SetCooldown(GetTime(), 0)
icon.cooldownFont:SetText("")
icon:SetScript("OnUpdate", nil)
end
icon.spellId = nil
icon:SetAlpha(1)
icon.texture:SetTexture("Interface\\Icons\\Spell_Holy_PainSupression")
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")
icon.cooldown:SetAlpha(Gladdy.db.cooldownCooldownAlpha)
icon.cooldownFont:SetFont(Gladdy.LSM:Fetch("font", Gladdy.db.cooldownFont), (icon:GetWidth()/2 - 1) * Gladdy.db.cooldownFontScale, "OUTLINE")
icon.cooldownFont:SetTextColor(Gladdy.db.cooldownFontColor.r, Gladdy.db.cooldownFontColor.g, Gladdy.db.cooldownFontColor.b, Gladdy.db.cooldownFontColor.a)
icon.border:SetTexture(Gladdy.db.cooldownBorderStyle)
icon.border:SetVertexColor(Gladdy.db.cooldownBorderColor.r, Gladdy.db.cooldownBorderColor.g, Gladdy.db.cooldownBorderColor.b, Gladdy.db.cooldownBorderColor.a)
icon:Hide()
end
button.spellCooldownFrame:Show()
else
button.spellCooldownFrame:Hide()
end
if (Gladdy.frame.testing) then
self:Test(unit)
end
end
function Cooldowns:Test(unit)
if Gladdy.db.cooldown then
local button = Gladdy.buttons[unit]
button.spellCooldownFrame:Show()
button.lastCooldownSpell = 1
self:UpdateTestCooldowns(unit)
end
end
function Cooldowns:UpdateTestCooldowns(unit)
local button = Gladdy.buttons[unit]
if (button.testSpec and button.testSpec == Gladdy.testData[unit].testSpec) then
button.lastCooldownSpell = 1
self:UpdateCooldowns(button)
button.spec = nil
self:DetectSpec(unit, button.testSpec)
button.test = true
-- use class spells
for k, v in pairs(self.cooldownSpells[button.class]) do
--k is spellId
self:CooldownUsed(unit, button.class, k, nil)
end
-- use race spells
for k, v in pairs(self.cooldownSpells[button.race]) do
self:CooldownUsed(unit, button.race, k, nil)
end
end
end
function Cooldowns:ENEMY_SPOTTED(unit)
self:UpdateCooldowns(Gladdy.buttons[unit])
end
function Cooldowns:SPEC_DETECTED(unit, spec)
self:DetectSpec(unit, spec)
end
function Cooldowns:CooldownStart(button, spellId, duration)
-- starts timer frame
if not duration or duration == nil or type(duration) ~= "number" then
return
end
for i = 1, button.lastCooldownSpell + 1 do
if (button.spellCooldownFrame["icon" .. i].spellId == spellId) then
local frame = button.spellCooldownFrame["icon" .. i]
frame.active = true
frame.timeLeft = duration
if (not Gladdy.db.cooldownDisableCircle) then frame.cooldown:SetCooldown(GetTime(), duration) end
frame:SetScript("OnUpdate", function(self, elapsed)
self.timeLeft = self.timeLeft - elapsed
local timeLeft = ceil(self.timeLeft)
if timeLeft >= 540 then
self.cooldownFont:SetText(ceil(timeLeft / 60) .. "m")
self.cooldownFont:SetFont(Gladdy.LSM:Fetch("font", Gladdy.db.cooldownFont), Gladdy.db.cooldownSize / 3.1 * Gladdy.db.cooldownFontScale, "OUTLINE")
elseif timeLeft < 540 and timeLeft >= 60 then
-- more than 1 minute
self.cooldownFont:SetText(ceil(timeLeft / 60) .. "m")
self.cooldownFont:SetFont(Gladdy.LSM:Fetch("font", Gladdy.db.cooldownFont), Gladdy.db.cooldownSize / 2.15 * Gladdy.db.cooldownFontScale, "OUTLINE")
elseif timeLeft < 60 and timeLeft > 0 then
-- between 60s and 21s (green)
self.cooldownFont:SetFont(Gladdy.LSM:Fetch("font", Gladdy.db.cooldownFont), Gladdy.db.cooldownSize / 2.15 * Gladdy.db.cooldownFontScale, "OUTLINE")
self.cooldownFont:SetText(timeLeft)
else
self.cooldownFont:SetText("")
end
if (self.timeLeft <= 0) then
Cooldowns:CooldownReady(button, spellId, frame)
end
if (self.timeLeft <= 0) then
Cooldowns:CooldownReady(button, spellId, frame)
end
end)
end
end
end
function Cooldowns:CooldownReady(button, spellId, frame)
if (frame == false) then
for i = 1, button.lastCooldownSpell do
frame = button.spellCooldownFrame["icon" .. i]
if (frame.spellId == spellId) then
frame.active = false
frame.cooldown:Hide()
frame.cooldownFont:SetText("")
frame:SetScript("OnUpdate", nil)
end
end
else
frame.active = false
frame.cooldown:Hide()
frame.cooldownFont:SetText("")
frame:SetScript("OnUpdate", nil)
end
end
function Cooldowns:DetectSpec(unit, spec)
local button = Gladdy.buttons[unit]
if (not button or not spec or button.spec) then
return
end
button.spec = spec
if not button.test then
Gladdy:SendMessage("UNIT_SPEC", unit, spec)
end
-- update cooldown tracker
--[[
All of this could possibly be handled in a "once they're used, they show up"-manner
but I PERSONALLY prefer it this way. It also meant less work and makes spec-specific cooldowns easier
]]
if (Gladdy.db.cooldown) then
local class = Gladdy.buttons[unit].class
local race = Gladdy.buttons[unit].race
for k, v in pairs(self.cooldownSpells[class]) do
--if (self.db.cooldownList[k] ~= false and self.db.cooldownList[class] ~= false) then
if (type(v) == "table" and ((v.spec ~= nil and v.spec == spec) or (v.notSpec ~= nil and v.notSpec ~= spec))) then
local sharedCD = false
if (type(v) == "table" and v.sharedCD ~= nil and v.sharedCD.cd == nil) then
for spellId, _ in pairs(v.sharedCD) do
for i = 1, button.lastCooldownSpell do
local icon = button.spellCooldownFrame["icon" .. i]
if (icon.spellId == spellId) then
sharedCD = true
end
end
end
end
if sharedCD then
return
end
local icon = button.spellCooldownFrame["icon" .. button.lastCooldownSpell]
icon:Show()
icon.texture:SetTexture(self.spellTextures[k])
icon.spellId = k
button.spellCooldownFrame["icon" .. button.lastCooldownSpell] = icon
button.lastCooldownSpell = button.lastCooldownSpell + 1
end
end
--end
end
----------------------
--- RACE FUNCTIONALITY
----------------------
local race = Gladdy.buttons[unit].race
if self.cooldownSpells[race] then
for k, v in pairs(self.cooldownSpells[race]) do
--if (self.db.cooldownList[k] ~= false and self.db.cooldownList[class] ~= false) then
if (type(v) == "table" and ((v.spec ~= nil and v.spec == spec) or (v.notSpec ~= nil and v.notSpec ~= spec))) then
local sharedCD = false
if (type(v) == "table" and v.sharedCD ~= nil and v.sharedCD.cd == nil) then
for spellId, _ in pairs(v.sharedCD) do
for i = 1, button.lastCooldownSpell do
local icon = button.spellCooldownFrame["icon" .. i]
if (icon.spellId == spellId) then
sharedCD = true
end
end
end
end
if sharedCD then
return
end
local icon = button.spellCooldownFrame["icon" .. button.lastCooldownSpell]
icon:Show()
icon.texture:SetTexture(self.spellTextures[k])
icon.spellId = k
button.spellCooldownFrame["icon" .. button.lastCooldownSpell] = icon
button.lastCooldownSpell = button.lastCooldownSpell + 1
end
end
end
end
function Cooldowns:ResetUnit(unit)
Gladdy.buttons[unit].lastCooldownSpell = nil
Gladdy.buttons[unit].test = nil
end
function Cooldowns:UpdateCooldowns(button)
local class = button.class
local race = button.race
if ( not button.lastCooldownSpell) then
button.lastCooldownSpell = 1
end
if (Gladdy.db.cooldown) then
for k, v in pairs(self.cooldownSpells[class]) do
if (type(v) ~= "table" or (type(v) == "table" and v.spec == nil and v.notSpec == nil)) then
-- see if we have shared cooldowns without a cooldown defined
-- e.g. hunter traps have shared cooldowns, so only display one trap instead all of them
local sharedCD = false
if (type(v) == "table" and v.sharedCD ~= nil and v.sharedCD.cd == nil) then
for spellId, _ in pairs(v.sharedCD) do
for i = 1, button.lastCooldownSpell do
local icon = button.spellCooldownFrame["icon" .. i]
if (icon.spellId == spellId) then
sharedCD = true
end
end
end
end
if (not sharedCD) then
local icon = button.spellCooldownFrame["icon" .. button.lastCooldownSpell]
icon:Show()
icon.spellId = k
icon.texture:SetTexture(self.spellTextures[k])
button.spellCooldownFrame["icon" .. button.lastCooldownSpell] = icon
button.lastCooldownSpell = button.lastCooldownSpell + 1
end
end
end
----
-- RACE FUNCTIONALITY
----
for k, v in pairs(self.cooldownSpells[race]) do
if (type(v) ~= "table" or (type(v) == "table" and v.spec == nil and v.notSpec == nil)) then
local icon = button.spellCooldownFrame["icon" .. button.lastCooldownSpell]
icon:Show()
icon.spellId = k
icon.texture:SetTexture(self.spellTextures[k])
button.spellCooldownFrame["icon" .. button.lastCooldownSpell] = icon
button.lastCooldownSpell = button.lastCooldownSpell + 1
end
end
end
end
function Cooldowns:CooldownUsed(unit, unitClass, spellId, spellName)
local button = Gladdy.buttons[unit]
if not button then
return
end
-- if (self.db.cooldownList[spellId] == false) then return end
local cooldown = self.cooldownSpells[unitClass][spellId]
local cd = cooldown
if (type(cooldown) == "table") then
-- return if the spec doesn't have a cooldown for this spell
--if (arenaSpecs[unit] ~= nil and cooldown.notSpec ~= nil and arenaSpecs[unit] == cooldown.notSpec) then return end
if (button.spec ~= nil and cooldown.notSpec ~= nil and button.spec == cooldown.notSpec) then
return
end
-- check if we need to reset other cooldowns because of this spell
if (cooldown.resetCD ~= nil) then
for k, v in pairs(cooldown.resetCD) do
self:CooldownReady(button, k, false)
end
end
-- check if there is a special cooldown for the units spec
--if (arenaSpecs[unit] ~= nil and cooldown[arenaSpecs[unit]] ~= nil) then
if (button.spec ~= nil and cooldown[button.spec] ~= nil) then
cd = cooldown[button.spec]
else
cd = cooldown.cd
end
-- check if there is a shared cooldown with an other spell
if (cooldown.sharedCD ~= nil) then
local sharedCD = cooldown.sharedCD.cd and cooldown.sharedCD.cd or cd
for k, v in pairs(cooldown.sharedCD) do
if (k ~= "cd") then
self:CooldownStart(button, k, sharedCD)
end
end
end
end
if (Gladdy.db.cooldown) then
-- start cooldown
self:CooldownStart(button, spellId, cd)
end
--[[ announcement
if (self.db.cooldownAnnounce or self.db.cooldownAnnounceList[spellId] or self.db.cooldownAnnounceList[unitClass]) then
self:SendAnnouncement(string.format(L["COOLDOWN USED: %s (%s) used %s - %s sec. cooldown"], UnitName(unit), UnitClass(unit), spellName, cd), RAID_CLASS_COLORS[UnitClass(unit)], self.db.cooldownAnnounceList[spellId] and self.db.cooldownAnnounceList[spellId] or self.db.announceType)
end]]
--[[ sound file
if (db.cooldownSoundList[spellId] ~= nil and db.cooldownSoundList[spellId] ~= "disabled") then
PlaySoundFile(LSM:Fetch(LSM.MediaType.SOUND, db.cooldownSoundList[spellId]))
end ]]
end
local function 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
if Gladdy.db.cooldownYPos == "LEFT" then
Gladdy.db.cooldownXPos = "RIGHT"
elseif Gladdy.db.cooldownYPos == "RIGHT" then
Gladdy.db.cooldownXPos = "LEFT"
end
Gladdy:UpdateFrame()
end,
}
for k, v in pairs(params) do
defaults[k] = v
end
return defaults
end
function Cooldowns:GetOptions()
return {
headerCooldown = {
type = "header",
name = L["Cooldown"],
order = 2,
},
cooldown = Gladdy:option({
type = "toggle",
name = L["Enable"],
desc = L["Enabled cooldown module"],
order = 2,
}),
group = {
type = "group",
childGroups = "tree",
name = "Frame",
order = 3,
args = {
icon = {
type = "group",
name = L["Icon"],
order = 1,
args = {
headerIcon = {
type = "header",
name = L["Icon"],
order = 2,
},
cooldownSize = Gladdy:option({
type = "range",
name = L["Cooldown size"],
desc = L["Size of each cd icon"],
order = 4,
min = 5,
max = (Gladdy.db.healthBarHeight + Gladdy.db.castBarHeight + Gladdy.db.powerBarHeight + Gladdy.db.bottomMargin) / 2,
}),
cooldownWidthFactor = Gladdy:option({
type = "range",
name = L["Icon Width Factor"],
desc = L["Stretches the icon"],
order = 5,
min = 0.5,
max = 2,
step = 0.05,
}),
cooldownIconPadding = Gladdy:option({
type = "range",
name = L["Icon Padding"],
desc = L["Space between Icons"],
order = 6,
min = 0,
max = 10,
step = 0.1,
}),
cooldownMaxIconsPerLine = Gladdy:option({
type = "range",
name = L["Max Icons per row"],
order = 7,
min = 3,
max = 14,
step = 1,
}),
},
},
cooldown = {
type = "group",
name = L["Cooldown"],
order = 2,
args = {
header = {
type = "header",
name = L["Cooldown"],
order = 2,
},
cooldownDisableCircle = Gladdy:option({
type = "toggle",
name = L["No Cooldown Circle"],
order = 8,
}),
cooldownCooldownAlpha = Gladdy:option({
type = "range",
name = L["Cooldown circle alpha"],
min = 0,
max = 1,
step = 0.1,
order = 9,
}),
},
},
font = {
type = "group",
name = L["Font"],
order = 3,
args = {
header = {
type = "header",
name = L["Font"],
order = 2,
},
cooldownFont = Gladdy:option({
type = "select",
name = L["Font"],
desc = L["Font of the cooldown"],
order = 11,
dialogControl = "LSM30_Font",
values = AceGUIWidgetLSMlists.font,
}),
cooldownFontScale = Gladdy:option({
type = "range",
name = L["Font scale"],
desc = L["Scale of the font"],
order = 12,
min = 0.1,
max = 2,
step = 0.1,
}),
cooldownFontColor = Gladdy:colorOption({
type = "color",
name = L["Font color"],
desc = L["Color of the text"],
order = 13,
hasAlpha = true,
}),
},
},
position = {
type = "group",
name = L["Position"],
order = 4,
args = {
header = {
type = "header",
name = L["Position"],
order = 2,
},
cooldownYPos = option({
type = "select",
name = L["Anchor"],
desc = L["Anchor of the cooldown icons"],
order = 3,
values = {
["TOP"] = L["Top"],
["BOTTOM"] = L["Bottom"],
["LEFT"] = L["Left"],
["RIGHT"] = L["Right"],
},
}),
cooldownXPos = Gladdy:option({
type = "select",
name = L["Grow Direction"],
desc = L["Grow Direction of the cooldown icons"],
order = 4,
values = {
["LEFT"] = L["Right"],
["RIGHT"] = L["Left"],
},
}),
headerOffset = {
type = "header",
name = L["Offset"],
order = 5,
},
cooldownXOffset = Gladdy:option({
type = "range",
name = L["Horizontal offset"],
order = 6,
min = -400,
max = 400,
step = 0.1,
}),
cooldownYOffset = Gladdy:option({
type = "range",
name = L["Vertical offset"],
order = 7,
min = -400,
max = 400,
step = 0.1,
}),
},
},
border = {
type = "group",
name = L["Border"],
order = 5,
args = {
header = {
type = "header",
name = L["Border"],
order = 2,
},
cooldownBorderStyle = Gladdy:option({
type = "select",
name = L["Border style"],
order = 31,
values = Gladdy:GetIconStyles()
}),
cooldownBorderColor = Gladdy:colorOption({
type = "color",
name = L["Border color"],
desc = L["Color of the border"],
order = 32,
hasAlpha = true,
}),
},
},
},
},
}
end
function Gladdy:UpdateTestCooldowns(i)
local unit = "arena" .. i
local button = Gladdy.buttons[unit]
if (button.testSpec and button.testSpec == Gladdy.testData[unit].testSpec) then
button.lastCooldownSpell = 1
Cooldowns:UpdateCooldowns(button)
button.spec = nil
Cooldowns:DetectSpec(unit, button.testSpec)
-- use class spells
for k, v in pairs(Cooldowns.cooldownSpells[button.class]) do
--k is spellId
Cooldowns:CooldownUsed(unit, button.class, k, nil)
end
-- use race spells
for k, v in pairs(Cooldowns.cooldownSpells[button.race]) do
Cooldowns:CooldownUsed(unit, button.race, k, nil)
end
end
end
Cooldowns.cooldownSpells = {
-- Spell Name Cooldown[, Spec]
-- Mage
["MAGE"] = {
[1953] = 15, -- Blink
--[122] = 22, -- Frost Nova
--[12051] = 480, --Evocation
[2139] = 24, -- Counterspell
[45438] = { cd = 300, [L["Frost"]] = 240, }, -- Ice Block
[12472] = { cd = 180, spec = L["Frost"], }, -- Icy Veins
[31687] = { cd = 180, spec = L["Frost"], }, -- Summon Water Elemental
[12043] = { cd = 180, spec = L["Arcane"], }, -- Presence of Mind
[11129] = { cd = 180, spec = L["Fire"] }, -- Combustion
[120] = { cd = 10,
sharedCD = {
[31661] = true, -- Cone of Cold
}, spec = L["Fire"] }, -- Dragon's Breath
[31661] = { cd = 20,
sharedCD = {
[120] = true, -- Cone of Cold
}, spec = L["Fire"] }, -- Dragon's Breath
[12042] = { cd = 180, spec = L["Arcane"], }, -- Arcane Power
[11958] = { cd = 384, spec = L["Frost"], -- Coldsnap
resetCD = {
[12472] = true,
[45438] = true,
[31687] = true,
},
},
},
-- Priest
["PRIEST"] = {
[10890] = { cd = 27, [L["Shadow"]] = 23, }, -- Psychic Scream
[15487] = { cd = 45, spec = L["Shadow"], }, -- Silence
[10060] = { cd = 180, spec = L["Discipline"], }, -- Power Infusion
[33206] = { cd = 120, spec = L["Discipline"], }, -- Pain Suppression
[34433] = 300, -- Shadowfiend
},
-- Druid
["DRUID"] = {
[22812] = 60, -- Barkskin
[29166] = 360, -- Innervate
[8983] = 60, -- Bash
[16689] = 60, -- Natures Grasp
[17116] = { cd = 180, spec = L["Restoration"], }, -- Natures Swiftness
[33831] = { cd = 180, spec = L["Balance"], }, -- Force of Nature
},
-- Shaman
["SHAMAN"] = {
[8042] = { cd = 6, -- Earth Shock
sharedCD = {
[8056] = true, -- Frost Shock
[8050] = true, -- Flame Shock
},
},
[30823] = { cd = 120, spec = L["Enhancement"], }, -- Shamanistic Rage
[16166] = { cd = 180, spec = L["Elemental"], }, -- Elemental Mastery
[16188] = { cd = 180, spec = L["Restoration"], }, -- Natures Swiftness
[16190] = { cd = 300, spec = L["Restoration"], }, -- Mana Tide Totem
},
-- Paladin
["PALADIN"] = {
[10278] = 180, -- Blessing of Protection
[1044] = 25, -- Blessing of Freedom
[10308] = { cd = 60, [L["Retribution"]] = 40, }, -- Hammer of Justice
[642] = { cd = 300, -- Divine Shield
sharedCD = {
cd = 60, -- no actual shared CD but debuff
[31884] = true,
},
},
[31884] = { cd = 180, spec = L["Retribution"], -- Avenging Wrath
sharedCD = {
cd = 60,
[642] = true,
},
},
[20066] = { cd = 60, spec = L["Retribution"], }, -- Repentance
[31842] = { cd = 180, spec = L["Holy"], }, -- Divine Illumination
[31935] = { cd = 30, spec = L["Protection"], }, -- Avengers Shield
},
-- Warlock
["WARLOCK"] = {
[17928] = 40, -- Howl of Terror
[27223] = 120, -- Death Coil
--[19647] = { cd = 24 }, -- Spell Lock; how will I handle pet spells?
[30414] = { cd = 20, spec = L["Destruction"], }, -- Shadowfury
[17877] = { cd = 15, spec = L["Destruction"], }, -- Shadowburn
[18708] = { cd = 900, spec = L["Demonology"], }, -- Feldom
},
-- Warrior
["WARRIOR"] = {
--[[6552] = { cd = 10, -- Pummel
sharedCD = {
[72] = true,
},
},
[72] = { cd = 12, -- Shield Bash
sharedCD = {
[6552] = true,
},
}, ]]
--[23920] = 10, -- Spell Reflection
[3411] = 30, -- Intervene
[676] = 60, -- Disarm
[5246] = 180, -- Intimidating Shout
--[2565] = 60, -- Shield Block
[12292] = { cd = 180, spec = L["Arms"], }, -- Death Wish
[12975] = { cd = 180, spec = L["Protection"], }, -- Last Stand
[12809] = { cd = 30, spec = L["Protection"], }, -- Concussion Blow
},
-- Hunter
["HUNTER"] = {
[19503] = 30, -- Scatter Shot
[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
sharedCD = {
[14311] = true, -- Freezing Trap
[34600] = true, -- Snake Trap
},
},
[34600] = { cd = 30, -- Snake Trap
sharedCD = {
[14311] = true, -- Freezing Trap
[13809] = true, -- Frost Trap
},
},
[34490] = { cd = 20, spec = L["Marksmanship"], }, -- Silencing Shot
[19386] = { cd = 60, spec = L["Survival"], }, -- Wyvern Sting
[19577] = { cd = 60, spec = L["Beast Mastery"], }, -- Intimidation
[38373] = { cd = 120, spec = L["Beast Mastery"], }, -- The Beast Within
},
-- Rogue
["ROGUE"] = {
[1766] = 10, -- Kick
[8643] = 20, -- Kidney Shot
[31224] = 60, -- Cloak of Shadow
[26889] = { cd = 300, [L["Subtlety"]] = 180, }, -- Vanish
[2094] = { cd = 180, [L["Subtlety"]] = 90, }, -- Blind
[11305] = { cd = 300, [L["Combat"]] = 180, }, -- Sprint
[26669] = { cd = 300, [L["Combat"]] = 180, }, -- Evasion
[14177] = { cd = 180, spec = L["Assassination"], }, -- Cold Blood
[13750] = { cd = 300, spec = L["Combat"], }, -- Adrenaline Rush
[13877] = { cd = 120, spec = L["Combat"], }, -- Blade Flurry
[36554] = { cd = 30, spec = L["Subtlety"], }, -- Shadowstep
[14185] = { cd = 600, spec = L["Subtlety"], -- Preparation
resetCD = {
[26669] = true,
[11305] = true,
[26889] = true,
[14177] = true,
[36554] = true,
},
},
},
["Scourge"] = {
[7744] = 120, -- Will of the Forsaken
},
["BloodElf"] = {
[28730] = 120, -- Arcane Torrent
},
["Tauren"] = {
[20549] = 120, -- War Stomp
},
["Orc"] = {
},
["Troll"] = {
},
["NightElf"] = {
[2651] = { cd = 180, spec = L["Discipline"], }, -- Elune's Grace
[10797] = { cd = 30, spec = L["Discipline"], }, -- Star Shards
},
["Draenei"] = {
[32548] = { cd = 300, spec = L["Discipline"], }, -- Hymn of Hope
},
["Human"] = {
[13908] = { cd = 600, spec = L["Discipline"], }, -- Desperate Prayer
[20600] = 180, -- Perception
},
["Gnome"] = {
[20589] = 105, -- Escape Artist
},
["Dwarf"] = {
[20594] = 180, -- Stoneform
[13908] = { cd = 600, spec = L["Discipline"], }, -- Desperate Prayer
},
}

677
Modules/Diminishings.lua Normal file
View File

@ -0,0 +1,677 @@
local select = select
local pairs,ipairs,tbl_sort,tinsert,format = pairs,ipairs,table.sort,tinsert,format
local drDuration = 18
local GetSpellInfo = GetSpellInfo
local CreateFrame = CreateFrame
local GetTime = GetTime
local Gladdy = LibStub("Gladdy")
local DRData = LibStub("DRData-1.0")
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)
for i,v in ipairs(indexList) do
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,
drCooldownPos = "RIGHT",
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 },
drWidthFactor = 1,
drCategories = defaultCategories()
})
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
function Diminishings:Initialize()
self.frames = {}
self:RegisterMessage("UNIT_DEATH", "ResetUnit", "AURA_FADE")
end
function Diminishings:CreateFrame(unit)
local drFrame = CreateFrame("Frame", nil, Gladdy.buttons[unit])
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")
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
if self.timeLeft >=5 then
self.timeText:SetFormattedText("%d", self.timeLeft)
else
self.timeText:SetFormattedText("%.1f", self.timeLeft)
end
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")
icon.text:SetFont(Gladdy.LSM:Fetch("font", Gladdy.db.drFont), 10, "OUTLINE")
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")
icon.timeText:SetFont(Gladdy.LSM:Fetch("font", Gladdy.db.drFont), 10, "OUTLINE")
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)
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
drFrame:ClearAllPoints()
local horizontalMargin = Gladdy.db.highlightBorderSize + Gladdy.db.padding
local verticalMargin = -(Gladdy.db.powerBarHeight)/2
if (Gladdy.db.drCooldownPos == "LEFT") then
if (Gladdy.db.trinketPos == "LEFT" and Gladdy.db.trinketEnabled) then
horizontalMargin = horizontalMargin + (Gladdy.db.trinketSize * Gladdy.db.trinketWidthFactor) + Gladdy.db.padding
if (Gladdy.db.classIconPos == "LEFT") then
horizontalMargin = horizontalMargin + (Gladdy.db.classIconSize * Gladdy.db.classIconWidthFactor) + Gladdy.db.padding
end
elseif (Gladdy.db.classIconPos == "LEFT") then
horizontalMargin = horizontalMargin + (Gladdy.db.classIconSize * Gladdy.db.classIconWidthFactor) + Gladdy.db.padding
if (Gladdy.db.trinketPos == "LEFT" and Gladdy.db.trinketEnabled) then
horizontalMargin = horizontalMargin + (Gladdy.db.trinketSize * Gladdy.db.trinketWidthFactor) + Gladdy.db.padding
end
end
if (Gladdy.db.castBarPos == "LEFT") then
verticalMargin = verticalMargin -
(((Gladdy.db.castBarHeight < Gladdy.db.castBarIconSize) and Gladdy.db.castBarIconSize
or Gladdy.db.castBarHeight)/2 + Gladdy.db.padding/2)
end
if (Gladdy.db.cooldownYPos == "LEFT" and Gladdy.db.cooldown) then
verticalMargin = verticalMargin - (Gladdy.db.cooldownSize/2 + Gladdy.db.padding/2)
end
if (Gladdy.db.buffsCooldownPos == "LEFT" and Gladdy.db.buffsEnabled) then
verticalMargin = verticalMargin - (Gladdy.db.buffsIconSize/2 + Gladdy.db.padding/2)
end
drFrame:SetPoint("RIGHT", Gladdy.buttons[unit].healthBar, "LEFT", -horizontalMargin + Gladdy.db.drXOffset, Gladdy.db.drYOffset + verticalMargin)
end
if (Gladdy.db.drCooldownPos == "RIGHT") then
if (Gladdy.db.trinketPos == "RIGHT" and Gladdy.db.trinketEnabled) then
horizontalMargin = horizontalMargin + (Gladdy.db.trinketSize * Gladdy.db.trinketWidthFactor) + Gladdy.db.padding
if (Gladdy.db.classIconPos == "RIGHT") then
horizontalMargin = horizontalMargin + (Gladdy.db.classIconSize * Gladdy.db.classIconWidthFactor) + Gladdy.db.padding
end
elseif (Gladdy.db.classIconPos == "RIGHT") then
horizontalMargin = horizontalMargin + (Gladdy.db.classIconSize * Gladdy.db.classIconWidthFactor) + Gladdy.db.padding
if (Gladdy.db.trinketPos == "RIGHT" and Gladdy.db.trinketEnabled) then
horizontalMargin = horizontalMargin + (Gladdy.db.trinketSize * Gladdy.db.trinketWidthFactor) + Gladdy.db.padding
end
end
if (Gladdy.db.castBarPos == "RIGHT") then
verticalMargin = verticalMargin -
(((Gladdy.db.castBarHeight < Gladdy.db.castBarIconSize) and Gladdy.db.castBarIconSize
or Gladdy.db.castBarHeight)/2 + Gladdy.db.padding/2)
end
if (Gladdy.db.cooldownYPos == "RIGHT" and Gladdy.db.cooldown) then
verticalMargin = verticalMargin - (Gladdy.db.cooldownSize/2 + Gladdy.db.padding/2)
end
if (Gladdy.db.buffsCooldownPos == "RIGHT" and Gladdy.db.buffsEnabled) then
verticalMargin = verticalMargin - (Gladdy.db.buffsIconSize/2 + Gladdy.db.padding/2)
end
drFrame:SetPoint("LEFT", Gladdy.buttons[unit].healthBar, "RIGHT", horizontalMargin + Gladdy.db.drXOffset, Gladdy.db.drYOffset + verticalMargin)
end
drFrame:SetWidth(Gladdy.db.drIconSize * 16)
drFrame:SetHeight(Gladdy.db.drIconSize)
for i = 1, 16 do
local icon = drFrame["icon" .. i]
icon:SetWidth(Gladdy.db.drIconSize * Gladdy.db.drWidthFactor)
icon:SetHeight(Gladdy.db.drIconSize)
icon.text:SetFont(Gladdy.LSM:Fetch("font", Gladdy.db.drFont), (Gladdy.db.drIconSize/2 - 1) * Gladdy.db.drFontScale, "OUTLINE")
icon.text:SetTextColor(Gladdy.db.drFontColor.r, Gladdy.db.drFontColor.g, Gladdy.db.drFontColor.b, Gladdy.db.drFontColor.a)
icon.timeText:SetFont(Gladdy.LSM:Fetch("font", Gladdy.db.drFont), (Gladdy.db.drIconSize/2 - 1) * Gladdy.db.drFontScale, "OUTLINE")
icon.timeText:SetTextColor(Gladdy.db.drFontColor.r, Gladdy.db.drFontColor.g, Gladdy.db.drFontColor.b, Gladdy.db.drFontColor.a)
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
icon:ClearAllPoints()
if (Gladdy.db.drCooldownPos == "LEFT") then
if (i == 1) then
icon:SetPoint("TOPRIGHT")
else
icon:SetPoint("RIGHT", drFrame["icon" .. (i - 1)], "LEFT", -Gladdy.db.drIconPadding, 0)
end
else
if (i == 1) then
icon:SetPoint("TOPLEFT")
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
icon.texture:SetTexCoord(.1, .9, .1, .9)
icon.texture:SetPoint("TOPLEFT", icon, "TOPLEFT", 2, -2)
icon.texture:SetPoint("BOTTOMRIGHT", icon, "BOTTOMRIGHT", -2, 2)
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
function Diminishings:Test(unit)
if Gladdy.db.drEnabled then
local spells = { 33786, 118, 8643, 8983 }
for i = 1, 4 do
if i == 1 then
self:AuraFade(unit, spells[i])
elseif i == 2 then
self:AuraFade(unit, spells[i])
self:AuraFade(unit, spells[i])
else
self:AuraFade(unit, spells[i])
self:AuraFade(unit, spells[i])
self:AuraFade(unit, spells[i])
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
lastIcon.dr = drCat
lastIcon.timeLeft = drDuration
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
lastIcon.cooldown:SetCooldown(GetTime(), drDuration)
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()
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()
if (Gladdy.db.drCooldownPos == "LEFT") then
if (not lastIcon) then
icon:SetPoint("TOPRIGHT")
else
icon:SetPoint("RIGHT", lastIcon, "LEFT", -Gladdy.db.drIconPadding, 0)
end
else
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",
name = L["Enable"],
desc = L["Enabled DR module"],
order = 3,
}),
group = {
type = "group",
childGroups = "tree",
name = "Frame",
order = 4,
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,
max = 50,
step = 1,
}),
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,
}),
drIconPadding = Gladdy:option({
type = "range",
name = L["Icon Padding"],
desc = L["Space between Icons"],
order = 7,
min = 0,
max = 10,
step = 0.1,
}),
},
},
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,
}),
drCooldownAlpha = Gladdy:option({
type = "range",
name = L["Cooldown circle alpha"],
min = 0,
max = 1,
step = 0.1,
order = 9,
}),
},
},
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,
}),
}
},
position = {
type = "group",
name = L["Position"],
order = 4,
args = {
headerPosition = {
type = "header",
name = L["Position"],
order = 20,
},
drCooldownPos = Gladdy:option({
type = "select",
name = L["DR Cooldown position"],
desc = L["Position of the cooldown icons"],
order = 21,
values = {
["LEFT"] = L["Left"],
["RIGHT"] = L["Right"],
},
}),
headerOffset = {
type = "header",
name = L["Offset"],
order = 22,
},
drXOffset = Gladdy:option({
type = "range",
name = L["Horizontal offset"],
order = 23,
min = -400,
max = 400,
step = 0.1,
}),
drYOffset = Gladdy:option({
type = "range",
name = L["Vertical offset"],
order = 24,
min = -400,
max = 400,
step = 0.1,
}),
},
},
border = {
type = "group",
name = L["Border"],
order = 5,
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 = {}
local indexList = {}
for k,v in pairs(DRData:GetCategories()) do
tinsert(indexList, k)
end
tbl_sort(indexList)
for i, k in ipairs(indexList) do
categories[k] = {
type = "group",
name = DRData:GetCategoryName(k),
order = i,
icon = Gladdy.db.drCategories[k].icon,
args = {
enabled = {
type = "toggle",
name = L["Enabled"],
order = 1,
get = function(info)
return Gladdy.db.drCategories[k].enabled
end,
set = function(info, value)
Gladdy.db.drCategories[k].enabled = value
end,
},
forceIcon = {
type = "toggle",
name = L["Force Icon"],
order = 2,
get = function(info)
return Gladdy.db.drCategories[k].forceIcon
end,
set = function(info, value)
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),
get = function(info)
return Gladdy.db.drCategories[k].icon
end,
set = function(info, value)
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

197
Modules/ExportImport.lua Normal file
View File

@ -0,0 +1,197 @@
local type, pairs = type, pairs
local Gladdy = LibStub("Gladdy")
local AceSerializer = LibStub("AceSerializer-3.0")
local L = Gladdy.L
local AceGUI = LibStub("AceGUI-3.0")
local LibDeflate = LibStub:GetLibrary("LibDeflate")
local function table_copy(t)
local t2 = {};
for k,v in pairs(t) do
if type(v) == "table" then
t2[k] = table_copy(v);
else
t2[k] = v;
end
end
return t2;
end
local function applyImport(t)
for k,v in pairs(t) do
if type(v) == "table" then
applyImport(v, Gladdy.dbi.profile[k]);
else
Gladdy.dbi.profile[k] = v;
end
end
end
local ExportImport = Gladdy:NewModule("ExportImport", nil, {
})
local export = AceGUI:Create("Frame")
export:SetWidth(550)
export.sizer_se:Hide()
export:SetStatusText("")
export:SetLayout("Flow")
export:SetTitle("Export")
export:Hide()
local exportEditBox = AceGUI:Create("MultiLineEditBox")
exportEditBox:SetLabel('ExportString')
exportEditBox:SetNumLines(29)
exportEditBox:SetText("")
exportEditBox:SetWidth(500)
exportEditBox.button:Hide()
exportEditBox.frame:SetClipsChildren(true)
export:AddChild(exportEditBox)
export.eb = exportEditBox
local import = AceGUI:Create("Frame")
import:SetWidth(550)
import:Hide()
import:SetLayout("Flow")
import.sizer_se:Hide()
import:SetStatusText("")
import:SetTitle("Import")
import:SetCallback("OnClose", function(widget)
import.eb:SetCallback("OnTextChanged", nil)
end)
local importEditBox = AceGUI:Create("MultiLineEditBox")
importEditBox:SetLabel('ImportString')
importEditBox:SetNumLines(23)
importEditBox:SetText("")
importEditBox:SetWidth(500)
importEditBox.button:Hide()
importEditBox.frame:SetClipsChildren(true)
import:AddChild(importEditBox)
import.eb = importEditBox
local importButton = AceGUI:Create("Button")
importButton:SetText("Import\n(this will overwrite your current profile!)")
importButton:SetWidth(200)
importButton:SetHeight(50)
importButton:SetCallback("OnClick", function(widget)
applyImport(import.deserializedTable)
Gladdy:UpdateFrame()
import:Hide()
end)
import:AddChild(importButton)
import.button = importButton
local importClearButton = AceGUI:Create("Button")
importClearButton:SetText("Clear")
importClearButton:SetWidth(200)
importClearButton:SetCallback("OnClick", function(widget)
import.eb:SetText("")
import.eb:SetFocus()
import.button.frame:Disable()
import:SetStatusText("Invalid Import String")
import.statustext:SetTextColor(1,0,0)
end)
import:AddChild(importClearButton)
import.clearButton = importClearButton
function ExportImport:CheckDeserializedOptions(tbl, refTbl, str)
if str == nil and not tbl.version_major then
return false, "Version conflict: version_major not seen"
end
if str == nil and tbl.version_major ~= Gladdy.version_major then
return false, "Version conflict: " .. tbl.version_major .. " ~= " .. Gladdy.version_major
end
if str == nil then
str = "Gladdy.db"
tbl.version_major = nil
end
if type(tbl) == "table" then
for k,v in pairs(tbl) do
if refTbl[k] ~= nil then
if type(v) ~= type(refTbl[k]) then
return false, str .. "." .. k .. " type error. Expected " .. type(refTbl[k]) .. " found " .. type(v)
end
ExportImport:CheckDeserializedOptions(v, refTbl[k], str .. "." .. k)
else
return false, str .. "." .. k .. " does not exist"
end
end
end
return true
end
local dump
local printable_compressed
function ExportImport:GetOptions()
return {
headerProfileClassic = {
type = "header",
name = L["Profile Export Import"],
order = 2,
},
export = {
type = "execute",
func = function()
local db = table_copy(Gladdy.db)
db.version_major = Gladdy.version_major
dump = AceSerializer:Serialize(db)
local compress_deflate = LibDeflate:CompressZlib(dump)
printable_compressed = LibDeflate:EncodeForPrint(compress_deflate)
export.eb:SetText(printable_compressed)
export:Show()
export.eb:SetFocus()
export.eb:HighlightText(0, export.eb.editBox:GetNumLetters())
export:SetStatusText("Copy this string to share your configuration with others.")
end,
name = "Export",
desc = "Export your current profile to share with others or your various accounts.",
order = 3,
},
import = {
type = "execute",
func = function()
import.eb:SetText("")
import:Show()
import:SetStatusText("Invalid Import String")
import.button.frame:Disable()
import.statustext:SetTextColor(1,0,0)
import.eb:SetFocus()
import.eb:SetCallback("OnTextChanged", function(widget)
local decoded_string = LibDeflate:DecodeForPrint(widget:GetText())
if not decoded_string then
import.statustext:SetTextColor(1,0,0)
import:SetStatusText("Invalid Import String FAILED LibDeflate:DecodeForPrint")
import.button.frame:Disable()
return
end
local decompress_deflate = LibDeflate:DecompressZlib(decoded_string)
if not decompress_deflate then
import.statustext:SetTextColor(1,0,0)
import:SetStatusText("Invalid Import String FAILED LibDeflate:DecompressZlib")
import.button.frame:Disable()
return
end
local success, deserialized = AceSerializer:Deserialize(decompress_deflate)
if not success then
import.statustext:SetTextColor(1,0,0)
import:SetStatusText("Invalid Import String FAILED AceSerializer:Deserialize")
import.button.frame:Disable()
return
end
local statusOption, error = ExportImport:CheckDeserializedOptions(deserialized, Gladdy.db)
if not statusOption then
import.statustext:SetTextColor(1,0,0)
import:SetStatusText(error)
import.button.frame:Disable()
return
end
import.statustext:SetTextColor(0,1,0)
import:SetStatusText("SUCCESS")
import.button.frame:Enable()
import.deserializedTable = deserialized
end)
end,
name = "Import",
desc = "This will overwrite your current profile!",
order = 4,
},
}
end

449
Modules/Healthbar.lua Normal file
View File

@ -0,0 +1,449 @@
local pairs = pairs
local floor = math.floor
local UnitHealth, UnitHealthMax, UnitName, UnitExists = UnitHealth, UnitHealthMax, UnitName, UnitExists
local CreateFrame = CreateFrame
local RAID_CLASS_COLORS = RAID_CLASS_COLORS
local Gladdy = LibStub("Gladdy")
local L = Gladdy.L
local AceGUIWidgetLSMlists = AceGUIWidgetLSMlists
local Healthbar = Gladdy:NewModule("Healthbar", 100, {
healthBarFont = "DorisPP",
healthBarHeight = 60,
healthBarTexture = "Smooth",
healthBarBorderStyle = "Gladdy Tooltip round",
healthBarBorderSize = 9,
healthBarBorderColor = { r = 0, g = 0, b = 0, a = 1 },
healthBarBgColor = { r = 0, g = 0, b = 0, a = 0.4 },
healthBarFontColor = { r = 1, g = 1, b = 1, a = 1 },
healthBarFontSize = 12,
healthActual = false,
healthMax = true,
healthPercentage = true,
})
function Healthbar:Initialize()
self.frames = {}
self:RegisterMessage("ENEMY_SPOTTED")
self:RegisterMessage("UNIT_DEATH")
end
function Healthbar:CreateFrame(unit)
local button = Gladdy.buttons[unit]
local healthBar = CreateFrame("Frame", nil, Gladdy.buttons[unit], BackdropTemplateMixin and "BackdropTemplate")
healthBar:SetBackdrop({ edgeFile = Gladdy.LSM:Fetch("border", Gladdy.db.healthBarBorderStyle),
edgeSize = Gladdy.db.healthBarBorderSize })
healthBar:SetBackdropBorderColor(Gladdy.db.healthBarBorderColor.r, Gladdy.db.healthBarBorderColor.g, Gladdy.db.healthBarBorderColor.b, Gladdy.db.healthBarBorderColor.a)
healthBar:SetFrameLevel(1)
healthBar.hp = CreateFrame("StatusBar", nil, healthBar)
healthBar.hp:SetStatusBarTexture(Gladdy.LSM:Fetch("statusbar", Gladdy.db.healthBarTexture))
healthBar.hp:SetMinMaxValues(0, 100)
healthBar.hp:SetFrameLevel(0)
healthBar.bg = healthBar.hp:CreateTexture(nil, "BACKGROUND")
healthBar.bg:SetTexture(Gladdy.LSM:Fetch("statusbar", Gladdy.db.healthBarTexture))
healthBar.bg:ClearAllPoints()
healthBar.bg:SetAllPoints(healthBar.hp)
healthBar.bg:SetAlpha(1)
healthBar.bg:SetVertexColor(Gladdy.db.healthBarBgColor.r, Gladdy.db.healthBarBgColor.g, Gladdy.db.healthBarBgColor.b, Gladdy.db.healthBarBgColor.a)
healthBar.nameText = healthBar:CreateFontString(nil, "LOW", "GameFontNormalSmall")
if (Gladdy.db.healthBarFontSize < 1) then
healthBar.nameText:SetFont(Gladdy.LSM:Fetch("font", Gladdy.db.healthBarFont), 1)
healthBar.nameText:Hide()
else
healthBar.nameText:SetFont(Gladdy.LSM:Fetch("font", Gladdy.db.healthBarFont), Gladdy.db.healthBarFontSize)
healthBar.nameText:Show()
end
healthBar.nameText:SetTextColor(Gladdy.db.healthBarFontColor.r, Gladdy.db.healthBarFontColor.g, Gladdy.db.healthBarFontColor.b, Gladdy.db.healthBarFontColor.a)
healthBar.nameText:SetShadowOffset(1, -1)
healthBar.nameText:SetShadowColor(0, 0, 0, 1)
healthBar.nameText:SetJustifyH("CENTER")
healthBar.nameText:SetPoint("LEFT", 5, 0)
healthBar.healthText = healthBar:CreateFontString(nil, "LOW")
if (Gladdy.db.healthBarFontSize < 1) then
healthBar.healthText:SetFont(Gladdy.LSM:Fetch("font", Gladdy.db.healthBarFont), 1)
healthBar.healthText:Hide()
else
healthBar.healthText:SetFont(Gladdy.LSM:Fetch("font", Gladdy.db.healthBarFont), Gladdy.db.healthBarFontSize)
healthBar.healthText:Hide()
end
healthBar.healthText:SetTextColor(Gladdy.db.healthBarFontColor.r, Gladdy.db.healthBarFontColor.g, Gladdy.db.healthBarFontColor.b, Gladdy.db.healthBarFontColor.a)
healthBar.healthText:SetShadowOffset(1, -1)
healthBar.healthText:SetShadowColor(0, 0, 0, 1)
healthBar.healthText:SetJustifyH("CENTER")
healthBar.healthText:SetPoint("RIGHT", -5, 0)
healthBar.unit = unit
self.frames[unit] = healthBar
button.healthBar = healthBar
self:ResetUnit(unit)
healthBar:RegisterUnitEvent("UNIT_HEALTH", unit)
healthBar:RegisterUnitEvent("UNIT_MAXHEALTH", unit)
healthBar:RegisterUnitEvent("UNIT_NAME_UPDATE", unit)
healthBar:SetScript("OnEvent", Healthbar.OnEvent)
end
function Healthbar.OnEvent(self, event, unit)
if event == "UNIT_HEALTH" then
local health = UnitHealth(unit)
local healthMax = UnitHealthMax(unit)
Healthbar:SetHealthText(self, health, healthMax)
self.hp:SetValue(UnitHealth(unit))
elseif event == "UNIT_MAXHEALTH" then
local health = UnitHealth(unit)
local healthMax = UnitHealthMax(unit)
self.hp:SetMinMaxValues(0, healthMax)
self.hp:SetValue(health)
Healthbar:SetHealthText(self, health, healthMax)
elseif event == "UNIT_NAME_UPDATE" then
local name = UnitName(unit)
Gladdy.buttons[unit].name = name
self.nameText:SetText(name)
end
if not Gladdy.buttons[unit].class then
Gladdy:SpotEnemy(unit, true)
end
end
function Healthbar:SetHealthText(healthBar, health, healthMax)
local healthText
local healthPercentage = floor(health * 100 / healthMax)
if health == 0 then
self:UNIT_DEATH(healthBar.unit)
return
end
if (Gladdy.db.healthActual) then
healthText = healthMax > 999 and ("%.1fk"):format(health / 1000) or health
end
if (Gladdy.db.healthMax) then
local text = healthMax > 999 and ("%.1fk"):format(healthMax / 1000) or healthMax
if (healthText) then
healthText = ("%s/%s"):format(healthText, text)
else
healthText = text
end
end
if (Gladdy.db.healthPercentage) then
if (healthText) then
healthText = ("%s (%d%%)"):format(healthText, healthPercentage)
else
healthText = ("%d%%"):format(healthPercentage)
end
end
healthBar.healthText:SetText(healthText)
end
function Healthbar:UpdateFrame(unit)
local healthBar = self.frames[unit]
if (not healthBar) then
return
end
local iconSize = Gladdy.db.healthBarHeight + Gladdy.db.powerBarHeight
healthBar.bg:SetTexture(Gladdy.LSM:Fetch("statusbar", Gladdy.db.healthBarTexture))
healthBar.bg:SetVertexColor(Gladdy.db.healthBarBgColor.r, Gladdy.db.healthBarBgColor.g, Gladdy.db.healthBarBgColor.b, Gladdy.db.healthBarBgColor.a)
healthBar:SetBackdrop({ edgeFile = Gladdy.LSM:Fetch("border", Gladdy.db.healthBarBorderStyle),
edgeSize = Gladdy.db.healthBarBorderSize })
healthBar:SetBackdropBorderColor(Gladdy.db.healthBarBorderColor.r, Gladdy.db.healthBarBorderColor.g, Gladdy.db.healthBarBorderColor.b, Gladdy.db.healthBarBorderColor.a)
healthBar:ClearAllPoints()
healthBar:SetPoint("TOPLEFT", Gladdy.buttons[unit], "TOPLEFT", iconSize, 0)
healthBar:SetPoint("BOTTOMRIGHT", Gladdy.buttons[unit], "BOTTOMRIGHT")
healthBar.hp:SetStatusBarTexture(Gladdy.LSM:Fetch("statusbar", Gladdy.db.healthBarTexture))
healthBar.hp:ClearAllPoints()
healthBar.hp:SetPoint("TOPLEFT", healthBar, "TOPLEFT", (Gladdy.db.healthBarBorderSize/Gladdy.db.statusbarBorderOffset), -(Gladdy.db.healthBarBorderSize/Gladdy.db.statusbarBorderOffset))
healthBar.hp:SetPoint("BOTTOMRIGHT", healthBar, "BOTTOMRIGHT", -(Gladdy.db.healthBarBorderSize/Gladdy.db.statusbarBorderOffset), (Gladdy.db.healthBarBorderSize/Gladdy.db.statusbarBorderOffset))
if (Gladdy.db.healthBarFontSize < 1) then
healthBar.nameText:SetFont(Gladdy.LSM:Fetch("font", Gladdy.db.healthBarFont), 1)
healthBar.healthText:SetFont(Gladdy.LSM:Fetch("font", Gladdy.db.healthBarFont), 1)
healthBar.nameText:Hide()
healthBar.healthText:Hide()
else
healthBar.nameText:SetFont(Gladdy.LSM:Fetch("font", Gladdy.db.healthBarFont), Gladdy.db.healthBarFontSize)
healthBar.nameText:Show()
healthBar.healthText:SetFont(Gladdy.LSM:Fetch("font", Gladdy.db.healthBarFont), Gladdy.db.healthBarFontSize)
healthBar.healthText:Show()
end
healthBar.nameText:SetTextColor(Gladdy.db.healthBarFontColor.r, Gladdy.db.healthBarFontColor.g, Gladdy.db.healthBarFontColor.b, Gladdy.db.healthBarFontColor.a)
healthBar.healthText:SetTextColor(Gladdy.db.healthBarFontColor.r, Gladdy.db.healthBarFontColor.g, Gladdy.db.healthBarFontColor.b, Gladdy.db.healthBarFontColor.a)
end
function Healthbar:ResetUnit(unit)
local healthBar = self.frames[unit]
if (not healthBar) then
return
end
healthBar.hp:SetStatusBarColor(1, 1, 1, 1)
healthBar.nameText:SetText("")
healthBar.healthText:SetText("")
healthBar.hp:SetValue(0)
end
function Healthbar:Test(unit)
local healthBar = self.frames[unit]
local button = Gladdy.buttons[unit]
if (not healthBar or not button) then
return
end
self:ENEMY_SPOTTED(unit)
self:UNIT_HEALTH(unit, button.health, button.healthMax)
end
function Healthbar:ENEMY_SPOTTED(unit)
local healthBar = self.frames[unit]
local button = Gladdy.buttons[unit]
if (not healthBar or not button) then
return
end
if UnitExists(unit) then
local health = UnitHealth(unit)
local healthMax = UnitHealthMax(unit)
healthBar.hp:SetMinMaxValues(0, healthMax)
healthBar.hp:SetValue(health)
Healthbar:SetHealthText(healthBar, health, healthMax)
end
healthBar.nameText:SetText(button.name)
healthBar.hp:SetStatusBarColor(RAID_CLASS_COLORS[button.class].r, RAID_CLASS_COLORS[button.class].g, RAID_CLASS_COLORS[button.class].b, 1)
end
function Healthbar:UNIT_HEALTH(unit, health, healthMax)
local healthBar = self.frames[unit]
if (not healthBar) then
return
end
if not Gladdy.buttons[unit].class then
Gladdy:SpotEnemy(unit, true)
end
Gladdy:SendMessage("UNIT_HEALTH", unit, health, healthMax)
local healthPercentage = floor(health * 100 / healthMax)
local healthText
if (Gladdy.db.healthActual) then
healthText = healthMax > 999 and ("%.1fk"):format(health / 1000) or health
end
if (Gladdy.db.healthMax) then
local text = healthMax > 999 and ("%.1fk"):format(healthMax / 1000) or healthMax
if (healthText) then
healthText = ("%s/%s"):format(healthText, text)
else
healthText = text
end
end
if (Gladdy.db.healthPercentage) then
if (healthText) then
healthText = ("%s (%d%%)"):format(healthText, healthPercentage)
else
healthText = ("%d%%"):format(healthPercentage)
end
end
healthBar.healthText:SetText(healthText)
healthBar.hp:SetValue(healthPercentage)
end
function Healthbar:UNIT_DEATH(unit)
local healthBar = self.frames[unit]
if (not healthBar) then
return
end
healthBar.hp:SetValue(0)
healthBar.healthText:SetText(L["DEAD"])
end
local function 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.options.args.Healthbar.args.group.args.border.args.healthBarBorderSize.max = Gladdy.db.healthBarHeight/2
if Gladdy.db.healthBarBorderSize > Gladdy.db.healthBarHeight/2 then
Gladdy.db.healthBarBorderSize = Gladdy.db.healthBarHeight/2
end
Gladdy:UpdateFrame()
end,
}
for k, v in pairs(params) do
defaults[k] = v
end
return defaults
end
function Healthbar:GetOptions()
return {
headerHealthbar = {
type = "header",
name = L["Health Bar"],
order = 2,
},
group = {
type = "group",
childGroups = "tree",
name = "Frame",
order = 3,
args = {
general = {
type = "group",
name = L["General"],
order = 1,
args = {
headerAuras = {
type = "header",
name = L["General"],
order = 1,
},
healthBarHeight = option({
type = "range",
name = L["Bar height"],
desc = L["Height of the bar"],
order = 3,
min = 10,
max = 100,
step = 1,
}),
healthBarTexture = option({
type = "select",
name = L["Bar texture"],
desc = L["Texture of the bar"],
order = 4,
dialogControl = "LSM30_Statusbar",
values = AceGUIWidgetLSMlists.statusbar,
}),
healthBarBgColor = Gladdy:colorOption({
type = "color",
name = L["Background color"],
desc = L["Color of the status bar background"],
order = 5,
hasAlpha = true,
}),
},
},
font = {
type = "group",
name = L["Font"],
order = 2,
args = {
header = {
type = "header",
name = L["Font"],
order = 1,
},
healthBarFont = option({
type = "select",
name = L["Font"],
desc = L["Font of the bar"],
order = 11,
dialogControl = "LSM30_Font",
values = AceGUIWidgetLSMlists.font,
}),
healthBarFontColor = Gladdy:colorOption({
type = "color",
name = L["Font color"],
desc = L["Color of the text"],
order = 12,
hasAlpha = true,
}),
healthBarFontSize = option({
type = "range",
name = L["Font size"],
desc = L["Size of the text"],
order = 13,
min = 0,
max = 20,
}),
},
},
border = {
type = "group",
name = L["Border"],
order = 3,
args = {
header = {
type = "header",
name = L["Border"],
order = 1,
},
healthBarBorderStyle = option({
type = "select",
name = L["Border style"],
order = 21,
dialogControl = "LSM30_Border",
values = AceGUIWidgetLSMlists.border,
}),
healthBarBorderSize = option({
type = "range",
name = L["Border size"],
desc = L["Size of the border"],
order = 22,
min = 0.5,
max = Gladdy.db.healthBarHeight/2,
step = 0.5,
}),
healthBarBorderColor = Gladdy:colorOption({
type = "color",
name = L["Border color"],
desc = L["Color of the border"],
order = 23,
hasAlpha = true,
}),
},
},
healthValues = {
type = "group",
name = L["Health Values"],
order = 4,
args = {
header = {
type = "header",
name = L["Health Values"],
order = 1,
},
healthActual = option({
type = "toggle",
name = L["Show the actual health"],
desc = L["Show the actual health on the health bar"],
order = 31,
}),
healthMax = option({
type = "toggle",
name = L["Show max health"],
desc = L["Show max health on the health bar"],
order = 32,
}),
healthPercentage = option({
type = "toggle",
name = L["Show health percentage"],
desc = L["Show health percentage on the health bar"],
order = 33,
}),
},
},
},
},
}
end

242
Modules/Highlight.lua Normal file
View File

@ -0,0 +1,242 @@
local CreateFrame, UnitIsUnit = CreateFrame, UnitIsUnit
local Gladdy = LibStub("Gladdy")
local L = Gladdy.L
local Highlight = Gladdy:NewModule("Highlight", nil, {
highlightBorderSize = 2,
targetBorderColor = { r = 1, g = 0.8, b = 0, a = 1 },
focusBorderColor = { r = 1, g = 0, b = 0, a = 1 },
leaderBorderColor = { r = 0, g = 1, b = 0, a = 1 },
highlight = true,
targetBorder = true,
focusBorder = true,
leaderBorder = true,
})
function Highlight:Initialize()
self:RegisterMessage("JOINED_ARENA")
end
function Highlight:JOINED_ARENA()
self:RegisterEvent("PLAYER_FOCUS_CHANGED")
self:RegisterEvent("PLAYER_TARGET_CHANGED")
self:SetScript("OnEvent", function(self, event, ...)
if self[event] then
self[event](self, ...)
end
end)
end
function Highlight:Reset()
self:UnregisterAllEvents()
self:SetScript("OnEvent", nil)
end
function Highlight:PLAYER_TARGET_CHANGED()
for i=1, Gladdy.curBracket do
self:Toggle("arena" .. i, "target", UnitIsUnit("target", "arena" .. i))
end
end
function Highlight:PLAYER_FOCUS_CHANGED()
for i=1, Gladdy.curBracket do
self:Toggle("arena" .. i, "focus", UnitIsUnit("focus", "arena" .. i))
end
end
function Highlight:CreateFrame(unit)
local button = Gladdy.buttons[unit]
if (not button) then
return
end
local healthBar = Gladdy.modules.Healthbar.frames[unit]
local targetBorder = CreateFrame("Frame", nil, button, BackdropTemplateMixin and "BackdropTemplate")
targetBorder:SetBackdrop({ edgeFile = "Interface\\ChatFrame\\ChatFrameBackground", edgeSize = Gladdy.db.highlightBorderSize })
targetBorder:SetFrameStrata("HIGH")
targetBorder:Hide()
local focusBorder = CreateFrame("Frame", nil, button, BackdropTemplateMixin and "BackdropTemplate")
focusBorder:SetBackdrop({ edgeFile = "Interface\\ChatFrame\\ChatFrameBackground", edgeSize = Gladdy.db.highlightBorderSize })
focusBorder:SetFrameStrata("LOW")
focusBorder:Hide()
local leaderBorder = CreateFrame("Frame", nil, button, BackdropTemplateMixin and "BackdropTemplate")
leaderBorder:SetBackdrop({ edgeFile = "Interface\\ChatFrame\\ChatFrameBackground", edgeSize = Gladdy.db.highlightBorderSize })
leaderBorder:SetFrameStrata("MEDIUM")
leaderBorder:Hide()
local highlight = healthBar:CreateTexture(nil, "OVERLAY")
highlight:SetTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight")
highlight:SetBlendMode("ADD")
highlight:SetAlpha(0.5)
highlight:ClearAllPoints()
highlight:SetAllPoints(healthBar)
highlight:Hide()
button.targetBorder = targetBorder
button.focusBorder = focusBorder
button.leaderBorder = leaderBorder
button.highlight = highlight
end
function Highlight:UpdateFrame(unit)
local button = Gladdy.buttons[unit]
if (not button) then
return
end
local borderSize = Gladdy.db.highlightBorderSize
local iconSize = Gladdy.db.healthBarHeight + Gladdy.db.powerBarHeight + 1
local width = Gladdy.db.barWidth + borderSize * 2
local height = iconSize + borderSize * 2
button.targetBorder:SetWidth(width)
button.targetBorder:SetHeight(height)
button.targetBorder:ClearAllPoints()
button.targetBorder:SetPoint("TOP", button.healthBar, "TOP", 0, borderSize)
button.targetBorder:SetBackdrop({ edgeFile = "Interface\\ChatFrame\\ChatFrameBackground", edgeSize = borderSize })
button.targetBorder:SetBackdropBorderColor(Gladdy.db.targetBorderColor.r, Gladdy.db.targetBorderColor.g, Gladdy.db.targetBorderColor.b, Gladdy.db.targetBorderColor.a)
button.focusBorder:SetWidth(width)
button.focusBorder:SetHeight(height)
button.focusBorder:ClearAllPoints()
button.focusBorder:SetPoint("TOP", button.healthBar, "TOP", 0, borderSize)
button.focusBorder:SetBackdrop({ edgeFile = "Interface\\ChatFrame\\ChatFrameBackground", edgeSize = borderSize })
button.focusBorder:SetBackdropBorderColor(Gladdy.db.focusBorderColor.r, Gladdy.db.focusBorderColor.g, Gladdy.db.focusBorderColor.b, Gladdy.db.focusBorderColor.a)
button.leaderBorder:SetWidth(width)
button.leaderBorder:SetHeight(height)
button.leaderBorder:ClearAllPoints()
button.leaderBorder:SetPoint("TOP", button.healthBar, "TOP", 0, borderSize)
button.leaderBorder:SetBackdrop({ edgeFile = "Interface\\ChatFrame\\ChatFrameBackground", edgeSize = borderSize })
button.leaderBorder:SetBackdropBorderColor(Gladdy.db.leaderBorderColor.r, Gladdy.db.leaderBorderColor.g, Gladdy.db.leaderBorderColor.b, Gladdy.db.leaderBorderColor.a)
if Gladdy.frame.testing then
Highlight:Test(unit)
end
end
function Highlight:ResetUnit(unit)
local button = Gladdy.buttons[unit]
if (not button) then
return
end
button.targetBorder:Hide()
button.focusBorder:Hide()
button.leaderBorder:Hide()
button.highlight:Hide()
end
function Highlight:Test(unit)
if (unit == "arena1") then
self:Toggle(unit, "focus", true)
elseif (unit == "arena2") then
self:Toggle(unit, "target", true)
elseif (unit == "arena3") then
self:Toggle(unit, "leader", true)
end
end
function Highlight:Toggle(unit, frame, show)
local button = Gladdy.buttons[unit]
if (not button) then
return
end
if (frame == "target") then
if (Gladdy.db.targetBorder and show) then
button.targetBorder:Show()
else
button.targetBorder:Hide()
end
if (Gladdy.db.highlight and show) then
button.highlight:Show()
else
button.highlight:Hide()
end
elseif (frame == "focus") then
if (Gladdy.db.focusBorder and show) then
button.focusBorder:Show()
else
button.focusBorder:Hide()
end
elseif (frame == "leader") then
if (Gladdy.db.leaderBorder and show) then
button.leaderBorder:Show()
else
button.leaderBorder:Hide()
end
end
end
function Highlight:GetOptions()
return {
headerHighlight = {
type = "header",
name = L["Highlight"],
order = 2,
},
highlightBorderSize = {
type = "range",
name = L["Border size"],
desc = L["Border size"],
order = 3,
min = 1,
max = 10,
step = 1,
},
targetBorderColor = Gladdy:colorOption({
type = "color",
name = L["Target border color"],
desc = L["Color of the selected targets border"],
order = 4,
hasAlpha = true,
}),
focusBorderColor = Gladdy:colorOption({
type = "color",
name = L["Focus border color"],
desc = L["Color of the focus border"],
order = 5,
hasAlpha = true,
}),
leaderBorderColor = Gladdy:colorOption({
type = "color",
name = L["Raid leader border color"],
desc = L["Color of the raid leader border"],
order = 6,
hasAlpha = true,
}),
headerEnable = {
type = "header",
name = L["Enable/Disable"],
order = 10,
},
highlight = Gladdy:option({
type = "toggle",
name = L["Highlight target"],
desc = L["Toggle if the selected target should be highlighted"],
order = 11,
}),
targetBorder = Gladdy:option({
type = "toggle",
name = L["Show border around target"],
desc = L["Toggle if a border should be shown around the selected target"],
order = 12,
}),
focusBorder = Gladdy:option({
type = "toggle",
name = L["Show border around focus"],
desc = L["Toggle of a border should be shown around the current focus"],
order = 13,
}),
leaderBorder = Gladdy:option({
type = "toggle",
name = L["Show border around raid leader"],
desc = L["Toggle if a border should be shown around the raid leader"],
order = 14,
}),
}
end

542
Modules/Pets.lua Normal file
View File

@ -0,0 +1,542 @@
local string_gsub, floor, pairs = string.gsub, math.floor, pairs
local CreateFrame = CreateFrame
local UnitHealthMax, UnitHealth, UnitGUID = UnitHealthMax, UnitHealth, UnitGUID
local Gladdy = LibStub("Gladdy")
local L = Gladdy.L
local Pets = Gladdy:NewModule("Pets", nil, {
petEnabled = true,
petWidth = 100,
petHeight = 20,
petPortraitEnabled = true,
petPortraitBorderStyle = "Interface\\AddOns\\Gladdy\\Images\\Border_rounded_blp",
petHealthBarFont = "DorisPP",
petHealthBarHeight = 60,
petHealthBarTexture = "Smooth",
petHealthBarBorderStyle = "Gladdy Tooltip round",
petHealthBarBorderSize = 9,
petHealthBarBorderColor = { r = 0, g = 0, b = 0, a = 1 },
petHealthBarColor = { r = 0, g = 1, b = 0, a = 1 },
petHealthBarBgColor = { r = 0, g = 0, b = 0, a = 0.4 },
petHealthBarFontColor = { r = 1, g = 1, b = 1, a = 1 },
petHealthBarFontSize = 12,
petHealthPercentage = true,
petXOffset = 50,
petYOffset = 0,
})
function Pets:Initialize()
self.frames = {}
self:RegisterMessage("JOINED_ARENA")
self:RegisterMessage("PET_SPOTTED")
self:RegisterMessage("PET_DESTROYED")
self:RegisterMessage("PET_STEALTH")
self:RegisterMessage("ENEMY_SPOTTED")
end
function Pets:JOINED_ARENA()
for k,v in pairs(self.frames) do
v.healthBar:SetAlpha(0)
end
if Gladdy.db.petEnabled then
self:RegisterEvent("UNIT_PET")
self:SetScript("OnEvent", function(self, event, unitId)
if event == "UNIT_PET" then
local unit = Gladdy.guids[UnitGUID(unitId)]
if unit then
Pets:CheckUnitPet(unit)
end
end
end)
end
end
function Pets:ResetUnit(unitId)
local unit = string_gsub(unitId, "%d$", "pet%1")
local petFrame = self.frames[unit]
if (not petFrame) then
return
end
petFrame.healthBar:SetAlpha(0)
petFrame.healthBar:SetScript("OnUpdate", nil)
self:UnregisterEvent("UNIT_PET")
end
function Pets:PET_SPOTTED(unit)
if Gladdy.db.petEnabled then
self.frames[unit].healthBar:SetAlpha(1)
self.frames[unit].healthBar.hp:SetStatusBarColor(Gladdy.db.petHealthBarColor.r, Gladdy.db.petHealthBarColor.g, Gladdy.db.petHealthBarColor.b, Gladdy.db.petHealthBarColor.a)
self.frames[unit].healthBar:SetScript("OnUpdate", function(self)
self.hp:SetValue(UnitHealth(self.unit))
Pets:SetHealthText(self, UnitHealth(unit), UnitHealthMax(unit))
end)
end
end
function Pets:PET_DESTROYED(unit)
if Gladdy.db.petEnabled then
self.frames[unit].healthBar:SetAlpha(0)
self.frames[unit].healthBar:SetScript("OnUpdate", nil)
end
end
function Pets:PET_STEALTH(unit)
if Gladdy.db.petEnabled then
self.frames[unit].healthBar.hp:SetStatusBarColor(0.66, 0.66, 0.66, 1)
end
end
function Pets:ENEMY_SPOTTED(unit)
if Gladdy.db.petEnabled then
self:CheckUnitPet(unit)
end
end
function Pets:CheckUnitPet(unitId)
local unit = string_gsub(unitId, "%d$", "pet%1")
local petFrame = self.frames[unit]
if (not petFrame) then
return
end
if ( UnitGUID(unit)) then
petFrame.healthBar:SetAlpha(1)
petFrame.healthBar.hp:SetMinMaxValues(0, UnitHealthMax(unit))
petFrame.healthBar.hp:SetValue(UnitHealth(unit))
Pets:SetHealthText(petFrame.healthBar, UnitHealth(unit), UnitHealthMax(unit))
petFrame.healthBar:SetScript("OnUpdate", function(self)
self.hp:SetValue(UnitHealth(self.unit))
Pets:SetHealthText(self, UnitHealth(unit), UnitHealthMax(unit))
end)
else
petFrame.healthBar:SetAlpha(0)
petFrame.healthBar:SetScript("OnUpdate", nil)
end
end
function Pets:Test(unitId)
if Gladdy.db.petEnabled then
local unit = string_gsub(unitId, "%d$", "pet%1")
local petFrame = self.frames[unit]
if (not petFrame) then
return
end
petFrame.healthBar:SetAlpha(1)
petFrame.healthBar.hp:SetMinMaxValues(0, 6200)
petFrame.healthBar.hp:SetValue(2000)
Pets:SetHealthText(petFrame.healthBar, 2000, 6200)
end
end
function Pets:CreateFrame(unitId)
local unit = string_gsub(unitId, "%d$", "pet%1")
if self.frames[unit] then
return
end
local button = CreateFrame("Frame", "GladdyButtonFramePet" .. unit, Gladdy.frame)
--button:SetAlpha(0)
button:SetPoint("LEFT", Gladdy.buttons[unitId].healthBar, "RIGHT", Gladdy.db.petXOffset, Gladdy.db.petYOffset)
local secure = CreateFrame("Button", "GladdyButton" .. unit, button, "SecureActionButtonTemplate")
secure:RegisterForClicks("AnyUp")
secure:RegisterForClicks("AnyUp")
secure:SetAttribute("*type1", "target")
secure:SetAttribute("*type2", "focus")
secure:SetAttribute("unit", unit)
secure:SetAllPoints(button)
button.unit = unit
button.secure = secure
local healthBar = CreateFrame("Frame", nil, button, BackdropTemplateMixin and "BackdropTemplate")
healthBar:SetBackdrop({ edgeFile = Gladdy.LSM:Fetch("border", Gladdy.db.petHealthBarBorderStyle),
edgeSize = Gladdy.db.petHealthBarBorderSize })
healthBar:SetBackdropBorderColor(Gladdy.db.petHealthBarBorderColor.r, Gladdy.db.petHealthBarBorderColor.g, Gladdy.db.petHealthBarBorderColor.b, Gladdy.db.petHealthBarBorderColor.a)
healthBar:SetFrameLevel(1)
healthBar:SetAllPoints(button)
healthBar:SetAlpha(0)
healthBar.portrait = healthBar:CreateTexture(nil, "OVERLAY")
healthBar.portrait:SetPoint("LEFT", healthBar, "RIGHT")
healthBar.portrait:SetTexCoord(0.1, 0.9, 0.1, 0.9)
SetPortraitTexture(healthBar.portrait, "player")
healthBar.portrait.border = healthBar:CreateTexture(nil, "OVERLAY")
healthBar.portrait.border:SetAllPoints(healthBar.portrait)
healthBar.portrait.border:SetTexture(Gladdy.db.classIconBorderStyle)
healthBar.portrait.border:SetVertexColor(Gladdy.db.petHealthBarBorderColor.r, Gladdy.db.petHealthBarBorderColor.g, Gladdy.db.petHealthBarBorderColor.b, Gladdy.db.petHealthBarBorderColor.a)
healthBar.hp = CreateFrame("StatusBar", nil, healthBar)
healthBar.hp:SetStatusBarTexture(Gladdy.LSM:Fetch("statusbar", Gladdy.db.petHealthBarTexture))
healthBar.hp:SetStatusBarColor(Gladdy.db.petHealthBarColor.r, Gladdy.db.petHealthBarColor.g, Gladdy.db.petHealthBarColor.b, Gladdy.db.petHealthBarColor.a)
healthBar.hp:SetMinMaxValues(0, 100)
healthBar.hp:SetFrameLevel(0)
healthBar.hp:SetAllPoints(healthBar)
healthBar.bg = healthBar.hp:CreateTexture(nil, "BACKGROUND")
healthBar.bg:SetTexture(Gladdy.LSM:Fetch("statusbar", Gladdy.db.petHealthBarTexture))
healthBar.bg:ClearAllPoints()
healthBar.bg:SetAllPoints(healthBar.hp)
healthBar.bg:SetAlpha(1)
healthBar.bg:SetVertexColor(Gladdy.db.petHealthBarBgColor.r, Gladdy.db.petHealthBarBgColor.g, Gladdy.db.petHealthBarBgColor.b, Gladdy.db.petHealthBarBgColor.a)
healthBar.nameText = healthBar:CreateFontString(nil, "LOW", "GameFontNormalSmall")
if (Gladdy.db.petHealthBarFontSize < 1) then
healthBar.nameText:SetFont(Gladdy.LSM:Fetch("font", Gladdy.db.petHealthBarFont), 1)
healthBar.nameText:Hide()
else
healthBar.nameText:SetFont(Gladdy.LSM:Fetch("font", Gladdy.db.petHealthBarFont), Gladdy.db.petHealthBarFontSize)
healthBar.nameText:Show()
end
healthBar.nameText:SetTextColor(Gladdy.db.petHealthBarFontColor.r, Gladdy.db.petHealthBarFontColor.g, Gladdy.db.petHealthBarFontColor.b, Gladdy.db.petHealthBarFontColor.a)
healthBar.nameText:SetShadowOffset(1, -1)
healthBar.nameText:SetShadowColor(0, 0, 0, 1)
healthBar.nameText:SetJustifyH("CENTER")
healthBar.nameText:SetPoint("LEFT", 5, 0)
healthBar.healthText = healthBar:CreateFontString(nil, "LOW")
if (Gladdy.db.petHealthBarFontSize < 1) then
healthBar.healthText:SetFont(Gladdy.LSM:Fetch("font", Gladdy.db.petHealthBarFont), 1)
healthBar.healthText:Hide()
else
healthBar.healthText:SetFont(Gladdy.LSM:Fetch("font", Gladdy.db.petHealthBarFont), Gladdy.db.petHealthBarFontSize)
healthBar.healthText:Hide()
end
healthBar.healthText:SetTextColor(Gladdy.db.petHealthBarFontColor.r, Gladdy.db.petHealthBarFontColor.g, Gladdy.db.petHealthBarFontColor.b, Gladdy.db.petHealthBarFontColor.a)
healthBar.healthText:SetShadowOffset(1, -1)
healthBar.healthText:SetShadowColor(0, 0, 0, 1)
healthBar.healthText:SetJustifyH("CENTER")
healthBar.healthText:SetPoint("RIGHT", -5, 0)
healthBar.unit = unit
button.healthBar = healthBar
healthBar:RegisterUnitEvent("UNIT_HEALTH", unit)
healthBar:RegisterUnitEvent("UNIT_MAXHEALTH", unit)
healthBar:RegisterUnitEvent("UNIT_PORTRAIT_UPDATE", unit)
healthBar:RegisterUnitEvent("UNIT_NAME_UPDATE", unit)
healthBar:SetScript("OnEvent", Pets.OnEvent)
button:SetWidth(Gladdy.db.petWidth)
button:SetHeight(Gladdy.db.petHeight)
self.frames[unit] = button
end
function Pets.OnEvent(self, event, unit)
if event == "UNIT_PORTRAIT_UPDATE" then
SetPortraitTexture(self.portrait, unit)
end
local health = UnitHealth(unit)
local healthMax = UnitHealthMax(unit)
self.hp:SetMinMaxValues(0, healthMax)
self.hp:SetValue(health)
Pets:SetHealthText(self, health, healthMax)
end
function Pets:UpdateFrame(unitId)
local unit = string_gsub(unitId, "%d$", "pet%1")
local healthBar = self.frames[unit].healthBar
if (not healthBar) then
return
end
if not Gladdy.db.petEnabled then
self.frames[unit]:Hide()
else
self.frames[unit]:Show()
end
self.frames[unit]:SetWidth(Gladdy.db.petWidth)
self.frames[unit]:SetHeight(Gladdy.db.petHeight)
self.frames[unit]:SetPoint("LEFT", Gladdy.buttons[unitId].healthBar, "RIGHT", Gladdy.db.petXOffset, Gladdy.db.petYOffset)
healthBar.portrait:SetHeight(Gladdy.db.petHeight)
healthBar.portrait:SetWidth(Gladdy.db.petHeight)
if not Gladdy.db.petPortraitEnabled then
healthBar.portrait:Hide()
healthBar.portrait.border:Hide()
else
healthBar.portrait:Show()
healthBar.portrait.border:Show()
end
healthBar.portrait.border:SetTexture(Gladdy.db.petPortraitBorderStyle)
healthBar.portrait.border:SetVertexColor(Gladdy.db.petHealthBarBorderColor.r, Gladdy.db.petHealthBarBorderColor.g, Gladdy.db.petHealthBarBorderColor.b, Gladdy.db.petHealthBarBorderColor.a)
healthBar.bg:SetTexture(Gladdy.LSM:Fetch("statusbar", Gladdy.db.petHealthBarTexture))
healthBar.bg:SetVertexColor(Gladdy.db.petHealthBarBgColor.r, Gladdy.db.petHealthBarBgColor.g, Gladdy.db.petHealthBarBgColor.b, Gladdy.db.petHealthBarBgColor.a)
healthBar:SetBackdrop({ edgeFile = Gladdy.LSM:Fetch("border", Gladdy.db.petHealthBarBorderStyle),
edgeSize = Gladdy.db.petHealthBarBorderSize })
healthBar:SetBackdropBorderColor(Gladdy.db.petHealthBarBorderColor.r, Gladdy.db.petHealthBarBorderColor.g, Gladdy.db.petHealthBarBorderColor.b, Gladdy.db.petHealthBarBorderColor.a)
healthBar.hp:SetStatusBarTexture(Gladdy.LSM:Fetch("statusbar", Gladdy.db.petHealthBarTexture))
healthBar.hp:SetStatusBarColor(Gladdy.db.petHealthBarColor.r, Gladdy.db.petHealthBarColor.g, Gladdy.db.petHealthBarColor.b, Gladdy.db.petHealthBarColor.a)
healthBar.hp:ClearAllPoints()
healthBar.hp:SetPoint("TOPLEFT", healthBar, "TOPLEFT", (Gladdy.db.petHealthBarBorderSize/Gladdy.db.statusbarBorderOffset), -(Gladdy.db.petHealthBarBorderSize/Gladdy.db.statusbarBorderOffset))
healthBar.hp:SetPoint("BOTTOMRIGHT", healthBar, "BOTTOMRIGHT", -(Gladdy.db.petHealthBarBorderSize/Gladdy.db.statusbarBorderOffset), (Gladdy.db.petHealthBarBorderSize/Gladdy.db.statusbarBorderOffset))
if (Gladdy.db.petHealthBarFontSize < 1) then
healthBar.nameText:SetFont(Gladdy.LSM:Fetch("font", Gladdy.db.petHealthBarFont), 1)
healthBar.healthText:SetFont(Gladdy.LSM:Fetch("font", Gladdy.db.petHealthBarFont), 1)
healthBar.nameText:Hide()
healthBar.healthText:Hide()
else
healthBar.nameText:SetFont(Gladdy.LSM:Fetch("font", Gladdy.db.petHealthBarFont), Gladdy.db.petHealthBarFontSize)
healthBar.nameText:Show()
healthBar.healthText:SetFont(Gladdy.LSM:Fetch("font", Gladdy.db.petHealthBarFont), Gladdy.db.petHealthBarFontSize)
healthBar.healthText:Show()
end
healthBar.nameText:SetTextColor(Gladdy.db.petHealthBarFontColor.r, Gladdy.db.petHealthBarFontColor.g, Gladdy.db.petHealthBarFontColor.b, Gladdy.db.petHealthBarFontColor.a)
healthBar.healthText:SetTextColor(Gladdy.db.petHealthBarFontColor.r, Gladdy.db.petHealthBarFontColor.g, Gladdy.db.petHealthBarFontColor.b, Gladdy.db.petHealthBarFontColor.a)
end
function Pets:SetHealthText(healthBar, health, healthMax)
local healthText = ""
if healthMax ~= 0 then
local healthPercentage = floor(health * 100 / healthMax)
if (Gladdy.db.petHealthPercentage) then
healthText = ("%d%%"):format(healthPercentage)
end
else
healthText = "DEAD"
end
healthBar.healthText:SetText(healthText)
end
local function 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.options.args.Pets.args.group.args.border.args.petHealthBarBorderSize.max = Gladdy.db.petHeight/2
if Gladdy.db.petHealthBarBorderSize > Gladdy.db.petHeight/2 then
Gladdy.db.petHealthBarBorderSize = Gladdy.db.petHeight/2
end
Gladdy:UpdateFrame()
end,
}
for k, v in pairs(params) do
defaults[k] = v
end
return defaults
end
function Pets:GetOptions()
return {
headerHealthbar = {
type = "header",
name = L["Health Bar"],
order = 2,
},
petEnabled = Gladdy:option({
type = "toggle",
name = L["Enable"],
desc = L["Enabled Pets module"],
order = 3,
}),
group = {
type = "group",
childGroups = "tree",
name = "Frame",
order = 3,
args = {
general = {
type = "group",
name = L["General"],
order = 1,
args = {
headerAuras = {
type = "header",
name = L["General"],
order = 1,
},
petHeight = option({
type = "range",
name = L["Bar height"],
desc = L["Height of the bar"],
order = 3,
min = 10,
max = 100,
step = 1,
}),
petWidth = option({
type = "range",
name = L["Bar width"],
desc = L["Width of the bar"],
order = 4,
min = 10,
max = 100,
step = 1,
}),
petHealthBarTexture = option({
type = "select",
name = L["Bar texture"],
desc = L["Texture of the bar"],
order = 5,
dialogControl = "LSM30_Statusbar",
values = AceGUIWidgetLSMlists.statusbar,
}),
petHealthBarColor = Gladdy:colorOption({
type = "color",
name = L["Health color"],
desc = L["Color of the status bar"],
order = 6,
hasAlpha = true,
}),
petHealthBarBgColor = Gladdy:colorOption({
type = "color",
name = L["Background color"],
desc = L["Color of the status bar background"],
order = 7,
hasAlpha = true,
}),
},
},
portrait = {
type = "group",
name = L["Portrait"],
order = 2,
args = {
headerAuras = {
type = "header",
name = L["Portrait"],
order = 1,
},
petPortraitEnabled = Gladdy:option({
type = "toggle",
name = L["Enabled"],
order = 2,
}),
petPortraitBorderStyle = Gladdy:option({
type = "select",
name = L["Border style"],
order = 3,
values = Gladdy:GetIconStyles()
}),
},
},
font = {
type = "group",
name = L["Font"],
order = 3,
args = {
header = {
type = "header",
name = L["Font"],
order = 1,
},
petHealthBarFont = option({
type = "select",
name = L["Font"],
desc = L["Font of the bar"],
order = 11,
dialogControl = "LSM30_Font",
values = AceGUIWidgetLSMlists.font,
}),
petHealthBarFontColor = Gladdy:colorOption({
type = "color",
name = L["Font color"],
desc = L["Color of the text"],
order = 12,
hasAlpha = true,
}),
petHealthBarFontSize = option({
type = "range",
name = L["Font size"],
desc = L["Size of the text"],
order = 13,
min = 0,
max = 20,
}),
},
},
border = {
type = "group",
name = L["Border"],
order = 4,
args = {
header = {
type = "header",
name = L["Border"],
order = 1,
},
petHealthBarBorderStyle = option({
type = "select",
name = L["Border style"],
order = 21,
dialogControl = "LSM30_Border",
values = AceGUIWidgetLSMlists.border,
}),
petHealthBarBorderSize = option({
type = "range",
name = L["Border size"],
desc = L["Size of the border"],
order = 22,
min = 0.5,
max = Gladdy.db.petHeight/2,
step = 0.5,
}),
petHealthBarBorderColor = Gladdy:colorOption({
type = "color",
name = L["Border color"],
desc = L["Color of the border"],
order = 23,
hasAlpha = true,
}),
},
},
position = {
type = "group",
name = L["Position"],
order = 5,
args = {
petXOffset = Gladdy:option({
type = "range",
name = L["Horizontal offset"],
order = 22,
min = -400,
max = 400,
step = 0.1,
}),
petYOffset = Gladdy:option({
type = "range",
name = L["Vertical offset"],
order = 23,
min = -400,
max = 400,
step = 0.1,
}),
}
},
healthValues = {
type = "group",
name = L["Health Values"],
order = 6,
args = {
header = {
type = "header",
name = L["Health Values"],
order = 1,
},
petHealthPercentage = option({
type = "toggle",
name = L["Show health percentage"],
desc = L["Show health percentage on the health bar"],
order = 33,
}),
},
},
},
},
}
end

442
Modules/Powerbar.lua Normal file
View File

@ -0,0 +1,442 @@
local pairs = pairs
local floor = math.floor
local CreateFrame, UnitPower, UnitPowerType, UnitPowerMax, UnitExists = CreateFrame, UnitPower, UnitPowerType, UnitPowerMax, UnitExists
local Gladdy = LibStub("Gladdy")
local L = Gladdy.L
local AceGUIWidgetLSMlists = AceGUIWidgetLSMlists
local Powerbar = Gladdy:NewModule("Powerbar", 90, {
powerBarFont = "DorisPP",
powerBarHeight = 20,
powerBarTexture = "Smooth",
powerBarBorderStyle = "Gladdy Tooltip round",
powerBarBorderSize = 9,
powerBarBorderColor = { r = 0, g = 0, b = 0, a = 1 },
powerBarFontColor = { r = 1, g = 1, b = 1, a = 1 },
powerBarBgColor = { r = 0.3, g = 0.3, b = 0.3, a = 0.7 },
powerBarFontSize = 10,
powerActual = true,
powerMax = true,
powerPercentage = false,
})
function Powerbar:Initialize()
self.frames = {}
self:RegisterMessage("ENEMY_SPOTTED")
self:RegisterMessage("UNIT_SPEC")
self:RegisterMessage("UNIT_DEATH")
end
function Powerbar:CreateFrame(unit)
local button = Gladdy.buttons[unit]
local powerBar = CreateFrame("Frame", nil, Gladdy.buttons[unit], BackdropTemplateMixin and "BackdropTemplate")
powerBar:SetBackdrop({ edgeFile = Gladdy.LSM:Fetch("border", Gladdy.db.powerBarBorderStyle),
edgeSize = Gladdy.db.powerBarBorderSize })
powerBar:SetBackdropBorderColor(Gladdy.db.powerBarBorderColor.r, Gladdy.db.powerBarBorderColor.g, Gladdy.db.powerBarBorderColor.b, Gladdy.db.powerBarBorderColor.a)
powerBar:SetFrameLevel(1)
powerBar.energy = CreateFrame("StatusBar", nil, powerBar)
powerBar.energy:SetStatusBarTexture(Gladdy.LSM:Fetch("statusbar", Gladdy.db.powerBarTexture))
powerBar.energy:SetMinMaxValues(0, 100)
powerBar.energy:SetFrameLevel(0)
powerBar.bg = powerBar.energy:CreateTexture(nil, "BACKGROUND")
powerBar.bg:SetTexture(Gladdy.LSM:Fetch("statusbar", Gladdy.db.powerBarTexture))
powerBar.bg:ClearAllPoints()
powerBar.bg:SetAllPoints(powerBar.energy)
powerBar.bg:SetVertexColor(Gladdy.db.powerBarBgColor.r, Gladdy.db.powerBarBgColor.g, Gladdy.db.powerBarBgColor.b, Gladdy.db.powerBarBgColor.a)
powerBar.raceText = powerBar:CreateFontString(nil, "LOW")
powerBar.raceText:SetFont(Gladdy.LSM:Fetch("font", Gladdy.db.powerBarFont), Gladdy.db.powerBarFontSize)
powerBar.raceText:SetTextColor(Gladdy.db.powerBarFontColor.r, Gladdy.db.powerBarFontColor.g, Gladdy.db.powerBarFontColor.b, Gladdy.db.powerBarFontColor.a)
powerBar.raceText:SetShadowOffset(1, -1)
powerBar.raceText:SetShadowColor(0, 0, 0, 1)
powerBar.raceText:SetJustifyH("CENTER")
powerBar.raceText:SetPoint("LEFT", 5, 1)
powerBar.powerText = powerBar:CreateFontString(nil, "LOW")
powerBar.powerText:SetFont(Gladdy.LSM:Fetch("font", Gladdy.db.powerBarFont), Gladdy.db.powerBarFontSize)
powerBar.powerText:SetTextColor(Gladdy.db.powerBarFontColor.r, Gladdy.db.powerBarFontColor.g, Gladdy.db.powerBarFontColor.b, Gladdy.db.powerBarFontColor.a)
powerBar.powerText:SetShadowOffset(1, -1)
powerBar.powerText:SetShadowColor(0, 0, 0, 1)
powerBar.powerText:SetJustifyH("CENTER")
powerBar.powerText:SetPoint("RIGHT", -5, 1)
button.powerBar = powerBar
self.frames[unit] = powerBar
self:ResetUnit(unit)
powerBar:RegisterUnitEvent("UNIT_POWER_UPDATE", unit)
powerBar:RegisterUnitEvent("UNIT_MAXPOWER", unit)
powerBar:RegisterUnitEvent("UNIT_DISPLAYPOWER", unit)
powerBar:SetScript("OnEvent", Powerbar.OnEvent)
end
function Powerbar.OnEvent(powerBar, event, unit)
if event == "UNIT_POWER_UPDATE" then
Powerbar:SetPower(powerBar, UnitPower(unit, UnitPowerType(unit), true), UnitPowerMax(unit, UnitPowerType(unit), true), UnitPowerType(unit))
elseif event == "UNIT_MAXPOWER" then
Powerbar:SetPower(powerBar, UnitPower(unit, UnitPowerType(unit), true), UnitPowerMax(unit, UnitPowerType(unit), true), UnitPowerType(unit))
elseif event == "UNIT_DISPLAYPOWER" then
Powerbar:SetPower(powerBar, UnitPower(unit, UnitPowerType(unit), true), UnitPowerMax(unit, UnitPowerType(unit), true), UnitPowerType(unit))
end
end
function Powerbar:SetPower(powerBar, power, powerMax, powerType)
local powerPercentage = floor(power * 100 / powerMax)
local powerText
if (Gladdy.db.powerActual) then
powerText = powerMax > 999 and ("%.1fk"):format(power / 1000) or power
end
if (Gladdy.db.powerMax) then
local text = powerMax > 999 and ("%.1fk"):format(powerMax / 1000) or powerMax
if (powerText) then
powerText = ("%s/%s"):format(powerText, text)
else
powerText = text
end
end
if (Gladdy.db.powerPercentage) then
if (powerText) then
powerText = ("%s (%d%%)"):format(powerText, powerPercentage)
else
powerText = ("%d%%"):format(powerPercentage)
end
end
if (powerType == 1) then
powerBar.energy:SetStatusBarColor(1, 0, 0, 1)
elseif (powerType == 3) then
powerBar.energy:SetStatusBarColor(1, 1, 0, 1)
else
powerBar.energy:SetStatusBarColor(.18, .44, .75, 1)
end
powerBar.powerText:SetText(powerText)
powerBar.energy:SetMinMaxValues(0, powerMax)
powerBar.energy:SetValue(power)
end
function Powerbar:UpdateFrame(unit)
local powerBar = self.frames[unit]
if (not powerBar) then
return
end
local healthBar = Gladdy.modules.Healthbar.frames[unit]
powerBar.bg:SetTexture(Gladdy.LSM:Fetch("statusbar", Gladdy.db.powerBarTexture))
powerBar.bg:SetVertexColor(Gladdy.db.powerBarBgColor.r, Gladdy.db.powerBarBgColor.g, Gladdy.db.powerBarBgColor.b, Gladdy.db.powerBarBgColor.a)
powerBar:SetWidth(healthBar:GetWidth())
powerBar:SetHeight(Gladdy.db.powerBarHeight)
powerBar:ClearAllPoints()
powerBar:SetPoint("TOPLEFT", healthBar, "BOTTOMLEFT", 0, -1)
powerBar:SetBackdrop({ edgeFile = Gladdy.LSM:Fetch("border", Gladdy.db.powerBarBorderStyle),
edgeSize = Gladdy.db.powerBarBorderSize })
powerBar:SetBackdropBorderColor(Gladdy.db.powerBarBorderColor.r, Gladdy.db.powerBarBorderColor.g, Gladdy.db.powerBarBorderColor.b, Gladdy.db.powerBarBorderColor.a)
powerBar.energy:SetStatusBarTexture(Gladdy.LSM:Fetch("statusbar", Gladdy.db.powerBarTexture))
powerBar.energy:ClearAllPoints()
powerBar.energy:SetPoint("TOPLEFT", powerBar, "TOPLEFT", (Gladdy.db.powerBarBorderSize/Gladdy.db.statusbarBorderOffset), -(Gladdy.db.powerBarBorderSize/Gladdy.db.statusbarBorderOffset))
powerBar.energy:SetPoint("BOTTOMRIGHT", powerBar, "BOTTOMRIGHT", -(Gladdy.db.powerBarBorderSize/Gladdy.db.statusbarBorderOffset), (Gladdy.db.powerBarBorderSize/Gladdy.db.statusbarBorderOffset))
powerBar.raceText:SetFont(Gladdy.LSM:Fetch("font", Gladdy.db.powerBarFont), Gladdy.db.powerBarFontSize)
powerBar.raceText:SetTextColor(Gladdy.db.powerBarFontColor.r, Gladdy.db.powerBarFontColor.g, Gladdy.db.powerBarFontColor.b, Gladdy.db.powerBarFontColor.a)
powerBar.powerText:SetFont(Gladdy.LSM:Fetch("font", Gladdy.db.powerBarFont), Gladdy.db.powerBarFontSize)
powerBar.powerText:SetTextColor(Gladdy.db.powerBarFontColor.r, Gladdy.db.powerBarFontColor.g, Gladdy.db.powerBarFontColor.b, Gladdy.db.powerBarFontColor.a)
end
function Powerbar:ResetUnit(unit)
local powerBar = self.frames[unit]
if (not powerBar) then
return
end
powerBar.energy:SetStatusBarColor(1, 1, 1, 1)
powerBar.raceText:SetText("")
powerBar.powerText:SetText("")
powerBar.energy:SetValue(0)
end
function Powerbar:Test(unit)
local powerBar = self.frames[unit]
local button = Gladdy.buttons[unit]
if (not powerBar or not button) then
return
end
self:ENEMY_SPOTTED(unit)
self:UNIT_POWER(unit, button.power, button.powerMax, button.powerType)
end
function Powerbar:ENEMY_SPOTTED(unit)
local powerBar = self.frames[unit]
local button = Gladdy.buttons[unit]
if (not powerBar or not button) then
return
end
local raceText = button.raceLoc
if (button.spec) then
raceText = button.spec .. " " .. raceText
end
powerBar.raceText:SetText(raceText)
if UnitExists(unit) then
Powerbar:SetPower(powerBar, UnitPower(unit, UnitPowerType(unit), true), UnitPowerMax(unit, UnitPowerType(unit), true), UnitPowerType(unit))
end
end
function Powerbar:UNIT_SPEC(unit, spec)
local powerBar = self.frames[unit]
local button = Gladdy.buttons[unit]
if (not powerBar or not button) then
return
end
powerBar.raceText:SetText(spec .. " " .. button.raceLoc)
end
function Powerbar:UNIT_POWER(unit, power, powerMax, powerType)
local powerBar = self.frames[unit]
if (not powerBar) then
return
end
if not Gladdy.buttons[unit].class then
Gladdy:SpotEnemy(unit, true)
end
local powerPercentage = floor(power * 100 / powerMax)
local powerText
if (Gladdy.db.powerActual) then
powerText = powerMax > 999 and ("%.1fk"):format(power / 1000) or power
end
if (Gladdy.db.powerMax) then
local text = powerMax > 999 and ("%.1fk"):format(powerMax / 1000) or powerMax
if (powerText) then
powerText = ("%s/%s"):format(powerText, text)
else
powerText = text
end
end
if (Gladdy.db.powerPercentage) then
if (powerText) then
powerText = ("%s (%d%%)"):format(powerText, powerPercentage)
else
powerText = ("%d%%"):format(powerPercentage)
end
end
if (powerType == 1) then
powerBar.energy:SetStatusBarColor(1, 0, 0, 1)
elseif (powerType == 3) then
powerBar.energy:SetStatusBarColor(1, 1, 0, 1)
else
powerBar.energy:SetStatusBarColor(.18, .44, .75, 1)
end
powerBar.powerText:SetText(powerText)
powerBar.energy:SetValue(powerPercentage)
end
function Powerbar:UNIT_DEATH(unit)
local powerBar = self.frames[unit]
if (not powerBar) then
return
end
powerBar.energy:SetValue(0)
powerBar.powerText:SetText("0%")
end
local function 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.options.args.Powerbar.args.group.args.border.arg.powerBarBorderSize.max = Gladdy.db.powerBarHeight/2
if Gladdy.db.powerBarBorderSize > Gladdy.db.powerBarHeight/2 then
Gladdy.db.powerBarBorderSize = Gladdy.db.powerBarHeight/2
end
Gladdy:UpdateFrame()
end,
}
for k, v in pairs(params) do
defaults[k] = v
end
return defaults
end
function Powerbar:GetOptions()
return {
headerPowerbar = {
type = "header",
name = L["Power Bar"],
order = 2,
},
group = {
type = "group",
childGroups = "tree",
name = "Frame",
order = 3,
args = {
general = {
type = "group",
name = L["General"],
order = 1,
args = {
header = {
type = "header",
name = L["General"],
order = 1,
},
powerBarHeight = option({
type = "range",
name = L["Bar height"],
desc = L["Height of the bar"],
order = 3,
min = 0,
max = 50,
step = 1,
}),
powerBarTexture = option({
type = "select",
name = L["Bar texture"],
desc = L["Texture of the bar"],
order = 4,
dialogControl = "LSM30_Statusbar",
values = AceGUIWidgetLSMlists.statusbar,
}),
powerBarBgColor = Gladdy:colorOption({
type = "color",
name = L["Background color"],
desc = L["Color of the status bar background"],
order = 5,
hasAlpha = true,
}),
},
},
font = {
type = "group",
name = L["Font"],
order = 2,
args = {
header = {
type = "header",
name = L["Font"],
order = 1,
},
powerBarFont = option({
type = "select",
name = L["Font"],
desc = L["Font of the bar"],
order = 11,
dialogControl = "LSM30_Font",
values = AceGUIWidgetLSMlists.font,
}),
powerBarFontColor = Gladdy:colorOption({
type = "color",
name = L["Font color"],
desc = L["Color of the text"],
order = 12,
hasAlpha = true,
}),
powerBarFontSize = option({
type = "range",
name = L["Font size"],
desc = L["Size of the text"],
order = 13,
min = 1,
max = 20,
}),
},
},
border = {
type = "group",
name = L["Border"],
order = 3,
args = {
header = {
type = "header",
name = L["Border"],
order = 1,
},
powerBarBorderStyle = option({
type = "select",
name = L["Border style"],
order = 21,
dialogControl = "LSM30_Border",
values = AceGUIWidgetLSMlists.border,
}),
powerBarBorderSize = option({
type = "range",
name = L["Border size"],
desc = L["Size of the border"],
order = 22,
min = 0.5,
max = Gladdy.db.powerBarHeight/2,
step = 0.5,
}),
powerBarBorderColor = Gladdy:colorOption({
type = "color",
name = L["Border color"],
desc = L["Color of the border"],
order = 23,
hasAlpha = true,
}),
},
},
powerValues = {
type = "group",
name = L["Power Values"],
order = 4,
args = {
header = {
type = "header",
name = L["Power Values"],
order = 1,
},
powerActual = option({
type = "toggle",
name = L["Show the actual power"],
desc = L["Show the actual power on the power bar"],
order = 31,
}),
powerMax = option({
type = "toggle",
name = L["Show max power"],
desc = L["Show max power on the power bar"],
order = 32,
}),
powerPercentage = option({
type = "toggle",
name = L["Show power percentage"],
desc = L["Show power percentage on the power bar"],
order = 33,
}),
},
},
},
},
}
end

606
Modules/TotemPlates.lua Normal file
View File

@ -0,0 +1,606 @@
local select, pairs, string_lower, tremove, tinsert, format, string_gsub, ipairs = select, pairs, string.lower, tremove, tinsert, format, string.gsub, ipairs
local UnitExists, UnitIsUnit, UnitName = UnitExists, UnitIsUnit, UnitName
local C_NamePlate = C_NamePlate
local Gladdy = LibStub("Gladdy")
local L = Gladdy.L
local GetSpellInfo, CreateFrame, GetCVar = GetSpellInfo, CreateFrame, GetCVar
---------------------------------------------------
-- Constants
---------------------------------------------------
local totemData = {
-- Fire
[string_lower("Searing Totem")] = {id = 3599,texture = select(3, GetSpellInfo(3599)), color = {r = 0, g = 0, b = 0, a = 1}, enabled = true, priority = 0}, -- Searing Totem
[string_lower("Flametongue Totem")] = {id = 8227,texture = select(3, GetSpellInfo(8227)), color = {r = 0, g = 0, b = 0, a = 1}, enabled = true, priority = 0}, -- Flametongue Totem
[string_lower("Magma Totem")] = {id = 8190,texture = select(3, GetSpellInfo(8190)), color = {r = 0, g = 0, b = 0, a = 1}, enabled = true, priority = 0}, -- Magma Totem
[string_lower("Fire Nova Totem")] = {id = 1535,texture = select(3, GetSpellInfo(1535)), color = {r = 0, g = 0, b = 0, a = 1}, enabled = true, priority = 0}, -- Fire Nova Totem
[string_lower("Totem of Wrath")] = {id = 30706,texture = select(3, GetSpellInfo(30706)), color = {r = 0, g = 0, b = 0, a = 1}, enabled = true, priority = 1}, -- Totem of Wrath
[string_lower("Fire Elemental Totem")] = {id = 32982,texture = select(3, GetSpellInfo(32982)), color = {r = 0, g = 0, b = 0, a = 1}, enabled = true, priority = 0}, -- Fire Elemental Totem
[string_lower("Frost Resistance Totem")] = {id = 8181,texture = select(3, GetSpellInfo(8181)), color = {r = 0, g = 0, b = 0, a = 1}, enabled = true, priority = 0}, -- Frost Resistance Totem
-- Water
[string_lower("Fire Resistance Totem")] = {id = 8184,texture = select(3, GetSpellInfo(8184)), color = {r = 0, g = 0, b = 0, a = 1}, enabled = true, priority = 0}, -- Fire Resistance Totem
[string_lower("Poison Cleansing Totem")] = {id = 8166,texture = select(3, GetSpellInfo(8166)), color = {r = 0, g = 0, b = 0, a = 1}, enabled = true, priority = 0}, -- Poison Cleansing Totem
[string_lower("Disease Cleansing Totem")] = {id = 8170,texture = select(3, GetSpellInfo(8170)), color = {r = 0, g = 0, b = 0, a = 1}, enabled = true, priority = 0}, -- Disease Cleansing Totem
[string_lower("Healing Stream Totem")] = {id = 5394,texture = select(3, GetSpellInfo(5394)), color = {r = 0, g = 0, b = 0, a = 1}, enabled = true, priority = 0}, -- Healing Stream Totem
[string_lower("Mana Tide Totem")] = {id = 16190,texture = select(3, GetSpellInfo(16190)), color = {r = 0.078, g = 0.9, b = 0.16, a = 1}, enabled = true, priority = 3}, -- Mana Tide Totem
[string_lower("Mana Spring Totem")] = {id = 5675,texture = "Interface\\AddOns\\Gladdy\\Images\\Totems\\Spell_Nature_ManaRegenTotem_edit", color = {r = 0, g = 0, b = 0, a = 1}, enabled = true, priority = 1}, -- Mana Spring Totem
-- Earth
[string_lower("Earthbind Totem")] = {id = 2484,texture = select(3, GetSpellInfo(2484)), color = {r = 0.5, g = 0.5, b = 0.5, a = 1}, enabled = true, priority = 1}, -- Earthbind Totem
[string_lower("Stoneclaw Totem")] = {id = 5730,texture = select(3, GetSpellInfo(5730)), color = {r = 0, g = 0, b = 0, a = 1}, enabled = true, priority = 0}, -- Stoneclaw Totem
[string_lower("Stoneskin Totem")] = {id = 8071,texture = select(3, GetSpellInfo(8071)), color = {r = 0, g = 0, b = 0, a = 1}, enabled = true, priority = 0}, -- Stoneskin Totem
[string_lower("Strength of Earth Totem")] = {id = 8075,texture = select(3, GetSpellInfo(8075)), color = {r = 0, g = 0, b = 0, a = 1}, enabled = true, priority = 0}, -- Strength of Earth Totem
[string_lower("Earth Elemental Totem")] = {id = 33663,texture = select(3, GetSpellInfo(33663)), color = {r = 0, g = 0, b = 0, a = 1}, enabled = true, priority = 0}, -- Earth Elemental Totem
[string_lower("Tremor Totem")] = {id = 8143,texture = select(3, GetSpellInfo(8143)), color = {r = 1, g = 0.9, b = 0.1, a = 1}, enabled = true, priority = 3}, -- Tremor Totem
-- Air
[string_lower("Grounding Totem")] = {id = 8177,texture = select(3, GetSpellInfo(8177)), color = {r = 0, g = 0.53, b = 0.92, a = 1}, enabled = true, priority = 3}, -- Grounding Totem
[string_lower("Grace of Air Totem")] = {id = 8835,texture = "Interface\\AddOns\\Gladdy\\Images\\Totems\\Spell_Nature_InvisibilityTotem_edit", color = {r = 0, g = 0, b = 0, a = 1}, enabled = true, priority = 0}, -- Grace of Air Totem
[string_lower("Nature Resistance Totem")] = {id = 10595,texture = select(3, GetSpellInfo(10595)), color = {r = 0, g = 0, b = 0, a = 1}, enabled = true, priority = 0}, -- Nature Resistance Totem
[string_lower("Windfury Totem")] = {id = 8512,texture = "Interface\\AddOns\\Gladdy\\Images\\Totems\\Spell_Nature_Windfury_edit", color = {r = 0.96, g = 0, b = 0.07, a = 1}, enabled = true, priority = 2}, -- Windfury Totem
[string_lower("Sentry Totem")] = {id = 6495, texture = "Interface\\AddOns\\Gladdy\\Images\\Totems\\Spell_Nature_RemoveCurse_edit", color = {r = 0, g = 0, b = 0, a = 1}, enabled = true, priority = 0}, -- Sentry Totem
[string_lower("Windwall Totem")] = {id = 15107,texture = select(3, GetSpellInfo(15107)), color = {r = 0, g = 0, b = 0, a = 1}, enabled = true, priority = 0}, -- Windwall Totem
[string_lower("Wrath of Air Totem")] = {id = 3738,texture = "Interface\\AddOns\\Gladdy\\Images\\Totems\\Spell_Nature_SlowingTotem_edit", color = {r = 0, g = 0, b = 0, a = 1}, enabled = true, priority = 0}, -- Wrath of Air Totem
[string_lower("Tranquil Air Totem")] = {id = 25908,texture = "Interface\\Icons\\INV_Staff_07", color = {r = 0, g = 0, b = 0, a = 1}, enabled = true, priority = 0}, -- Tranquil Air Totem
}
local localizedTotemData = {
["default"] = {
[string_lower(select(1, GetSpellInfo(3599)))] = totemData[string_lower("Searing Totem")], -- Searing Totem
[string_lower(select(1, GetSpellInfo(8227)))] = totemData[string_lower("Flametongue Totem")], -- Flametongue Totem
[string_lower(select(1, GetSpellInfo(8190)))] = totemData[string_lower("Magma Totem")], -- Magma Totem
[string_lower(select(1, GetSpellInfo(1535)))] = totemData[string_lower("Fire Nova Totem")], -- Fire Nova Totem
[string_lower(select(1, GetSpellInfo(30706)))] = totemData[string_lower("Totem of Wrath")], -- Totem of Wrath
[string_lower(select(1, GetSpellInfo(32982)))] = totemData[string_lower("Fire Elemental Totem")], -- Fire Elemental Totem
[string_lower(select(1, GetSpellInfo(8181)))] = totemData[string_lower("Frost Resistance Totem")], -- Frost Resistance Totem
-- Water
[string_lower(select(1, GetSpellInfo(8184)))] = totemData[string_lower("Fire Resistance Totem")], -- Fire Resistance Totem
[string_lower(select(1, GetSpellInfo(8166)))] = totemData[string_lower("Poison Cleansing Totem")], -- Poison Cleansing Totem
[string_lower(select(1, GetSpellInfo(8170)))] = totemData[string_lower("Disease Cleansing Totem")], -- Disease Cleansing Totem
[string_lower(select(1, GetSpellInfo(5394)))] = totemData[string_lower("Healing Stream Totem")], -- Healing Stream Totem
[string_lower(select(1, GetSpellInfo(16190)))] = totemData[string_lower("Mana Tide Totem")], -- Mana Tide Totem
[string_lower(select(1, GetSpellInfo(5675)))] = totemData[string_lower("Mana Spring Totem")], -- Mana Spring Totem
-- Earth
[string_lower(select(1, GetSpellInfo(2484)))] = totemData[string_lower("Earthbind Totem")], -- Earthbind Totem
[string_lower(select(1, GetSpellInfo(5730)))] = totemData[string_lower("Stoneclaw Totem")], -- Stoneclaw Totem
[string_lower(select(1, GetSpellInfo(8071)))] = totemData[string_lower("Stoneskin Totem")], -- Stoneskin Totem
[string_lower(select(1, GetSpellInfo(8075)))] = totemData[string_lower("Strength of Earth Totem")], -- Strength of Earth Totem
[string_lower(select(1, GetSpellInfo(33663)))] = totemData[string_lower("Earth Elemental Totem")], -- Earth Elemental Totem
[string_lower(select(1, GetSpellInfo(8143)))] = totemData[string_lower("Tremor Totem")], -- Tremor Totem
-- Air
[string_lower(select(1, GetSpellInfo(8177)))] = totemData[string_lower("Grounding Totem")], -- Grounding Totem
[string_lower(select(1, GetSpellInfo(8835)))] = totemData[string_lower("Grace of Air Totem")], -- Grace of Air Totem
[string_lower(select(1, GetSpellInfo(10595)))] = totemData[string_lower("Nature Resistance Totem")], -- Nature Resistance Totem
[string_lower(select(1, GetSpellInfo(8512)))] = totemData[string_lower("Windfury Totem")], -- Windfury Totem
[string_lower(select(1, GetSpellInfo(6495)))] = totemData[string_lower("Sentry Totem")], -- Sentry Totem
[string_lower(select(1, GetSpellInfo(15107)))] = totemData[string_lower("Windwall Totem")], -- Windwall Totem
[string_lower(select(1, GetSpellInfo(3738)))] = totemData[string_lower("Wrath of Air Totem")], -- Wrath of Air Totem
[string_lower(select(1, GetSpellInfo(25908)))] = totemData[string_lower("Tranquil Air Totem")], -- Tranquil Air Totem
},
["frFR"] = {
[string_lower("Totem incendiaire")] = totemData[string_lower("Searing Totem")],
[string_lower("Totem Langue de feu")] = totemData[string_lower("Flametongue Totem")],
[string_lower("Totem de lien terrestre")] = totemData[string_lower("Earthbind Totem")],
[string_lower("Totem de Griffes de pierre")] = totemData[string_lower("Stoneclaw Totem")],
[string_lower("Totem Nova de feu")] = totemData[string_lower("Fire Nova Totem")],
[string_lower("Totem de Magma")] = totemData[string_lower("Magma Totem")],
[string_lower("Totem de courroux")] = totemData[string_lower("Totem of Wrath")],
[string_lower("Totem d'\195\169lementaire de feu")] = totemData[string_lower("Fire Elemental Totem")],
[string_lower("Totem d'\195\169l\195\169mentaire de feu")] = totemData[string_lower("Fire Elemental Totem")],
[string_lower("Totem de Peau de pierre")] = totemData[string_lower("Stoneskin Totem")],
[string_lower("Totem d'\195\169lementaire de terre")] = totemData[string_lower("Earth Elemental Totem")],
[string_lower("Totem d'\195\169l\195\169mentaire de terre")] = totemData[string_lower("Earth Elemental Totem")],
[string_lower("Totem de Force de la Terre")] = totemData[string_lower("Strength of Earth Totem")],
[string_lower("Totem de r\195\169sistance au Givre")] = totemData[string_lower("Frost Resistance Totem")],
[string_lower("Totem de r\195\169sistance au Feu")] = totemData[string_lower("Fire Resistance Totem")],
[string_lower("Totem de Gl\195\168be")] = totemData[string_lower("Grounding Totem")],
[string_lower("Totem de Gr\195\162ce a\195\169rienne")] = totemData[string_lower("Grace of Air Totem")],
[string_lower("Totem de R\195\169sistance \195\160 la Nature")] = totemData[string_lower("Nature Resistance Totem")],
[string_lower("Totem Furie-des-vents")] = totemData[string_lower("Windfury Totem")],
[string_lower("Totem Sentinelle")] = totemData[string_lower("Sentry Totem")],
[string_lower("Totem de Mur des vents")] = totemData[string_lower("Windwall Totem")],
[string_lower("Totem de courroux de l'air")] = totemData[string_lower("Wrath of Air Totem")],
[string_lower("Totem de S\195\169isme")] = totemData[string_lower("Tremor Totem")],
[string_lower("Totem gu\195\169risseur")] = totemData[string_lower("Healing Stream Totem")],
[string_lower("Totem de Purification du poison")] = totemData[string_lower("Poison Cleansing Totem")],
[string_lower("Totem Fontaine de mana")] = totemData[string_lower("Mana Spring Totem")],
[string_lower("Totem de Purification des maladies")] = totemData[string_lower("Disease Cleansing Totem")],
[string_lower("Totem de purification")] = totemData[string_lower("Disease Cleansing Totem")],
[string_lower("Totem de Vague de mana")] = totemData[string_lower("Mana Tide Totem")],
[string_lower("Totem de Tranquillit\195\169 de l'air")] = totemData[string_lower("Tranquil Air Totem")],
}
}
local function GetTotemColorDefaultOptions()
local defaultDB = {}
local options = {}
local indexedList = {}
for k,v in pairs(totemData) do
tinsert(indexedList, {name = k, id = v.id, color = v.color, texture = v.texture, enabled = v.enabled})
end
table.sort(indexedList, function (a, b)
return a.name < b.name
end)
for i=1,#indexedList do
defaultDB["totem" .. indexedList[i].id] = {color = indexedList[i].color, enabled = indexedList[i].enabled, alpha = 0.6}
options["totem" .. indexedList[i].id] = {
order = i+1,
name = select(1, GetSpellInfo(indexedList[i].id)),
--inline = true,
width = "3.0",
type = "group",
icon = indexedList[i].texture,
args = {
headerTotemConfig = {
type = "header",
name = format("|T%s:20|t %s", indexedList[i].texture, select(1, GetSpellInfo(indexedList[i].id))),
order = 1,
},
enabled = {
order = 2,
name = "Enabled",
desc = "Enable " .. format("|T%s:20|t %s", indexedList[i].texture, select(1, GetSpellInfo(indexedList[i].id))),
type = "toggle",
width = "full",
get = function(info) return Gladdy.dbi.profile.npTotemColors["totem" .. indexedList[i].id].enabled end,
set = function(info, value)
Gladdy.dbi.profile.npTotemColors["totem" .. indexedList[i].id].enabled = value
Gladdy:UpdateFrame()
end
},
color = {
type = "color",
name = L["Border color"],
desc = L["Color of the border"],
order = 3,
hasAlpha = true,
width = "full",
get = function(info)
local key = info.arg or info[#info]
return Gladdy.dbi.profile.npTotemColors["totem" .. indexedList[i].id].color.r,
Gladdy.dbi.profile.npTotemColors["totem" .. indexedList[i].id].color.g,
Gladdy.dbi.profile.npTotemColors["totem" .. indexedList[i].id].color.b,
Gladdy.dbi.profile.npTotemColors["totem" .. indexedList[i].id].color.a
end,
set = function(info, r, g, b, a)
local key = info.arg or info[#info]
Gladdy.dbi.profile.npTotemColors["totem" .. indexedList[i].id].color.r,
Gladdy.dbi.profile.npTotemColors["totem" .. indexedList[i].id].color.g,
Gladdy.dbi.profile.npTotemColors["totem" .. indexedList[i].id].color.b,
Gladdy.dbi.profile.npTotemColors["totem" .. indexedList[i].id].color.a = r, g, b, a
Gladdy:UpdateFrame()
end,
},
alpha = {
type = "range",
name = L["Alpha"],
order = 4,
min = 0,
max = 1,
step = 0.1,
width = "full",
get = function(info)
return Gladdy.dbi.profile.npTotemColors["totem" .. indexedList[i].id].alpha
end,
set = function(info, value)
Gladdy.dbi.profile.npTotemColors["totem" .. indexedList[i].id].alpha = value
Gladdy:UpdateFrame()
end
},
customText = {
type = "input",
name = L["Custom totem name"],
order = 5,
width = "full",
get = function(info) return Gladdy.dbi.profile.npTotemColors["totem" .. indexedList[i].id].customText end,
set = function(info, value) Gladdy.dbi.profile.npTotemColors["totem" .. indexedList[i].id].customText = value Gladdy:UpdateFrame() end
},
}
}
end
return defaultDB, options, indexedList
end
local function GetTotemOptions()
local indexedList = select(3, GetTotemColorDefaultOptions())
local colorList = {}
for i=1, #indexedList do
tinsert(colorList, Gladdy.dbi.profile.npTotemColors["totem" .. indexedList[i].id])
end
return colorList
end
function Gladdy:GetTotemColors()
return GetTotemColorDefaultOptions()
end
---------------------------------------------------
-- Core
---------------------------------------------------
local TotemPlates = Gladdy:NewModule("TotemPlates", nil, {
npTotems = true,
npTotemPlatesBorderStyle = "Interface\\AddOns\\Gladdy\\Images\\Border_rounded_blp",
npTotemPlatesSize = 40,
npTotemPlatesWidthFactor = 1,
npTremorFont = "DorisPP",
npTremorFontSize = 10,
npTremorFontXOffset = 0,
npTremorFontYOffset = 0,
npTotemPlatesAlpha = 0.6,
npTotemPlatesAlphaAlways = false,
npTotemPlatesAlphaAlwaysTargeted = false,
npTotemColors = select(1, GetTotemColorDefaultOptions())
})
LibStub("AceHook-3.0"):Embed(TotemPlates)
LibStub("AceTimer-3.0"):Embed(TotemPlates)
function TotemPlates.OnEvent(self, event, ...)
TotemPlates[event](self, ...)
end
function TotemPlates:Initialize()
self.numChildren = 0
self.activeTotemNameplates = {}
self.totemPlateCache = {}
self:RegisterEvent("PLAYER_ENTERING_WORLD")
self:RegisterEvent("NAME_PLATE_UNIT_ADDED")
self:RegisterEvent("NAME_PLATE_UNIT_REMOVED")
self:RegisterEvent("PLAYER_TARGET_CHANGED")
self:SetScript("OnEvent", TotemPlates.OnEvent)
end
function TotemPlates:PLAYER_ENTERING_WORLD()
self.numChildren = 0
self.activeTotemNameplates = {}
end
function TotemPlates:Reset()
--self:CancelAllTimers()
--self:UnhookAll()
end
function TotemPlates:UpdateFrameOnce()
for k,nameplate in pairs(self.activeTotemNameplates) do
local totemDataEntry = nameplate.gladdyTotemFrame.totemDataEntry
nameplate.gladdyTotemFrame:SetWidth(Gladdy.db.npTotemPlatesSize * Gladdy.db.npTotemPlatesWidthFactor)
nameplate.gladdyTotemFrame:SetHeight(Gladdy.db.npTotemPlatesSize)
nameplate.gladdyTotemFrame.totemBorder:SetTexture(Gladdy.db.npTotemPlatesBorderStyle)
nameplate.gladdyTotemFrame.totemBorder:SetVertexColor(Gladdy.db.npTotemColors["totem" .. totemDataEntry.id].color.r,
Gladdy.db.npTotemColors["totem" .. totemDataEntry.id].color.g,
Gladdy.db.npTotemColors["totem" .. totemDataEntry.id].color.b,
Gladdy.db.npTotemColors["totem" .. totemDataEntry.id].color.a)
nameplate.gladdyTotemFrame.totemName:SetPoint("TOP", nameplate.gladdyTotemFrame, "BOTTOM", Gladdy.db.npTremorFontXOffset, Gladdy.db.npTremorFontYOffset)
nameplate.gladdyTotemFrame.totemName:SetFont(Gladdy.LSM:Fetch("font", Gladdy.db.npTremorFont), Gladdy.db.npTremorFontSize, "OUTLINE")
nameplate.gladdyTotemFrame.totemName:SetText(Gladdy.db.npTotemColors["totem" .. totemDataEntry.id].customText or "")
self:SetTotemAlpha(nameplate.gladdyTotemFrame, k)
nameplate.UnitFrame.selectionHighlight:SetPoint("TOPLEFT", nameplate.gladdyTotemFrame, "TOPLEFT", Gladdy.db.npTotemPlatesSize/16, -Gladdy.db.npTotemPlatesSize/16)
nameplate.UnitFrame.selectionHighlight:SetPoint("BOTTOMRIGHT", nameplate.gladdyTotemFrame, "BOTTOMRIGHT", -Gladdy.db.npTotemPlatesSize/16, Gladdy.db.npTotemPlatesSize/16)
end
for i,gladdyTotemFrame in ipairs(self.totemPlateCache) do
gladdyTotemFrame:SetWidth(Gladdy.db.npTotemPlatesSize * Gladdy.db.npTotemPlatesWidthFactor)
gladdyTotemFrame:SetHeight(Gladdy.db.npTotemPlatesSize)
gladdyTotemFrame.totemBorder:SetTexture(Gladdy.db.npTotemPlatesBorderStyle)
gladdyTotemFrame.totemName:SetFont(Gladdy.LSM:Fetch("font", Gladdy.db.npTremorFont), Gladdy.db.npTremorFontSize, "OUTLINE")
gladdyTotemFrame.totemName:SetPoint("TOP", gladdyTotemFrame, "BOTTOM", Gladdy.db.npTremorFontXOffset, Gladdy.db.npTremorFontYOffset)
end
end
---------------------------------------------------
-- Nameplate functions
---------------------------------------------------
function TotemPlates:PLAYER_TARGET_CHANGED()
for k,nameplate in pairs(self.activeTotemNameplates) do
TotemPlates:SetTotemAlpha(nameplate.gladdyTotemFrame, k)
end
end
function TotemPlates:NAME_PLATE_UNIT_ADDED(...)
local unitID = ...
local nameplateName = UnitName(unitID)
local totemName = string_gsub(nameplateName, "^%s+", "") --trim
totemName = string_gsub(totemName, "%s+$", "") --trim
totemName = string_gsub(totemName, "%s+[I,V,X]+$", "") --trim rank
totemName = string_lower(totemName)
local nameplate = C_NamePlate.GetNamePlateForUnit(unitID)
local totemDataEntry = localizedTotemData["default"][totemName]
if totemDataEntry and Gladdy.db.npTotemColors["totem" .. totemDataEntry.id].enabled then-- modify this nameplates
if #self.totemPlateCache > 0 then
nameplate.gladdyTotemFrame = tremove(self.totemPlateCache, #self.totemPlateCache)
else
nameplate.gladdyTotemFrame = CreateFrame("Frame", nil)
nameplate.gladdyTotemFrame:SetIgnoreParentAlpha(true)
nameplate.gladdyTotemFrame:SetWidth(Gladdy.db.npTotemPlatesSize * Gladdy.db.npTotemPlatesWidthFactor)
nameplate.gladdyTotemFrame:SetHeight(Gladdy.db.npTotemPlatesSize)
nameplate.gladdyTotemFrame.totemIcon = nameplate.gladdyTotemFrame:CreateTexture(nil, "BACKGROUND")
nameplate.gladdyTotemFrame.totemIcon:ClearAllPoints()
nameplate.gladdyTotemFrame.totemIcon:SetPoint("TOPLEFT", nameplate.gladdyTotemFrame, "TOPLEFT")
nameplate.gladdyTotemFrame.totemIcon:SetPoint("BOTTOMRIGHT", nameplate.gladdyTotemFrame, "BOTTOMRIGHT")
nameplate.gladdyTotemFrame.totemBorder = nameplate.gladdyTotemFrame:CreateTexture(nil, "BORDER")
nameplate.gladdyTotemFrame.totemBorder:ClearAllPoints()
nameplate.gladdyTotemFrame.totemBorder:SetPoint("TOPLEFT", nameplate.gladdyTotemFrame, "TOPLEFT")
nameplate.gladdyTotemFrame.totemBorder:SetPoint("BOTTOMRIGHT", nameplate.gladdyTotemFrame, "BOTTOMRIGHT")
nameplate.gladdyTotemFrame.totemBorder:SetTexture(Gladdy.db.npTotemPlatesBorderStyle)
nameplate.gladdyTotemFrame.totemName = nameplate.gladdyTotemFrame:CreateFontString(nil, "OVERLAY")
nameplate.gladdyTotemFrame.totemName:SetFont(Gladdy.LSM:Fetch("font", Gladdy.db.npTremorFont), Gladdy.db.npTremorFontSize, "OUTLINE")
nameplate.gladdyTotemFrame.totemName:SetPoint("TOP", nameplate.gladdyTotemFrame, "BOTTOM", Gladdy.db.npTremorFontXOffset, Gladdy.db.npTremorFontYOffset)
end
nameplate.gladdyTotemFrame.totemDataEntry = totemDataEntry
nameplate.gladdyTotemFrame.parent = nameplate
nameplate.gladdyTotemFrame:SetParent(nameplate)
nameplate.gladdyTotemFrame:ClearAllPoints()
nameplate.gladdyTotemFrame:SetPoint("CENTER", nameplate, "CENTER", 0, 0)
nameplate.gladdyTotemFrame.totemIcon:SetTexture(totemDataEntry.texture)
nameplate.gladdyTotemFrame.totemBorder:SetVertexColor(Gladdy.db.npTotemColors["totem" .. totemDataEntry.id].color.r,
Gladdy.db.npTotemColors["totem" .. totemDataEntry.id].color.g,
Gladdy.db.npTotemColors["totem" .. totemDataEntry.id].color.b,
Gladdy.db.npTotemColors["totem" .. totemDataEntry.id].color.a)
nameplate.gladdyTotemFrame.totemName:SetText(Gladdy.db.npTotemColors["totem" .. totemDataEntry.id].customText or "")
nameplate.gladdyTotemFrame:Show()
TotemPlates:SetTotemAlpha(nameplate.gladdyTotemFrame, unitID)
nameplate.UnitFrame:SetAlpha(0)
nameplate.UnitFrame.point = select(2, nameplate.UnitFrame.selectionHighlight:GetPoint())
nameplate.UnitFrame.selectionHighlight:ClearAllPoints()
nameplate.UnitFrame.selectionHighlight:SetPoint("TOPLEFT", nameplate.gladdyTotemFrame, "TOPLEFT", Gladdy.db.npTotemPlatesSize/16, -Gladdy.db.npTotemPlatesSize/16)
nameplate.UnitFrame.selectionHighlight:SetPoint("BOTTOMRIGHT", nameplate.gladdyTotemFrame, "BOTTOMRIGHT", -Gladdy.db.npTotemPlatesSize/16, Gladdy.db.npTotemPlatesSize/16)
nameplate.UnitFrame:SetScript("OnHide", function(unitFrame)
unitFrame:SetAlpha(1)
unitFrame.selectionHighlight:ClearAllPoints()
unitFrame.selectionHighlight:SetPoint("TOPLEFT", unitFrame.point, "TOPLEFT")
unitFrame.selectionHighlight:SetPoint("BOTTOMRIGHT", unitFrame.point, "BOTTOMRIGHT")
unitFrame:SetScript("OnHide", nil)
end)
self.activeTotemNameplates[unitID] = nameplate
end
end
function TotemPlates:NAME_PLATE_UNIT_REMOVED(...)
local unitID = ...
local nameplate = C_NamePlate.GetNamePlateForUnit(unitID)
self.activeTotemNameplates[unitID] = nil
if nameplate.gladdyTotemFrame then
nameplate.gladdyTotemFrame:Hide()
nameplate.gladdyTotemFrame:SetParent(nil)
tinsert(self.totemPlateCache, nameplate.gladdyTotemFrame)
nameplate.gladdyTotemFrame = nil
end
end
function TotemPlates:SetTotemAlpha(gladdyTotemFrame, unitID)
local targetExists = UnitExists("target")
local totemDataEntry = gladdyTotemFrame.totemDataEntry
if targetExists then
if (UnitIsUnit(unitID, "target")) then -- is target
if Gladdy.db.npTotemPlatesAlphaAlwaysTargeted then
gladdyTotemFrame:SetAlpha(Gladdy.db.npTotemColors["totem" .. totemDataEntry.id].alpha)
else
gladdyTotemFrame:SetAlpha(1)
end
else -- is not target
gladdyTotemFrame:SetAlpha(Gladdy.db.npTotemColors["totem" .. totemDataEntry.id].alpha)
end
else -- no target
if Gladdy.db.npTotemPlatesAlphaAlways then
gladdyTotemFrame:SetAlpha(Gladdy.db.npTotemColors["totem" .. totemDataEntry.id].alpha)
else
gladdyTotemFrame:SetAlpha(0.95)
end
end
end
---------------------------------------------------
-- Interface options
---------------------------------------------------
function TotemPlates:GetOptions()
return {
headerTotems = {
type = "header",
name = L["Totem General"],
order = 2,
},
npTotems = Gladdy:option({
type = "toggle",
name = L["Totem icons on/off"],
desc = L["Turns totem icons instead of nameplates on or off. (Requires reload)"],
order = 3,
}),
group = {
type = "group",
childGroups = "tree",
name = "Frame",
order = 4,
args = {
icon = {
type = "group",
name = L["Icon"],
order = 1,
args = {
header = {
type = "header",
name = L["Icon"],
order = 1,
},
npTotemPlatesSize = Gladdy:option({
type = "range",
name = L["Totem size"],
desc = L["Size of totem icons"],
order = 5,
min = 20,
max = 100,
step = 1,
}),
npTotemPlatesWidthFactor = Gladdy:option({
type = "range",
name = L["Icon Width Factor"],
desc = L["Stretches the icon"],
order = 6,
min = 0.5,
max = 2,
step = 0.05,
}),
},
},
font = {
type = "group",
name = L["Font"],
order = 2,
args = {
header = {
type = "header",
name = L["Icon"],
order = 1,
},
npTremorFont = Gladdy:option({
type = "select",
name = L["Font"],
desc = L["Font of the custom totem name"],
order = 11,
dialogControl = "LSM30_Font",
values = AceGUIWidgetLSMlists.font,
}),
npTremorFontSize = Gladdy:option({
type = "range",
name = L["Size"],
desc = L["Scale of the font"],
order = 12,
min = 1,
max = 50,
step = 0.1,
}),
npTremorFontXOffset = Gladdy:option({
type = "range",
name = L["Horizontal offset"],
desc = L["Scale of the font"],
order = 13,
min = -300,
max = 300,
step = 1,
}),
npTremorFontYOffset = Gladdy:option({
type = "range",
name = L["Vertical offset"],
desc = L["Scale of the font"],
order = 14,
min = -300,
max = 300,
step = 1,
}),
},
},
alpha = {
type = "group",
name = L["Alpha"],
order = 4,
args = {
header = {
type = "header",
name = L["Alpha"],
order = 1,
},
npTotemPlatesAlphaAlways = Gladdy:option({
type = "toggle",
name = L["Apply alpha when no target"],
desc = L["Always applies alpha, even when you don't have a target. Else it is 1."],
width = "full",
order = 21,
}),
npTotemPlatesAlphaAlwaysTargeted = Gladdy:option({
type = "toggle",
name = L["Apply alpha when targeted"],
desc = L["Always applies alpha, even when you target the totem. Else it is 1."],
width = "full",
order = 22,
}),
npAllTotemAlphas = {
type = "range",
name = L["All totem border alphas (configurable per totem)"],
min = 0,
max = 1,
step = 0.1,
width = "double",
order = 23,
get = function(info)
local alphas = GetTotemOptions()
for i=2, #alphas do
if alphas[i].alpha ~= alphas[1].alpha then
return ""
end
end
return alphas[1].alpha
end,
set = function(info, value)
local alphas = GetTotemOptions()
for i=1, #alphas do
alphas[i].alpha = value
end
Gladdy:UpdateFrame()
end,
},
},
},
border = {
type = "group",
name = L["Border"],
order = 5,
args = {
header = {
type = "header",
name = L["Border"],
order = 1,
},
npTotemPlatesBorderStyle = Gladdy:option({
type = "select",
name = L["Totem icon border style"],
order = 41,
values = Gladdy:GetIconStyles()
}),
npAllTotemColors = {
type = "color",
name = L["All totem border color"],
order = 42,
hasAlpha = true,
get = function(info)
local colors = GetTotemOptions()
local color = colors[1].color
for i=2, #colors do
if colors[i].r ~= color.r or colors[i].color.r ~= color.r or colors[i].color.r ~= color.r or colors[i].color.r ~= color.r then
return 0, 0, 0, 0
end
end
return color.r, color.g, color.b, color.a
end,
set = function(info, r, g, b, a)
local colors = GetTotemOptions()
for i=1, #colors do
colors[i].color.r = r
colors[i].color.g = g
colors[i].color.b = b
colors[i].color.a = a
end
Gladdy:UpdateFrame()
end,
},
},
},
},
},
npTotemColors = {
order = 50,
name = "Customize Totems",
type = "group",
childGroups = "tree",
args = select(2, Gladdy:GetTotemColors())
},
}
end

364
Modules/Trinket.lua Normal file
View File

@ -0,0 +1,364 @@
local ceil, floor, string_format, tonumber = ceil, floor, string.format, tonumber
local CreateFrame = CreateFrame
local GetTime = GetTime
local Gladdy = LibStub("Gladdy")
local L = Gladdy.L
local Trinket = Gladdy:NewModule("Trinket", nil, {
trinketFont = "DorisPP",
trinketFontScale = 1,
trinketEnabled = true,
trinketSize = 60 + 20 + 1,
trinketWidthFactor = 0.9,
trinketPos = "RIGHT",
trinketBorderStyle = "Interface\\AddOns\\Gladdy\\Images\\Border_rounded_blp",
trinketBorderColor = { r = 0, g = 0, b = 0, a = 1 },
trinketDisableCircle = false,
trinketCooldownAlpha = 1,
})
LibStub("AceComm-3.0"):Embed(Trinket)
function Trinket:Initialize()
self.frames = {}
self:RegisterMessage("JOINED_ARENA")
end
function Trinket:CreateFrame(unit)
local trinket = CreateFrame("Button", "GladdyTrinketButton" .. unit, Gladdy.buttons[unit])
trinket.texture = trinket:CreateTexture(nil, "BACKGROUND")
trinket.texture:SetAllPoints(trinket)
trinket.texture:SetTexture("Interface\\Icons\\INV_Jewelry_TrinketPVP_02")
trinket.cooldown = CreateFrame("Cooldown", nil, trinket, "CooldownFrameTemplate")
trinket.cooldown.noCooldownCount = true --Gladdy.db.trinketDisableOmniCC
trinket.cooldown:SetHideCountdownNumbers(true)
trinket.cooldownFrame = CreateFrame("Frame", nil, trinket)
trinket.cooldownFrame:ClearAllPoints()
trinket.cooldownFrame:SetPoint("TOPLEFT", trinket, "TOPLEFT")
trinket.cooldownFrame:SetPoint("BOTTOMRIGHT", trinket, "BOTTOMRIGHT")
trinket.cooldownFont = trinket.cooldownFrame:CreateFontString(nil, "OVERLAY")
trinket.cooldownFont:SetFont(Gladdy.LSM:Fetch("font", Gladdy.db.trinketFont), 20, "OUTLINE")
--trinket.cooldownFont:SetAllPoints(trinket.cooldown)
trinket.cooldownFont:SetJustifyH("CENTER")
trinket.cooldownFont:SetPoint("CENTER")
trinket.borderFrame = CreateFrame("Frame", nil, trinket)
trinket.borderFrame:SetAllPoints(trinket)
trinket.texture.overlay = trinket.borderFrame:CreateTexture(nil, "OVERLAY")
trinket.texture.overlay:SetAllPoints(trinket)
trinket.texture.overlay:SetTexture(Gladdy.db.trinketBorderStyle)
local function formatTimer(num, numDecimalPlaces)
return tonumber(string_format("%." .. (numDecimalPlaces or 0) .. "f", num))
end
trinket:SetScript("OnUpdate", function(self, elapsed)
if (self.active) then
if (self.timeLeft <= 0) then
self.active = false
self.cooldown:Clear()
Gladdy:SendMessage("TRINKET_READY", unit)
else
self.timeLeft = self.timeLeft - elapsed
end
local timeLeft = ceil(self.timeLeft)
local timeLeftMilliSec = formatTimer(self.timeLeft, 1)
if timeLeft >= 60 then
-- more than 1 minute
self.cooldownFont:SetTextColor(1, 1, 0)
self.cooldownFont:SetText(floor(timeLeft / 60) .. ":" .. string_format("%02.f", floor(timeLeft - floor(timeLeft / 60) * 60)))
self.cooldownFont:SetFont(Gladdy.LSM:Fetch("font", Gladdy.db.trinketFont), (trinket:GetWidth()/2 - 0.15*trinket:GetWidth()) * Gladdy.db.trinketFontScale, "OUTLINE")
elseif timeLeft < 60 and timeLeft >= 21 then
-- between 60s and 21s (green)
self.cooldownFont:SetTextColor(0.7, 1, 0)
self.cooldownFont:SetText(timeLeft)
self.cooldownFont:SetFont(Gladdy.LSM:Fetch("font", Gladdy.db.trinketFont), (trinket:GetWidth()/2 - 1) * Gladdy.db.trinketFontScale, "OUTLINE")
elseif timeLeft < 20.9 and timeLeft >= 11 then
-- between 20s and 11s (green)
self.cooldownFont:SetTextColor(0, 1, 0)
self.cooldownFont:SetText(timeLeft)
self.cooldownFont:SetFont(Gladdy.LSM:Fetch("font", Gladdy.db.trinketFont), (trinket:GetWidth()/2 - 1) * Gladdy.db.trinketFontScale, "OUTLINE")
elseif timeLeftMilliSec <= 10 and timeLeftMilliSec >= 5 then
-- between 10s and 5s (orange)
self.cooldownFont:SetTextColor(1, 0.7, 0)
self.cooldownFont:SetFormattedText("%.1f", timeLeftMilliSec)
self.cooldownFont:SetFont(Gladdy.LSM:Fetch("font", Gladdy.db.trinketFont), (trinket:GetWidth()/2 - 1) * Gladdy.db.trinketFontScale, "OUTLINE")
elseif timeLeftMilliSec < 5 and timeLeftMilliSec > 0 then
-- between 5s and 1s (red)
self.cooldownFont:SetTextColor(1, 0, 0)
self.cooldownFont:SetFormattedText("%.1f", timeLeftMilliSec)
self.cooldownFont:SetFont(Gladdy.LSM:Fetch("font", Gladdy.db.trinketFont), (trinket:GetWidth()/2 - 1) * Gladdy.db.trinketFontScale, "OUTLINE")
else
self.cooldownFont:SetText("")
end
end
end)
self.frames[unit] = trinket
end
function Trinket:UpdateFrame(unit)
local trinket = self.frames[unit]
if (not trinket) then
return
end
local width, height = Gladdy.db.trinketSize * Gladdy.db.trinketWidthFactor, Gladdy.db.trinketSize
trinket:SetWidth(width)
trinket:SetHeight(height)
trinket.cooldown:SetWidth(width - width/16)
trinket.cooldown:SetHeight(height - height/16)
trinket.cooldown:ClearAllPoints()
trinket.cooldown:SetPoint("CENTER", trinket, "CENTER")
trinket.cooldown.noCooldownCount = true -- Gladdy.db.trinketDisableOmniCC
trinket.cooldown:SetAlpha(Gladdy.db.trinketCooldownAlpha)
trinket.texture:ClearAllPoints()
trinket.texture:SetAllPoints(trinket)
trinket.texture.overlay:SetTexture(Gladdy.db.trinketBorderStyle)
trinket.texture.overlay:SetVertexColor(Gladdy.db.trinketBorderColor.r, Gladdy.db.trinketBorderColor.g, Gladdy.db.trinketBorderColor.b, Gladdy.db.trinketBorderColor.a)
trinket:ClearAllPoints()
local margin = Gladdy.db.highlightBorderSize + Gladdy.db.padding
if (Gladdy.db.classIconPos == "LEFT") then
if (Gladdy.db.trinketPos == "RIGHT") then
trinket:SetPoint("TOPLEFT", Gladdy.buttons[unit].healthBar, "TOPRIGHT", margin, 0)
else
trinket:SetPoint("TOPRIGHT", Gladdy.buttons[unit].classIcon, "TOPLEFT", -Gladdy.db.padding, 0)
end
else
if (Gladdy.db.trinketPos == "RIGHT") then
trinket:SetPoint("TOPLEFT", Gladdy.buttons[unit].classIcon, "TOPRIGHT", Gladdy.db.padding, 0)
else
trinket:SetPoint("TOPRIGHT", Gladdy.buttons[unit].healthBar, "TOPLEFT", -margin, 0)
end
end
if (Gladdy.db.trinketEnabled == false) then
trinket:Hide()
else
trinket:Show()
end
end
function Trinket:Reset()
self:UnregisterEvent("ARENA_COOLDOWNS_UPDATE")
self:SetScript("OnEvent", nil)
end
function Trinket:ResetUnit(unit)
local trinket = self.frames[unit]
if (not trinket) then
return
end
trinket.timeLeft = nil
trinket.active = false
trinket.cooldown:Clear()
trinket.cooldownFont:SetText("")
end
function Trinket:Test(unit)
local trinket = self.frames[unit]
if (not trinket) then
return
end
if (unit == "arena2" or unit == "arena3") then
self:Used(unit, GetTime() * 1000, 120000)
end
end
function Trinket:JOINED_ARENA()
self:RegisterEvent("ARENA_COOLDOWNS_UPDATE")
self:SetScript("OnEvent", function(self, event, ...)
if self[event] then
self[event](self, ...)
end
end)
end
function Trinket:ARENA_COOLDOWNS_UPDATE()
for i=1, Gladdy.curBracket do
local unit = "arena" .. i
local spellID, itemID, startTime, duration = C_PvP.GetArenaCrowdControlInfo(unit);
if (spellID) then
if (startTime ~= 0 and duration ~= 0) then
self:Used(unit, startTime, duration)
end
end
end
end
function Trinket:Used(unit, startTime, duration)
local trinket = self.frames[unit]
if (not trinket) then
return
end
if not trinket.active then
trinket.timeLeft = (startTime/1000.0 + duration/1000.0) - GetTime()
if not Gladdy.db.trinketDisableCircle then trinket.cooldown:SetCooldown(startTime/1000.0, duration/1000.0) end
trinket.active = true
Gladdy:SendMessage("TRINKET_USED", unit)
end
end
function Trinket:GetOptions()
return {
headerTrinket = {
type = "header",
name = L["Trinket"],
order = 2,
},
trinketEnabled = Gladdy:option({
type = "toggle",
name = L["Enabled"],
desc = L["Enable trinket icon"],
order = 3,
}),
group = {
type = "group",
childGroups = "tree",
name = "Frame",
order = 4,
args = {
general = {
type = "group",
name = L["Size"],
order = 1,
args = {
header = {
type = "header",
name = L["Size"],
order = 4,
},
trinketSize = Gladdy:option({
type = "range",
name = L["Trinket size"],
min = 5,
max = 100,
step = 1,
order = 4,
}),
trinketWidthFactor = Gladdy:option({
type = "range",
name = L["Icon width factor"],
min = 0.5,
max = 2,
step = 0.05,
order = 6,
}),
},
},
cooldown = {
type = "group",
name = L["Cooldown"],
order = 2,
args = {
header = {
type = "header",
name = L["Cooldown"],
order = 4,
},
trinketDisableCircle = Gladdy:option({
type = "toggle",
name = L["No Cooldown Circle"],
order = 7,
}),
trinketCooldownAlpha = Gladdy:option({
type = "range",
name = L["Cooldown circle alpha"],
min = 0,
max = 1,
step = 0.1,
order = 8,
}),
},
},
font = {
type = "group",
name = L["Font"],
order = 3,
args = {
header = {
type = "header",
name = L["Font"],
order = 4,
},
trinketFont = Gladdy:option({
type = "select",
name = L["Font"],
desc = L["Font of the cooldown"],
order = 11,
dialogControl = "LSM30_Font",
values = AceGUIWidgetLSMlists.font,
}),
trinketFontScale = Gladdy:option({
type = "range",
name = L["Font scale"],
desc = L["Scale of the font"],
order = 12,
min = 0.1,
max = 2,
step = 0.1,
}),
},
},
position = {
type = "group",
name = L["Position"],
order = 4,
args = {
header = {
type = "header",
name = L["Position"],
order = 4,
},
trinketPos = Gladdy:option({
type = "select",
name = L["Trinket position"],
desc = L["This changes positions of the trinket"],
order = 21,
values = {
["LEFT"] = L["Left"],
["RIGHT"] = L["Right"],
},
}),
},
},
border = {
type = "group",
name = L["Border"],
order = 4,
args = {
header = {
type = "header",
name = L["Border"],
order = 4,
},
trinketBorderStyle = Gladdy:option({
type = "select",
name = L["Border style"],
order = 31,
values = Gladdy:GetIconStyles()
}),
trinketBorderColor = Gladdy:colorOption({
type = "color",
name = L["Border color"],
desc = L["Color of the border"],
order = 32,
hasAlpha = true,
}),
},
},
},
},
}
end

46
Modules/VersionCheck.lua Normal file
View File

@ -0,0 +1,46 @@
local UnitName = UnitName
local Gladdy = LibStub("Gladdy")
local L = Gladdy.L
local VersionCheck = Gladdy:NewModule("VersionCheck", 1, {
})
LibStub("AceComm-3.0"):Embed(VersionCheck)
function VersionCheck:Initialize()
self.frames = {}
self:RegisterMessage("JOINED_ARENA")
self.playerName = UnitName("player")
end
function VersionCheck:Reset()
self:UnregisterComm("GladdyVCheck")
end
function VersionCheck:JOINED_ARENA()
self:RegisterComm("GladdyVCheck", VersionCheck.OnCommReceived)
end
function VersionCheck:Test(unit)
if unit == "arena1" then
self:RegisterComm("GladdyVCheck", VersionCheck.OnCommReceived)
self:SendCommMessage("GladdyVCheck", Gladdy.version, "RAID", self.playerName)
end
end
function VersionCheck.OnCommReceived(prefix, message, distribution, sender)
if sender ~= VersionCheck.playerName then
local addonVersion = Gladdy.version
if (message == addonVersion) then
--Gladdy:Print("Version", "\"".. addonVersion.."\"", "is up to date")
else
Gladdy:Warn("Current version", "\"".. addonVersion.."\"", "is outdated. Most recent version is", "\"".. message.."\"")
Gladdy:Warn("Please download the latest Gladdy version at:")
Gladdy:Warn("https://github.com/XiconQoo/Gladdy")
end
end
end
function VersionCheck:GetOptions()
return nil
end

288
Modules/XiconProfiles.lua Normal file
View File

@ -0,0 +1,288 @@
local Gladdy = LibStub("Gladdy")
local L = Gladdy.L
local XiconProfiles = Gladdy:NewModule("XiconProfiles", nil, {
})
function XiconProfiles:ApplyKlimp()
Gladdy.db.castBarXOffset = -7
Gladdy.db.powerActual = false
Gladdy.db.npCastbarsBorderSize = 4
Gladdy.db.healthBarTexture = "Minimalist"
Gladdy.db.highlight = false
Gladdy.db.healthMax = false
Gladdy.db.castBarYOffset = -24
Gladdy.db.castBarFont = "Friz Quadrata TT"
Gladdy.db.drXOffset = -7
Gladdy.db.classIconBorderColor.a = 0.6200000047683716
Gladdy.db.auraBorderStyle = "Interface\\AddOns\\Gladdy\\Images\\Border_squared_blp"
Gladdy.db.powerBarHeight = 7
Gladdy.db.powerBarFontSize = 8
Gladdy.db.announcements.dest = "party"
Gladdy.db.powerMax = false
Gladdy.db.healthBarFontSize = 17
Gladdy.db.healthBarBorderSize = 5
Gladdy.db.npCastbarsWidth = 85
Gladdy.db.npCastbarsTexture = "Minimalist"
Gladdy.db.cooldown = false
Gladdy.db.barWidth = 190
Gladdy.db.healthBarBgColor.a = 0.6700000166893005
Gladdy.db.drCooldownPos = "LEFT"
Gladdy.db.npCastbarsFont = "Friz Quadrata TT"
Gladdy.db.trinketSize = 40
Gladdy.db.y = 501.7654729182068
Gladdy.db.x = 1048.626941536808
Gladdy.db.bottomMargin = 2
Gladdy.db.npCastbarsIconSize = 14
Gladdy.db.castBarTexture = "Minimalist"
Gladdy.db.drFont = "Friz Quadrata TT"
Gladdy.db.highlightBorderSize = 1
Gladdy.db.healthBarFont = "Friz Quadrata TT"
Gladdy.db.padding = 0
Gladdy.db.castBarBorderSize = 5
Gladdy.db.powerBarFontColor.a = 0
Gladdy.db.classIconSize = 40
Gladdy.db.npCastbarsHeight = 14
Gladdy.db.castBarIconColor.a = 0.6200000047683716
Gladdy.db.trinketFontScale = 1.3
Gladdy.db.trinketBorderColor.a = 0.6200000047683716
Gladdy.db.leaderBorder = false
Gladdy.db.powerPercentage = true
Gladdy.db.drYOffset = 33
Gladdy.db.healthBarHeight = 40
Gladdy.db.powerBarTexture = "Minimalist"
Gladdy.db.cooldownFont = "Friz Quadrata TT"
Gladdy.db.powerBarFont = "Friz Quadrata TT"
Gladdy.db.auraFont = "Friz Quadrata TT"
Gladdy.db.powerBarBorderSize = 3
Gladdy.db.trinketFont = "Friz Quadrata TT"
Gladdy.db.castBarIconSize = 20
Gladdy.db.cooldownYOffset = 15.10000000000002
Gladdy.db.cooldownXOffset = 5
Gladdy.db.cooldownMaxIconsPerLine = 4
Gladdy.db.cooldownBorderStyle = "Interface\\AddOns\\Gladdy\\Images\\Border_squared_blp"
Gladdy.db.cooldownYPos = "RIGHT"
Gladdy.db.cooldownCooldownAlpha = 0.6000000000000001
Gladdy.db.cooldownSize = 25.25495910644531
Gladdy.db.cooldownFontScale = 0.6
Gladdy.db.cooldownBorderColor = {
b = 0.3019607843137255,
g = 0.3019607843137255,
r = 0.3019607843137255,
}
Gladdy.db.locked = true
Gladdy.db.classIconWidthFactor = 1
Gladdy.db.buffsFontScale = 0.8
Gladdy.db.buffsIconSize = 24
Gladdy.db.buffsCooldownAlpha = 0.8
Gladdy.db.trinketWidthFactor = 1
Gladdy.db.frameScale = 1
Gladdy.db.drWidthFactor = 1.3
Gladdy:UpdateFrame()
end
function XiconProfiles:ApplyKnall()
Gladdy.db["cooldownCooldownAlpha"] = 0.6000000000000001
Gladdy.db["buffsIconPadding"] = 1.5
Gladdy.db["powerBarBorderSize"] = 5.5
Gladdy.db["trinketSize"] = 66
Gladdy.db["cooldownFontScale"] = 0.8
Gladdy.db["healthBarHeight"] = 54
Gladdy.db["drYOffset"] = -14
Gladdy.db["classIconSize"] = 70
Gladdy.db["padding"] = 0
Gladdy.db["buffsFontScale"] = 0.8
Gladdy.db["healthBarFontColor"]["a"] = 0
Gladdy.db["buffsCooldownGrowDirection"] = "LEFT"
Gladdy.db["cooldownXOffset"] = 1
Gladdy.db["castBarIconSize"] = 26
Gladdy.db["bottomMargin"] = -35
Gladdy.db["y"] = 457.111085058903
Gladdy.db["x"] = 993.110763706718
Gladdy.db["locked"] = true
Gladdy.db["drCooldownPos"] = "LEFT"
Gladdy.db["castBarWidth"] = 162
Gladdy.db["healthBarBorderSize"] = 8.5
Gladdy.db["buffsYOffset"] = -47
Gladdy.db["frameScale"] = 0.9
Gladdy.db["announcements"]["dest"] = "fct"
Gladdy.db["powerBarFontSize"] = 8.576186180114746
Gladdy.db["powerBarHeight"] = 11
Gladdy.db["drIconPadding"] = 2
Gladdy.db["buffsXOffset"] = -245.7
Gladdy.db["castBarYOffset"] = -13.59999999999997
Gladdy.db["drFontScale"] = 0.8
Gladdy.db["castBarHeight"] = 26
Gladdy.db["castBarHeight"] = 26
Gladdy.db["buffsCooldownAlpha"] = 0.8
Gladdy.db["drCooldownAlpha"] = 0.7000000000000001
Gladdy.db["buffsIconSize"] = 35
Gladdy:UpdateFrame()
end
function XiconProfiles:ApplyClassic()
Gladdy.db["buffsIconSize"] = 29
Gladdy.db["drCooldownAlpha"] = 0.8
Gladdy.db["castBarBgColor"] = {
["a"] = 0.4000000357627869,
["b"] = 0.7372549019607844,
["g"] = 0.7372549019607844,
["r"] = 0.7372549019607844,
}
Gladdy.db["npCastbarsBorderSize"] = 4
Gladdy.db["healthBarTexture"] = "Minimalist"
Gladdy.db["drFontScale"] = 0.9
Gladdy.db["highlight"] = false
Gladdy.db["buffsCooldownPos"] = "LEFT"
Gladdy.db["castBarYOffset"] = -67
Gladdy.db["castBarFont"] = "Friz Quadrata TT"
Gladdy.db["buffsXOffset"] = -1
Gladdy.db["drXOffset"] = -1
Gladdy.db["classIconBorderColor"]["a"] = 0
Gladdy.db["cooldownYOffset"] = 10
Gladdy.db["auraBorderStyle"] = "Interface\\AddOns\\Gladdy\\Images\\Border_squared_blp"
Gladdy.db["powerBarHeight"] = 16
Gladdy.db["powerBarFontSize"] = 10.21056747436523
Gladdy.db["announcements"]["dest"] = "party"
Gladdy.db["healthBarFontSize"] = 13.42293167114258
Gladdy.db["buffsYOffset"] = -2.099999999999966
Gladdy.db["healthBarBorderSize"] = 4
Gladdy.db["healthBarBorderStyle"] = "Gladdy Tooltip squared"
Gladdy.db["barWidth"] = 190
Gladdy.db["castBarWidth"] = 265
Gladdy.db["cooldownMaxIconsPerLine"] = 4
Gladdy.db["drCooldownPos"] = "LEFT"
Gladdy.db["locked"] = true
Gladdy.db["npCastbarsFont"] = "Friz Quadrata TT"
Gladdy.db["cooldownFontScale"] = 0.6
Gladdy.db["auraFont"] = "Friz Quadrata TT"
Gladdy.db["y"] = 511.0100769632991
Gladdy.db["x"] = 912.8048284050892
Gladdy.db["bottomMargin"] = 20
Gladdy.db["trinketFont"] = "Friz Quadrata TT"
Gladdy.db["npCastbarsIconSize"] = 14
Gladdy.db["trinketFontScale"] = 1.3
Gladdy.db["cooldownBorderStyle"] = "Interface\\AddOns\\Gladdy\\Images\\Border_squared_blp"
Gladdy.db["castBarTexture"] = "Minimalist"
Gladdy.db["classIconWidthFactor"] = 1
Gladdy.db["cooldownYPos"] = "RIGHT"
Gladdy.db["castBarIconSize"] = 20
Gladdy.db["drFont"] = "Friz Quadrata TT"
Gladdy.db["buffsCooldownAlpha"] = 0.8
Gladdy.db["cooldownXOffset"] = 1
Gladdy.db["buffsCooldownGrowDirection"] = "LEFT"
Gladdy.db["highlightBorderSize"] = 1
Gladdy.db["drIconSize"] = 34
Gladdy.db["powerBarBgColor"] = {
["a"] = 0.3500000238418579,
["r"] = 0.8,
["g"] = 0.8,
["b"] = 0.8,
}
Gladdy.db["castBarXOffset"] = 287
Gladdy.db["healthBarFont"] = "Friz Quadrata TT"
Gladdy.db["buffsFontScale"] = 0.8
Gladdy.db["castBarIconStyle"] = "Interface\\AddOns\\Gladdy\\Images\\Border_squared_blp"
Gladdy.db["padding"] = 0
Gladdy.db["powerBarBorderStyle"] = "Gladdy Tooltip squared"
Gladdy.db["castBarBorderSize"] = 4
Gladdy.db["classIconSize"] = 48
Gladdy.db["castBarColor"]["g"] = 0.8274509803921568
Gladdy.db["castBarColor"]["b"] = 0
Gladdy.db["castBarIconColor"]["a"] = 0.6200000047683716
Gladdy.db["leaderBorder"] = false
Gladdy.db["castBarBorderStyle"] = "Gladdy Tooltip squared"
Gladdy.db["drYOffset"] = -3
Gladdy.db["cooldownCooldownAlpha"] = 0.6000000000000001
Gladdy.db["healthBarHeight"] = 30
Gladdy.db["healthBarBgColor"] = {
["a"] = 0.3600000143051148,
["r"] = 0.7294117647058823,
["g"] = 0.7294117647058823,
["b"] = 0.7294117647058823,
}
Gladdy.db["powerBarTexture"] = "Minimalist"
Gladdy.db["healthBarBorderColor"] = {
["r"] = 0.4313725490196079,
["g"] = 0.4313725490196079,
["b"] = 0.4313725490196079,
["a"] = 1,
}
Gladdy.db["powerBarFont"] = "Friz Quadrata TT"
Gladdy.db["cooldownFont"] = "Friz Quadrata TT"
Gladdy.db["cooldownBorderColor"] = {
["r"] = 0.3019607843137255,
["g"] = 0.3019607843137255,
["b"] = 0.3019607843137255,
["a"] = 1,
}
Gladdy.db["trinketWidthFactor"] = 1
Gladdy.db["powerBarBorderSize"] = 4
Gladdy.db["trinketSize"] = 47
Gladdy.db["cooldownSize"] = 25.25495910644531
Gladdy.db["trinketBorderColor"]["a"] = 0
Gladdy.db["npCastbarsTexture"] = "Minimalist"
Gladdy:UpdateFrame()
end
function XiconProfiles:GetOptions()
return {
headerProfileClassic = {
type = "header",
name = L["Classic Profile"],
order = 2,
},
classicProfile = {
type = "execute",
func = function()
Gladdy.dbi:ResetProfile(Gladdy.dbi:GetCurrentProfile())
XiconProfiles:ApplyClassic()
end,
name = " ",
desc = "Classic Profile",
image = "Interface\\AddOns\\Gladdy\\Images\\BasicProfiles\\Classic1.blp",
imageWidth = 256,
imageHeight = 128,
width = "full",
order = 3,
},
headerProfileKnall = {
type = "header",
name = L["Knall's Profile"],
order = 4,
},
knallProfile = {
type = "execute",
func = function()
Gladdy.dbi:ResetProfile(Gladdy.dbi:GetCurrentProfile())
XiconProfiles:ApplyKnall()
end,
name = " ",
desc = "Knall's Profile",
image = "Interface\\AddOns\\Gladdy\\Images\\BasicProfiles\\Knall1.blp",
imageWidth = 256,
imageHeight = 128,
width = "full",
order = 5,
},
headerProfileKlimp = {
type = "header",
name = L["Klimp's Profile"],
order = 6,
},
klimpProfiles = {
type = "execute",
func = function()
Gladdy.dbi:ResetProfile(Gladdy.dbi:GetCurrentProfile())
XiconProfiles:ApplyKlimp()
end,
image = "Interface\\AddOns\\Gladdy\\Images\\BasicProfiles\\Klimp1.blp",
imageWidth = 256,
imageHeight = 128,
name = " ",
desc = "Klimp's Profile",
width = "full",
order = 7,
},
}
end