Removed old login dialog. Fixed tabs in login screen that

were not properly focused.
This commit is contained in:
hiker 2014-01-21 17:11:48 +11:00
parent 50ef878e39
commit f0365fc7a0
19 changed files with 261 additions and 548 deletions

View File

@ -6,12 +6,12 @@
<header align="center" width="80%" text="Login" text_align="center"/>
<spacer height="15" width="10"/>
<tabs id="category" height="10%" max_height="110" x="2%" width="98%" align="center">
<icon-button id="login" width="128" height="128" icon="gui/track_random.png"
<tabs id="login_tabs" height="10%" max_height="110" x="2%" width="98%" align="center">
<icon-button id="tab_login" width="128" height="128" icon="gui/track_random.png"
I18N="Tab in login menu" text="Sign In"/>
<icon-button id="guest_login" width="128" height="128" icon="gui/mode_ftl.png"
<icon-button id="tab_guest_login" width="128" height="128" icon="gui/mode_ftl.png"
I18N="Tab in login menu" text="Sign In As Guest"/>
<icon-button id="register" width="128" height="128" icon="gui/mode_ftl.png"
<icon-button id="tab_register" width="128" height="128" icon="gui/mode_ftl.png"
I18N="Tab in login menu" text="Register"/>
</tabs>

View File

@ -6,12 +6,12 @@
<header align="center" width="80%" text="Login" text_align="center"/>
<spacer height="15" width="10"/>
<tabs id="category" height="10%" max_height="110" x="2%" width="98%" align="center">
<icon-button id="login" width="128" height="128" icon="gui/track_random.png"
<tabs id="login_tabs" height="10%" max_height="110" x="2%" width="98%" align="center">
<icon-button id="tab_login" width="128" height="128" icon="gui/track_random.png"
I18N="Tab in login menu" text="Sign In"/>
<icon-button id="guest_login" width="128" height="128" icon="gui/mode_ftl.png"
<icon-button id="tab_guest_login" width="128" height="128" icon="gui/mode_ftl.png"
I18N="Tab in login menu" text="Sign In As Guest"/>
<icon-button id="register" width="128" height="128" icon="gui/mode_ftl.png"
<icon-button id="tab_register" width="128" height="128" icon="gui/mode_ftl.png"
I18N="Tab in login menu" text="Register"/>
</tabs>
@ -40,7 +40,7 @@
</div>
<label id="info" proportion="1" width="90%" align="center" text_align="center"
word_wrap="true" text=""/>
<spacer height="40" width="20"/>
<spacer height="20" width="20"/>
<buttonbar id="options" width="90%" height="13%" align="bottom">
<icon-button id="sign_in" width="64" height="64" icon="gui/green_check.png"
I18N="Login dialog" text="Sign In" label_location="bottom"/>

View File

@ -1,59 +0,0 @@
<stkgui>
<div x="2%" y="5%" width="96%" height="90%" layout="vertical-row" >
<header id="title" width="96%" height="fit" text_align="center" word_wrap="true"
I18N="In the login dialog" text="Sign in"/>
<spacer height="25" width="50"/>
<label id="message" proportion="2" width="90%" align="center" text_align="left" word_wrap="true" text=""/>
<spacer height="40" width="50"/>
<div width="80%" align="center" layout="vertical-row" height="fit" >
<div width="100%" height="fit" layout="horizontal-row" >
<label proportion="1" height="100%" text_align="left" I18N="In the login dialog" text="Username"/>
<textbox proportion="2" height="fit" id="username" I18N="In the login dialog"/>
</div>
<spacer height="20" width="20"/>
<div width="100%" height="fit" layout="horizontal-row" >
<label proportion="1" height="100%" text_align="left" I18N="In the login dialog" text="Password"/>
<textbox x="5" proportion="2" height="fit" id="password" I18N="In the login dialog"/>
</div>
<spacer height="20" width="20"/>
<div width="100%" height="fit" layout="horizontal-row" >
<label proportion="1" text_align="left" I18N="In the login dialog" text="Stay signed in"/>
<div proportion="2" height="100%" layout="horizontal-row">
<checkbox width="fit" height="fit" id="remember" I18N="In the login dialog"/>
</div>
</div>
</div>
<spacer height="20" width="50"/>
<label id="info" proportion="1" width="90%" align="center" text_align="center" word_wrap="true" text=""/>
<spacer height="20" width="50"/>
<buttonbar id="options" width="90%" height="13%" align="center">
<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"/>
<icon-button id="register" width="64" height="64" icon="gui/tutorial.png"
I18N="Login dialog" text="Register" label_location="bottom"/>
<icon-button id="as_guest" width="64" height="64" icon="gui/main_about.png"
I18N="Login dialog" text="As guest" label_location="bottom"/>
<icon-button id="cancel" width="64" height="64" icon="gui/main_quit.png"
I18N="Login dialog" text="Close" label_location="bottom"/>
</buttonbar>
</div>
</stkgui>

View File

@ -32,10 +32,6 @@
<spacer width="10" height="10" />
<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="Online menu button" text="Sign In" label_location="hover"/>
<icon-button id="register" width="64" height="64" icon="gui/tutorial.png" extend_label="75"
I18N="Online menu button" text="Register" label_location="hover"/>
<icon-button id="profile" width="64" height="64" icon="gui/green_check.png" extend_label="50"
I18N="Online menu button" text="Profile" label_location="hover"/>
<icon-button id="sign_out" width="64" height="64" icon="gui/main_quit.png" extend_label="70"

View File

@ -6,12 +6,12 @@
<header align="center" width="80%" text="Login" text_align="center"/>
<spacer height="15" width="10"/>
<tabs id="category" height="10%" max_height="110" x="2%" width="98%" align="center">
<icon-button id="login" width="128" height="128" icon="gui/track_random.png"
<tabs id="login_tabs" height="10%" max_height="110" x="2%" width="98%" align="center">
<icon-button id="tab_login" width="128" height="128" icon="gui/track_random.png"
I18N="Tab in login menu" text="Sign In"/>
<icon-button id="guest_login" width="128" height="128" icon="gui/mode_ftl.png"
<icon-button id="tab_guest_login" width="128" height="128" icon="gui/mode_ftl.png"
I18N="Tab in login menu" text="Sign In As Guest"/>
<icon-button id="register" width="128" height="128" icon="gui/mode_ftl.png"
<icon-button id="tab_register" width="128" height="128" icon="gui/mode_ftl.png"
I18N="Tab in login menu" text="Register"/>
</tabs>

View File

@ -1,23 +0,0 @@
<stkgui>
<div x="2%" y="4%" width="96%" height="92%" layout="vertical-row" >
<header id="title" width="96%" height="fit" text_align="center" word_wrap="true"
I18N="In the registration dialog' dialog" text="Registration Complete"/>
<spacer height="25" width="50">
<label id="info" proportion="1" width="90%" align="center" text_align="center" word_wrap="true" I18N="In the registration dialog"
text="You will receive an email with further instructions regarding account activation. Please be patient and be sure to check your spam folder."/>
<spacer height="20" width="50">
<buttonbar id="options" width="25%" height="14%" align="center">
<icon-button id="cancel" width="64" height="64" icon="gui/green_check.png"
I18N="Registration dialog" text="Close" label_location="none"/>
</buttonbar>
</div>
</stkgui>

View File

@ -1,61 +0,0 @@
<stkgui>
<div x="2%" y="4%" width="96%" height="92%" layout="vertical-row" >
<header id="title" width="96%" height="fit" text_align="center" word_wrap="true"
I18N="In the registration dialog' dialog" text="Registration"/>
<spacer height="25" width="50">
<div width="80%" align="center" layout="vertical-row" height="fit">
<div width="100%" height="fit" layout="horizontal-row" >
<label proportion="1" height="100%" text_align="left" I18N="In the registration dialog" text="Username"/>
<textbox proportion="2" height="fit" id="username" I18N="In the registration dialog"/>
</div>
<spacer height="20" width="20">
<div width="100%" height="fit" layout="horizontal-row" >
<label proportion="1" height="100%" text_align="left" I18N="In the registration dialog" text="Password"/>
<textbox proportion="2" height="fit" id="password" I18N="In the registration dialog"/>
</div>
<spacer height="20" width="20">
<div width="100%" height="fit" layout="horizontal-row" >
<label proportion="1" height="100%" text_align="left" I18N="In the registration dialog" text="Confirm"/>
<textbox proportion="2" height="fit" id="password_confirm" I18N="In the registration dialog"/>
</div>
<spacer height="20" width="20">
<div width="100%" height="fit" layout="horizontal-row" >
<label proportion="1" height="100%" text_align="left" I18N="In the registration dialog" text="Email"/>
<textbox proportion="2" height="fit" id="email" I18N="In the registration dialog"/>
</div>
<spacer height="20" width="20">
<div width="100%" height="fit" layout="horizontal-row" >
<label proportion="1" height="100%" text_align="left" I18N="In the registration dialog" text="Confirm"/>
<textbox proportion="2" height="fit" id="email_confirm" I18N="In the registration dialog"/>
</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" text="You don't need to register if you have a STK Addons account!"/>
<spacer height="20" width="50">
<buttonbar id="options" width="25%" height="14%" 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>
</stkgui>

View File

@ -30,7 +30,6 @@
#include "states_screens/addons_screen.hpp"
#include "states_screens/dialogs/message_dialog.hpp"
#include "states_screens/dialogs/vote_dialog.hpp"
#include "states_screens/dialogs/login_dialog.hpp"
#include "states_screens/state_manager.hpp"
#include "tracks/track_manager.hpp"
#include "utils/string_utils.hpp"
@ -253,9 +252,7 @@ void AddonsLoading::voteClicked()
ModalDialog::dismiss();
if (Online::CurrentUser::get()->isRegisteredUser())
new VoteDialog(m_addon.getId());
else
new LoginDialog(LoginDialog::Registration_Required, new VoteDialog::LoginListener(m_addon.getId()));
}
} // voteClicked
// ----------------------------------------------------------------------------
void AddonsLoading::onUpdate(float delta)

View File

@ -1,217 +0,0 @@
// 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/login_dialog.hpp"
#include <IGUIEnvironment.h>
#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 "states_screens/dialogs/registration_dialog.hpp"
#include "states_screens/dialogs/recovery_dialog.hpp"
#include "online/messages.hpp"
using namespace GUIEngine;
using namespace irr;
using namespace irr::gui;
using namespace Online;
// -----------------------------------------------------------------------------
LoginDialog::LoginDialog(const Message message_type, const LoginDialog::Listener * listener) :
ModalDialog(0.8f,0.9f), m_listener(listener)
{
m_self_destroy = false;
m_open_registration_dialog = false;
m_open_recovery_dialog = false;
m_success = false;
loadFromFile("online/login_dialog.stkgui");
m_message_widget = getWidget<LabelWidget>("message");
assert(m_message_widget != NULL);
irr::core::stringw message("");
if (message_type == Normal)
message = _("Fill in your username and password. ");
else if (message_type == Signing_In_Required)
message = _("You need to sign in to be able to use this feature. ");
else if (message_type == Registration_Required)
message = _("You need to be a registered user to enjoy this feature! "
"If you do not have an account yet, you can sign up using the register icon at the bottom.");
else
message = "";
if (message_type == Normal || message_type == Signing_In_Required)
message += _("If you do not have an account yet, you can choose to sign in as a guest "
"or press the register icon at the bottom to gain access to all the features!");
m_message_widget->setText(message, false);
m_username_widget = getWidget<TextBoxWidget>("username");
assert(m_username_widget != NULL);
m_username_widget->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
m_password_widget = getWidget<TextBoxWidget>("password");
assert(m_password_widget != NULL);
m_password_widget->setPasswordBox(true,L'*');
m_remember_widget = getWidget<CheckBoxWidget>("remember");
assert(m_remember_widget != NULL);
m_remember_widget->setState(false);
m_info_widget = getWidget<LabelWidget>("info");
assert(m_info_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");
assert(m_recovery_widget != NULL);
m_register_widget = getWidget<IconButtonWidget>("register");
assert(m_register_widget != NULL);
m_as_guest_widget = getWidget<IconButtonWidget>("as_guest");
assert(m_as_guest_widget != NULL);
m_as_guest_widget->setDeactivated();
m_cancel_widget = getWidget<IconButtonWidget>("cancel");
assert(m_cancel_widget != NULL);
}
// -----------------------------------------------------------------------------
LoginDialog::~LoginDialog()
{
}
// -----------------------------------------------------------------------------
void LoginDialog::login()
{
const stringw username = m_username_widget->getText().trim();
const stringw password = m_password_widget->getText().trim();
if (username.size() < 4 || username.size() > 30 || password.size() < 8 || password.size() > 30)
{
sfx_manager->quickSound("anvil");
m_info_widget->setErrorColor();
m_info_widget->setText(_("Username and/or password invalid."), false);
}
else
{
m_options_widget->setDeactivated();
m_info_widget->setDefaultColor();
Online::CurrentUser::get()->requestSignIn(username,password, m_remember_widget->getState());
}
}
// -----------------------------------------------------------------------------
GUIEngine::EventPropagation LoginDialog::processEvent(const std::string& eventSource)
{
if (eventSource == m_options_widget->m_properties[PROP_ID])
{
const std::string& selection = m_options_widget->getSelectionIDString(PLAYER_ID_GAME_MASTER);
if (selection == m_cancel_widget->m_properties[PROP_ID])
{
m_self_destroy = true;
return GUIEngine::EVENT_BLOCK;
}
else if(selection == m_sign_in_widget->m_properties[PROP_ID])
{
login();
return GUIEngine::EVENT_BLOCK;
}
else if(selection == m_register_widget->m_properties[PROP_ID])
{
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;
}
// -----------------------------------------------------------------------------
void LoginDialog::onEnterPressedInternal()
{
const int playerID = PLAYER_ID_GAME_MASTER;
if (GUIEngine::isFocusedForPlayer(m_options_widget, playerID))
return;
if (m_sign_in_widget->isActivated())
login();
}
// -----------------------------------------------------------------------------
bool LoginDialog::onEscapePressed()
{
if (m_cancel_widget->isActivated())
m_self_destroy = true;
return false;
}
// -----------------------------------------------------------------------------
void LoginDialog::success()
{
m_success = true;
}
// -----------------------------------------------------------------------------
void LoginDialog::error(const irr::core::stringw & error)
{
sfx_manager->quickSound("anvil");
m_info_widget->setErrorColor();
m_info_widget->setText(error, false);
m_options_widget->setActivated();
m_as_guest_widget->setDeactivated();
}
// -----------------------------------------------------------------------------
void LoginDialog::onUpdate(float dt)
{
if(!m_options_widget->isActivated())
m_info_widget->setText(Online::Messages::signingIn(), false);
//If we want to open another dialog, we need to close this one first
m_self_destroy |= (m_open_registration_dialog || m_open_recovery_dialog || m_success);
bool open_registration_dialog = m_open_registration_dialog;
bool open_recovery_dialog = m_open_recovery_dialog;
bool success = m_success;
const LoginDialog::Listener *listener = m_listener;
// It's unsafe to delete from inside the event handler so we do it here
if (m_self_destroy)
{
ModalDialog::dismiss();
if (open_registration_dialog)
new RegistrationDialog();
else if (open_recovery_dialog)
new RecoveryDialog();
else if (success && (listener != NULL) )
listener->onClose();
return;
}
}

View File

@ -1,90 +0,0 @@
// 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_LOGIN_DIALOG_HPP
#define HEADER_LOGIN_DIALOG_HPP
#include <irrString.h>
#include "online/current_user.hpp"
#include "guiengine/modaldialog.hpp"
#include "guiengine/widgets.hpp"
/**
* \brief Dialog that allows a user to sign in
* \ingroup states_screens
*/
class LoginDialog : public GUIEngine::ModalDialog
{
public:
class Listener
{
public :
virtual void onClose() const = 0;
};
enum Message
{
Normal = 0, // If the user presses the sign in button himself
Signing_In_Required = 1, // If the user needs to be signed in
Registration_Required = 2 // If the user needs to be registered
};
/**
* Creates a modal dialog with given percentage of screen width and height
*/
LoginDialog(const Message = Normal, const LoginDialog::Listener * = NULL);
~LoginDialog();
virtual void onEnterPressedInternal();
void success();
void error(const irr::core::stringw & error_message);
GUIEngine::EventPropagation processEvent(const std::string& eventSource);
virtual bool onEscapePressed();
virtual void onUpdate(float dt);
private:
const Listener * m_listener;
bool m_self_destroy;
bool m_open_registration_dialog;
bool m_open_recovery_dialog;
bool m_success;
GUIEngine::LabelWidget * m_message_widget;
GUIEngine::TextBoxWidget * m_username_widget;
GUIEngine::TextBoxWidget * m_password_widget;
GUIEngine::CheckBoxWidget * m_remember_widget;
GUIEngine::LabelWidget * m_info_widget;
GUIEngine::RibbonWidget * m_options_widget;
GUIEngine::IconButtonWidget * m_sign_in_widget;
GUIEngine::IconButtonWidget * m_recovery_widget;
GUIEngine::IconButtonWidget * m_register_widget;
GUIEngine::IconButtonWidget * m_as_guest_widget;
GUIEngine::IconButtonWidget * m_cancel_widget;
void login();
};
#endif

View File

@ -24,8 +24,6 @@
#include "guiengine/modaldialog.hpp"
#include "guiengine/widgets.hpp"
#include "online/current_user.hpp"
#include "states_screens/dialogs/login_dialog.hpp"
/**
* \brief Dialog that allows a user to sign in
@ -33,15 +31,6 @@
*/
class VoteDialog : public GUIEngine::ModalDialog
{
public :
class LoginListener : public LoginDialog::Listener
{
const std::string m_addon_id;
public :
LoginListener(const std::string & addon_id) : m_addon_id(addon_id) {}
virtual void onClose() const { new VoteDialog(m_addon_id); }
};
private:
const std::string m_addon_id;
bool m_self_destroy;

View File

@ -32,20 +32,27 @@ GuestLoginScreen::GuestLoginScreen() : Screen("online/guest_login.stkgui")
{
} // GuestLoginScreen
// -----------------------------------------------------------------------------
/** Make sure this tab is actually selected.
*/
void GuestLoginScreen::init()
{
RibbonWidget* tabs = this->getWidget<RibbonWidget>("login_tabs");
if (tabs) tabs->select( "tab_guest_login", PLAYER_ID_GAME_MASTER );
} // init
// -----------------------------------------------------------------------------
void GuestLoginScreen::eventCallback(Widget* widget, const std::string& name,
const int playerID)
{
if (name == "category")
if (name == "login_tabs")
{
const std::string selection =
((RibbonWidget*)widget)->getSelectionIDString(PLAYER_ID_GAME_MASTER);
Log::warn("login", "selection %s", selection.c_str());
if (selection == "login")
if (selection == "tab_login")
StateManager::get()->replaceTopMostScreen(LoginScreen::getInstance());
else if (selection == "register")
else if (selection == "tab_register")
StateManager::get()->replaceTopMostScreen(RegisterScreen::getInstance());
}
else if (name=="options")

View File

@ -34,6 +34,7 @@ class GuestLoginScreen : public GUIEngine::Screen,
public:
virtual void init() OVERRIDE;
/** \brief implement callback from parent class GUIEngine::Screen */
virtual void loadedFromFile() OVERRIDE {};

View File

@ -45,6 +45,10 @@ LoginScreen::LoginScreen() : Screen("online/login.stkgui")
// -----------------------------------------------------------------------------
void LoginScreen::init()
{
// Make sure this tab is actually focused.
RibbonWidget* tabs = this->getWidget<RibbonWidget>("login_tabs");
if (tabs) tabs->select( "tab_login", PLAYER_ID_GAME_MASTER );
TextBoxWidget *password_widget = getWidget<TextBoxWidget>("password");
password_widget->setPasswordBox(true,L'*');
@ -55,6 +59,9 @@ void LoginScreen::init()
m_info_widget = getWidget<LabelWidget>("info");
assert(m_info_widget != NULL);
m_success = false;
// As default don't select 'remember'
getWidget<CheckBoxWidget>("remember")->setState(false);
} // loadedFromFile
// -----------------------------------------------------------------------------
@ -141,15 +148,15 @@ void LoginScreen::onUpdate(float dt, irr::video::IVideoDriver*)
void LoginScreen::eventCallback(Widget* widget, const std::string& name,
const int playerID)
{
if (name == "category")
if (name == "login_tabs")
{
StateManager *sm = StateManager::get();
const std::string selection =
((RibbonWidget*)widget)->getSelectionIDString(PLAYER_ID_GAME_MASTER);
if (selection == "guest_login")
if (selection == "tab_guest_login")
sm->replaceTopMostScreen(GuestLoginScreen::getInstance());
else if (selection == "register")
else if (selection == "tab_register")
sm->replaceTopMostScreen(RegisterScreen::getInstance());
}
else if (name=="options")

View File

@ -31,8 +31,6 @@
#include "main_loop.hpp"
#include "states_screens/state_manager.hpp"
#include "states_screens/dialogs/message_dialog.hpp"
#include "states_screens/dialogs/login_dialog.hpp"
#include "states_screens/dialogs/registration_dialog.hpp"
#include "states_screens/networking_lobby.hpp"
#include "states_screens/server_selection.hpp"
#include "states_screens/create_server_screen.hpp"
@ -89,10 +87,6 @@ void OnlineScreen::loadedFromFile()
m_bottom_menu_widget = getWidget<RibbonWidget>("menu_bottomrow");
assert(m_bottom_menu_widget != NULL);
m_sign_in_widget = (IconButtonWidget *) m_bottom_menu_widget->findWidgetNamed("sign_in");
assert(m_sign_in_widget != NULL);
m_register_widget = (IconButtonWidget *) m_bottom_menu_widget->findWidgetNamed("register");
assert(m_register_widget != NULL);
m_profile_widget = (IconButtonWidget *) m_bottom_menu_widget->findWidgetNamed("profile");
assert(m_profile_widget != NULL);
m_sign_out_widget = (IconButtonWidget *) m_bottom_menu_widget->findWidgetNamed("sign_out");
@ -117,29 +111,18 @@ void OnlineScreen::beforeAddingWidget()
m_bottom_menu_widget->setVisible(true);
m_top_menu_widget->setVisible(true);
hasStateChanged();
if (m_recorded_state == CurrentUser::US_SIGNED_IN)
{
m_register_widget->setVisible(false);
m_sign_in_widget->setVisible(false);
}
else if (m_recorded_state == CurrentUser::US_SIGNED_OUT || m_recorded_state == CurrentUser::US_SIGNING_IN || m_recorded_state == CurrentUser::US_SIGNING_OUT)
if (m_recorded_state == CurrentUser::US_SIGNED_OUT || m_recorded_state == CurrentUser::US_SIGNING_IN || m_recorded_state == CurrentUser::US_SIGNING_OUT)
{
m_quick_play_widget->setDeactivated();
m_find_server_widget->setDeactivated();
m_create_server_widget->setDeactivated();
m_sign_out_widget->setVisible(false);
m_profile_widget->setVisible(false);
if(m_recorded_state == CurrentUser::US_SIGNING_IN || m_recorded_state == CurrentUser::US_SIGNING_OUT)
{
m_register_widget->setDeactivated();
m_sign_in_widget->setDeactivated();
}
}
else if (m_recorded_state == CurrentUser::US_GUEST)
{
m_find_server_widget->setDeactivated();
m_create_server_widget->setDeactivated();
m_sign_in_widget->setVisible(false);
m_profile_widget->setVisible(false);
}
@ -189,11 +172,7 @@ void OnlineScreen::eventCallback(Widget* widget, const std::string& name, const
if (ribbon == NULL) return;
std::string selection = ribbon->getSelectionIDString(PLAYER_ID_GAME_MASTER);
if (selection == m_sign_in_widget->m_properties[PROP_ID])
{
new LoginDialog(LoginDialog::Normal);
}
else if (selection == m_sign_out_widget->m_properties[PROP_ID])
if (selection == m_sign_out_widget->m_properties[PROP_ID])
{
CurrentUser::get()->requestSignOut();
}
@ -202,10 +181,6 @@ void OnlineScreen::eventCallback(Widget* widget, const std::string& name, const
ProfileManager::get()->setVisiting(CurrentUser::get()->getID());
StateManager::get()->pushScreen(OnlineProfileOverview::getInstance());
}
else if (selection == m_register_widget->m_properties[PROP_ID])
{
new RegistrationDialog();
}
else if (selection == m_find_server_widget->m_properties[PROP_ID])
{
StateManager::get()->pushScreen(ServerSelection::getInstance());
@ -260,23 +235,6 @@ void OnlineScreen::tearDown()
{
}
// ----------------------------------------------------------------------------
void OnlineScreen::onDisabledItemClicked(const std::string& item)
{
if (item == "find_server")
{
new LoginDialog(LoginDialog::Registration_Required);
}
else if (item =="create_server")
{
new LoginDialog(LoginDialog::Registration_Required);
}
else if (item == "quick_play")
{
new LoginDialog(LoginDialog::Signing_In_Required);
}
} // onDisabledItemClicked
// ----------------------------------------------------------------------------
void OnlineScreen::setInitialFocus()
{

View File

@ -50,7 +50,6 @@ private:
GUIEngine::LabelWidget * m_online_status_widget;
GUIEngine::RibbonWidget * m_bottom_menu_widget;
GUIEngine::IconButtonWidget * m_sign_in_widget;
GUIEngine::IconButtonWidget * m_register_widget;
GUIEngine::IconButtonWidget * m_profile_widget;
GUIEngine::IconButtonWidget * m_sign_out_widget;
@ -82,9 +81,6 @@ public:
/** \brief implement callback from parent class GUIEngine::Screen */
virtual void tearDown() OVERRIDE;
/** \brief implement callback from parent class GUIEngine::Screen */
virtual void onDisabledItemClicked(const std::string& item) OVERRIDE;
/** \brief Implements the callback when a dialog gets closed. */
virtual void onDialogClose() OVERRIDE;
};

View File

@ -46,6 +46,10 @@ RegisterScreen::RegisterScreen() : Screen("online/register.stkgui")
// -----------------------------------------------------------------------------
void RegisterScreen::init()
{
// Make sure this tab is actually focused.
RibbonWidget* tabs = this->getWidget<RibbonWidget>("login_tabs");
if (tabs) tabs->select( "tab_register", PLAYER_ID_GAME_MASTER );
TextBoxWidget *password_widget = getWidget<TextBoxWidget>("password");
password_widget->setPasswordBox(true,L'*');
password_widget = getWidget<TextBoxWidget>("password_confirm");
@ -165,14 +169,14 @@ void RegisterScreen::onUpdate(float dt, irr::video::IVideoDriver*)
void RegisterScreen::eventCallback(Widget* widget, const std::string& name,
const int playerID)
{
if (name == "category")
if (name == "login_tabs")
{
const std::string selection =
((RibbonWidget*)widget)->getSelectionIDString(PLAYER_ID_GAME_MASTER);
StateManager *sm = StateManager::get();
if (selection == "login")
sm->replaceTopMostScreen(RegisterScreen::getInstance());
else if (selection == "guest_login")
if (selection == "tab_login")
sm->replaceTopMostScreen(LoginScreen::getInstance());
else if (selection == "tab_guest_login")
sm->replaceTopMostScreen(GuestLoginScreen::getInstance());
}
else if (name=="options")

View File

@ -0,0 +1,204 @@
// SuperTuxKart - a fun racing game with go-kart
// Copyright (C) 2014 Joerg Henrichs
//
// 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/register_screen.hpp"
#include "audio/sfx_manager.hpp"
#include "guiengine/widgets/label_widget.hpp"
#include "guiengine/widgets/ribbon_widget.hpp"
#include "guiengine/widgets/text_box_widget.hpp"
#include "online/current_user.hpp"
#include "online/messages.hpp"
#include "states_screens/dialogs/registration_dialog.hpp"
#include "states_screens/dialogs/message_dialog.hpp"
#include "states_screens/guest_login_screen.hpp"
#include "states_screens/login_screen.hpp"
#include "states_screens/main_menu_screen.hpp"
#include "states_screens/state_manager.hpp"
#include "utils/log.hpp"
#include "utils/translation.hpp"
using namespace GUIEngine;
using namespace Online;
DEFINE_SCREEN_SINGLETON( RegisterScreen );
// -----------------------------------------------------------------------------
RegisterScreen::RegisterScreen() : Screen("online/register.stkgui")
{
} // RegisterScreen
// -----------------------------------------------------------------------------
void RegisterScreen::init()
{
// Make sure this tab is actually focused.
RibbonWidget* tabs = this->getWidget<RibbonWidget>("login_tabs");
if (tabs) tabs->select( "tab_register", PLAYER_ID_GAME_MASTER );
TextBoxWidget *password_widget = getWidget<TextBoxWidget>("password");
password_widget->setPasswordBox(true,L'*');
password_widget = getWidget<TextBoxWidget>("password_confirm");
password_widget->setPasswordBox(true,L'*');
m_info_widget = getWidget<LabelWidget>("info");
assert(m_info_widget);
m_options_widget = getWidget<RibbonWidget>("options");
assert(m_options_widget);
m_signup_request = NULL;
m_info_message_shown = false;
} // init
// -----------------------------------------------------------------------------
void RegisterScreen::doRegister()
{
core::stringw username = getWidget<TextBoxWidget>("username")->getText().trim();
core::stringw password = getWidget<TextBoxWidget>("password")->getText().trim();
core::stringw password_confirm = getWidget<TextBoxWidget>("password_confirm")
->getText().trim();
core::stringw email = getWidget<TextBoxWidget>("email")->getText().trim();
core::stringw email_confirm = getWidget<TextBoxWidget>("email_confirm")
->getText().trim();
m_info_widget->setErrorColor();
if (password != password_confirm)
{
m_info_widget->setText(_("Passwords don't match!"), false);
}
else if (email != email_confirm)
{
m_info_widget->setText(_("Emails don't match!"), false);
}
else if (username.size() < 4 || username.size() > 30)
{
m_info_widget->setText(_("Username has to be between 4 and 30 characters long!"), false);
}
else if (password.size() < 8 || password.size() > 30)
{
m_info_widget->setText(_("Password has to be between 8 and 30 characters long!"), false);
}
else if (email.size() < 4 || email.size() > 50)
{
m_info_widget->setText(_("Email has to be between 4 and 50 characters long!"), false);
}
else
{
m_info_widget->setDefaultColor();
new MessageDialog(
_("=== STK Terms and Conditions ===\n"
"You must agree to these terms in order to register an account for STK."
"Still needs actual content. Preferably in an XML document which can then be parsed to be put here.\n\n"
"By checking the box below, you are confirming that you understand these terms."
"If you have any questions or comments regarding these terms,"
"one of the members of the development team would gladly assist you."
),
MessageDialog::MESSAGE_DIALOG_OK_CANCEL, NULL, false);
return;
}
sfx_manager->quickSound( "anvil" );
} // doRegister
// -----------------------------------------------------------------------------
/** Called from the registration info dialog when 'accept' is clicked.
*/
void RegisterScreen::acceptTerms()
{
m_options_widget->setDeactivated();
core::stringw username = getWidget<TextBoxWidget>("username")->getText().trim();
core::stringw password = getWidget<TextBoxWidget>("password")->getText().trim();
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);
} // acceptTerms
// -----------------------------------------------------------------------------
void RegisterScreen::onUpdate(float dt, irr::video::IVideoDriver*)
{
if(m_signup_request)
{
if(!m_options_widget->isActivated())
m_info_widget->setText(Messages::validatingInfo(), false);
if(m_signup_request->isDone())
{
if(m_signup_request->isSuccess())
{
new MessageDialog(
_("You will receive an email with further instructions "
"regarding account activation. Please be patient and be "
"sure to check your spam folder."),
MessageDialog::MESSAGE_DIALOG_OK, NULL, false);
// Set the flag that the message was shown, which will triger
// a pop of this menu and so a return to the main menu
m_info_message_shown = true;
}
else
{
// Error signing up, display error message
m_info_widget->setText(m_signup_request->getInfo(), false);
}
delete m_signup_request;
m_signup_request = NULL;
m_options_widget->setActivated();
}
}
else if(m_info_message_shown && !ModalDialog::isADialogActive())
{
// Once the info message was shown (signup was successful), but the
// message has been gone (user clicked on OK), go back to main menu
StateManager::get()->popMenu();
}
} // onUpdate
// -----------------------------------------------------------------------------
void RegisterScreen::eventCallback(Widget* widget, const std::string& name,
const int playerID)
{
if (name == "login_tabs")
{
const std::string selection =
((RibbonWidget*)widget)->getSelectionIDString(PLAYER_ID_GAME_MASTER);
StateManager *sm = StateManager::get();
if (selection == "tab_login")
sm->replaceTopMostScreen(LoginScreen::getInstance());
else if (selection == "tab_guest_login")
sm->replaceTopMostScreen(GuestLoginScreen::getInstance());
}
else if (name=="options")
{
const std::string button = m_options_widget
->getSelectionIDString(PLAYER_ID_GAME_MASTER);
if(button=="next")
{
doRegister();
}
else if(button=="cancel")
StateManager::get()->escapePressed();
}
} // eventCallback
// -----------------------------------------------------------------------------

View File

@ -92,7 +92,9 @@ void StoryModeLobbyScreen::tearDown()
// ----------------------------------------------------------------------------
void StoryModeLobbyScreen::eventCallback(Widget* widget, const std::string& name, const int playerID)
void StoryModeLobbyScreen::eventCallback(Widget* widget,
const std::string& name,
const int player_id)
{
if (name == "back")
{
@ -122,8 +124,9 @@ void StoryModeLobbyScreen::eventCallback(Widget* widget, const std::string& name
if (!slot_found)
{
fprintf(stderr, "[StoryModeLobbyScreen] ERROR: cannot find player corresponding to slot '%s'\n",
core::stringc(list->getSelectionLabel().c_str()).c_str());
Log::error("StoryModeLobby",
"Cannot find player corresponding to slot '%s'.",
core::stringc(list->getSelectionLabel().c_str()).c_str());
}
else
{
@ -164,12 +167,13 @@ void StoryModeLobbyScreen::onNewPlayerWithName(const stringw& newName)
if (!slot_found)
{
fprintf(stderr, "[StoryModeLobbyScreen] ERROR: cannot find player corresponding to slot '%s'\n",
core::stringc(newName.c_str()).c_str());
Log::error("StoryModeLobbyScreen",
"Cannot find player corresponding to slot '%s'.",
core::stringc(newName.c_str()).c_str());
}
StateManager::get()->resetAndGoToScreen(MainMenuScreen::getInstance());
}
} // onNewPlayerWithName
// -----------------------------------------------------------------------------