console max lines

This commit is contained in:
Eduardo Bart
2011-08-21 18:49:31 -03:00
parent 4ebb201da2
commit 8007e37796
9 changed files with 32 additions and 20 deletions

View File

@@ -3,6 +3,8 @@ Console = { }
local console
local logLocked = false
local commandEnv = createEnvironment()
local maxLines = 80
local numLines = 0
function Console.onLog(level, message, time)
-- avoid logging while reporting logs (would cause a infinite loop)
@@ -28,12 +30,18 @@ end
function Console.addLine(text, color)
-- create new label
local label = UILabel.create()
label:setStyle('ConsoleLabel')
label:setText(text)
label:setForegroundColor(color)
console:insertChild(label, -1)
numLines = numLines + 1
if numLines > maxLines then
local firstLine = console:getChildByIndex(0)
firstLine:destroy()
end
end
function Console.create()