Fixed what should happen when pressing enter in the register and sign in dialog.

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/uni@13051 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
unitraxx 2013-07-01 01:06:11 +00:00
parent 5ecf73d90f
commit 49717d8cca
3 changed files with 18 additions and 16 deletions

View File

@ -70,6 +70,8 @@ LoginDialog::LoginDialog(const Message message_type) :
m_message_widget = getWidget<LabelWidget>("message");
assert(m_message_widget != NULL);
m_options_widget = getWidget<RibbonWidget>("options");
assert(m_options_widget != NULL);
m_sign_in_widget = getWidget<IconButtonWidget>("sign_in");
assert(m_sign_in_widget != NULL);
m_recovery_widget = getWidget<IconButtonWidget>("recovery");
@ -126,15 +128,12 @@ GUIEngine::EventPropagation LoginDialog::processEvent(const std::string& eventSo
void LoginDialog::onEnterPressedInternal()
{
//If enter was pressed while none of the other widgets are focused, then interpret as "signin" press.
//If enter was pressed while none of the buttons was focused interpret as sign_in event
const int playerID = PLAYER_ID_GAME_MASTER;
if (!GUIEngine::isFocusedForPlayer(m_recovery_widget, playerID) &&
!GUIEngine::isFocusedForPlayer(m_register_widget, playerID) &&
!GUIEngine::isFocusedForPlayer(m_as_guest_widget, playerID) &&
!GUIEngine::isFocusedForPlayer(m_cancel_widget, playerID))
{
processEvent("sign_in");
}
if (GUIEngine::isFocusedForPlayer(m_options_widget, playerID))
return;
processEvent("sign_in");
}
// -----------------------------------------------------------------------------

View File

@ -24,6 +24,7 @@
#include "guiengine/modaldialog.hpp"
#include "guiengine/widgets/text_box_widget.hpp"
#include "guiengine/widgets/icon_button_widget.hpp"
#include "guiengine/widgets/ribbon_widget.hpp"
#include "guiengine/widgets/label_widget.hpp"
/**
@ -43,6 +44,7 @@ private:
GUIEngine::TextBoxWidget * m_password_widget;
GUIEngine::LabelWidget * m_message_widget;
GUIEngine::RibbonWidget * m_options_widget;
GUIEngine::IconButtonWidget * m_sign_in_widget;
GUIEngine::IconButtonWidget * m_recovery_widget;
GUIEngine::IconButtonWidget * m_register_widget;

View File

@ -147,7 +147,7 @@ bool RegistrationDialog::processInfoEvent(const std::string& eventSource){
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!)
//FIXME More validation of registration information
if (m_password != m_password_confirm)
{
getWidget<LabelWidget>("info")->setText(_("Passwords don't match!"), false);
@ -260,17 +260,18 @@ GUIEngine::EventPropagation RegistrationDialog::processEvent(const std::string&
void RegistrationDialog::onEnterPressedInternal()
{
//If enter was pressed while "cancel" nor "previous" was selected, then interpret as "next" press.
//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* button = getWidget<ButtonWidget>("cancel");
assert(button != NULL);
interpret_as_next = interpret_as_next && !GUIEngine::isFocusedForPlayer(button, playerID);
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)
{
button = getWidget<ButtonWidget>("previous");
assert(button != NULL);
interpret_as_next = interpret_as_next && !GUIEngine::isFocusedForPlayer(button, playerID);
ButtonWidget * previous_widget = getWidget<ButtonWidget>("previous");
interpret_as_next = interpret_as_next && !GUIEngine::isFocusedForPlayer(previous_widget, playerID);
}
if (interpret_as_next)
{