WoWInterface SVN fernir_UI

[/] [actionbars_style.lua] - Rev 2

Compare with Previous | Blame | View Log

local settings = oUF_Settings

  
hooksecurefunc('PetActionBar_Update', function()
    for _, name in pairs({
        'PetActionButton',
        'PossessButton',
        'ShapeshiftButton', 
    }) do
        for i = 1, 12 do
            local button = _G[name..i]
            if (button) then
                local icon = _G[name..i..'Icon']
                icon:SetTexCoord(.1, .9, .1, .9)
                icon:SetPoint("TOPRIGHT", button)
                icon:SetPoint("BOTTOMLEFT", button)
                icon:SetDrawLayer('BORDER')
                
                local cooldown = _G[name..i..'Cooldown']
                cooldown:ClearAllPoints()
                cooldown:SetAllPoints(button)
                
                local normalTexture
                if (name == 'PetActionButton') then 
                    normalTexture = _G[name..i..'NormalTexture2'] 
                else 
                    normalTexture = _G[name..i..'NormalTexture'] 
                end
                
                if (not button.Border) then
                      button.Border = button:CreateTexture(nil, "BACKGROUND")
                      button.Border:SetPoint("TOPLEFT", -2, 2)
                      button.Border:SetPoint("BOTTOMRIGHT", 2, -2)
                      button.Border:SetTexture(0, 0, 0)
                end               
                
                local border = _G[name.."Border"]
                if border then border:SetAlpha(0) end
                if normalTexture then 
                    normalTexture:SetAlpha(0) 
                end
            end
        end
    end
end)

hooksecurefunc('ActionButton_Update', function(self)
    local totemButton = self:GetName():match("MultiCastAction")
    
    if (not totemButton) then
        local button = _G[self:GetName()]
        local normalTexture = _G[self:GetName()..'NormalTexture']
        
        local icon = _G[self:GetName()..'Icon']
        icon:SetTexCoord(.1, .9, .1, .9)
        icon:SetPoint("TOPRIGHT", button)
        icon:SetPoint("BOTTOMLEFT", button)
        icon:SetDrawLayer('BORDER')
        
        local hotkey = _G[self:GetName().."HotKey"]
        hotkey:SetFont(settings.font, 13, "OUTLINE")
        local count = _G[self:GetName().."Count"]
        count:SetFont(settings.font, 13, "OUTLINE")
        local name = _G[self:GetName().."Name"]
        name:SetFont(settings.font, 8, "OUTLINE")
        
        if (not button.Border) then
            button.Border = button:CreateTexture(nil, "BACKGROUND")
            button.Border:SetPoint("TOPLEFT", -2, 2)
            button.Border:SetPoint("BOTTOMRIGHT", 2, -2)
            button.Border:SetTexture(0, 0, 0)
        end
        
        local border = _G[self:GetName().."Border"]
        if border then border:SetAlpha(0) end
        if normalTexture then 
            normalTexture:SetAlpha(0)
        end
           
        if (IsEquippedAction(self.action)) then
            _G[self:GetName()..'Border']:SetAlpha(1)
        else
            _G[self:GetName()..'Border']:SetAlpha(0)
        end 
    end
end)     

hooksecurefunc('ActionButton_ShowGrid', function(self)
    _G[self:GetName()..'NormalTexture']:SetAlpha(0)
    
    if (IsEquippedAction(self.action)) then
        _G[self:GetName()..'Border']:SetAlpha(1)
    else
        _G[self:GetName()..'Border']:SetAlpha(0)
    end
end)

hooksecurefunc('ActionButton_UpdateUsable', function(self)
        local isUsable, notEnoughMana = IsUsableAction(self.action)
        if (isUsable) then
                _G[self:GetName()..'Icon']:SetVertexColor(1, 1, 1)
        elseif (notEnoughMana) then
                _G[self:GetName()..'Icon']:SetVertexColor(.1,.3,1)
        else
                _G[self:GetName()..'Icon']:SetVertexColor(.4,.4,.4)
        end
end)


-- --------------------------------------------------------------------
-- create a new original function, 
-- its easier and do use less cpu cycles than a hooksecuredfunc (!)
-- --------------------------------------------------------------------

function ActionButton_OnUpdate(self, elapsed)
        if (ActionButton_IsFlashing(self)) then
                local flashtime = self.flashtime
                flashtime = flashtime - elapsed
                
                if (flashtime <= 0) then
                        local overtime = - flashtime
                        if (overtime >= ATTACK_BUTTON_FLASH_TIME) then
                                overtime = 0
                        end
                        flashtime = ATTACK_BUTTON_FLASH_TIME - overtime

                        local flashTexture = _G[self:GetName()..'Flash']
         flashTexture:SetTexture(settings.glowTex)
                        if (flashTexture:IsShown()) then
                                flashTexture:Hide()
                        else
                                flashTexture:Show()
                        end
                end
                
                self.flashtime = flashtime
        end

        local rangeTimer = self.rangeTimer
        if (rangeTimer) then
                rangeTimer = rangeTimer - elapsed
                if (rangeTimer <= 0) then            
          local isInRange = false
          if (ActionHasRange(self.action) and IsActionInRange(self.action) == 0) then
              _G[self:GetName()..'Icon']:SetVertexColor(.8,.1,.1)
              isInRange = true
          end
              
          if (self.isInRange ~= isInRange) then
              self.isInRange = isInRange
              ActionButton_UpdateUsable(self)
          end
          rangeTimer = TOOLTIP_UPDATE_TIME
                end
                self.rangeTimer = rangeTimer
        end
end

Compare with Previous | Blame