Skip to content

Commit

Permalink
Added Movement Speed Option (thanks to pkajan)
Browse files Browse the repository at this point in the history
  • Loading branch information
muleyo committed Oct 2, 2024
1 parent 231f53f commit 5544ced
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 16 deletions.
22 changes: 15 additions & 7 deletions Config/Layouts/_General.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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
3 changes: 2 additions & 1 deletion Core/Init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ local defaults = {
display = {
ilvl = true,
fps = true,
ms = true
ms = true,
movementSpeed = false
}
},
unitframes = {
Expand Down
32 changes: 24 additions & 8 deletions Modules/General/_Stats.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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)
Expand Down Expand Up @@ -65,4 +81,4 @@ function Module:OnEnable()

StatsFrame:SetScript("OnUpdate", update)
end
end
end

0 comments on commit 5544ced

Please sign in to comment.