Mercurial > wow > kbf
comparison KBF.lua @ 6:bc661466f10c
use deferred processing of unit_aura in order to avoid race conditions with the attributes of the secure frames
| author | Chris Mellon <arkanes@gmai.com> |
|---|---|
| date | Tue, 12 Oct 2010 18:14:06 -0500 |
| parents | 43340216545c |
| children | 31048236391d |
comparison
equal
deleted
inserted
replaced
| 5:43340216545c | 6:bc661466f10c |
|---|---|
| 24 -- "bar" is the set of icon + status bars that we create to show the buff time | 24 -- "bar" is the set of icon + status bars that we create to show the buff time |
| 25 | 25 |
| 26 function kbf:OnUpdate() | 26 function kbf:OnUpdate() |
| 27 for idx=1,99 do | 27 for idx=1,99 do |
| 28 local frame = self.secureFrame:GetAttribute("child"..idx) | 28 local frame = self.secureFrame:GetAttribute("child"..idx) |
| 29 if not (frame and frame.expirationTime) then break end | 29 if not frame then break end |
| 30 local remaining = frame.expirationTime - GetTime() | 30 if self.dirty then |
| 31 remaining = math.max(0, remaining) | 31 local unit = self.secureFrame:GetAttribute("unit") |
| 32 local perc = remaining / frame.duration | 32 self:BindBarToBuff(frame, unit) |
| 33 frame.timertext:SetText(self:FormatTimeText(remaining)) | 33 elseif frame.expirationTime then |
| 34 frame.statusbar:SetValue(remaining) | 34 local remaining = frame.expirationTime - GetTime() |
| 35 end | 35 remaining = math.max(0, remaining) |
| 36 local perc = remaining / frame.duration | |
| 37 frame.timertext:SetText(self:FormatTimeText(remaining)) | |
| 38 frame.statusbar:SetValue(remaining) | |
| 39 end | |
| 40 end | |
| 41 self.dirty = nil | |
| 36 end | 42 end |
| 37 | 43 |
| 38 function kbf:UNIT_AURA(event, unit) | 44 function kbf:UNIT_AURA(event, unit) |
| 39 if unit ~= self.secureFrame:GetAttribute("unit") then return end | 45 if unit ~= self.secureFrame:GetAttribute("unit") then return end |
| 40 for idx=1,99 do | 46 self.dirty = true |
| 41 local frame = self.secureFrame:GetAttribute("child"..idx) | |
| 42 if not frame then break end | |
| 43 self:BindBarToBuff(frame, unit) | |
| 44 end | |
| 45 end | 47 end |
| 46 | 48 |
| 47 function kbf:BindBarToBuff(parentFrame, unit) | 49 function kbf:BindBarToBuff(parentFrame, unit) |
| 48 local index = parentFrame:GetAttribute("index") | 50 local index = parentFrame:GetAttribute("index") |
| 49 local filter = parentFrame:GetAttribute("filter") | 51 local filter = parentFrame:GetAttribute("filter") |
| 58 else | 60 else |
| 59 parentFrame.text:SetText(name) | 61 parentFrame.text:SetText(name) |
| 60 end | 62 end |
| 61 parentFrame.timertext:SetText(self:FormatTimeText(duration)) | 63 parentFrame.timertext:SetText(self:FormatTimeText(duration)) |
| 62 -- store duration information | 64 -- store duration information |
| 63 if duration > 0 then | 65 if duration and duration > 0 then |
| 64 parentFrame.expirationTime = expirationTime | 66 parentFrame.expirationTime = expirationTime |
| 65 parentFrame.duration = duration | 67 parentFrame.duration = duration |
| 66 parentFrame.statusbar:SetMinMaxValues(0, duration) | 68 parentFrame.statusbar:SetMinMaxValues(0, duration) |
| 67 parentFrame.statusbar:SetValue(duration) | 69 parentFrame.statusbar:SetValue(duration) |
| 68 else | 70 else |
