[GSoC Uni_] Registration has now 3 fases. Login also uses the new red error messages. This commit works for all testers as it doesn't connect to a server.
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/uni@12983 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
@@ -5,9 +5,9 @@
|
||||
<header id="title" width="96%" proportion="2" text_align="center" word_wrap="true"
|
||||
I18N="In the login dialog' dialog" text="Sign in"/>
|
||||
|
||||
<spacer height="50" width="50">
|
||||
<spacer height="40" width="50">
|
||||
|
||||
<div width="80%" align="center" layout="vertical-row" proportion="4">
|
||||
<div width="80%" align="center" layout="vertical-row" height="fit" >
|
||||
<div width="100%" height="fit" layout="horizontal-row" >
|
||||
<label proportion="1" text_align="left" I18N="In the login dialog" text="Username"/>
|
||||
<textbox proportion="2" id="username" I18N="In the login dialog"/>
|
||||
@@ -19,7 +19,9 @@
|
||||
<label proportion="1" text_align="left" I18N="In the login dialog" text="Password"/>
|
||||
<textbox proportion="2" id="password" I18N="In the login dialog"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<spacer height="20" width="50">
|
||||
|
||||
<label id="info" proportion="2" width="90%" align="center" text_align="center" word_wrap="true" dialog" text=""/>
|
||||
|
||||
|
||||
27
data/gui/online/registration_activation.stkgui
Normal file
27
data/gui/online/registration_activation.stkgui
Normal file
@@ -0,0 +1,27 @@
|
||||
<stkgui>
|
||||
|
||||
<div x="2%" y="5%" width="96%" height="90%" layout="vertical-row" >
|
||||
|
||||
<header id="title" width="96%" proportion="1" text_align="center" word_wrap="true"
|
||||
I18N="In the registration dialog' dialog" text="User Activation"/>
|
||||
|
||||
<spacer height="20" width="50">
|
||||
|
||||
<label id="terms" proportion="6" width="90%" align="center" text_align="center" word_wrap="true"
|
||||
I18N="In the registration dialog' dialog" text="Activation information will come here."/>
|
||||
|
||||
<label id="info" proportion="1" width="90%" align="center" text_align="center" word_wrap="true"
|
||||
I18N="In the registration dialog' dialog" text=""/>
|
||||
|
||||
<spacer height="20" width="50">
|
||||
|
||||
<div id="options" width="fit" proportion="1" align="center" layout="horizontal-row">
|
||||
<button id="activate" height="fit" align="center" width="fit" I18N="In the registration dialog" text="Activate"/>
|
||||
<spacer height="50" width="50">
|
||||
<button id="cancel" height="fit" align="center" width="fit" I18N="In the registration dialog" text="Close"/>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</stkgui>
|
||||
@@ -5,9 +5,9 @@
|
||||
<header id="title" width="96%" proportion="1" text_align="center" word_wrap="true"
|
||||
I18N="In the registration dialog' dialog" text="Registration"/>
|
||||
|
||||
<spacer height="50" width="50">
|
||||
<spacer height="40" width="50">
|
||||
|
||||
<div width="80%" align="center" layout="vertical-row" proportion="6">
|
||||
<div width="80%" align="center" layout="vertical-row" height="fit">
|
||||
<div width="100%" height="fit" layout="horizontal-row" >
|
||||
<label proportion="1" text_align="left" I18N="In the registration dialog" text="Username"/>
|
||||
<textbox proportion="2" id="username" I18N="In the registration dialog"/>
|
||||
@@ -40,7 +40,9 @@
|
||||
<label proportion="1" text_align="left" I18N="In the registration dialog" text="Confirm"/>
|
||||
<textbox proportion="2" id="email_confirm" I18N="In the registration dialog"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<spacer height="20" width="50">
|
||||
|
||||
<label id="info" proportion="1" width="90%" align="center" text_align="center" word_wrap="true"
|
||||
I18N="In the registration dialog' dialog" text=""/>
|
||||
@@ -48,8 +50,6 @@
|
||||
<spacer height="20" width="50">
|
||||
|
||||
<div id="options" width="fit" proportion="1" align="center" layout="horizontal-row">
|
||||
<button id="previous" height="fit" align="center" width="fit" I18N="In the registration dialog" text="Previous"/>
|
||||
<spacer height="50" width="50">
|
||||
<button id="next" height="fit" align="center" width="fit" I18N="In the registration dialog" text="Next"/>
|
||||
<spacer height="50" width="50">
|
||||
<button id="cancel" height="fit" align="center" width="fit" I18N="In the registration dialog" text="Cancel"/>
|
||||
|
||||
32
data/gui/online/registration_terms.stkgui
Normal file
32
data/gui/online/registration_terms.stkgui
Normal file
@@ -0,0 +1,32 @@
|
||||
<stkgui>
|
||||
|
||||
<div x="2%" y="5%" width="96%" height="90%" layout="vertical-row" >
|
||||
|
||||
<header id="title" width="96%" proportion="1" text_align="center" word_wrap="true"
|
||||
I18N="In the registration dialog' dialog" text="Terms and Agreement"/>
|
||||
|
||||
<spacer height="20" width="50">
|
||||
|
||||
<label id="terms" proportion="6" width="90%" align="center" text_align="center" word_wrap="true"
|
||||
I18N="In the registration dialog' dialog" text="The terms will come here. In a fancy scroll box."/>
|
||||
|
||||
<div align="center" width="fit" height="fit" layout="horizontal-row" >
|
||||
<label text_align="center" align="center" I18N="In the registration dialog" word_wrap="true"
|
||||
text="I agree to the above terms and am 13 years or older. "/>
|
||||
<checkbox id="accepted" I18N="In the registration dialog"/>
|
||||
</div>
|
||||
|
||||
<spacer height="20" width="50">
|
||||
|
||||
<div id="options" width="fit" proportion="1" align="center" layout="horizontal-row">
|
||||
<button id="previous" height="fit" align="center" width="fit" I18N="In the registration dialog" text="Previous"/>
|
||||
<spacer height="50" width="50">
|
||||
<button id="submit" height="fit" align="center" width="fit" I18N="In the registration dialog" text="Submit"/>
|
||||
<spacer height="50" width="50">
|
||||
<button id="cancel" height="fit" align="center" width="fit" I18N="In the registration dialog" text="Cancel"/>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</stkgui>
|
||||
@@ -42,6 +42,7 @@ LoginDialog::LoginDialog(const float w, const float h, const core::stringw& msg)
|
||||
ModalDialog(w,h)
|
||||
{
|
||||
m_self_destroy = false;
|
||||
m_open_registration_dialog = false;
|
||||
loadFromFile("online/login_dialog.stkgui");
|
||||
|
||||
TextBoxWidget* textBox = getWidget<TextBoxWidget>("password");
|
||||
@@ -70,7 +71,7 @@ GUIEngine::EventPropagation LoginDialog::processEvent(const std::string& eventSo
|
||||
{
|
||||
if (eventSource == "cancel")
|
||||
{
|
||||
dismiss();
|
||||
m_self_destroy = true;
|
||||
return GUIEngine::EVENT_BLOCK;
|
||||
}
|
||||
else if(eventSource == "signin")
|
||||
@@ -86,15 +87,15 @@ GUIEngine::EventPropagation LoginDialog::processEvent(const std::string& eventSo
|
||||
else
|
||||
{
|
||||
sfx_manager->quickSound( "anvil" );
|
||||
m_self_destroy = false;
|
||||
LabelWidget * infoLabel = getWidget<LabelWidget>("info");
|
||||
infoLabel->setColor(irr::video::SColor(255, 255, 0, 0));
|
||||
infoLabel->setText(info, false);
|
||||
}
|
||||
getWidget<LabelWidget>("info")->setText(info, false);
|
||||
return GUIEngine::EVENT_BLOCK;
|
||||
}
|
||||
else if(eventSource == "signup")
|
||||
{
|
||||
m_self_destroy = true;
|
||||
new RegistrationDialog(0.6f, 0.9f);
|
||||
m_open_registration_dialog = true;
|
||||
return GUIEngine::EVENT_BLOCK;
|
||||
}
|
||||
return GUIEngine::EVENT_LET;
|
||||
@@ -121,10 +122,15 @@ void LoginDialog::onEnterPressedInternal()
|
||||
|
||||
void LoginDialog::onUpdate(float dt)
|
||||
{
|
||||
//If we want to open the registration dialog, we need to close this one first
|
||||
m_open_registration_dialog && (m_self_destroy = true);
|
||||
// It's unsafe to delete from inside the event handler so we do it here
|
||||
if (m_self_destroy)
|
||||
{
|
||||
GUIEngine::getGUIEnv()->removeFocus( m_irrlicht_window );
|
||||
ModalDialog::dismiss();
|
||||
if (m_open_registration_dialog)
|
||||
new RegistrationDialog(0.8f, 0.9f, RegistrationDialog::Info);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ class LoginDialog : public GUIEngine::ModalDialog
|
||||
private:
|
||||
|
||||
bool m_self_destroy;
|
||||
bool m_open_registration_dialog;
|
||||
|
||||
public:
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "guiengine/widgets/button_widget.hpp"
|
||||
#include "guiengine/widgets/label_widget.hpp"
|
||||
#include "guiengine/widgets/text_box_widget.hpp"
|
||||
#include "guiengine/widgets/check_box_widget.hpp"
|
||||
#include "states_screens/state_manager.hpp"
|
||||
#include "utils/translation.hpp"
|
||||
#include "utils/string_utils.hpp"
|
||||
@@ -37,13 +38,54 @@ using namespace irr::gui;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
RegistrationDialog::RegistrationDialog(const float w, const float h) :
|
||||
RegistrationDialog::RegistrationDialog(const float w, const float h, const Phase phase) :
|
||||
ModalDialog(w,h)
|
||||
{
|
||||
m_self_destroy = false;
|
||||
m_username = "";
|
||||
m_email = "";
|
||||
m_email_confirm = "";
|
||||
m_password = "";
|
||||
m_password_confirm = "";
|
||||
m_agreement = false;
|
||||
//Left the agreement phase out as an option, defaults to the first phase.
|
||||
switch (phase)
|
||||
{
|
||||
case Info:
|
||||
showRegistrationInfo();
|
||||
break;
|
||||
case Activation:
|
||||
showRegistrationActivation();
|
||||
break;
|
||||
default:
|
||||
showRegistrationInfo();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
RegistrationDialog::~RegistrationDialog()
|
||||
{
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void RegistrationDialog::showRegistrationInfo(){
|
||||
clearWindow();
|
||||
m_phase = Info;
|
||||
loadFromFile("online/registration_info.stkgui");
|
||||
|
||||
TextBoxWidget* textBox = getWidget<TextBoxWidget>("password");
|
||||
//Password should always be reentered if previous has been clicked, or an error occurred.
|
||||
m_password = "";
|
||||
m_password_confirm = "";
|
||||
|
||||
TextBoxWidget* textBox = getWidget<TextBoxWidget>("username");
|
||||
assert(textBox != NULL);
|
||||
textBox->setText(m_username);
|
||||
textBox->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
|
||||
|
||||
textBox = getWidget<TextBoxWidget>("password");
|
||||
assert(textBox != NULL);
|
||||
textBox->setPasswordBox(true,L'*');
|
||||
|
||||
@@ -51,15 +93,138 @@ RegistrationDialog::RegistrationDialog(const float w, const float h) :
|
||||
assert(textBox != NULL);
|
||||
textBox->setPasswordBox(true,L'*');
|
||||
|
||||
textBox = getWidget<TextBoxWidget>("username");
|
||||
textBox = getWidget<TextBoxWidget>("email");
|
||||
assert(textBox != NULL);
|
||||
textBox->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
|
||||
textBox->setText(m_email);
|
||||
|
||||
textBox = getWidget<TextBoxWidget>("email_confirm");
|
||||
assert(textBox != NULL);
|
||||
textBox->setText(m_email_confirm);
|
||||
|
||||
LabelWidget * label = getWidget<LabelWidget>("info");
|
||||
assert(label != NULL);
|
||||
label->setColor(irr::video::SColor(255, 255, 0, 0));
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
RegistrationDialog::~RegistrationDialog()
|
||||
{
|
||||
void RegistrationDialog::showRegistrationTerms(){
|
||||
clearWindow();
|
||||
m_phase = Terms;
|
||||
loadFromFile("online/registration_terms.stkgui");
|
||||
CheckBoxWidget * checkbox = getWidget<CheckBoxWidget>("accepted");
|
||||
assert(checkbox != NULL);
|
||||
checkbox->setState(false);
|
||||
ButtonWidget * submitButton = getWidget<ButtonWidget>("submit");
|
||||
assert(submitButton != NULL);
|
||||
submitButton->setDeactivated();
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void RegistrationDialog::showRegistrationActivation(){
|
||||
clearWindow();
|
||||
m_phase = Activation;
|
||||
loadFromFile("online/registration_activation.stkgui");
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
bool RegistrationDialog::processInfoEvent(const std::string& eventSource){
|
||||
if (m_phase == Info)
|
||||
{
|
||||
if (eventSource == "next")
|
||||
{
|
||||
m_username = getWidget<TextBoxWidget>("username")->getText().trim();
|
||||
m_password = getWidget<TextBoxWidget>("password")->getText().trim();
|
||||
m_password_confirm = getWidget<TextBoxWidget>("password_confirm")->getText().trim();
|
||||
m_email = getWidget<TextBoxWidget>("email")->getText().trim();
|
||||
m_email_confirm = getWidget<TextBoxWidget>("email_confirm")->getText().trim();
|
||||
|
||||
//FIXME More validation of registration information (Though all validation should happen at the server too!)
|
||||
if (m_password != m_password_confirm)
|
||||
{
|
||||
getWidget<LabelWidget>("info")->setText(_("Passwords don't match!"), false);
|
||||
sfx_manager->quickSound( "anvil" );
|
||||
}
|
||||
else if (m_email != m_email_confirm)
|
||||
{
|
||||
getWidget<LabelWidget>("info")->setText(_("Emails don't match!"), false);
|
||||
sfx_manager->quickSound( "anvil" );
|
||||
}
|
||||
else if (m_username.size() < 5 || m_username.size() > 30)
|
||||
{
|
||||
getWidget<LabelWidget>("info")->setText(_("Username has to be between 5 and 30 characters long!"), false);
|
||||
sfx_manager->quickSound( "anvil" );
|
||||
}
|
||||
else if (m_password.size() < 5 || m_password.size() > 30)
|
||||
{
|
||||
getWidget<LabelWidget>("info")->setText(_("Password has to be between 5 and 30 characters long!"), false);
|
||||
sfx_manager->quickSound( "anvil" );
|
||||
}
|
||||
else if (m_email.size() < 5 || m_email.size() > 50)
|
||||
{
|
||||
getWidget<LabelWidget>("info")->setText(_("Email has to be between 5 and 50 characters long!"), false);
|
||||
sfx_manager->quickSound( "anvil" );
|
||||
}
|
||||
else
|
||||
{
|
||||
showRegistrationTerms();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
bool RegistrationDialog::processTermsEvent(const std::string& eventSource){
|
||||
if (m_phase == Terms)
|
||||
{
|
||||
if (eventSource == "submit")
|
||||
{
|
||||
if (getWidget<CheckBoxWidget>("accepted")->getState())
|
||||
{
|
||||
m_agreement = true;
|
||||
showRegistrationActivation();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else if (eventSource == "accepted")
|
||||
{
|
||||
CheckBoxWidget * checkbox = getWidget<CheckBoxWidget>("accepted");
|
||||
bool new_state = !checkbox->getState();
|
||||
checkbox->setState(new_state);
|
||||
ButtonWidget * submitButton = getWidget<ButtonWidget>("submit");
|
||||
if(new_state)
|
||||
submitButton->setActivated();
|
||||
else
|
||||
submitButton->setDeactivated();
|
||||
return true;
|
||||
}
|
||||
else if (eventSource == "previous")
|
||||
{
|
||||
showRegistrationInfo();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
bool RegistrationDialog::processActivationEvent(const std::string& eventSource){
|
||||
if (m_phase == Activation)
|
||||
{
|
||||
if (eventSource == "activate")
|
||||
{
|
||||
//FIXME : activate
|
||||
m_self_destroy = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -69,25 +234,11 @@ GUIEngine::EventPropagation RegistrationDialog::processEvent(const std::string&
|
||||
{
|
||||
if (eventSource == "cancel")
|
||||
{
|
||||
dismiss();
|
||||
m_self_destroy = true;
|
||||
return GUIEngine::EVENT_BLOCK;
|
||||
}
|
||||
else if(eventSource == "signin")
|
||||
else if (processInfoEvent(eventSource) or processTermsEvent(eventSource) or processActivationEvent(eventSource))
|
||||
{
|
||||
// ---- See if we can accept the input
|
||||
const stringw username = getWidget<TextBoxWidget>("username")->getText().trim();
|
||||
const stringw password = getWidget<TextBoxWidget>("password")->getText().trim();
|
||||
stringw info = "";
|
||||
if(CurrentOnlineUser::get()->signIn(username,password,info))
|
||||
{
|
||||
m_self_destroy = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
sfx_manager->quickSound( "anvil" );
|
||||
m_self_destroy = false;
|
||||
}
|
||||
getWidget<LabelWidget>("info")->setText(info, false);
|
||||
return GUIEngine::EVENT_BLOCK;
|
||||
}
|
||||
return GUIEngine::EVENT_LET;
|
||||
|
||||
@@ -22,32 +22,48 @@
|
||||
#include <irrString.h>
|
||||
|
||||
#include "guiengine/modaldialog.hpp"
|
||||
#include "guiengine/widgets/text_box_widget.hpp"
|
||||
|
||||
/**
|
||||
* \brief Dialog that allows a user to register
|
||||
* \ingroup states_screens
|
||||
*/
|
||||
class RegistrationDialog : public GUIEngine::ModalDialog
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
bool m_self_destroy;
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Creates a modal dialog with given percentage of screen width and height
|
||||
*/
|
||||
RegistrationDialog(const float percentWidth, const float percentHeight);
|
||||
enum Phase
|
||||
{
|
||||
Info = 1,
|
||||
Terms = 2,
|
||||
Activation = 3
|
||||
};
|
||||
|
||||
RegistrationDialog(const float percentWidth, const float percentHeight, const Phase phase);
|
||||
~RegistrationDialog();
|
||||
|
||||
void onEnterPressedInternal();
|
||||
GUIEngine::EventPropagation processEvent(const std::string& eventSource);
|
||||
|
||||
virtual void onUpdate(float dt);
|
||||
//virtual void onTextUpdated();
|
||||
|
||||
private:
|
||||
Phase m_phase;
|
||||
bool m_self_destroy;
|
||||
|
||||
//Saved user input :
|
||||
irr::core::stringw m_username;
|
||||
irr::core::stringw m_password;
|
||||
irr::core::stringw m_password_confirm;
|
||||
irr::core::stringw m_email;
|
||||
irr::core::stringw m_email_confirm;
|
||||
bool m_agreement;
|
||||
|
||||
void showRegistrationInfo();
|
||||
void showRegistrationTerms();
|
||||
void showRegistrationActivation();
|
||||
bool processInfoEvent(const std::string& eventSource);
|
||||
bool processTermsEvent(const std::string& eventSource);
|
||||
bool processActivationEvent(const std::string& eventSource);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user