Registration process fine-tuned. Using icons now and the asynchronous layer. Still TODO : activation and recovery.
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/uni@13331 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
@@ -21,8 +21,8 @@
|
||||
|
||||
<label id="info" proportion="1" width="100%" align="center" text_align="center" word_wrap="true" text=""/>
|
||||
|
||||
<buttonbar id="options" x="0" y="0" width="30%" height="12%" align="center">
|
||||
<icon-button id="create" width="64" height="64" icon="gui/tutorial.png"
|
||||
<buttonbar id="options" x="0" y="0" width="25%" height="12%" align="center">
|
||||
<icon-button id="create" width="64" height="64" icon="gui/green_check.png"
|
||||
I18N="Main menu button" text="Create" label_location="bottom"/>
|
||||
<icon-button id="cancel" width="64" height="64" icon="gui/main_quit.png"
|
||||
I18N="Main menu button" text="Cancel" label_location="bottom"/>
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
<spacer height="20" width="50">
|
||||
|
||||
<buttonbar id="options" width="90%" proportion="1" align="center">
|
||||
<icon-button id="sign_in" width="64" height="64" icon="gui/main_options.png"
|
||||
<icon-button id="sign_in" width="64" height="64" icon="gui/green_check.png"
|
||||
I18N="Login dialog" text="Sign In" label_location="bottom"/>
|
||||
<icon-button id="recovery" width="64" height="64" icon="gui/main_help.png"
|
||||
I18N="Login dialog" text="Recovery" label_location="bottom"/>
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
|
||||
<spacer width="10" height="10" />
|
||||
|
||||
<buttonbar id="menu_bottomrow" x="0" y="0" width="10%" height="100%" align="center">
|
||||
<buttonbar id="menu_bottomrow" x="0" y="0" width="12%" height="100%" align="center">
|
||||
<icon-button id="sign_in" width="64" height="64" icon="gui/main_about.png" extend_label="50"
|
||||
I18N="Main menu button" text="Sign In" label_location="hover"/>
|
||||
<icon-button id="register" width="64" height="64" icon="gui/tutorial.png" extend_label="75"
|
||||
|
||||
@@ -15,11 +15,12 @@
|
||||
|
||||
<spacer height="20" width="50">
|
||||
|
||||
<div id="options" width="fit" proportion="1" align="center" layout="horizontal-row">
|
||||
<button id="next" 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>
|
||||
<buttonbar id="options" width="25%" proportion="1" align="center">
|
||||
<icon-button id="next" width="64" height="64" icon="gui/green_check.png"
|
||||
I18N="Registration dialog" text="Next" label_location="none"/>
|
||||
<icon-button id="cancel" width="64" height="64" icon="gui/main_quit.png"
|
||||
I18N="Registration dialog" text="Cancel" label_location="none"/>
|
||||
</buttonbar>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
@@ -49,12 +49,12 @@
|
||||
|
||||
<spacer height="20" width="50">
|
||||
|
||||
<div id="options" width="fit" proportion="1" align="center" layout="horizontal-row">
|
||||
<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"/>
|
||||
</div>
|
||||
|
||||
<buttonbar id="options" width="25%" proportion="1" align="center">
|
||||
<icon-button id="next" width="64" height="64" icon="gui/green_check.png"
|
||||
I18N="Registration dialog" text="Next" label_location="none"/>
|
||||
<icon-button id="cancel" width="64" height="64" icon="gui/main_quit.png"
|
||||
I18N="Registration dialog" text="Cancel" label_location="none"/>
|
||||
</buttonbar>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
<spacer height="20" width="50">
|
||||
|
||||
<label id="terms" proportion="6" width="90%" align="center" text_align="center" word_wrap="true"
|
||||
<label id="terms" proportion="5" 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" >
|
||||
@@ -22,14 +22,15 @@
|
||||
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="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="Submit"/>
|
||||
<spacer height="50" width="50">
|
||||
<button id="cancel" height="fit" align="center" width="fit" I18N="In the registration dialog" text="Cancel"/>
|
||||
</div>
|
||||
|
||||
<buttonbar id="options" width="45%" proportion="1" align="center">
|
||||
<icon-button id="previous" width="64" height="64" icon="gui/back.png"
|
||||
I18N="Registration dialog" text="Previous" label_location="bottom"/>
|
||||
<icon-button id="next" width="64" height="64" icon="gui/green_check.png"
|
||||
I18N="Registration dialog" text="Submit" label_location="bottom"/>
|
||||
<icon-button id="cancel" width="64" height="64" icon="gui/main_quit.png"
|
||||
I18N="Registration dialog" text="Cancel" label_location="bottom"/>
|
||||
</buttonbar>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
<spacer height="20" width="50">
|
||||
|
||||
<buttonbar id="options" width="90%" height="20%" align="center">
|
||||
<icon-button id="join" width="64" height="64" icon="gui/main_options.png"
|
||||
<icon-button id="join" width="64" height="64" icon="gui/green_check.png"
|
||||
I18N="Login dialog" text="Join" label_location="bottom"/>
|
||||
<icon-button id="cancel" width="64" height="64" icon="gui/main_quit.png"
|
||||
I18N="Login dialog" text="Cancel" label_location="bottom"/>
|
||||
|
||||
@@ -77,37 +77,38 @@ void RegistrationDialog::showRegistrationInfo(){
|
||||
m_password = "";
|
||||
m_password_confirm = "";
|
||||
|
||||
TextBoxWidget* textBox = getWidget<TextBoxWidget>("username");
|
||||
assert(textBox != NULL);
|
||||
textBox->setText(m_username);
|
||||
textBox->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
|
||||
m_username_widget = getWidget<TextBoxWidget>("username");
|
||||
assert(m_username_widget != NULL);
|
||||
m_username_widget->setText(m_username);
|
||||
m_username_widget->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
|
||||
|
||||
textBox = getWidget<TextBoxWidget>("password");
|
||||
assert(textBox != NULL);
|
||||
textBox->setPasswordBox(true,L'*');
|
||||
m_password_widget = getWidget<TextBoxWidget>("password");
|
||||
assert(m_password_widget != NULL);
|
||||
m_password_widget->setPasswordBox(true,L'*');
|
||||
|
||||
textBox = getWidget<TextBoxWidget>("password_confirm");
|
||||
assert(textBox != NULL);
|
||||
textBox->setPasswordBox(true,L'*');
|
||||
m_password_confirm_widget = getWidget<TextBoxWidget>("password_confirm");
|
||||
assert(m_password_confirm_widget != NULL);
|
||||
m_password_confirm_widget->setPasswordBox(true,L'*');
|
||||
|
||||
textBox = getWidget<TextBoxWidget>("email");
|
||||
assert(textBox != NULL);
|
||||
textBox->setText(m_email);
|
||||
m_email_widget = getWidget<TextBoxWidget>("email");
|
||||
assert(m_email_widget != NULL);
|
||||
m_email_widget->setText(m_email);
|
||||
|
||||
textBox = getWidget<TextBoxWidget>("email_confirm");
|
||||
assert(textBox != NULL);
|
||||
textBox->setText(m_email_confirm);
|
||||
m_email_confirm_widget = getWidget<TextBoxWidget>("email_confirm");
|
||||
assert(m_email_confirm_widget != NULL);
|
||||
m_email_confirm_widget->setText(m_email_confirm);
|
||||
|
||||
LabelWidget* label = getWidget<LabelWidget>("info");
|
||||
assert(label != NULL);
|
||||
label->setText(m_registration_error, false);
|
||||
|
||||
ButtonWidget * button = getWidget<ButtonWidget>("next");
|
||||
assert(button != NULL);
|
||||
|
||||
button = getWidget<ButtonWidget>("cancel");
|
||||
assert(button != NULL);
|
||||
m_info_widget = getWidget<LabelWidget>("info");
|
||||
assert(m_info_widget != NULL);
|
||||
m_info_widget->setErrorColor();
|
||||
m_info_widget->setText(m_registration_error, false);
|
||||
|
||||
m_options_widget = getWidget<RibbonWidget>("options");
|
||||
assert(m_options_widget != NULL);
|
||||
m_next_widget = getWidget<IconButtonWidget>("next");
|
||||
assert(m_next_widget != NULL);
|
||||
m_cancel_widget = getWidget<IconButtonWidget>("cancel");
|
||||
assert(m_cancel_widget != NULL);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
@@ -117,13 +118,24 @@ void RegistrationDialog::showRegistrationTerms(){
|
||||
clearWindow();
|
||||
m_phase = Terms;
|
||||
loadFromFile("online/registration_terms.stkgui");
|
||||
CheckBoxWidget * checkbox = getWidget<CheckBoxWidget>("accepted");
|
||||
assert(checkbox != NULL);
|
||||
checkbox->setState(false);
|
||||
checkbox->setFocusForPlayer(PLAYER_ID_GAME_MASTER); //FIXME set focus on the terms
|
||||
ButtonWidget * submitButton = getWidget<ButtonWidget>("next");
|
||||
assert(submitButton != NULL);
|
||||
submitButton->setDeactivated();
|
||||
m_accept_terms_widget = getWidget<CheckBoxWidget>("accepted");
|
||||
assert(m_accept_terms_widget != NULL);
|
||||
m_accept_terms_widget->setState(false);
|
||||
m_accept_terms_widget->setFocusForPlayer(PLAYER_ID_GAME_MASTER); //FIXME set focus on the terms
|
||||
|
||||
m_info_widget = getWidget<LabelWidget>("info");
|
||||
assert(m_info_widget != NULL);
|
||||
m_info_widget->setText(m_registration_error, false);
|
||||
|
||||
m_options_widget = getWidget<RibbonWidget>("options");
|
||||
assert(m_options_widget != NULL);
|
||||
m_previous_widget = getWidget<IconButtonWidget>("previous");
|
||||
assert(m_previous_widget != NULL);
|
||||
m_next_widget = getWidget<IconButtonWidget>("next");
|
||||
assert(m_next_widget != NULL);
|
||||
m_cancel_widget = getWidget<IconButtonWidget>("cancel");
|
||||
assert(m_cancel_widget != NULL);
|
||||
m_next_widget->setDeactivated();
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
@@ -133,6 +145,17 @@ void RegistrationDialog::showRegistrationActivation(){
|
||||
clearWindow();
|
||||
m_phase = Activation;
|
||||
loadFromFile("online/registration_activation.stkgui");
|
||||
|
||||
m_info_widget = getWidget<LabelWidget>("info");
|
||||
assert(m_info_widget != NULL);
|
||||
m_info_widget->setText(m_registration_error, false);
|
||||
|
||||
m_options_widget = getWidget<RibbonWidget>("options");
|
||||
assert(m_options_widget != NULL);
|
||||
m_next_widget = getWidget<IconButtonWidget>("next");
|
||||
assert(m_next_widget != NULL);
|
||||
m_cancel_widget = getWidget<IconButtonWidget>("cancel");
|
||||
assert(m_cancel_widget != NULL);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
@@ -140,35 +163,34 @@ void RegistrationDialog::showRegistrationActivation(){
|
||||
bool RegistrationDialog::processInfoEvent(const std::string& eventSource){
|
||||
if (m_phase == Info)
|
||||
{
|
||||
if (eventSource == "next")
|
||||
if (eventSource == m_next_widget->m_properties[PROP_ID])
|
||||
{
|
||||
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();
|
||||
LabelWidget * info_widget = getWidget<LabelWidget>("info");
|
||||
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
|
||||
info_widget->setErrorColor();
|
||||
m_info_widget->setErrorColor();
|
||||
if (m_password != m_password_confirm)
|
||||
{
|
||||
info_widget->setText(_("Passwords don't match!"), false);
|
||||
m_info_widget->setText(_("Passwords don't match!"), false);
|
||||
}
|
||||
else if (m_email != m_email_confirm)
|
||||
{
|
||||
info_widget->setText(_("Emails don't match!"), false);
|
||||
m_info_widget->setText(_("Emails don't match!"), false);
|
||||
}
|
||||
else if (m_username.size() < 4 || m_username.size() > 30)
|
||||
{
|
||||
info_widget->setText(_("Username has to be between 4 and 30 characters long!"), false);
|
||||
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)
|
||||
{
|
||||
info_widget->setText(_("Password has to be between 8 and 30 characters long!"), false);
|
||||
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)
|
||||
{
|
||||
info_widget->setText(_("Email has to be between 4 and 50 characters long!"), false);
|
||||
m_info_widget->setText(_("Email has to be between 4 and 50 characters long!"), false);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -187,26 +209,27 @@ bool RegistrationDialog::processInfoEvent(const std::string& eventSource){
|
||||
bool RegistrationDialog::processTermsEvent(const std::string& eventSource){
|
||||
if (m_phase == Terms)
|
||||
{
|
||||
if (eventSource == "next")
|
||||
if (eventSource == m_next_widget->m_properties[PROP_ID])
|
||||
{
|
||||
assert(getWidget<CheckBoxWidget>("accepted")->getState());
|
||||
assert(m_accept_terms_widget->getState());
|
||||
m_options_widget->setDeactivated();
|
||||
m_info_widget->setDefaultColor();
|
||||
m_info_widget->setText(Messages::signingUp(), false);
|
||||
m_sign_up_request = CurrentUser::acquire()->requestSignUp(m_username, m_password, m_password_confirm, m_email, true);
|
||||
CurrentUser::release();
|
||||
return true;
|
||||
}
|
||||
else if (eventSource == "accepted")
|
||||
else if (eventSource == m_accept_terms_widget->m_properties[PROP_ID])
|
||||
{
|
||||
CheckBoxWidget * checkbox = getWidget<CheckBoxWidget>("accepted");
|
||||
bool new_state = !checkbox->getState();
|
||||
checkbox->setState(new_state);
|
||||
ButtonWidget * submitButton = getWidget<ButtonWidget>("next");
|
||||
bool new_state = !m_accept_terms_widget->getState();
|
||||
m_accept_terms_widget->setState(new_state);
|
||||
if(new_state)
|
||||
submitButton->setActivated();
|
||||
m_next_widget->setActivated();
|
||||
else
|
||||
submitButton->setDeactivated();
|
||||
m_next_widget->setDeactivated();
|
||||
return true;
|
||||
}
|
||||
else if (eventSource == "previous")
|
||||
else if (eventSource == m_previous_widget->m_properties[PROP_ID])
|
||||
{
|
||||
m_show_registration_info = true;
|
||||
return true;
|
||||
@@ -220,7 +243,7 @@ bool RegistrationDialog::processTermsEvent(const std::string& eventSource){
|
||||
bool RegistrationDialog::processActivationEvent(const std::string& eventSource){
|
||||
if (m_phase == Activation)
|
||||
{
|
||||
if (eventSource == "next")
|
||||
if (eventSource == m_next_widget->m_properties[PROP_ID])
|
||||
{
|
||||
//FIXME : activate
|
||||
m_self_destroy = true;
|
||||
@@ -230,17 +253,28 @@ bool RegistrationDialog::processActivationEvent(const std::string& eventSource){
|
||||
return false;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
bool RegistrationDialog::onEscapePressed()
|
||||
{
|
||||
return m_cancel_widget->isActivated();
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
GUIEngine::EventPropagation RegistrationDialog::processEvent(const std::string& eventSource)
|
||||
{
|
||||
if (eventSource == "cancel")
|
||||
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 (processInfoEvent(eventSource) || processTermsEvent(eventSource) || processActivationEvent(eventSource))
|
||||
else if (processInfoEvent(selection) || processTermsEvent(selection) || processActivationEvent(selection))
|
||||
{
|
||||
return GUIEngine::EVENT_BLOCK;
|
||||
}
|
||||
@@ -251,23 +285,11 @@ GUIEngine::EventPropagation RegistrationDialog::processEvent(const std::string&
|
||||
|
||||
void RegistrationDialog::onEnterPressedInternal()
|
||||
{
|
||||
//If enter was pressed while no button was focused, then interpret as "next" press.
|
||||
const int playerID = PLAYER_ID_GAME_MASTER;
|
||||
bool interpret_as_next = true;
|
||||
ButtonWidget * cancel_widget = getWidget<ButtonWidget>("cancel");
|
||||
ButtonWidget * next_widget = getWidget<ButtonWidget>("next");
|
||||
interpret_as_next = interpret_as_next &&
|
||||
!GUIEngine::isFocusedForPlayer(next_widget, playerID) &&
|
||||
!GUIEngine::isFocusedForPlayer(cancel_widget, playerID);
|
||||
if (interpret_as_next && m_phase == Terms)
|
||||
{
|
||||
ButtonWidget * previous_widget = getWidget<ButtonWidget>("previous");
|
||||
interpret_as_next = interpret_as_next && !GUIEngine::isFocusedForPlayer(previous_widget, playerID);
|
||||
}
|
||||
if (interpret_as_next)
|
||||
{
|
||||
|
||||
if (GUIEngine::isFocusedForPlayer(m_options_widget, PLAYER_ID_GAME_MASTER))
|
||||
return;
|
||||
if (m_next_widget->isActivated())
|
||||
processEvent("next");
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
@@ -296,10 +318,8 @@ void RegistrationDialog::onUpdate(float dt)
|
||||
}
|
||||
else
|
||||
{
|
||||
LabelWidget* label = getWidget<LabelWidget>("info");
|
||||
assert(label != NULL);
|
||||
label->setDefaultColor();
|
||||
label->setText(Messages::signingUp(), false);
|
||||
m_info_widget->setDefaultColor();
|
||||
m_info_widget->setText(Messages::signingUp(), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,6 +46,7 @@ public:
|
||||
GUIEngine::EventPropagation processEvent(const std::string& eventSource);
|
||||
|
||||
virtual void onUpdate(float dt);
|
||||
virtual bool onEscapePressed();
|
||||
|
||||
private:
|
||||
|
||||
@@ -67,6 +68,20 @@ private:
|
||||
irr::core::stringw m_registration_error;
|
||||
bool m_agreement;
|
||||
|
||||
GUIEngine::TextBoxWidget * m_username_widget;
|
||||
GUIEngine::TextBoxWidget * m_password_widget;
|
||||
GUIEngine::TextBoxWidget * m_password_confirm_widget;
|
||||
GUIEngine::TextBoxWidget * m_email_widget;
|
||||
GUIEngine::TextBoxWidget * m_email_confirm_widget;
|
||||
|
||||
GUIEngine::LabelWidget * m_info_widget;
|
||||
|
||||
GUIEngine::RibbonWidget * m_options_widget;
|
||||
GUIEngine::IconButtonWidget * m_previous_widget;
|
||||
GUIEngine::IconButtonWidget * m_next_widget;
|
||||
GUIEngine::IconButtonWidget * m_cancel_widget;
|
||||
|
||||
GUIEngine::CheckBoxWidget * m_accept_terms_widget;
|
||||
|
||||
void showRegistrationInfo();
|
||||
void showRegistrationTerms();
|
||||
|
||||
Reference in New Issue
Block a user