SuperTuxKart
Loading...
Searching...
No Matches
user_screen.hpp
1// SuperTuxKart - a fun racing game with go-kart
2// Copyright (C) 2009-2015 Marianne Gagnon
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
19#ifndef __HEADER_USER_SCREEN_HPP__
20#define __HEADER_USER_SCREEN_HPP__
21
22#include <string>
23
24#include "guiengine/screen.hpp"
25#include "guiengine/widgets/spinner_widget.hpp"
26#include "input/input.hpp"
27namespace GUIEngine
28{
29 class CheckBoxWidget;
30 class LabelWidget;
31 class RibbonWidget;
32 class TextBoxWidget;
33 class Widget;
34}
35
36class PlayerProfile;
37
38
49{
50protected:
51 BaseUserScreen(const std::string &name);
52
53private:
54
58 enum UserScreenState { STATE_NONE=0, STATE_LOGIN=1, STATE_LOGOUT=2} m_state;
59
62 irr::core::stringw m_sign_out_name;
63
66 irr::core::stringw m_sign_in_name;
67
70
73
76
79
82
85
90
94
95 void selectUser(int index);
97 void login();
98 void closeScreen();
99 void deletePlayer();
100 void doDeletePlayer();
101 PlayerProfile* getSelectedPlayer();
102 virtual void onUpdate(float dt) OVERRIDE;
103
104public:
106 virtual void loadedFromFile() OVERRIDE;
107
109 virtual void eventCallback(GUIEngine::Widget* widget,
110 const std::string& name, const int playerID) OVERRIDE;
111
113 virtual void beforeAddingWidget() OVERRIDE;
114
116 virtual void init() OVERRIDE;
117
119 virtual void tearDown() OVERRIDE;
120
122 virtual void unloaded() OVERRIDE;
123
124 void setNewAccountData(bool online, bool auto_login,
125 const core::stringw &online_name="",
126 const core::stringw &password="");
127 void loginSuccessful();
128 void loginError(const irr::core::stringw &error_message, bool clear_password);
129 void logoutSuccessful();
130 void logoutError(const irr::core::stringw &error_message);
131
132 virtual GUIEngine::EventPropagation filterActions(PlayerAction action,
133 int deviceID,
134 const unsigned int value,
135 Input::InputType type,
136 int playerId) OVERRIDE;
137}; // class BaseUserScreen
138
139// ============================================================================
141 public GUIEngine::ScreenSingleton<UserScreen>
142{
143private:
144 UserScreen() : BaseUserScreen("user_screen.stkgui")
145 {};
146public:
148}; // class UserScreenTabed
149
150// ============================================================================
152 public GUIEngine::ScreenSingleton<TabbedUserScreen>
153{
154private:
155 TabbedUserScreen() : BaseUserScreen("user_screen_tab.stkgui")
156 {}
157
158public:
160
161 virtual void init() OVERRIDE;
162 virtual void eventCallback(GUIEngine::Widget* widget,
163 const std::string& name, const int playerID) OVERRIDE;
164}; // class TabbedUserScreen
165
166#endif
The user management screen.
Definition: user_screen.hpp:49
virtual GUIEngine::EventPropagation filterActions(PlayerAction action, int deviceID, const unsigned int value, Input::InputType type, int playerId) OVERRIDE
Override this if you need to be notified of player actions in subclasses.
Definition: user_screen.cpp:204
bool m_new_registered_data
Set to indicate when the sceen is initialised that new data from a registration are available,...
Definition: user_screen.hpp:89
void loginError(const irr::core::stringw &error_message, bool clear_password)
Callback from player profile if login was unsuccessful.
Definition: user_screen.cpp:602
void deletePlayer()
Called when a player will be deleted.
Definition: user_screen.cpp:653
GUIEngine::LabelWidget * m_info_widget
Label field for warning and error messages.
Definition: user_screen.hpp:78
UserScreenState
The state of the user screen.
Definition: user_screen.hpp:58
virtual void eventCallback(GUIEngine::Widget *widget, const std::string &name, const int playerID) OVERRIDE
implement callback from parent class GUIEngine::Screen
Definition: user_screen.cpp:331
GUIEngine::TextBoxWidget * m_username_tb
User name entry field.
Definition: user_screen.hpp:72
bool m_auto_login
Set from the register screen if the newly created account can be used directly without waiting to con...
Definition: user_screen.hpp:93
virtual void onUpdate(float dt) OVERRIDE
Called once every frame.
Definition: user_screen.cpp:570
void closeScreen()
Closes the BaseUserScreen, and makes sure that the right screen is displayed next.
Definition: user_screen.cpp:464
GUIEngine::DynamicRibbonWidget * m_players
The dynamic ribbon containing all players.
Definition: user_screen.hpp:84
void doDeletePlayer()
Callback when the user confirms to delete a player.
Definition: user_screen.cpp:693
GUIEngine::CheckBoxWidget * m_online_cb
Online check box.
Definition: user_screen.hpp:69
void logoutError(const irr::core::stringw &error_message)
Callback from player profile if login was unsuccessful.
Definition: user_screen.cpp:635
GUIEngine::RibbonWidget * m_options_widget
The ribbon with all buttons.
Definition: user_screen.hpp:81
virtual void init() OVERRIDE
implement callback from parent class GUIEngine::Screen
Definition: user_screen.cpp:112
void login()
Called when OK or OK-and-save is clicked.
Definition: user_screen.cpp:482
void setNewAccountData(bool online, bool auto_login, const core::stringw &online_name="", const core::stringw &password="")
Stores information from the register screen.
Definition: user_screen.cpp:90
GUIEngine::TextBoxWidget * m_password_tb
Password widget.
Definition: user_screen.hpp:75
virtual void unloaded() OVERRIDE
implement optional callback from parent class GUIEngine::Screen
Definition: user_screen.cpp:717
virtual void beforeAddingWidget() OVERRIDE
implement callback from parent class GUIEngine::Screen
Definition: user_screen.cpp:103
virtual void loadedFromFile() OVERRIDE
implement callback from parent class GUIEngine::Screen
Definition: user_screen.cpp:62
void loginSuccessful()
Callback from player profile if login was successful.
Definition: user_screen.cpp:585
void logoutSuccessful()
Callback from player profile if logout was successful.
Definition: user_screen.cpp:623
void makeEntryFieldsVisible()
Make the entry fields either visible or invisible.
Definition: user_screen.cpp:288
irr::core::stringw m_sign_out_name
The user name that is currently being logged out.
Definition: user_screen.hpp:62
irr::core::stringw m_sign_in_name
The user name that is currently being logged out.
Definition: user_screen.hpp:66
void selectUser(int index)
Called when a user is selected.
Definition: user_screen.cpp:229
virtual void tearDown() OVERRIDE
implement callback from parent class GUIEngine::Screen
Definition: user_screen.cpp:197
A checkbox widget.
Definition: check_box_widget.hpp:34
An extended version of RibbonWidget, with more capabilities.
Definition: dynamic_ribbon_widget.hpp:82
A simple label widget.
Definition: label_widget.hpp:36
A static text/icons/tabs bar widget.
Definition: ribbon_widget.hpp:60
Declares a class to be a singleton.
Definition: screen.hpp:59
Represents a single GUI screen.
Definition: screen.hpp:97
A text field widget.
Definition: text_box_widget.hpp:53
The nearly-abstract base of all widgets (not fully abstract since a bare Widget can be created for th...
Definition: widget.hpp:143
Class for managing player profiles (name, usage frequency, etc.).
Definition: player_profile.hpp:54
Definition: user_screen.hpp:153
Definition: user_screen.hpp:142
PlayerAction
types of input events / what actions the players can do
Definition: input.hpp:117
Contains all GUI engine related classes and functions.
Definition: abstract_state_manager.hpp:33
Definition: input.hpp:35