diff --git a/src/states_screens/dialogs/user_info_dialog.cpp b/src/states_screens/dialogs/user_info_dialog.cpp index 8c457f518..698e396ce 100644 --- a/src/states_screens/dialogs/user_info_dialog.cpp +++ b/src/states_screens/dialogs/user_info_dialog.cpp @@ -479,8 +479,9 @@ void UserInfoDialog::onUpdate(float dt) // It's unsafe to delete from inside the event handler so we do it here if (m_self_destroy) { + bool enter_profile = m_enter_profile; ModalDialog::dismiss(); - if (m_enter_profile) + if (enter_profile) StateManager::get()->replaceTopMostScreen(OnlineProfileAchievements::getInstance()); return; } diff --git a/src/states_screens/online_profile_base.cpp b/src/states_screens/online_profile_base.cpp index c7b938a5c..0d90bdd0d 100644 --- a/src/states_screens/online_profile_base.cpp +++ b/src/states_screens/online_profile_base.cpp @@ -17,6 +17,7 @@ #include "states_screens/online_profile_base.hpp" +#include "config/player_manager.hpp" #include "guiengine/engine.hpp" #include "guiengine/scalable_font.hpp" #include "guiengine/screen.hpp" @@ -71,6 +72,8 @@ void OnlineProfileBase::beforeAddingWidget() m_visiting_profile = ProfileManager::get()->getVisitingProfile(); if (!m_visiting_profile || !m_visiting_profile->isCurrentUser()) m_settings_tab->setVisible(false); + else + m_settings_tab->setVisible(true); // If not logged in, don't show profile or friends if (!m_visiting_profile) @@ -103,6 +106,19 @@ void OnlineProfileBase::init() } // init +// ----------------------------------------------------------------------------- +bool OnlineProfileBase::onEscapePressed() +{ + //return to main menu if it's your profile + if (!m_visiting_profile || m_visiting_profile->isCurrentUser()) + return true; + + //return to your profile if it's another profile + ProfileManager::get()->setVisiting(PlayerManager::getCurrentOnlineId()); + StateManager::get()->replaceTopMostScreen(OnlineProfileAchievements::getInstance()); + return false; +} // onEscapePressed + // ----------------------------------------------------------------------------- /** Called when an event occurs (i.e. user clicks on something). */ diff --git a/src/states_screens/online_profile_base.hpp b/src/states_screens/online_profile_base.hpp index 956b43d9b..247de6e95 100644 --- a/src/states_screens/online_profile_base.hpp +++ b/src/states_screens/online_profile_base.hpp @@ -62,6 +62,8 @@ public: /** \brief implement callback from parent class GUIEngine::Screen */ virtual void init() OVERRIDE; + virtual bool onEscapePressed() OVERRIDE; + virtual void beforeAddingWidget() OVERRIDE; };