Fix #1620 (Player's achievements can only be seen when logged in).
This commit is contained in:
parent
49474a5370
commit
ea3a433147
@ -57,6 +57,8 @@
|
|||||||
I18N="In the main screen" text="Help" label_location="hover"/>
|
I18N="In the main screen" text="Help" label_location="hover"/>
|
||||||
<icon-button id="startTutorial" width="64" height="64" icon="gui/tutorial.png" extend_label="150"
|
<icon-button id="startTutorial" width="64" height="64" icon="gui/tutorial.png" extend_label="150"
|
||||||
I18N="In the main screen" text="Tutorial" label_location="hover"/>
|
I18N="In the main screen" text="Tutorial" label_location="hover"/>
|
||||||
|
<icon-button id="achievements" width="64" height="64" icon="gui/gp_copy.png" extend_label="150"
|
||||||
|
I18N="In the main screen" text="Achievements" label_location="hover"/>
|
||||||
<icon-button id="gpEditor" width="64" height="64" icon="gui/gpeditor.png" extend_label="150"
|
<icon-button id="gpEditor" width="64" height="64" icon="gui/gpeditor.png" extend_label="150"
|
||||||
I18N="In the main screen" text="Grand Prix Editor" label_location="hover"/>
|
I18N="In the main screen" text="Grand Prix Editor" label_location="hover"/>
|
||||||
<icon-button id="about" width="64" height="64" icon="gui/main_about.png" extend_label="50"
|
<icon-button id="about" width="64" height="64" icon="gui/main_about.png" extend_label="50"
|
||||||
|
@ -8,13 +8,6 @@
|
|||||||
|
|
||||||
<spacer height="25" width="10"/>
|
<spacer height="25" width="10"/>
|
||||||
|
|
||||||
<tabs id="profile_tabs" height="10%" max_height="110" x="2%" width="98%" align="center">
|
|
||||||
<icon-button id="tab_achievements" width="128" height="128" icon="gui/options_players.png"
|
|
||||||
I18N="Section in the profile screen" text="Achievements"/>
|
|
||||||
<icon-button id="tab_friends" width="128" height="128" icon="gui/options_players.png"/>
|
|
||||||
<icon-button id="tab_settings" width="128" height="128" icon="gui/main_options.png"/>
|
|
||||||
</tabs>
|
|
||||||
|
|
||||||
<box proportion="1" width="100%" layout="vertical-row" padding="6">
|
<box proportion="1" width="100%" layout="vertical-row" padding="6">
|
||||||
<list id="achievements_list" x="0" y="0" width="100%" height="100%"/>
|
<list id="achievements_list" x="0" y="0" width="100%" height="100%"/>
|
||||||
</box>
|
</box>
|
||||||
|
22
data/gui/online/profile_achievements_tab.stkgui
Normal file
22
data/gui/online/profile_achievements_tab.stkgui
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<stkgui>
|
||||||
|
<icon-button id="back" x="0" y="0" height="8%" icon="gui/back.png"/>
|
||||||
|
|
||||||
|
<div x="1%" y="1%" width="98%" height="98%" layout="vertical-row" >
|
||||||
|
|
||||||
|
<header id="title" text_align="center" width="80%" align="center" text="..."/>
|
||||||
|
|
||||||
|
<spacer height="25" width="10"/>
|
||||||
|
|
||||||
|
<tabs id="profile_tabs" height="10%" max_height="110" x="2%" width="98%" align="center">
|
||||||
|
<icon-button id="tab_achievements" width="128" height="128" icon="gui/options_players.png"
|
||||||
|
I18N="Section in the profile screen" text="Achievements"/>
|
||||||
|
<icon-button id="tab_friends" width="128" height="128" icon="gui/options_players.png"/>
|
||||||
|
<icon-button id="tab_settings" width="128" height="128" icon="gui/main_options.png"/>
|
||||||
|
</tabs>
|
||||||
|
|
||||||
|
<box proportion="1" width="100%" layout="vertical-row" padding="6">
|
||||||
|
<list id="achievements_list" x="0" y="0" width="100%" height="100%"/>
|
||||||
|
</box>
|
||||||
|
</div>
|
||||||
|
</stkgui>
|
@ -496,7 +496,7 @@ void MainMenuScreen::eventCallback(Widget* widget, const std::string& name,
|
|||||||
// For 0.8.2 disable the server menu, instead go to online profile
|
// For 0.8.2 disable the server menu, instead go to online profile
|
||||||
//OnlineScreen::getInstance()->push();
|
//OnlineScreen::getInstance()->push();
|
||||||
ProfileManager::get()->setVisiting(PlayerManager::getCurrentOnlineId());
|
ProfileManager::get()->setVisiting(PlayerManager::getCurrentOnlineId());
|
||||||
OnlineProfileAchievements::getInstance()->push();
|
TabOnlineProfileAchievements::getInstance()->push();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -522,6 +522,10 @@ void MainMenuScreen::eventCallback(Widget* widget, const std::string& name,
|
|||||||
{
|
{
|
||||||
GrandPrixEditorScreen::getInstance()->push();
|
GrandPrixEditorScreen::getInstance()->push();
|
||||||
}
|
}
|
||||||
|
else if (selection == "achievements")
|
||||||
|
{
|
||||||
|
OnlineProfileAchievements::getInstance()->push();
|
||||||
|
}
|
||||||
} // eventCallback
|
} // eventCallback
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
@ -40,21 +40,22 @@ using namespace irr::core;
|
|||||||
using namespace irr::gui;
|
using namespace irr::gui;
|
||||||
using namespace Online;
|
using namespace Online;
|
||||||
|
|
||||||
DEFINE_SCREEN_SINGLETON( OnlineProfileAchievements );
|
DEFINE_SCREEN_SINGLETON( OnlineProfileAchievements );
|
||||||
|
DEFINE_SCREEN_SINGLETON( TabOnlineProfileAchievements );
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
/** Constructor.
|
/** Constructor.
|
||||||
*/
|
*/
|
||||||
OnlineProfileAchievements::OnlineProfileAchievements()
|
BaseOnlineProfileAchievements::BaseOnlineProfileAchievements(const std::string &name)
|
||||||
: OnlineProfileBase("online/profile_achievements.stkgui")
|
: OnlineProfileBase(name)
|
||||||
{
|
{
|
||||||
m_selected_achievement_index = -1;
|
m_selected_achievement_index = -1;
|
||||||
} // OnlineProfileAchievements
|
} // BaseOnlineProfileAchievements
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
/** Callback when the xml file was loaded.
|
/** Callback when the xml file was loaded.
|
||||||
*/
|
*/
|
||||||
void OnlineProfileAchievements::loadedFromFile()
|
void BaseOnlineProfileAchievements::loadedFromFile()
|
||||||
{
|
{
|
||||||
OnlineProfileBase::loadedFromFile();
|
OnlineProfileBase::loadedFromFile();
|
||||||
m_achievements_list_widget = getWidget<ListWidget>("achievements_list");
|
m_achievements_list_widget = getWidget<ListWidget>("achievements_list");
|
||||||
@ -65,7 +66,7 @@ void OnlineProfileAchievements::loadedFromFile()
|
|||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
/** Callback before widgets are added. Clears all widgets.
|
/** Callback before widgets are added. Clears all widgets.
|
||||||
*/
|
*/
|
||||||
void OnlineProfileAchievements::beforeAddingWidget()
|
void BaseOnlineProfileAchievements::beforeAddingWidget()
|
||||||
{
|
{
|
||||||
OnlineProfileBase::beforeAddingWidget();
|
OnlineProfileBase::beforeAddingWidget();
|
||||||
m_achievements_list_widget->clearColumns();
|
m_achievements_list_widget->clearColumns();
|
||||||
@ -82,11 +83,12 @@ void OnlineProfileAchievements::beforeAddingWidget()
|
|||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
/** Called when entering this menu (after widgets have been added).
|
/** Called when entering this menu (after widgets have been added).
|
||||||
*/
|
*/
|
||||||
void OnlineProfileAchievements::init()
|
void BaseOnlineProfileAchievements::init()
|
||||||
{
|
{
|
||||||
OnlineProfileBase::init();
|
OnlineProfileBase::init();
|
||||||
m_profile_tabs->select( m_achievements_tab->m_properties[PROP_ID],
|
if (m_profile_tabs)
|
||||||
PLAYER_ID_GAME_MASTER );
|
m_profile_tabs->select(m_achievements_tab->m_properties[PROP_ID],
|
||||||
|
PLAYER_ID_GAME_MASTER);
|
||||||
|
|
||||||
// For current user add the progrss information.
|
// For current user add the progrss information.
|
||||||
// m_visiting_profile is NULL if the user is not logged in.
|
// m_visiting_profile is NULL if the user is not logged in.
|
||||||
@ -129,7 +131,7 @@ void OnlineProfileAchievements::init()
|
|||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
void OnlineProfileAchievements::eventCallback(Widget* widget,
|
void BaseOnlineProfileAchievements::eventCallback(Widget* widget,
|
||||||
const std::string& name,
|
const std::string& name,
|
||||||
const int playerID)
|
const int playerID)
|
||||||
{
|
{
|
||||||
@ -155,7 +157,7 @@ void OnlineProfileAchievements::eventCallback(Widget* widget,
|
|||||||
/** Called every frame. It will check if results from an achievement request
|
/** Called every frame. It will check if results from an achievement request
|
||||||
* have been received, and if so, display them.
|
* have been received, and if so, display them.
|
||||||
*/
|
*/
|
||||||
void OnlineProfileAchievements::onUpdate(float delta)
|
void BaseOnlineProfileAchievements::onUpdate(float delta)
|
||||||
{
|
{
|
||||||
if (!m_waiting_for_achievements) return;
|
if (!m_waiting_for_achievements) return;
|
||||||
|
|
||||||
|
@ -35,18 +35,20 @@ namespace GUIEngine { class Widget; }
|
|||||||
* \brief Online profiel overview screen
|
* \brief Online profiel overview screen
|
||||||
* \ingroup states_screens
|
* \ingroup states_screens
|
||||||
*/
|
*/
|
||||||
class OnlineProfileAchievements : public OnlineProfileBase, public GUIEngine::ScreenSingleton<OnlineProfileAchievements>
|
class BaseOnlineProfileAchievements : public OnlineProfileBase
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
OnlineProfileAchievements();
|
|
||||||
|
|
||||||
GUIEngine::ListWidget * m_achievements_list_widget;
|
GUIEngine::ListWidget * m_achievements_list_widget;
|
||||||
|
|
||||||
int m_selected_achievement_index;
|
int m_selected_achievement_index;
|
||||||
bool m_waiting_for_achievements;
|
bool m_waiting_for_achievements;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
BaseOnlineProfileAchievements(const std::string &filename);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
friend class GUIEngine::ScreenSingleton<OnlineProfileAchievements>;
|
friend class GUIEngine::ScreenSingleton<BaseOnlineProfileAchievements>;
|
||||||
|
|
||||||
/** \brief implement callback from parent class GUIEngine::Screen */
|
/** \brief implement callback from parent class GUIEngine::Screen */
|
||||||
virtual void loadedFromFile() OVERRIDE;
|
virtual void loadedFromFile() OVERRIDE;
|
||||||
@ -61,7 +63,46 @@ public:
|
|||||||
|
|
||||||
virtual void beforeAddingWidget() OVERRIDE;
|
virtual void beforeAddingWidget() OVERRIDE;
|
||||||
|
|
||||||
virtual void refreshAchievementsList() { m_waiting_for_achievements = true; }
|
// ------------------------------------------------------------------------
|
||||||
|
virtual void refreshAchievementsList()
|
||||||
|
{
|
||||||
|
m_waiting_for_achievements = true;
|
||||||
|
} // refreshAchievementsList
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// ============================================================================
|
||||||
|
/**
|
||||||
|
* \brief Online profiel overview screen
|
||||||
|
* \ingroup states_screens
|
||||||
|
*/
|
||||||
|
class TabOnlineProfileAchievements : public BaseOnlineProfileAchievements,
|
||||||
|
public GUIEngine::ScreenSingleton<TabOnlineProfileAchievements>
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
friend class GUIEngine::ScreenSingleton<TabOnlineProfileAchievements>;
|
||||||
|
|
||||||
|
TabOnlineProfileAchievements()
|
||||||
|
: BaseOnlineProfileAchievements("online/profile_achievements_tab.stkgui")
|
||||||
|
{}
|
||||||
|
|
||||||
|
}; // TabOnlineProfileAchievements
|
||||||
|
|
||||||
|
// ============================================================================
|
||||||
|
/**
|
||||||
|
* \brief Online profiel overview screen
|
||||||
|
* \ingroup states_screens
|
||||||
|
*/
|
||||||
|
class OnlineProfileAchievements : public BaseOnlineProfileAchievements,
|
||||||
|
public GUIEngine::ScreenSingleton < OnlineProfileAchievements >
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
friend class GUIEngine::ScreenSingleton<OnlineProfileAchievements>;
|
||||||
|
|
||||||
|
OnlineProfileAchievements()
|
||||||
|
: BaseOnlineProfileAchievements("online/profile_achievements.stkgui")
|
||||||
|
{}
|
||||||
|
|
||||||
|
}; // class
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -38,7 +38,8 @@ using namespace irr::gui;
|
|||||||
using namespace Online;
|
using namespace Online;
|
||||||
|
|
||||||
|
|
||||||
OnlineProfileBase::OnlineProfileBase(const char* filename) : Screen(filename)
|
OnlineProfileBase::OnlineProfileBase(const std::string &filename)
|
||||||
|
: Screen(filename.c_str())
|
||||||
{
|
{
|
||||||
} // OnlineProfileBase
|
} // OnlineProfileBase
|
||||||
|
|
||||||
@ -48,19 +49,19 @@ OnlineProfileBase::OnlineProfileBase(const char* filename) : Screen(filename)
|
|||||||
void OnlineProfileBase::loadedFromFile()
|
void OnlineProfileBase::loadedFromFile()
|
||||||
{
|
{
|
||||||
m_profile_tabs = getWidget<RibbonWidget>("profile_tabs");
|
m_profile_tabs = getWidget<RibbonWidget>("profile_tabs");
|
||||||
assert(m_profile_tabs != NULL);
|
|
||||||
m_header = getWidget<LabelWidget>("title");
|
m_header = getWidget<LabelWidget>("title");
|
||||||
assert(m_header != NULL);
|
assert(m_header != NULL);
|
||||||
|
|
||||||
m_friends_tab =
|
m_friends_tab = !m_profile_tabs ? NULL :
|
||||||
(IconButtonWidget *) m_profile_tabs->findWidgetNamed("tab_friends");
|
(IconButtonWidget *) m_profile_tabs->findWidgetNamed("tab_friends");
|
||||||
assert(m_friends_tab != NULL);
|
assert(m_profile_tabs == NULL || m_friends_tab != NULL);
|
||||||
m_achievements_tab =
|
m_achievements_tab = !m_profile_tabs ? NULL :
|
||||||
(IconButtonWidget*)m_profile_tabs->findWidgetNamed("tab_achievements");
|
(IconButtonWidget*)m_profile_tabs->findWidgetNamed("tab_achievements");
|
||||||
assert(m_achievements_tab != NULL);
|
assert(m_profile_tabs == NULL || m_achievements_tab != NULL);
|
||||||
m_settings_tab =
|
m_settings_tab = !m_profile_tabs ? NULL :
|
||||||
(IconButtonWidget *) m_profile_tabs->findWidgetNamed("tab_settings");
|
(IconButtonWidget *) m_profile_tabs->findWidgetNamed("tab_settings");
|
||||||
assert(m_settings_tab != NULL);
|
assert(m_profile_tabs == NULL || m_settings_tab != NULL);
|
||||||
} // loadedFromFile
|
} // loadedFromFile
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
@ -70,17 +71,20 @@ void OnlineProfileBase::loadedFromFile()
|
|||||||
void OnlineProfileBase::beforeAddingWidget()
|
void OnlineProfileBase::beforeAddingWidget()
|
||||||
{
|
{
|
||||||
m_visiting_profile = ProfileManager::get()->getVisitingProfile();
|
m_visiting_profile = ProfileManager::get()->getVisitingProfile();
|
||||||
if (!m_visiting_profile || !m_visiting_profile->isCurrentUser())
|
if (m_profile_tabs)
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
m_friends_tab->setVisible(false);
|
if (!m_visiting_profile || !m_visiting_profile->isCurrentUser())
|
||||||
m_profile_tabs->setVisible(false);
|
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)
|
||||||
|
{
|
||||||
|
m_friends_tab->setVisible(false);
|
||||||
|
m_profile_tabs->setVisible(false);
|
||||||
|
}
|
||||||
|
} // if m_profile_tabhs
|
||||||
} // beforeAddingWidget
|
} // beforeAddingWidget
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
@ -90,20 +94,26 @@ void OnlineProfileBase::init()
|
|||||||
{
|
{
|
||||||
Screen::init();
|
Screen::init();
|
||||||
|
|
||||||
m_friends_tab->setTooltip( _("Friends") );
|
if (m_profile_tabs)
|
||||||
m_achievements_tab->setTooltip( _("Achievements") );
|
|
||||||
m_settings_tab->setTooltip( _("Account Settings") );
|
|
||||||
|
|
||||||
// If no visiting_profile is defined, use the data of the current player.
|
|
||||||
if (!m_visiting_profile || m_visiting_profile->isCurrentUser())
|
|
||||||
m_header->setText(_("Your profile"), false);
|
|
||||||
else if (m_visiting_profile)
|
|
||||||
{
|
{
|
||||||
m_header->setText(m_visiting_profile->getUserName() + _("'s profile"), false);
|
m_friends_tab->setTooltip(_("Friends"));
|
||||||
}
|
m_achievements_tab->setTooltip(_("Achievements"));
|
||||||
else
|
m_settings_tab->setTooltip(_("Account Settings"));
|
||||||
Log::error("OnlineProfileBase", "No visting profile");
|
|
||||||
|
|
||||||
|
// If no visiting_profile is defined, use the data of the current player.
|
||||||
|
if (!m_visiting_profile || m_visiting_profile->isCurrentUser())
|
||||||
|
m_header->setText(_("Your profile"), false);
|
||||||
|
else if (m_visiting_profile)
|
||||||
|
{
|
||||||
|
m_header->setText(m_visiting_profile->getUserName() + _("'s profile"), false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
Log::error("OnlineProfileBase", "No visting profile");
|
||||||
|
}
|
||||||
|
else // no tabs, so must be local player achievements:
|
||||||
|
{
|
||||||
|
m_header->setText(_("Your profile"), false);
|
||||||
|
}
|
||||||
} // init
|
} // init
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
@ -115,7 +125,8 @@ bool OnlineProfileBase::onEscapePressed()
|
|||||||
|
|
||||||
//return to your profile if it's another profile
|
//return to your profile if it's another profile
|
||||||
ProfileManager::get()->setVisiting(PlayerManager::getCurrentOnlineId());
|
ProfileManager::get()->setVisiting(PlayerManager::getCurrentOnlineId());
|
||||||
StateManager::get()->replaceTopMostScreen(OnlineProfileAchievements::getInstance());
|
StateManager::get()->replaceTopMostScreen(
|
||||||
|
TabOnlineProfileAchievements::getInstance());
|
||||||
return false;
|
return false;
|
||||||
} // onEscapePressed
|
} // onEscapePressed
|
||||||
|
|
||||||
@ -125,7 +136,7 @@ bool OnlineProfileBase::onEscapePressed()
|
|||||||
void OnlineProfileBase::eventCallback(Widget* widget, const std::string& name,
|
void OnlineProfileBase::eventCallback(Widget* widget, const std::string& name,
|
||||||
const int playerID)
|
const int playerID)
|
||||||
{
|
{
|
||||||
if (name == m_profile_tabs->m_properties[PROP_ID])
|
if (m_profile_tabs && name == m_profile_tabs->m_properties[PROP_ID])
|
||||||
{
|
{
|
||||||
std::string selection =
|
std::string selection =
|
||||||
((RibbonWidget*)widget)->getSelectionIDString(PLAYER_ID_GAME_MASTER);
|
((RibbonWidget*)widget)->getSelectionIDString(PLAYER_ID_GAME_MASTER);
|
||||||
|
@ -37,7 +37,7 @@ namespace GUIEngine { class Widget; }
|
|||||||
class OnlineProfileBase : public GUIEngine::Screen
|
class OnlineProfileBase : public GUIEngine::Screen
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
OnlineProfileBase(const char* filename);
|
OnlineProfileBase(const std::string &filename);
|
||||||
|
|
||||||
/** Pointer to the various widgets on the screen. */
|
/** Pointer to the various widgets on the screen. */
|
||||||
GUIEngine::LabelWidget * m_header;
|
GUIEngine::LabelWidget * m_header;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user