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 SERVER_ONLY // No GUI files in server builds
20 #ifndef HEADER_RACE_RESULT_GUI_HPP
21 #define HEADER_RACE_RESULT_GUI_HPP
22 
23 
24 #include "guiengine/screen.hpp"
25 #include "states_screens/dialogs/message_dialog.hpp"
26 #include "states_screens/race_gui_base.hpp"
27 #include "states_screens/state_manager.hpp"
28 
29 #include <assert.h>
30 #include <vector>
31 
32 
33 namespace irr
34 {
35  namespace gui
36  {
37  class ScalableFont;
38  }
39 }
40 
41 class MusicInformation;
42 class SFXBase;
43 
48 class RaceResultGUI : public RaceGUIBase,
49  public GUIEngine::Screen,
50  public GUIEngine::ScreenSingleton<RaceResultGUI>,
52 {
53 private:
55  float m_timer;
56 
68  enum {RR_INIT,
69  RR_RACE_RESULT,
70  RR_WAITING_GP_RESULT,
71  RR_OLD_GP_RESULTS,
72  RR_INCREASE_POINTS,
73  RR_RESORT_TABLE,
74  RR_WAIT_TILL_END}
76 
77  class RowInfo
78  {
79  public:
81  unsigned int m_kart_id;
83  float m_start_at;
85  float m_x_pos;
87  float m_y_pos;
92  float m_radius;
96  core::stringw m_kart_name;
98  float m_new_points;
108  video::ITexture *m_kart_icon;
110  core::stringw m_finish_time_string;
114  unsigned int m_laps;
115  }; // Rowinfo
116 
119  std::vector<RowInfo> m_all_row_infos, m_all_row_info_waiting;
120 
123 
126 
129 
133 
137 
140 
143 
146 
148  unsigned int m_width_icon;
149 
151  unsigned int m_width_kart_name;
152 
154  unsigned int m_width_finish_time;
155 
157  unsigned int m_width_new_points;
158 
161  unsigned int m_leftmost_column;
162 
164  unsigned int m_top;
165 
167  unsigned int m_width_column_space;
168 
170  unsigned int m_table_width;
171 
173  gui::ScalableFont *m_font;
174 
178 
179  bool m_started_race_over_music;
180 
182  //bool m_was_monospace;
183 
186 
189 
192 
195 
196  unsigned int m_width_all_points;
197 
198  int m_max_tracks;
199  int m_start_track;
200  int m_end_track;
201  int m_sshot_height;
202 
203  PtrVector<GUIEngine::Widget, HOLD> m_gp_progress_widgets;
204 
205  static const int SSHOT_SEPARATION = 10;
206 
207  void displayOneEntry(unsigned int x, unsigned int y,
208  unsigned int n, bool display_points);
209  void determineTableLayout();
210  void determineGPLayout();
211  void enableAllButtons();
212  void enableGPProgress();
213  void addGPProgressWidget(GUIEngine::Widget* widget);
214  void displayGPProgress();
215  void displayPostRaceInfo();
216  int displayHighscores(int x, int y, bool increase_density);
217  int displayLapDifficulty(int x, int y, bool increase_density);
218  int displayChallengeInfo(int x, int y, bool increase_density);
219  void displayCTFResults();
220  void drawCTFScorers(KartTeam team, int x, int y, int height);
221  void displaySoccerResults();
222  void drawTeamScorers(KartTeam team, int x, int y, int height);
223  void displayBenchmarkSummary();
224  void displayScreenShots();
225 
226  int getFontHeight () const;
227 
228 public:
229 
230  RaceResultGUI();
231  virtual void renderGlobal(float dt) OVERRIDE;
232 
234  virtual void loadedFromFile() OVERRIDE {};
235 
236  virtual void init() OVERRIDE;
237  virtual void tearDown() OVERRIDE;
238  virtual bool onEscapePressed() OVERRIDE;
239  virtual void unload() OVERRIDE;
240  virtual GUIEngine::EventPropagation
241  filterActions(PlayerAction action, int deviceID, const unsigned int value,
242  Input::InputType type, int playerId) OVERRIDE;
243  void eventCallback(GUIEngine::Widget* widget, const std::string& name,
244  const int playerID) OVERRIDE;
245  friend class GUIEngine::ScreenSingleton<RaceResultGUI>;
246 
248  const core::dimension2du getMiniMapSize() const OVERRIDE
249  { return core::dimension2du(0, 0); }
250 
252  virtual void renderPlayerView(const Camera *camera, float dt) OVERRIDE {}
253 
254  virtual void onUpdate(float dt) OVERRIDE;
255  virtual void onDraw(float dt) OVERRIDE;
256 
261  virtual void addMessage(const irr::core::stringw &m,
262  const AbstractKart *kart,
263  float time,
264  const video::SColor &color=
265  video::SColor(255, 255, 0, 255),
266  bool important=true,
267  bool big_font=false,
268  bool outline=false) OVERRIDE { }
269 
270  void nextPhase();
271 
273  void clearHighscores();
274 
282  void setHighscore(int rank);
283 
284  virtual void onConfirm() OVERRIDE;
285  void cleanupGPProgress();
286  virtual void onResize() OVERRIDE;
287 }; // RaceResultGUI
288 
289 #endif
290 #endif // ifndef SERVER_ONLY
An abstract interface for the actual karts.
Definition: abstract_kart.hpp:62
This is the base class for all cameras.
Definition: camera.hpp:49
Declares a class to be a singleton.
Definition: screen.hpp:59
Represents a single GUI screen.
Definition: screen.hpp:94
The nearly-abstract base of all widgets (not fully abstract since a bare Widget can be created for th...
Definition: widget.hpp:147
Listener interface to get notified of whether the user chose to confirm or cancel.
Definition: message_dialog.hpp:39
Wrapper around an instance of the Music interface Adds information like composer, song title,...
Definition: music_information.hpp:43
An abstract base class for the two race guis (race_gui and race_result gui)
Definition: race_gui_base.hpp:50
Definition: race_result_gui.hpp:78
core::stringw m_finish_time_string
The times of all karts in the right order.
Definition: race_result_gui.hpp:110
video::ITexture * m_kart_icon
The kart icons.
Definition: race_result_gui.hpp:108
core::stringw m_kart_name
The names of all karts in the right order.
Definition: race_result_gui.hpp:96
float m_kart_color
The kart color.
Definition: race_result_gui.hpp:112
int m_new_gp_rank
New GP rank after this race.
Definition: race_result_gui.hpp:102
float m_centre_point
The center point when sorting the entries.
Definition: race_result_gui.hpp:94
float m_radius
The radius to use when sorting the entries.
Definition: race_result_gui.hpp:92
unsigned int m_laps
Number of laps that kart finished.
Definition: race_result_gui.hpp:114
bool m_is_player_kart
True if kart is a player kart.
Definition: race_result_gui.hpp:89
float m_y_pos
Currenct Y position.
Definition: race_result_gui.hpp:87
int m_new_overall_points
New overall points after this race.
Definition: race_result_gui.hpp:100
unsigned int m_kart_id
Kart ID in World.
Definition: race_result_gui.hpp:81
float m_start_at
Start time for each line of the animation.
Definition: race_result_gui.hpp:83
float m_x_pos
Currenct X position.
Definition: race_result_gui.hpp:85
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:106
float m_new_points
Points earned in this race.
Definition: race_result_gui.hpp:98
Displays the results (while the end animation is shown).
Definition: race_result_gui.hpp:52
virtual void unload() OVERRIDE
Next time this menu needs to be shown, don't use cached values, re-calculate everything.
Definition: race_result_gui.cpp:824
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:261
float m_most_points
Maximum number of points earned by a player in this game (used in animation).
Definition: race_result_gui.hpp:194
unsigned int m_width_finish_time
Width of the finish time column.
Definition: race_result_gui.hpp:154
void drawCTFScorers(KartTeam team, int x, int y, int height)
Displays the CTF scorers for a team.
Definition: race_result_gui.cpp:759
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:1110
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:1415
float m_timer
Timer variable for animations.
Definition: race_result_gui.hpp:55
int displayLapDifficulty(int x, int y, bool increase_density)
Displays the difficulty, the number of laps and the best lap time, if applicable for this game mode.
Definition: race_result_gui.cpp:2049
void eventCallback(GUIEngine::Widget *widget, const std::string &name, const int playerID) OVERRIDE
will be called everytime something happens.
Definition: race_result_gui.cpp:389
virtual void renderGlobal(float dt) OVERRIDE
Render all global parts of the race gui, i.e.
Definition: race_result_gui.cpp:1120
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:252
bool m_gp_position_was_changed
True if a GP position was changed.
Definition: race_result_gui.hpp:177
unsigned int m_table_width
The overall width of the table.
Definition: race_result_gui.hpp:170
gui::ScalableFont * m_font
The font to use.
Definition: race_result_gui.hpp:173
void displayPostRaceInfo()
Manages the display of the post-race info located on the right-side of the screen as applicable: high...
Definition: race_result_gui.cpp:1879
void clearHighscores()
Show no highscore.
Definition: race_result_gui.cpp:1688
float m_time_rotation
Time to rotate the GP entries.
Definition: race_result_gui.hpp:128
unsigned int m_top
Top-most pixel for first row.
Definition: race_result_gui.hpp:164
unsigned int m_distance_between_meta_rows
Distance between each row of the highscore, race data, etc.
Definition: race_result_gui.hpp:145
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:1069
float m_time_for_points
The time for inreasing the points by one during the point update phase.
Definition: race_result_gui.hpp:132
void enableAllButtons()
Makes the correct buttons visible again, and gives them the right label.
Definition: race_result_gui.cpp:253
virtual void onResize() OVERRIDE
optional callback you can override to be notified at every resize.
Definition: race_result_gui.cpp:2431
void nextPhase()
This function is called when one of the player presses 'fire'.
Definition: race_result_gui.cpp:1048
unsigned int m_width_new_points
Width of the new points columns.
Definition: race_result_gui.hpp:157
unsigned int m_distance_between_rows
Distance between each row of the race results.
Definition: race_result_gui.hpp:142
const core::dimension2du getMiniMapSize() const OVERRIDE
Should not be called anymore.
Definition: race_result_gui.hpp:248
void determineTableLayout()
This determines the layout, i.e.
Definition: race_result_gui.cpp:850
virtual void init() OVERRIDE
Besides calling init in the base class this makes all buttons of this screen invisible.
Definition: race_result_gui.cpp:92
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:1058
int displayChallengeInfo(int x, int y, bool increase_density)
Displays the result of the challenge and the status of the different goals associated with the challe...
Definition: race_result_gui.cpp:2163
std::vector< RowInfo > m_all_row_infos
The team icons.
Definition: race_result_gui.hpp:119
virtual void onConfirm() OVERRIDE
Implement to be notified of dialog confirmed.
Definition: race_result_gui.cpp:831
float m_time_between_rows
Time to wait till the next row starts to be animated.
Definition: race_result_gui.hpp:122
void drawTeamScorers(KartTeam team, int x, int y, int height)
Displays the goal scorers for a team.
Definition: race_result_gui.cpp:1614
unsigned int m_width_kart_name
Width of the kart name column.
Definition: race_result_gui.hpp:151
MusicInformation * m_race_over_music
Music to be played after race ended.
Definition: race_result_gui.hpp:188
enum RaceResultGUI::@18 m_animation_state
Finite state machine for the animations: INIT: Set up data structures.
int m_highscore_rank
For highscores.
Definition: race_result_gui.hpp:191
unsigned int m_width_column_space
Size of space between columns.
Definition: race_result_gui.hpp:167
SFXBase * m_finish_sound
The previous monospace state of the font.
Definition: race_result_gui.hpp:185
virtual void loadedFromFile() OVERRIDE
Implement callback from parent class GUIEngine::Screen.
Definition: race_result_gui.hpp:234
void determineGPLayout()
Determine the layout and fields for the GP table based on the previous GP results.
Definition: race_result_gui.cpp:1332
RaceResultGUI()
Constructor, initialises internal data structures.
Definition: race_result_gui.cpp:82
float m_time_single_scroll
The time a single line scrolls into place.
Definition: race_result_gui.hpp:125
unsigned int m_width_icon
The size of the kart icons.
Definition: race_result_gui.hpp:148
float m_extra_scroll_time
The small waiting time for the above.
Definition: race_result_gui.hpp:139
float m_time_overall_scroll
The overall time the first phase (scrolling) is displayed.
Definition: race_result_gui.hpp:136
void setHighscore(int rank)
To call if the user got a new highscore.
Definition: race_result_gui.cpp:1695
unsigned int m_leftmost_column
Position of left end of table (so that the whole table is aligned.
Definition: race_result_gui.hpp:161
int displayHighscores(int x, int y, bool increase_density)
Displays the highscores, if applicable for this game mode.
Definition: race_result_gui.cpp:1922
virtual void onUpdate(float dt) OVERRIDE
Called once a frame.
Definition: race_result_gui.cpp:1085
virtual void tearDown() OVERRIDE
Callback invoked before leaving this menu.
Definition: race_result_gui.cpp:237
The base class for sound effects.
Definition: sfx_base.hpp:43
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