The actual fetchitng and showing of your friends in the friendslist
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/uni@13456 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
d8734acbe6
commit
c8eea98342
@ -70,6 +70,13 @@ namespace Online
|
|||||||
return irr::core::stringw(_("Fetching servers")) + loadingDots();
|
return irr::core::stringw(_("Fetching servers")) + loadingDots();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
|
irr::core::stringw fetchingFriends()
|
||||||
|
{
|
||||||
|
return irr::core::stringw(_("Fetching friends")) + loadingDots();
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
irr::core::stringw loadingDots(bool spaces, float interval, int max_dots)
|
irr::core::stringw loadingDots(bool spaces, float interval, int max_dots)
|
||||||
{
|
{
|
||||||
|
@ -34,6 +34,7 @@ namespace Online
|
|||||||
irr::core::stringw joiningServer ();
|
irr::core::stringw joiningServer ();
|
||||||
irr::core::stringw creatingServer ();
|
irr::core::stringw creatingServer ();
|
||||||
irr::core::stringw fetchingServers ();
|
irr::core::stringw fetchingServers ();
|
||||||
|
irr::core::stringw fetchingFriends ();
|
||||||
irr::core::stringw signedInAs (const irr::core::stringw & name);
|
irr::core::stringw signedInAs (const irr::core::stringw & name);
|
||||||
} // namespace Messages
|
} // namespace Messages
|
||||||
}// namespace Online
|
}// namespace Online
|
||||||
|
@ -90,6 +90,8 @@ namespace Online{
|
|||||||
const PtrVector<Online::User> & Profile::getFriends()
|
const PtrVector<Online::User> & Profile::getFriends()
|
||||||
{
|
{
|
||||||
assert (m_has_fetched_friends && getState() == S_READY);
|
assert (m_has_fetched_friends && getState() == S_READY);
|
||||||
|
delete m_friends_list_request;
|
||||||
|
m_friends_list_request = NULL;
|
||||||
return m_friends;
|
return m_friends;
|
||||||
}
|
}
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
@ -52,7 +52,7 @@ namespace Online{
|
|||||||
|
|
||||||
ProfilesMap m_profiles_cache;
|
ProfilesMap m_profiles_cache;
|
||||||
Profile * m_currently_visiting;
|
Profile * m_currently_visiting;
|
||||||
const int m_max_cache_size = 5;
|
static const unsigned int m_max_cache_size = 5;
|
||||||
|
|
||||||
void iterateCache();
|
void iterateCache();
|
||||||
void addToCache(Profile * profile);
|
void addToCache(Profile * profile);
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include "guiengine/widget.hpp"
|
#include "guiengine/widget.hpp"
|
||||||
#include "states_screens/state_manager.hpp"
|
#include "states_screens/state_manager.hpp"
|
||||||
#include "utils/translation.hpp"
|
#include "utils/translation.hpp"
|
||||||
|
#include "online/messages.hpp"
|
||||||
|
|
||||||
#include <IGUIButton.h>
|
#include <IGUIButton.h>
|
||||||
|
|
||||||
@ -47,14 +48,30 @@ OnlineProfileFriends::OnlineProfileFriends() : OnlineProfileBase("online/profile
|
|||||||
void OnlineProfileFriends::loadedFromFile()
|
void OnlineProfileFriends::loadedFromFile()
|
||||||
{
|
{
|
||||||
OnlineProfileBase::loadedFromFile();
|
OnlineProfileBase::loadedFromFile();
|
||||||
|
m_friends_list_widget = getWidget<GUIEngine::ListWidget>("friends_list");
|
||||||
|
assert(m_friends_list_widget != NULL);
|
||||||
|
|
||||||
} // loadedFromFile
|
} // loadedFromFile
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void OnlineProfileFriends::beforeAddingWidget()
|
||||||
|
{
|
||||||
|
m_friends_list_widget->clearColumns();
|
||||||
|
m_friends_list_widget->addColumn( _("Username"), 3 );
|
||||||
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
void OnlineProfileFriends::init()
|
void OnlineProfileFriends::init()
|
||||||
{
|
{
|
||||||
OnlineProfileBase::init();
|
OnlineProfileBase::init();
|
||||||
m_profile_tabs->select( m_friends_tab->m_properties[PROP_ID], PLAYER_ID_GAME_MASTER );
|
m_profile_tabs->select( m_friends_tab->m_properties[PROP_ID], PLAYER_ID_GAME_MASTER );
|
||||||
|
m_visiting_profile = ProfileManager::get()->getVisitingProfile();
|
||||||
|
m_visiting_profile->fetchFriends();
|
||||||
|
m_friends_list_widget->clear();
|
||||||
|
m_friends_list_widget->addItem("spacer", L"");
|
||||||
|
m_friends_list_widget->addItem("loading", Messages::fetchingFriends());
|
||||||
} // init
|
} // init
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -63,3 +80,20 @@ void OnlineProfileFriends::eventCallback(Widget* widget, const std::string& name
|
|||||||
OnlineProfileBase::eventCallback( widget, name, playerID);
|
OnlineProfileBase::eventCallback( widget, name, playerID);
|
||||||
} // eventCallback
|
} // eventCallback
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
void OnlineProfileFriends::onUpdate(float delta, irr::video::IVideoDriver* driver)
|
||||||
|
{
|
||||||
|
if(m_visiting_profile->isReady())
|
||||||
|
{
|
||||||
|
for(int i = 0; i < m_visiting_profile->getFriends().size(); i++)
|
||||||
|
{
|
||||||
|
PtrVector<GUIEngine::ListWidget::ListCell> * row = new PtrVector<GUIEngine::ListWidget::ListCell>;
|
||||||
|
row->push_back(new GUIEngine::ListWidget::ListCell(m_visiting_profile->getFriends()[i].getUserName(),-1,3));
|
||||||
|
m_friends_list_widget->addItem("server", row);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_friends_list_widget->renameItem("loading", Messages::fetchingFriends());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -25,6 +25,8 @@
|
|||||||
#include "guiengine/screen.hpp"
|
#include "guiengine/screen.hpp"
|
||||||
#include "guiengine/widgets.hpp"
|
#include "guiengine/widgets.hpp"
|
||||||
#include "states_screens/online_profile_base.hpp"
|
#include "states_screens/online_profile_base.hpp"
|
||||||
|
#include "online/profile_manager.hpp"
|
||||||
|
|
||||||
|
|
||||||
namespace GUIEngine { class Widget; }
|
namespace GUIEngine { class Widget; }
|
||||||
|
|
||||||
@ -38,6 +40,9 @@ class OnlineProfileFriends : public OnlineProfileBase, public GUIEngine::ScreenS
|
|||||||
private:
|
private:
|
||||||
OnlineProfileFriends();
|
OnlineProfileFriends();
|
||||||
|
|
||||||
|
GUIEngine::ListWidget * m_friends_list_widget;
|
||||||
|
Online::Profile * m_visiting_profile;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
friend class GUIEngine::ScreenSingleton<OnlineProfileFriends>;
|
friend class GUIEngine::ScreenSingleton<OnlineProfileFriends>;
|
||||||
|
|
||||||
@ -49,6 +54,10 @@ public:
|
|||||||
|
|
||||||
/** \brief implement callback from parent class GUIEngine::Screen */
|
/** \brief implement callback from parent class GUIEngine::Screen */
|
||||||
virtual void init() OVERRIDE;
|
virtual void init() OVERRIDE;
|
||||||
|
|
||||||
|
virtual void onUpdate(float delta, irr::video::IVideoDriver* driver) OVERRIDE;
|
||||||
|
|
||||||
|
virtual void beforeAddingWidget() OVERRIDE;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user