Quantcast

Breaking changes! Check the lua doc

p3lim-52096 [11-10-08 - 19:37]
Breaking changes! Check the lua doc
Added more support

git-svn-id: svn://svn.wowinterface.com/oUF_BarFader-229/trunk@10 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 0f9874e..492765a 100644
--- a/oUF_BarFader/oUF_BarFader.lua
+++ b/oUF_BarFader/oUF_BarFader.lua
@@ -1,58 +1,99 @@
 --[[

 	Shared:
-	 - barFade [boolean]
-	 - barFadeAlpha [value] default: 0.25
+	 - BarFade [boolean]
+	 - BarFadeMinAlpha [value] default: 0.25
+	 - BarFadeMaxAlpha [value] default: 1

 --]]
 local function UpdateElement(self, unit)
-	if(unit == 'player' and self.barFade) then
-		local l, class = UnitClass('player')
+	if(unit == 'player' and self.BarFade) then
+		local _, class = UnitClass('player')
 		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)
+			self:SetAlpha(self.BarFadeMaxAlpha or 1)
 		elseif(UnitAffectingCombat('player')) then
-			self:SetAlpha(1)
+			self:SetAlpha(self.BarFadeMaxAlpha or 1)
 		elseif(UnitExists('target')) then
-			self:SetAlpha(1)
+			self:SetAlpha(self.BarFadeMaxAlpha or 1)
 		elseif(self.Castbar) then
-			self:SetAlpha(self.Castbar.casting and 1 or (self.barFadeAlpha or 0.25))
+			self:SetAlpha(self.Castbar.casting and (self.BarFadeMaxAlpha or 1) or (self.BarFadeMinAlpha or 0.25))
 		else
-			self:SetAlpha(self.barFadeAlpha or 0.25)
+			self:SetAlpha(self.BarFadeMinAlpha or 0.25)
 		end
-	elseif(unit == 'pet' and self.barFade) then
+	end
+	if(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)
+			self:SetAlpha(self.BarFadeMaxAlpha or 1)
 		elseif(UnitAffectingCombat('pet')) then
-			self:SetAlpha(1)
+			self:SetAlpha(self.BarFadeMaxAlpha or 1)
 		elseif(UnitExists('pettarget')) then
-			self:SetAlpha(1)
+			self:SetAlpha(self.BarFadeMaxAlpha or 1)
+		elseif(self.Castbar) then
+			self:SetAlpha(self.Castbar.casting and (self.BarFadeMaxAlpha or 1) or (self.BarFadeMinAlpha or 0.25))
 		elseif(happiness) then
-			self:SetAlpha((happiness < 3) and 1 or (self.barFadeAlpha or 0.25))
+			self:SetAlpha((happiness < 3) and (self.BarFadeMaxAlpha or 1) or (self.BarFadeMinAlpha or 0.25))
 		else
-			self:SetAlpha(self.barFadeAlpha or 0.25)
+			self:SetAlpha(self.BarFadeMinAlpha or 0.25)
 		end
-	elseif(unit == 'focus' and self.BarFade) then
+	end
+	if(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)
+			self:SetAlpha(self.BarFadeMaxAlpha or 1)
 		elseif(UnitAffectingCombat('focus')) then
-			self:SetAlpha(1)
+			self:SetAlpha(self.BarFadeMaxAlpha or 1)
 		elseif(UnitExists('focustarget')) then
-			self:SetAlpha(1)
+			self:SetAlpha(self.BarFadeMaxAlpha or 1)
+		elseif(self.Castbar) then
+			self:SetAlpha(self.Castbar.casting and (self.BarFadeMaxAlpha or 1) or (self.BarFadeMinAlpha or 0.25))
 		else
-			self:SetAlpha(self.barFadeAlpha or 0.25)
-		end
+			self:SetAlpha(self.BarFadeMinAlpha or 0.25)
+		end
+	end
+	if(unit == 'focustarget' and self.BarFade) then
+		local notFull = (UnitHealth('focustarget') ~= UnitHealthMax('focustarget')) or
+			(UnitPowerType('focustarget') ~= 1 and UnitMana('focustarget') ~= UnitManaMax('focustarget')) or
+			(UnitPowerType('focustarget') == 1 and UnitMana('focustarget') > 0)
+
+		if(notFull) then
+			self:SetAlpha(self.BarFadeMaxAlpha or 1)
+		elseif(UnitAffectingCombat('focustarget')) then
+			self:SetAlpha(self.BarFadeMaxAlpha or 1)
+		elseif(UnitExists('focustargettarget')) then
+			self:SetAlpha(self.BarFadeMaxAlpha or 1)
+		elseif(self.Castbar) then
+			self:SetAlpha(self.Castbar.casting and (self.BarFadeMaxAlpha or 1) or (self.BarFadeMinAlpha or 0.25))
+		else
+			self:SetAlpha(self.BarFadeMinAlpha or 0.25)
+		end
+	end
+	if(unit == 'targettarget' and self.BarFade) then
+		local notFull = (UnitHealth('targettarget') ~= UnitHealthMax('targettarget')) or
+			(UnitPowerType('targettarget') ~= 1 and UnitMana('targettarget') ~= UnitManaMax('targettarget')) or
+			(UnitPowerType('targettarget') == 1 and UnitMana('targettarget') > 0)
+
+		if(notFull) then
+			self:SetAlpha(self.BarFadeMaxAlpha or 1)
+		elseif(UnitAffectingCombat('targettarget')) then
+			self:SetAlpha(self.BarFadeMaxAlpha or 1)
+		elseif(UnitExists('targettargettarget')) then
+			self:SetAlpha(self.BarFadeMaxAlpha or 1)
+		elseif(self.Castbar) then
+			self:SetAlpha(self.Castbar.casting and (self.BarFadeMaxAlpha or 1) or (self.BarFadeMinAlpha or 0.25))
+		else
+			self:SetAlpha(self.BarFadeMinAlpha or 0.25)
+		end
 	end
 end