mirror of
https://github.com/edubart/otclient.git
synced 2025-10-14 19:44:54 +02:00
improved charlist
This commit is contained in:
@@ -8,18 +8,49 @@ function EnterGame_characterWindow_okClicked()
|
||||
Game.loginWorld(account, password, selected.worldHost, selected.worldPort, selected.characterName)
|
||||
charactersWindow:destroy()
|
||||
mainMenu:hide()
|
||||
else
|
||||
displayErrorBox('Error', 'You must select a character to login!')
|
||||
end
|
||||
end
|
||||
|
||||
local function showMotd(motdNumber, motdMessage)
|
||||
if motdNumber ~= Configs.get("motd") then
|
||||
displayInfoBox("Message of the day", motdMessage)
|
||||
Configs.set("motd", motdNumber)
|
||||
end
|
||||
end
|
||||
|
||||
local function createCharactersWindow(characters, premDays)
|
||||
local charactersWindow = UI.loadAndDisplayLocked('/mainmenu/ui/charlist.otui')
|
||||
local charactersList = charactersWindow:getChildById('charactersList')
|
||||
local accountStatusLabel = charactersWindow:getChildById('accountStatusLabel')
|
||||
for i,characterInfo in ipairs(characters) do
|
||||
local characterName = characterInfo[1]
|
||||
local worldName = characterInfo[2]
|
||||
local worldHost = characterInfo[3]
|
||||
local worldIp = characterInfo[4]
|
||||
|
||||
local label = UILabel.create()
|
||||
charactersList:addChild(label)
|
||||
label:setText(characterName .. ' (' .. worldName .. ')')
|
||||
label:setStyle('CharactersListLabel')
|
||||
label.characterName = characterName
|
||||
label.worldHost = worldHost
|
||||
label.worldPort = worldIp
|
||||
end
|
||||
if premDays > 0 then
|
||||
accountStatusLabel:setText("Account Status:\nPremium Account (" .. premDays .. ' days left)')
|
||||
end
|
||||
end
|
||||
|
||||
function EnterGame_connectToLoginServer()
|
||||
local protocolLogin = ProtocolLogin.create()
|
||||
|
||||
local recreateEnterGame = function()
|
||||
UI.loadAndDisplayLocked("/mainmenu/ui/entergamewindow.otui")
|
||||
UI.loadAndDisplayLocked('/mainmenu/ui/entergamewindow.otui')
|
||||
end
|
||||
|
||||
local loadBox = displayCancelBox("Please wait", "Connecting..")
|
||||
local loadBox = displayCancelBox('Please wait', 'Connecting to login server...')
|
||||
|
||||
loadBox.onCancel = function(msgbox)
|
||||
-- cancel protocol and reacreate enter game window
|
||||
@@ -29,43 +60,25 @@ function EnterGame_connectToLoginServer()
|
||||
|
||||
protocolLogin.onError = function(protocol, error)
|
||||
loadBox:destroy()
|
||||
local errorBox = displayErrorBox("Login Error", error)
|
||||
local errorBox = displayErrorBox('Login Error', error)
|
||||
errorBox.onOk = recreateEnterGame
|
||||
end
|
||||
|
||||
protocolLogin.onMotd = function(protocol, motd)
|
||||
loadBox:destroy()
|
||||
local motdNumber = string.sub(motd, 0, string.find(motd, "\n"))
|
||||
local motdText = string.sub(motd, string.find(motd, "\n") + 1, string.len(motd))
|
||||
if motdNumber ~= Configs.get("motd") then
|
||||
displayInfoBox("Message of the day", motdText)
|
||||
Configs.set("motd", motdNumber)
|
||||
end
|
||||
local motdMessage = string.sub(motd, string.find(motd, "\n") + 1, string.len(motd))
|
||||
showMotd(motdNumber, motdMessage)
|
||||
end
|
||||
|
||||
protocolLogin.onCharacterList = function(protocol, characters, premDays)
|
||||
loadBox:destroy()
|
||||
local charactersWindow = UI.loadAndDisplayLocked('/mainmenu/ui/charlist.otui')
|
||||
local charactersList = charactersWindow:getChildById('charactersList')
|
||||
for i,characterInfo in ipairs(characters) do
|
||||
local characterName = characterInfo[1]
|
||||
local worldName = characterInfo[2]
|
||||
local worldHost = characterInfo[3]
|
||||
local worldIp = characterInfo[4]
|
||||
|
||||
local label = UILabel.create()
|
||||
charactersList:addChild(label)
|
||||
label:setText(characterName .. ' (' .. worldName .. ')')
|
||||
label:setStyle('CharactersListLabel')
|
||||
label.characterName = characterName
|
||||
label.worldHost = worldHost
|
||||
label.worldPort = worldIp
|
||||
end
|
||||
createCharactersWindow(characters, premDays)
|
||||
end
|
||||
|
||||
local enterGameWindow = UI.root:getChildById("enterGameWindow")
|
||||
account = enterGameWindow:getChildById("accountNameLineEdit"):getText()
|
||||
password = enterGameWindow:getChildById("accountPasswordLineEdit"):getText()
|
||||
local enterGameWindow = UI.root:getChildById('enterGameWindow')
|
||||
account = enterGameWindow:getChildById('accountNameLineEdit'):getText()
|
||||
password = enterGameWindow:getChildById('accountPasswordLineEdit'):getText()
|
||||
protocolLogin:login(account, password)
|
||||
|
||||
enterGameWindow:destroy()
|
||||
|
@@ -1,7 +1,8 @@
|
||||
CharactersListLabel < Label
|
||||
image: /core_ui/images/empty_rect.png
|
||||
font: helvetica-12px-bold
|
||||
font: tibia-10px-monochrome
|
||||
background-color: #00000000
|
||||
offset: 2 0
|
||||
focusable: true
|
||||
margin.left: 1
|
||||
margin.right: 1
|
||||
@@ -14,16 +15,36 @@ CharactersListLabel < Label
|
||||
MainWindow
|
||||
id: charactersWindow
|
||||
title: Charlist
|
||||
size: 200 250
|
||||
size: 250 250
|
||||
|
||||
TextList
|
||||
id: charactersList
|
||||
anchors.fill: parent
|
||||
anchors.bottom: next.top
|
||||
margin.top: 30
|
||||
margin.bottom: 50
|
||||
margin.bottom: 5
|
||||
margin.left: 16
|
||||
margin.right: 16
|
||||
|
||||
Label
|
||||
text: |-
|
||||
Account Status:
|
||||
Free Account
|
||||
id: accountStatusLabel
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: next.top
|
||||
margin.left: 16
|
||||
margin.bottom: 5
|
||||
|
||||
HorizontalSeparator
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: next.top
|
||||
margin.left: 16
|
||||
margin.right: 16
|
||||
margin.bottom: 10
|
||||
|
||||
Button
|
||||
id: buttonOk
|
||||
text: Ok
|
||||
|
Reference in New Issue
Block a user