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
This commit is contained in:
unitraxx 2013-08-17 21:39:51 +00:00
parent f0cf45b9b4
commit 66c9c1fac7
6 changed files with 56 additions and 28 deletions

View File

@ -1,6 +1,8 @@
<stkgui>
<div x="1%" y="1%" width="98%" height="98%" layout="vertical-row" >
<icon-button id="back" x="0" y="0" height="8%" icon="gui/back.png"/>
<div x="1%" y="2%" width="98%" height="96%" layout="vertical-row" >
<header id="title" text_align="center" width="80%" align="center" text="..."/>
@ -11,27 +13,23 @@
<icon-button id="tab_friends" width="128" height="128" icon="gui/options_players.png" I18N="Section in the profile menu" text="Friends"/>
</tabs>
<box proportion="1" width="100%" layout="vertical-row">
<div x="1%" y="2%" width="98%" height="96%" layout="horizontal-row" >
<div proportion="2" height="100%" layout="vertical-row">
<box proportion="2" width="100%" align="center" layout="vertical-row" padding="6">
<box proportion="1" width="100%" layout="vertical-row" padding="6">
<list id="friends_list" x="0" y="0" width="100%" height="100%"/>
</box>
<div id="search_div" height="fit" width="100%" layout="vertical-row">
<spacer width="10" height="10"/>
<box height="fit" width="100%" layout="vertical-row">
<label height="fit" text_align="left" I18N="Profile friends" text="Look for more friends:"/>
<spacer width="10" height="10"/>
<div height="fit" width="100%" layout="horizontal-row" align="center">
<textbox id="search_box" proportion="1" height="fit"/>
<spacer width="10" height="10"/>
<spacer width="10" height="100%"/>
<button id="search_button" height="100%" width="fit" text="Search" />
</div>
</div>
<spacer width="2%" height="10"/>
<div proportion="1" height="100%" layout="horizontal-row" > </div>
</div>
</box>
</div>
</div>
<icon-button id="back" x="0" y="0" height="8%" icon="gui/back.png"/>
</stkgui>

View File

@ -1,6 +1,7 @@
<stkgui>
<icon-button id="back" x="0" y="0" height="8%" icon="gui/back.png"/>
<div x="1%" y="0%" width="98%" height="99%" layout="vertical-row" >
<icon-button id="back" x="0" y="0" height="8%" icon="gui/back.png"/>
<header text_align="center" height="fit" text="User search" align="center"/>
<spacer width="10" height="10"/>
@ -19,4 +20,5 @@
</div>
</stkgui>

View File

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

View File

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

View File

@ -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<GUIEngine::ListWidget::ListCell> * row = new PtrVector<GUIEngine::ListWidget::ListCell>;
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;

View File

@ -46,6 +46,7 @@ private:
int m_selected_friend_index;
bool m_waiting_for_friends;
bool m_own_profile;
public:
friend class GUIEngine::ScreenSingleton<OnlineProfileFriends>;