Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Frames now independent
Browse files Browse the repository at this point in the history
Fixed most issues

git-svn-id: svn://svn.wowinterface.com/oUF_BarFader-229/trunk@6 cbe42a47-3b53-4817-a5a9-47e79666164c
  • Loading branch information
p3lim-52096 committed Aug 30, 2008
1 parent 14ad18c commit 9f1cff7
Showing 1 changed file with 44 additions and 7 deletions.
51 changes: 44 additions & 7 deletions 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)
Expand All @@ -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.