From 9f1cff758eba0057bd09888dc6dd10b5ef8a3d7d Mon Sep 17 00:00:00 2001 From: p3lim-52096 Date: Sat, 30 Aug 2008 14:25:23 +0000 Subject: [PATCH] Frames now independent Fixed most issues git-svn-id: svn://svn.wowinterface.com/oUF_BarFader-229/trunk@6 cbe42a47-3b53-4817-a5a9-47e79666164c --- oUF_BarFader/oUF_BarFader.lua | 51 ++++++++++++++++++++++++++++++----- 1 file changed, 44 insertions(+), 7 deletions(-) diff --git a/oUF_BarFader/oUF_BarFader.lua b/oUF_BarFader/oUF_BarFader.lua index da7d95f..0d13e78 100644 --- a/oUF_BarFader/oUF_BarFader.lua +++ b/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) \ No newline at end of file