Quantcast

Fixed updating issues

p3lim-52096 [02-07-09 - 20:37]
Fixed updating issues

git-svn-id: svn://svn.wowinterface.com/oUF_BarFader-229/trunk@17 cbe42a47-3b53-4817-a5a9-47e79666164c
Filename
oUF_BarFader/oUF_BarFader.lua
diff --git a/oUF_BarFader/oUF_BarFader.lua b/oUF_BarFader/oUF_BarFader.lua
index 9856392..fab267d 100644
--- a/oUF_BarFader/oUF_BarFader.lua
+++ b/oUF_BarFader/oUF_BarFader.lua
@@ -7,33 +7,31 @@

 --]]

-local function Regenerating(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 end
-		else
-			if(UnitMana(unit) ~= UnitManaMax(unit)) then return true end
-		end
+local function Validation(self, unit)
+	if(self.Castbar and (self.Castbar.casting or self.Castbar.channeling)) then
+		return false
+	elseif(UnitAffectingCombat(unit)) then
+		return false
+	elseif(unit == 'pet' and GetPetHappiness() and GetPetHappiness() < 3) then
+		return false
+	elseif(UnitExists(unit..'target')) then
+		return false
+	elseif(UnitHealth(unit) < UnitHealthMax(unit)) then
+		return false
+	elseif((UnitPowerType(unit) == 6 or UnitPowerType(unit) == 1) and UnitMana(unit) > 0) then
+		return false
+	elseif(UnitMana(unit) < UnitManaMax(unit)) then
+		return false
 	end
+
+	return true
 end

 local function Update(self)
-	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
+	if(Validation(self, self.unit)) then
 		self:SetAlpha(self.BarFadeMinAlpha or 0.25)
+	else
+		self:SetAlpha(self.BarFadeMaxAlpha or 1)
 	end
 end