-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdebugMenu.lua
More file actions
56 lines (43 loc) · 1.18 KB
/
debugMenu.lua
File metadata and controls
56 lines (43 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
local Node2D = require("lib.2d.Node2d")
local Label = require("lib.2d.gui.Label")
---@class DebugMenu: Node2D
local DebugMenu = class("DebugMenu", Node2D)
DebugMenu.label = nil ---@type Label
DebugMenu.updateMode = "always"
local mem = 0
function DebugMenu:ready()
local dm = self
main.onEvent("keypressed", function(key)
if key == "f3" then
dm.visible = not dm.visible
end
end)
self:createTimer()
:setWait(0.5)
:setLoop(true)
:onEnd(function()
mem = collectgarbage("count")
end)
:start()
self.visible = false
self.label = self:addChild(
Label:new()
:setPosition(0.5, 0.9)
:setText("loading info...")
)
end
function DebugMenu:update(delta)
if not self.visible then
return
end
local info = {}
local function add(label, value)
table.insert(info, label .. ": " .. tostring(value))
end
add("FPS", love.timer.getFPS())
add("Mem", string.format("%.2f MB", mem / 1024))
add("OS", love.system.getOS())
add("Ver", os.getenv("LOVER_PKG_VERSION"))
self.label:setText(table.concat(info, " | "))
end
return DebugMenu