Fix Enter Game window not being centered on startup

This commit is contained in:
TheSumm 2015-01-21 18:58:30 +01:00
parent 596717bf32
commit 6edc73a8ba
1 changed files with 16 additions and 10 deletions

View File

@ -124,13 +124,14 @@ function EnterGame.init()
clientBox = enterGame:getChildById('clientComboBox') clientBox = enterGame:getChildById('clientComboBox')
connect(clientBox, { onOptionChange = EnterGame.onClientVersionChange })
for _, proto in pairs(g_game.getSupportedClients()) do for _, proto in pairs(g_game.getSupportedClients()) do
clientBox:addOption(proto) clientBox:addOption(proto)
end end
clientBox:setCurrentOption(clientVersion) clientBox:setCurrentOption(clientVersion)
EnterGame.toggleAuthenticatorToken(clientVersion, true)
connect(clientBox, { onOptionChange = EnterGame.onClientVersionChange })
enterGame:hide() enterGame:hide()
if g_app.isRunning() and not g_game.isOnline() then if g_app.isRunning() and not g_game.isOnline() then
@ -220,7 +221,8 @@ function EnterGame.clearAccountFields()
g_settings.remove('password') g_settings.remove('password')
end end
function EnterGame.toggleAuthenticatorToken(enabled) function EnterGame.toggleAuthenticatorToken(clientVersion, init)
local enabled = (clientVersion >= 1072)
if enabled == enterGame.authenticatorEnabled then if enabled == enterGame.authenticatorEnabled then
return return
end end
@ -232,9 +234,11 @@ function EnterGame.toggleAuthenticatorToken(enabled)
local serverLabel = enterGame:getChildById('serverLabel') local serverLabel = enterGame:getChildById('serverLabel')
serverLabel:setMarginTop(serverLabel:getMarginTop() + enterGame.authenticatorHeight) serverLabel:setMarginTop(serverLabel:getMarginTop() + enterGame.authenticatorHeight)
enterGame:breakAnchors() if not init then
enterGame:setY(enterGame:getY() - enterGame.authenticatorHeight) enterGame:breakAnchors()
enterGame:bindRectToParent() enterGame:setY(enterGame:getY() - enterGame.authenticatorHeight)
enterGame:bindRectToParent()
end
enterGame:setHeight(enterGame:getHeight() + enterGame.authenticatorHeight) enterGame:setHeight(enterGame:getHeight() + enterGame.authenticatorHeight)
else else
@ -244,9 +248,11 @@ function EnterGame.toggleAuthenticatorToken(enabled)
local serverLabel = enterGame:getChildById('serverLabel') local serverLabel = enterGame:getChildById('serverLabel')
serverLabel:setMarginTop(serverLabel:getMarginTop() - enterGame.authenticatorHeight) serverLabel:setMarginTop(serverLabel:getMarginTop() - enterGame.authenticatorHeight)
enterGame:breakAnchors() if not init then
enterGame:setY(enterGame:getY() + enterGame.authenticatorHeight) enterGame:breakAnchors()
enterGame:bindRectToParent() enterGame:setY(enterGame:getY() + enterGame.authenticatorHeight)
enterGame:bindRectToParent()
end
enterGame:setHeight(enterGame:getHeight() - enterGame.authenticatorHeight) enterGame:setHeight(enterGame:getHeight() - enterGame.authenticatorHeight)
end end
@ -256,7 +262,7 @@ end
function EnterGame.onClientVersionChange(comboBox, text, data) function EnterGame.onClientVersionChange(comboBox, text, data)
local clientVersion = tonumber(text) local clientVersion = tonumber(text)
EnterGame.toggleAuthenticatorToken(clientVersion >= 1072) EnterGame.toggleAuthenticatorToken(clientVersion)
end end
function EnterGame.doLogin() function EnterGame.doLogin()