diff --git a/modules/mainmenu/characterlist.lua b/modules/mainmenu/characterlist.lua index 6eaf367e..7c3392e3 100644 --- a/modules/mainmenu/characterlist.lua +++ b/modules/mainmenu/characterlist.lua @@ -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 diff --git a/modules/mainmenu/entergame.lua b/modules/mainmenu/entergame.lua index 9791266c..d7f6c18a 100644 --- a/modules/mainmenu/entergame.lua +++ b/modules/mainmenu/entergame.lua @@ -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() - enterGameWindow = UI.loadAndDisplay('/mainmenu/ui/entergamewindow.otui') +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) diff --git a/modules/mainmenu/mainmenu.otmod b/modules/mainmenu/mainmenu.otmod index 72e87011..6e33983e 100644 --- a/modules/mainmenu/mainmenu.otmod +++ b/modules/mainmenu/mainmenu.otmod @@ -16,7 +16,7 @@ Module if not initialized then MainMenu.create() - EnterGame.create() + EnterGame.show() initialized = true end return true diff --git a/modules/mainmenu/ui/charlist.otui b/modules/mainmenu/ui/charlist.otui index 7825b7c5..c5c624a4 100644 --- a/modules/mainmenu/ui/charlist.otui +++ b/modules/mainmenu/ui/charlist.otui @@ -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 \ No newline at end of file + onClick: CharacterList.close() \ No newline at end of file diff --git a/src/framework/ui/uiwidget.cpp b/src/framework/ui/uiwidget.cpp index c46aeca9..cc8a308d 100644 --- a/src/framework/ui/uiwidget.cpp +++ b/src/framework/ui/uiwidget.cpp @@ -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);