Quantcast

Added all units support

p3lim-52096 [01-23-09 - 22:07]
Added all units support
Removed useless events

git-svn-id: svn://svn.wowinterface.com/oUF_BarFader-229/trunk@15 cbe42a47-3b53-4817-a5a9-47e79666164c
Filename
oUF_BarFader/oUF_BarFader.lua
oUF_BarFader/oUF_BarFader.toc
diff --git a/oUF_BarFader/oUF_BarFader.lua b/oUF_BarFader/oUF_BarFader.lua
index ad90135..f8885fa 100644
--- a/oUF_BarFader/oUF_BarFader.lua
+++ b/oUF_BarFader/oUF_BarFader.lua
@@ -6,8 +6,10 @@
 	 - BarFadeMaxAlpha [value] default: 1

 --]]
+
 local function Regenerating(unit)
-	if(UnitHealth(unit) ~= UnitHealthMax(unit)) then return true
+	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 end
@@ -15,44 +17,40 @@ local function Regenerating(unit)
 			if(UnitMana(unit) ~= UnitManaMax(unit)) then return true end
 		end
 	end
-
-	return false
 end

 local function Update(self)
-	if(self.unit == 'player' or self.unit == 'pet' or self.unit == 'focus' or self.unit == 'focustarget' or self.unit == 'targettarget') then
-		if(self.Castbar and (self.Castbar.casting or self.Castbar.channeling)) then
-			self:SetAlpha(self.BarFadeMaxAlpha or 1)
-		elseif(UnitAffectingCombat(self.unit)) then
-			self:SetAlpha(self.BarFadeMaxAlpha or 1)
-		elseif(self.unit == 'pet' and GetPetHappiness()) then
-			self:SetAlpha((GetPetHappiness() < 3) and (self.BarFadeMaxAlpha or 1) or (self.BarFadeMinAlpha or 0.25))
-		elseif(UnitExists(self.unit..'target')) then
-			self:SetAlpha(self.BarFadeMaxAlpha or 1)
-		elseif(Regenerating(self.unit)) then
-			self:SetAlpha(self.BarFadeMaxAlpha or 1)
-		else
-			self:SetAlpha(self.BarFadeMinAlpha or 0.25)
-		end
+	local unit = self.unit
+
+	if(self.Castbar and (self.Castbar.casting or self.Castbar.channeling)) then
+		self:SetAlpha(self.BarFadeMaxAlpha or 1)
+	elseif(UnitAffectingCombat(unit)) then
+		self:SetAlpha(self.BarFadeMaxAlpha or 1)
+	elseif(unit == 'pet' and GetPetHappiness()) then
+		self:SetAlpha((GetPetHappiness() < 3) and (self.BarFadeMaxAlpha or 1) or (self.BarFadeMinAlpha or 0.25))
+	elseif(UnitExists(unit..'target')) then
+		self:SetAlpha(self.BarFadeMaxAlpha or 1)
+	elseif(Regenerating(unit)) then
+		self:SetAlpha(self.BarFadeMaxAlpha or 1)
+	else
+		self:SetAlpha(self.BarFadeMinAlpha or 0.25)
 	end
 end

 local function Enable(self)
 	if(self.BarFade) then
-		self:RegisterEvent('PLAYER_LOGIN', Update)
-		self:RegisterEvent('PLAYER_REGEN_ENABLED', Update)
-		self:RegisterEvent('PLAYER_REGEN_DISABLED', Update)
-		self:RegisterEvent('PLAYER_TARGET_CHANGED', Update)
-		self:RegisterEvent('PLAYER_FOCUS_CHANGED', Update)
+		Update(self)
+
+		self:RegisterEvent('UNIT_COMBAT', Update)
 		self:RegisterEvent('UNIT_HAPPINESS', Update)
+		self:RegisterEvent('UNIT_TARGET', Update)
+		self:RegisterEvent('UNIT_FOCUS', Update)
 		self:RegisterEvent('UNIT_HEALTH', Update)
-		self:RegisterEvent('UNIT_MANA', Update)
+		self:RegisterEvent('UNIT_POWER', Update)
 		self:RegisterEvent('UNIT_ENERGY', Update)
-		self:RegisterEvent('UNIT_FOCUS', Update)
 		self:RegisterEvent('UNIT_RAGE', Update)
+		self:RegisterEvent('UNIT_MANA', Update)
 		self:RegisterEvent('UNIT_RUNIC_POWER', Update)
-		self:RegisterEvent('UNIT_POWER', Update)
-		self:RegisterEvent('UNIT_TARGET', Update)

 		if(self.Castbar) then
 			self.PostCastStart = Update
@@ -71,20 +69,16 @@ end

 local function Disable(self)
 	if(self.BarFade) then
-		self:UnregisterEvent('PLAYER_LOGIN', Update)
-		self:UnregisterEvent('PLAYER_REGEN_ENABLED', Update)
-		self:UnregisterEvent('PLAYER_REGEN_DISABLED', Update)
-		self:UnregisterEvent('PLAYER_TARGET_CHANGED', Update)
-		self:UnregisterEvent('PLAYER_FOCUS_CHANGED', Update)
+		self:UnregisterEvent('UNIT_COMBAT', Update)
 		self:UnregisterEvent('UNIT_HAPPINESS', Update)
+		self:UnregisterEvent('UNIT_TARGET', Update)
+		self:UnregisterEvent('UNIT_FOCUS', Update)
 		self:UnregisterEvent('UNIT_HEALTH', Update)
-		self:UnregisterEvent('UNIT_MANA', Update)
+		self:UnregisterEvent('UNIT_POWER', Update)
 		self:UnregisterEvent('UNIT_ENERGY', Update)
-		self:UnregisterEvent('UNIT_FOCUS', Update)
 		self:UnregisterEvent('UNIT_RAGE', Update)
+		self:UnregisterEvent('UNIT_MANA', Update)
 		self:UnregisterEvent('UNIT_RUNIC_POWER', Update)
-		self:UnregisterEvent('UNIT_POWER', Update)
-		self:UnregisterEvent('UNIT_TARGET', Update)

 		if(self.Castbar) then
 			self.PostCastStart = nil
diff --git a/oUF_BarFader/oUF_BarFader.toc b/oUF_BarFader/oUF_BarFader.toc
index ecaab23..6250b59 100644
--- a/oUF_BarFader/oUF_BarFader.toc
+++ b/oUF_BarFader/oUF_BarFader.toc
@@ -2,7 +2,7 @@
 ## Author: p3lim
 ## Version: 30000.wowi:revision
 ## Title: oUF BarFader
-## Notes: Condition fading support for oUF layouts
+## Notes: Condition fading plug-in for oUF
 ## RequiredDeps: oUF

 oUF_BarFader.lua
\ No newline at end of file