From a8ec255a9033b1c3621bc6d117cbcbaa40d91769 Mon Sep 17 00:00:00 2001 From: kompolompo Date: Sat, 5 Sep 2026 18:30:47 +0200 Subject: [PATCH] Add FPS display, make world latency opt-in, bump to 1.3 World latency never populates on OctoWoW (always 0), so it's now hidden behind /octolat worldlatency instead of showing a misleading "0 ms". --- CHANGELOG.md | 9 +++++++++ OctoLatency.lua | 38 +++++++++++++++++++++++++++++++------- OctoLatency.toc | 2 +- OctoLatency.xml | 4 ++-- 4 files changed, 43 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dffc7f4..b734776 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,15 @@ All notable changes to OctoLatency are documented in this file. ## [Unreleased] +## [1.3] +### Added +- FPS display next to latency in the main frame and tooltip, color-coded (green ≥30, yellow 15-30, red <15), via `GetFramerate()`. +- `/octolat worldlatency` slash command to opt in to world latency display. + +### Changed +- World latency is now hidden by default (tooltip shows `N/A`, status text always uses home latency) since many private-server cores (including OctoWoW) never populate it. Enable it with `/octolat worldlatency` on servers that do report it. +- Widened the frame (90px → 150px) and status text (80px → 140px) to fit the added FPS text. + ## [1.2] ### Fixed - Drag could get permanently stuck following the cursor: `OnMouseUp` only fires while the mouse is still over the frame at the instant the button is released, which a quick flick of this small (90x24) frame easily misses. `OnUpdate` now polls `IsMouseButtonDown("LeftButton")` every frame and stops the drag as soon as the button is released, regardless of where the cursor ends up. diff --git a/OctoLatency.lua b/OctoLatency.lua index 22fa161..0fe4b00 100644 --- a/OctoLatency.lua +++ b/OctoLatency.lua @@ -51,12 +51,21 @@ function OctoLatency_OnLoad(self) OctoLatency_SafeCall("OnEnter", function() GameTooltip:SetOwner(this, "ANCHOR_TOP") GameTooltip:AddLine("OctoLatency", 0, 1, 1) + local db = OctoLatency_EnsureDB() local bandwidth, latency, homeLatency, worldLatency = GetNetStats() bandwidth = bandwidth or 0 homeLatency = homeLatency or 0 worldLatency = worldLatency or 0 GameTooltip:AddLine("Home Latency: " .. homeLatency .. " ms", 1, 1, 1) - GameTooltip:AddLine("World Latency: " .. worldLatency .. " ms", 1, 1, 1) + if (db.showWorldLatency) then + GameTooltip:AddLine("World Latency: " .. worldLatency .. " ms", 1, 1, 1) + else + -- Many private-server cores never populate this (always 0), so + -- it's hidden behind an opt-in setting (/octolat worldlatency) + -- instead of showing a permanently-wrong "0 ms". + GameTooltip:AddLine("World Latency: N/A", 1, 1, 1) + end + GameTooltip:AddLine("FPS: " .. string.format("%.0f", GetFramerate() or 0), 1, 1, 1) GameTooltip:AddLine("Bandwidth: " .. string.format("%.2f", bandwidth) .. " KB/s", 1, 1, 1) GameTooltip:AddLine("Left-click and drag to move.", 0.7, 0.7, 0.7) GameTooltip:Show() @@ -69,14 +78,16 @@ function OctoLatency_OnLoad(self) end local function OctoLatency_UpdateText() + local db = OctoLatency_EnsureDB() + -- GetNetStats returns: bandwidth, latency, homeLatency, worldLatency local _, _, homeLatency, worldLatency = GetNetStats() - -- We'll display world latency (or max of home/world) - -- Some servers never populate world latency (always 0), and 0 is - -- truthy in Lua, so treat a zero world latency as "unavailable" too. + -- World latency defaults to off since many private-server cores never + -- populate it (always 0); enable it with /octolat worldlatency if your + -- server does report it. local latency = homeLatency or 0 - if (worldLatency and worldLatency > 0) then + if (db.showWorldLatency and worldLatency and worldLatency > 0) then latency = worldLatency end @@ -90,7 +101,17 @@ local function OctoLatency_UpdateText() colorHex = "|cffff0000" -- Red end - OctoLatencyText:SetText(colorHex .. latency .. " ms|r") + local fps = GetFramerate() or 0 + local fpsColorHex + if (fps >= 30) then + fpsColorHex = "|cff00ff00" -- Green + elseif (fps >= 15) then + fpsColorHex = "|cffffff00" -- Yellow + else + fpsColorHex = "|cffff0000" -- Red + end + + OctoLatencyText:SetText(colorHex .. latency .. " ms|r " .. fpsColorHex .. string.format("%.0f", fps) .. " fps|r") end function OctoLatency_OnUpdate(elapsed) @@ -236,7 +257,10 @@ SlashCmdList["OCTOLATENCY"] = function(msg) elseif (msg == "clearerrors") then db.errorLog = {} DEFAULT_CHAT_FRAME:AddMessage("OctoLatency: error log cleared.") + elseif (msg == "worldlatency") then + db.showWorldLatency = not db.showWorldLatency + DEFAULT_CHAT_FRAME:AddMessage("OctoLatency: world latency display " .. (db.showWorldLatency and "enabled" or "disabled") .. ".") else - DEFAULT_CHAT_FRAME:AddMessage("OctoLatency commands: /octolat errors, /octolat copyerrors, /octolat clearerrors") + DEFAULT_CHAT_FRAME:AddMessage("OctoLatency commands: /octolat errors, /octolat copyerrors, /octolat clearerrors, /octolat worldlatency") end end diff --git a/OctoLatency.toc b/OctoLatency.toc index d9bd858..0fe54a2 100644 --- a/OctoLatency.toc +++ b/OctoLatency.toc @@ -2,7 +2,7 @@ ## Title: |cff003c00O|cff005000c|cff006300t|cff007700o|cff008a00L|cff009e00a|cff00b100t|cff00c500e|cff00d800n|cff00ec00c|cff00ff00y|r ## Notes: Lightweight latency monitor with color-coding for Vanilla WoW (1.12.1) ## Author: Palladinpala -## Version: 1.2 +## Version: 1.3 ## SavedVariables: OctoLatencyDB OctoLatency.xml diff --git a/OctoLatency.xml b/OctoLatency.xml index 62de95c..650ce12 100644 --- a/OctoLatency.xml +++ b/OctoLatency.xml @@ -2,7 +2,7 @@