1 // SuperTuxKart - a fun racing game with go-kart 2 // Copyright (C) 2014-2015 Joerg Henrichs 3 // 4 // This program is free software; you can redistribute it and/or 5 // modify it under the terms of the GNU General Public License 6 // as published by the Free Software Foundation; either version 3 7 // of the License, or (at your option) any later version. 8 // 9 // This program is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with this program; if not, write to the Free Software 16 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 18 #ifndef HEADER_REGISTER_SCREEN_HPP 19 #define HEADER_REGISTER_SCREEN_HPP 20 21 #include "guiengine/screen.hpp" 22 23 namespace GUIEngine { class Widget; class LabelWidget; 24 class RibbonWidget; class TextBoxWidget; } 25 namespace Online { class XMLRequest; } 26 27 class PlayerProfile; 28 class BaseUserScreen; 29 30 /** 31 * \brief Screen to register an online account. 32 * \ingroup states_screens 33 */ 34 class RegisterScreen : public GUIEngine::Screen, 35 public GUIEngine::ScreenSingleton<RegisterScreen> 36 { 37 private: 38 friend class GUIEngine::ScreenSingleton<RegisterScreen>; 39 40 void makeEntryFieldsVisible(); 41 void handleLocalName(const irr::core::stringw &local_name); 42 void doRegister(); 43 void init() OVERRIDE; 44 RegisterScreen(); 45 46 /** Save the pointer to the info widget, it is widely used. */ 47 GUIEngine::LabelWidget *m_info_widget; 48 49 /** Save the pointer to the options widget, it is widely used. */ 50 GUIEngine::RibbonWidget *m_options_widget; 51 52 /** Save the pointer to the options widget, it is widely used. */ 53 GUIEngine::TextBoxWidget *m_password_widget; 54 55 /** The XML request to the server. */ 56 std::shared_ptr<Online::XMLRequest> m_signup_request; 57 58 /** Pointer to an existing player if the screen is doing a rename, 59 * NULL otherwise. */ 60 PlayerProfile *m_existing_player; 61 62 /** True if the info message (email was sent...) is shown. */ 63 bool m_info_message_shown; 64 65 /** Which kind of account to create: new online account, new account 66 * using an existing online account, offline account. */ 67 enum { ACCOUNT_NEW_ONLINE, 68 ACCOUNT_EXISTING_ONLINE, 69 ACCOUNT_OFFLINE } m_account_mode; 70 71 /** A pointer to the parent UserScreen, in order to allow this screen 72 * to pass information back. */ 73 BaseUserScreen *m_parent_screen; 74 75 public: 76 77 /** \brief implement callback from parent class GUIEngine::Screen */ loadedFromFile()78 virtual void loadedFromFile() OVERRIDE {}; 79 virtual void onUpdate(float dt) OVERRIDE; 80 virtual bool onEscapePressed() OVERRIDE; 81 virtual void onDialogClose() OVERRIDE; 82 virtual void onFocusChanged(GUIEngine::Widget *previous, 83 GUIEngine::Widget *focus, 84 int playerID) OVERRIDE; 85 void setRename(PlayerProfile *player); 86 87 void acceptTerms(); 88 /** \brief implement callback from parent class GUIEngine::Screen */ 89 virtual void eventCallback(GUIEngine::Widget* widget, 90 const std::string& name, 91 const int playerID) OVERRIDE; 92 93 // ------------------------------------------------------------------------ 94 /** Set the parent screen. */ setParent(BaseUserScreen * us)95 void setParent(BaseUserScreen *us) { m_parent_screen = us; } 96 }; // class RegisterScreen 97 98 #endif 99