diff options
author | chai <chaifix@163.com> | 2018-05-19 09:40:17 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2018-05-19 09:40:17 +0800 |
commit | 3ce3b10167a98f45614408a8042a10c686f3a9cc (patch) | |
tree | 136603c06ffaf2f36cf9d8f17b811316f8f65609 /src/script/embed/debug.lua | |
parent | 6ed3819f1a859ffc350c4aaad132f164478f5d79 (diff) |
格式化代码
Diffstat (limited to 'src/script/embed/debug.lua')
-rw-r--r-- | src/script/embed/debug.lua | 72 |
1 files changed, 36 insertions, 36 deletions
diff --git a/src/script/embed/debug.lua b/src/script/embed/debug.lua index fbf0967..76f59ed 100644 --- a/src/script/embed/debug.lua +++ b/src/script/embed/debug.lua @@ -31,27 +31,27 @@ local refresh = true function jin.debug.init() debug = true - panel = jin.graphics.Canvas(jin.graphics.size()) + panel = jin.graphics.Canvas(jin.graphics.size()) end -- set buffer size function jin.debug.size(c) - bsize = c + bsize = c end function jin.debug.print(msg) - if not debug then return end - - msg = tostring(msg) - local tp = type(msg) - if tp ~= "string" and tp ~= "number" then - msg = string.format("print failed, expect string or number but get a %s", tp) - end - + if not debug then return end + + msg = tostring(msg) + local tp = type(msg) + if tp ~= "string" and tp ~= "number" then + msg = string.format("print failed, expect string or number but get a %s", tp) + end + -- remove the first one (old msg) - if #buffer >= bsize then - table.remove(buffer, 1) - end + if #buffer >= bsize then + table.remove(buffer, 1) + end buffer[#buffer + 1] = msg refresh = true @@ -59,33 +59,33 @@ end -- clear debug buffer function jin.debug.clear() - buffer = {} + buffer = {} end local function getStrHeight(str, lheight) - local h = lheight - if #str == 0 then - h = 0 - end - for i = 1, #str do - local c = string.sub(str, i, i) - if c == '\n' then - h = h + lheight - end - end - return h + local h = lheight + if #str == 0 then + h = 0 + end + for i = 1, #str do + local c = string.sub(str, i, i) + if c == '\n' then + h = h + lheight + end + end + return h end local function getBgQuad() - local width, height = 0, 0 - for i = 1, #buffer do - local w, h = jin.graphics.box( buffer[i], fsize, 1, lheight) - height = height + h - if width < w then - width = w - end - end - return width, height + local width, height = 0, 0 + for i = 1, #buffer do + local w, h = jin.graphics.box( buffer[i], fsize, 1, lheight) + height = height + h + if width < w then + width = w + end + end + return width, height end -- render to screen @@ -113,7 +113,7 @@ function jin.debug.render() y = y - h jin.graphics.write(msg, margin / 2, y - margin/ 2, fsize, 1, lheight) end - + jin.graphics.bind() refresh = false @@ -124,5 +124,5 @@ function jin.debug.render() end function jin.debug.status() - return debug + return debug end |