SuperTuxKart
Loading...
Searching...
No Matches
race_gui.hpp
1//
2// SuperTuxKart - a fun racing game with go-kart
3// Copyright (C) 2004-2015 Steve Baker <sjbaker1@airmail.net>
4// Copyright (C) 2006-2015 Joerg Henrichs, SuperTuxKart-Team, Steve Baker
5//
6// This program is free software; you can redistribute it and/or
7// modify it under the terms of the GNU General Public License
8// as published by the Free Software Foundation; either version 3
9// of the License, or (at your option) any later version.
10//
11// This program is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14// GNU General Public License for more details.
15//
16// You should have received a copy of the GNU General Public License
17// along with this program; if not, write to the Free Software
18// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19
20#ifndef HEADER_RACE_GUI_HPP
21#define HEADER_RACE_GUI_HPP
22
23#include <string>
24#include <vector>
25
26#include <irrString.h>
27using namespace irr;
28
29#include "states_screens/race_gui_base.hpp"
30
31class AbstractKart;
32class InputMap;
33class Material;
34class RaceSetup;
35
40class RaceGUI : public RaceGUIBase
41{
42private:
43
44 // Minimap related variables
45 // -------------------------
49
53
56
59
62
65
68
71
74
77
81
85
86 int m_negative_timer_additional_width;
87
90
93 irr::video::ITexture *m_red_team;
94 irr::video::ITexture *m_blue_team;
95 irr::video::ITexture *m_red_flag;
96 irr::video::ITexture *m_blue_flag;
97 irr::video::ITexture *m_soccer_ball;
98 irr::video::ITexture *m_heart_icon;
99 irr::video::ITexture *m_basket_ball_icon;
101 irr::video::ITexture* m_champion;
102
104 irr::video::ITexture *m_speed_meter_icon;
105 irr::video::ITexture *m_speed_bar_icon;
106
109 enum AnimationState {AS_NONE, AS_SMALLER, AS_BIGGER};
110 std::vector<AnimationState> m_animation_states;
111
113 std::vector<float> m_rank_animation_duration;
114
116 std::vector<int> m_last_ranks;
117
118 bool m_is_tutorial;
119
120 /* Display informat for one player on the screen. */
121 void drawEnergyMeter (int x, int y, const AbstractKart *kart,
122 const core::recti &viewport,
123 const core::vector2df &scaling);
124 void drawSpeedEnergyRank (const AbstractKart* kart,
125 const core::recti &viewport,
126 const core::vector2df &scaling, float dt);
127 void drawLap (const AbstractKart* kart,
128 const core::recti &viewport,
129 const core::vector2df &scaling);
130 void drawRank (const AbstractKart *kart,
131 const core::vector2df &offset,
132 float min_ratio, int meter_width,
133 int meter_height, float dt);
134
135 /* Helper functions for drawing meters */
136
137 void drawMeterTexture(video::ITexture *meter_texture, video::S3DVertex vertices[], unsigned int count, bool reverse = false);
138
139 unsigned int computeVerticesForMeter(core::vector2df position[], float threshold[], video::S3DVertex vertices[],
140 unsigned int vertices_count, float measure, int gauge_width,
141 int gauge_height, core::vector2df offset);
142
144 void drawGlobalMiniMap ();
145 void drawGlobalTimer ();
146 void drawLiveDifference ();
147
148public:
149
150 RaceGUI();
151 ~RaceGUI();
152 virtual void init();
153 virtual void reset();
154 virtual void renderGlobal(float dt);
155 virtual void renderPlayerView(const Camera *camera, float dt);
156
158 virtual const core::dimension2du getMiniMapSize() const
159 { return core::dimension2du(m_map_width, m_map_height); }
160 virtual void initSize();
161 virtual void calculateMinimapSize();
162}; // RaceGUI
163
164#endif
An abstract interface for the actual karts.
Definition: abstract_kart.hpp:62
This is the base class for all cameras.
Definition: camera.hpp:49
Definition: material.hpp:48
An abstract base class for the two race guis (race_gui and race_result gui)
Definition: race_gui_base.hpp:50
Handles the in-race GUI (messages, mini-map, rankings, timer, etc...)
Definition: race_gui.hpp:41
int m_font_height
Height of the digit font.
Definition: race_gui.hpp:89
int m_big_precise_timer_width
Maximum string length for a big precise timer (like the live difference timer over a minute)
Definition: race_gui.hpp:84
virtual const core::dimension2du getMiniMapSize() const
Returns the size of the texture on which to render the minimap to.
Definition: race_gui.hpp:158
void drawGlobalTimer()
Displays the racing time on the screen.
Definition: race_gui.cpp:414
irr::video::ITexture * m_red_team
Icon textures (stored as variables to not look up their location on every frame)
Definition: race_gui.hpp:93
std::vector< int > m_last_ranks
Stores the previous rank for each kart.
Definition: race_gui.hpp:116
virtual void reset()
Reset the gui before a race.
Definition: race_gui.cpp:164
int m_lap_width
Maximum lap display length (either 9/9 or 99/99).
Definition: race_gui.hpp:73
int m_map_bottom
Distance of map from bottom of screen.
Definition: race_gui.hpp:70
int m_map_rendered_width
The width of the rendered mini map in pixels, must be a power of 2.
Definition: race_gui.hpp:55
virtual void renderPlayerView(const Camera *camera, float dt)
Render the details for a single player, i.e.
Definition: race_gui.cpp:364
virtual void initSize()
Called when loading the race gui or screen resized.
Definition: race_gui.cpp:113
void drawLap(const AbstractKart *kart, const core::recti &viewport, const core::vector2df &scaling)
Displays the lap of the kart.
Definition: race_gui.cpp:1239
void drawLiveDifference()
Displays the live difference with a ghost on screen.
Definition: race_gui.cpp:484
virtual void init()
This is a second initialisation call (after the constructor) for the race gui.
Definition: race_gui.cpp:148
irr::video::ITexture * m_champion
Texture for the hit limit icon.
Definition: race_gui.hpp:101
virtual void renderGlobal(float dt)
Render all global parts of the race gui, i.e.
Definition: race_gui.cpp:277
void drawRank(const AbstractKart *kart, const core::vector2df &offset, float min_ratio, int meter_width, int meter_height, float dt)
Draws the rank of a player.
Definition: race_gui.cpp:897
void drawSpeedEnergyRank(const AbstractKart *kart, const core::recti &viewport, const core::vector2df &scaling, float dt)
Draws the speedometer, the display of available nitro, and the rank of the kart (inside the speedomet...
Definition: race_gui.cpp:984
void drawEnergyMeter(int x, int y, const AbstractKart *kart, const core::recti &viewport, const core::vector2df &scaling)
Energy meter that gets filled with nitro.
Definition: race_gui.cpp:778
unsigned int computeVerticesForMeter(core::vector2df position[], float threshold[], video::S3DVertex vertices[], unsigned int vertices_count, float measure, int gauge_width, int gauge_height, core::vector2df offset)
This function computes a polygon used for drawing the measure for a meter (speedometer,...
Definition: race_gui.cpp:1179
irr::video::ITexture * m_speed_meter_icon
Texture for speedometer.
Definition: race_gui.hpp:104
int m_map_rendered_height
The height of the rendered mini map in pixels, must be a power of 2.
Definition: race_gui.hpp:58
AnimationState
Animation state: none, getting smaller (old value), getting bigger (new number).
Definition: race_gui.hpp:109
int m_map_width
Width of the map in pixels on the screen, need not be a power of 2.
Definition: race_gui.hpp:61
int m_minimap_player_size
The size of a single marker on the screen or player karts, need not be a power of 2.
Definition: race_gui.hpp:52
int m_small_precise_timer_width
Maximum string length for a small precise timer (like the live difference timer under a minute)
Definition: race_gui.hpp:80
int m_minimap_ai_size
The size of a single marker on the screen for AI karts, need not be a power of 2.
Definition: race_gui.hpp:48
std::vector< float > m_rank_animation_duration
How long the rank animation has been shown.
Definition: race_gui.hpp:113
int m_map_height
Height of the map in pixels on the screen, need not be a power of 2.
Definition: race_gui.hpp:64
RaceGUI()
The constructor is called before anything is attached to the scene node.
Definition: race_gui.cpp:73
void drawGlobalMiniMap()
Display items that are shown once only (for all karts).
Definition: race_gui.cpp:547
int m_map_left
Distance of map from left side of screen.
Definition: race_gui.hpp:67
int m_timer_width
Maximum string length for the timer.
Definition: race_gui.hpp:76