diff --git a/data/gui/online/recovery_info.stkgui b/data/gui/online/recovery_info.stkgui
new file mode 100644
index 000000000..07cffd12c
--- /dev/null
+++ b/data/gui/online/recovery_info.stkgui
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/data/gui/online/recovery_input.stkgui b/data/gui/online/recovery_input.stkgui
new file mode 100644
index 000000000..26a8a7da0
--- /dev/null
+++ b/data/gui/online/recovery_input.stkgui
@@ -0,0 +1,46 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/data/gui/online/registration_activation.stkgui b/data/gui/online/registration_activation.stkgui
deleted file mode 100644
index a7d5ec82c..000000000
--- a/data/gui/online/registration_activation.stkgui
+++ /dev/null
@@ -1,28 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/data/gui/online/registration_info.stkgui b/data/gui/online/registration_info.stkgui
index 0617b87bc..5d8b6d12a 100644
--- a/data/gui/online/registration_info.stkgui
+++ b/data/gui/online/registration_info.stkgui
@@ -3,58 +3,20 @@
+ I18N="In the registration dialog' dialog" text="Registration Complete"/>
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
+
+
diff --git a/data/gui/online/registration_input.stkgui b/data/gui/online/registration_input.stkgui
new file mode 100644
index 000000000..cdcf59772
--- /dev/null
+++ b/data/gui/online/registration_input.stkgui
@@ -0,0 +1,61 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/data/gui/online/registration_terms.stkgui b/data/gui/online/registration_terms.stkgui
index edda8527b..5ba2b1bad 100644
--- a/data/gui/online/registration_terms.stkgui
+++ b/data/gui/online/registration_terms.stkgui
@@ -19,7 +19,7 @@
+ I18N="In the registration dialog" text=""/>
diff --git a/sources.cmake b/sources.cmake
index 41e1673ea..2ee78af57 100644
--- a/sources.cmake
+++ b/sources.cmake
@@ -184,6 +184,7 @@ src/states_screens/dialogs/message_dialog.cpp
src/states_screens/dialogs/player_info_dialog.cpp
src/states_screens/dialogs/press_a_key_dialog.cpp
src/states_screens/dialogs/race_paused_dialog.cpp
+src/states_screens/dialogs/recovery_dialog.cpp
src/states_screens/dialogs/registration_dialog.cpp
src/states_screens/dialogs/select_challenge.cpp
src/states_screens/dialogs/server_info_dialog.cpp
@@ -458,6 +459,7 @@ src/states_screens/dialogs/message_dialog.hpp
src/states_screens/dialogs/player_info_dialog.hpp
src/states_screens/dialogs/press_a_key_dialog.hpp
src/states_screens/dialogs/race_paused_dialog.hpp
+src/states_screens/dialogs/recovery_dialog.hpp
src/states_screens/dialogs/registration_dialog.hpp
src/states_screens/dialogs/select_challenge.hpp
src/states_screens/dialogs/server_info_dialog.hpp
diff --git a/src/online/current_user.cpp b/src/online/current_user.cpp
index 2584c09cf..d16c68f4c 100644
--- a/src/online/current_user.cpp
+++ b/src/online/current_user.cpp
@@ -54,6 +54,20 @@ namespace Online{
setSaveSession(false);
}
+ // ============================================================================
+ const XMLRequest * CurrentUser::requestRecovery( const irr::core::stringw &username,
+ const irr::core::stringw &email)
+ {
+ assert(getUserState() == US_SIGNED_OUT || getUserState() == US_GUEST);
+ XMLRequest * request = new XMLRequest();
+ request->setURL((std::string)UserConfigParams::m_server_multiplayer + "client-user.php");
+ request->setParameter("action", std::string("recovery"));
+ request->setParameter("username", username);
+ request->setParameter("email", email);
+ HTTPManager::get()->addRequest(request);
+ return request;
+ }
+
// ============================================================================
const XMLRequest * CurrentUser::requestSignUp( const irr::core::stringw &username,
const irr::core::stringw &password,
diff --git a/src/online/current_user.hpp b/src/online/current_user.hpp
index 27b0e2a3b..dfa548f6a 100644
--- a/src/online/current_user.hpp
+++ b/src/online/current_user.hpp
@@ -105,7 +105,7 @@ namespace Online{
void createServer (const ServerCreationRequest * input);
public:
- //Singleton
+ /**Singleton */
static CurrentUser * get();
static void deallocate();
@@ -118,13 +118,16 @@ namespace Online{
const ServerJoinRequest * requestServerJoin( uint32_t server_id);
- // Register
+ /** 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,
bool terms);
+ const XMLRequest * requestRecovery( const irr::core::stringw &username,
+ const irr::core::stringw &email);
+
/** Returns the username if signed in. */
const irr::core::stringw getUserName() const;
const UserState getUserState() const { return m_state.getAtomic(); }
diff --git a/src/online/messages.cpp b/src/online/messages.cpp
index 0b1e61448..d484cd0e2 100644
--- a/src/online/messages.cpp
+++ b/src/online/messages.cpp
@@ -40,6 +40,11 @@ namespace Online
return irr::core::stringw(_("Validating registration info")) + loadingDots();
}
// ------------------------------------------------------------------------
+ irr::core::stringw recovery()
+ {
+ return irr::core::stringw(_("Validating recovery info")) + loadingDots();
+ }
+ // ------------------------------------------------------------------------
irr::core::stringw signedInAs(const irr::core::stringw & name)
{
diff --git a/src/online/messages.hpp b/src/online/messages.hpp
index 36a936d79..7c6cbb673 100644
--- a/src/online/messages.hpp
+++ b/src/online/messages.hpp
@@ -30,6 +30,7 @@ namespace Online
irr::core::stringw signingIn ();
irr::core::stringw signingOut ();
irr::core::stringw signingUp ();
+ irr::core::stringw recovery ();
irr::core::stringw joiningServer ();
irr::core::stringw creatingServer ();
irr::core::stringw fetchingServers ();
diff --git a/src/online/request.cpp b/src/online/request.cpp
index 9a4697cd0..2277862db 100644
--- a/src/online/request.cpp
+++ b/src/online/request.cpp
@@ -92,7 +92,7 @@ namespace Online{
curl_session = curl_easy_init();
if(!curl_session)
{
- Log::error("online/http_functions", "Error while initialising libCurl session");
+ Log::error("HTTPRequest::downloadPage", "Error while initialising libCurl session");
return "";
}
curl_easy_setopt(curl_session, CURLOPT_URL, m_url.getAtomic().c_str());
@@ -132,7 +132,7 @@ namespace Online{
CURLcode res = curl_easy_perform(curl_session);
if(res == CURLE_OK)
{
- Log::info("online/http_functions", "Received : %s", readBuffer.c_str());
+ Log::info("HTTPRequest::downloadPage", "Received : %s", readBuffer.c_str());
setProgress(1.0f);
}
else
diff --git a/src/states_screens/dialogs/login_dialog.cpp b/src/states_screens/dialogs/login_dialog.cpp
index a87230f63..bcc6165ac 100644
--- a/src/states_screens/dialogs/login_dialog.cpp
+++ b/src/states_screens/dialogs/login_dialog.cpp
@@ -26,6 +26,7 @@
#include "utils/translation.hpp"
#include "utils/string_utils.hpp"
#include "states_screens/dialogs/registration_dialog.hpp"
+#include "states_screens/dialogs/recovery_dialog.hpp"
#include "online/messages.hpp"
@@ -41,6 +42,7 @@ LoginDialog::LoginDialog(const Message message_type) :
{
m_self_destroy = false;
m_open_registration_dialog = false;
+ m_open_recovery_dialog = false;
m_sign_in_request = NULL;
loadFromFile("online/login_dialog.stkgui");
@@ -86,6 +88,7 @@ LoginDialog::LoginDialog(const Message message_type) :
assert(m_register_widget != NULL);
m_as_guest_widget = getWidget("as_guest");
assert(m_as_guest_widget != NULL);
+ m_as_guest_widget->setDeactivated();
m_cancel_widget = getWidget("cancel");
assert(m_cancel_widget != NULL);
@@ -141,6 +144,11 @@ GUIEngine::EventPropagation LoginDialog::processEvent(const std::string& eventSo
m_open_registration_dialog = true;
return GUIEngine::EVENT_BLOCK;
}
+ else if(selection == m_recovery_widget->m_properties[PROP_ID])
+ {
+ m_open_recovery_dialog = true;
+ return GUIEngine::EVENT_BLOCK;
+ }
}
return GUIEngine::EVENT_LET;
}
@@ -191,8 +199,8 @@ void LoginDialog::onUpdate(float dt)
m_info_widget->setText(Online::Messages::signingIn(), false);
}
}
- //If we want to open the registration dialog, we need to close this one first
- m_open_registration_dialog && (m_self_destroy = true);
+ //If we want to open another dialog, we need to close this one first
+ (m_open_registration_dialog || m_open_recovery_dialog) && (m_self_destroy = true);
// It's unsafe to delete from inside the event handler so we do it here
if (m_self_destroy)
@@ -200,6 +208,8 @@ void LoginDialog::onUpdate(float dt)
ModalDialog::dismiss();
if (m_open_registration_dialog)
new RegistrationDialog();
+ else if (m_open_recovery_dialog)
+ new RecoveryDialog();
return;
}
}
diff --git a/src/states_screens/dialogs/login_dialog.hpp b/src/states_screens/dialogs/login_dialog.hpp
index 9ec00b654..30825a744 100644
--- a/src/states_screens/dialogs/login_dialog.hpp
+++ b/src/states_screens/dialogs/login_dialog.hpp
@@ -37,6 +37,7 @@ private:
bool m_self_destroy;
bool m_open_registration_dialog;
+ bool m_open_recovery_dialog;
const Online::CurrentUser::SignInRequest * m_sign_in_request;
GUIEngine::LabelWidget * m_message_widget;
GUIEngine::TextBoxWidget * m_username_widget;
diff --git a/src/states_screens/dialogs/recovery_dialog.cpp b/src/states_screens/dialogs/recovery_dialog.cpp
new file mode 100644
index 000000000..7ed3cfec7
--- /dev/null
+++ b/src/states_screens/dialogs/recovery_dialog.cpp
@@ -0,0 +1,190 @@
+// SuperTuxKart - a fun racing game with go-kart
+// Copyright (C) 2013 Glenn De Jonghe
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 3
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+#include "states_screens/dialogs/recovery_dialog.hpp"
+
+#include
+
+#include "audio/sfx_manager.hpp"
+#include "config/player.hpp"
+#include "guiengine/engine.hpp"
+#include "states_screens/state_manager.hpp"
+#include "utils/translation.hpp"
+#include "utils/string_utils.hpp"
+#include "online/messages.hpp"
+
+
+using namespace GUIEngine;
+using namespace irr;
+using namespace irr::gui;
+using namespace Online;
+
+// -----------------------------------------------------------------------------
+
+RecoveryDialog::RecoveryDialog() :
+ ModalDialog(0.8f,0.8f)
+{
+ m_recovery_request = NULL;
+ m_self_destroy = false;
+ m_show_recovery_input = true;
+}
+
+// -----------------------------------------------------------------------------
+
+RecoveryDialog::~RecoveryDialog()
+{
+ delete m_recovery_request;
+}
+
+// -----------------------------------------------------------------------------
+
+void RecoveryDialog::showRecoveryInput(){
+ m_show_recovery_input = false;
+ clearWindow();
+ m_phase = Input;
+ loadFromFile("online/recovery_input.stkgui");
+
+ m_username_widget = getWidget("username");
+ assert(m_username_widget != NULL);
+ m_username_widget->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
+
+ m_email_widget = getWidget("email");
+ assert(m_email_widget != NULL);
+
+ m_info_widget = getWidget("info");
+ assert(m_info_widget != NULL);
+
+ m_options_widget = getWidget("options");
+ assert(m_options_widget != NULL);
+ m_submit_widget = getWidget("submit");
+ assert(m_submit_widget != NULL);
+ m_cancel_widget = getWidget("cancel");
+ assert(m_cancel_widget != NULL);
+}
+
+// -----------------------------------------------------------------------------
+
+void RecoveryDialog::showRecoveryInfo(){
+ m_show_recovery_info = false;
+ clearWindow();
+ m_phase = Info;
+ loadFromFile("online/recovery_info.stkgui");
+
+ m_info_widget = getWidget("info");
+ assert(m_info_widget != NULL);
+
+ m_options_widget = getWidget("options");
+ assert(m_options_widget != NULL);
+ m_cancel_widget = getWidget("cancel");
+ assert(m_cancel_widget != NULL);
+}
+
+// -----------------------------------------------------------------------------
+
+bool RecoveryDialog::onEscapePressed()
+{
+ return m_cancel_widget->isActivated();
+}
+
+// -----------------------------------------------------------------------------
+
+void RecoveryDialog::processInput()
+{
+ const stringw username = m_username_widget->getText().trim();
+ const stringw email = m_email_widget->getText().trim();
+ 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);
+ }
+ else
+ {
+ m_info_widget->setDefaultColor();
+ m_options_widget->setDeactivated();
+ m_recovery_request = CurrentUser::get()->requestRecovery(username, email);
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+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);
+ else
+ selection = eventSource;
+ if (selection == m_cancel_widget->m_properties[PROP_ID])
+ {
+ m_self_destroy = true;
+ return GUIEngine::EVENT_BLOCK;
+ }
+ else if (selection == m_submit_widget->m_properties[PROP_ID])
+ {
+ processInput();
+ return GUIEngine::EVENT_BLOCK;
+ }
+ return GUIEngine::EVENT_LET;
+}
+
+// -----------------------------------------------------------------------------
+
+void RecoveryDialog::onEnterPressedInternal()
+{
+
+ if (GUIEngine::isFocusedForPlayer(m_options_widget, PLAYER_ID_GAME_MASTER))
+ return;
+ if (m_submit_widget->isActivated())
+ processInput();
+}
+
+// -----------------------------------------------------------------------------
+
+void RecoveryDialog::onUpdate(float dt)
+{
+ if(m_recovery_request != NULL)
+ {
+ if(m_recovery_request->isDone())
+ {
+ if(m_recovery_request->isSuccess())
+ {
+ m_show_recovery_info = true;
+ }
+ else
+ {
+ sfx_manager->quickSound( "anvil" );
+ m_info_widget->setErrorColor();
+ m_info_widget->setText(m_recovery_request->getInfo(), false);
+ m_options_widget->setActivated();
+ }
+ delete m_recovery_request;
+ m_recovery_request = NULL;
+ }
+ else
+ {
+ m_info_widget->setText(Messages::recovery(), false);
+ }
+ }
+ // It's unsafe to delete from inside the event handler so we do it here
+ if (m_self_destroy)
+ ModalDialog::dismiss();
+ else if (m_show_recovery_input)
+ showRecoveryInput();
+ else if (m_show_recovery_info)
+ showRecoveryInfo();
+}
diff --git a/src/states_screens/dialogs/recovery_dialog.hpp b/src/states_screens/dialogs/recovery_dialog.hpp
new file mode 100644
index 000000000..0f10d34b4
--- /dev/null
+++ b/src/states_screens/dialogs/recovery_dialog.hpp
@@ -0,0 +1,71 @@
+// SuperTuxKart - a fun racing game with go-kart
+// Copyright (C) 2013 Glenn De Jonghe
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 3
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+
+#ifndef HEADER_RECOVERY_DIALOG_HPP
+#define HEADER_RECOVERY_DIALOG_HPP
+
+#include
+
+#include "guiengine/modaldialog.hpp"
+#include "guiengine/widgets.hpp"
+#include "online/current_user.hpp"
+
+/**
+ * \brief Dialog that allows a user to recover his account
+ * \ingroup states_screens
+ */
+class RecoveryDialog : public GUIEngine::ModalDialog
+{
+public:
+ enum Phase
+ {
+ Input = 1,
+ Info = 2,
+ };
+ RecoveryDialog();
+ ~RecoveryDialog();
+
+ void onEnterPressedInternal();
+ GUIEngine::EventPropagation processEvent(const std::string& eventSource);
+
+ virtual void onUpdate(float dt);
+ virtual bool onEscapePressed();
+
+private:
+ Phase m_phase;
+ bool m_self_destroy;
+ bool m_show_recovery_input;
+ bool m_show_recovery_info;
+
+ const Online::XMLRequest * m_recovery_request;
+
+ GUIEngine::TextBoxWidget * m_username_widget;
+ GUIEngine::TextBoxWidget * m_email_widget;
+
+ GUIEngine::LabelWidget * m_info_widget;
+
+ GUIEngine::RibbonWidget * m_options_widget;
+ GUIEngine::IconButtonWidget * m_submit_widget;
+ GUIEngine::IconButtonWidget * m_cancel_widget;
+
+ void showRecoveryInput();
+ void showRecoveryInfo();
+ void processInput();
+};
+
+#endif
diff --git a/src/states_screens/dialogs/registration_dialog.cpp b/src/states_screens/dialogs/registration_dialog.cpp
index ddfcec9d7..cb75080fc 100644
--- a/src/states_screens/dialogs/registration_dialog.cpp
+++ b/src/states_screens/dialogs/registration_dialog.cpp
@@ -35,26 +35,20 @@ using namespace Online;
// -----------------------------------------------------------------------------
-RegistrationDialog::RegistrationDialog(const Phase phase) :
+RegistrationDialog::RegistrationDialog() :
ModalDialog(0.8f,0.9f)
{
m_sign_up_request = NULL;
- m_activation_request = NULL;
m_self_destroy = false;
- m_show_registration_info = false;
+ m_show_registration_input = true;
m_show_registration_terms = false;
- m_show_registration_activation = false;
+ m_show_registration_info = false;
m_username = "";
m_email = "";
m_email_confirm = "";
m_password = "";
m_password_confirm = "";
m_agreement = false;
- //If not asked for the Activation phase, default to the Info phase.
- if (phase == Activation)
- m_show_registration_activation = true;
- else
- m_show_registration_info = true;
}
// -----------------------------------------------------------------------------
@@ -62,16 +56,16 @@ RegistrationDialog::RegistrationDialog(const Phase phase) :
RegistrationDialog::~RegistrationDialog()
{
delete m_sign_up_request;
- delete m_activation_request;
}
// -----------------------------------------------------------------------------
-void RegistrationDialog::showRegistrationInfo(){
- m_show_registration_info = false;
+void RegistrationDialog::showRegistrationInput()
+{
+ m_show_registration_input = false;
clearWindow();
- m_phase = Info;
- loadFromFile("online/registration_info.stkgui");
+ m_phase = Input;
+ loadFromFile("online/registration_input.stkgui");
//Password should always be reentered if previous has been clicked, or an error occurred.
m_password = "";
@@ -113,7 +107,8 @@ void RegistrationDialog::showRegistrationInfo(){
// -----------------------------------------------------------------------------
-void RegistrationDialog::showRegistrationTerms(){
+void RegistrationDialog::showRegistrationTerms()
+{
m_show_registration_terms = false;
clearWindow();
m_phase = Terms;
@@ -139,64 +134,71 @@ void RegistrationDialog::showRegistrationTerms(){
// -----------------------------------------------------------------------------
-void RegistrationDialog::showRegistrationActivation(){
- m_show_registration_activation = false;
+void RegistrationDialog::showRegistrationInfo()
+{
+ m_show_registration_info = false;
clearWindow();
- m_phase = Activation;
- loadFromFile("online/registration_activation.stkgui");
+ m_phase = Info;
+ loadFromFile("online/registration_info.stkgui");
m_info_widget = getWidget("info");
assert(m_info_widget != NULL);
- m_info_widget->setText(m_registration_error, false);
m_options_widget = getWidget("options");
assert(m_options_widget != NULL);
- m_next_widget = getWidget("next");
- assert(m_next_widget != NULL);
m_cancel_widget = getWidget("cancel");
assert(m_cancel_widget != NULL);
}
// -----------------------------------------------------------------------------
-bool RegistrationDialog::processInfoEvent(const std::string& eventSource){
- if (m_phase == Info)
+void RegistrationDialog::processInput()
+{
+ m_username = m_username_widget->getText().trim();
+ m_password = m_password_widget->getText().trim();
+ m_password_confirm = m_password_confirm_widget->getText().trim();
+ m_email = m_email_widget->getText().trim();
+ m_email_confirm = m_email_confirm_widget->getText().trim();
+ //FIXME More validation of registration information
+ m_info_widget->setErrorColor();
+ if (m_password != m_password_confirm)
+ {
+ m_info_widget->setText(_("Passwords don't match!"), false);
+ }
+ else if (m_email != m_email_confirm)
+ {
+ m_info_widget->setText(_("Emails don't match!"), false);
+ }
+ else if (m_username.size() < 4 || m_username.size() > 30)
+ {
+ m_info_widget->setText(_("Username has to be between 4 and 30 characters long!"), false);
+ }
+ else if (m_password.size() < 8 || m_password.size() > 30)
+ {
+ m_info_widget->setText(_("Password has to be between 8 and 30 characters long!"), false);
+ }
+ else if (m_email.size() < 4 || m_email.size() > 50)
+ {
+ m_info_widget->setText(_("Email has to be between 4 and 50 characters long!"), false);
+ }
+ else
+ {
+ m_show_registration_terms = true;
+ return;
+ }
+ sfx_manager->quickSound( "anvil" );
+}
+
+
+// -----------------------------------------------------------------------------
+
+bool RegistrationDialog::processInputEvent(const std::string& eventSource)
+{
+ if (m_phase == Input)
{
if (eventSource == m_next_widget->m_properties[PROP_ID])
{
- m_username = m_username_widget->getText().trim();
- m_password = m_password_widget->getText().trim();
- m_password_confirm = m_password_confirm_widget->getText().trim();
- m_email = m_email_widget->getText().trim();
- m_email_confirm = m_email_confirm_widget->getText().trim();
- //FIXME More validation of registration information
- m_info_widget->setErrorColor();
- if (m_password != m_password_confirm)
- {
- m_info_widget->setText(_("Passwords don't match!"), false);
- }
- else if (m_email != m_email_confirm)
- {
- m_info_widget->setText(_("Emails don't match!"), false);
- }
- else if (m_username.size() < 4 || m_username.size() > 30)
- {
- m_info_widget->setText(_("Username has to be between 4 and 30 characters long!"), false);
- }
- else if (m_password.size() < 8 || m_password.size() > 30)
- {
- m_info_widget->setText(_("Password has to be between 8 and 30 characters long!"), false);
- }
- else if (m_email.size() < 4 || m_email.size() > 50)
- {
- m_info_widget->setText(_("Email has to be between 4 and 50 characters long!"), false);
- }
- else
- {
- m_show_registration_terms = true;
- return true;
- }
- sfx_manager->quickSound( "anvil" );
+ processInput();
return true;
}
}
@@ -205,7 +207,8 @@ bool RegistrationDialog::processInfoEvent(const std::string& eventSource){
// -----------------------------------------------------------------------------
-bool RegistrationDialog::processTermsEvent(const std::string& eventSource){
+bool RegistrationDialog::processTermsEvent(const std::string& eventSource)
+{
if (m_phase == Terms)
{
if (eventSource == m_next_widget->m_properties[PROP_ID])
@@ -238,16 +241,8 @@ bool RegistrationDialog::processTermsEvent(const std::string& eventSource){
// -----------------------------------------------------------------------------
-bool RegistrationDialog::processActivationEvent(const std::string& eventSource){
- if (m_phase == Activation)
- {
- if (eventSource == m_next_widget->m_properties[PROP_ID])
- {
- //FIXME : activate
- m_self_destroy = true;
- return true;
- }
- }
+bool RegistrationDialog::processInfoEvent(const std::string& eventSource)
+{
return false;
}
@@ -272,7 +267,7 @@ GUIEngine::EventPropagation RegistrationDialog::processEvent(const std::string&
m_self_destroy = true;
return GUIEngine::EVENT_BLOCK;
}
- else if (processInfoEvent(selection) || processTermsEvent(selection) || processActivationEvent(selection))
+ else if (processInputEvent(selection) || processTermsEvent(selection) || processInfoEvent(selection))
{
return GUIEngine::EVENT_BLOCK;
}
@@ -287,7 +282,7 @@ void RegistrationDialog::onEnterPressedInternal()
if (GUIEngine::isFocusedForPlayer(m_options_widget, PLAYER_ID_GAME_MASTER))
return;
if (m_next_widget->isActivated())
- processEvent("next");
+ processInput();
}
// -----------------------------------------------------------------------------
@@ -302,12 +297,12 @@ void RegistrationDialog::onUpdate(float dt)
{
if(m_sign_up_request->isSuccess())
{
- m_show_registration_activation = true;
+ m_show_registration_info = true;
}
else
{
sfx_manager->quickSound( "anvil" );
- m_show_registration_info = true;
+ m_show_registration_input = true;
m_registration_error = m_sign_up_request->getInfo();
}
delete m_sign_up_request;
@@ -321,34 +316,13 @@ void RegistrationDialog::onUpdate(float dt)
}
}
}
- else if (m_phase == Activation)
- {
- /*
- XMLRequest * sign_up_request = HTTPManager::get()->getXMLResponse(Request::RT_SIGN_UP);
- if(sign_up_request != NULL)
- {
- if(sign_up_request->isSuccess())
- {
- m_show_registration_activation = true;
- }
- else
- {
- sfx_manager->quickSound( "anvil" );
- m_show_registration_info = true;
- m_registration_error = sign_up_request->getInfo();
- }
- delete sign_up_request;
- m_signing_up = false;
- //FIXME m_options_widget->setActivated();
- }*/
- }
// It's unsafe to delete from inside the event handler so we do it here
if (m_self_destroy)
ModalDialog::dismiss();
- else if (m_show_registration_info)
- showRegistrationInfo();
+ else if (m_show_registration_input)
+ showRegistrationInput();
else if (m_show_registration_terms)
showRegistrationTerms();
- else if (m_show_registration_activation)
- showRegistrationActivation();
+ else if (m_show_registration_info)
+ showRegistrationInfo();
}
diff --git a/src/states_screens/dialogs/registration_dialog.hpp b/src/states_screens/dialogs/registration_dialog.hpp
index f39d15efa..60fc9340d 100644
--- a/src/states_screens/dialogs/registration_dialog.hpp
+++ b/src/states_screens/dialogs/registration_dialog.hpp
@@ -31,15 +31,13 @@
class RegistrationDialog : public GUIEngine::ModalDialog
{
public:
-
enum Phase
{
- Info = 1,
+ Input = 1,
Terms = 2,
- Activation = 4
+ Info = 4
};
-
- RegistrationDialog(const Phase phase = Info);
+ RegistrationDialog();
~RegistrationDialog();
void onEnterPressedInternal();
@@ -49,15 +47,13 @@ public:
virtual bool onEscapePressed();
private:
-
Phase m_phase;
bool m_self_destroy;
- bool m_show_registration_info;
+ bool m_show_registration_input;
bool m_show_registration_terms;
- bool m_show_registration_activation;
+ bool m_show_registration_info;
const Online::XMLRequest * m_sign_up_request;
- const Online::XMLRequest * m_activation_request;
//Saved user input :
irr::core::stringw m_username;
@@ -83,12 +79,13 @@ private:
GUIEngine::CheckBoxWidget * m_accept_terms_widget;
- void showRegistrationInfo();
+ void showRegistrationInput();
void showRegistrationTerms();
- void showRegistrationActivation();
- bool processInfoEvent(const std::string& eventSource);
+ void showRegistrationInfo();
+ void processInput();
+ bool processInputEvent(const std::string& eventSource);
bool processTermsEvent(const std::string& eventSource);
- bool processActivationEvent(const std::string& eventSource);
+ bool processInfoEvent(const std::string& eventSource);
};