WoWInterface SVN fernir_UI

[/] [oUF/] [elements/] [cpoints.lua] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 Wildbreath-135052
local parent, ns = ...
2 Wildbreath-135052
local oUF = ns.oUF
3 Wildbreath-135052
 
4 Wildbreath-135052
local GetComboPoints = GetComboPoints
5 Wildbreath-135052
local MAX_COMBO_POINTS = MAX_COMBO_POINTS
6 Wildbreath-135052
 
7 Wildbreath-135052
local Update = function(self, event, unit)
8 Wildbreath-135052
        local cpoints = self.CPoints
9 Wildbreath-135052
        if(self.unit ~= unit and (cpoints.unit and cpoints.unit ~= unit)) then return end
10 Wildbreath-135052
        local cp = GetComboPoints(cpoints.unit or unit, 'target')
11 Wildbreath-135052
 
12 Wildbreath-135052
        if(#cpoints == 0) then
13 Wildbreath-135052
                cpoints:SetText((cp > 0) and cp)
14 Wildbreath-135052
        else
15 Wildbreath-135052
                for i=1, MAX_COMBO_POINTS do
16 Wildbreath-135052
                        if(i <= cp) then
17 Wildbreath-135052
                                cpoints[i]:Show()
18 Wildbreath-135052
                        else
19 Wildbreath-135052
                                cpoints[i]:Hide()
20 Wildbreath-135052
                        end
21 Wildbreath-135052
                end
22 Wildbreath-135052
        end
23 Wildbreath-135052
end
24 Wildbreath-135052
 
25 Wildbreath-135052
local Enable = function(self)
26 Wildbreath-135052
        if(self.CPoints) then
27 Wildbreath-135052
                self:RegisterEvent('UNIT_COMBO_POINTS', Update)
28 Wildbreath-135052
 
29 Wildbreath-135052
                return true
30 Wildbreath-135052
        end
31 Wildbreath-135052
end
32 Wildbreath-135052
 
33 Wildbreath-135052
local Disable = function(self)
34 Wildbreath-135052
        if(self.CPoints) then
35 Wildbreath-135052
                self:UnregisterEvent('UNIT_COMBO_POINTS', Update)
36 Wildbreath-135052
        end
37 Wildbreath-135052
end
38 Wildbreath-135052
 
39 Wildbreath-135052
oUF:AddElement('CPoints', Update, Enable, Disable)