aboutsummaryrefslogtreecommitdiff
path: root/src/script/embed/debug.lua.h
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2018-05-19 12:05:57 +0800
committerchai <chaifix@163.com>2018-05-19 12:05:57 +0800
commitadfda73e1810973a40b7bedd9a8edc3e7ab89e3c (patch)
tree3ee6b9ad4f3c71b5cefc719c694e7a80f3df7088 /src/script/embed/debug.lua.h
parent3ce3b10167a98f45614408a8042a10c686f3a9cc (diff)
增加子系统基类
Diffstat (limited to 'src/script/embed/debug.lua.h')
-rw-r--r--src/script/embed/debug.lua.h72
1 files changed, 36 insertions, 36 deletions
diff --git a/src/script/embed/debug.lua.h b/src/script/embed/debug.lua.h
index 7ccc99d..79c95ba 100644
--- a/src/script/embed/debug.lua.h
+++ b/src/script/embed/debug.lua.h
@@ -33,27 +33,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
@@ -61,33 +61,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
@@ -115,7 +115,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
@@ -126,7 +126,7 @@ function jin.debug.render()
end
function jin.debug.status()
- return debug
+ return debug
end
)"; \ No newline at end of file