SuperTuxKart
Loading...
Searching...
No Matches
kart_selection.hpp
1// SuperTuxKart - a fun racing game with go-kart
2//
3// Copyright (C) 2006-2015 SuperTuxKart-Team
4//
5// This program is free software; you can redistribute it and/or
6// modify it under the terms of the GNU General Public License
7// as published by the Free Software Foundation; either version 3
8// of the License, or (at your option) any later version.
9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with this program; if not, write to the Free Software
17// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19#ifndef KART_SELECTION_INCLUDED
20#define KART_SELECTION_INCLUDED
21
22#include "guiengine/screen.hpp"
23#include "guiengine/widgets/dynamic_ribbon_widget.hpp"
24#include "guiengine/widgets/player_kart_widget.hpp"
25#include "states_screens/state_manager.hpp"
26
27namespace GUIEngine
28{
29 class Widget;
30 class BubbleWidget;
31 enum EventPropagation;
32}
33namespace Online
34{
35 class User;
36 class OnlineProfile;
37}
38
39class FocusDispatcher;
40class InputDevice;
41class PlayerProfile;
43
44extern int g_root_id;
45
51{
52 friend class KartHoverListener;
53 friend class PlayerNameSpinner;
54 friend class FocusDispatcher;
55protected:
61
63 friend class GUIEngine::PlayerKartWidget;
64
65 bool m_multiplayer;
66
69
70 bool m_go_to_overworld_next;
71
73
78
79 GUIEngine::PlayerKartWidget* m_removed_widget;
80
83
84 FocusDispatcher *m_dispatcher;
85
86 KartSelectionScreen(const char* filename);
87
89 virtual void allPlayersDone();
90
93 void renumberKarts();
94
100
104 bool validateKartChoices();
105
108
109 void playerConfirm(const int playerID);
110
111 void updateKartStats(uint8_t widget_id,
112 const std::string& selection);
113
116 void updateKartWidgetModel(int widget_id,
117 const std::string& selection,
118 const irr::core::stringw& selectionText,
119 float kart_color);
120
123
126
127 virtual bool isIgnored(const std::string& ident) const { return false; }
128
131private:
133 const std::string& selected_kart_group);
134 bool useContinueButton() const;
135public:
138
140 virtual void loadedFromFile() OVERRIDE;
141
142 void setMultiplayer(bool multiplayer);
143
145 void setFromOverworld(bool from_overworld) { m_from_overworld = from_overworld; }
146
147 void setGoToOverworldNext() { m_go_to_overworld_next = true; }
148
151 bool joinPlayer(InputDevice* device, PlayerProfile* p);
152
158 virtual bool playerQuit(StateManager::ActivePlayer* player);
159
161 virtual void init() OVERRIDE;
162
163 virtual void beforeAddingWidget() OVERRIDE;
164
166 virtual void tearDown() OVERRIDE;
167
169 virtual void eventCallback(GUIEngine::Widget* widget, const std::string& name,
170 const int playerID) OVERRIDE;
171
173 virtual void onUpdate(float dt) OVERRIDE;
174
177 virtual void unloaded() OVERRIDE;
178
181 virtual bool onEscapePressed() OVERRIDE;
182
183}; // KartSelectionScreen
184
187
193class FocusDispatcher : public GUIEngine::Widget
194{
195protected:
196 KartSelectionScreen* m_parent;
197 int m_reserved_id;
198
199 bool m_is_initialised;
200
201public:
202
203 LEAK_CHECK()
204
205 // ------------------------------------------------------------------------
207 // ------------------------------------------------------------------------
208 void setRootID(const int reservedID);
209
210 // ------------------------------------------------------------------------
211 virtual void add();
212
213 // ------------------------------------------------------------------------
214
215 virtual GUIEngine::EventPropagation focused(const int playerID);
216}; // FocusDispatcher
217
221{
222 KartSelectionScreen* m_parent;
223public:
224 unsigned int m_magic_number;
225
227
228 // ------------------------------------------------------------------------
229 virtual ~KartHoverListener();
230
231 // ------------------------------------------------------------------------
232 void onSelectionChanged(GUIEngine::DynamicRibbonWidget* theWidget,
233 const std::string& selectionID,
234 const irr::core::stringw& selectionText,
235 const int playerID);
236}; // KartHoverListener
237
238#endif
239
Currently, navigation for multiple players at the same time is implemented in a somewhat clunky way.
Definition: kart_selection.hpp:194
A text widget that can expand when focused.
Definition: bubble_widget.hpp:36
Even if you have a ribbon that only acts on click/enter, you may wish to know which item is currently...
Definition: dynamic_ribbon_widget.hpp:41
An extended version of RibbonWidget, with more capabilities.
Definition: dynamic_ribbon_widget.hpp:82
A widget representing the kart selection for a player (i.e.
Definition: player_kart_widget.hpp:42
Declares a class to be a singleton.
Definition: screen.hpp:59
Represents a single GUI screen.
Definition: screen.hpp:97
unsigned int m_magic_number
to catch errors as early as possible, for debugging purposes only
Definition: screen.hpp:121
base class for input devices
Definition: input_device.hpp:48
Definition: kart_selection.hpp:221
screen where players can choose their kart
Definition: kart_selection.hpp:51
virtual void allPlayersDone()
Called when all players selected their kart.
Definition: kart_selection.cpp:1225
PtrVector< GUIEngine::PlayerKartWidget, REF > m_kart_widgets
Contains the custom widget shown for every player.
Definition: kart_selection.hpp:60
void addMultiplayerMessage()
Adds a message to the screen which indicates that players must press fire to join.
Definition: kart_selection.cpp:1039
virtual void beforeAddingWidget() OVERRIDE
Optional callback invoked very early, before widgets have been added (contrast with init(),...
Definition: kart_selection.cpp:276
virtual void init() OVERRIDE
implement callback from parent class GUIEngine::Screen
Definition: kart_selection.cpp:346
bool m_from_overworld
Whether this screen is being visited from overworld or not.
Definition: kart_selection.hpp:68
static KartSelectionScreen * getRunningInstance()
Returns the current instance.
Definition: kart_selection.cpp:254
GUIEngine::BubbleWidget * m_multiplayer_message
Message shown in multiplayer mode.
Definition: kart_selection.hpp:82
virtual void unloaded() OVERRIDE
implement optional callback from parent class GUIEngine::Screen
Definition: kart_selection.cpp:491
bool m_must_delete_on_back
To delete the screen if back is pressed.
Definition: kart_selection.hpp:72
virtual void loadedFromFile() OVERRIDE
implement callback from parent class GUIEngine::Screen
Definition: kart_selection.cpp:261
void setKartsFromCurrentGroup()
Fill the ribbon with the karts from the currently selected group.
Definition: kart_selection.cpp:1558
void updateKartWidgetModel(int widget_id, const std::string &selection, const irr::core::stringw &selectionText, float kart_color)
updates model of a kart widget, to have the good selection when the user validates
Definition: kart_selection.cpp:909
static KartSelectionScreen * m_instance_ptr
Stores a pointer to the current selection screen.
Definition: kart_selection.hpp:130
bool m_game_master_confirmed
Stores whether any player confirmed their choice; then, some things are "frozen", for instance the se...
Definition: kart_selection.hpp:77
bool validateIdentChoices()
Checks identities chosen by players, making sure no duplicates are used.
Definition: kart_selection.cpp:1360
virtual bool onEscapePressed() OVERRIDE
implement optional callback from parent class GUIEngine::Screen
Definition: kart_selection.cpp:1202
virtual void tearDown() OVERRIDE
implement callback from parent class GUIEngine::Screen
Definition: kart_selection.cpp:455
virtual void eventCallback(GUIEngine::Widget *widget, const std::string &name, const int playerID) OVERRIDE
implement callback from parent class GUIEngine::Screen
Definition: kart_selection.cpp:1090
virtual bool playerQuit(StateManager::ActivePlayer *player)
Called when a player hits 'rescue'/'cancel' on his device to leave the game.
Definition: kart_selection.cpp:639
bool validateKartChoices()
Checks karts chosen by players, making sure no duplicates are used.
Definition: kart_selection.cpp:1441
void removeMultiplayerMessage()
Remove the multiplayer message.
Definition: kart_selection.cpp:1074
void setFromOverworld(bool from_overworld)
Set whether this screen is being visited from overworld or not.
Definition: kart_selection.hpp:145
virtual void onUpdate(float dt) OVERRIDE
implement callback from parent class GUIEngine::Screen
Definition: kart_selection.cpp:765
void renumberKarts()
Called when number/order of karts changed, so that all will keep an up-to-date ID.
Definition: kart_selection.cpp:1519
bool joinPlayer(InputDevice *device, PlayerProfile *p)
Called when a player hits 'fire'/'select' on his device to join the game.
Definition: kart_selection.cpp:499
Class for managing player profiles (name, usage frequency, etc.).
Definition: player_profile.hpp:54
Definition: ptr_vector.hpp:44
Represents a player that is currently playing.
Definition: state_manager.hpp:76
Contains all GUI engine related classes and functions.
Definition: abstract_state_manager.hpp:33