Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Now uses events and a proper check

git-svn-id: svn://svn.wowinterface.com/oUF_BarFader-229/trunk@5 cbe42a47-3b53-4817-a5a9-47e79666164c
  • Loading branch information...
commit 14ad18c0d38e17487a5a8b23dd729cbde061c43d 1 parent 34fbd23
p3lim-52096 authored
Showing with 24 additions and 26 deletions.
  1. +24 −26 oUF_BarFader/oUF_BarFader.lua
View
50 oUF_BarFader/oUF_BarFader.lua
@@ -1,32 +1,30 @@
local function UpdateElement(self)
- local notFull = UnitHealth('player') ~= UnitHealthMax('player') or
- (UnitPowerType("player") == 1 and UnitMana('player') > 0) or
- (UnitPowerType("player") ~= 1 and UnitMana('player') ~= UnitManaMax('player'))
+ if(self.BarFade) then
+ local notFull = UnitHealth('player') ~= UnitHealthMax('player') or
+ (UnitPowerType("player") == 1 and UnitMana('player') > 0) or
+ (UnitPowerType("player") ~= 1 and UnitMana('player') ~= UnitManaMax('player'))
- if(notFull) then
- self:SetAlpha(1)
- elseif(UnitAffectingCombat('player')) then
- self:SetAlpha(1)
- elseif(UnitExists('target')) then
- self:SetAlpha(1)
- elseif(self.Castbar) then
- self:SetAlpha(self.Castbar.casting and 1 or (self.BarFadeAlpha or 0.25))
- else
- self:SetAlpha(self.BarFadeAlpha or 0.25)
+ if(notFull) then
+ self:SetAlpha(1)
+ elseif(UnitAffectingCombat('player')) then
+ self:SetAlpha(1)
+ elseif(UnitExists('target')) then
+ self:SetAlpha(1)
+ elseif(self.Castbar) then
+ self:SetAlpha(self.Castbar.casting and 1 or (self.BarFadeAlpha or 0.25))
+ else
+ self:SetAlpha(self.BarFadeAlpha or 0.25)
+ end
end
end
oUF:RegisterInitCallback(function(self)
- local unit = self.unit
- if(self.BarFade) then
- local total = 0
- local event = CreateFrame('Frame')
- event:SetScript('OnUpdate', function(_, elapsed)
- total = total + elapsed
- if(total > 0.25) then
- UpdateElement(self)
- total = 0
- end
- end)
- end
-end)
+ local event = CreateFrame('Frame')
+ event:SetScript('OnEvent', function() UpdateElement(self) end)
+ event:RegisterEvent('PLAYER_REGEN_ENABLED')
+ event:RegisterEvent('PLAYER_REGEN_DISABLED')
+ event:RegisterEvent('PLAYER_TARGET_CHANGED')
+ event:RegisterEvent('UNIT_HEALTH')
+ event:RegisterEvent('UNIT_MANA')
+ event:RegisterEvent('PLAYER_LOGIN')
+end)
Please sign in to comment.
Something went wrong with that request. Please try again.