local addonName, addon = ... local fname = format("%s", addonName) addon['f'] = CreateFrame("Button", fname, UIParent, "ActionButtonTemplate") addon['guid'] = UnitGUID('player') local guid, f = addon['guid'], addon['f'] local spellInfo = {GetSpellInfo(336267)} local wdlSpellInfo = {GetSpellInfo(109186)} f['wdl1'] = CreateFrame("Button", format("%s1", fname), f, "ActionButtonTemplate") f['wdl2'] = CreateFrame("Button", format("%s2", fname), f, "ActionButtonTemplate") local auraName = spellInfo[1] local auraName2 = wdlSpellInfo[1] local buttons = {f, f['wdl1'], f['wdl2']} for i = 1, #buttons do local btn = buttons[i] btn:SetSize(36, 36) btn:SetScale(i == 1 and 2 or 0.5) btn:Hide() end _G[format("%sIcon",fname)]:SetTexture(spellInfo[3]) _G[format("%sIcon",format("%s1", fname))]:SetTexture(wdlSpellInfo[3]) _G[format("%sIcon",format("%s2", fname))]:SetTexture(wdlSpellInfo[3]) f:SetPoint("CENTER") f:SetMovable(true) f:EnableMouse(true) f:RegisterForDrag("LeftButton") f:SetScript("OnDragStart", f.StartMoving) f:SetScript("OnDragStop", f.StopMovingOrSizing) local ct = _G[format("%sCount", fname)] local cd = _G[format("%sCooldown", fname)] local cd1 = _G[format("%sCooldown", format("%s1", fname))] local cd2 = _G[format("%sCooldown", format("%s2", fname))] f['elapsed'] = 0 f['wdl1']:SetPoint("BOTTOMRIGHT", f, "BOTTOMLEFT",-4,0) f['wdl2']:SetPoint("BOTTOMLEFT", f, "BOTTOMRIGHT",4,0) f:SetScript("OnUpdate", function(self, elapsed) self['elapsed'] = self['elapsed'] + elapsed if(self['elapsed']>0.1) then local name, icon, count, debuffType, duration, expirationTime = AuraUtil.FindAuraByName(auraName, 'player') if(name) then local run = expirationTime - GetTime() cd:SetCooldown(GetTime() - run, duration) ct:SetText(count and count or 0) end local name, icon, count, debuffType, duration, expirationTime = AuraUtil.FindAuraByName(auraName2, 'player') if(name) then local run = expirationTime - GetTime() if(count) then if(count > 1) then cd2:SetCooldown(GetTime() - run, duration) end cd1:SetCooldown(GetTime() - run, duration) end end end end) function f:dmg(event, data) if(data[9] == guid) then if(data[13] == 336267) then local name, icon, count, debuffType, duration, expirationTime, unitCaster, canStealOrPurge, nameplateShowPersonal, spellId, canApplyAura, isBossDebuff, isCastByPlayer, nameplateShowAll, timeMod = AuraUtil.FindAuraByName(auraName, 'player') if(name and count > 0) then f:Show() else f:Hide() end elseif(data[13] == 114255) then local name, icon, count, debuffType, duration, expirationTime, unitCaster, canStealOrPurge, nameplateShowPersonal, spellId, canApplyAura, isBossDebuff, isCastByPlayer, nameplateShowAll, timeMod = AuraUtil.FindAuraByName(auraName2, 'player') if(name and count and count > 0) then local run = expirationTime - GetTime() if(count > 1) then f['wdl2']:Show() else f['wdl2']:Hide() end f['wdl1']:Show() else f['wdl1']:Hide() f['wdl2']:Hide() end end end end function f:Reset() self:SetSize(36,36) self:ClearAllPoints() self:SetPoint("CENTER",UIParent,"CENTER") spellInfo = {GetSpellInfo(336267)} _G[format("%sIcon",fname)]:SetTexture(spellInfo[3]) self:Show() end function f:Scale(scale) if(not scale or scale <= 0 or scale > 5) then scale = 2 end _G[format("%s%s", addonName, 'DB')] = scale self:Reset() self:SetScale(scale) end LibStub("LibCombatLog"):Embed(f) f:RegisterCLEvent({'AURA_APPLIED','AURA_REMOVED','AURA_APPLIED_DOSE','AURA_REMOVED_DOSE','AURA_REFRESH','AURA_BROKEN','AURA_BROKEN_SPELL'}, 'dmg') f:RegisterEvent("ADDON_LOADED") f:SetScript("OnEvent", function(self,event,arg1) if(event == "ADDON_LOADED" and arg1 == addonName) then self:UnregisterEvent(event) self:Scale(_G[format("%s%s", addonName, 'DB')]) self:Hide() end end)