mirror of
https://github.com/edubart/otclient.git
synced 2025-10-14 11:34:54 +02:00
lua console and some changes
This commit is contained in:
@@ -6,3 +6,11 @@ AnchorLeft = 3
|
||||
AnchorRight = 4
|
||||
AnchorVerticalCenter = 5
|
||||
AnchorHorizontalCenter = 6
|
||||
|
||||
LogDebug = 0
|
||||
LogInfo = 1
|
||||
LogWarning = 2
|
||||
LogError = 3
|
||||
LogFatal = 4
|
||||
|
||||
EmptyFunction = function() end
|
@@ -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()
|
||||
|
@@ -1,5 +1,7 @@
|
||||
function createEmptyFunction()
|
||||
local emptyFunction = function() end
|
||||
return emptyFunction
|
||||
end
|
||||
|
||||
function print(...)
|
||||
local msg = ""
|
||||
for i,v in ipairs(arg) do
|
||||
msg = msg .. tostring(v) .. "\t"
|
||||
end
|
||||
Logger.log(LogInfo, msg)
|
||||
end
|
@@ -1,19 +1,19 @@
|
||||
function UIWidget:setMargin(...)
|
||||
local params = {...}
|
||||
if #params == 1 then
|
||||
self.marginTop = params[1]
|
||||
self.marginRight = params[1]
|
||||
self.marginBottom = params[1]
|
||||
self.marginLeft = params[1]
|
||||
self:setMarginTop(params[1])
|
||||
self:setMarginRight(params[1])
|
||||
self:setMarginBottom(params[1])
|
||||
self:setMarginLeft(params[1])
|
||||
elseif #params == 2 then
|
||||
self.marginTop = params[1]
|
||||
self.marginRight = params[2]
|
||||
self.marginBottom = params[1]
|
||||
self.marginLeft = params[2]
|
||||
self:setMarginTop(params[1])
|
||||
self:setMarginRight(params[2])
|
||||
self:setMarginBottom(params[1])
|
||||
self:setMarginLeft(params[2])
|
||||
elseif #params == 4 then
|
||||
self.marginTop = params[1]
|
||||
self.marginRight = params[2]
|
||||
self.marginBottom = params[3]
|
||||
self.marginLeft = params[4]
|
||||
self:setMarginTop(params[1])
|
||||
self:setMarginRight(params[2])
|
||||
self:setMarginBottom(params[3])
|
||||
self:setMarginLeft(params[4])
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user