Removed file accidentally added (thanks to Konstin for noticing).
This commit is contained in:
parent
3b721d3803
commit
a07c931921
@ -1,306 +0,0 @@
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 1) // SuperTuxKart - a fun racing game with go-kart
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 2) // Copyright (C) 2014 Joerg Henrichs
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 3) //
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 4) // This program is free software; you can redistribute it and/or
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 5) // modify it under the terms of the GNU General Public License
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 6) // as published by the Free Software Foundation; either version 3
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 7) // of the License, or (at your option) any later version.
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 8) //
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 9) // This program is distributed in the hope that it will be useful,
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 10) // but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 11) // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 12) // GNU General Public License for more details.
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 13) //
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 14) // You should have received a copy of the GNU General Public License
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 15) // along with this program; if not, write to the Free Software
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 16) // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 17)
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 18) #include "states_screens/register_screen.hpp"
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 19)
|
||||
ea2b797b (hiker 2014-04-24 08:17:44 +1000 20) #include "config/player_manager.hpp"
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 21) #include "audio/sfx_manager.hpp"
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 22) #include "guiengine/widgets/check_box_widget.hpp"
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 23) #include "guiengine/widgets/label_widget.hpp"
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 24) #include "guiengine/widgets/ribbon_widget.hpp"
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 25) #include "guiengine/widgets/text_box_widget.hpp"
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 26) #include "online/messages.hpp"
|
||||
447ca89c (hiker 2014-04-16 11:13:35 +1000 27) #include "online/xml_request.hpp"
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 28) #include "states_screens/dialogs/registration_dialog.hpp"
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 29) #include "states_screens/dialogs/message_dialog.hpp"
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 30) #include "states_screens/main_menu_screen.hpp"
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 31) #include "states_screens/state_manager.hpp"
|
||||
d847e8de (hiker 2014-05-05 21:17:46 +1000 32) #include "states_screens/user_screen.hpp"
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 33) #include "utils/log.hpp"
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 34) #include "utils/translation.hpp"
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 35)
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 36) using namespace GUIEngine;
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 37) using namespace Online;
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 38) using namespace irr;
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 39) using namespace core;
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 40)
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 41) DEFINE_SCREEN_SINGLETON( RegisterScreen );
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 42)
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 43) // -----------------------------------------------------------------------------
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 44)
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 45) RegisterScreen::RegisterScreen() : Screen("online/register.stkgui")
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 46) {
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 47) } // RegisterScreen
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 48)
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 49) // -----------------------------------------------------------------------------
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 50) void RegisterScreen::init()
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 51) {
|
||||
c72544b4 (hiker 2014-01-22 16:54:57 +1100 52) Screen::init();
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 53)
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 54) // If there is no player (i.e. first start of STK), try to pick
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 55) // a good default name
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 56) stringw username = "";
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 57) if (PlayerManager::get()->getNumPlayers() == 0)
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 58) {
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 59) if (getenv("USERNAME") != NULL) // for windows
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 60) username = getenv("USERNAME");
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 61) else if (getenv("USER") != NULL) // Linux, Macs
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 62) username = getenv("USER");
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 63) else if (getenv("LOGNAME") != NULL) // Linux, Macs
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 64) username = getenv("LOGNAME");
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 65) }
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 66) getWidget<TextBoxWidget>("local_username")->setText(username);
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 67)
|
||||
f0365fc7 (hiker 2014-01-21 17:11:48 +1100 68)
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 69) TextBoxWidget *password_widget = getWidget<TextBoxWidget>("password");
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 70) password_widget->setPasswordBox(true,L'*');
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 71) password_widget = getWidget<TextBoxWidget>("password_confirm");
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 72) password_widget->setPasswordBox(true,L'*');
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 73)
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 74) m_info_widget = getWidget<LabelWidget>("info");
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 75) assert(m_info_widget);
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 76) m_options_widget = getWidget<RibbonWidget>("options");
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 77) assert(m_options_widget);
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 78)
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 79) m_signup_request = NULL;
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 80) m_info_message_shown = false;
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 81) } // init
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 82)
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 83) // -----------------------------------------------------------------------------
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 84) /** Shows or hides the entry fields for online registration, depending on
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 85) * online mode.
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 86) * \param online True if an online account should be created.
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 87) */
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 88) void RegisterScreen::makeEntryFieldsVisible(bool online)
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 89) {
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 90) getWidget<TextBoxWidget>("username")->setVisible(online);
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 91) getWidget<LabelWidget >("label_username")->setVisible(online);
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 92) getWidget<TextBoxWidget>("password")->setVisible(online);
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 93) getWidget<LabelWidget >("label_password")->setVisible(online);
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 94) getWidget<TextBoxWidget>("password_confirm")->setVisible(online);
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 95) getWidget<LabelWidget >("label_password_confirm")->setVisible(online);
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 96) getWidget<TextBoxWidget>("email")->setVisible(online);
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 97) getWidget<LabelWidget >("label_email")->setVisible(online);
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 98) getWidget<TextBoxWidget>("email_confirm")->setVisible(online);
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 99) getWidget<LabelWidget >("label_email_confirm")->setVisible(online);
|
||||
1946df97 (hiker 2014-05-17 11:43:05 +1000 100) } // makeEntryFieldsVisible
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 101)
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 102) // -----------------------------------------------------------------------------
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 103) /** If necessary creates the local user.
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 104) * \param local_name Name of the local user.
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 105) */
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 106) void RegisterScreen::registerLocal(const stringw &local_name)
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 107) {
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 108) if (local_name.size()==0)
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 109) return;
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 110)
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 111) // If a local player with that name does not exist, create one
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 112) if(!PlayerManager::get()->getPlayer(local_name))
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 113) {
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 114) PlayerProfile *player = PlayerManager::get()->addNewPlayer(local_name);
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 115) PlayerManager::get()->save();
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 116) if(player)
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 117) PlayerManager::get()->setCurrentPlayer(player);
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 118) else
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 119) {
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 120) m_info_widget->setErrorColor();
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 121) m_info_widget->setText(_("Could not create player '%s'.", local_name),
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 122) false);
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 123) }
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 124) }
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 125)
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 126) } // registerLocal
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 127)
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 128) // -----------------------------------------------------------------------------
|
||||
c72544b4 (hiker 2014-01-22 16:54:57 +1100 129) /** Handles the actual registration process. It does some tests on id, password
|
||||
c72544b4 (hiker 2014-01-22 16:54:57 +1100 130) * and email address, then submits a corresponding request.
|
||||
c72544b4 (hiker 2014-01-22 16:54:57 +1100 131) */
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 132) void RegisterScreen::doRegister()
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 133) {
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 134) stringw local_name = getWidget<TextBoxWidget>("local_username")
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 135) ->getText().trim();
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 136)
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 137) registerLocal(local_name);
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 138)
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 139) // If no online account is requested, don't register
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 140) if(!getWidget<CheckBoxWidget>("online")->getState())
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 141) {
|
||||
4f14ddb9 (hiker 2014-05-15 08:57:02 +1000 142) if(local_name.size()>0)
|
||||
4f14ddb9 (hiker 2014-05-15 08:57:02 +1000 143) UserScreen::getInstance()->newUserAdded(local_name, L"");
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 144) StateManager::get()->popMenu();
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 145) return;
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 146) }
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 147)
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 148) stringw username = getWidget<TextBoxWidget>("username")->getText().trim();
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 149) stringw password = getWidget<TextBoxWidget>("password")->getText().trim();
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 150) stringw password_confirm = getWidget<TextBoxWidget>("password_confirm")
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 151) ->getText().trim();
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 152) stringw email = getWidget<TextBoxWidget>("email")->getText().trim();
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 153) stringw email_confirm = getWidget<TextBoxWidget>("email_confirm")
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 154) ->getText().trim();
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 155)
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 156) m_info_widget->setErrorColor();
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 157)
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 158) if (password != password_confirm)
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 159) {
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 160) m_info_widget->setText(_("Passwords don't match!"), false);
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 161) }
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 162) else if (email != email_confirm)
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 163) {
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 164) m_info_widget->setText(_("Emails don't match!"), false);
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 165) }
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 166) else if (username.size() < 3 || username.size() > 30)
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 167) {
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 168) m_info_widget->setText(_("Username has to be between 4 and 30 characters long!"), false);
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 169) }
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 170) else if (password.size() < 8 || password.size() > 30)
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 171) {
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 172) m_info_widget->setText(_("Password has to be between 8 and 30 characters long!"), false);
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 173) }
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 174) else if (email.size() < 4 || email.size() > 50)
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 175) {
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 176) m_info_widget->setText(_("Email has to be between 4 and 50 characters long!"), false);
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 177) }
|
||||
efdaac10 (amtkhdkr 2014-05-21 16:14:44 +0530 178) else if ( email.find(L"@")== -1 || email.find(L".")== -1 ||
|
||||
efdaac10 (amtkhdkr 2014-05-21 16:14:44 +0530 179) (email.findLast(L'.') - email.findLast(L'@') <= 2 ) ||
|
||||
efdaac10 (amtkhdkr 2014-05-21 16:14:44 +0530 180) email.findLast(L'@')==0 )
|
||||
50119a49 (amtkhdkr 2014-05-21 11:57:56 +0530 181) {
|
||||
397c2e4a (amtkhdkr 2014-05-21 13:04:44 +0530 182) m_info_widget->setText(_("Email is invalid!"), false);
|
||||
50119a49 (amtkhdkr 2014-05-21 11:57:56 +0530 183) }
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 184) else
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 185) {
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 186) m_info_widget->setDefaultColor();
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 187) new RegistrationDialog();
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 188) return;
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 189) }
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 190)
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 191) sfx_manager->quickSound( "anvil" );
|
||||
4f14ddb9 (hiker 2014-05-15 08:57:02 +1000 192) if(local_name.size()>0)
|
||||
4f14ddb9 (hiker 2014-05-15 08:57:02 +1000 193) UserScreen::getInstance()->newUserAdded(local_name, username);
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 194) } // doRegister
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 195)
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 196) // -----------------------------------------------------------------------------
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 197) /** Called from the registration info dialog when 'accept' is clicked.
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 198) */
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 199) void RegisterScreen::acceptTerms()
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 200) {
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 201) m_options_widget->setDeactivated();
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 202)
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 203) core::stringw username = getWidget<TextBoxWidget>("username")->getText().trim();
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 204) core::stringw password = getWidget<TextBoxWidget>("password")->getText().trim();
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 205) core::stringw password_confirm= getWidget<TextBoxWidget>("password_confirm")->getText().trim();
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 206) core::stringw email = getWidget<TextBoxWidget>("email")->getText().trim();
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 207)
|
||||
e77287d3 (hiker 2014-03-15 09:34:23 +1100 208) m_signup_request = new XMLRequest();
|
||||
e77287d3 (hiker 2014-03-15 09:34:23 +1100 209) m_signup_request->setServerURL("client-user.php");
|
||||
e77287d3 (hiker 2014-03-15 09:34:23 +1100 210) m_signup_request->addParameter("action", "register" );
|
||||
e77287d3 (hiker 2014-03-15 09:34:23 +1100 211) m_signup_request->addParameter("username", username );
|
||||
e77287d3 (hiker 2014-03-15 09:34:23 +1100 212) m_signup_request->addParameter("password", password );
|
||||
e77287d3 (hiker 2014-03-15 09:34:23 +1100 213) m_signup_request->addParameter("password_confirm", password_confirm);
|
||||
e77287d3 (hiker 2014-03-15 09:34:23 +1100 214) m_signup_request->addParameter("email", email );
|
||||
e77287d3 (hiker 2014-03-15 09:34:23 +1100 215) m_signup_request->addParameter("terms", "on" );
|
||||
e77287d3 (hiker 2014-03-15 09:34:23 +1100 216) m_signup_request->queue();
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 217) } // acceptTerms
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 218)
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 219) // -----------------------------------------------------------------------------
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 220)
|
||||
5474b552 (hiker 2014-01-22 07:43:17 +1100 221) void RegisterScreen::onUpdate(float dt)
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 222) {
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 223) if(m_signup_request)
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 224) {
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 225) if(!m_options_widget->isActivated())
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 226) m_info_widget->setText(Messages::validatingInfo(), false);
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 227)
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 228) if(m_signup_request->isDone())
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 229) {
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 230) if(m_signup_request->isSuccess())
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 231) {
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 232) new MessageDialog(
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 233) _("You will receive an email with further instructions "
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 234) "regarding account activation. Please be patient and be "
|
||||
7cc83e14 (konstin 2014-03-29 11:33:43 +0100 235) "sure to check your spam folder."),
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 236) MessageDialog::MESSAGE_DIALOG_OK, NULL, false);
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 237) // Set the flag that the message was shown, which will triger
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 238) // a pop of this menu and so a return to the main menu
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 239) m_info_message_shown = true;
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 240) }
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 241) else
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 242) {
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 243) // Error signing up, display error message
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 244) m_info_widget->setText(m_signup_request->getInfo(), false);
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 245) }
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 246) delete m_signup_request;
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 247) m_signup_request = NULL;
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 248) m_options_widget->setActivated();
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 249) }
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 250) }
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 251) else if(m_info_message_shown && !ModalDialog::isADialogActive())
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 252) {
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 253) // Once the info message was shown (signup was successful), but the
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 254) // message has been gone (user clicked on OK), go back to main menu
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 255) StateManager::get()->popMenu();
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 256) }
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 257) } // onUpdate
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 258)
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 259) // -----------------------------------------------------------------------------
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 260)
|
||||
7cc83e14 (konstin 2014-03-29 11:33:43 +0100 261) void RegisterScreen::eventCallback(Widget* widget, const std::string& name,
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 262) const int playerID)
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 263) {
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 264) if (name == "online")
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 265) {
|
||||
8d4b33f2 (hiker 2014-05-08 22:17:15 +1000 266) makeEntryFieldsVisible(getWidget<CheckBoxWidget>("online")->getState());
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 267) }
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 268) else if (name=="options")
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 269) {
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 270) const std::string button = m_options_widget
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 271) ->getSelectionIDString(PLAYER_ID_GAME_MASTER);
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 272) if(button=="next")
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 273) {
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 274) doRegister();
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 275) }
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 276) else if(button=="cancel")
|
||||
1946df97 (hiker 2014-05-17 11:43:05 +1000 277) {
|
||||
1946df97 (hiker 2014-05-17 11:43:05 +1000 278) // We poop this menu, onEscapePress will handle the special case
|
||||
1946df97 (hiker 2014-05-17 11:43:05 +1000 279) // of e.g. a fresh start of stk that is aborted.
|
||||
1946df97 (hiker 2014-05-17 11:43:05 +1000 280) StateManager::get()->popMenu();
|
||||
1946df97 (hiker 2014-05-17 11:43:05 +1000 281) onEscapePressed();
|
||||
1946df97 (hiker 2014-05-17 11:43:05 +1000 282) }
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 283) }
|
||||
5ecfed29 (Daniel Butum 2014-04-26 13:42:30 +0300 284) else if (name == "back")
|
||||
5ecfed29 (Daniel Butum 2014-04-26 13:42:30 +0300 285) {
|
||||
5ecfed29 (Daniel Butum 2014-04-26 13:42:30 +0300 286) StateManager::get()->escapePressed();
|
||||
5ecfed29 (Daniel Butum 2014-04-26 13:42:30 +0300 287) }
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 288)
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 289) } // eventCallback
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 290)
|
||||
260f4f14 (hiker 2014-01-20 21:39:59 +1100 291) // -----------------------------------------------------------------------------
|
||||
1946df97 (hiker 2014-05-17 11:43:05 +1000 292) bool RegisterScreen::onEscapePressed()
|
||||
1946df97 (hiker 2014-05-17 11:43:05 +1000 293) {
|
||||
1946df97 (hiker 2014-05-17 11:43:05 +1000 294) if (PlayerManager::get()->getNumPlayers() == 0)
|
||||
1946df97 (hiker 2014-05-17 11:43:05 +1000 295) {
|
||||
1946df97 (hiker 2014-05-17 11:43:05 +1000 296) // Must be first time start, and player cancelled player creation
|
||||
1946df97 (hiker 2014-05-17 11:43:05 +1000 297) // so quit stk. At this stage there are two menus on the stack:
|
||||
1946df97 (hiker 2014-05-17 11:43:05 +1000 298) // 1) The UserScreen, 2) RegisterStreen
|
||||
1946df97 (hiker 2014-05-17 11:43:05 +1000 299) // Popping them both will trigger STK to close.
|
||||
1946df97 (hiker 2014-05-17 11:43:05 +1000 300) StateManager::get()->popMenu();
|
||||
1946df97 (hiker 2014-05-17 11:43:05 +1000 301) return true;
|
||||
1946df97 (hiker 2014-05-17 11:43:05 +1000 302) }
|
||||
1946df97 (hiker 2014-05-17 11:43:05 +1000 303) StateManager::get()->escapePressed();
|
||||
1946df97 (hiker 2014-05-17 11:43:05 +1000 304) return true;
|
||||
1946df97 (hiker 2014-05-17 11:43:05 +1000 305) } // onEscapePressed
|
||||
1946df97 (hiker 2014-05-17 11:43:05 +1000 306)
|
Loading…
Reference in New Issue
Block a user