Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
a3a851b300
@ -132,8 +132,11 @@ void STKMeshSceneNode::drawGlow(const GLMesh &mesh)
|
||||
computeMVP(ModelViewProjectionMatrix);
|
||||
MeshShader::ColorizeShader::setUniforms(ModelViewProjectionMatrix, cb->getRed(), cb->getGreen(), cb->getBlue());
|
||||
|
||||
glBindVertexArray(mesh.vao_glow_pass);
|
||||
glDrawElements(ptype, count, itype, 0);
|
||||
if (mesh.vao_glow_pass != 0)
|
||||
{
|
||||
glBindVertexArray(mesh.vao_glow_pass);
|
||||
glDrawElements(ptype, count, itype, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void STKMeshSceneNode::drawDisplace(const GLMesh &mesh)
|
||||
|
@ -30,10 +30,10 @@
|
||||
#include "online/profile_manager.hpp"
|
||||
#include "online/servers_manager.hpp"
|
||||
#include "states_screens/login_screen.hpp"
|
||||
#include "states_screens/online_profile_friends.hpp"
|
||||
#include "states_screens/dialogs/change_password_dialog.hpp"
|
||||
#include "states_screens/dialogs/user_info_dialog.hpp"
|
||||
#include "states_screens/dialogs/notification_dialog.hpp"
|
||||
#include "states_screens/online_profile_friends.hpp"
|
||||
#include "utils/log.hpp"
|
||||
#include "utils/translation.hpp"
|
||||
|
||||
@ -88,39 +88,6 @@ namespace Online
|
||||
m_profile = NULL;
|
||||
} // CurrentUser
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
const XMLRequest * CurrentUser::requestRecovery(const core::stringw &username,
|
||||
const core::stringw &email)
|
||||
{
|
||||
assert(m_state == US_SIGNED_OUT || m_state == US_GUEST);
|
||||
XMLRequest * request = new XMLRequest();
|
||||
request->setServerURL("client-user.php");
|
||||
request->addParameter("action", "recovery");
|
||||
request->addParameter("username", username);
|
||||
request->addParameter("email", email);
|
||||
request->queue();
|
||||
return request;
|
||||
} // requestRecovery
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
const XMLRequest * CurrentUser::requestSignUp(const core::stringw &username,
|
||||
const core::stringw &password,
|
||||
const core::stringw &password_confirm,
|
||||
const core::stringw &email)
|
||||
{
|
||||
assert(m_state == US_SIGNED_OUT || m_state == US_GUEST);
|
||||
XMLRequest * request = new XMLRequest();
|
||||
request->setServerURL("client-user.php");
|
||||
request->addParameter("action", "register");
|
||||
request->addParameter("username", username);
|
||||
request->addParameter("password", password);
|
||||
request->addParameter("password_confirm", password_confirm);
|
||||
request->addParameter("email", email);
|
||||
request->addParameter("terms", "on");
|
||||
request->queue();
|
||||
return request;
|
||||
} // requestSignUp
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Request a login using the saved credentials of the user.
|
||||
*/
|
||||
@ -266,34 +233,6 @@ namespace Online
|
||||
UserConfigParams::m_saved_session = false;
|
||||
} // signOut
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
const CurrentUser::ServerCreationRequest*
|
||||
CurrentUser::requestServerCreation(const core::stringw &name,
|
||||
int max_players)
|
||||
{
|
||||
assert(m_state == US_SIGNED_IN);
|
||||
ServerCreationRequest * request = new ServerCreationRequest();
|
||||
request->setServerURL("client-user.php");
|
||||
request->addParameter("action", "create_server");
|
||||
request->addParameter("token", getToken());
|
||||
request->addParameter("userid", getID());
|
||||
request->addParameter("name", name);
|
||||
request->addParameter("max_players", max_players);
|
||||
request->queue();
|
||||
return request;
|
||||
} // requestServerCreation
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
void CurrentUser::ServerCreationRequest::callback()
|
||||
{
|
||||
if(isSuccess())
|
||||
{
|
||||
Server * server = new Server(*getXMLData()->getNode("server"));
|
||||
ServersManager::get()->addServer(server);
|
||||
m_created_server_id = server->getServerId();
|
||||
}
|
||||
} // ServerCreationRequest::callback
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
CurrentUser::ServerJoinRequest*
|
||||
CurrentUser::requestServerJoin(uint32_t server_id,
|
||||
@ -397,138 +336,6 @@ namespace Online
|
||||
} // requestUserSearch
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** A request to the server, to invite a user to be friends.
|
||||
* \param friend_id The id of the user which has to be friended.
|
||||
*/
|
||||
void CurrentUser::requestFriendRequest(const uint32_t friend_id) const
|
||||
{
|
||||
assert(m_state == US_SIGNED_IN);
|
||||
CurrentUser::FriendRequest * request = new CurrentUser::FriendRequest();
|
||||
request->setServerURL("client-user.php");
|
||||
request->addParameter("action", "friend-request");
|
||||
request->addParameter("token", getToken());
|
||||
request->addParameter("userid", getID());
|
||||
request->addParameter("friendid", friend_id);
|
||||
request->queue();
|
||||
} // requestFriendRequest
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Callback for the request to send a friend invitation. Shows a
|
||||
* confirmation message and takes care of updating all the cached
|
||||
* information.
|
||||
*/
|
||||
void CurrentUser::FriendRequest::callback()
|
||||
{
|
||||
uint32_t id(0);
|
||||
getXMLData()->get("friendid", &id);
|
||||
core::stringw info_text("");
|
||||
if(isSuccess())
|
||||
{
|
||||
CurrentUser::get()->getProfile()->addFriend(id);
|
||||
OnlineProfile::RelationInfo *info =
|
||||
new OnlineProfile::RelationInfo(_("Today"), false, true, false);
|
||||
ProfileManager::get()->getProfileByID(id)->setRelationInfo(info);
|
||||
OnlineProfileFriends::getInstance()->refreshFriendsList();
|
||||
info_text = _("Friend request send!");
|
||||
}
|
||||
else
|
||||
info_text = getInfo();
|
||||
UserInfoDialog *dialog = new UserInfoDialog(id, info_text,
|
||||
!isSuccess(), true);
|
||||
GUIEngine::DialogQueue::get()->pushDialog(dialog, true);
|
||||
} // FriendRequest::callback
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** A request to the server, to accept a friend request.
|
||||
* \param friend_id The id of the user of which the request has to be
|
||||
* accepted.
|
||||
*/
|
||||
void CurrentUser::requestAcceptFriend(const uint32_t friend_id) const
|
||||
{
|
||||
assert(m_state == US_SIGNED_IN);
|
||||
CurrentUser::AcceptFriendRequest * request =
|
||||
new CurrentUser::AcceptFriendRequest();
|
||||
request->setServerURL("client-user.php");
|
||||
request->addParameter("action", "accept-friend-request");
|
||||
request->addParameter("token", getToken());
|
||||
request->addParameter("userid", getID());
|
||||
request->addParameter("friendid", friend_id);
|
||||
request->queue();
|
||||
} // requestAcceptFriend
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Callback for the request to accept a friend invitation. Shows a
|
||||
* confirmation message and takes care of updating all the cached
|
||||
* information.
|
||||
*/
|
||||
void CurrentUser::AcceptFriendRequest::callback()
|
||||
{
|
||||
uint32_t id(0);
|
||||
getXMLData()->get("friendid", &id);
|
||||
core::stringw info_text("");
|
||||
if(isSuccess())
|
||||
{
|
||||
OnlineProfile * profile = ProfileManager::get()->getProfileByID(id);
|
||||
profile->setFriend();
|
||||
OnlineProfile::RelationInfo *info =
|
||||
new OnlineProfile::RelationInfo(_("Today"), false, false, true);
|
||||
profile->setRelationInfo(info);
|
||||
OnlineProfileFriends::getInstance()->refreshFriendsList();
|
||||
info_text = _("Friend request accepted!");
|
||||
}
|
||||
else
|
||||
info_text = getInfo();
|
||||
GUIEngine::DialogQueue::get()->pushDialog(
|
||||
new UserInfoDialog(id, info_text,!isSuccess(), true), true);
|
||||
} // AcceptFriendRequest::callback
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** A request to the server, to decline a friend request.
|
||||
* \param friend_id The id of the user of which the request has to be
|
||||
* declined.
|
||||
*/
|
||||
void CurrentUser::requestDeclineFriend(const uint32_t friend_id) const
|
||||
{
|
||||
assert(m_state == US_SIGNED_IN);
|
||||
CurrentUser::DeclineFriendRequest * request =
|
||||
new CurrentUser::DeclineFriendRequest();
|
||||
request->setServerURL("client-user.php");
|
||||
request->addParameter("action", "decline-friend-request");
|
||||
request->addParameter("token", getToken());
|
||||
request->addParameter("userid", getID());
|
||||
request->addParameter("friendid", friend_id);
|
||||
request->queue();
|
||||
} // requestDeclineFriend
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Callback for the request to decline a friend invitation. Shows a
|
||||
* confirmation message and takes care of updating all the cached
|
||||
* information.
|
||||
*/
|
||||
void CurrentUser::DeclineFriendRequest::callback()
|
||||
{
|
||||
uint32_t id(0);
|
||||
getXMLData()->get("friendid", &id);
|
||||
core::stringw info_text("");
|
||||
if(isSuccess())
|
||||
{
|
||||
CurrentUser::get()->getProfile()->removeFriend(id);
|
||||
ProfileManager::get()->moveToCache(id);
|
||||
ProfileManager::get()->getProfileByID(id)->deleteRelationalInfo();
|
||||
OnlineProfileFriends::getInstance()->refreshFriendsList();
|
||||
info_text = _("Friend request declined!");
|
||||
}
|
||||
else
|
||||
info_text = getInfo();
|
||||
GUIEngine::DialogQueue::get()->pushDialog(
|
||||
new UserInfoDialog(id, info_text,!isSuccess(), true), true);
|
||||
} // DeclineFriendRequest::callback
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** A request to the server, to cancel a pending friend request.
|
||||
* \param friend_id The id of the user of which the request has to be
|
||||
* canceled.
|
||||
*/
|
||||
void CurrentUser::requestCancelFriend(const uint32_t friend_id) const
|
||||
{
|
||||
assert(m_state == US_SIGNED_IN);
|
||||
@ -575,7 +382,7 @@ namespace Online
|
||||
{
|
||||
assert(m_state == US_SIGNED_IN);
|
||||
CurrentUser::RemoveFriendRequest * request =
|
||||
new CurrentUser::RemoveFriendRequest();
|
||||
new CurrentUser::RemoveFriendRequest(friend_id);
|
||||
request->setServerURL("client-user.php");
|
||||
request->addParameter("action", "remove-friend");
|
||||
request->addParameter("token", getToken());
|
||||
@ -590,20 +397,18 @@ namespace Online
|
||||
*/
|
||||
void CurrentUser::RemoveFriendRequest::callback()
|
||||
{
|
||||
uint32_t id(0);
|
||||
getXMLData()->get("friendid", &id);
|
||||
core::stringw info_text("");
|
||||
if(isSuccess())
|
||||
{
|
||||
CurrentUser::get()->getProfile()->removeFriend(id);
|
||||
ProfileManager::get()->moveToCache(id);
|
||||
ProfileManager::get()->getProfileByID(id)->deleteRelationalInfo();
|
||||
CurrentUser::get()->getProfile()->removeFriend(m_id);
|
||||
ProfileManager::get()->moveToCache(m_id);
|
||||
ProfileManager::get()->getProfileByID(m_id)->deleteRelationalInfo();
|
||||
OnlineProfileFriends::getInstance()->refreshFriendsList();
|
||||
info_text = _("Friend removed!");
|
||||
}
|
||||
else
|
||||
info_text = getInfo();
|
||||
UserInfoDialog *info = new UserInfoDialog(id, info_text,!isSuccess(),
|
||||
UserInfoDialog *info = new UserInfoDialog(m_id, info_text,!isSuccess(),
|
||||
true);
|
||||
GUIEngine::DialogQueue::get()->pushDialog(info, true);
|
||||
|
||||
|
@ -72,19 +72,6 @@ namespace Online
|
||||
SignOutRequest() : XMLRequest(true,/*priority*/10) {}
|
||||
}; // SignOutRequest
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
class ServerCreationRequest : public XMLRequest {
|
||||
virtual void callback ();
|
||||
uint32_t m_created_server_id;
|
||||
public:
|
||||
ServerCreationRequest() : XMLRequest() {}
|
||||
const uint32_t getCreatedServerID() const
|
||||
{
|
||||
assert(isDone());
|
||||
return m_created_server_id;
|
||||
} // getCreatedServerID
|
||||
}; // ServerCreationRequest
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
|
||||
class ServerJoinRequest : public XMLRequest {
|
||||
@ -100,32 +87,13 @@ namespace Online
|
||||
SetAddonVoteRequest() : XMLRequest() {}
|
||||
}; // SetAddonVoteRequest
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
class FriendRequest : public XMLRequest {
|
||||
virtual void callback ();
|
||||
public:
|
||||
FriendRequest() : XMLRequest(true) {}
|
||||
}; // FriendRequest
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
class AcceptFriendRequest : public XMLRequest {
|
||||
virtual void callback ();
|
||||
public:
|
||||
AcceptFriendRequest() : XMLRequest(true) {}
|
||||
}; // AcceptFriendRequest
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
class DeclineFriendRequest : public XMLRequest {
|
||||
virtual void callback ();
|
||||
public:
|
||||
DeclineFriendRequest() : XMLRequest(true) {}
|
||||
}; // DeclineFriendRequest
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
class RemoveFriendRequest : public XMLRequest {
|
||||
unsigned int m_id;
|
||||
virtual void callback ();
|
||||
public:
|
||||
RemoveFriendRequest() : XMLRequest(true) {}
|
||||
RemoveFriendRequest(unsigned int id)
|
||||
: XMLRequest(true), m_id(id) {}
|
||||
}; // RemoveFriendRequest
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
@ -168,7 +136,7 @@ namespace Online
|
||||
/**Singleton */
|
||||
static CurrentUser * get();
|
||||
static void deallocate();
|
||||
static void setUserDetails(HTTPRequest *html);
|
||||
static void setUserDetails(HTTPRequest *request);
|
||||
|
||||
void requestSavedSession();
|
||||
SignInRequest * requestSignIn( const irr::core::stringw &username,
|
||||
@ -176,24 +144,12 @@ namespace Online
|
||||
bool save_session,
|
||||
bool request_now = true);
|
||||
void requestSignOut();
|
||||
const ServerCreationRequest * requestServerCreation(const irr::core::stringw &name, int max_players);
|
||||
ServerJoinRequest * requestServerJoin(uint32_t server_id, bool request_now = true);
|
||||
|
||||
|
||||
/** Register */
|
||||
const XMLRequest * requestSignUp( const irr::core::stringw &username,
|
||||
const irr::core::stringw &password,
|
||||
const irr::core::stringw &password_ver,
|
||||
const irr::core::stringw &email);
|
||||
|
||||
const XMLRequest * requestRecovery(const irr::core::stringw &username,
|
||||
const irr::core::stringw &email);
|
||||
|
||||
const XMLRequest * requestGetAddonVote(const std::string & addon_id) const;
|
||||
const SetAddonVoteRequest * requestSetAddonVote(const std::string & addon_id, float rating) const;
|
||||
void requestFriendRequest(const uint32_t friend_id) const;
|
||||
void requestAcceptFriend(const uint32_t friend_id) const;
|
||||
void requestDeclineFriend(const uint32_t friend_id) const;
|
||||
void requestRemoveFriend(const uint32_t friend_id) const;
|
||||
void requestCancelFriend(const uint32_t friend_id) const;
|
||||
void requestPasswordChange( const irr::core::stringw ¤t_password,
|
||||
|
@ -136,15 +136,32 @@ void CreateServerScreen::serverCreationRequest()
|
||||
}
|
||||
else
|
||||
{
|
||||
//m_options_widget->setDeactivated();
|
||||
m_server_creation_request = Online::CurrentUser::get()->requestServerCreation(name, max_players);
|
||||
|
||||
m_server_creation_request = new ServerCreationRequest();
|
||||
CurrentUser::setUserDetails(m_server_creation_request);
|
||||
m_server_creation_request->addParameter("action", "create_server");
|
||||
m_server_creation_request->addParameter("name", name);
|
||||
m_server_creation_request->addParameter("max_players", max_players);
|
||||
m_server_creation_request->queue();
|
||||
|
||||
return;
|
||||
}
|
||||
sfx_manager->quickSound("anvil");
|
||||
}
|
||||
// --------------------------------------------------------------------
|
||||
void CreateServerScreen::ServerCreationRequest::callback()
|
||||
{
|
||||
if (isSuccess())
|
||||
{
|
||||
Server *server = new Server(*getXMLData()->getNode("server"));
|
||||
ServersManager::get()->addServer(server);
|
||||
m_created_server_id = server->getServerId();
|
||||
} // isSuccess
|
||||
} // callback
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void CreateServerScreen::eventCallback(Widget* widget, const std::string& name, const int playerID)
|
||||
void CreateServerScreen::eventCallback(Widget* widget, const std::string& name,
|
||||
const int playerID)
|
||||
{
|
||||
if (name == m_options_widget->m_properties[PROP_ID])
|
||||
{
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "guiengine/screen.hpp"
|
||||
#include "guiengine/widgets.hpp"
|
||||
#include "online/current_user.hpp"
|
||||
#include "online/xml_request.hpp"
|
||||
|
||||
|
||||
namespace GUIEngine { class Widget; class ListWidget; }
|
||||
@ -46,7 +47,22 @@ private:
|
||||
GUIEngine::IconButtonWidget * m_create_widget;
|
||||
GUIEngine::IconButtonWidget * m_cancel_widget;
|
||||
|
||||
const Online::CurrentUser::ServerCreationRequest * m_server_creation_request;
|
||||
// --------------------------------------------------------------------
|
||||
class ServerCreationRequest : public Online::XMLRequest
|
||||
{
|
||||
virtual void callback();
|
||||
uint32_t m_created_server_id;
|
||||
public:
|
||||
const uint32_t getCreatedServerID() const
|
||||
{
|
||||
assert(isDone());
|
||||
return m_created_server_id;
|
||||
} // getCreatedServerID
|
||||
}; // ServerCreationRequest
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
|
||||
ServerCreationRequest *m_server_creation_request;
|
||||
|
||||
/** \brief Sets which widget has to be focused. Depends on the user state. */
|
||||
void setInitialFocus();
|
||||
|
@ -32,25 +32,30 @@ using namespace irr::gui;
|
||||
using namespace Online;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
RecoveryDialog::RecoveryDialog() :
|
||||
ModalDialog(0.8f,0.8f)
|
||||
/** Constructor for the recovery dialog.
|
||||
*/
|
||||
RecoveryDialog::RecoveryDialog() : ModalDialog(0.8f,0.8f)
|
||||
{
|
||||
m_recovery_request = NULL;
|
||||
m_self_destroy = false;
|
||||
m_recovery_request = NULL;
|
||||
m_self_destroy = false;
|
||||
m_show_recovery_input = true;
|
||||
}
|
||||
m_show_recovery_info = false;
|
||||
showRecoveryInput();
|
||||
} // RecoveryDialog
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
/** Destructor, destroys the recovery request.
|
||||
*/
|
||||
RecoveryDialog::~RecoveryDialog()
|
||||
{
|
||||
delete m_recovery_request;
|
||||
}
|
||||
} //~RecoverDialog
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void RecoveryDialog::showRecoveryInput(){
|
||||
/** Shows the input screen to get the account name and email address.
|
||||
*/
|
||||
void RecoveryDialog::showRecoveryInput()
|
||||
{
|
||||
m_show_recovery_input = false;
|
||||
clearWindow();
|
||||
m_phase = Input;
|
||||
@ -72,11 +77,13 @@ void RecoveryDialog::showRecoveryInput(){
|
||||
assert(m_submit_widget != NULL);
|
||||
m_cancel_widget = getWidget<IconButtonWidget>("cancel");
|
||||
assert(m_cancel_widget != NULL);
|
||||
}
|
||||
} // showRecoveryInput
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void RecoveryDialog::showRecoveryInfo(){
|
||||
/** Informs the user that an email will be sent.
|
||||
*/
|
||||
void RecoveryDialog::showRecoveryInfo()
|
||||
{
|
||||
m_show_recovery_info = false;
|
||||
clearWindow();
|
||||
m_phase = Info;
|
||||
@ -89,14 +96,15 @@ void RecoveryDialog::showRecoveryInfo(){
|
||||
assert(m_options_widget != NULL);
|
||||
m_cancel_widget = getWidget<IconButtonWidget>("cancel");
|
||||
assert(m_cancel_widget != NULL);
|
||||
}
|
||||
} // showRecoveryInfo
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
/** Let esc act as cancel.
|
||||
*/
|
||||
bool RecoveryDialog::onEscapePressed()
|
||||
{
|
||||
return m_cancel_widget->isActivated();
|
||||
}
|
||||
} // onEscapePressed
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
@ -104,29 +112,40 @@ void RecoveryDialog::processInput()
|
||||
{
|
||||
const core::stringw username = m_username_widget->getText().trim();
|
||||
const core::stringw email = m_email_widget->getText().trim();
|
||||
if (username.size() < 4 || username.size() > 30 || email.size() < 4 || email.size() > 50)
|
||||
if (username.size() < 4 || username.size() > 30 ||
|
||||
email.size() < 4 || email.size() > 50 )
|
||||
{
|
||||
sfx_manager->quickSound("anvil");
|
||||
m_info_widget->setErrorColor();
|
||||
m_info_widget->setText(_("Username and/or email address invalid."), false);
|
||||
m_info_widget->setText(_("Username and/or email address invalid."),
|
||||
false);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_info_widget->setDefaultColor();
|
||||
m_options_widget->setDeactivated();
|
||||
m_recovery_request = CurrentUser::get()->requestRecovery(username, email);
|
||||
m_recovery_request = new XMLRequest();
|
||||
m_recovery_request->setServerURL("client-user.php");
|
||||
m_recovery_request->addParameter("action", "recovery");
|
||||
m_recovery_request->addParameter("username", username);
|
||||
m_recovery_request->addParameter("email", email);
|
||||
m_recovery_request->queue();
|
||||
}
|
||||
}
|
||||
} // processInput
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
GUIEngine::EventPropagation RecoveryDialog::processEvent(const std::string& eventSource)
|
||||
/** Handle a user event.
|
||||
*/
|
||||
GUIEngine::EventPropagation
|
||||
RecoveryDialog::processEvent(const std::string& eventSource)
|
||||
{
|
||||
std::string selection;
|
||||
if (eventSource == m_options_widget->m_properties[PROP_ID])
|
||||
selection = m_options_widget->getSelectionIDString(PLAYER_ID_GAME_MASTER);
|
||||
selection =
|
||||
m_options_widget->getSelectionIDString(PLAYER_ID_GAME_MASTER);
|
||||
else
|
||||
selection = eventSource;
|
||||
|
||||
if (selection == m_cancel_widget->m_properties[PROP_ID])
|
||||
{
|
||||
m_self_destroy = true;
|
||||
@ -138,10 +157,11 @@ GUIEngine::EventPropagation RecoveryDialog::processEvent(const std::string& even
|
||||
return GUIEngine::EVENT_BLOCK;
|
||||
}
|
||||
return GUIEngine::EVENT_LET;
|
||||
}
|
||||
} // processEvent
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
/** Called when the user pressed enter.
|
||||
*/
|
||||
void RecoveryDialog::onEnterPressedInternal()
|
||||
{
|
||||
|
||||
@ -152,7 +172,10 @@ void RecoveryDialog::onEnterPressedInternal()
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
/** This is called every frame and checks if an outstanding recovery request
|
||||
* was finished. If so, it displays the results.
|
||||
* \param dt Time step size.
|
||||
*/
|
||||
void RecoveryDialog::onUpdate(float dt)
|
||||
{
|
||||
if(m_recovery_request != NULL)
|
||||
@ -185,4 +208,4 @@ void RecoveryDialog::onUpdate(float dt)
|
||||
showRecoveryInput();
|
||||
else if (m_show_recovery_info)
|
||||
showRecoveryInfo();
|
||||
}
|
||||
} // onUpdates
|
||||
|
@ -52,7 +52,7 @@ private:
|
||||
bool m_show_recovery_input;
|
||||
bool m_show_recovery_info;
|
||||
|
||||
const Online::XMLRequest * m_recovery_request;
|
||||
Online::XMLRequest * m_recovery_request;
|
||||
|
||||
GUIEngine::TextBoxWidget * m_username_widget;
|
||||
GUIEngine::TextBoxWidget * m_email_widget;
|
||||
|
@ -18,9 +18,11 @@
|
||||
#include "states_screens/dialogs/user_info_dialog.hpp"
|
||||
|
||||
#include "audio/sfx_manager.hpp"
|
||||
#include "guiengine/dialog_queue.hpp"
|
||||
#include "guiengine/engine.hpp"
|
||||
#include "online/online_profile.hpp"
|
||||
#include "online/messages.hpp"
|
||||
#include "states_screens/online_profile_friends.hpp"
|
||||
#include "states_screens/online_profile_overview.hpp"
|
||||
#include "states_screens/state_manager.hpp"
|
||||
#include "utils/translation.hpp"
|
||||
@ -56,6 +58,11 @@ void UserInfoDialog::load()
|
||||
void UserInfoDialog::beforeAddingWidgets()
|
||||
{
|
||||
m_profile = ProfileManager::get()->getProfileByID(m_showing_id);
|
||||
|
||||
// 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).
|
||||
if (!m_profile)
|
||||
m_profile = CurrentUser::get()->getProfile();
|
||||
m_self_destroy = false;
|
||||
m_enter_profile = false;
|
||||
m_processing = false;
|
||||
@ -120,6 +127,157 @@ UserInfoDialog::~UserInfoDialog()
|
||||
{
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
/** Sends a friend request to the server. When the request is finished, it
|
||||
* show a dialog with the result of this request.
|
||||
*/
|
||||
void UserInfoDialog::sendFriendRequest()
|
||||
{
|
||||
class FriendRequest : public XMLRequest
|
||||
{
|
||||
// ------------------------------------------------------------------------
|
||||
/** Callback for the request to send a friend invitation. Shows a
|
||||
* confirmation message and takes care of updating all the cached
|
||||
* information.
|
||||
*/
|
||||
virtual void callback()
|
||||
{
|
||||
uint32_t id(0);
|
||||
getXMLData()->get("friendid", &id);
|
||||
core::stringw info_text("");
|
||||
if (isSuccess())
|
||||
{
|
||||
CurrentUser::get()->getProfile()->addFriend(id);
|
||||
OnlineProfile::RelationInfo *info =
|
||||
new OnlineProfile::RelationInfo(_("Today"), false,
|
||||
true, false);
|
||||
ProfileManager::get()->getProfileByID(id)->setRelationInfo(info);
|
||||
OnlineProfileFriends::getInstance()->refreshFriendsList();
|
||||
info_text = _("Friend request send!");
|
||||
}
|
||||
else
|
||||
info_text = getInfo();
|
||||
UserInfoDialog *dialog = new UserInfoDialog(id, info_text,
|
||||
!isSuccess(), true);
|
||||
GUIEngine::DialogQueue::get()->pushDialog(dialog, true);
|
||||
|
||||
} // callback
|
||||
public:
|
||||
FriendRequest() : XMLRequest(true) {}
|
||||
}; // FriendRequest
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
FriendRequest *request = new FriendRequest();
|
||||
CurrentUser::setUserDetails(request);
|
||||
request->addParameter("action", "friend-request");
|
||||
request->addParameter("friendid", m_profile->getID());
|
||||
request->queue();
|
||||
|
||||
m_processing = true;
|
||||
m_options_widget->setDeactivated();
|
||||
|
||||
} // sendFriendRequest
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Sends an AcceptFriend request to the server. It will show a popup
|
||||
* menu with the result once the request has been processed.
|
||||
*/
|
||||
void UserInfoDialog::acceptFriendRequest()
|
||||
{
|
||||
// ----------------------------------------------------------------
|
||||
class AcceptFriendRequest : public XMLRequest
|
||||
{
|
||||
/** Callback for the request to accept a friend invitation. Shows a
|
||||
* confirmation message and takes care of updating all the cached
|
||||
* information.
|
||||
*/
|
||||
virtual void callback()
|
||||
{
|
||||
uint32_t id(0);
|
||||
getXMLData()->get("friendid", &id);
|
||||
core::stringw info_text("");
|
||||
if (isSuccess())
|
||||
{
|
||||
OnlineProfile * profile =
|
||||
ProfileManager::get()->getProfileByID(id);
|
||||
profile->setFriend();
|
||||
OnlineProfile::RelationInfo *info =
|
||||
new OnlineProfile::RelationInfo(_("Today"), false,
|
||||
false, true);
|
||||
profile->setRelationInfo(info);
|
||||
OnlineProfileFriends::getInstance()->refreshFriendsList();
|
||||
info_text = _("Friend request accepted!");
|
||||
}
|
||||
else
|
||||
info_text = getInfo();
|
||||
GUIEngine::DialogQueue::get()->pushDialog(
|
||||
new UserInfoDialog(id, info_text, !isSuccess(), true), true);
|
||||
|
||||
} // callback
|
||||
public:
|
||||
AcceptFriendRequest() : XMLRequest(true) {}
|
||||
}; // AcceptFriendRequest
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
AcceptFriendRequest *request = new AcceptFriendRequest();
|
||||
CurrentUser::setUserDetails(request);
|
||||
request->addParameter("action", "accept-friend-request");
|
||||
request->addParameter("friendid", m_profile->getID());
|
||||
request->queue();
|
||||
m_processing = true;
|
||||
m_options_widget->setDeactivated();
|
||||
} // acceptFriendRequest
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
/** A request to the server, to decline a friend request.
|
||||
* \param friend_id The id of the user of which the request has to be
|
||||
* declined.
|
||||
*/
|
||||
void UserInfoDialog::declineFriendRequest()
|
||||
{
|
||||
// ----------------------------------------------------------------
|
||||
class DeclineFriendRequest : public XMLRequest
|
||||
{
|
||||
/** A request to the server, to cancel a pending friend request.
|
||||
* \param friend_id The id of the user of which the request has to be
|
||||
* canceled.
|
||||
*/
|
||||
virtual void callback()
|
||||
{
|
||||
uint32_t id(0);
|
||||
getXMLData()->get("friendid", &id);
|
||||
core::stringw info_text("");
|
||||
if (isSuccess())
|
||||
{
|
||||
CurrentUser::get()->getProfile()->removeFriend(id);
|
||||
ProfileManager::get()->moveToCache(id);
|
||||
ProfileManager::get()->getProfileByID(id)
|
||||
->deleteRelationalInfo();
|
||||
OnlineProfileFriends::getInstance()->refreshFriendsList();
|
||||
info_text = _("Friend request declined!");
|
||||
}
|
||||
else
|
||||
info_text = getInfo();
|
||||
GUIEngine::DialogQueue::get()->pushDialog(
|
||||
new UserInfoDialog(id, info_text, !isSuccess(),
|
||||
true), true);
|
||||
} // callback
|
||||
public:
|
||||
DeclineFriendRequest() : XMLRequest(true) {}
|
||||
}; // DeclineFriendRequest
|
||||
// ----------------------------------------------------------------
|
||||
DeclineFriendRequest *request = new DeclineFriendRequest();
|
||||
CurrentUser::setUserDetails(request);
|
||||
request->addParameter("action", "decline-friend-request");
|
||||
request->addParameter("friendid", m_profile->getID());
|
||||
request->queue();
|
||||
|
||||
m_processing = true;
|
||||
m_options_widget->setDeactivated();
|
||||
|
||||
} // declineFriendRequest
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
GUIEngine::EventPropagation UserInfoDialog::processEvent(const std::string& eventSource)
|
||||
{
|
||||
@ -141,9 +299,7 @@ GUIEngine::EventPropagation UserInfoDialog::processEvent(const std::string& even
|
||||
}
|
||||
else if(selection == m_friend_widget->m_properties[PROP_ID])
|
||||
{
|
||||
CurrentUser::get()->requestFriendRequest(m_profile->getID());
|
||||
m_processing = true;
|
||||
m_options_widget->setDeactivated();
|
||||
sendFriendRequest();
|
||||
return GUIEngine::EVENT_BLOCK;
|
||||
}
|
||||
else if(selection == m_remove_widget->m_properties[PROP_ID])
|
||||
@ -158,16 +314,12 @@ GUIEngine::EventPropagation UserInfoDialog::processEvent(const std::string& even
|
||||
}
|
||||
else if(selection == m_accept_widget->m_properties[PROP_ID])
|
||||
{
|
||||
CurrentUser::get()->requestAcceptFriend(m_profile->getID());
|
||||
m_processing = true;
|
||||
m_options_widget->setDeactivated();
|
||||
acceptFriendRequest();
|
||||
return GUIEngine::EVENT_BLOCK;
|
||||
}
|
||||
else if(selection == m_decline_widget->m_properties[PROP_ID])
|
||||
{
|
||||
CurrentUser::get()->requestDeclineFriend(m_profile->getID());
|
||||
m_processing = true;
|
||||
m_options_widget->setDeactivated();
|
||||
declineFriendRequest();
|
||||
return GUIEngine::EVENT_BLOCK;
|
||||
}
|
||||
}
|
||||
|
@ -60,6 +60,9 @@ private:
|
||||
void requestJoin();
|
||||
void activate();
|
||||
void deactivate();
|
||||
void sendFriendRequest();
|
||||
void acceptFriendRequest();
|
||||
void declineFriendRequest();
|
||||
|
||||
public:
|
||||
UserInfoDialog(uint32_t showing_id, const core::stringw info = "", bool error = false, bool from_queue = false);
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "states_screens/online_screen.hpp"
|
||||
#include "states_screens/register_screen.hpp"
|
||||
#include "states_screens/state_manager.hpp"
|
||||
#include "states_screens/dialogs/recovery_dialog.hpp"
|
||||
#include "utils/log.hpp"
|
||||
#include "utils/translation.hpp"
|
||||
|
||||
@ -174,6 +175,7 @@ void LoginScreen::eventCallback(Widget* widget, const std::string& name,
|
||||
}
|
||||
else if(button=="recovery")
|
||||
{
|
||||
new RecoveryDialog();
|
||||
}
|
||||
else if(button=="cancel")
|
||||
StateManager::get()->escapePressed();
|
||||
|
@ -124,8 +124,15 @@ void RegisterScreen::acceptTerms()
|
||||
core::stringw password_confirm= getWidget<TextBoxWidget>("password_confirm")->getText().trim();
|
||||
core::stringw email = getWidget<TextBoxWidget>("email")->getText().trim();
|
||||
|
||||
m_signup_request = CurrentUser::get()->requestSignUp(username, password,
|
||||
password_confirm, email);
|
||||
m_signup_request = new XMLRequest();
|
||||
m_signup_request->setServerURL("client-user.php");
|
||||
m_signup_request->addParameter("action", "register" );
|
||||
m_signup_request->addParameter("username", username );
|
||||
m_signup_request->addParameter("password", password );
|
||||
m_signup_request->addParameter("password_confirm", password_confirm);
|
||||
m_signup_request->addParameter("email", email );
|
||||
m_signup_request->addParameter("terms", "on" );
|
||||
m_signup_request->queue();
|
||||
} // acceptTerms
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
@ -43,7 +43,8 @@ private:
|
||||
/** Save the pointer to the options widget, it is widely used. */
|
||||
GUIEngine::RibbonWidget *m_options_widget;
|
||||
|
||||
const Online::XMLRequest *m_signup_request;
|
||||
/** The XML request to the server. */
|
||||
Online::XMLRequest *m_signup_request;
|
||||
|
||||
/** True if the info message (email was sent...) is shown. */
|
||||
bool m_info_message_shown;
|
||||
|
Loading…
Reference in New Issue
Block a user