mirror of
https://github.com/edubart/otclient.git
synced 2025-10-14 11:34:54 +02:00
rework on UILineEdit
* allow multiline text editing * rename UILineEdit to UITextEdit
This commit is contained in:
@@ -10,9 +10,9 @@ local enterGameButton
|
||||
|
||||
-- private functions
|
||||
local function clearAccountFields()
|
||||
enterGame:getChildById('accountNameLineEdit'):clearText()
|
||||
enterGame:getChildById('accountPasswordLineEdit'):clearText()
|
||||
enterGame:getChildById('accountNameLineEdit'):focus()
|
||||
enterGame:getChildById('accountNameTextEdit'):clearText()
|
||||
enterGame:getChildById('accountPasswordTextEdit'):clearText()
|
||||
enterGame:getChildById('accountNameTextEdit'):focus()
|
||||
Settings.remove('account')
|
||||
Settings.remove('password')
|
||||
end
|
||||
@@ -71,13 +71,13 @@ function EnterGame.init()
|
||||
local port = Settings.get('port')
|
||||
local autologin = Settings.getBoolean('autologin')
|
||||
|
||||
enterGame:getChildById('accountNameLineEdit'):setText(account)
|
||||
enterGame:getChildById('accountPasswordLineEdit'):setText(password)
|
||||
enterGame:getChildById('serverHostLineEdit'):setText(host)
|
||||
enterGame:getChildById('serverPortLineEdit'):setText(port)
|
||||
enterGame:getChildById('accountNameTextEdit'):setText(account)
|
||||
enterGame:getChildById('accountPasswordTextEdit'):setText(password)
|
||||
enterGame:getChildById('serverHostTextEdit'):setText(host)
|
||||
enterGame:getChildById('serverPortTextEdit'):setText(port)
|
||||
enterGame:getChildById('autoLoginBox'):setChecked(autologin)
|
||||
enterGame:getChildById('rememberPasswordBox'):setChecked(#account > 0)
|
||||
enterGame:getChildById('accountNameLineEdit'):focus()
|
||||
enterGame:getChildById('accountNameTextEdit'):focus()
|
||||
|
||||
-- only open entergame when app starts
|
||||
enterGame:hide()
|
||||
@@ -120,10 +120,10 @@ function EnterGame.openWindow()
|
||||
end
|
||||
|
||||
function EnterGame.doLogin()
|
||||
EnterGame.account = enterGame:getChildById('accountNameLineEdit'):getText()
|
||||
EnterGame.password = enterGame:getChildById('accountPasswordLineEdit'):getText()
|
||||
EnterGame.host = enterGame:getChildById('serverHostLineEdit'):getText()
|
||||
EnterGame.port = tonumber(enterGame:getChildById('serverPortLineEdit'):getText())
|
||||
EnterGame.account = enterGame:getChildById('accountNameTextEdit'):getText()
|
||||
EnterGame.password = enterGame:getChildById('accountPasswordTextEdit'):getText()
|
||||
EnterGame.host = enterGame:getChildById('serverHostTextEdit'):getText()
|
||||
EnterGame.port = tonumber(enterGame:getChildById('serverPortTextEdit'):getText())
|
||||
EnterGame.hide()
|
||||
|
||||
Settings.set('host', EnterGame.host)
|
||||
|
@@ -10,8 +10,8 @@ MainWindow
|
||||
anchors.left: parent.left
|
||||
anchors.top: parent.top
|
||||
|
||||
LineEdit
|
||||
id: accountNameLineEdit
|
||||
TextEdit
|
||||
id: accountNameTextEdit
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.top: prev.bottom
|
||||
@@ -23,8 +23,8 @@ MainWindow
|
||||
anchors.top: prev.bottom
|
||||
margin-top: 8
|
||||
|
||||
PasswordLineEdit
|
||||
id: accountPasswordLineEdit
|
||||
PasswordTextEdit
|
||||
id: accountPasswordTextEdit
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.top: prev.bottom
|
||||
@@ -38,8 +38,8 @@ MainWindow
|
||||
anchors.top: prev.bottom
|
||||
margin-top: 8
|
||||
|
||||
LineEdit
|
||||
id: serverHostLineEdit
|
||||
TextEdit
|
||||
id: serverHostTextEdit
|
||||
tooltip: |-
|
||||
Make sure that your client uses
|
||||
the correct game protocol version
|
||||
@@ -56,8 +56,8 @@ MainWindow
|
||||
anchors.top: serverLabel.top
|
||||
margin-left: 10
|
||||
|
||||
LineEdit
|
||||
id: serverPortLineEdit
|
||||
TextEdit
|
||||
id: serverPortTextEdit
|
||||
text: 7171
|
||||
anchors.left: portLabel.left
|
||||
anchors.right: portLabel.right
|
||||
|
@@ -13,7 +13,7 @@ local terminalWindow
|
||||
local terminalButton
|
||||
local logLocked = false
|
||||
local commandEnv = newenv()
|
||||
local commandLineEdit
|
||||
local commandTextEdit
|
||||
local terminalBuffer
|
||||
local commandHistory = { }
|
||||
local currentHistoryIndex = 0
|
||||
@@ -25,18 +25,18 @@ local function navigateCommand(step)
|
||||
currentHistoryIndex = math.min(math.max(currentHistoryIndex + step, 0), numCommands)
|
||||
if currentHistoryIndex > 0 then
|
||||
local command = commandHistory[numCommands - currentHistoryIndex + 1]
|
||||
commandLineEdit:setText(command)
|
||||
commandTextEdit:setText(command)
|
||||
else
|
||||
commandLineEdit:clearText()
|
||||
commandTextEdit:clearText()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function completeCommand()
|
||||
local cursorPos = commandLineEdit:getCursorPos()
|
||||
local cursorPos = commandTextEdit:getCursorPos()
|
||||
if cursorPos == 0 then return end
|
||||
|
||||
local commandBegin = commandLineEdit:getText():sub(1, cursorPos)
|
||||
local commandBegin = commandTextEdit:getText():sub(1, cursorPos)
|
||||
local possibleCommands = {}
|
||||
|
||||
-- create a list containing all globals
|
||||
@@ -52,7 +52,7 @@ local function completeCommand()
|
||||
|
||||
-- complete command with one match
|
||||
if #possibleCommands == 1 then
|
||||
commandLineEdit:setText(possibleCommands[1])
|
||||
commandTextEdit:setText(possibleCommands[1])
|
||||
-- show command matches
|
||||
elseif #possibleCommands > 0 then
|
||||
print('>> ' .. commandBegin)
|
||||
@@ -75,7 +75,7 @@ local function completeCommand()
|
||||
commandBegin = expandedComplete
|
||||
end
|
||||
end
|
||||
commandLineEdit:setText(commandBegin)
|
||||
commandTextEdit:setText(commandBegin)
|
||||
|
||||
for i,v in ipairs(possibleCommands) do
|
||||
print(v)
|
||||
@@ -84,11 +84,11 @@ local function completeCommand()
|
||||
end
|
||||
|
||||
local function doCommand()
|
||||
local currentCommand = commandLineEdit:getText()
|
||||
local currentCommand = commandTextEdit:getText()
|
||||
Terminal.executeCommand(currentCommand)
|
||||
|
||||
if commandLineEdit then
|
||||
commandLineEdit:clearText()
|
||||
if commandTextEdit then
|
||||
commandTextEdit:clearText()
|
||||
end
|
||||
return true
|
||||
end
|
||||
@@ -133,11 +133,11 @@ function Terminal.init()
|
||||
|
||||
commandHistory = Settings.getList('terminal-history')
|
||||
|
||||
commandLineEdit = terminalWindow:getChildById('commandLineEdit')
|
||||
Keyboard.bindKeyPress('Up', function() navigateCommand(1) end, commandLineEdit)
|
||||
Keyboard.bindKeyPress('Down', function() navigateCommand(-1) end, commandLineEdit)
|
||||
Keyboard.bindKeyDown('Tab', completeCommand, commandLineEdit)
|
||||
Keyboard.bindKeyDown('Enter', doCommand, commandLineEdit)
|
||||
commandTextEdit = terminalWindow:getChildById('commandTextEdit')
|
||||
Keyboard.bindKeyPress('Up', function() navigateCommand(1) end, commandTextEdit)
|
||||
Keyboard.bindKeyPress('Down', function() navigateCommand(-1) end, commandTextEdit)
|
||||
Keyboard.bindKeyDown('Tab', completeCommand, commandTextEdit)
|
||||
Keyboard.bindKeyDown('Enter', doCommand, commandTextEdit)
|
||||
Keyboard.bindKeyDown('Escape', Terminal.hide, terminalWindow)
|
||||
|
||||
terminalBuffer = terminalWindow:getChildById('terminalBuffer')
|
||||
@@ -151,7 +151,7 @@ function Terminal.terminate()
|
||||
g_logger.setOnLog(nil)
|
||||
terminalButton:destroy()
|
||||
terminalButton = nil
|
||||
commandLineEdit = nil
|
||||
commandTextEdit = nil
|
||||
terminalBuffer = nil
|
||||
terminalWindow:destroy()
|
||||
terminalWindow = nil
|
||||
|
@@ -32,8 +32,8 @@ UIWindow
|
||||
font: terminus-14px-bold
|
||||
text: >>
|
||||
|
||||
UILineEdit
|
||||
id: commandLineEdit
|
||||
UITextEdit
|
||||
id: commandTextEdit
|
||||
height: 16
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.left: commandSymbolLabel.right
|
||||
|
@@ -1,4 +1,4 @@
|
||||
UISpinBox = extends(UILineEdit)
|
||||
UISpinBox = extends(UITextEdit)
|
||||
|
||||
function UISpinBox.create()
|
||||
local spinbox = UISpinBox.internalCreate()
|
||||
|
@@ -18,7 +18,7 @@ Module
|
||||
importStyle 'styles/labels.otui'
|
||||
importStyle 'styles/panels.otui'
|
||||
importStyle 'styles/separators.otui'
|
||||
importStyle 'styles/lineedits.otui'
|
||||
importStyle 'styles/textedits.otui'
|
||||
importStyle 'styles/checkboxes.otui'
|
||||
importStyle 'styles/progressbars.otui'
|
||||
importStyle 'styles/tabbars.otui'
|
||||
|
17
modules/core_styles/styles/textedits.otui
Normal file
17
modules/core_styles/styles/textedits.otui
Normal file
@@ -0,0 +1,17 @@
|
||||
TextEdit < UITextEdit
|
||||
font: verdana-11px-antialised
|
||||
color: #aaaaaa
|
||||
size: 86 20
|
||||
text-offset: 0 3
|
||||
text-margin: 3
|
||||
image-source: /core_styles/styles/images/panel_flat.png
|
||||
image-border: 1
|
||||
|
||||
$disabled:
|
||||
color: #aaaaaa88
|
||||
|
||||
PasswordTextEdit < TextEdit
|
||||
text-hidden: true
|
||||
|
||||
MultilineTextEdit < TextEdit
|
||||
multiline: true
|
@@ -31,7 +31,7 @@ MainWindow
|
||||
text-align: center
|
||||
margin-bottom: 2
|
||||
|
||||
LineEdit
|
||||
TextEdit
|
||||
id: openPrivateChannelWith
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
|
@@ -45,7 +45,7 @@ local SayModes = {
|
||||
local consolePanel
|
||||
local consoleContentPanel
|
||||
local consoleTabBar
|
||||
local consoleLineEdit
|
||||
local consoleTextEdit
|
||||
local channels
|
||||
local messageHistory = { }
|
||||
local currentMessageIndex = 0
|
||||
@@ -60,9 +60,9 @@ local function navigateMessageHistory(step)
|
||||
currentMessageIndex = math.min(math.max(currentMessageIndex + step, 0), numCommands)
|
||||
if currentMessageIndex > 0 then
|
||||
local command = messageHistory[numCommands - currentMessageIndex + 1]
|
||||
consoleLineEdit:setText(command)
|
||||
consoleTextEdit:setText(command)
|
||||
else
|
||||
consoleLineEdit:clearText()
|
||||
consoleTextEdit:clearText()
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -159,7 +159,7 @@ function Console.init()
|
||||
onGameEnd = Console.clear })
|
||||
|
||||
consolePanel = displayUI('console.otui', GameInterface.getBottomPanel())
|
||||
consoleLineEdit = consolePanel:getChildById('consoleLineEdit')
|
||||
consoleTextEdit = consolePanel:getChildById('consoleTextEdit')
|
||||
consoleContentPanel = consolePanel:getChildById('consoleContentPanel')
|
||||
consoleTabBar = consolePanel:getChildById('consoleTabBar')
|
||||
consoleTabBar:setContentWidget(consoleContentPanel)
|
||||
@@ -208,7 +208,7 @@ function Console.terminate()
|
||||
|
||||
consolePanel:destroy()
|
||||
consolePanel = nil
|
||||
consoleLineEdit = nil
|
||||
consoleTextEdit = nil
|
||||
consoleContentPanel = nil
|
||||
consoleTabBar = nil
|
||||
|
||||
@@ -233,7 +233,7 @@ function Console.clear()
|
||||
consoleTabBar:removeTab(npcTab)
|
||||
end
|
||||
|
||||
consoleLineEdit:clearText()
|
||||
consoleTextEdit:clearText()
|
||||
|
||||
if channelsWindow then
|
||||
channelsWindow:destroy()
|
||||
@@ -241,8 +241,8 @@ function Console.clear()
|
||||
end
|
||||
end
|
||||
|
||||
function Console.setLineEditText(text)
|
||||
consoleLineEdit:setText(text)
|
||||
function Console.setTextEditText(text)
|
||||
consoleTextEdit:setText(text)
|
||||
end
|
||||
|
||||
function Console.addTab(name, focus)
|
||||
@@ -339,9 +339,9 @@ function Console.addTabText(text, speaktype, tab)
|
||||
end
|
||||
|
||||
function Console.sendCurrentMessage()
|
||||
local message = consoleLineEdit:getText()
|
||||
local message = consoleTextEdit:getText()
|
||||
if #message == 0 then return end
|
||||
consoleLineEdit:clearText()
|
||||
consoleTextEdit:clearText()
|
||||
|
||||
-- get current channel
|
||||
local tab = Console.getCurrentTab()
|
||||
@@ -365,7 +365,7 @@ function Console.sendCurrentMessage()
|
||||
if chatCommandInitial == chatCommandEnd then
|
||||
chatCommandPrivateRepeat = false
|
||||
if chatCommandInitial == "*" then
|
||||
consoleLineEdit:setText('*'.. chatCommandPrivate .. '* ')
|
||||
consoleTextEdit:setText('*'.. chatCommandPrivate .. '* ')
|
||||
end
|
||||
message = chatCommandMessage:trim()
|
||||
chatCommandPrivateReady = true
|
||||
|
@@ -88,7 +88,7 @@ Panel
|
||||
anchors.top: prev.bottom
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: consoleLineEdit.top
|
||||
anchors.bottom: consoleTextEdit.top
|
||||
margin-left: 6
|
||||
margin-right: 6
|
||||
margin-bottom: 4
|
||||
@@ -108,8 +108,8 @@ Panel
|
||||
margin-bottom: 6
|
||||
@onClick: Console.sayModeChange()
|
||||
|
||||
LineEdit
|
||||
id: consoleLineEdit
|
||||
TextEdit
|
||||
id: consoleTextEdit
|
||||
anchors.left: sayModeButton.right
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: parent.bottom
|
||||
|
@@ -290,7 +290,7 @@ function HotkeysManager.call(keyCombo)
|
||||
if hotKey.autoSend then
|
||||
g_game.talk(hotKey.value)
|
||||
else
|
||||
Console.setLineEditText(hotKey.value)
|
||||
Console.setTextEditText(hotKey.value)
|
||||
end
|
||||
elseif hotKey.itemId ~= nil then
|
||||
if hotKey.useType == HOTKEY_MANAGER_USEONSELF then
|
||||
|
@@ -68,7 +68,7 @@ MainWindow
|
||||
anchors.top: prev.bottom
|
||||
margin-top: 20
|
||||
|
||||
LineEdit
|
||||
TextEdit
|
||||
id: hotkeyText
|
||||
enabled: false
|
||||
anchors.left: parent.left
|
||||
|
@@ -10,7 +10,7 @@ MainWindow
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
|
||||
LineEdit
|
||||
TextEdit
|
||||
id: name
|
||||
anchors.top: prev.bottom
|
||||
anchors.left: parent.left
|
||||
|
Reference in New Issue
Block a user