2013-02-11 21:15:40 +00:00
|
|
|
--[[------------------------------------------------
|
|
|
|
-- Love Frames - A GUI library for LOVE --
|
2014-01-14 11:29:11 +00:00
|
|
|
-- Copyright (c) 2012-2014 Kenny Shields --
|
2013-02-11 21:15:40 +00:00
|
|
|
--]]------------------------------------------------
|
|
|
|
|
2014-10-23 22:36:16 +00:00
|
|
|
-- get the current require path
|
|
|
|
local path = string.sub(..., 1, string.len(...) - string.len(".debug"))
|
|
|
|
local loveframes = require(path .. ".common")
|
|
|
|
|
2013-02-11 21:15:40 +00:00
|
|
|
-- debug library
|
|
|
|
loveframes.debug = {}
|
|
|
|
|
|
|
|
--[[---------------------------------------------------------
|
|
|
|
- func: draw()
|
|
|
|
- desc: draws debug information
|
|
|
|
--]]---------------------------------------------------------
|
|
|
|
function loveframes.debug.draw()
|
|
|
|
|
|
|
|
-- do not draw anthing if debug is off
|
2013-08-15 02:09:22 +00:00
|
|
|
local debug = loveframes.config["DEBUG"]
|
2013-02-11 21:15:40 +00:00
|
|
|
if not debug then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2013-08-15 02:09:22 +00:00
|
|
|
local infox = 5
|
|
|
|
local infoy = 40
|
2013-11-22 17:00:06 +00:00
|
|
|
local topcol = {type = "None", children = {}, x = 0, y = 0, width = 0, height = 0}
|
|
|
|
local hoverobject = loveframes.hoverobject
|
|
|
|
--local objects = loveframes.util.GetAllObjects()
|
2013-08-15 19:28:18 +00:00
|
|
|
local version = loveframes.version
|
|
|
|
local stage = loveframes.stage
|
2013-02-11 21:15:40 +00:00
|
|
|
local basedir = loveframes.config["DIRECTORY"]
|
|
|
|
local loveversion = love._version
|
|
|
|
local fps = love.timer.getFPS()
|
|
|
|
local deltatime = love.timer.getDelta()
|
2013-08-12 13:48:51 +00:00
|
|
|
local font = loveframes.basicfontsmall
|
2013-02-11 21:15:40 +00:00
|
|
|
|
2013-11-22 17:00:06 +00:00
|
|
|
if hoverobject then
|
|
|
|
topcol = hoverobject
|
2013-02-11 21:15:40 +00:00
|
|
|
end
|
|
|
|
|
2013-08-15 02:09:22 +00:00
|
|
|
-- show frame docking zones
|
2013-08-12 13:48:51 +00:00
|
|
|
if topcol.type == "frame" then
|
|
|
|
for k, v in pairs(topcol.dockzones) do
|
|
|
|
love.graphics.setLineWidth(1)
|
2018-04-15 01:23:26 +00:00
|
|
|
love.graphics.setColor(255/255, 0, 0, 100/255)
|
2013-08-12 13:48:51 +00:00
|
|
|
love.graphics.rectangle("fill", v.x, v.y, v.width, v.height)
|
2018-04-15 01:23:26 +00:00
|
|
|
love.graphics.setColor(255/255, 0, 0, 255/255)
|
2013-08-12 13:48:51 +00:00
|
|
|
love.graphics.rectangle("line", v.x, v.y, v.width, v.height)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-02-11 21:15:40 +00:00
|
|
|
-- outline the object that the mouse is hovering over
|
2018-04-15 01:23:26 +00:00
|
|
|
love.graphics.setColor(255/255, 204/255, 51/255, 255/255)
|
2013-08-12 13:48:51 +00:00
|
|
|
love.graphics.setLineWidth(2)
|
2013-02-11 21:15:40 +00:00
|
|
|
love.graphics.rectangle("line", topcol.x - 1, topcol.y - 1, topcol.width + 2, topcol.height + 2)
|
|
|
|
|
2013-08-15 02:09:22 +00:00
|
|
|
-- draw main debug box
|
|
|
|
love.graphics.setFont(font)
|
2018-04-15 01:23:26 +00:00
|
|
|
love.graphics.setColor(0, 0, 0, 200/255)
|
2013-08-15 02:09:22 +00:00
|
|
|
love.graphics.rectangle("fill", infox, infoy, 200, 70)
|
2018-04-15 01:23:26 +00:00
|
|
|
love.graphics.setColor(255/255, 0, 0, 255/255)
|
2013-08-15 02:09:22 +00:00
|
|
|
love.graphics.print("Love Frames - Debug (" ..version.. " - " ..stage.. ")", infox + 5, infoy + 5)
|
2018-04-15 01:23:26 +00:00
|
|
|
love.graphics.setColor(255/255, 255/255, 255/255, 255/255)
|
2013-08-15 02:09:22 +00:00
|
|
|
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)
|
2013-11-22 17:00:06 +00:00
|
|
|
love.graphics.print("Total Objects: " ..loveframes.objectcount, infox + 10, infoy + 50)
|
2013-08-15 02:09:22 +00:00
|
|
|
|
|
|
|
-- draw object information if needed
|
2013-11-22 17:00:06 +00:00
|
|
|
if topcol.type ~= "base" then
|
2018-04-15 01:23:26 +00:00
|
|
|
love.graphics.setColor(0, 0, 0, 200/255)
|
2013-08-15 02:09:22 +00:00
|
|
|
love.graphics.rectangle("fill", infox, infoy + 75, 200, 100)
|
2018-04-15 01:23:26 +00:00
|
|
|
love.graphics.setColor(255/255, 0, 0, 255/255)
|
2013-08-15 02:09:22 +00:00
|
|
|
love.graphics.print("Object Information", infox + 5, infoy + 80)
|
2018-04-15 01:23:26 +00:00
|
|
|
love.graphics.setColor(255/255, 255/255, 255/255, 255/255)
|
2013-08-15 02:09:22 +00:00
|
|
|
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)
|
2013-02-11 21:15:40 +00:00
|
|
|
end
|
|
|
|
|
2013-09-07 04:35:22 +00:00
|
|
|
end
|