fix some login phases issues

This commit is contained in:
Eduardo Bart 2011-11-01 23:55:36 -02:00
parent d2e8e1d774
commit 2304ff3529
5 changed files with 31 additions and 31 deletions

View File

@ -86,14 +86,17 @@ function CharacterList.create(characters, premDays)
end
function CharacterList.hide()
charactersWindow:unlock()
charactersWindow:hide()
end
function CharacterList.close()
CharacterList.hide()
EnterGame.show()
end
function CharacterList.show()
if not loadBox then
charactersWindow:show()
charactersWindow:lock()
end
end

View File

@ -1,10 +1,10 @@
EnterGame = { }
-- private variables
local password
local loadBox
local enterGameWindow
local hideCharlist = false
local motdNumber
local motdMessage
-- private functions
local function onError(protocol, error)
@ -14,31 +14,33 @@ local function onError(protocol, error)
end
local function onMotd(protocol, motd)
loadBox:destroy()
local motdNumber = tonumber(string.sub(motd, 0, string.find(motd, "\n")))
local motdMessage = string.sub(motd, string.find(motd, "\n") + 1, string.len(motd))
local lastMotdNumber = tonumber(Configs.get("motd"))
if motdNumber ~= lastMotdNumber then
hideCharlist = true
local motdBox = displayInfoBox("Message of the day", motdMessage)
motdBox.onOk = function()
CharacterList.show()
end
Configs.set("motd", motdNumber)
end
motdNumber = tonumber(string.sub(motd, 0, string.find(motd, "\n")))
motdMessage = string.sub(motd, string.find(motd, "\n") + 1, string.len(motd))
end
local function onCharacterList(protocol, characters, premDays)
loadBox:destroy()
CharacterList.create(characters, premDays)
if hideCharlist then
local lastMotdNumber = tonumber(Configs.get("motd"))
if motdNumber and motdNumber ~= lastMotdNumber then
Configs.set("motd", motdNumber)
local motdBox = displayInfoBox("Message of the day", motdMessage)
motdBox.onOk = CharacterList.show
CharacterList.hide()
hideCharlist = false
end
end
-- public functions
function EnterGame.create()
function EnterGame.show()
if not enterGameWindow then
enterGameWindow = UI.loadAndDisplay('/mainmenu/ui/entergamewindow.otui')
end
enterGameWindow:show()
end
function EnterGame.hide()
enterGameWindow:hide()
end
function EnterGame.destroy()
@ -49,7 +51,7 @@ end
function EnterGame.doLogin()
EnterGame.account = enterGameWindow:getChildById('accountNameLineEdit'):getText()
EnterGame.password = enterGameWindow:getChildById('accountPasswordLineEdit'):getText()
EnterGame.destroy()
EnterGame.hide()
local protocolLogin = ProtocolLogin.create()
protocolLogin.onError = onError
@ -59,7 +61,7 @@ function EnterGame.doLogin()
loadBox = displayCancelBox('Please wait', 'Connecting to login server...')
loadBox.onCancel = function(msgbox)
protocolLogin:cancelLogin()
EnterGame.create()
EnterGame.show()
end
protocolLogin:login(EnterGame.account, EnterGame.password)

View File

@ -16,7 +16,7 @@ Module
if not initialized then
MainMenu.create()
EnterGame.create()
EnterGame.show()
initialized = true
end
return true

View File

@ -17,7 +17,7 @@ MainWindow
title: Charlist
size: 250 250
onEnter: CharacterList.doLogin()
onEscape: CharacterList.hide()
onEscape: CharacterList.close()
TextList
id: characterList
@ -65,9 +65,4 @@ MainWindow
anchors.bottom: parent.bottom
margin.bottom: 16
margin.right: 16
onClick: |
function(self)
self:getParent():unlock()
self:getParent():hide()
EnterGame.create()
end
onClick: CharacterList.close()

View File

@ -444,7 +444,7 @@ void UIWidget::focusPreviousChild(Fw::FocusReason reason)
{
UIWidgetPtr toFocus;
UIWidgetList rotatedChildren(m_children);
std::reverse(m_children.begin(), m_children.end());
std::reverse(rotatedChildren.begin(), rotatedChildren.end());
if(m_focusedChild) {
auto focusedIt = std::find(rotatedChildren.begin(), rotatedChildren.end(), m_focusedChild);