From 66c9c1fac790fe2c88e8ebc803445b36271e0e8d Mon Sep 17 00:00:00 2001 From: unitraxx Date: Sat, 17 Aug 2013 21:39:51 +0000 Subject: [PATCH] More info shown now in the friendslist. Client now knows when a friend request is pending etc. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/uni@13494 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- data/gui/online/profile_friends.stkgui | 40 +++++++++---------- data/gui/online/user_search.stkgui | 4 +- src/online/profile.cpp | 7 +++- src/online/profile.hpp | 2 +- src/states_screens/online_profile_friends.cpp | 30 ++++++++++++-- src/states_screens/online_profile_friends.hpp | 1 + 6 files changed, 56 insertions(+), 28 deletions(-) diff --git a/data/gui/online/profile_friends.stkgui b/data/gui/online/profile_friends.stkgui index ff4c42cd3..02385964f 100644 --- a/data/gui/online/profile_friends.stkgui +++ b/data/gui/online/profile_friends.stkgui @@ -1,6 +1,8 @@ -
+ + +
@@ -11,27 +13,23 @@ - -
-
- - - - -
- -
-
+ + + +
+ + + +
+
- - diff --git a/data/gui/online/user_search.stkgui b/data/gui/online/user_search.stkgui index 8bab756a6..df933620b 100644 --- a/data/gui/online/user_search.stkgui +++ b/data/gui/online/user_search.stkgui @@ -1,6 +1,7 @@ + +
-
@@ -19,4 +20,5 @@
+
diff --git a/src/online/profile.cpp b/src/online/profile.cpp index 90487ea13..88bd2c51a 100644 --- a/src/online/profile.cpp +++ b/src/online/profile.cpp @@ -39,7 +39,6 @@ namespace Online{ Profile::RelationInfo::RelationInfo(const irr::core::stringw & date, bool is_online, bool is_pending, bool is_asker) { m_date = date; - Log::info("date","%s",m_date.c_str()); m_is_online = is_online; m_is_pending = is_pending; m_is_asker = is_asker; @@ -113,7 +112,11 @@ namespace Online{ m_friends.clear(); for (unsigned int i = 0; i < friends_xml->getNumNodes(); i++) { - Profile * profile = new Profile(friends_xml->getNode(i), (m_is_current_user ? C_RELATION_INFO : C_DEFAULT)); + Profile * profile; + if(m_is_current_user) + profile = new Profile(friends_xml->getNode(i) , C_RELATION_INFO); + else + profile = new Profile(friends_xml->getNode(i)->getNode("user"), C_DEFAULT); m_friends.push_back(profile->getID()); ProfileManager::get()->addToCache(profile); } diff --git a/src/online/profile.hpp b/src/online/profile.hpp index 25f096365..2a6b9cd18 100644 --- a/src/online/profile.hpp +++ b/src/online/profile.hpp @@ -107,7 +107,7 @@ namespace Online{ bool isReady() const { return getState() == S_READY; } bool isCurrentUser() const { return m_is_current_user; } - const RelationInfo * getRelationInfo() { return m_relation_info; } + RelationInfo * getRelationInfo() { return m_relation_info; } void setCacheBit() { m_cache_bit = true; } void unsetCacheBit() { m_cache_bit = false; } diff --git a/src/states_screens/online_profile_friends.cpp b/src/states_screens/online_profile_friends.cpp index 109a669d1..6b2fda65c 100644 --- a/src/states_screens/online_profile_friends.cpp +++ b/src/states_screens/online_profile_friends.cpp @@ -44,6 +44,7 @@ DEFINE_SCREEN_SINGLETON( OnlineProfileFriends ); OnlineProfileFriends::OnlineProfileFriends() : OnlineProfileBase("online/profile_friends.stkgui") { m_selected_friend_index = -1; + m_own_profile = true; } // OnlineProfileFriends // ----------------------------------------------------------------------------- @@ -65,7 +66,12 @@ void OnlineProfileFriends::loadedFromFile() void OnlineProfileFriends::beforeAddingWidget() { m_friends_list_widget->clearColumns(); - m_friends_list_widget->addColumn( _("Friends"), 3 ); + m_friends_list_widget->addColumn( _("Username"), 2 ); + if(m_own_profile) + { + m_friends_list_widget->addColumn( _("Since"), 1 ); + m_friends_list_widget->addColumn( _("Status"), 2 ); + } } // ----------------------------------------------------------------------------- @@ -73,6 +79,12 @@ void OnlineProfileFriends::beforeAddingWidget() void OnlineProfileFriends::init() { OnlineProfileBase::init(); + if(m_own_profile != m_visiting_profile->isCurrentUser()) + { + m_own_profile = m_visiting_profile->isCurrentUser(); + GUIEngine::reshowCurrentScreen(); + return; + } m_profile_tabs->select( m_friends_tab->m_properties[PROP_ID], PLAYER_ID_GAME_MASTER ); assert(m_visiting_profile != NULL); m_visiting_profile->fetchFriends(); @@ -106,12 +118,24 @@ void OnlineProfileFriends::onUpdate(float delta, irr::video::IVideoDriver* driv if(m_visiting_profile->isReady()) { m_friends_list_widget->clear(); - Log::info("","%d",m_visiting_profile->getFriends().size()); for(unsigned int i = 0; i < m_visiting_profile->getFriends().size(); i++) { PtrVector * row = new PtrVector; Profile * friend_profile = ProfileManager::get()->getProfileByID(m_visiting_profile->getFriends()[i]); - row->push_back(new GUIEngine::ListWidget::ListCell(friend_profile->getUserName(),-1,3)); + row->push_back(new GUIEngine::ListWidget::ListCell(friend_profile->getUserName(),-1,2)); + if(m_visiting_profile->isCurrentUser()) + { + Profile::RelationInfo * relation_info = friend_profile->getRelationInfo(); + row->push_back(new GUIEngine::ListWidget::ListCell(relation_info->getDate(),-1,1, true)); + irr::core::stringw status(""); + if(relation_info->isPending()) + { + status = (relation_info->isAsker() ? _("Pending") : _("New request")); + } + else + status = (relation_info->isOnline() ? _("Online") : _("Offline")); + row->push_back(new GUIEngine::ListWidget::ListCell(status,-1,2, true)); + } m_friends_list_widget->addItem("friend", row); } m_waiting_for_friends = false; diff --git a/src/states_screens/online_profile_friends.hpp b/src/states_screens/online_profile_friends.hpp index f3c4571ff..c73f184f3 100644 --- a/src/states_screens/online_profile_friends.hpp +++ b/src/states_screens/online_profile_friends.hpp @@ -46,6 +46,7 @@ private: int m_selected_friend_index; bool m_waiting_for_friends; + bool m_own_profile; public: friend class GUIEngine::ScreenSingleton;