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 
67  enum {RR_INIT,
68  RR_RACE_RESULT,
69  RR_WAITING_GP_RESULT,
70  RR_OLD_GP_RESULTS,
71  RR_INCREASE_POINTS,
72  RR_RESORT_TABLE,
73  RR_WAIT_TILL_END}
74  m_animation_state;
75 
76  class RowInfo
77  {
78  public:
80  unsigned int m_kart_id;
82  float m_start_at;
84  float m_x_pos;
86  float m_y_pos;
91  float m_radius;
95  core::stringw m_kart_name;
97  float m_new_points;
107  video::ITexture *m_kart_icon;
109  core::stringw m_finish_time_string;
113  unsigned int m_laps;
114  }; // Rowinfo
115 
118  std::vector<RowInfo> m_all_row_infos, m_all_row_info_waiting;
119 
122 
125 
128 
132 
136 
139 
142 
144  unsigned int m_width_icon;
145 
147  unsigned int m_width_kart_name;
148 
150  unsigned int m_width_finish_time;
151 
153  unsigned int m_width_new_points;
154 
157  unsigned int m_leftmost_column;
158 
160  unsigned int m_top;
161 
163  unsigned int m_width_column_space;
164 
166  unsigned int m_table_width;
167 
170 
174 
175  bool m_started_race_over_music;
176 
178  //bool m_was_monospace;
179 
182 
185 
188 
189  unsigned int m_width_all_points;
190 
191  int m_max_tracks;
192  int m_start_track;
193  int m_end_track;
194  int m_sshot_height;
195 
196  PtrVector<GUIEngine::Widget, HOLD> m_gp_progress_widgets;
197 
198  static const int SSHOT_SEPARATION = 10;
199 
200  void displayOneEntry(unsigned int x, unsigned int y,
201  unsigned int n, bool display_points);
202  void determineTableLayout();
203  void determineGPLayout();
204  void enableAllButtons();
205  void enableGPProgress();
206  void addGPProgressWidget(GUIEngine::Widget* widget);
207  void displayGPProgress();
208  void displayPostRaceInfo();
209  void displayCTFResults();
210  void displaySoccerResults();
211  void displayScreenShots();
212 
213  int getFontHeight () const;
214 
215 public:
216 
217  RaceResultGUI();
218  virtual void renderGlobal(float dt) OVERRIDE;
219 
221  virtual void loadedFromFile() OVERRIDE {};
222 
223  virtual void init() OVERRIDE;
224  virtual void tearDown() OVERRIDE;
225  virtual bool onEscapePressed() OVERRIDE;
226  virtual void unload() OVERRIDE;
227  virtual GUIEngine::EventPropagation
228  filterActions(PlayerAction action, int deviceID, const unsigned int value,
229  Input::InputType type, int playerId) OVERRIDE;
230  void eventCallback(GUIEngine::Widget* widget, const std::string& name,
231  const int playerID) OVERRIDE;
232  friend class GUIEngine::ScreenSingleton<RaceResultGUI>;
233 
235  const core::dimension2du getMiniMapSize() const OVERRIDE
236  { return core::dimension2du(0, 0); }
237 
239  virtual void renderPlayerView(const Camera *camera, float dt) OVERRIDE {}
240 
241  virtual void onUpdate(float dt) OVERRIDE;
242  virtual void onDraw(float dt) OVERRIDE;
243 
248  virtual void addMessage(const irr::core::stringw &m,
249  const AbstractKart *kart,
250  float time,
251  const video::SColor &color=
252  video::SColor(255, 255, 0, 255),
253  bool important=true,
254  bool big_font=false,
255  bool outline=false) OVERRIDE { }
256 
257  void nextPhase();
258 
260  void clearHighscores();
261 
269  void setHighscore(int rank);
270 
271  virtual void onConfirm() OVERRIDE;
272  void cleanupGPProgress();
273 }; // RaceResultGUI
274 
275 #endif
unsigned int m_distance_between_rows
Distance between each row of the race results.
Definition: race_result_gui.hpp:138
float m_new_points
Points earned in this race.
Definition: race_result_gui.hpp:97
bool m_is_player_kart
True if kart is a player kart.
Definition: race_result_gui.hpp:88
float m_radius
The radius to use when sorting the entries.
Definition: race_result_gui.hpp:91
Wrapper around an instance of the Music interface Adds information like composer, song title...
Definition: music_information.hpp:42
An abstract base class for the two race guis (race_gui and race_result gui)
Definition: race_gui_base.hpp:49
float m_kart_color
The kart color.
Definition: race_result_gui.hpp:111
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:248
float m_centre_point
The center point when sorting the entries.
Definition: race_result_gui.hpp:93
int m_new_overall_points
New overall points after this race.
Definition: race_result_gui.hpp:99
SFXBase * m_finish_sound
The previous monospace state of the font.
Definition: race_result_gui.hpp:181
const core::dimension2du getMiniMapSize() const OVERRIDE
Should not be called anymore.
Definition: race_result_gui.hpp:235
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:127
unsigned int m_table_width
The overall width of the table.
Definition: race_result_gui.hpp:166
Definition: race_result_gui.hpp:76
gui::ScalableFont * m_font
The font to use.
Definition: race_result_gui.hpp:169
unsigned int m_width_finish_time
Width of the finish time column.
Definition: race_result_gui.hpp:150
Definition: three_d_animation.hpp:32
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:105
float m_timer
Timer variable for animations.
Definition: race_result_gui.hpp:54
MusicInformation * m_race_over_music
Music to be played after race ended.
Definition: race_result_gui.hpp:184
unsigned int m_distance_between_meta_rows
Distance between each row of the highscore, race data, etc.
Definition: race_result_gui.hpp:141
float m_time_overall_scroll
The overall time the first phase (scrolling) is displayed.
Definition: race_result_gui.hpp:135
bool m_gp_position_was_changed
True if a GP position was changed.
Definition: race_result_gui.hpp:173
virtual void loadedFromFile() OVERRIDE
Implement callback from parent class GUIEngine::Screen.
Definition: race_result_gui.hpp:221
float m_y_pos
Currenct Y position.
Definition: race_result_gui.hpp:86
video::ITexture * m_kart_icon
The kart icons.
Definition: race_result_gui.hpp:107
float m_time_single_scroll
The time a single line scrolls into place.
Definition: race_result_gui.hpp:124
std::vector< RowInfo > m_all_row_infos
The team icons.
Definition: race_result_gui.hpp:118
unsigned int m_width_new_points
Width of the new points columns.
Definition: race_result_gui.hpp:153
core::stringw m_finish_time_string
The times of all karts in the right order.
Definition: race_result_gui.hpp:109
unsigned int m_width_column_space
Size of space between columns.
Definition: race_result_gui.hpp:163
Definition: scalable_font.hpp:34
unsigned int m_kart_id
Kart ID in World.
Definition: race_result_gui.hpp:80
unsigned int m_width_icon
The size of the kart icons.
Definition: race_result_gui.hpp:144
unsigned int m_laps
Number of laps that kart finished.
Definition: race_result_gui.hpp:113
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:239
unsigned int m_top
Top-most pixel for first row.
Definition: race_result_gui.hpp:160
float m_start_at
Start time for each line of the animation.
Definition: race_result_gui.hpp:82
Represents a single GUI screen.
Definition: screen.hpp:96
Declares a class to be a singleton.
Definition: screen.hpp:58
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:121
int m_highscore_rank
For highscores.
Definition: race_result_gui.hpp:187
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:95
float m_time_for_points
The time for inreasing the points by one during the point update phase.
Definition: race_result_gui.hpp:131
The base class for sound effects.
Definition: sfx_base.hpp:42
This is the base class for all cameras.
Definition: camera.hpp:48
unsigned int m_width_kart_name
Width of the kart name column.
Definition: race_result_gui.hpp:147
An abstract interface for the actual karts.
Definition: abstract_kart.hpp:61
The nearly-abstract base of all widgets (not fully abstract since a bare Widget can be created for th...
Definition: widget.hpp:142
int m_new_gp_rank
New GP rank after this race.
Definition: race_result_gui.hpp:101
float m_x_pos
Currenct X position.
Definition: race_result_gui.hpp:84
unsigned int m_leftmost_column
Position of left end of table (so that the whole table is aligned.
Definition: race_result_gui.hpp:157