Moved getProfile from CurrentUser to PlayerManager::getCurrentOnlineProfile().
This commit is contained in:
parent
70cb9cec59
commit
5ec71c5b06
@ -83,6 +83,14 @@ PlayerManager::OnlineState PlayerManager::getCurrentOnlineState()
|
|||||||
{
|
{
|
||||||
return (OnlineState)getCurrentUser()->getUserState();
|
return (OnlineState)getCurrentUser()->getUserState();
|
||||||
} // getCurrentOnlineState
|
} // getCurrentOnlineState
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
/** Returns the current online profile (which is the list of all achievements
|
||||||
|
* and friends).
|
||||||
|
*/
|
||||||
|
Online::OnlineProfile* PlayerManager::getCurrentOnlineProfile()
|
||||||
|
{
|
||||||
|
return getCurrentUser()->getProfile();
|
||||||
|
} // getCurrentOnlineProfile
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
/** Constructor.
|
/** Constructor.
|
||||||
|
@ -31,10 +31,11 @@
|
|||||||
|
|
||||||
class AchievementsStatus;
|
class AchievementsStatus;
|
||||||
|
|
||||||
namespace online
|
namespace Online
|
||||||
{
|
{
|
||||||
class CurrentUser;
|
class CurrentUser;
|
||||||
class HTTPRequest;
|
class HTTPRequest;
|
||||||
|
class OnlineProfile;
|
||||||
}
|
}
|
||||||
class PlayerProfile;
|
class PlayerProfile;
|
||||||
|
|
||||||
@ -99,6 +100,7 @@ public:
|
|||||||
const std::string &php_name = "");
|
const std::string &php_name = "");
|
||||||
static unsigned int getCurrentOnlineId();
|
static unsigned int getCurrentOnlineId();
|
||||||
static bool isCurrentLoggedIn();
|
static bool isCurrentLoggedIn();
|
||||||
|
static Online::OnlineProfile* getCurrentOnlineProfile();
|
||||||
|
|
||||||
/** The online state a player can be in. */
|
/** The online state a player can be in. */
|
||||||
enum OnlineState
|
enum OnlineState
|
||||||
|
@ -377,7 +377,7 @@ void ClientLobbyRoomProtocol::connectionAccepted(Event* event)
|
|||||||
NetworkPlayerProfile* profile = new NetworkPlayerProfile();
|
NetworkPlayerProfile* profile = new NetworkPlayerProfile();
|
||||||
profile->kart_name = "";
|
profile->kart_name = "";
|
||||||
profile->race_id = data.gui8(1);
|
profile->race_id = data.gui8(1);
|
||||||
profile->user_profile = PlayerManager::getCurrentUser()->getProfile();
|
profile->user_profile = PlayerManager::getCurrentOnlineProfile();
|
||||||
m_setup->addPlayer(profile);
|
m_setup->addPlayer(profile);
|
||||||
// connection token
|
// connection token
|
||||||
uint32_t token = data.gui32(3);
|
uint32_t token = data.gui32(3);
|
||||||
|
@ -106,7 +106,8 @@ void StartGameProtocol::update()
|
|||||||
// have to add self first
|
// have to add self first
|
||||||
for (unsigned int i = 0; i < players.size(); i++)
|
for (unsigned int i = 0; i < players.size(); i++)
|
||||||
{
|
{
|
||||||
bool is_me = (players[i]->user_profile == PlayerManager::getCurrentUser()->getProfile());
|
bool is_me = (players[i]->user_profile ==
|
||||||
|
PlayerManager::getCurrentOnlineProfile());
|
||||||
if (is_me)
|
if (is_me)
|
||||||
{
|
{
|
||||||
NetworkPlayerProfile* profile = players[i];
|
NetworkPlayerProfile* profile = players[i];
|
||||||
@ -134,7 +135,8 @@ void StartGameProtocol::update()
|
|||||||
}
|
}
|
||||||
for (unsigned int i = 0; i < players.size(); i++)
|
for (unsigned int i = 0; i < players.size(); i++)
|
||||||
{
|
{
|
||||||
bool is_me = (players[i]->user_profile == PlayerManager::getCurrentUser()->getProfile());
|
bool is_me = (players[i]->user_profile ==
|
||||||
|
PlayerManager::getCurrentOnlineProfile());
|
||||||
NetworkPlayerProfile* profile = players[i];
|
NetworkPlayerProfile* profile = players[i];
|
||||||
RemoteKartInfo rki(profile->race_id, profile->kart_name,
|
RemoteKartInfo rki(profile->race_id, profile->kart_name,
|
||||||
profile->user_profile->getUserName(), profile->race_id, !is_me);
|
profile->user_profile->getUserName(), profile->race_id, !is_me);
|
||||||
|
@ -91,9 +91,14 @@ namespace Online
|
|||||||
// access to them. FIXME
|
// access to them. FIXME
|
||||||
|
|
||||||
// FIXME: This apparently does not compile on linux :(
|
// FIXME: This apparently does not compile on linux :(
|
||||||
// So I'll make this all public for now again
|
// So for now (while this is needed) I'll only add this on
|
||||||
// friend class PlayerManager;
|
// windows only (where it works).
|
||||||
|
#ifdef WIN32
|
||||||
|
friend class PlayerManager;
|
||||||
|
private:
|
||||||
|
#else
|
||||||
public:
|
public:
|
||||||
|
#endif
|
||||||
uint32_t getID() const;
|
uint32_t getID() const;
|
||||||
void setUserDetails(HTTPRequest *request,
|
void setUserDetails(HTTPRequest *request,
|
||||||
const std::string &action,
|
const std::string &action,
|
||||||
@ -110,6 +115,10 @@ namespace Online
|
|||||||
};
|
};
|
||||||
UserState m_state;
|
UserState m_state;
|
||||||
const UserState getUserState() const { return m_state; }
|
const UserState getUserState() const { return m_state; }
|
||||||
|
// ----------------------------------------------------------------
|
||||||
|
/** Returns a pointer to the profile associated with the current
|
||||||
|
* user. */
|
||||||
|
OnlineProfile* getProfile() const { return m_profile; }
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -131,10 +140,6 @@ namespace Online
|
|||||||
/** Returns the session token of the signed in user. */
|
/** Returns the session token of the signed in user. */
|
||||||
const std::string& getToken() const { return m_token; }
|
const std::string& getToken() const { return m_token; }
|
||||||
// ----------------------------------------------------------------
|
// ----------------------------------------------------------------
|
||||||
/** Returns a pointer to the profile associated with the current
|
|
||||||
* user. */
|
|
||||||
OnlineProfile* getProfile() const { return m_profile; }
|
|
||||||
// ----------------------------------------------------------------
|
|
||||||
|
|
||||||
}; // class CurrentUser
|
}; // class CurrentUser
|
||||||
|
|
||||||
|
@ -35,35 +35,38 @@ using namespace irr;
|
|||||||
using namespace irr::gui;
|
using namespace irr::gui;
|
||||||
using namespace Online;
|
using namespace Online;
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
UserInfoDialog::UserInfoDialog(uint32_t showing_id, const core::stringw info, bool error, bool from_queue)
|
UserInfoDialog::UserInfoDialog(uint32_t showing_id, const core::stringw info,
|
||||||
: ModalDialog(0.8f,0.8f), m_showing_id(showing_id)
|
bool error, bool from_queue)
|
||||||
|
: ModalDialog(0.8f,0.8f), m_showing_id(showing_id)
|
||||||
{
|
{
|
||||||
m_error = error;
|
m_error = error;
|
||||||
m_info = info;
|
m_info = info;
|
||||||
if(!from_queue) load();
|
if(!from_queue) load();
|
||||||
}
|
} // UserInfoDialog
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
void UserInfoDialog::load()
|
void UserInfoDialog::load()
|
||||||
{
|
{
|
||||||
loadFromFile("online/user_info_dialog.stkgui");
|
loadFromFile("online/user_info_dialog.stkgui");
|
||||||
if(m_error)
|
if(m_error)
|
||||||
m_info_widget->setErrorColor();
|
m_info_widget->setErrorColor();
|
||||||
m_name_widget->setText(m_profile->getUserName(),false);
|
m_name_widget->setText(m_online_profile->getUserName(),false);
|
||||||
m_info_widget->setText(m_info, false);
|
m_info_widget->setText(m_info, false);
|
||||||
if(m_remove_widget->isVisible() && !m_profile->isFriend())
|
if(m_remove_widget->isVisible() && !m_online_profile->isFriend())
|
||||||
m_remove_widget->setLabel("Cancel Request");
|
m_remove_widget->setLabel("Cancel Request");
|
||||||
}
|
} // load
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
void UserInfoDialog::beforeAddingWidgets()
|
void UserInfoDialog::beforeAddingWidgets()
|
||||||
{
|
{
|
||||||
m_profile = ProfileManager::get()->getProfileByID(m_showing_id);
|
m_online_profile = ProfileManager::get()->getProfileByID(m_showing_id);
|
||||||
|
|
||||||
// Avoid a crash in case that an invalid m_showing_id is given
|
// Avoid a crash in case that an invalid m_showing_id is given
|
||||||
// (which can only happen if there's a problem on the server).
|
// (which can only happen if there's a problem on the server).
|
||||||
if (!m_profile)
|
if (!m_online_profile)
|
||||||
m_profile = PlayerManager::getCurrentUser()->getProfile();
|
m_online_profile = PlayerManager::getCurrentOnlineProfile();
|
||||||
m_self_destroy = false;
|
m_self_destroy = false;
|
||||||
m_enter_profile = false;
|
m_enter_profile = false;
|
||||||
m_processing = false;
|
m_processing = false;
|
||||||
@ -91,17 +94,18 @@ void UserInfoDialog::beforeAddingWidgets()
|
|||||||
m_accept_widget->setVisible(false);
|
m_accept_widget->setVisible(false);
|
||||||
m_decline_widget->setVisible(false);
|
m_decline_widget->setVisible(false);
|
||||||
m_remove_widget->setVisible(false);
|
m_remove_widget->setVisible(false);
|
||||||
if(m_profile->isCurrentUser())
|
if(m_online_profile->isCurrentUser())
|
||||||
{
|
{
|
||||||
m_friend_widget->setVisible(false);
|
m_friend_widget->setVisible(false);
|
||||||
}
|
}
|
||||||
if(m_profile->isFriend())
|
if(m_online_profile->isFriend())
|
||||||
{
|
{
|
||||||
m_friend_widget->setVisible(false);
|
m_friend_widget->setVisible(false);
|
||||||
m_remove_widget->setVisible(true);
|
m_remove_widget->setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
OnlineProfile::RelationInfo * relation_info = m_profile->getRelationInfo();
|
OnlineProfile::RelationInfo * relation_info =
|
||||||
|
m_online_profile->getRelationInfo();
|
||||||
if(relation_info != NULL)
|
if(relation_info != NULL)
|
||||||
{
|
{
|
||||||
if(relation_info->isPending())
|
if(relation_info->isPending())
|
||||||
@ -119,14 +123,12 @@ void UserInfoDialog::beforeAddingWidgets()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // beforeAddingWidgets
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
UserInfoDialog::~UserInfoDialog()
|
UserInfoDialog::~UserInfoDialog()
|
||||||
{
|
{
|
||||||
}
|
} // ~UserInfoDialog
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
/** Sends a friend request to the server. When the request is finished, it
|
/** Sends a friend request to the server. When the request is finished, it
|
||||||
@ -148,7 +150,7 @@ void UserInfoDialog::sendFriendRequest()
|
|||||||
core::stringw info_text("");
|
core::stringw info_text("");
|
||||||
if (isSuccess())
|
if (isSuccess())
|
||||||
{
|
{
|
||||||
PlayerManager::getCurrentUser()->getProfile()->addFriend(id);
|
PlayerManager::getCurrentOnlineProfile()->addFriend(id);
|
||||||
OnlineProfile::RelationInfo *info =
|
OnlineProfile::RelationInfo *info =
|
||||||
new OnlineProfile::RelationInfo(_("Today"), false,
|
new OnlineProfile::RelationInfo(_("Today"), false,
|
||||||
true, false);
|
true, false);
|
||||||
@ -171,7 +173,7 @@ void UserInfoDialog::sendFriendRequest()
|
|||||||
|
|
||||||
FriendRequest *request = new FriendRequest();
|
FriendRequest *request = new FriendRequest();
|
||||||
PlayerManager::setUserDetails(request, "friend-request");
|
PlayerManager::setUserDetails(request, "friend-request");
|
||||||
request->addParameter("friendid", m_profile->getID());
|
request->addParameter("friendid", m_online_profile->getID());
|
||||||
request->queue();
|
request->queue();
|
||||||
|
|
||||||
m_processing = true;
|
m_processing = true;
|
||||||
@ -222,7 +224,7 @@ void UserInfoDialog::acceptFriendRequest()
|
|||||||
|
|
||||||
AcceptFriendRequest *request = new AcceptFriendRequest();
|
AcceptFriendRequest *request = new AcceptFriendRequest();
|
||||||
PlayerManager::setUserDetails(request, "accept-friend-request");
|
PlayerManager::setUserDetails(request, "accept-friend-request");
|
||||||
request->addParameter("friendid", m_profile->getID());
|
request->addParameter("friendid", m_online_profile->getID());
|
||||||
request->queue();
|
request->queue();
|
||||||
m_processing = true;
|
m_processing = true;
|
||||||
m_options_widget->setDeactivated();
|
m_options_widget->setDeactivated();
|
||||||
@ -249,7 +251,7 @@ void UserInfoDialog::declineFriendRequest()
|
|||||||
core::stringw info_text("");
|
core::stringw info_text("");
|
||||||
if (isSuccess())
|
if (isSuccess())
|
||||||
{
|
{
|
||||||
PlayerManager::getCurrentUser()->getProfile()->removeFriend(id);
|
PlayerManager::getCurrentOnlineProfile()->removeFriend(id);
|
||||||
ProfileManager::get()->moveToCache(id);
|
ProfileManager::get()->moveToCache(id);
|
||||||
ProfileManager::get()->getProfileByID(id)
|
ProfileManager::get()->getProfileByID(id)
|
||||||
->deleteRelationalInfo();
|
->deleteRelationalInfo();
|
||||||
@ -268,7 +270,7 @@ void UserInfoDialog::declineFriendRequest()
|
|||||||
// ----------------------------------------------------------------
|
// ----------------------------------------------------------------
|
||||||
DeclineFriendRequest *request = new DeclineFriendRequest();
|
DeclineFriendRequest *request = new DeclineFriendRequest();
|
||||||
PlayerManager::setUserDetails(request, "decline-friend-request");
|
PlayerManager::setUserDetails(request, "decline-friend-request");
|
||||||
request->addParameter("friendid", m_profile->getID());
|
request->addParameter("friendid", m_online_profile->getID());
|
||||||
request->queue();
|
request->queue();
|
||||||
|
|
||||||
m_processing = true;
|
m_processing = true;
|
||||||
@ -290,7 +292,7 @@ void UserInfoDialog::removeExistingFriend()
|
|||||||
core::stringw info_text("");
|
core::stringw info_text("");
|
||||||
if (isSuccess())
|
if (isSuccess())
|
||||||
{
|
{
|
||||||
PlayerManager::getCurrentUser()->getProfile()->removeFriend(m_id);
|
PlayerManager::getCurrentOnlineProfile()->removeFriend(m_id);
|
||||||
ProfileManager *pm = ProfileManager::get();
|
ProfileManager *pm = ProfileManager::get();
|
||||||
pm->moveToCache(m_id);
|
pm->moveToCache(m_id);
|
||||||
pm->getProfileByID(m_id)->deleteRelationalInfo();
|
pm->getProfileByID(m_id)->deleteRelationalInfo();
|
||||||
@ -312,7 +314,7 @@ void UserInfoDialog::removeExistingFriend()
|
|||||||
}; // RemoveFriendRequest
|
}; // RemoveFriendRequest
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
int friend_id = m_profile->getID();
|
int friend_id = m_online_profile->getID();
|
||||||
RemoveFriendRequest * request = new RemoveFriendRequest(friend_id);
|
RemoveFriendRequest * request = new RemoveFriendRequest(friend_id);
|
||||||
PlayerManager::setUserDetails(request, "remove-friend");
|
PlayerManager::setUserDetails(request, "remove-friend");
|
||||||
request->addParameter("friendid", friend_id);
|
request->addParameter("friendid", friend_id);
|
||||||
@ -338,7 +340,7 @@ void UserInfoDialog::removePendingFriend()
|
|||||||
core::stringw info_text("");
|
core::stringw info_text("");
|
||||||
if (isSuccess())
|
if (isSuccess())
|
||||||
{
|
{
|
||||||
PlayerManager::getCurrentUser()->getProfile()->removeFriend(id);
|
PlayerManager::getCurrentOnlineProfile()->removeFriend(id);
|
||||||
ProfileManager *pm = ProfileManager::get();
|
ProfileManager *pm = ProfileManager::get();
|
||||||
pm->moveToCache(id);
|
pm->moveToCache(id);
|
||||||
pm->getProfileByID(id)->deleteRelationalInfo();
|
pm->getProfileByID(id)->deleteRelationalInfo();
|
||||||
@ -359,7 +361,7 @@ void UserInfoDialog::removePendingFriend()
|
|||||||
|
|
||||||
CancelFriendRequest * request = new CancelFriendRequest();
|
CancelFriendRequest * request = new CancelFriendRequest();
|
||||||
PlayerManager::setUserDetails(request, "cancel-friend-request");
|
PlayerManager::setUserDetails(request, "cancel-friend-request");
|
||||||
request->addParameter("friendid", m_profile->getID());
|
request->addParameter("friendid", m_online_profile->getID());
|
||||||
request->queue();
|
request->queue();
|
||||||
} // removePendingFriend
|
} // removePendingFriend
|
||||||
|
|
||||||
@ -377,7 +379,7 @@ GUIEngine::EventPropagation UserInfoDialog::processEvent(const std::string& even
|
|||||||
}
|
}
|
||||||
else if(selection == m_enter_widget->m_properties[PROP_ID])
|
else if(selection == m_enter_widget->m_properties[PROP_ID])
|
||||||
{
|
{
|
||||||
ProfileManager::get()->setVisiting(m_profile->getID());
|
ProfileManager::get()->setVisiting(m_online_profile->getID());
|
||||||
m_enter_profile = true;
|
m_enter_profile = true;
|
||||||
m_options_widget->setDeactivated();
|
m_options_widget->setDeactivated();
|
||||||
return GUIEngine::EVENT_BLOCK;
|
return GUIEngine::EVENT_BLOCK;
|
||||||
@ -389,8 +391,8 @@ GUIEngine::EventPropagation UserInfoDialog::processEvent(const std::string& even
|
|||||||
}
|
}
|
||||||
else if(selection == m_remove_widget->m_properties[PROP_ID])
|
else if(selection == m_remove_widget->m_properties[PROP_ID])
|
||||||
{
|
{
|
||||||
if (m_profile->getRelationInfo() &&
|
if (m_online_profile->getRelationInfo() &&
|
||||||
m_profile->getRelationInfo()->isPending() )
|
m_online_profile->getRelationInfo()->isPending() )
|
||||||
removePendingFriend();
|
removePendingFriend();
|
||||||
else
|
else
|
||||||
removeExistingFriend();
|
removeExistingFriend();
|
||||||
@ -411,20 +413,19 @@ GUIEngine::EventPropagation UserInfoDialog::processEvent(const std::string& even
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return GUIEngine::EVENT_LET;
|
return GUIEngine::EVENT_LET;
|
||||||
}
|
} // processEvent
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
void UserInfoDialog::deactivate()
|
void UserInfoDialog::deactivate()
|
||||||
{
|
{
|
||||||
m_options_widget->setDeactivated();
|
m_options_widget->setDeactivated();
|
||||||
}
|
} // deactivate
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
void UserInfoDialog::activate()
|
void UserInfoDialog::activate()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
} // activate
|
||||||
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -445,7 +446,7 @@ bool UserInfoDialog::onEscapePressed()
|
|||||||
if (m_cancel_widget->isActivated())
|
if (m_cancel_widget->isActivated())
|
||||||
m_self_destroy = true;
|
m_self_destroy = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
} // onEscapePressed
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -465,4 +466,4 @@ void UserInfoDialog::onUpdate(float dt)
|
|||||||
StateManager::get()->replaceTopMostScreen(OnlineProfileOverview::getInstance());
|
StateManager::get()->replaceTopMostScreen(OnlineProfileOverview::getInstance());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
} // onUpdate
|
||||||
|
@ -44,7 +44,7 @@ private:
|
|||||||
irr::core::stringw m_info;
|
irr::core::stringw m_info;
|
||||||
|
|
||||||
const uint32_t m_showing_id;
|
const uint32_t m_showing_id;
|
||||||
Online::OnlineProfile * m_profile;
|
Online::OnlineProfile * m_online_profile;
|
||||||
|
|
||||||
GUIEngine::LabelWidget * m_name_widget;
|
GUIEngine::LabelWidget * m_name_widget;
|
||||||
GUIEngine::LabelWidget * m_info_widget;
|
GUIEngine::LabelWidget * m_info_widget;
|
||||||
|
@ -68,7 +68,7 @@ void NetworkKartSelectionScreen::init()
|
|||||||
|
|
||||||
for (unsigned int i = 0; i < players.size(); i++)
|
for (unsigned int i = 0; i < players.size(); i++)
|
||||||
{
|
{
|
||||||
if (players[i]->user_profile == PlayerManager::getCurrentUser()->getProfile())
|
if (players[i]->user_profile == PlayerManager::getCurrentOnlineProfile())
|
||||||
{
|
{
|
||||||
m_id_mapping.insert(m_id_mapping.begin(),players[i]->race_id); //!< first kart widget always me
|
m_id_mapping.insert(m_id_mapping.begin(),players[i]->race_id); //!< first kart widget always me
|
||||||
Log::info("NKSS", "Insert %d at pos 0", players[i]->race_id);
|
Log::info("NKSS", "Insert %d at pos 0", players[i]->race_id);
|
||||||
|
Loading…
Reference in New Issue
Block a user