2011-12-04 18:06:53 -05:00
|
|
|
// SuperTuxKart - a fun racing game with go-kart
|
2015-03-29 20:31:42 -04:00
|
|
|
// Copyright (C) 2009-2015 Marianne Gagnon
|
2011-12-04 18:06:53 -05:00
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
|
|
|
|
|
2014-05-05 07:17:46 -04:00
|
|
|
#ifndef __HEADER_USER_SCREEN_HPP__
|
|
|
|
#define __HEADER_USER_SCREEN_HPP__
|
2011-12-04 18:06:53 -05:00
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include "guiengine/screen.hpp"
|
2014-09-01 19:18:58 -04:00
|
|
|
#include "guiengine/widgets/spinner_widget.hpp"
|
2016-04-12 19:25:45 -04:00
|
|
|
#include "input/input.hpp"
|
2014-06-04 09:10:20 -04:00
|
|
|
namespace GUIEngine
|
2014-04-28 19:02:44 -04:00
|
|
|
{
|
|
|
|
class CheckBoxWidget;
|
2014-05-08 08:17:15 -04:00
|
|
|
class LabelWidget;
|
2014-05-04 19:17:19 -04:00
|
|
|
class RibbonWidget;
|
2014-04-28 19:02:44 -04:00
|
|
|
class TextBoxWidget;
|
2014-06-04 09:10:20 -04:00
|
|
|
class Widget;
|
2014-04-28 19:02:44 -04:00
|
|
|
}
|
2011-12-04 18:06:53 -05:00
|
|
|
|
2014-05-06 02:52:36 -04:00
|
|
|
class PlayerProfile;
|
|
|
|
|
2011-12-04 18:06:53 -05:00
|
|
|
|
|
|
|
/**
|
2014-05-15 08:59:21 -04:00
|
|
|
* \brief The user management screen. The screen cames in two variations:
|
|
|
|
* either as a stand-alone screen before the main menu (on first time STK
|
|
|
|
* is started, or it the user is not remembered), but also as tab in the
|
2014-06-04 09:10:20 -04:00
|
|
|
* options menu. To implement this, we use one common base class that
|
2014-05-15 08:59:21 -04:00
|
|
|
* implements nearly all functionality, and derive to classes - one for
|
|
|
|
* the stand alone version, one for the version with tabs.
|
|
|
|
* \ingroup states_screens.
|
2011-12-04 18:06:53 -05:00
|
|
|
*/
|
2014-05-15 08:59:21 -04:00
|
|
|
class BaseUserScreen : public GUIEngine::Screen
|
2011-12-04 18:06:53 -05:00
|
|
|
{
|
2014-05-15 08:59:21 -04:00
|
|
|
protected:
|
|
|
|
BaseUserScreen(const std::string &name);
|
2013-05-30 15:47:39 -04:00
|
|
|
|
2014-04-28 19:02:44 -04:00
|
|
|
private:
|
2014-05-04 18:59:27 -04:00
|
|
|
|
2014-05-20 08:13:26 -04:00
|
|
|
/** The state of the user screen. Note that this is a bit mask, since the
|
|
|
|
* current user can be logged out, and the new one logged in at the
|
|
|
|
* same time. */
|
|
|
|
enum UserScreenState { STATE_NONE=0, STATE_LOGIN=1, STATE_LOGOUT=2} m_state;
|
2014-05-21 17:45:19 -04:00
|
|
|
|
|
|
|
/** The user name that is currently being logged out. Used to
|
|
|
|
* display more meaningful sign-out message. */
|
|
|
|
irr::core::stringw m_sign_out_name;
|
|
|
|
|
|
|
|
/** The user name that is currently being logged out. Used to
|
|
|
|
* display more meaningful sign-out message. */
|
|
|
|
irr::core::stringw m_sign_in_name;
|
|
|
|
|
2014-04-28 19:02:44 -04:00
|
|
|
/** Online check box. */
|
|
|
|
GUIEngine::CheckBoxWidget *m_online_cb;
|
|
|
|
|
|
|
|
/** User name entry field. */
|
|
|
|
GUIEngine::TextBoxWidget *m_username_tb;
|
|
|
|
|
|
|
|
/** Password widget. */
|
|
|
|
GUIEngine::TextBoxWidget *m_password_tb;
|
|
|
|
|
2014-05-04 18:59:27 -04:00
|
|
|
/** Label field for warning and error messages. */
|
|
|
|
GUIEngine::LabelWidget * m_info_widget;
|
|
|
|
|
|
|
|
/** The ribbon with all buttons. */
|
|
|
|
GUIEngine::RibbonWidget *m_options_widget;
|
|
|
|
|
2014-04-29 17:54:49 -04:00
|
|
|
/** The dynamic ribbon containing all players. */
|
|
|
|
GUIEngine::DynamicRibbonWidget* m_players;
|
|
|
|
|
2015-01-11 17:41:34 -05:00
|
|
|
/** 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;
|
|
|
|
|
2015-01-12 06:27:45 -05:00
|
|
|
/** Set from the register screen if the newly created account can be
|
|
|
|
* used directly without waiting to confirm the account. */
|
|
|
|
bool m_auto_login;
|
|
|
|
|
2014-04-29 17:54:49 -04:00
|
|
|
void selectUser(int index);
|
2014-05-16 21:43:05 -04:00
|
|
|
void makeEntryFieldsVisible();
|
2014-05-08 08:17:15 -04:00
|
|
|
void login();
|
2014-05-05 18:21:53 -04:00
|
|
|
void closeScreen();
|
2014-05-06 02:52:36 -04:00
|
|
|
void deletePlayer();
|
|
|
|
void doDeletePlayer();
|
|
|
|
PlayerProfile* getSelectedPlayer();
|
2014-05-04 18:59:27 -04:00
|
|
|
virtual void onUpdate(float dt) OVERRIDE;
|
|
|
|
|
2011-12-04 18:06:53 -05:00
|
|
|
public:
|
|
|
|
/** \brief implement callback from parent class GUIEngine::Screen */
|
2016-02-20 19:21:43 -05:00
|
|
|
virtual void loadedFromFile() OVERRIDE;
|
2013-05-30 15:47:39 -04:00
|
|
|
|
2011-12-04 18:06:53 -05:00
|
|
|
/** \brief implement callback from parent class GUIEngine::Screen */
|
2014-05-15 08:59:21 -04:00
|
|
|
virtual void eventCallback(GUIEngine::Widget* widget,
|
2016-02-20 19:21:43 -05:00
|
|
|
const std::string& name, const int playerID) OVERRIDE;
|
2013-05-30 15:47:39 -04:00
|
|
|
|
2011-12-04 18:06:53 -05:00
|
|
|
/** \brief implement callback from parent class GUIEngine::Screen */
|
2016-02-20 19:21:43 -05:00
|
|
|
virtual void init() OVERRIDE;
|
2013-05-30 15:47:39 -04:00
|
|
|
|
2011-12-04 18:06:53 -05:00
|
|
|
/** \brief implement callback from parent class GUIEngine::Screen */
|
2016-02-20 19:21:43 -05:00
|
|
|
virtual void tearDown() OVERRIDE;
|
2013-05-30 15:47:39 -04:00
|
|
|
|
2011-12-04 18:06:53 -05:00
|
|
|
/** \brief implement optional callback from parent class GUIEngine::Screen */
|
2016-02-20 19:21:43 -05:00
|
|
|
virtual void unloaded() OVERRIDE;
|
2013-05-30 15:47:39 -04:00
|
|
|
|
2015-01-12 06:27:45 -05:00
|
|
|
void setNewAccountData(bool online, bool auto_login,
|
|
|
|
const core::stringw &online_name="",
|
2015-01-11 17:41:34 -05:00
|
|
|
const core::stringw &password="");
|
2014-05-04 18:59:27 -04:00
|
|
|
void loginSuccessful();
|
2014-05-08 08:17:15 -04:00
|
|
|
void loginError(const irr::core::stringw &error_message);
|
2014-05-20 08:13:26 -04:00
|
|
|
void logoutSuccessful();
|
|
|
|
void logoutError(const irr::core::stringw &error_message);
|
2016-04-12 19:25:45 -04:00
|
|
|
|
|
|
|
virtual GUIEngine::EventPropagation filterActions(PlayerAction action,
|
|
|
|
int deviceID,
|
|
|
|
const unsigned int value,
|
|
|
|
Input::InputType type,
|
|
|
|
int playerId) OVERRIDE;
|
2014-05-15 08:59:21 -04:00
|
|
|
}; // class BaseUserScreen
|
|
|
|
|
|
|
|
// ============================================================================
|
|
|
|
class UserScreen : public BaseUserScreen,
|
|
|
|
public GUIEngine::ScreenSingleton<UserScreen>
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
UserScreen() : BaseUserScreen("user_screen.stkgui")
|
|
|
|
{};
|
|
|
|
public:
|
|
|
|
friend class GUIEngine::ScreenSingleton<UserScreen>;
|
|
|
|
}; // class UserScreenTabed
|
|
|
|
|
|
|
|
// ============================================================================
|
|
|
|
class TabbedUserScreen : public BaseUserScreen,
|
|
|
|
public GUIEngine::ScreenSingleton<TabbedUserScreen>
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
TabbedUserScreen() : BaseUserScreen("user_screen_tab.stkgui")
|
|
|
|
{}
|
|
|
|
|
|
|
|
public:
|
|
|
|
friend class GUIEngine::ScreenSingleton<TabbedUserScreen>;
|
|
|
|
|
2016-02-20 19:21:43 -05:00
|
|
|
virtual void init() OVERRIDE;
|
2014-05-15 08:59:21 -04:00
|
|
|
virtual void eventCallback(GUIEngine::Widget* widget,
|
2016-02-20 19:21:43 -05:00
|
|
|
const std::string& name, const int playerID) OVERRIDE;
|
2014-05-15 08:59:21 -04:00
|
|
|
}; // class TabbedUserScreen
|
2011-12-04 18:06:53 -05:00
|
|
|
|
|
|
|
#endif
|