Quantcast

Cleanup whitespace

Scott Sibley [09-15-10 - 02:17]
Cleanup whitespace
Filename
Modules/Bars.lua
Modules/Histograms.lua
Modules/Text.lua
Modules/UnitTooltip.lua
diff --git a/Modules/Bars.lua b/Modules/Bars.lua
index e2b0dd3..6f0c7b0 100644
--- a/Modules/Bars.lua
+++ b/Modules/Bars.lua
@@ -304,7 +304,7 @@ function mod:OnInitialize()
 	self.core = LibCore:New(mod, environment, "StarTip.Bars", {["StarTip.Bars"] = {}}, nil, StarTip.db.profile.errorLevel)

 	StarTip:SetOptionsDisabled(options, true)
-
+
 	self.bars = {}
 end

diff --git a/Modules/Histograms.lua b/Modules/Histograms.lua
index 2731592..f03c0d7 100644
--- a/Modules/Histograms.lua
+++ b/Modules/Histograms.lua
@@ -17,7 +17,7 @@ local LSM = LibStub("LibSharedMedia-3.0")
 local WidgetHistogram = LibStub("StarLibWidgetHistogram-1.0")
 local LibCore = LibStub("StarLibCore-1.0")

-local unit
+local unit
 local environment = {}

 local createHistograms
@@ -145,7 +145,7 @@ end
 		update = 1000,
 		persistent = true
 	},
-
+
 }

 local defaults = {
@@ -177,7 +177,7 @@ local optionsDefaults = {
 			}
 			tinsert(mod.db.profile.histograms, widget)
 			StarTip:RebuildOpts()
-
+
 		end,
 		order = 5
 	},
@@ -185,9 +185,9 @@ local optionsDefaults = {
 		name = "Restore Defaults",
 		desc = "Restore Defaults",
 		type = "execute",
-		func = function()
-			mod.db.profile.histograms = copy(defaultWidgets);
-			StarTip:RebuildOpts()
+		func = function()
+			mod.db.profile.histograms = copy(defaultWidgets);
+			StarTip:RebuildOpts()
 		end,
 		order = 6
 	},
@@ -195,7 +195,7 @@ local optionsDefaults = {

 function updateHistogram(widget)
 	for i = 1, #widget.history do
-		local bar = widget.bars[i]
+		local bar = widget.bars[i]
 		local segment = widget.history[i]
 		if not segment then break end
 		if type(segment) == "table" then
@@ -216,13 +216,13 @@ do
 	local pool = {}
 	function new()
 		local histogram = next(pool)
-
+
 		if histogram then
 			pool[histogram] = nil
 		else
 			histogram = CreateFrame("StatusBar", nil, GameTooltip)
 		end
-
+
 		return histogram
 	end
 	function del(histogram)
@@ -266,7 +266,7 @@ local function createHistograms()
 			end
 		end
 	end
-
+
 	for k, v in pairs(self.db.profile.histograms) do
 		if v.enabled and not v.deleted then
 			v.width = v.width or WidgetHistogram.defaults.width
@@ -274,10 +274,10 @@ local function createHistograms()
 			local newWidget
 			if not mod.histograms then mod.histograms = {} end
 			if not widget then
-				widget = WidgetHistogram:New(mod.core, v.name, v, v.row or 0, v.col or 0, 0, StarTip.db.profile.errorLevel, updateHistogram)
+				widget = WidgetHistogram:New(mod.core, v.name, v, v.row or 0, v.col or 0, 0, StarTip.db.profile.errorLevel, updateHistogram)
 				widget.persistent = v.persistent
 				newWidget = true
-				for i = 0, v.width - 1 do
+				for i = 0, v.width - 1 do
 					local bar = new()
 					bar:SetStatusBarTexture(LSM:Fetch("statusbar", v.texture))
 					bar:ClearAllPoints()
@@ -307,8 +307,8 @@ local function createHistograms()
 					if not widget.bars then widget.bars = {} end
 					tinsert(widget.bars, bar)
 				end
-			end
-			widget.config.unit = StarTip.unit
+			end
+			widget.config.unit = StarTip.unit
 			mod.histograms[v] = widget
 		end
 	end
@@ -320,18 +320,18 @@ end

 function mod:OnInitialize()
 	self.db = StarTip.db:RegisterNamespace(self:GetName(), defaults)
-
+
 	if not self.db.profile.histograms then
 		self.db.profile.histograms = {}
 	end
-
+
 	for k in pairs(self.db.profile.histograms) do
 		if type(k) == "string" then
 			wipe(self.db.profile.histograms)
 			break
 		end
 	end
-
+
 	for i, v in ipairs(defaultWidgets) do
 		for j, vv in ipairs(self.db.profile.histograms) do
 			if v.name == vv.name and not vv.custom then
@@ -350,11 +350,11 @@ function mod:OnInitialize()
 			tinsert(self.db.profile.histograms, copy(v))
 		end
 	end
-
-	self.core = LibCore:New(mod, environment, "StarTip.Histograms", {["StarTip.Histograms"] = {}}, nil, StarTip.db.profile.errorLevel)
-
-	self.offset = 0
-
+
+	self.core = LibCore:New(mod, environment, "StarTip.Histograms", {["StarTip.Histograms"] = {}}, nil, StarTip.db.profile.errorLevel)
+
+	self.offset = 0
+
 	StarTip:SetOptionsDisabled(options, true)

 	self.histograms = {}
@@ -383,7 +383,7 @@ function mod:SetUnit()
 	createHistograms()
 	for k, widget in pairs(self.histograms) do
 		for i = 1, widget.width or WidgetHistogram.defaults.width do
-			widget.bars[i]:Show()
+			widget.bars[i]:Show()
 		end
 		widget:Start()
 	end
@@ -452,8 +452,8 @@ function mod:RebuildOpts()
 					desc = "Toggle whether this histogram is enabled or not",
 					type = "toggle",
 					get = function() return db.enabled end,
-					set = function(info, v)
-						db.enabled = v
+					set = function(info, v)
+						db.enabled = v
 						db["enabledDirty"] = true
 						self:ClearHistograms()
 					end,
@@ -465,10 +465,10 @@ function mod:RebuildOpts()
 					type = "input",
 					pattern = "%d",
 					get = function() return tostring(db.height or defaults.height) end,
-					set = function(info, v)
-						db.height = tonumber(v);
+					set = function(info, v)
+						db.height = tonumber(v);
 						db["heightDirty"] = true
-						self:ClearHistograms()
+						self:ClearHistograms()
 					end,
 					order = 2
 				},
@@ -500,10 +500,10 @@ function mod:RebuildOpts()
 					type = "input",
 					pattern = "%d",
 					get = function() return tostring(db.update or defaults.update) end,
-					set = function(info, v)
-						db.update = tonumber(v);
-						db["updateDirty"] = true
-						self:ClearHistograms()
+					set = function(info, v)
+						db.update = tonumber(v);
+						db["updateDirty"] = true
+						self:ClearHistograms()
 					end,
 					order = 5
 				},
@@ -533,7 +533,7 @@ function mod:RebuildOpts()
 					end,
 					set = function(info, v)
 						db.texture = LSM:List("statusbar")[v]
-						db["textureDirty"] = true
+						db["textureDirty"] = true
 						self:ClearHistograms()
 					end,
 					order = 6
@@ -580,7 +580,7 @@ function mod:RebuildOpts()
 							pattern = "%d",
 							get = function() return tostring(db.point[5] or 0) end,
 							set = function(info, v) db.point[5] = tonumber(v); self:ClearHistograms(); end,
-							order = 4
+							order = 4
 						}
 					},
 					order = 7
@@ -600,11 +600,11 @@ function mod:RebuildOpts()
 					multiline = true,
 					width = "full",
 					get = function() return db.expression end,
-					set = function(info, v)
-						db.expression = v;
+					set = function(info, v)
+						db.expression = v;
 						db["expressionDirty"] = true
 						self:ClearHistograms()
-
+
 					end,
 					order = 9
 				},
@@ -615,14 +615,14 @@ function mod:RebuildOpts()
 					multiline = true,
 					width = "full",
 					get = function() return db.min end,
-					set = function(info, v)
-						db.min = v;
+					set = function(info, v)
+						db.min = v;
 						db["minDirty"] = true
 						self:ClearHistograms()
-
+
 					end,
 					order = 10
-
+
 				},
 				max = {
 					name = "Histogram max expression",
@@ -631,11 +631,11 @@ function mod:RebuildOpts()
 					multiline = true,
 					width = "full",
 					get = function() return db.max end,
-					set = function(info, v)
-						db.max = v;
+					set = function(info, v)
+						db.max = v;
 						db["maxDirty"] = true
 						self:ClearHistograms()
-
+
 					end,
 					order = 11
 				},
@@ -646,11 +646,11 @@ function mod:RebuildOpts()
 					multiline = true,
 					width = "full",
 					get = function() return db.color end,
-					set = function(info, v)
-						db.color = v;
+					set = function(info, v)
+						db.color = v;
 						db["colorDirty"] = true
 						self:ClearHistograms()
-
+
 					end,
 					order = 12
 				},
@@ -669,8 +669,8 @@ function mod:RebuildOpts()
 						if delete then
 							self.db.profile.histograms[i] = nil
 						end
-						self:ClearHistograms()
-						StarTip:RebuildOpts()
+						self:ClearHistograms()
+						StarTip:RebuildOpts()
 					end,
 					order = 13
 				}
@@ -713,7 +713,7 @@ function mod:UpdateHistogram()
 		color.r, color.g, color.b = colorGradient(min/max)
 	elseif(UnitIsTapped(unit) and not UnitIsTappedByPlayer(unit) or not UnitIsConnected(unit)) then
 		color = health[1]
-	elseif UnitIsPlayer(unit) then
+	elseif UnitIsPlayer(unit) then
 		color = RAID_CLASS_COLORS[select(2, UnitClass(unit))]
 	else
 		color = StarTip.new()
@@ -724,7 +724,7 @@ function mod:UpdateHistogram()
 	StarTip.del(color)
 end
 ]]
--- Logic snagged from oUF
+-- Logic snagged from oUF
 --[[
 function mod:UpdateHealth()
 	local unit = "mouseover"
@@ -739,7 +739,7 @@ function mod:UpdateHealth()
 		color.r, color.g, color.b = colorGradient(min/max)
 	elseif(UnitIsTapped(unit) and not UnitIsTappedByPlayer(unit) or not UnitIsConnected(unit)) then
 		color = health[1]
-	elseif UnitIsPlayer(unit) then
+	elseif UnitIsPlayer(unit) then
 		color = RAID_CLASS_COLORS[select(2, UnitClass(unit))]
 	else
 		color = StarTip.new()
diff --git a/Modules/Text.lua b/Modules/Text.lua
index eddcd29..2aaf568 100644
--- a/Modules/Text.lua
+++ b/Modules/Text.lua
@@ -71,7 +71,7 @@ return ClassColor(unit)
 		dontRtrim = true,
 		point = {"BOTTOMLEFT", "GameTooltip", "TOPLEFT", 0, 12},
 		parent = "GameTooltip",
-	},
+	},
 	[2] = {
 		name = "Health",
 		enabled = true,
@@ -84,7 +84,7 @@ return format('Health: %.1f%%', health / max * 100)
 		color = [[
 if not UnitExists(unit) then return end
 local health, max = UnitHealth(unit), UnitHealthMax(unit)
-return HPColor(health, max)
+return HPColor(health, max)
 ]],
 		cols = 20,
 		update = 1000,
@@ -97,7 +97,7 @@ return HPColor(health, max)
 		value = [[
 if not UnitExists(unit) then return end
 local mana, max = UnitMana(unit), UnitManaMax(unit)
-if max == 0 then max = 0.0001 end
+if max == 0 then max = 0.0001 end
 return format(PowerName(unit)..': %.1f%%', mana / max * 100)
 ]],
 		color = [[
@@ -114,7 +114,7 @@ return HPColor(mana, max)
 	[4] = {
 		name = "Memory Percent",
 		enabled = false,
-		value = [[
+		value = [[
 local mem, percent, memdiff, totalMem, totaldiff, memperc = GetMemUsage("StarTip")
 if mem then
     local num = floor(memperc)
@@ -144,9 +144,11 @@ end
 	[5] = {
 		name = "Memory Total",
 		enabled = false,
-		value = [[
+		value = [[
 local mem, percent, memdiff, totalMem, totaldiff, memperc = GetMemUsage("StarTip")
 if mem then
+    if totalMem == 0 then totalMem = 100; mem = 0 end
+    memperc = mem / totalMem * 100
     return format("%s (%.2f%%)", memshort(mem), memperc)
 end
 ]],
@@ -158,7 +160,7 @@ return 1, 1, 0
 		dontRtrim = true,
 		point = {"TOPLEFT", "GameTooltip", "BOTTOMLEFT", 0, -124},
 		parent = "GameTooltip"
-	},
+	},
 	[6] = {
 		name = "CPU Percent",
 		enabled = false,
@@ -176,7 +178,7 @@ if cpu then
     if num > 100 then num = 100 end
     local r, g, b = gradient[num][1], gradient[num][2], gradient[num][3]
     return r, g, b
-end
+end
 ]],
 		cols = 20,
 		align = WidgetText.ALIGN_RIGHT,
@@ -197,7 +199,7 @@ if cpu then
 end
 ]],
 		color = [[
-return 1, 1, 0
+return 1, 1, 0
 ]],
 		cols = 20,
 		align = WidgetText.ALIGN_RIGHT,
@@ -205,7 +207,7 @@ return 1, 1, 0
 		dontRtrim = true,
 		point = {"TOPRIGHT", "GameTooltip", "BOTTOMRIGHT", 0, -124},
 		parent = "GameTooltip"
-	},
+	},
 }

 local defaults = {
@@ -242,9 +244,9 @@ local optionsDefaults = {
 		name = "Restore Defaults",
 		desc = "Restore Defaults",
 		type = "execute",
-		func = function()
-			mod.db.profile.texts = copy(defaultWidgets);
-			StarTip:RebuildOpts()
+		func = function()
+			mod.db.profile.texts = copy(defaultWidgets);
+			StarTip:RebuildOpts()
 		end,
 		order = 6
 	},
@@ -252,13 +254,13 @@ local optionsDefaults = {

 function updateText(widget)
 	widget.text:SetText(widget.buffer)
-
+
 	local r, g, b = 0, 0, 1
-
+
 	if widget.color then
 		r, g, b, a = widget.color.res1, widget.color.res2, widget.color.res3, widget.color.res4
 	end
-
+
 	if type(r) == "number" then
 		widget.text:SetVertexColor(r, g, b, a)
 	end
@@ -276,14 +278,14 @@ do
 	local i = 0
 	function new(cols)
 		local text = next(pool)
-
+
 		if text then
 			pool[text] = nil
 		else
 			text = GameTooltip:CreateFontString()
 			text:SetFontObject(GameTooltipText)
 		end
-
+
 		return text
 	end
 	function del(text)
@@ -292,7 +294,7 @@ do
 end

 local defaultPoint = {"BOTTOMLEFT", "GameTooltip", "TOPLEFT"}
-
+
 local strataNameList = {
 	"BACKGROUND", "LOW", "MEDIUM", "HIGH", "DIALOG", "FULLSCREEN", "FULLSCREEN_DIALOG", "TOOLTIP"
 }
@@ -320,11 +322,11 @@ function createTexts()
 		v.text:Hide()
 		del(v.text)
 	end]]
-	local appearance = StarTip:GetModule("Appearance")
+	local appearance = StarTip:GetModule("Appearance")
 	for i, v in ipairs(self.db.profile.texts) do
 		if v.enabled and not v.deleted then
 			local text = new(v.cols or WidgetText.defaults.cols)
-			local widget = mod.texts[v] or WidgetText:New(mod.core, v.name, v, v.row or 0, v.col or 0, v.layer or 0, StarTip.db.profile.errorLevel, updateText)
+			local widget = mod.texts[v] or WidgetText:New(mod.core, v.name, v, v.row or 0, v.col or 0, v.layer or 0, StarTip.db.profile.errorLevel, updateText)
 			widget.config.unit = StarTip.unit
 			text:ClearAllPoints()
 			text:SetParent(v.parent)
@@ -341,11 +343,11 @@ end

 function mod:OnInitialize()
 	self.db = StarTip.db:RegisterNamespace(self:GetName(), defaults)
-
+
 	if not self.db.profile.texts then
 		self.db.profile.texts = {}
 	end
-
+
 	for i, v in ipairs(defaultWidgets) do
 		for j, vv in ipairs(self.db.profile.texts) do
 			if v.name == vv.name and not vv.custom then
@@ -364,9 +366,9 @@ function mod:OnInitialize()
 			tinsert(self.db.profile.texts, copy(v))
 		end
 	end
-
-	self.core = LibCore:New(mod, environment, "StarTip.Texts", {["StarTip.Texts"] = {}}, nil, StarTip.db.profile.errorLevel)
-
+
+	self.core = LibCore:New(mod, environment, "StarTip.Texts", {["StarTip.Texts"] = {}}, nil, StarTip.db.profile.errorLevel)
+
 	StarTip:SetOptionsDisabled(options, true)

 	self.texts = {}
@@ -445,7 +447,7 @@ function mod:RebuildOpts()
 	for k, v in pairs(optionsDefaults) do
 		options[k] = v
 	end
-
+
 	for i, db in ipairs(self.db.profile.texts) do
 		options[db.name:gsub(" ", "_")] = {
 			name = db.name,
@@ -493,10 +495,10 @@ end
 					type = "input",
 					pattern = "%d",
 					get = function() return tostring(db.height or defaults.height) end,
-					set = function(info, v)
-						db.height = tonumber(v);
+					set = function(info, v)
+						db.height = tonumber(v);
 						db["heightDirty"] = true
-						createTexts();
+						createTexts();
 					end,
 					order = 2
 				},
@@ -506,10 +508,10 @@ end
 					type = "input",
 					pattern = "%d",
 					get = function() return tostring(db.update or defaults.update) end,
-					set = function(info, v)
-						db.update = tonumber(v);
-						db["updateDirty"] = true
-						createTexts()
+					set = function(info, v)
+						db.update = tonumber(v);
+						db["updateDirty"] = true
+						createTexts()
 					end,
 					order = 3
 				},
@@ -563,7 +565,7 @@ end
 							pattern = "%d",
 							get = function() return tostring(db.point[5] or 0) end,
 							set = function(info, v) db.point[5] = tonumber(anchors[v]) end,
-							order = 4
+							order = 4
 						}
 					},
 					order = 7
@@ -573,10 +575,10 @@ end
 					desc = "Toggle whether to place the first text on top",
 					type = "toggle",
 					get = function() return db.top end,
-					set = function(info, v)
-						db.top = v;
-						db["topDirty"] = true
-						createTexts()
+					set = function(info, v)
+						db.top = v;
+						db["topDirty"] = true
+						createTexts()
 					end,
 					order = 8
 				},
@@ -587,10 +589,10 @@ end
 					multiline = true,
 					width = "full",
 					get = function() return db.value end,
-					set = function(info, v)
-						db.value = v;
+					set = function(info, v)
+						db.value = v;
 						db["valueDirty"] = true
-						createTexts()
+						createTexts()
 					end,
 					order = 9
 				},
diff --git a/Modules/UnitTooltip.lua b/Modules/UnitTooltip.lua
index b0674f4..0bdf094 100644
--- a/Modules/UnitTooltip.lua
+++ b/Modules/UnitTooltip.lua
@@ -108,14 +108,14 @@ local r, g, b
 local unit = (unit or "mouseover") .. "target"
 if UnitExists(unit) then
     if UnitIsPlayer(unit) then
-		r, g, b = ClassColor(unit)
+        r, g, b = ClassColor(unit)
     else
         r, g, b = UnitSelectionColor(unit)
     end
 else
-	r = 1
-	g = 1
-	b = 1
+    r = 1
+    g = 1
+    b = 1
 end
 local name = UnitName(unit)
 if name == select(1, UnitName("player")) then name = "<<YOU>>" end
@@ -250,12 +250,7 @@ return value
     [12] = {
         name = "Mana",
         left = [[
-class = select(2, UnitClass(unit))
-if not UnitIsPlayer(unit) then
-	class = "MAGE"
-end
-
-return (powers[class] or "Mana:")
+return PowerName(unit)
 ]],
         right = [[
 mana = UnitMana(unit)
@@ -302,7 +297,6 @@ if mem then
     local num = floor(memperc)
     if num < 1 then num = 1 end
     if num > 100 then num = 100 end
-	assert(gradient[num], format("%d", num))
     local r, g, b = gradient[num][1], gradient[num][2], gradient[num][3]
     return GetColorCode(format("%s (%.2f%%)", memshort(mem), memperc), r, g, b)
 end
@@ -491,7 +485,7 @@ function mod:CreateLines()
                 local left, right, c, cc = '', ''
 				environment.unit = StarTip.unit
 				v.config.unit = StarTip.unit
-                if v.right and v.right ~= "" then
+                if v.right and v.right ~= "" then
                     right = mod.evaluator.ExecuteCode(environment, v.name .. " right", v.right)
                     left = mod.evaluator.ExecuteCode(environment, v.name .. " left", v.left)
 					if right == "" then right = "nil" end
@@ -500,7 +494,7 @@ function mod:CreateLines()
                     right = ''
                     left = mod.evaluator.ExecuteCode(environment, v.name .. " left", v.left)
                 end
-
+
                 if left and left ~= "" and right ~= "nil" then
                     lineNum = lineNum + 1
                     if v.right then
@@ -510,7 +504,7 @@ function mod:CreateLines()
 							v.config.value = v.left
 							local tmp = v.update
 							if not v.leftUpdating then v.update = 0 end
-
+
 							v.leftObj = v.leftObj or WidgetText:New(mod.core, v.name .. "left", copy(v.config), 0, 0, v.layer or 0, StarTip.db.profile.errorLevel, updateWidget)
 							v.update = tmp
 						end
@@ -1046,7 +1040,7 @@ function mod:SetUnit()
     end

     lastLine = lastLine + 1
-
+
 	wipe(linesToAdd)
 	wipe(linesToAddR)
 	wipe(linesToAddG)
@@ -1075,19 +1069,19 @@ function mod:SetUnit()
     -- End

 	lines()
-
+
 	GameTooltip:Show()

 	if self.db.profile.refreshRate > 0 and self.timer then
 		self.timer:Start()
-	end
-
+	end
+
 end

 function mod:RefixEndLines()
     -- Another part taken from CowTip
     for i, left in ipairs(linesToAdd) do
-
+
         local right = linesToAddRight[i]
         if right then
             GameTooltip:AddDoubleLine(left, right, linesToAddR[i], linesToAddG[i], linesToAddB[i], linesToAddRightR[i], linesToAddRightG[i], linesToAddRightB[i])