From 112d584b66a8a6d518e341b89c62eb7406d816a7 Mon Sep 17 00:00:00 2001 From: Eduardo Bart Date: Thu, 23 Aug 2012 14:45:39 -0300 Subject: [PATCH] Allow to set default server in entergame --- modules/client_entergame/entergame.lua | 23 ++++++++++++++++++++++- modules/client_locales/locales.lua | 8 ++++++-- modules/corelib/ui/uitable.lua | 7 +++++-- 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/modules/client_entergame/entergame.lua b/modules/client_entergame/entergame.lua index 182b4993..40e2da1e 100644 --- a/modules/client_entergame/entergame.lua +++ b/modules/client_entergame/entergame.lua @@ -105,7 +105,7 @@ function EnterGame.firstShow() local host = g_settings.get('host') local autologin = g_settings.getBoolean('autologin') if #host > 0 and #password > 0 and #account > 0 and autologin then - addEvent(EnterGame.doLogin) + autoLogiEvent = addEvent(EnterGame.doLogin) end end @@ -148,6 +148,7 @@ function EnterGame.clearAccountFields() end function EnterGame.doLogin() + autoLogiEvent = nil G.account = enterGame:getChildById('accountNameTextEdit'):getText() G.password = enterGame:getChildById('accountPasswordTextEdit'):getText() G.host = enterGame:getChildById('serverHostTextEdit'):getText() @@ -192,6 +193,26 @@ function EnterGame.displayMotd() displayInfoBox(tr('Message of the day'), G.motdMessage) end +function EnterGame.setDefaultServer(host, port, protocol) + local hostTextEdit = enterGame:getChildById('serverHostTextEdit') + local portTextEdit = enterGame:getChildById('serverPortTextEdit') + local protocolLabel = enterGame:getChildById('protocolLabel') + local accountTextEdit = enterGame:getChildById('accountNameTextEdit') + local passwordTextEdit = enterGame:getChildById('accountPasswordTextEdit') + + if hostTextEdit:getText() ~= host then + hostTextEdit:setText(host) + portTextEdit:setText(port) + protocolBox:setCurrentOption(protocol) + accountTextEdit:setText('') + passwordTextEdit:setText('') + + if autoLogiEvent then + autoLogiEvent:cancel() + end + end +end + function EnterGame.setUniqueServer(host, port, protocol, windowWidth, windowHeight) local hostTextEdit = enterGame:getChildById('serverHostTextEdit') hostTextEdit:setText(host) diff --git a/modules/client_locales/locales.lua b/modules/client_locales/locales.lua index 8e34d65b..242ec67b 100644 --- a/modules/client_locales/locales.lua +++ b/modules/client_locales/locales.lua @@ -70,8 +70,12 @@ end function Locales.terminate() installedLocales = nil currentLocale = nil - localeComboBox:destroy() - localeComboBox = nil + + if localeComboBox then + localeComboBox:destroy() + localeComboBox = nil + end + Extended.unregister(ExtendedLocales) disconnect(g_game, { onGameStart = onGameStart }) end diff --git a/modules/corelib/ui/uitable.lua b/modules/corelib/ui/uitable.lua index 098bd091..8747d192 100644 --- a/modules/corelib/ui/uitable.lua +++ b/modules/corelib/ui/uitable.lua @@ -31,8 +31,11 @@ function UITable:onDestroy() self.columns = {} self.headerRow = {} self.selectedRow = nil - self.dataSpace:destroyChildren() - self.dataSpace = nil + + if self.dataSpace then + self.dataSpace:destroyChildren() + self.dataSpace = nil + end end function UITable:onStyleApply(styleName, styleNode)