mirror of
https://github.com/edubart/otclient.git
synced 2025-11-30 07:26:49 +01:00
add ui padding
This commit is contained in:
@@ -2,4 +2,9 @@ function dumpWidgets()
|
||||
for i=1,rootWidget:getChildCount() do
|
||||
print(rootWidget:getChildByIndex(i):getId())
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function drawDebugBoxes(enable)
|
||||
if enable == nil then enable = true end
|
||||
g_ui.setDebugBoxesDrawing(enable)
|
||||
end
|
||||
|
||||
@@ -82,29 +82,11 @@ local function completeCommand()
|
||||
end
|
||||
end
|
||||
|
||||
local function onCommandLineKeyPress(widget, keyCode, keyText, keyboardModifiers)
|
||||
if keyboardModifiers == KeyboardNoModifier then
|
||||
-- execute current command
|
||||
if keyCode == KeyReturn or keyCode == KeyEnter then
|
||||
local currentCommand = commandLineEdit:getText()
|
||||
Terminal.executeCommand(currentCommand)
|
||||
commandLineEdit:clearText()
|
||||
return true
|
||||
-- navigate history up
|
||||
elseif keyCode == KeyUp then
|
||||
navigateCommand(1)
|
||||
return true
|
||||
-- navigate history down
|
||||
elseif keyCode == KeyDown then
|
||||
navigateCommand(-1)
|
||||
return true
|
||||
-- complete command
|
||||
elseif keyCode == KeyTab then
|
||||
completeCommand()
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
local function doCommand()
|
||||
local currentCommand = commandLineEdit:getText()
|
||||
Terminal.executeCommand(currentCommand)
|
||||
commandLineEdit:clearText()
|
||||
return true
|
||||
end
|
||||
|
||||
local function onLog(level, message, time)
|
||||
@@ -128,7 +110,11 @@ function Terminal.init()
|
||||
Hotkeys.bind('Ctrl+T', Terminal.toggle)
|
||||
|
||||
commandLineEdit = terminalWidget:getChildById('commandLineEdit')
|
||||
connect(commandLineEdit, { onKeyPress = onCommandLineKeyPress })
|
||||
Hotkeys.bind('Up', function() navigateCommand(1) end, commandLineEdit)
|
||||
Hotkeys.bind('Down', function() navigateCommand(-1) end, commandLineEdit)
|
||||
Hotkeys.bind('Tab', completeCommand, commandLineEdit)
|
||||
Hotkeys.bind('Enter', doCommand, commandLineEdit)
|
||||
Hotkeys.bind('Return', doCommand, commandLineEdit)
|
||||
|
||||
terminalBuffer = terminalWidget:getChildById('terminalBuffer')
|
||||
Logger.setOnLog(onLog)
|
||||
@@ -171,7 +157,7 @@ function Terminal.addLine(text, color)
|
||||
local label = createWidget('TerminalLabel', terminalBuffer)
|
||||
label:setId('terminalLabel' .. numLines)
|
||||
label:setText(text)
|
||||
label:setForegroundColor(color)
|
||||
label:setColor(color)
|
||||
|
||||
-- delete old lines if needed
|
||||
if numLines > MaxLogLines then
|
||||
@@ -182,6 +168,7 @@ function Terminal.addLine(text, color)
|
||||
end
|
||||
|
||||
function Terminal.executeCommand(command)
|
||||
if command == nil or #command == 0 then return end
|
||||
-- detect and convert commands with simple syntax
|
||||
local realCommand
|
||||
if commandEnv[command] then
|
||||
|
||||
@@ -41,7 +41,7 @@ function Console.addText(text, color)
|
||||
|
||||
local label = createWidget('ConsoleLabel', consoleBuffer)
|
||||
label:setText(text)
|
||||
label:setForegroundColor(color)
|
||||
label:setColor(color)
|
||||
end
|
||||
|
||||
-- hooked events
|
||||
|
||||
@@ -17,10 +17,10 @@ SkillValueLabel < GameLabel
|
||||
id: value
|
||||
font: verdana-11px-monochrome
|
||||
text-align: topright
|
||||
width: 64
|
||||
anchors.right: parent.right
|
||||
anchors.top: parent.top
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.left: prev.left
|
||||
|
||||
SkillPercentPanel < UIProgressBar
|
||||
id: percent
|
||||
|
||||
@@ -46,7 +46,7 @@ local function displayMessage(msgtype, msg, time)
|
||||
label:setVisible(true)
|
||||
label:setText(msg)
|
||||
label:setStyle(style)
|
||||
label:setForegroundColor(msgtype.color)
|
||||
label:setColor(msgtype.color)
|
||||
|
||||
if not time then
|
||||
time = math.max(#msg * 75, 3000)
|
||||
|
||||
@@ -37,9 +37,9 @@ function Game.onAddVip(id, name, online)
|
||||
label:setText(name)
|
||||
|
||||
if online then
|
||||
label:setForegroundColor('#00ff00')
|
||||
label:setColor('#00ff00')
|
||||
else
|
||||
label:setForegroundColor('#ff0000')
|
||||
label:setColor('#ff0000')
|
||||
end
|
||||
|
||||
label.vipOnline = online
|
||||
@@ -50,9 +50,9 @@ function Game.onVipStateChange(id, online)
|
||||
local label = vipList:getChildById('vip' .. id)
|
||||
|
||||
if online then
|
||||
label:setForegroundColor('#00ff00')
|
||||
label:setColor('#00ff00')
|
||||
else
|
||||
label:setForegroundColor('#ff0000')
|
||||
label:setColor('#ff0000')
|
||||
end
|
||||
|
||||
label.vipOnline = online
|
||||
|
||||
Reference in New Issue
Block a user