Quantcast

Only update segments when they've changed

Scott Sibley [08-15-10 - 19:35]
Only update segments when they've changed
Filename
Modules/Text.lua
diff --git a/Modules/Text.lua b/Modules/Text.lua
index d98a12f..35d94bc 100644
--- a/Modules/Text.lua
+++ b/Modules/Text.lua
@@ -497,6 +497,7 @@ local function updateFontString(widget, fontString)
 end

 function draw()
+	local drawn
 	if not UnitExists("mouseover") then
 		return
 	end
@@ -506,31 +507,34 @@ function draw()
 		for i, table in ipairs(linesToDraw) do
 			local widget = table[1]
 			local fontString = table[2]
-			fontString:SetText(widget.buffer)
-			fontString:SetVertexColor(widget.color.r / 255, widget.color.g / 255, widget.color.b / 255, widget.color.a / 255)
-			local appearance = StarTip:GetModule("Appearance")
+			if widget.changed then
+				drawn = true
+				fontString:SetText(widget.buffer)
+				fontString:SetVertexColor(widget.color.r / 255, widget.color.g / 255, widget.color.b / 255, widget.color.a / 255)
+				local appearance = StarTip:GetModule("Appearance")

-			local font = appearance.db.profile.font
-			local fontsList = LSM:List("font")
-			font = LSM:Fetch("font", fontsList[font])
+				local font = appearance.db.profile.font
+				local fontsList = LSM:List("font")
+				font = LSM:Fetch("font", fontsList[font])

-			if widget.bold then
-				if mod.leftLines and mod.leftLines[widget.i] then
-					mod.leftLines[widget.i]:SetFont(font, appearance.db.profile.fontSizeBold)
+				if widget.bold then
+					if mod.leftLines and mod.leftLines[widget.i] then
+						mod.leftLines[widget.i]:SetFont(font, appearance.db.profile.fontSizeBold)
+					end
+					if mod.rightLines and mod.rightLines[widget.i] then
+						mod.rightLines[widget.i]:SetFont(font, appearance.db.profile.fontSizeBold)
+					end
+				else
+					if mod.leftlines and mod.leftLines[widget.i] then
+						mod.leftLines[widget.i]:SetFont(font, appearance.db.profile.fontSizeNormal)
 				end
-				if mod.rightLines and mod.rightLines[widget.i] then
-					mod.rightLines[widget.i]:SetFont(font, appearance.db.profile.fontSizeBold)
-				end
-			else
-				if mod.leftlines and mod.leftLines[widget.i] then
-					mod.leftLines[widget.i]:SetFont(font, appearance.db.profile.fontSizeNormal)
-			end
-				if mod.rightLines and mod.rightLines[widget.i] then
-					mod.rightLines[widget.i]:SetFont(font, appearance.db.profile.fontSizeNormal)
+					if mod.rightLines and mod.rightLines[widget.i] then
+						mod.rightLines[widget.i]:SetFont(font, appearance.db.profile.fontSizeNormal)
+					end
 				end
 			end
 		end
-	if UnitExists("mouseover") then
+	if UnitExists("mouseover") and drawn then
 		GameTooltip:Hide()
 		GameTooltip:Show()
 	end