SuperTuxKart
race_result_gui.hpp
1 //
2 // SuperTuxKart - a fun racing game with go-kart
3 // Copyright (C) 2010-2015 Joerg Henrichs
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 HEADER_RACE_RESULT_GUI_HPP
20 #define HEADER_RACE_RESULT_GUI_HPP
21 
22 
23 #include "guiengine/screen.hpp"
24 #include "states_screens/dialogs/message_dialog.hpp"
25 #include "states_screens/race_gui_base.hpp"
26 #include "states_screens/state_manager.hpp"
27 
28 #include <assert.h>
29 #include <vector>
30 
31 
32 namespace irr
33 {
34  namespace gui
35  {
36  class ScalableFont;
37  }
38 }
39 
40 class MusicInformation;
41 class SFXBase;
42 
47 class RaceResultGUI : public RaceGUIBase,
48  public GUIEngine::Screen,
49  public GUIEngine::ScreenSingleton<RaceResultGUI>,
51 {
52 private:
54  float m_timer;
55 
66  enum {RR_INIT,
67  RR_RACE_RESULT,
68  RR_OLD_GP_RESULTS,
69  RR_INCREASE_POINTS,
70  RR_RESORT_TABLE,
71  RR_WAIT_TILL_END}
73 
74  class RowInfo
75  {
76  public:
78  float m_start_at;
80  float m_x_pos;
82  float m_y_pos;
87  float m_radius;
91  core::stringw m_kart_name;
93  float m_new_points;
101  video::ITexture *m_kart_icon;
103  core::stringw m_finish_time_string;
104  }; // Rowinfo
105 
108  std::vector<RowInfo> m_all_row_infos;
109 
112 
115 
118 
122 
126 
129 
132 
134  unsigned int m_width_icon;
135 
137  unsigned int m_width_kart_name;
138 
140  unsigned int m_width_finish_time;
141 
143  unsigned int m_width_new_points;
144 
147  unsigned int m_leftmost_column;
148 
150  unsigned int m_top;
151 
153  unsigned int m_width_column_space;
154 
156  unsigned int m_table_width;
157 
160 
164 
166  //bool m_was_monospace;
167 
170 
173 
176 
177  unsigned int m_width_all_points;
178 
179  int m_max_tracks;
180  int m_start_track;
181  int m_end_track;
182  int m_sshot_height;
183 
184  PtrVector<GUIEngine::Widget, HOLD> m_gp_progress_widgets;
185 
186  static const int SSHOT_SEPARATION = 10;
187 
188  void displayOneEntry(unsigned int x, unsigned int y,
189  unsigned int n, bool display_points);
190  void determineTableLayout();
191  void determineGPLayout();
192  void enableAllButtons();
193  void enableGPProgress();
194  void addGPProgressWidget(GUIEngine::Widget* widget);
195  void displayGPProgress();
196  void cleanupGPProgress();
197  void displayPostRaceInfo();
198  void displayCTFResults();
199  void displaySoccerResults();
200  void displayScreenShots();
201 
202  int getFontHeight () const;
203 
204 public:
205 
206  RaceResultGUI();
207  virtual void renderGlobal(float dt) OVERRIDE;
208 
210  virtual void loadedFromFile() OVERRIDE {};
211 
212  virtual void init() OVERRIDE;
213  virtual void tearDown() OVERRIDE;
214  virtual bool onEscapePressed() OVERRIDE;
215  virtual GUIEngine::EventPropagation
216  filterActions(PlayerAction action, int deviceID, const unsigned int value,
217  Input::InputType type, int playerId) OVERRIDE;
218  void eventCallback(GUIEngine::Widget* widget, const std::string& name,
219  const int playerID) OVERRIDE;
220  void backToLobby();
221 
222 
223  friend class GUIEngine::ScreenSingleton<RaceResultGUI>;
224 
226  const core::dimension2du getMiniMapSize() const OVERRIDE
227  { assert(false); return core::dimension2du(0, 0); }
228 
230  virtual void renderPlayerView(const Camera *camera, float dt) OVERRIDE {}
231 
232  virtual void onUpdate(float dt) OVERRIDE;
233  virtual void onDraw(float dt) OVERRIDE;
234 
239  virtual void addMessage(const irr::core::stringw &m,
240  const AbstractKart *kart,
241  float time,
242  const video::SColor &color=
243  video::SColor(255, 255, 0, 255),
244  bool important=true,
245  bool big_font=false,
246  bool outline=false) OVERRIDE { }
247 
248  void nextPhase();
249 
251  void clearHighscores();
252 
260  void setHighscore(int rank);
261 
262  virtual void onConfirm() OVERRIDE;
263 }; // RaceResultGUI
264 
265 #endif
unsigned int m_distance_between_rows
Distance between each row of the race results.
Definition: race_result_gui.hpp:128
float m_new_points
Points earned in this race.
Definition: race_result_gui.hpp:93
bool m_is_player_kart
True if kart is a player kart.
Definition: race_result_gui.hpp:84
float m_radius
The radius to use when sorting the entries.
Definition: race_result_gui.hpp:87
Wrapper around an instance of the Music interface Adds information like composer, song title,...
Definition: music_information.hpp:42
Contains all GUI engine related classes and functions.
Definition: abstract_state_manager.hpp:31
void determineGPLayout()
Determine the layout and fields for the GP table based on the previous GP results.
Definition: race_result_gui.cpp:1182
An abstract base class for the two race guis (race_gui and race_result gui)
Definition: race_gui_base.hpp:49
virtual void addMessage(const irr::core::stringw &m, const AbstractKart *kart, float time, const video::SColor &color=video::SColor(255, 255, 0, 255), bool important=true, bool big_font=false, bool outline=false) OVERRIDE
No more messages need to be displayed, but the function might still be called (e.g.
Definition: race_result_gui.hpp:239
float m_centre_point
The center point when sorting the entries.
Definition: race_result_gui.hpp:89
int m_new_overall_points
New overall points after this race.
Definition: race_result_gui.hpp:95
SFXBase * m_finish_sound
The previous monospace state of the font.
Definition: race_result_gui.hpp:169
const core::dimension2du getMiniMapSize() const OVERRIDE
Should not be called anymore.
Definition: race_result_gui.hpp:226
PlayerAction
types of input events / what actions the players can do
Definition: input.hpp:116
float m_time_rotation
Time to rotate the GP entries.
Definition: race_result_gui.hpp:117
unsigned int m_table_width
The overall width of the table.
Definition: race_result_gui.hpp:156
virtual void onUpdate(float dt) OVERRIDE
Called once a frame.
Definition: race_result_gui.cpp:963
Definition: race_result_gui.hpp:74
gui::ScalableFont * m_font
The font to use.
Definition: race_result_gui.hpp:159
unsigned int m_width_finish_time
Width of the finish time column.
Definition: race_result_gui.hpp:140
void backToLobby()
Sets up the gui to go back to the lobby.
Definition: race_result_gui.cpp:522
float m_current_displayed_points
When updating the number of points in the display, this is the currently displayed number of points.
Definition: race_result_gui.hpp:99
Definition: input.hpp:34
float m_timer
Timer variable for animations.
Definition: race_result_gui.hpp:54
void nextPhase()
This function is called when one of the player presses 'fire'.
Definition: race_result_gui.cpp:923
MusicInformation * m_race_over_music
Music to be played after race ended.
Definition: race_result_gui.hpp:172
virtual void onDraw(float dt) OVERRIDE
Called once a frame, this now triggers the rendering of the actual race result gui.
Definition: race_result_gui.cpp:986
virtual void onConfirm() OVERRIDE
Implement to be notified of dialog confirmed.
Definition: race_result_gui.cpp:714
unsigned int m_distance_between_meta_rows
Distance between each row of the highscore, race data, etc.
Definition: race_result_gui.hpp:131
float m_time_overall_scroll
The overall time the first phase (scrolling) is displayed.
Definition: race_result_gui.hpp:125
bool m_gp_position_was_changed
True if a GP position was changed.
Definition: race_result_gui.hpp:163
virtual void loadedFromFile() OVERRIDE
Implement callback from parent class GUIEngine::Screen.
Definition: race_result_gui.hpp:210
void displayOneEntry(unsigned int x, unsigned int y, unsigned int n, bool display_points)
Displays the race results for a single kart.
Definition: race_result_gui.cpp:1275
float m_y_pos
Currenct Y position.
Definition: race_result_gui.hpp:82
video::ITexture * m_kart_icon
The kart icons.
Definition: race_result_gui.hpp:101
void eventCallback(GUIEngine::Widget *widget, const std::string &name, const int playerID) OVERRIDE
will be called everytime something happens.
Definition: race_result_gui.cpp:284
float m_time_single_scroll
The time a single line scrolls into place.
Definition: race_result_gui.hpp:114
std::vector< RowInfo > m_all_row_infos
The team icons.
Definition: race_result_gui.hpp:108
unsigned int m_width_new_points
Width of the new points columns.
Definition: race_result_gui.hpp:143
core::stringw m_finish_time_string
The times of all karts in the right order.
Definition: race_result_gui.hpp:103
unsigned int m_width_column_space
Size of space between columns.
Definition: race_result_gui.hpp:153
virtual void renderGlobal(float dt) OVERRIDE
Render all global parts of the race gui, i.e.
Definition: race_result_gui.cpp:997
Definition: scalable_font.hpp:34
unsigned int m_width_icon
The size of the kart icons.
Definition: race_result_gui.hpp:134
void determineTableLayout()
This determines the layout, i.e.
Definition: race_result_gui.cpp:734
virtual void tearDown() OVERRIDE
Callback invoked before leaving this menu.
Definition: race_result_gui.cpp:158
virtual void renderPlayerView(const Camera *camera, float dt) OVERRIDE
No kart specific view needs to be rendered in the result gui.
Definition: race_result_gui.hpp:230
virtual GUIEngine::EventPropagation filterActions(PlayerAction action, int deviceID, const unsigned int value, Input::InputType type, int playerId) OVERRIDE
This is called before an event is sent to a widget.
Definition: race_result_gui.cpp:944
unsigned int m_top
Top-most pixel for first row.
Definition: race_result_gui.hpp:150
float m_start_at
Start time for each line of the animation.
Definition: race_result_gui.hpp:78
void enableAllButtons()
Makes the correct buttons visible again, and gives them the right label.
Definition: race_result_gui.cpp:174
Represents a single GUI screen.
Definition: screen.hpp:94
virtual bool onEscapePressed() OVERRIDE
If escape is pressed, don't do the default option (close the screen), but advance to the next animati...
Definition: race_result_gui.cpp:933
Declares a class to be a singleton.
Definition: screen.hpp:57
Displays the results (while the end animation is shown).
Definition: race_result_gui.hpp:47
float m_time_between_rows
Time to wait till the next row starts to be animated.
Definition: race_result_gui.hpp:111
int m_highscore_rank
For highscores.
Definition: race_result_gui.hpp:175
void setHighscore(int rank)
To call if the user got a new highscore.
Definition: race_result_gui.cpp:1554
Listener interface to get notified of whether the user chose to confirm or cancel.
Definition: message_dialog.hpp:38
core::stringw m_kart_name
The names of all karts in the right order.
Definition: race_result_gui.hpp:91
RaceResultGUI()
Constructor, initialises internal data structures.
Definition: race_result_gui.cpp:73
float m_time_for_points
The time for inreasing the points by one during the point update phase.
Definition: race_result_gui.hpp:121
The base class for sound effects.
Definition: sfx_base.hpp:42
This is the base class for all cameras.
Definition: camera.hpp:48
virtual void init() OVERRIDE
Besides calling init in the base class this makes all buttons of this screen invisible.
Definition: race_result_gui.cpp:83
unsigned int m_width_kart_name
Width of the kart name column.
Definition: race_result_gui.hpp:137
An abstract interface for the actual karts.
Definition: abstract_kart.hpp:61
void clearHighscores()
Show no highscore.
Definition: race_result_gui.cpp:1547
The nearly-abstract base of all widgets (not fully abstract since a bare Widget can be created for th...
Definition: widget.hpp:138
float m_x_pos
Currenct X position.
Definition: race_result_gui.hpp:80
unsigned int m_leftmost_column
Position of left end of table (so that the whole table is aligned.
Definition: race_result_gui.hpp:147
enum RaceResultGUI::@20 m_animation_state
Finite state machine for the animations: INIT: Set up data structures.