Quantcast

better values support

Sidoine De Wispelaere [12-17-11 - 15:30]
better values support

git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@449 d5049fe3-3747-40f7-a4b5-f36d6801af5f
Filename
Locale-enUS.lua
Ovale.lua
OvaleCompile.lua
OvaleFrame.lua
diff --git a/Locale-enUS.lua b/Locale-enUS.lua
index 0d738f8..8969137 100644
--- a/Locale-enUS.lua
+++ b/Locale-enUS.lua
@@ -4,7 +4,7 @@ defaultLanguage = false
 --@end-debug@

 local AceLocale = LibStub:GetLibrary("AceLocale-3.0")
-local L = AceLocale:NewLocale("Ovale", "enUS", defaultLanguage)
+local L = AceLocale:NewLocale("Ovale", "enUS", defaultLanguage, defaultLanguage)
 if not L then return end

 --@localization(locale="enUS", format="lua_additive_table", same-key-is-true=true, handle-subnamespaces="concat")@
\ No newline at end of file
diff --git a/Ovale.lua b/Ovale.lua
index 24270d6..adedf55 100644
--- a/Ovale.lua
+++ b/Ovale.lua
@@ -2046,10 +2046,17 @@ function Ovale:CalculerMeilleureAction(element)
 				self:Print("Function "..parameterList..") returned "..nilstring(start)..","..nilstring(ending)..","..nilstring(rate))
 			end

-			return start, ending, rate
+			if rate then
+				return 0, nil, 3, {value=start, origin=ending, rate=rate, type="value"}
+			else
+				return start, ending
+			end
 		end
 	elseif element.type == "time" then
-		return element.value, 0, 0
+		return element.value
+	elseif element.type == "value" then
+		Ovale:Log("value " .. element.value)
+		return 0, nil, 3, element
 	elseif element.type == "after" then
 		local timeA = Ovale:CalculerMeilleureAction(element.time)
 		local startA, endA = Ovale:CalculerMeilleureAction(element.a)
@@ -2115,7 +2122,7 @@ function Ovale:CalculerMeilleureAction(element)
 			return 0
 		end
 		return nil
-	elseif (element.type == "and" or element.type == "if") then
+	elseif element.type == "and" or element.type == "if" then
 		if (Ovale.trace) then
 			self:Print(element.type.." ["..element.nodeId.."]")
 		end
@@ -2143,8 +2150,8 @@ function Ovale:CalculerMeilleureAction(element)
 			Ovale:Print(element.type.." return "..nilstring(startB)..","..nilstring(endB).." ["..element.nodeId.."]")
 		end
 		return startB, endB, prioriteB, elementB
-	elseif (element.type == "unless") then
-		if (Ovale.trace) then
+	elseif element.type == "unless" then
+		if Ovale.trace then
 			self:Print(element.type)
 		end
 		local startA, endA = Ovale:CalculerMeilleureAction(element.a)
@@ -2197,9 +2204,15 @@ function Ovale:CalculerMeilleureAction(element)
 		end
 		return startB, endB
 	elseif element.type == "operator" then
-		local a,b,c = self:CalculerMeilleureAction(element.a)
-		local x,y,z = self:CalculerMeilleureAction(element.b)
-
+		local startA, endA, elementA = self:CalculerMeilleureAction(element.a)
+		local startB, endB, elementB = self:CalculerMeilleureAction(element.b)
+		local a = elementA.value
+		local b = elementA.origin
+		local c = elementA.rate
+		local x = elementB.value
+		local y = elementB.origin
+		local z = elementB.rate
+
 		if not a or not x then
 			self:Log("operator: a or x is nil")
 			return nil
@@ -2207,30 +2220,34 @@ function Ovale:CalculerMeilleureAction(element)

 		self:Log(a.."+(t-"..b..")*"..c.. element.operator..x.."+(t-"..y..")*"..z)

+		local l, m, n
+
 		if element.operator == "*" then
 			if c == 0 then
-				return a*x, y, a*z
+				l = a*x
+				m = y
+				n = a*z
 			elseif z == 0 then
-				return x*a, b, x*c
+				l = x*a; m = b; n = x*c
 			else
 				self:Print("ERROR: at least one value must be constant when multiplying")
 				self.bug = true
 			end
 		elseif element.operator == "+" then
 			if c+z == 0 then
-				return a+x, 0, 0
+				l = a+x; m = 0; n = 0
 			else
-				return a+x, (b*c+y*z)/(c+z), c+z
+				l = a+x; m = (b*c+y*z)/(c+z); n = c+z
 			end
 		elseif element.operator == '-' then
 			if c-z == 0 then
-				return a-x, 0, 0
+				l = a-x; m = 0; n = 0
 			else
-				return a-x, (b*c-y*z)/(c-z), c-z
+				l = a-x; m = (b*c-y*z)/(c-z); n = c-z
 			end
 		elseif element.operator == '/' then
 			if z == 0 then
-				return a/x, b, c/x
+				l = a/x; m = b; n = c/x
 			else
 				self:Print("ERROR: second operator of / must be constant")
 				self.bug = true
@@ -2273,10 +2290,11 @@ function Ovale:CalculerMeilleureAction(element)
 				end
 			end
 		end
+		return startA, endA, 3, { value = l, origin = m, rate = n, type = "time" }
 	elseif element.type == "lua" then
 		local ret = loadstring(element.lua)()
 		self:Log("lua "..nilstring(ret))
-		return ret, 0, 0
+		return 0, nil, 3, { type="value", value=ret, origin=0, rate=0}
 	elseif (element.type == "group") then
 		local meilleurTempsFils
 		local bestEnd
diff --git a/OvaleCompile.lua b/OvaleCompile.lua
index ab5d258..ca3848f 100644
--- a/OvaleCompile.lua
+++ b/OvaleCompile.lua
@@ -41,7 +41,7 @@ local function ParseTime(value)
 end

 local function ParseNumber(dummy, value)
-	return dummy..AddNode({type="time", value=tonumber(value)})
+	return dummy..AddNode({type="value", value=tonumber(value), origin=0, rate=0})
 end

 local function ParseFunction(prefix, func, params)
@@ -529,6 +529,8 @@ function Ovale:DebugNode(node)
 		text = self:DebugNode(node.a)..node.operator..self:DebugNode(node.b)
 	elseif node.type == "lua" then
 		text = "["..node.lua.."]"
+	elseif node.type == "value" then
+		text = node.value
 	else
 		text = "#unknown node type#"
 	end
diff --git a/OvaleFrame.lua b/OvaleFrame.lua
index e229b41..9207efa 100644
--- a/OvaleFrame.lua
+++ b/OvaleFrame.lua
@@ -169,14 +169,14 @@ do
 				Ovale:Log("CalculerMeilleureAction start = "..start)
 			end
 			local action = self.actions[k]
-			if node.params.type == "value" then
+			if element and element.type == "value" then
 				local actionTexture
 				if node.params.texture then
 					actionTexture = GetSpellTexture(node.params.texture)
 				end
 				local value
-				if ending and priorite and start then
-					value = start + (Ovale.maintenant - ending) * priorite
+				if element.value and element.origin and element.rate then
+					value = element.value + (Ovale.maintenant - element.origin) * element.rate
 				end
 				action.icons[1]:SetValue(value, actionTexture)
 				if #action.icons > 1 then