mirror of
https://github.com/linux-man/LoveFrames.git
synced 2024-11-18 16:04:22 +00:00
96 lines
3.5 KiB
Lua
96 lines
3.5 KiB
Lua
--[[------------------------------------------------
|
|
-- Love Frames - A GUI library for LOVE --
|
|
-- Copyright (c) 2013 Kenny Shields --
|
|
--]]------------------------------------------------
|
|
|
|
-- debug library
|
|
loveframes.debug = {}
|
|
|
|
--[[---------------------------------------------------------
|
|
- func: draw()
|
|
- desc: draws debug information
|
|
--]]---------------------------------------------------------
|
|
function loveframes.debug.draw()
|
|
|
|
-- do not draw anthing if debug is off
|
|
local debug = loveframes.config["DEBUG"]
|
|
if not debug then
|
|
return
|
|
end
|
|
|
|
local infox = 5
|
|
local infoy = 40
|
|
local cols = loveframes.util.GetCollisions()
|
|
local topcol = {type = none, children = {}, x = 0, y = 0, width = 0, height = 0}
|
|
local objects = loveframes.util.GetAllObjects()
|
|
local author = loveframes.info.author
|
|
local version = loveframes.info.version
|
|
local stage = loveframes.info.stage
|
|
local basedir = loveframes.config["DIRECTORY"]
|
|
local loveversion = love._version
|
|
local fps = love.timer.getFPS()
|
|
local deltatime = love.timer.getDelta()
|
|
local font = loveframes.basicfontsmall
|
|
local loveversion = love._version
|
|
|
|
-- set the top most collision object
|
|
for k, v in ipairs(cols) do
|
|
if v:IsTopCollision() then
|
|
topcol = v
|
|
break
|
|
end
|
|
end
|
|
|
|
-- show frame docking zones
|
|
if topcol.type == "frame" then
|
|
for k, v in pairs(topcol.dockzones) do
|
|
love.graphics.setLineWidth(1)
|
|
love.graphics.setColor(255, 0, 0, 100)
|
|
love.graphics.rectangle("fill", v.x, v.y, v.width, v.height)
|
|
love.graphics.setColor(255, 0, 0, 255)
|
|
love.graphics.rectangle("line", v.x, v.y, v.width, v.height)
|
|
end
|
|
end
|
|
|
|
-- outline the object that the mouse is hovering over
|
|
love.graphics.setColor(255, 204, 51, 255)
|
|
love.graphics.setLineWidth(2)
|
|
love.graphics.rectangle("line", topcol.x - 1, topcol.y - 1, topcol.width + 2, topcol.height + 2)
|
|
|
|
-- draw main debug box
|
|
love.graphics.setFont(font)
|
|
love.graphics.setColor(0, 0, 0, 200)
|
|
love.graphics.rectangle("fill", infox, infoy, 200, 70)
|
|
love.graphics.setColor(255, 0, 0, 255)
|
|
love.graphics.print("Love Frames - Debug (" ..version.. " - " ..stage.. ")", infox + 5, infoy + 5)
|
|
love.graphics.setColor(255, 255, 255, 255)
|
|
love.graphics.print("LOVE Version: " ..loveversion, infox + 10, infoy + 20)
|
|
love.graphics.print("FPS: " ..fps, infox + 10, infoy + 30)
|
|
love.graphics.print("Delta Time: " ..deltatime, infox + 10, infoy + 40)
|
|
love.graphics.print("Total Objects: " ..#objects, infox + 10, infoy + 50)
|
|
|
|
-- draw object information if needed
|
|
if #cols > 0 and topcol.type ~= "base" then
|
|
love.graphics.setColor(0, 0, 0, 200)
|
|
love.graphics.rectangle("fill", infox, infoy + 75, 200, 100)
|
|
love.graphics.setColor(255, 0, 0, 255)
|
|
love.graphics.print("Object Information", infox + 5, infoy + 80)
|
|
love.graphics.setColor(255, 255, 255, 255)
|
|
love.graphics.print("Type: " ..topcol.type, infox + 10, infoy + 95)
|
|
if topcol.children then
|
|
love.graphics.print("# of children: " .. #topcol.children, infox + 10, infoy + 105)
|
|
else
|
|
love.graphics.print("# of children: 0", infox + 10, infoy + 105)
|
|
end
|
|
if topcol.internals then
|
|
love.graphics.print("# of internals: " .. #topcol.internals, infox + 10, infoy + 115)
|
|
else
|
|
love.graphics.print("# of internals: 0", infox + 10, infoy + 115)
|
|
end
|
|
love.graphics.print("X: " ..topcol.x, infox + 10, infoy + 125)
|
|
love.graphics.print("Y: " ..topcol.y, infox + 10, infoy + 135)
|
|
love.graphics.print("Width: " ..topcol.width, infox + 10, infoy + 145)
|
|
love.graphics.print("Height: " ..topcol.height, infox + 10, infoy + 155)
|
|
end
|
|
|
|
end |