Improve flow from register screen back to user screen. Now password
and online user name do not need to be added again.
This commit is contained in:
parent
5ccedfc349
commit
7bd1126df8
@ -18,7 +18,7 @@
|
||||
<div width="90%" align="center" layout="vertical-row" height="80%">
|
||||
<div width="100%" height="12%" layout="horizontal-row" >
|
||||
<label proportion="1" height="100%" text_align="left"
|
||||
I18N="In the registration dialog" text="Local Username"/>
|
||||
I18N="In the registration dialog" text="Name"/>
|
||||
<textbox id="local_username" proportion="2" height="fit" I18N="In the registration dialog"/>
|
||||
</div>
|
||||
|
||||
|
@ -45,11 +45,20 @@ DEFINE_SCREEN_SINGLETON( RegisterScreen );
|
||||
RegisterScreen::RegisterScreen() : Screen("online/register.stkgui")
|
||||
{
|
||||
m_existing_player = NULL;
|
||||
m_account_mode = ACCOUNT_OFFLINE;
|
||||
} // RegisterScreen
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
void RegisterScreen::init()
|
||||
{
|
||||
m_info_widget = getWidget<LabelWidget>("info");
|
||||
assert(m_info_widget);
|
||||
m_info_widget->setDefaultColor();
|
||||
m_options_widget = getWidget<RibbonWidget>("options");
|
||||
assert(m_options_widget);
|
||||
m_password_widget = getWidget<TextBoxWidget>("password");
|
||||
assert(m_password_widget);
|
||||
|
||||
RibbonWidget* ribbon = getWidget<RibbonWidget>("mode_tabs");
|
||||
assert(ribbon);
|
||||
if (UserConfigParams::m_internet_status !=
|
||||
@ -87,16 +96,8 @@ void RegisterScreen::init()
|
||||
|
||||
getWidget<TextBoxWidget>("local_username")->setText(username);
|
||||
|
||||
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_info_widget->setDefaultColor();
|
||||
m_options_widget = getWidget<RibbonWidget>("options");
|
||||
assert(m_options_widget);
|
||||
m_password_widget->setPasswordBox(true, L'*');
|
||||
getWidget<TextBoxWidget>("password_confirm")->setPasswordBox(true, L'*');
|
||||
|
||||
m_signup_request = NULL;
|
||||
m_info_message_shown = false;
|
||||
@ -141,7 +142,7 @@ void RegisterScreen::makeEntryFieldsVisible()
|
||||
bool online = m_account_mode != ACCOUNT_OFFLINE;
|
||||
getWidget<TextBoxWidget>("username")->setVisible(online);
|
||||
getWidget<LabelWidget >("label_username")->setVisible(online);
|
||||
getWidget<TextBoxWidget>("password")->setVisible(online);
|
||||
m_password_widget->setVisible(online);
|
||||
getWidget<LabelWidget >("label_password")->setVisible(online);
|
||||
|
||||
bool new_account = online && (m_account_mode == ACCOUNT_NEW_ONLINE);
|
||||
@ -213,13 +214,20 @@ void RegisterScreen::doRegister()
|
||||
// If no online account is requested, don't register
|
||||
if(m_account_mode!=ACCOUNT_NEW_ONLINE|| m_existing_player)
|
||||
{
|
||||
StateManager::get()->popMenu();
|
||||
bool online = m_account_mode == ACCOUNT_EXISTING_ONLINE;
|
||||
core::stringw password = online ? m_password_widget->getText() : "";
|
||||
core::stringw online_name =
|
||||
online ? getWidget<TextBoxWidget>("username")->getText().trim()
|
||||
: "";
|
||||
//m_parent_screen->setNewAccountData(online, online_name, password);
|
||||
m_parent_screen->setNewAccountData(true, "online", "password");
|
||||
m_existing_player = NULL;
|
||||
StateManager::get()->popMenu();
|
||||
return;
|
||||
}
|
||||
|
||||
stringw username = getWidget<TextBoxWidget>("username")->getText().trim();
|
||||
stringw password = getWidget<TextBoxWidget>("password")->getText().trim();
|
||||
stringw password = m_password_widget->getText().trim();
|
||||
stringw password_confirm = getWidget<TextBoxWidget>("password_confirm")
|
||||
->getText().trim();
|
||||
stringw email = getWidget<TextBoxWidget>("email")->getText().trim();
|
||||
@ -272,6 +280,10 @@ void RegisterScreen::doRegister()
|
||||
PlayerProfile *player = PlayerManager::get()->getPlayer(local_name);
|
||||
if (player)
|
||||
{
|
||||
core::stringw online_name = getWidget<TextBoxWidget>("username")->getText().trim();
|
||||
m_parent_screen->setNewAccountData(/*online*/true,
|
||||
username, password);
|
||||
|
||||
player->setLastOnlineName(username);
|
||||
player->setWasOnlineLastTime(true);
|
||||
}
|
||||
@ -290,7 +302,7 @@ 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 = m_password_widget->getText().trim();
|
||||
core::stringw password_confirm= getWidget<TextBoxWidget>("password_confirm")->getText().trim();
|
||||
core::stringw email = getWidget<TextBoxWidget>("email")->getText().trim();
|
||||
|
||||
|
@ -20,11 +20,12 @@
|
||||
|
||||
#include "guiengine/screen.hpp"
|
||||
|
||||
namespace GUIEngine { class Widget; class LabelWidget;
|
||||
class RibbonWidget; }
|
||||
namespace GUIEngine { class Widget; class LabelWidget;
|
||||
class RibbonWidget; class TextBoxWidget; }
|
||||
namespace Online { class XMLRequest; }
|
||||
|
||||
class PlayerProfile;
|
||||
class BaseUserScreen;
|
||||
|
||||
/**
|
||||
* \brief Screen to register an online account.
|
||||
@ -48,6 +49,9 @@ private:
|
||||
/** Save the pointer to the options widget, it is widely used. */
|
||||
GUIEngine::RibbonWidget *m_options_widget;
|
||||
|
||||
/** Save the pointer to the options widget, it is widely used. */
|
||||
GUIEngine::TextBoxWidget *m_password_widget;
|
||||
|
||||
/** The XML request to the server. */
|
||||
Online::XMLRequest *m_signup_request;
|
||||
|
||||
@ -64,6 +68,10 @@ private:
|
||||
ACCOUNT_EXISTING_ONLINE,
|
||||
ACCOUNT_OFFLINE } m_account_mode;
|
||||
|
||||
/** A pointer to the parent UserScreen, in order to allow this screen
|
||||
* to pass information back. */
|
||||
BaseUserScreen *m_parent_screen;
|
||||
|
||||
public:
|
||||
|
||||
/** \brief implement callback from parent class GUIEngine::Screen */
|
||||
@ -79,6 +87,9 @@ public:
|
||||
const std::string& name,
|
||||
const int playerID) OVERRIDE;
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Set the parent screen. */
|
||||
void setParent(BaseUserScreen *us) { m_parent_screen = us; }
|
||||
}; // class RegisterScreen
|
||||
|
||||
#endif
|
||||
|
@ -46,18 +46,13 @@ DEFINE_SCREEN_SINGLETON( TabbedUserScreen );
|
||||
|
||||
BaseUserScreen::BaseUserScreen(const std::string &name) : Screen(name.c_str())
|
||||
{
|
||||
m_online_cb = NULL;
|
||||
m_new_registered_data = false;
|
||||
} // BaseUserScreen
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void BaseUserScreen::loadedFromFile()
|
||||
{
|
||||
|
||||
} // loadedFromFile
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void BaseUserScreen::init()
|
||||
{
|
||||
m_online_cb = getWidget<CheckBoxWidget>("online");
|
||||
assert(m_online_cb);
|
||||
@ -65,7 +60,6 @@ void BaseUserScreen::init()
|
||||
assert(m_username_tb);
|
||||
m_password_tb = getWidget<TextBoxWidget >("password");
|
||||
assert(m_password_tb);
|
||||
m_password_tb->setPasswordBox(true, L'*');
|
||||
m_players = getWidget<DynamicRibbonWidget>("players");
|
||||
assert(m_players);
|
||||
m_options_widget = getWidget<RibbonWidget>("options");
|
||||
@ -73,6 +67,25 @@ void BaseUserScreen::init()
|
||||
m_info_widget = getWidget<LabelWidget>("message");
|
||||
assert(m_info_widget);
|
||||
|
||||
} // loadedFromFile
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void BaseUserScreen::setNewAccountData(bool online,
|
||||
const core::stringw &online_name,
|
||||
const core::stringw &password)
|
||||
{
|
||||
// Indicate for init that new user data is available.
|
||||
m_new_registered_data = true;
|
||||
m_online_cb->setState(online);
|
||||
m_username_tb->setText(online_name);
|
||||
m_password_tb->setText(password);
|
||||
} // setOnline
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void BaseUserScreen::init()
|
||||
{
|
||||
m_password_tb->setPasswordBox(true, L'*');
|
||||
|
||||
// The behaviour of the screen is slightly different at startup, i.e.
|
||||
// when it is the first screen: cancel will exit the game, and in
|
||||
// this case no 'back' error should be shown.
|
||||
@ -139,6 +152,7 @@ void BaseUserScreen::init()
|
||||
getWidget<IconButtonWidget>("rename")->setActivated();
|
||||
getWidget<IconButtonWidget>("delete")->setActivated();
|
||||
}
|
||||
m_new_registered_data = false;
|
||||
} // init
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -170,15 +184,21 @@ void BaseUserScreen::selectUser(int index)
|
||||
m_players->setSelection(StringUtils::toString(index), PLAYER_ID_GAME_MASTER,
|
||||
/*focusIt*/ true);
|
||||
|
||||
m_username_tb->setText(profile->getLastOnlineName());
|
||||
// Delete a password that might have been typed for another user
|
||||
m_password_tb->setText("");
|
||||
if (!m_new_registered_data)
|
||||
m_username_tb->setText(profile->getLastOnlineName());
|
||||
|
||||
if (!m_new_registered_data)
|
||||
{
|
||||
// Delete a password that might have been typed for another user
|
||||
m_password_tb->setText("");
|
||||
}
|
||||
|
||||
// Last game was not online, so make the offline settings the default
|
||||
// (i.e. unckeck online checkbox, and make entry fields invisible).
|
||||
if (!profile->wasOnlineLastTime() || profile->getLastOnlineName() == "")
|
||||
{
|
||||
m_online_cb->setState(false);
|
||||
if (!m_new_registered_data)
|
||||
m_online_cb->setState(false);
|
||||
makeEntryFieldsVisible();
|
||||
return;
|
||||
}
|
||||
@ -299,6 +319,7 @@ void BaseUserScreen::eventCallback(Widget* widget,
|
||||
else if (button == "new_user")
|
||||
{
|
||||
RegisterScreen::getInstance()->push();
|
||||
RegisterScreen::getInstance()->setParent(this);
|
||||
// Make sure the new user will have an empty online name field
|
||||
// that can also be edited.
|
||||
m_username_tb->setText("");
|
||||
@ -318,6 +339,7 @@ void BaseUserScreen::eventCallback(Widget* widget,
|
||||
PlayerProfile *cp = getSelectedPlayer();
|
||||
RegisterScreen::getInstance()->setRename(cp);
|
||||
RegisterScreen::getInstance()->push();
|
||||
m_new_registered_data = false;
|
||||
// Init will automatically be called, which
|
||||
// refreshes the player list
|
||||
}
|
||||
|
@ -89,6 +89,11 @@ private:
|
||||
/** The dynamic ribbon containing all players. */
|
||||
GUIEngine::DynamicRibbonWidget* m_players;
|
||||
|
||||
/** Set to indicate when the sceen is initialised that new data from a
|
||||
* registration are available, and therefore entry fields are not
|
||||
* all cleared. */
|
||||
bool m_new_registered_data;
|
||||
|
||||
void selectUser(int index);
|
||||
void makeEntryFieldsVisible();
|
||||
void login();
|
||||
@ -115,6 +120,8 @@ public:
|
||||
/** \brief implement optional callback from parent class GUIEngine::Screen */
|
||||
virtual void unloaded();
|
||||
|
||||
void setNewAccountData(bool online, const core::stringw &online_name="",
|
||||
const core::stringw &password="");
|
||||
void loginSuccessful();
|
||||
void loginError(const irr::core::stringw &error_message);
|
||||
void logoutSuccessful();
|
||||
|
Loading…
x
Reference in New Issue
Block a user