WoWInterface SVN fernir_UI

[/] [actionbars_style.lua] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 Wildbreath-135052
local settings = oUF_Settings
2 Wildbreath-135052
 
3 Wildbreath-135052
 
4 Wildbreath-135052
hooksecurefunc('PetActionBar_Update', function()
5 Wildbreath-135052
    for _, name in pairs({
6 Wildbreath-135052
        'PetActionButton',
7 Wildbreath-135052
        'PossessButton',
8 Wildbreath-135052
        'ShapeshiftButton',
9 Wildbreath-135052
    }) do
10 Wildbreath-135052
        for i = 1, 12 do
11 Wildbreath-135052
            local button = _G[name..i]
12 Wildbreath-135052
            if (button) then
13 Wildbreath-135052
                local icon = _G[name..i..'Icon']
14 Wildbreath-135052
                icon:SetTexCoord(.1, .9, .1, .9)
15 Wildbreath-135052
                icon:SetPoint("TOPRIGHT", button)
16 Wildbreath-135052
                icon:SetPoint("BOTTOMLEFT", button)
17 Wildbreath-135052
                icon:SetDrawLayer('BORDER')
18 Wildbreath-135052
 
19 Wildbreath-135052
                local cooldown = _G[name..i..'Cooldown']
20 Wildbreath-135052
                cooldown:ClearAllPoints()
21 Wildbreath-135052
                cooldown:SetAllPoints(button)
22 Wildbreath-135052
 
23 Wildbreath-135052
                local normalTexture
24 Wildbreath-135052
                if (name == 'PetActionButton') then
25 Wildbreath-135052
                    normalTexture = _G[name..i..'NormalTexture2']
26 Wildbreath-135052
                else
27 Wildbreath-135052
                    normalTexture = _G[name..i..'NormalTexture']
28 Wildbreath-135052
                end
29 Wildbreath-135052
 
30 Wildbreath-135052
                if (not button.Border) then
31 Wildbreath-135052
                      button.Border = button:CreateTexture(nil, "BACKGROUND")
32 Wildbreath-135052
                      button.Border:SetPoint("TOPLEFT", -2, 2)
33 Wildbreath-135052
                      button.Border:SetPoint("BOTTOMRIGHT", 2, -2)
34 Wildbreath-135052
                      button.Border:SetTexture(0, 0, 0)
35 Wildbreath-135052
                end
36 Wildbreath-135052
 
37 Wildbreath-135052
                local border = _G[name.."Border"]
38 Wildbreath-135052
                if border then border:SetAlpha(0) end
39 Wildbreath-135052
                if normalTexture then
40 Wildbreath-135052
                    normalTexture:SetAlpha(0)
41 Wildbreath-135052
                end
42 Wildbreath-135052
            end
43 Wildbreath-135052
        end
44 Wildbreath-135052
    end
45 Wildbreath-135052
end)
46 Wildbreath-135052
 
47 Wildbreath-135052
hooksecurefunc('ActionButton_Update', function(self)
48 Wildbreath-135052
    local totemButton = self:GetName():match("MultiCastAction")
49 Wildbreath-135052
 
50 Wildbreath-135052
    if (not totemButton) then
51 Wildbreath-135052
        local button = _G[self:GetName()]
52 Wildbreath-135052
        local normalTexture = _G[self:GetName()..'NormalTexture']
53 Wildbreath-135052
 
54 Wildbreath-135052
        local icon = _G[self:GetName()..'Icon']
55 Wildbreath-135052
        icon:SetTexCoord(.1, .9, .1, .9)
56 Wildbreath-135052
        icon:SetPoint("TOPRIGHT", button)
57 Wildbreath-135052
        icon:SetPoint("BOTTOMLEFT", button)
58 Wildbreath-135052
        icon:SetDrawLayer('BORDER')
59 Wildbreath-135052
 
60 Wildbreath-135052
        local hotkey = _G[self:GetName().."HotKey"]
61 Wildbreath-135052
        hotkey:SetFont(settings.font, 13, "OUTLINE")
62 Wildbreath-135052
        local count = _G[self:GetName().."Count"]
63 Wildbreath-135052
        count:SetFont(settings.font, 13, "OUTLINE")
64 Wildbreath-135052
        local name = _G[self:GetName().."Name"]
65 Wildbreath-135052
        name:SetFont(settings.font, 8, "OUTLINE")
66 Wildbreath-135052
 
67 Wildbreath-135052
        if (not button.Border) then
68 Wildbreath-135052
            button.Border = button:CreateTexture(nil, "BACKGROUND")
69 Wildbreath-135052
            button.Border:SetPoint("TOPLEFT", -2, 2)
70 Wildbreath-135052
            button.Border:SetPoint("BOTTOMRIGHT", 2, -2)
71 Wildbreath-135052
            button.Border:SetTexture(0, 0, 0)
72 Wildbreath-135052
        end
73 Wildbreath-135052
 
74 Wildbreath-135052
        local border = _G[self:GetName().."Border"]
75 Wildbreath-135052
        if border then border:SetAlpha(0) end
76 Wildbreath-135052
        if normalTexture then
77 Wildbreath-135052
            normalTexture:SetAlpha(0)
78 Wildbreath-135052
        end
79 Wildbreath-135052
 
80 Wildbreath-135052
        if (IsEquippedAction(self.action)) then
81 Wildbreath-135052
            _G[self:GetName()..'Border']:SetAlpha(1)
82 Wildbreath-135052
        else
83 Wildbreath-135052
            _G[self:GetName()..'Border']:SetAlpha(0)
84 Wildbreath-135052
        end
85 Wildbreath-135052
    end
86 Wildbreath-135052
end)
87 Wildbreath-135052
 
88 Wildbreath-135052
hooksecurefunc('ActionButton_ShowGrid', function(self)
89 Wildbreath-135052
    _G[self:GetName()..'NormalTexture']:SetAlpha(0)
90 Wildbreath-135052
 
91 Wildbreath-135052
    if (IsEquippedAction(self.action)) then
92 Wildbreath-135052
        _G[self:GetName()..'Border']:SetAlpha(1)
93 Wildbreath-135052
    else
94 Wildbreath-135052
        _G[self:GetName()..'Border']:SetAlpha(0)
95 Wildbreath-135052
    end
96 Wildbreath-135052
end)
97 Wildbreath-135052
 
98 Wildbreath-135052
hooksecurefunc('ActionButton_UpdateUsable', function(self)
99 Wildbreath-135052
        local isUsable, notEnoughMana = IsUsableAction(self.action)
100 Wildbreath-135052
        if (isUsable) then
101 Wildbreath-135052
                _G[self:GetName()..'Icon']:SetVertexColor(1, 1, 1)
102 Wildbreath-135052
        elseif (notEnoughMana) then
103 Wildbreath-135052
                _G[self:GetName()..'Icon']:SetVertexColor(.1,.3,1)
104 Wildbreath-135052
        else
105 Wildbreath-135052
                _G[self:GetName()..'Icon']:SetVertexColor(.4,.4,.4)
106 Wildbreath-135052
        end
107 Wildbreath-135052
end)
108 Wildbreath-135052
 
109 Wildbreath-135052
 
110 Wildbreath-135052
-- --------------------------------------------------------------------
111 Wildbreath-135052
-- create a new original function,
112 Wildbreath-135052
-- its easier and do use less cpu cycles than a hooksecuredfunc (!)
113 Wildbreath-135052
-- --------------------------------------------------------------------
114 Wildbreath-135052
 
115 Wildbreath-135052
function ActionButton_OnUpdate(self, elapsed)
116 Wildbreath-135052
        if (ActionButton_IsFlashing(self)) then
117 Wildbreath-135052
                local flashtime = self.flashtime
118 Wildbreath-135052
                flashtime = flashtime - elapsed
119 Wildbreath-135052
 
120 Wildbreath-135052
                if (flashtime <= 0) then
121 Wildbreath-135052
                        local overtime = - flashtime
122 Wildbreath-135052
                        if (overtime >= ATTACK_BUTTON_FLASH_TIME) then
123 Wildbreath-135052
                                overtime = 0
124 Wildbreath-135052
                        end
125 Wildbreath-135052
                        flashtime = ATTACK_BUTTON_FLASH_TIME - overtime
126 Wildbreath-135052
 
127 Wildbreath-135052
                        local flashTexture = _G[self:GetName()..'Flash']
128 Wildbreath-135052
         flashTexture:SetTexture(settings.glowTex)
129 Wildbreath-135052
                        if (flashTexture:IsShown()) then
130 Wildbreath-135052
                                flashTexture:Hide()
131 Wildbreath-135052
                        else
132 Wildbreath-135052
                                flashTexture:Show()
133 Wildbreath-135052
                        end
134 Wildbreath-135052
                end
135 Wildbreath-135052
 
136 Wildbreath-135052
                self.flashtime = flashtime
137 Wildbreath-135052
        end
138 Wildbreath-135052
 
139 Wildbreath-135052
        local rangeTimer = self.rangeTimer
140 Wildbreath-135052
        if (rangeTimer) then
141 Wildbreath-135052
                rangeTimer = rangeTimer - elapsed
142 Wildbreath-135052
                if (rangeTimer <= 0) then
143 Wildbreath-135052
          local isInRange = false
144 Wildbreath-135052
          if (ActionHasRange(self.action) and IsActionInRange(self.action) == 0) then
145 Wildbreath-135052
              _G[self:GetName()..'Icon']:SetVertexColor(.8,.1,.1)
146 Wildbreath-135052
              isInRange = true
147 Wildbreath-135052
          end
148 Wildbreath-135052
 
149 Wildbreath-135052
          if (self.isInRange ~= isInRange) then
150 Wildbreath-135052
              self.isInRange = isInRange
151 Wildbreath-135052
              ActionButton_UpdateUsable(self)
152 Wildbreath-135052
          end
153 Wildbreath-135052
          rangeTimer = TOOLTIP_UPDATE_TIME
154 Wildbreath-135052
                end
155 Wildbreath-135052
                self.rangeTimer = rangeTimer
156 Wildbreath-135052
        end
157 Wildbreath-135052
end