Permalink
Browse files

Fixed for Death Knights

Removed useless code

git-svn-id: svn://svn.wowinterface.com/oUF_BarFader-229/trunk@11 cbe42a47-3b53-4817-a5a9-47e79666164c
  • Loading branch information...
1 parent a8fd437 commit d86f0e2b920b4d8d03deea7397ced8d681e551b0 p3lim-52096 committed Nov 23, 2008
Showing with 27 additions and 77 deletions.
  1. +27 −77 oUF_BarFader/oUF_BarFader.lua
@@ -6,100 +6,49 @@
- BarFadeMaxAlpha [value] default: 1
--]]
-local function UpdateElement(self, unit)
- if(unit == 'player' and self.BarFade) then
- local _, class = UnitClass('player')
- local notFull = (UnitHealth('player') ~= UnitHealthMax('player')) or
- (UnitPowerType('player') ~= 1 and UnitMana('player') ~= UnitManaMax('player')) or
- (UnitPowerType('player') == 1 and UnitMana('player') > 0)
-
- if(notFull) then
- self:SetAlpha(self.BarFadeMaxAlpha or 1)
- elseif(UnitAffectingCombat('player')) then
- self:SetAlpha(self.BarFadeMaxAlpha or 1)
- elseif(UnitExists('target')) then
- self:SetAlpha(self.BarFadeMaxAlpha or 1)
- elseif(self.Castbar) then
- self:SetAlpha(self.Castbar.casting and (self.BarFadeMaxAlpha or 1) or (self.BarFadeMinAlpha or 0.25))
+local function NotFull(unit)
+ if(UnitHealth(unit) ~= UnitHealthMax(unit)) then
+ return true
+ else
+ if(UnitPowerType(unit) == 6 or UnitPowerType(unit) == 1) then
+ if(UnitMana(unit) > 0) then
+ return true
+ else
+ return false
+ end
else
- self:SetAlpha(self.BarFadeMinAlpha or 0.25)
+ if(UnitMana(unit) ~= UnitManaMax(unit)) then
+ return true
+ else
+ return false
+ end
end
end
- if(unit == 'pet' and self.BarFade) then
- local happiness = GetPetHappiness()
- local notFull = (UnitHealth('pet') ~= UnitHealthMax('pet')) or
- (UnitMana('pet') ~= UnitManaMax('pet'))
-
- if(notFull) then
- self:SetAlpha(self.BarFadeMaxAlpha or 1)
- elseif(UnitAffectingCombat('pet')) then
- self:SetAlpha(self.BarFadeMaxAlpha or 1)
- elseif(UnitExists('pettarget')) then
- self:SetAlpha(self.BarFadeMaxAlpha or 1)
- elseif(self.Castbar) then
- self:SetAlpha(self.Castbar.casting and (self.BarFadeMaxAlpha or 1) or (self.BarFadeMinAlpha or 0.25))
- elseif(happiness) then
- self:SetAlpha((happiness < 3) and (self.BarFadeMaxAlpha or 1) or (self.BarFadeMinAlpha or 0.25))
- else
- self:SetAlpha(self.BarFadeMinAlpha or 0.25)
- end
- end
- if(unit == 'focus' and self.BarFade) then
- local notFull = (UnitHealth('focus') ~= UnitHealthMax('focus')) or
- (UnitPowerType('focus') ~= 1 and UnitMana('focus') ~= UnitManaMax('focus')) or
- (UnitPowerType('focus') == 1 and UnitMana('focus') > 0)
-
- if(notFull) then
- self:SetAlpha(self.BarFadeMaxAlpha or 1)
- elseif(UnitAffectingCombat('focus')) then
- self:SetAlpha(self.BarFadeMaxAlpha or 1)
- elseif(UnitExists('focustarget')) then
- self:SetAlpha(self.BarFadeMaxAlpha or 1)
- elseif(self.Castbar) then
- self:SetAlpha(self.Castbar.casting and (self.BarFadeMaxAlpha or 1) or (self.BarFadeMinAlpha or 0.25))
- else
- self:SetAlpha(self.BarFadeMinAlpha or 0.25)
- end
- end
- if(unit == 'focustarget' and self.BarFade) then
- local notFull = (UnitHealth('focustarget') ~= UnitHealthMax('focustarget')) or
- (UnitPowerType('focustarget') ~= 1 and UnitMana('focustarget') ~= UnitManaMax('focustarget')) or
- (UnitPowerType('focustarget') == 1 and UnitMana('focustarget') > 0)
+end
- if(notFull) then
- self:SetAlpha(self.BarFadeMaxAlpha or 1)
- elseif(UnitAffectingCombat('focustarget')) then
- self:SetAlpha(self.BarFadeMaxAlpha or 1)
- elseif(UnitExists('focustargettarget')) then
- self:SetAlpha(self.BarFadeMaxAlpha or 1)
- elseif(self.Castbar) then
- self:SetAlpha(self.Castbar.casting and (self.BarFadeMaxAlpha or 1) or (self.BarFadeMinAlpha or 0.25))
- else
- self:SetAlpha(self.BarFadeMinAlpha or 0.25)
- end
- end
- if(unit == 'targettarget' and self.BarFade) then
- local notFull = (UnitHealth('targettarget') ~= UnitHealthMax('targettarget')) or
- (UnitPowerType('targettarget') ~= 1 and UnitMana('targettarget') ~= UnitManaMax('targettarget')) or
- (UnitPowerType('targettarget') == 1 and UnitMana('targettarget') > 0)
+local function UpdateElement(self)
+ if(self.unit == 'player' or self.unit == 'pet' or self.unit == 'focus' or self.unit == 'focustarget' or self.unit == 'targettarget') then
+ if(not self.BarFade) then return end
- if(notFull) then
+ if(NotFull(self.unit)) then
self:SetAlpha(self.BarFadeMaxAlpha or 1)
- elseif(UnitAffectingCombat('targettarget')) then
+ elseif(UnitAffectingCombat(self.unit)) then
self:SetAlpha(self.BarFadeMaxAlpha or 1)
- elseif(UnitExists('targettargettarget')) then
+ elseif(UnitExists(self.unit..'target')) then
self:SetAlpha(self.BarFadeMaxAlpha or 1)
elseif(self.Castbar) then
self:SetAlpha(self.Castbar.casting and (self.BarFadeMaxAlpha or 1) or (self.BarFadeMinAlpha or 0.25))
+ elseif(self.unit == 'pet' and GetPetHappiness()) then
+ self:SetAlpha((GetPetHappiness() < 3) and (self.BarFadeMaxAlpha or 1) or (self.BarFadeMinAlpha or 0.25))
else
self:SetAlpha(self.BarFadeMinAlpha or 0.25)
end
end
end
-oUF:RegisterInitCallback(function(self)
+oUF:RegisterInitCallback(function(obj)
local addon = CreateFrame('Frame')
- addon:SetScript('OnEvent', function() UpdateElement(self, self.unit) end)
+ addon:SetScript('OnEvent', function() UpdateElement(obj) end)
addon:RegisterEvent('PLAYER_LOGIN')
addon:RegisterEvent('PLAYER_REGEN_ENABLED')
addon:RegisterEvent('PLAYER_REGEN_DISABLED')
@@ -112,6 +61,7 @@ oUF:RegisterInitCallback(function(self)
addon:RegisterEvent('UNIT_FOCUS')
addon:RegisterEvent('UNIT_RAGE')
addon:RegisterEvent('UNIT_RUNIC_POWER')
+ addon:RegisterEvent('UNIT_POWER')
addon:RegisterEvent('UNIT_TARGET')
addon:RegisterEvent('UNIT_SPELLCAST_START')
addon:RegisterEvent('UNIT_SPELLCAST_STOP')

0 comments on commit d86f0e2

Please sign in to comment.