Quantcast

Introduce LibMarquee

Scott Sibley [08-09-10 - 06:21]
Introduce LibMarquee
Filename
LibMarquee.lua
LibProperty.lua
Modules/Text.lua
diff --git a/LibMarquee.lua b/LibMarquee.lua
new file mode 100644
index 0000000..e69de29
diff --git a/LibProperty.lua b/LibProperty.lua
index 8f06070..d786a0f 100644
--- a/LibProperty.lua
+++ b/LibProperty.lua
@@ -3,7 +3,7 @@ local MAJOR = "LibProperty-1.0"
 local MINOR = 1
 assert(LibStub, MAJOR.." requires LibStub")
 local LibProperty = LibStub:NewLibrary(MAJOR, MINOR)
-local Evaluator = LibStub("LibEvaluator-1.0")
+local Evaluator = LibStub("LibEvaluator-1.0"):New()

 if not LibProperty or not Evaluator then return end

@@ -12,13 +12,14 @@ if not LibProperty.pool then
 	LibProperty.__index = LibProperty
 end

-function LibProperty:New(v, line, name, defval)
+function LibProperty:New(v, expression, name, defval)
+	if not v or not line or not name then return end
 	self.visitor = v
 	self.is_valid = false
-	self.expression = line.left
+	self.expression = expression

 	if self.expression ~= nil and type(expression) == "string" then
-		self.result = Evaluator(self.expression, defval)
+		self.result = Evaluator.ExecuteCode(v, self.expression, defval)
 		if self.result == nil then
 			StarTip:Print(("Property: %s in \"%s\""):format(self.result, self.expression))
 		end
@@ -54,7 +55,7 @@ function LibProperty:Eval()

 	local old = self.result

-	self.result = strlen(StarTip:ExecuteCode(self.expression)) and 1
+	self.result = strlen(Evaluator.ExecuteCode(self.visitor, self.expression)) and 1

 	if old == result then
 		update = 0
diff --git a/Modules/Text.lua b/Modules/Text.lua
index 031c11c..aae6a14 100644
--- a/Modules/Text.lua
+++ b/Modules/Text.lua
@@ -2,6 +2,7 @@ local mod = StarTip:NewModule("Text", "AceTimer-3.0", "AceEvent-3.0")
 mod.name = "Text"
 mod.toggled = true
 local Evaluator = LibStub("LibEvaluator-1.0"):New()
+local LibProperty = LibStub("LibProperty-1.0")
 local _G = _G
 local GameTooltip = _G.GameTooltip
 local StarTip = _G.StarTip
@@ -425,11 +426,13 @@ function mod:MarqUpdate(line)
 	local str = ''
 	local update = 0

-	update = update + StarTip:EvalCode(line.prefix)
-	update = update + StarTip:EvalCode(line.postfix)
-	update = update + StarTip:EvalCode(line.style)
+	update = update + line.prefixProp:Eval()
+	update = update + line.postfixProp:Eval()
+	update = update + line.styleProp:Eval()
+
+	line.leftStyle:Eval()
+

-	StarTip:EvalCode(line.left)
 end

 local function makeMarquee(line, text)
@@ -447,6 +450,12 @@ function mod:CreateLines()
         local lineNum = 0
 		GameTooltip:ClearLines()
         for i, v in ipairs(self) do
+			if not self.leftProperty then
+				self.leftProp = LibProperty:New(self, v.name .. " left", v.left)
+				self.rightProp = LibProperty:New(self, v.name .. " right", v.right)
+				self.prefixProp = LibProperty:New(self, v.name .. " prefix", v.prefix)
+				self.postfixProp = LibProperty:New(self, v.name .. " postfix", v.postfix)
+			end
 			if v.enabled and not v.deleted then

                 local left, right, c