lua console and some changes

This commit is contained in:
Eduardo Bart
2011-08-20 17:30:41 -03:00
parent 033f14780d
commit 38529ea837
70 changed files with 672 additions and 305 deletions

View File

@@ -11,45 +11,48 @@ function MessageBox.create(title, text, flags)
-- create messagebox window
local window = UIWindow.create()
window.id = "messageBoxWindow"
window.title = title
window:setStyle('Window')
window:setId("messageBoxWindow")
window:setTitle(title)
window:centerIn("parent")
rootWidget:addChild(window)
window:lock()
rootWidget:lockChild(window)
-- create messagebox label
local label = UILabel.create()
label.id = "messageBoxLabel"
label.text = text
label:addAnchor(AnchorHorizontalCenter, window.id, AnchorHorizontalCenter)
label:addAnchor(AnchorTop, window.id, AnchorTop)
label:setStyle('Label')
label:setId("messageBoxLabel")
label:setText(text)
label:addAnchor(AnchorHorizontalCenter, window:getId(), AnchorHorizontalCenter)
label:addAnchor(AnchorTop, window:getId(), AnchorTop)
label:setMargin(27, 0)
label:resizeToText()
window:addChild(label)
-- set window size based on label size
window.width = label.width + 60
window.height = label.height + 64
window:setWidth(label:getWidth() + 60)
window:setHeight(label:getHeight() + 64)
-- setup messagebox first button
local button1 = UIButton.create()
button1.id = "messageBoxButton1"
button1:addAnchor(AnchorBottom, window.id, AnchorBottom)
button1:addAnchor(AnchorRight, window.id, AnchorRight)
button1:setStyle('Button')
button1:setId("messageBoxButton1")
button1:addAnchor(AnchorBottom, window:getId(), AnchorBottom)
button1:addAnchor(AnchorRight, window:getId(), AnchorRight)
button1:setMargin(10)
button1.width = 64
button1:setWidth(64)
window:addChild(button1)
if flags == MessageBoxOk then
button1.text = "Ok"
box.onOk = createEmptyFunction()
button1:setText("Ok")
box.onOk = EmptyFunction
button1.onClick = function()
box.onOk()
box:destroy()
end
elseif flags == MessageBoxCancel then
button1.text = "Cancel"
box.onCancel = createEmptyFunction()
button1:setText("Cancel")
box.onCancel = EmptyFunction
button1.onClick = function()
box.onCancel()
box:destroy()