Permalink
Browse files

Frames now independent

Fixed most issues

git-svn-id: svn://svn.wowinterface.com/oUF_BarFader-229/trunk@6 cbe42a47-3b53-4817-a5a9-47e79666164c
  • Loading branch information...
1 parent 14ad18c commit 9f1cff758eba0057bd09888dc6dd10b5ef8a3d7d p3lim-52096 committed Aug 30, 2008
Showing with 44 additions and 7 deletions.
  1. +44 −7 oUF_BarFader/oUF_BarFader.lua
View
51 oUF_BarFader/oUF_BarFader.lua
@@ -1,8 +1,8 @@
-local function UpdateElement(self)
- 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'))
+local function UpdateElement(self, unit)
+ if(unit == 'player' and self.BarFade) then
+ 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(1)
@@ -15,16 +15,53 @@ local function UpdateElement(self)
else
self:SetAlpha(self.BarFadeAlpha or 0.25)
end
+ elseif(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(1)
+ elseif(UnitAffectingCombat('pet')) then
+ self:SetAlpha(1)
+ elseif(UnitExists('pettarget')) then
+ self:SetAlpha(1)
+ elseif(happiness) then
+ self:SetAlpha((happiness < 3) and 1 or (self.BarFadeAlpha or 0.25))
+ else
+ self:SetAlpha(self.BarFadeAlpha or 0.25)
+ end
+ elseif(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(1)
+ elseif(UnitAffectingCombat('focus')) then
+ self:SetAlpha(1)
+ elseif(UnitExists('focustarget')) then
+ self:SetAlpha(1)
+ else
+ self:SetAlpha(self.BarFadeAlpha or 0.25)
+ end
end
end
oUF:RegisterInitCallback(function(self)
local event = CreateFrame('Frame')
- event:SetScript('OnEvent', function() UpdateElement(self) end)
+ event:SetScript('OnEvent', function() UpdateElement(self, self.unit) end)
+ event:RegisterEvent('PLAYER_LOGIN')
event:RegisterEvent('PLAYER_REGEN_ENABLED')
event:RegisterEvent('PLAYER_REGEN_DISABLED')
event:RegisterEvent('PLAYER_TARGET_CHANGED')
+ event:RegisterEvent('PLAYER_FOCUS_CHANGED')
+ event:RegisterEvent('UNIT_HAPPINESS')
event:RegisterEvent('UNIT_HEALTH')
event:RegisterEvent('UNIT_MANA')
- event:RegisterEvent('PLAYER_LOGIN')
+ event:RegisterEvent('UNIT_TARGET')
+ event:RegisterEvent('UNIT_SPELLCAST_START')
+ event:RegisterEvent('UNIT_SPELLCAST_STOP')
+ event:RegisterEvent('UNIT_SPELLCAST_CHANNEL_START')
+ event:RegisterEvent('UNIT_SPELLCAST_CHANNEL_STOP')
end)

0 comments on commit 9f1cff7

Please sign in to comment.