see previous commit

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/uni@13458 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
unitraxx 2013-08-11 17:24:36 +00:00
parent c8eea98342
commit 098b191e9e
6 changed files with 32 additions and 18 deletions

View File

@ -14,7 +14,7 @@
<box proportion="1" width="100%" layout="vertical-row">
<div x="1%" y="2%" width="98%" height="96%" layout="vertical-row" >
<div proportion="1" width="100%" layout="horizontal-row">
<box proportion="1" height="100%" align="center" layout="vertical-row" padding="0">
<box proportion="1" height="100%" align="center" layout="vertical-row" padding="6">
<list id="friends_list" x="0" y="0" width="100%" height="100%"/>
</box>
<spacer width="2%" height="10"/>

View File

@ -62,8 +62,8 @@ namespace Online{
void Profile::friendsListCallback(const XMLNode * input)
{
uint32_t friendid = 0;
irr::core::stringw username("");
uint32_t friendid(0);
irr::core::stringw username("check");
const XMLNode * friends_xml = input->getNode("friends");
m_friends.clearAndDeleteAll();
for (unsigned int i = 0; i < friends_xml->getNumNodes(); i++)
@ -71,6 +71,7 @@ namespace Online{
friends_xml->getNode(i)->get("friend_id", &friendid);
m_friends.push_back(new User(username, friendid));
}
m_has_fetched_friends = true;
Profile::setState (Profile::S_READY);
}
@ -79,8 +80,8 @@ namespace Online{
void Profile::FriendsListRequest::callback()
{
uint32_t user_id;
m_result->get("visitingid", &user_id);
uint32_t user_id(0);
int result = m_result->get("visitingid", &user_id);
assert(ProfileManager::get()->getProfileByID(user_id) != NULL);
ProfileManager::get()->getProfileByID(user_id)->friendsListCallback(m_result);
}

View File

@ -78,7 +78,7 @@ namespace Online{
void ProfileManager::addToCache(Profile * profile)
{
assert(profile != NULL);
if(m_profiles_cache.size() == m_max_cache_size)
{
ProfilesMap::iterator iter;
@ -121,7 +121,10 @@ namespace Online{
Profile * ProfileManager::getProfileByID(uint32_t id)
{
if( m_profiles_cache.find(id) == m_profiles_cache.end())
{
Log::info("getProfileByID","here");
return NULL;
}
return m_profiles_cache[id];
}

View File

@ -58,7 +58,7 @@ void OnlineProfileFriends::loadedFromFile()
void OnlineProfileFriends::beforeAddingWidget()
{
m_friends_list_widget->clearColumns();
m_friends_list_widget->addColumn( _("Username"), 3 );
m_friends_list_widget->addColumn( _("Friends"), 3 );
}
// -----------------------------------------------------------------------------
@ -68,7 +68,9 @@ void OnlineProfileFriends::init()
OnlineProfileBase::init();
m_profile_tabs->select( m_friends_tab->m_properties[PROP_ID], PLAYER_ID_GAME_MASTER );
m_visiting_profile = ProfileManager::get()->getVisitingProfile();
assert(m_visiting_profile != NULL);
m_visiting_profile->fetchFriends();
m_waiting_for_friends = true;
m_friends_list_widget->clear();
m_friends_list_widget->addItem("spacer", L"");
m_friends_list_widget->addItem("loading", Messages::fetchingFriends());
@ -83,17 +85,22 @@ void OnlineProfileFriends::eventCallback(Widget* widget, const std::string& name
// ----------------------------------------------------------------------------
void OnlineProfileFriends::onUpdate(float delta, irr::video::IVideoDriver* driver)
{
if(m_visiting_profile->isReady())
if(m_waiting_for_friends)
{
for(int i = 0; i < m_visiting_profile->getFriends().size(); i++)
if(m_visiting_profile->isReady())
{
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);
m_friends_list_widget->clear();
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);
}
m_waiting_for_friends = false;
}
else
{
m_friends_list_widget->renameItem("loading", Messages::fetchingFriends());
}
}
else
{
m_friends_list_widget->renameItem("loading", Messages::fetchingFriends());
}
}

View File

@ -40,8 +40,9 @@ class OnlineProfileFriends : public OnlineProfileBase, public GUIEngine::ScreenS
private:
OnlineProfileFriends();
GUIEngine::ListWidget * m_friends_list_widget;
Online::Profile * m_visiting_profile;
GUIEngine::ListWidget * m_friends_list_widget;
Online::Profile * m_visiting_profile;
bool m_waiting_for_friends;
public:
friend class GUIEngine::ScreenSingleton<OnlineProfileFriends>;

View File

@ -39,6 +39,7 @@
#include "states_screens/online_profile_overview.hpp"
#include "online/servers_manager.hpp"
#include "online/messages.hpp"
#include "online/profile_manager.hpp"
#include "online/request.hpp"
#include "modes/demo_world.hpp"
@ -216,6 +217,7 @@ void OnlineScreen::eventCallback(Widget* widget, const std::string& name, const
}
else if (selection == m_profile_widget->m_properties[PROP_ID])
{
ProfileManager::get()->setVisiting(CurrentUser::get());
StateManager::get()->pushScreen(OnlineProfileOverview::getInstance());
}
else if (selection == "register")