commit 54e44ef8dc6a0e3b306ed62051071be1f08e98c0 Author: Robin Date: Fri Jan 15 15:55:17 2021 +0100 init diff --git a/zzCR.lua b/zzCR.lua new file mode 100644 index 0000000..02463d8 --- /dev/null +++ b/zzCR.lua @@ -0,0 +1,55 @@ +local name = ... +local rebirth = 20484 +local f = CreateFrame("Button", name.."Button", UIParent, BackdropTemplateMixin and "ActionButtonTemplate BackdropTemplate" or "ActionButtonTemplate") +f:RegisterEvent("ADDON_LOADED") +f:SetMovable(true) +f:SetScript("OnMouseDown", function(self) self:StartMoving() end) +f:SetScript("OnMouseUp", function(self) self:StopMovingOrSizing() end) +f:SetScript("OnLeave", function() GameTooltip:Hide() end) +f:SetScript("OnEnter", function(self) + GameTooltip:SetOwner(self,"ANCHOR_CURSOR") + GameTooltip:ClearLines() + GameTooltip:SetSpellByID(rebirth) + GameTooltip:Show() +end) +local nm = f:GetName() +local ct = _G[format("%sCount",nm)] +local cd = _G[format("%sCooldown",nm)] +cd:SetReverse(true) +function f:Reset() + self:SetSize(36,36) + self:ClearAllPoints() + self:SetPoint("CENTER",UIParent,"CENTER") + self:SetAttribute("type","spell") + self:SetAttribute("spell",rebirth) + local spellInfo = {GetSpellInfo(rebirth)} + _G[format("%sIcon",self:GetName())]:SetTexture(spellInfo[3]) + spellInfo = nil + self:Show() +end +function f:Update() + local currentCharges, maxCharges, cooldownStart, cooldownDuration = GetSpellCharges(rebirth) + self:Hide() + if(currentCharges) then + if(cooldownStart) then + CooldownFrame_Set(cd, cooldownStart, cooldownDuration,1) + else + CooldownFrame_Set(cd,0,0,0) + end + ct:SetText(currentCharges and currentCharges or 0) + self:Show() + end +end +f:SetScript("OnEvent", function(self,event,arg1,...) + if(event=="ADDON_LOADED" and name==arg1) then + self:UnregisterEvent(event) + self:RegisterEvent("PLAYER_REGEN_ENABLED") + self:RegisterEvent("PLAYER_REGEN_DISABLED") + self:Reset() + elseif(event=="PLAYER_REGEN_ENABLED") then + self:UnregisterEvent("SPELL_UPDATE_CHARGES") + elseif(event=="PLAYER_REGEN_DISABLED") then + self:RegisterEvent("SPELL_UPDATE_CHARGES") + end + self:Update() +end) \ No newline at end of file diff --git a/zzCR.toc b/zzCR.toc new file mode 100644 index 0000000..231f783 --- /dev/null +++ b/zzCR.toc @@ -0,0 +1,5 @@ +## Interface: 90002 +## X-Repository: https://svn.grml.de/zzCR +## X-WoWI-ID: 23280 +## X-Curse-Project-ID: 86475 +zzCR.lua