diff --git a/src/states_screens/main_menu_screen.cpp b/src/states_screens/main_menu_screen.cpp index 6e6bb9fa3..a00f14195 100644 --- a/src/states_screens/main_menu_screen.cpp +++ b/src/states_screens/main_menu_screen.cpp @@ -97,18 +97,8 @@ void MainMenuScreen::init() { Screen::init(); - ButtonWidget *user_id = getWidget("user-id"); - assert(user_id); - PlayerProfile *player = PlayerManager::getCurrentPlayer(); - if(player) - { - if(player->isLoggedIn()) - user_id->setText(player->getLastOnlineName()+"@stk"); - else - user_id->setText(player->getName()); - } - else - user_id->setText(""); + m_user_id = getWidget("user-id"); + assert(m_user_id); // reset in case we're coming back from a race StateManager::get()->resetActivePlayers(); @@ -168,9 +158,11 @@ void MainMenuScreen::init() void MainMenuScreen::onUpdate(float delta) { + PlayerProfile *player = PlayerManager::getCurrentPlayer(); if(PlayerManager::getCurrentOnlineState() == PlayerProfile::OS_GUEST || PlayerManager::getCurrentOnlineState() == PlayerProfile::OS_SIGNED_IN) { + m_user_id->setText(player->getLastOnlineName() + "@stk"); m_online->setActivated(); m_online->setLabel( _("Online")); } @@ -178,9 +170,14 @@ void MainMenuScreen::onUpdate(float delta) { m_online->setActivated(); m_online->setLabel( _("Login" )); + m_user_id->setText(player->getName()); } - else // now must be either logging in or logging out + else + { + // now must be either logging in or logging out m_online->setDeactivated(); + m_user_id->setText(player->getName()); + } m_online->setLabel(PlayerManager::getCurrentOnlineId() ? _("Online") : _("Login" ) ); diff --git a/src/states_screens/main_menu_screen.hpp b/src/states_screens/main_menu_screen.hpp index f469a9909..141415859 100644 --- a/src/states_screens/main_menu_screen.hpp +++ b/src/states_screens/main_menu_screen.hpp @@ -20,8 +20,8 @@ #include "guiengine/screen.hpp" -namespace GUIEngine { class Widget; class ListWidget; - class IconButtonWidget; } +namespace GUIEngine { class Widget; class ListWidget; + class ButtonWidget; class IconButtonWidget; } /** * \brief Handles the main menu @@ -35,6 +35,9 @@ private: /** Keep the widget to avoid looking it up every frame. */ GUIEngine::IconButtonWidget* m_online; + /** Keep the widget to to the user name. */ + GUIEngine::ButtonWidget *m_user_id; + MainMenuScreen(); public: