diff Libs/DF/normal_bar.lua @ 25:6bb668a41455

- framework update.
author Tercio
date Thu, 08 Oct 2015 11:52:43 -0300
parents 7a285d98b95f
children 5da06cb420d4
line wrap: on
line diff
--- a/Libs/DF/normal_bar.lua	Mon Sep 14 17:10:38 2015 -0300
+++ b/Libs/DF/normal_bar.lua	Thu Oct 08 11:52:43 2015 -0300
@@ -197,6 +197,9 @@
 		_object.statusbar:SetStatusBarColor (_value1, _value2, _value3, _value4)
 		_object._texture.original_colors = {_value1, _value2, _value3, _value4}
 		_object.timer_texture:SetVertexColor (_value1, _value2, _value3, _value4)
+		
+		_object.timer_textureR:SetVertexColor (_value1, _value2, _value3, _value4)
+
 		return _object._texture:SetVertexColor (_value1, _value2, _value3, _value4)
 	end
 	--> icon
@@ -218,9 +221,11 @@
 			local _value1, _value2 = _unpack (_value)
 			_object._texture:SetTexture (_value1)
 			_object.timer_texture:SetTexture (_value1)
+			_object.timer_textureR:SetTexture (_value1)
 			if (_value2) then
 				_object._texture:SetTexCoord (_unpack (_value2))
 				_object.timer_texture:SetTexCoord (_unpack (_value2))
+				_object.timer_textureR:SetTexCoord (_unpack (_value2))
 			end
 		else
 			if (_value:find ("\\")) then
@@ -230,9 +235,11 @@
 				if (file) then
 					_object._texture:SetTexture (file)
 					_object.timer_texture:SetTexture (file)
+					_object.timer_textureR:SetTexture (file)
 				else
 					_object._texture:SetTexture (_value)
 					_object.timer_texture:SetTexture (_value)
+					_object.timer_textureR:SetTexture (_value)
 				end
 			end
 		end
@@ -521,6 +528,24 @@
 		self.timer = false
 	end
 
+	function BarMetaFunctions:CancelTimerBar (no_timer_end)
+		if (not self.HasTimer) then
+			return
+		end
+		if (self.TimerScheduled) then
+			DF:CancelTimer (self.TimerScheduled)
+			self.TimerScheduled = nil
+		else
+			if (self.statusbar:GetScript ("OnUpdate")) then
+				self.statusbar:SetScript ("OnUpdate", nil)
+			end
+		end
+		self.righttext = ""
+		if (not no_timer_end) then
+			self:OnTimerEnd()
+		end
+	end
+
 	local OnUpdate = function (self, elapsed)
 		--> percent of elapsed
 		local pct = abs (self.end_timer - GetTime() - self.tempo) / self.tempo
@@ -541,23 +566,24 @@
 		if (pct >= 1) then
 			self.righttext:SetText ("")
 			self:SetScript ("OnUpdate", nil)
+			self.MyObject.HasTimer = nil
 			self.MyObject:OnTimerEnd()
 		end
 	end
 	
-	function BarMetaFunctions:SetTimer (tempo)
-		
-		-- o que é inverso
-			-- barra cheia 
-			-- barra vazia
-		-- o que é left to right
-			-- barra que faz da direita pra esquerda
-			-- contrário
-		
-		self.statusbar.tempo = tempo
-		self.statusbar.remaining = tempo
+	function BarMetaFunctions:SetTimer (tempo, end_at)
+
+		if (end_at) then
+			self.statusbar.tempo = end_at - tempo
+			self.statusbar.remaining = end_at - GetTime()
+			self.statusbar.end_timer = end_at
+		else
+			self.statusbar.tempo = tempo
+			self.statusbar.remaining = tempo
+			self.statusbar.end_timer = GetTime() + tempo
+		end
+
 		self.statusbar.total_size = self.statusbar:GetWidth()
-		self.statusbar.end_timer = GetTime() + tempo
 		self.statusbar.inverse = self.BarIsInverse
 		
 		self (0)
@@ -590,10 +616,12 @@
 		
 		self.timer = true
 		
-		DF:ScheduleTimer ("StartTimeBarAnimation", 0.1, self)
+		self.HasTimer = true
+		self.TimerScheduled = DF:ScheduleTimer ("StartTimeBarAnimation", 0.1, self)
 	end
 	
 	function DF:StartTimeBarAnimation (timebar)
+		timebar.TimerScheduled = nil
 		timebar.statusbar:SetScript ("OnUpdate", OnUpdate)
 	end
 	
@@ -716,4 +744,4 @@
 		end
 		
 	return BarObject
-end
+end --endd