Quantcast

refresh timer when UNIT_AURA fires

yaroot [12-31-10 - 02:44]
refresh timer when UNIT_AURA fires
Filename
core.lua
diff --git a/core.lua b/core.lua
index ad3d45a..0f1f590 100644
--- a/core.lua
+++ b/core.lua
@@ -23,7 +23,7 @@
     OTHER DEALINGS IN THE SOFTWARE.
 ]===]

-local Cenote = LibStub('AceAddon-3.0'):NewAddon('Cenote')
+local Cenote = LibStub('AceAddon-3.0'):NewAddon('Cenote', 'AceEvent-3.0')
 local debug

 local complexLocationTable = {
@@ -48,6 +48,7 @@ function Cenote:OnInitialize()
         Cenote:OnSAOFEvent(...)
     end)

+    self:RegisterEvent('UNIT_AURA', 'UNIT_AURA')
 end

 function Cenote:OnSAOFEvent(_, event, ...)
@@ -57,6 +58,31 @@ function Cenote:OnSAOFEvent(_, event, ...)
     end
 end

+function Cenote:UNIT_AURA(event, unit)
+    --if(unit == PlayerFrame.unit) then
+    if(unit == 'player') then
+        return self:RescanVisibleOverlay()
+    end
+end
+
+function Cenote:RescanVisibleOverlay()
+    for index, f in ipairs(self.timers) do
+        if(f.using) then
+            self:UpdateTimer(f)
+        end
+    end
+end
+
+function Cenote:UpdateTimer(f)
+    local endTime = self:GetTimeLeft(f.spellID)
+    if(endTime) then
+        f.endTime = endTime
+        self:Update(f)
+    else
+        self:Remove(f)
+    end
+end
+
 function Cenote:SPELL_ACTIVATION_OVERLAY_SHOW(spellID, texture, position, scale, r, g, b)
     local f = self:Get(spellID)
     local endTime = self:GetTimeLeft(spellID)