-Added a slash command to turn on/off the new World ping display.
Xruptor [05-03-11 - 13:05]
-Added a slash command to turn on/off the new World ping display.
-The slash command will also resize the box to have some more room ;)
-NEW SLASH: /lagbar worldping
diff --git a/LagBar.lua b/LagBar.lua
index 8b4873f..5ea1259 100644
--- a/LagBar.lua
+++ b/LagBar.lua
@@ -32,12 +32,16 @@ function LagBar:Enable()
LagBar_DB.locked = false;
LagBar_DB.bgShown = true;
end
+ --lets do a toggle for world ping
+ if LagBar_DB and LagBar_DB.worldping == nil then
+ LagBar_DB.worldping = true
+ end
SLASH_LAGBAR1 = "/lagbar";
SlashCmdList["LAGBAR"] = LagBar_SlashCommand;
- LagBar:DrawGUI();
- LagBar:MoveFrame();
+ LagBar:DrawGUI()
+ LagBar:MoveFrame()
end
function LagBar:OnEvent(event, arg1, arg2, arg3, arg4, ...)
@@ -56,11 +60,17 @@ function LagBar_SlashCommand(cmd)
elseif cmd:lower() == "bg" then
LagBar:BackgroundToggle();
return nil;
+
+ elseif cmd:lower() == "worldping" then
+ LagBar:WorldPingToggle();
+ return nil;
+
end
end
DEFAULT_CHAT_FRAME:AddMessage("LagBar");
DEFAULT_CHAT_FRAME:AddMessage("/lagbar reset - resets the frame position");
DEFAULT_CHAT_FRAME:AddMessage("/lagbar bg - toggles the background on/off");
+ DEFAULT_CHAT_FRAME:AddMessage("/lagbar worldping - toggles world ping display on/off");
end
function LagBar:MoveFrame()
@@ -92,9 +102,15 @@ function LagBar:DrawGUI()
lbFrame:SetToplevel(true);
lbFrame:SetMovable(true);
lbFrame:SetFrameStrata("LOW");
- lbFrame:SetWidth(120);
lbFrame:SetHeight(25);
+ --now change size according to worldping
+ if LagBar_DB.worldping then
+ LagBar.frame:SetWidth(120 + 30)
+ else
+ LagBar.frame:SetWidth(120)
+ end
+
if LagBar_DB.bgShown then
local backdrop_header = {bgFile = "Interface\\Tooltips\\UI-Tooltip-Background",
@@ -155,8 +171,13 @@ function LagBar:DrawGUI()
local latencyWorld = select(4, GetNetStats())
local latency_text_server = format("|cff%s%d|r ms", LagBar_GetThresholdHexColor(latencyWorld, 1000, 500, 250, 100, 0), latencyWorld)
- LagBarFrameText:SetText(framerate_text.." | "..latency_text.." | "..latency_text_server);
-
+ --change text according to worldping
+ if LagBar_DB.worldping then
+ LagBarFrameText:SetText(framerate_text.." | "..latency_text.." | "..latency_text_server)
+ else
+ LagBarFrameText:SetText(framerate_text.." | "..latency_text)
+ end
+
end
end)
@@ -227,6 +248,28 @@ function LagBar:BackgroundToggle()
end
+function LagBar:WorldPingToggle()
+
+ if not LagBar_DB.worldping then
+ LagBar_DB.worldping = true
+ DEFAULT_CHAT_FRAME:AddMessage("LagBar: World ping is now displayed")
+ elseif LagBar_DB.worldping then
+ LagBar_DB.worldping = false
+ DEFAULT_CHAT_FRAME:AddMessage("LagBar: World ping is now hidden")
+ else
+ LagBar_DB.worldping = true
+ DEFAULT_CHAT_FRAME:AddMessage("LagBar: World ping is now displayed")
+ end
+
+ --now change size
+ if LagBar_DB.worldping then
+ LagBar.frame:SetWidth(120 + 30)
+ else
+ LagBar.frame:SetWidth(120)
+ 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)
diff --git a/LagBar.toc b/LagBar.toc
index fb48a57..8e35a88 100644
--- a/LagBar.toc
+++ b/LagBar.toc
@@ -1,7 +1,7 @@
## Interface: 40100
## Title: LagBar
## Author: Xruptor
-## Version: 2.2
+## Version: 2.3
## Notes: Displays a simple bar with some Latency Information.
## SavedVariables: LagBar_DB
LagBar.lua