improved charlist
This commit is contained in:
parent
c60b677baa
commit
0749e6a9d5
|
@ -19,7 +19,7 @@ function MessageBox.create(title, text, flags)
|
||||||
label:resizeToText()
|
label:resizeToText()
|
||||||
|
|
||||||
-- set window size based on label size
|
-- set window size based on label size
|
||||||
window:setWidth(label:getWidth() + 60)
|
window:setWidth(label:getWidth() + 48)
|
||||||
window:setHeight(label:getHeight() + 64)
|
window:setHeight(label:getHeight() + 64)
|
||||||
window:updateParentLayout()
|
window:updateParentLayout()
|
||||||
|
|
||||||
|
|
|
@ -8,45 +8,22 @@ function EnterGame_characterWindow_okClicked()
|
||||||
Game.loginWorld(account, password, selected.worldHost, selected.worldPort, selected.characterName)
|
Game.loginWorld(account, password, selected.worldHost, selected.worldPort, selected.characterName)
|
||||||
charactersWindow:destroy()
|
charactersWindow:destroy()
|
||||||
mainMenu:hide()
|
mainMenu:hide()
|
||||||
|
else
|
||||||
|
displayErrorBox('Error', 'You must select a character to login!')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function showMotd(motdNumber, motdMessage)
|
||||||
function EnterGame_connectToLoginServer()
|
|
||||||
local protocolLogin = ProtocolLogin.create()
|
|
||||||
|
|
||||||
local recreateEnterGame = function()
|
|
||||||
UI.loadAndDisplayLocked("/mainmenu/ui/entergamewindow.otui")
|
|
||||||
end
|
|
||||||
|
|
||||||
local loadBox = displayCancelBox("Please wait", "Connecting..")
|
|
||||||
|
|
||||||
loadBox.onCancel = function(msgbox)
|
|
||||||
-- cancel protocol and reacreate enter game window
|
|
||||||
protocolLogin:cancelLogin()
|
|
||||||
recreateEnterGame()
|
|
||||||
end
|
|
||||||
|
|
||||||
protocolLogin.onError = function(protocol, error)
|
|
||||||
loadBox:destroy()
|
|
||||||
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
|
if motdNumber ~= Configs.get("motd") then
|
||||||
displayInfoBox("Message of the day", motdText)
|
displayInfoBox("Message of the day", motdMessage)
|
||||||
Configs.set("motd", motdNumber)
|
Configs.set("motd", motdNumber)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
protocolLogin.onCharacterList = function(protocol, characters, premDays)
|
local function createCharactersWindow(characters, premDays)
|
||||||
loadBox:destroy()
|
|
||||||
local charactersWindow = UI.loadAndDisplayLocked('/mainmenu/ui/charlist.otui')
|
local charactersWindow = UI.loadAndDisplayLocked('/mainmenu/ui/charlist.otui')
|
||||||
local charactersList = charactersWindow:getChildById('charactersList')
|
local charactersList = charactersWindow:getChildById('charactersList')
|
||||||
|
local accountStatusLabel = charactersWindow:getChildById('accountStatusLabel')
|
||||||
for i,characterInfo in ipairs(characters) do
|
for i,characterInfo in ipairs(characters) do
|
||||||
local characterName = characterInfo[1]
|
local characterName = characterInfo[1]
|
||||||
local worldName = characterInfo[2]
|
local worldName = characterInfo[2]
|
||||||
|
@ -61,11 +38,47 @@ function EnterGame_connectToLoginServer()
|
||||||
label.worldHost = worldHost
|
label.worldHost = worldHost
|
||||||
label.worldPort = worldIp
|
label.worldPort = worldIp
|
||||||
end
|
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')
|
||||||
end
|
end
|
||||||
|
|
||||||
local enterGameWindow = UI.root:getChildById("enterGameWindow")
|
local loadBox = displayCancelBox('Please wait', 'Connecting to login server...')
|
||||||
account = enterGameWindow:getChildById("accountNameLineEdit"):getText()
|
|
||||||
password = enterGameWindow:getChildById("accountPasswordLineEdit"):getText()
|
loadBox.onCancel = function(msgbox)
|
||||||
|
-- cancel protocol and reacreate enter game window
|
||||||
|
protocolLogin:cancelLogin()
|
||||||
|
recreateEnterGame()
|
||||||
|
end
|
||||||
|
|
||||||
|
protocolLogin.onError = function(protocol, error)
|
||||||
|
loadBox:destroy()
|
||||||
|
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 motdMessage = string.sub(motd, string.find(motd, "\n") + 1, string.len(motd))
|
||||||
|
showMotd(motdNumber, motdMessage)
|
||||||
|
end
|
||||||
|
|
||||||
|
protocolLogin.onCharacterList = function(protocol, characters, premDays)
|
||||||
|
loadBox:destroy()
|
||||||
|
createCharactersWindow(characters, premDays)
|
||||||
|
end
|
||||||
|
|
||||||
|
local enterGameWindow = UI.root:getChildById('enterGameWindow')
|
||||||
|
account = enterGameWindow:getChildById('accountNameLineEdit'):getText()
|
||||||
|
password = enterGameWindow:getChildById('accountPasswordLineEdit'):getText()
|
||||||
protocolLogin:login(account, password)
|
protocolLogin:login(account, password)
|
||||||
|
|
||||||
enterGameWindow:destroy()
|
enterGameWindow:destroy()
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
CharactersListLabel < Label
|
CharactersListLabel < Label
|
||||||
image: /core_ui/images/empty_rect.png
|
image: /core_ui/images/empty_rect.png
|
||||||
font: helvetica-12px-bold
|
font: tibia-10px-monochrome
|
||||||
background-color: #00000000
|
background-color: #00000000
|
||||||
|
offset: 2 0
|
||||||
focusable: true
|
focusable: true
|
||||||
margin.left: 1
|
margin.left: 1
|
||||||
margin.right: 1
|
margin.right: 1
|
||||||
|
@ -14,16 +15,36 @@ CharactersListLabel < Label
|
||||||
MainWindow
|
MainWindow
|
||||||
id: charactersWindow
|
id: charactersWindow
|
||||||
title: Charlist
|
title: Charlist
|
||||||
size: 200 250
|
size: 250 250
|
||||||
|
|
||||||
TextList
|
TextList
|
||||||
id: charactersList
|
id: charactersList
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
anchors.bottom: next.top
|
||||||
margin.top: 30
|
margin.top: 30
|
||||||
margin.bottom: 50
|
margin.bottom: 5
|
||||||
margin.left: 16
|
margin.left: 16
|
||||||
margin.right: 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
|
Button
|
||||||
id: buttonOk
|
id: buttonOk
|
||||||
text: Ok
|
text: Ok
|
||||||
|
|
|
@ -12,7 +12,9 @@ void UILabel::setup()
|
||||||
void UILabel::render()
|
void UILabel::render()
|
||||||
{
|
{
|
||||||
UIWidget::render();
|
UIWidget::render();
|
||||||
m_font->renderText(m_text, m_rect, m_align, m_foregroundColor);
|
Rect textRect = m_rect;
|
||||||
|
textRect.setTopLeft(textRect.topLeft() + m_offset);
|
||||||
|
m_font->renderText(m_text, textRect, m_align, m_foregroundColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UILabel::setText(const std::string& text)
|
void UILabel::setText(const std::string& text)
|
||||||
|
@ -43,5 +45,8 @@ void UILabel::onStyleApply(const OTMLNodePtr& styleNode)
|
||||||
setText(node->value());
|
setText(node->value());
|
||||||
else if(node->tag() == "align")
|
else if(node->tag() == "align")
|
||||||
setAlign(fw::translateAlignment(node->value()));
|
setAlign(fw::translateAlignment(node->value()));
|
||||||
|
else if(node->tag() == "offset") {
|
||||||
|
setOffset(node->value<Point>());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,15 +13,18 @@ public:
|
||||||
|
|
||||||
void setText(const std::string& text);
|
void setText(const std::string& text);
|
||||||
void setAlign(AlignmentFlag align) { m_align = align; }
|
void setAlign(AlignmentFlag align) { m_align = align; }
|
||||||
|
void setOffset(const Point& offset) { m_offset = offset; }
|
||||||
|
|
||||||
std::string getText() const { return m_text; }
|
std::string getText() const { return m_text; }
|
||||||
AlignmentFlag getAlign() const { return m_align; }
|
AlignmentFlag getAlign() const { return m_align; }
|
||||||
|
Point getOffset() const { return m_offset; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void onStyleApply(const OTMLNodePtr& styleNode);
|
virtual void onStyleApply(const OTMLNodePtr& styleNode);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string m_text;
|
std::string m_text;
|
||||||
|
Point m_offset;
|
||||||
AlignmentFlag m_align;
|
AlignmentFlag m_align;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue