escape or back on friends profile takes you to your profile

Also, fixed bug where user info dialog was accessing m_enter_profile
after it was deleted
This commit is contained in:
quizywiz
2014-10-12 15:57:18 +05:30
parent c18579d86a
commit 6dd9feff36
3 changed files with 20 additions and 1 deletions

View File

@@ -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;
}

View File

@@ -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).
*/

View File

@@ -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;
};