Use tabs in register screen (work in progress).
This commit is contained in:
parent
91b4c6e08a
commit
5ccedfc349
@ -4,22 +4,23 @@
|
||||
|
||||
<header align="center" width="80%" text="Create User" text_align="center"
|
||||
I18N="In the registration dialog" />
|
||||
<spacer height="15" width="10"/>
|
||||
<spacer height="15" width="10"/>
|
||||
<tabs id="mode_tabs" height="10%" max_height="110" x="2%" width="98%" align="center">
|
||||
<icon-button id="tab_new_online" width="128" height="128" icon="gui/main_network.png"
|
||||
I18N="Section in the register screen" text="New Online Account"/>
|
||||
<icon-button id="tab_existing_online" width="128" height="128" icon="gui/main_network.png"
|
||||
I18N="Section in the register screen" text="Existing Online Account"/>
|
||||
<icon-button id="tab_offline" width="128" height="128" icon="gui/options_players.png"
|
||||
I18N="Section in the register screen" text="Offline Account"/>
|
||||
</tabs>
|
||||
|
||||
<box proportion="1" width="100%" height="100%" layout="vertical-row">
|
||||
<box proportion="1" width="100%" height="100%" layout="vertical-row">
|
||||
<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"/>
|
||||
<textbox id="local_username" proportion="2" height="fit" I18N="In the registration dialog"/>
|
||||
</div>
|
||||
<div width="100%" height="12%" layout="horizontal-row" >
|
||||
<label id="label_online" proportion="1" height="100%" text_align="left"
|
||||
I18N="In the registration dialog" text="Create online account"/>
|
||||
<div proportion="2" layout="horizontal-row" height="fit">
|
||||
<checkbox id="online" I18N="In the registration dialog" text_align="left"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div width="100%" height="12%" layout="horizontal-row" >
|
||||
<label id="label_username" proportion="1" height="100%" text_align="left"
|
||||
|
@ -50,6 +50,22 @@ RegisterScreen::RegisterScreen() : Screen("online/register.stkgui")
|
||||
// -----------------------------------------------------------------------------
|
||||
void RegisterScreen::init()
|
||||
{
|
||||
RibbonWidget* ribbon = getWidget<RibbonWidget>("mode_tabs");
|
||||
assert(ribbon);
|
||||
if (UserConfigParams::m_internet_status !=
|
||||
Online::RequestManager::IPERM_NOT_ALLOWED)
|
||||
{
|
||||
m_account_mode = ACCOUNT_NEW_ONLINE;
|
||||
ribbon->select("tab_new_online", PLAYER_ID_GAME_MASTER);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_account_mode = ACCOUNT_OFFLINE;
|
||||
ribbon->select("tab_offline", PLAYER_ID_GAME_MASTER);
|
||||
}
|
||||
|
||||
// Hide the tabs in case of a rename
|
||||
ribbon->setVisible(m_existing_player == NULL);
|
||||
Screen::init();
|
||||
|
||||
// If there is no player (i.e. first start of STK), try to pick
|
||||
@ -85,13 +101,8 @@ void RegisterScreen::init()
|
||||
m_signup_request = NULL;
|
||||
m_info_message_shown = false;
|
||||
|
||||
getWidget<CheckBoxWidget>("online")->setVisible(true);
|
||||
getWidget<LabelWidget>("label_online")->setVisible(true);
|
||||
onDialogClose();
|
||||
bool online = UserConfigParams::m_internet_status
|
||||
!= Online::RequestManager::IPERM_NOT_ALLOWED;
|
||||
getWidget<CheckBoxWidget>("online")->setState(online);
|
||||
makeEntryFieldsVisible(online);
|
||||
makeEntryFieldsVisible();
|
||||
} // init
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
@ -109,8 +120,8 @@ void RegisterScreen::onDialogClose()
|
||||
{
|
||||
bool online = UserConfigParams::m_internet_status
|
||||
!= Online::RequestManager::IPERM_NOT_ALLOWED;
|
||||
getWidget<CheckBoxWidget>("online")->setState(online);
|
||||
makeEntryFieldsVisible(online);
|
||||
m_account_mode = online ? ACCOUNT_NEW_ONLINE : ACCOUNT_OFFLINE;
|
||||
makeEntryFieldsVisible();
|
||||
} // onDialogClose
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
@ -118,29 +129,30 @@ void RegisterScreen::onDialogClose()
|
||||
* online mode.
|
||||
* \param online True if an online account should be created.
|
||||
*/
|
||||
void RegisterScreen::makeEntryFieldsVisible(bool online)
|
||||
void RegisterScreen::makeEntryFieldsVisible()
|
||||
{
|
||||
// In case of a rename, hide all other fields.
|
||||
if(m_existing_player)
|
||||
{
|
||||
m_info_widget->setVisible(false);
|
||||
getWidget<CheckBoxWidget>("online")->setVisible(false);
|
||||
getWidget<LabelWidget>("label_online")->setVisible(false);
|
||||
online = false;
|
||||
m_account_mode = ACCOUNT_OFFLINE;
|
||||
}
|
||||
|
||||
bool online = m_account_mode != ACCOUNT_OFFLINE;
|
||||
getWidget<TextBoxWidget>("username")->setVisible(online);
|
||||
getWidget<LabelWidget >("label_username")->setVisible(online);
|
||||
getWidget<TextBoxWidget>("password")->setVisible(online);
|
||||
getWidget<LabelWidget >("label_password")->setVisible(online);
|
||||
getWidget<TextBoxWidget>("password_confirm")->setVisible(online);
|
||||
getWidget<LabelWidget >("label_password_confirm")->setVisible(online);
|
||||
getWidget<TextBoxWidget>("email")->setVisible(online);
|
||||
getWidget<LabelWidget >("label_email")->setVisible(online);
|
||||
|
||||
bool new_account = online && (m_account_mode == ACCOUNT_NEW_ONLINE);
|
||||
getWidget<TextBoxWidget>("password_confirm")->setVisible(new_account);
|
||||
getWidget<LabelWidget >("label_password_confirm")->setVisible(new_account);
|
||||
getWidget<TextBoxWidget>("email")->setVisible(new_account);
|
||||
getWidget<LabelWidget >("label_email")->setVisible(new_account);
|
||||
if(getWidget<TextBoxWidget>("email_confirm"))
|
||||
{
|
||||
getWidget<TextBoxWidget>("email_confirm")->setVisible(online);
|
||||
getWidget<LabelWidget >("label_email_confirm")->setVisible(online);
|
||||
getWidget<TextBoxWidget>("email_confirm")->setVisible(new_account);
|
||||
getWidget<LabelWidget >("label_email_confirm")->setVisible(new_account);
|
||||
}
|
||||
} // makeEntryFieldsVisible
|
||||
|
||||
@ -199,7 +211,7 @@ void RegisterScreen::doRegister()
|
||||
handleLocalName(local_name);
|
||||
|
||||
// If no online account is requested, don't register
|
||||
if(!getWidget<CheckBoxWidget>("online")->getState() || m_existing_player)
|
||||
if(m_account_mode!=ACCOUNT_NEW_ONLINE|| m_existing_player)
|
||||
{
|
||||
StateManager::get()->popMenu();
|
||||
m_existing_player = NULL;
|
||||
@ -339,16 +351,25 @@ void RegisterScreen::onUpdate(float dt)
|
||||
void RegisterScreen::eventCallback(Widget* widget, const std::string& name,
|
||||
const int playerID)
|
||||
{
|
||||
if (name == "online")
|
||||
if (name == "mode_tabs")
|
||||
{
|
||||
if (UserConfigParams::m_internet_status == Online::RequestManager::IPERM_NOT_ALLOWED)
|
||||
RibbonWidget *ribbon = static_cast<RibbonWidget*>(widget);
|
||||
std::string selection = ribbon->getSelectionIDString(PLAYER_ID_GAME_MASTER);
|
||||
if ( (selection == "tab_new_online" || selection == "tab_existing_online")
|
||||
&& (UserConfigParams::m_internet_status == Online::RequestManager::IPERM_NOT_ALLOWED) )
|
||||
{
|
||||
m_info_widget->setErrorColor();
|
||||
m_info_widget->setText(_("Internet access is disabled, please enable it in the options"), false);
|
||||
getWidget<CheckBoxWidget>("online")->setState(false);
|
||||
return;
|
||||
}
|
||||
else
|
||||
makeEntryFieldsVisible(getWidget<CheckBoxWidget>("online")->getState());
|
||||
if (selection == "tab_new_online")
|
||||
m_account_mode = ACCOUNT_NEW_ONLINE;
|
||||
else if (selection == "tab_existing_online")
|
||||
m_account_mode = ACCOUNT_EXISTING_ONLINE;
|
||||
else if (selection == "tab_offline")
|
||||
m_account_mode = ACCOUNT_OFFLINE;
|
||||
|
||||
makeEntryFieldsVisible();
|
||||
}
|
||||
else if (name=="options")
|
||||
{
|
||||
|
@ -36,7 +36,7 @@ class RegisterScreen : public GUIEngine::Screen,
|
||||
private:
|
||||
friend class GUIEngine::ScreenSingleton<RegisterScreen>;
|
||||
|
||||
void makeEntryFieldsVisible(bool online);
|
||||
void makeEntryFieldsVisible();
|
||||
void handleLocalName(const irr::core::stringw &local_name);
|
||||
void doRegister();
|
||||
void init();
|
||||
@ -58,6 +58,12 @@ private:
|
||||
/** True if the info message (email was sent...) is shown. */
|
||||
bool m_info_message_shown;
|
||||
|
||||
/** Which kind of account to create: new online account, new account
|
||||
* using an existing online account, offline account. */
|
||||
enum { ACCOUNT_NEW_ONLINE,
|
||||
ACCOUNT_EXISTING_ONLINE,
|
||||
ACCOUNT_OFFLINE } m_account_mode;
|
||||
|
||||
public:
|
||||
|
||||
/** \brief implement callback from parent class GUIEngine::Screen */
|
||||
|
Loading…
x
Reference in New Issue
Block a user