diff --git a/modules/core/constants.lua b/modules/core/constants.lua index e5654526..4439ba3a 100644 --- a/modules/core/constants.lua +++ b/modules/core/constants.lua @@ -13,4 +13,6 @@ LogWarning = 2 LogError = 3 LogFatal = 4 +ActiveFocusReason = 2 + EmptyFunction = function() end \ No newline at end of file diff --git a/modules/mainmenu/entergame.lua b/modules/mainmenu/entergame.lua index 797ff0d0..2723a64c 100644 --- a/modules/mainmenu/entergame.lua +++ b/modules/mainmenu/entergame.lua @@ -6,6 +6,7 @@ function EnterGame_characterWindow_okClicked() local selected = charactersWindow:getChildById('charactersList'):getFocusedChild() if selected then Game.loginWorld(account, password, selected.worldHost, selected.worldPort, selected.characterName) + Configs.set('lastUsedCharacter', selected.characterName) charactersWindow:destroy() mainMenu:hide() else @@ -24,6 +25,7 @@ local function createCharactersWindow(characters, premDays) local charactersWindow = UI.loadAndDisplayLocked('/mainmenu/ui/charlist.otui') local charactersList = charactersWindow:getChildById('charactersList') local accountStatusLabel = charactersWindow:getChildById('accountStatusLabel') + for i,characterInfo in ipairs(characters) do local characterName = characterInfo[1] local worldName = characterInfo[2] @@ -37,6 +39,10 @@ local function createCharactersWindow(characters, premDays) label.characterName = characterName label.worldHost = worldHost label.worldPort = worldIp + + if i == 0 or Configs.get('lastUsedCharacter') == characterName then + charactersList:focusChild(label, ActiveFocusReason) + end end if premDays > 0 then accountStatusLabel:setText("Account Status:\nPremium Account (" .. premDays .. ' days left)') diff --git a/src/framework/graphics/animatedtexture.cpp b/src/framework/graphics/animatedtexture.cpp index 8d9db9a0..c6edadbd 100644 --- a/src/framework/graphics/animatedtexture.cpp +++ b/src/framework/graphics/animatedtexture.cpp @@ -22,7 +22,6 @@ AnimatedTexture::AnimatedTexture(int width, int height, int channels, int numFra m_framesTextureId[i] = id; m_framesDelay[i] = framesDelay[i]; } - m_currentFrame = -1; g_dispatcher.scheduleEvent(std::bind(&AnimatedTexture::processAnimation, this), 0); } @@ -51,5 +50,5 @@ void AnimatedTexture::processAnimation() m_textureId = m_framesTextureId[m_currentFrame]; AnimatedTexturePtr me = std::static_pointer_cast(shared_from_this()); if(me.use_count() > 1) - g_dispatcher.addEvent(std::bind(&AnimatedTexture::processAnimation, me), m_framesDelay[m_currentFrame]); + g_dispatcher.scheduleEvent(std::bind(&AnimatedTexture::processAnimation, me), m_framesDelay[m_currentFrame]); } diff --git a/src/framework/luascript/luafunctions.cpp b/src/framework/luascript/luafunctions.cpp index 39f52415..cbb91936 100644 --- a/src/framework/luascript/luafunctions.cpp +++ b/src/framework/luascript/luafunctions.cpp @@ -46,6 +46,7 @@ void LuaInterface::registerFunctions() g_lua.bindClassMemberFunction("insertChild", &UIWidget::insertChild); g_lua.bindClassMemberFunction("removeChild", &UIWidget::removeChild); g_lua.bindClassMemberFunction("addChild", &UIWidget::addChild); + g_lua.bindClassMemberFunction("focusChild", &UIWidget::focusChild); g_lua.bindClassMemberFunction("lockChild", &UIWidget::lockChild); g_lua.bindClassMemberFunction("updateLayout", &UIWidget::updateLayout); g_lua.bindClassMemberFunction("updateParentLayout", &UIWidget::updateParentLayout);