SuperTuxKart
Loading...
Searching...
No Matches
player_kart_widget.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 PLAYER_KART_WIDGET_HPP
20#define PLAYER_KART_WIDGET_HPP
21
22#include "guiengine/widgets/spinner_widget.hpp"
23#include "states_screens/state_manager.hpp"
24#include <IGUIStaticText.h>
25#include <IGUIImage.h>
26#include <string>
27
28
30
31namespace GUIEngine
32{
33 class PlayerNameSpinner;
34 class KartStatsWidget;
35 class ModelViewWidget;
36 class LabelWidget;
37
42 {
44 bool m_ready;
47
49 int player_name_x, player_name_y, player_name_w, player_name_h;
50 int model_x, model_y, model_w, model_h;
51 int kart_name_x, kart_name_y, kart_name_w, kart_name_h;
52 int m_kart_stats_x, m_kart_stats_y, m_kart_stats_w, m_kart_stats_h;
53
57
59 int target_x, target_y, target_w, target_h;
60 float x_speed, y_speed, w_speed, h_speed;
61
65 int m_player_id;
66
69 std::string spinnerID;
70
71#ifdef DEBUG
72 long m_magic_number;
73#endif
74
75 public:
76
77 LEAK_CHECK()
78
79
81 KartStatsWidget* m_kart_stats;
82 ModelViewWidget* m_model_view;
83 LabelWidget* m_kart_name;
84
85 KartSelectionScreen* m_parent_screen;
86
87 irr::gui::IGUIStaticText* m_ready_text;
88
89 core::stringw deviceName;
90 std::string m_kart_internal_name;
91
92 bool m_not_updated_yet;
93
95 StateManager::ActivePlayer* associated_player,
96 core::recti area, const int player_id,
97 std::string kart_group,
98 const int irrlicht_idget_id=-1);
99 // ------------------------------------------------------------------------
100
102
103 // ------------------------------------------------------------------------
105 void setPlayerID(const int newPlayerID);
106 // ------------------------------------------------------------------------
107 PlayerNameSpinner* getPlayerNameSpinner() const
108 { return m_player_ident_spinner; }
109 // ------------------------------------------------------------------------
111 int getPlayerID() const;
112
113 // ------------------------------------------------------------------------
115 virtual void add();
116
117 // ------------------------------------------------------------------------
120
121 // ------------------------------------------------------------------------
124 void move(const int x, const int y, const int w, const int h);
125
126 // ------------------------------------------------------------------------
128 void markAsReady();
129
130 // ------------------------------------------------------------------------
132 bool isReady();
133
134 // ------------------------------------------------------------------------
137
138 // -------------------------------------------------------------------------
140 void onUpdate(float delta);
141
142 // -------------------------------------------------------------------------
144 virtual GUIEngine::EventPropagation transmitEvent(
146 const std::string& originator,
147 const int m_player_id);
148
149 // -------------------------------------------------------------------------
152 void setSize(const int x, const int y, const int w, const int h);
153
154 // -------------------------------------------------------------------------
155
157 void setKartInternalName(const std::string& whichKart);
158
159 // -------------------------------------------------------------------------
160
161 const std::string& getKartInternalName() const;
162
163 // -------------------------------------------------------------------------
164
166 virtual GUIEngine::EventPropagation onSpinnerConfirmed();
167 // -------------------------------------------------------------------------
168 void enableHandicapForNetwork();
169 }; // PlayerKartWidget
170}
171
172#endif
173
A progress bar widget.
Definition: kart_stats_widget.hpp:43
A simple label widget.
Definition: label_widget.hpp:36
A model view widget.
Definition: model_view_widget.hpp:37
A widget representing the kart selection for a player (i.e.
Definition: player_kart_widget.hpp:42
HandicapLevel m_handicap
If the player is handicapped.
Definition: player_kart_widget.hpp:46
void markAsReady()
Call when player confirmed his identity and kart.
Definition: player_kart_widget.cpp:431
virtual GUIEngine::EventPropagation transmitEvent(GUIEngine::Widget *w, const std::string &originator, const int m_player_id)
Event callback.
Definition: player_kart_widget.cpp:595
bool m_ready
Whether this player confirmed their selection.
Definition: player_kart_widget.hpp:44
virtual GUIEngine::EventPropagation onSpinnerConfirmed()
Event callback from ISpinnerConfirmListener.
Definition: player_kart_widget.cpp:743
bool isReady()
Definition: player_kart_widget.cpp:466
void setSize(const int x, const int y, const int w, const int h)
Sets the size of the widget as a whole, and placed children widgets inside itself.
Definition: player_kart_widget.cpp:656
int target_x
For animation purposes (see method 'move')
Definition: player_kart_widget.hpp:59
virtual void add()
Add the widgets to the current screen.
Definition: player_kart_widget.cpp:330
int m_irrlicht_widget_id
A reserved ID for this widget if any, -1 otherwise.
Definition: player_kart_widget.hpp:56
PlayerNameSpinner * m_player_ident_spinner
Sub-widgets created by this widget.
Definition: player_kart_widget.hpp:80
int getPlayerID() const
Returns the ID of this player.
Definition: player_kart_widget.cpp:322
void setKartInternalName(const std::string &whichKart)
Sets which kart was selected for this player.
Definition: player_kart_widget.cpp:726
void onUpdate(float delta)
Updates the animation (moving/shrinking/etc.)
Definition: player_kart_widget.cpp:482
int player_name_x
widget coordinates
Definition: player_kart_widget.hpp:49
std::string spinnerID
Internal name of the spinner; useful to interpret spinner events, which contain the name of the activ...
Definition: player_kart_widget.hpp:69
StateManager::ActivePlayer * m_associated_player
Object representing this player.
Definition: player_kart_widget.hpp:64
void move(const int x, const int y, const int w, const int h)
Starts a 'move/resize' animation, by simply passing destination coords.
Definition: player_kart_widget.cpp:415
HandicapLevel getHandicap()
Definition: player_kart_widget.cpp:474
void setPlayerID(const int newPlayerID)
Called when players are renumbered (changes the player ID)
Definition: player_kart_widget.cpp:287
StateManager::ActivePlayer * getAssociatedPlayer()
Get the associated ActivePlayer object.
Definition: player_kart_widget.cpp:406
A small extension to the spinner widget to add features like player ID management or badging.
Definition: player_name_spinner.hpp:32
Definition: spinner_widget.hpp:44
The nearly-abstract base of all widgets (not fully abstract since a bare Widget can be created for th...
Definition: widget.hpp:143
screen where players can choose their kart
Definition: kart_selection.hpp:51
Represents a player that is currently playing.
Definition: state_manager.hpp:76
A concrete scene manager, derived from GUIEngine's AbastractSceneManager.
Definition: state_manager.hpp:60
Contains all GUI engine related classes and functions.
Definition: abstract_state_manager.hpp:33
HandicapLevel
Handicap per player.
Definition: remote_kart_info.hpp:42