Quantcast

-Rewrote the addon

Xruptor [01-22-11 - 13:34]
-Rewrote the addon
Filename
LagBar.lua
LagBar.toc
diff --git a/LagBar.lua b/LagBar.lua
index b6b28a7..f9ae78d 100644
--- a/LagBar.lua
+++ b/LagBar.lua
@@ -108,62 +108,76 @@ function LagBar:DrawGUI()
 		lbFrame:SetBackdrop(nil);
 	end

-
-
-
 	lbFrame:RegisterForDrag("LeftButton")
 	lbFrame.text = lbFrame:CreateFontString("$parentText", "ARTWORK", "GameFontNormalSmall");
 	lbFrame.text:SetPoint("CENTER", lbFrame, "CENTER", 0, 0);
 	lbFrame.text:Show();
-
+

-		lbFrame:SetScript("OnLoad", function()
+	lbFrame:SetScript("OnUpdate", function(self, arg1)
+
+		if (LagBar.UPDATE_INTERVAL > 0) then
+			LagBar.UPDATE_INTERVAL = LagBar.UPDATE_INTERVAL - arg1;
+		else
+			LagBar.UPDATE_INTERVAL = LagBar.MAX_INTERVAL;
+
+			--local bandwidthIn, bandwidthOut, latency = GetNetStats();
+			--if (latency > LagBar_MEDIUM_LATENCY) then
+			--	LagBar_Text:SetTextColor(1, 0, 0);
+			--elseif (latency > LagBar_LOW_LATENCY) then
+			--	LagBar_Text:SetTextColor(1, 1, 0);
+			--else
+			--	LagBar_Text:SetTextColor(0, 1, 0);
+			--end
+			--if (latency > 9999) then
+			--	LagBar_Text:SetText("Ping: HIGH");
+			--else
+			--	LagBar_Text:SetText("Ping: "..latency.." ms");
+			--end
+
+			local framerate = floor(GetFramerate() + 0.5)
+			local framerate_text = format("|cff%s%d|r fps", LagBar_GetThresholdHexColor(framerate / 60), framerate)
+
+			local latency = select(3, GetNetStats())
+			local latency_text = format("|cff%s%d|r ms", LagBar_GetThresholdHexColor(latency, 1000, 500, 250, 100, 0), latency)
+
+			LagBarFrameText:SetText(framerate_text.." | "..latency_text);
+		end

-			end)
+	end)

-		lbFrame:SetScript("OnShow", function()
+	lbFrame:SetScript("OnMouseDown", function(frame, button)
+
+		if not LagBar_DB.locked and button ~= "RightButton" then
+			frame.isMoving = true
+			frame:StartMoving();
+		end
+
+	end)

+	lbFrame:SetScript("OnMouseUp", function(frame, button)

-			end)
-
-		lbFrame:SetScript("OnUpdate", function(self, arg1)
-
-				LagBar:OnUpdate(arg1);
+		if not LagBar_DB.locked and button ~= "RightButton" then
+			if( frame.isMoving ) then

-			end)
+				frame.isMoving = nil
+				frame:StopMovingOrSizing()

-		lbFrame:SetScript("OnMouseDown", function(frame, button)
-
-				if not LagBar_DB.locked and button ~= "RightButton" then
-					frame.isMoving = true
-					frame:StartMoving();
-				end
-
-			end)
-
-		lbFrame:SetScript("OnMouseUp", function(frame, button)
-
-				if not LagBar_DB.locked and button ~= "RightButton" then
-					if( frame.isMoving ) then
-
-						frame.isMoving = nil
-						frame:StopMovingOrSizing()
-
-						LagBar_DB.x, LagBar_DB.y = frame:GetCenter()
-					end
-
-				elseif button == "RightButton" then
-
-					if LagBar_DB.locked then
-						LagBar_DB.locked = false
-						DEFAULT_CHAT_FRAME:AddMessage("LagBar: Unlocked");
-					else
-						LagBar_DB.locked = true
-						DEFAULT_CHAT_FRAME:AddMessage("LagBar: Locked");
-					end
-				end
-
-			end)
+				LagBar_DB.x, LagBar_DB.y = frame:GetCenter()
+			end
+
+		elseif button == "RightButton" then
+
+			if LagBar_DB.locked then
+				LagBar_DB.locked = false
+				DEFAULT_CHAT_FRAME:AddMessage("LagBar: Unlocked");
+			else
+				LagBar_DB.locked = true
+				DEFAULT_CHAT_FRAME:AddMessage("LagBar: Locked");
+			end
+		end
+
+	end)

 	LagBar.frame = lbFrame;

@@ -198,44 +212,11 @@ function LagBar:BackgroundToggle()

 end

-function LagBar:OnUpdate(arg1)
-
-	if (LagBar.UPDATE_INTERVAL > 0) then
-		LagBar.UPDATE_INTERVAL = LagBar.UPDATE_INTERVAL - arg1;
-	else
-		LagBar.UPDATE_INTERVAL = LagBar.MAX_INTERVAL;
-
-		--local bandwidthIn, bandwidthOut, latency = GetNetStats();
-		--if (latency > LagBar_MEDIUM_LATENCY) then
-		--	LagBar_Text:SetTextColor(1, 0, 0);
-		--elseif (latency > LagBar_LOW_LATENCY) then
-		--	LagBar_Text:SetTextColor(1, 1, 0);
-		--else
-		--	LagBar_Text:SetTextColor(0, 1, 0);
-		--end
-		--if (latency > 9999) then
-		--	LagBar_Text:SetText("Ping: HIGH");
-		--else
-		--	LagBar_Text:SetText("Ping: "..latency.." ms");
-		--end
-
-		local framerate = floor(GetFramerate() + 0.5)
-		local framerate_text = format("|cff%s%d|r fps", LagBar_GetThresholdHexColor(framerate / 60), framerate)
-
-		local latency = select(3, GetNetStats())
-		local latency_text = format("|cff%s%d|r ms", LagBar_GetThresholdHexColor(latency, 1000, 500, 250, 100, 0), latency)
-
-		LagBarFrameText:SetText(framerate_text.." | "..latency_text);
-	end
-end
-
-
 function LagBar_GetThresholdHexColor(quality, ...)
 	local r, g, b = LagBar_GetThresholdColor(quality, ...)
 	return string.format("%02x%02x%02x", r*255, g*255, b*255)
 end

-
 function LagBar_GetThresholdColor(quality, ...)

 	local inf = 1/0
diff --git a/LagBar.toc b/LagBar.toc
index 3e88474..8e88633 100644
--- a/LagBar.toc
+++ b/LagBar.toc
@@ -1,7 +1,7 @@
 ## Interface: 40000
 ## Title: LagBar
 ## Author: Xruptor
-## Version:  2.0
+## Version:  2.1
 ## Notes: Displays a simple bar with some Latency Information.
 ## SavedVariables: LagBar_DB
 LagBar.lua