From 5544ced5c9376c20b00057e047497878ee513683 Mon Sep 17 00:00:00 2001 From: muleyo Date: Wed, 2 Oct 2024 15:58:07 +0200 Subject: [PATCH] Added Movement Speed Option (thanks to pkajan) --- Config/Layouts/_General.lua | 22 +++++++++++++++------- Core/Init.lua | 3 ++- Modules/General/_Stats.lua | 32 ++++++++++++++++++++++++-------- 3 files changed, 41 insertions(+), 16 deletions(-) diff --git a/Config/Layouts/_General.lua b/Config/Layouts/_General.lua index ffce712c..c3b83a1f 100755 --- a/Config/Layouts/_General.lua +++ b/Config/Layouts/_General.lua @@ -168,14 +168,14 @@ function Layout:OnEnable() column = 2, order = 3 }, - talkhead = { - key = 'cosmetic.talkinghead', + movementSpeed = { + key = 'display.movementSpeed', type = 'checkbox', - label = 'Talkinghead', - tooltip = 'Show Talkinghead frame', + label = 'Movement Speed', + tooltip = 'Show current movement speed', column = 3, order = 4 - } + }, }, { afkscreen = { @@ -186,15 +186,23 @@ function Layout:OnEnable() column = 3, order = 1 }, + talkhead = { + key = 'cosmetic.talkinghead', + type = 'checkbox', + label = 'Talkinghead', + tooltip = 'Show Talkinghead frame', + column = 3, + order = 2 + }, Errors = { key = 'cosmetic.errors', type = 'checkbox', label = 'Error Messages', tooltip = 'Display Error Messages (Out of Range etc.)', column = 3, - order = 2 + order = 3 }, } }, } -end +end \ No newline at end of file diff --git a/Core/Init.lua b/Core/Init.lua index bedc1716..27205f90 100755 --- a/Core/Init.lua +++ b/Core/Init.lua @@ -32,7 +32,8 @@ local defaults = { display = { ilvl = true, fps = true, - ms = true + ms = true, + movementSpeed = false } }, unitframes = { diff --git a/Modules/General/_Stats.lua b/Modules/General/_Stats.lua index 7ff3eae0..efb68abc 100755 --- a/Modules/General/_Stats.lua +++ b/Modules/General/_Stats.lua @@ -10,7 +10,7 @@ function Module:OnEnable() StatsFrame:ClearAllPoints() StatsFrame:SetPoint(db.statsframe.point, UIParent, db.statsframe.point, db.statsframe.x, db.statsframe.y) - if (db.display.fps or db.display.ms) then + if (db.display.fps or db.display.ms or db.display.movementSpeed) then local font = STANDARD_TEXT_FONT local fontSize = 13 local fontFlag = "THINOUTLINE" @@ -31,13 +31,29 @@ function Module:OnEnable() local function getLatency() return "|c00ffffff" .. select(4, GetNetStats()) .. "|r ms" end - if (db.display.fps and db.display.ms) then - return getFPS() .. " " .. getLatency() - elseif (db.display.fps) then - return getFPS() - elseif (db.display.ms) then - return getLatency() + local isGliding, canGlide, forwardSpeed = C_PlayerInfo.GetGlidingInfo() + local function getMovementSpeed() + if isGliding then + return "|c00ffffff" .. string.format("%d", forwardSpeed and (forwardSpeed / BASE_MOVEMENT_SPEED * 100)) .. "%|r speed" + else + return "|c00ffffff" .. string.format("%d", (GetUnitSpeed("player") / BASE_MOVEMENT_SPEED * 100)) .. "%|r speed" + end end + + local result = {} + if db.display.fps then + table.insert(result, getFPS()) + end + + if db.display.ms then + table.insert(result, getLatency()) + end + + if db.display.movementSpeed then + table.insert(result, getMovementSpeed()) + end + + return table.concat(result, " ") end StatsFrame:SetWidth(50) @@ -65,4 +81,4 @@ function Module:OnEnable() StatsFrame:SetScript("OnUpdate", update) end -end +end \ No newline at end of file