SuperTuxKart
Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
RaceGUI Class Reference

Handles the in-race GUI (messages, mini-map, rankings, timer, etc...) More...

#include <race_gui.hpp>

Inheritance diagram for RaceGUI:
Inheritance graph
[legend]

Public Member Functions

 RaceGUI ()
 The constructor is called before anything is attached to the scene node. More...
 
virtual void init ()
 This is a second initialisation call (after the constructor) for the race gui. More...
 
virtual void reset ()
 Reset the gui before a race. More...
 
virtual void renderGlobal (float dt)
 Render all global parts of the race gui, i.e. More...
 
virtual void renderPlayerView (const Camera *camera, float dt)
 Render the details for a single player, i.e. More...
 
virtual const core::dimension2du getMiniMapSize () const
 Returns the size of the texture on which to render the minimap to. More...
 
virtual void calculateMinimapSize ()
 
- Public Member Functions inherited from RaceGUIBase
virtual ~RaceGUIBase ()
 The destructor removes the marker texture and the referee scene node.
 
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)
 Adds a message to the message queue. More...
 
virtual void update (float dt)
 Update, called once per frame. More...
 
virtual void preRenderCallback (const Camera *camera)
 This function is called just before rendering the view for each kart. More...
 
virtual void clearAllMessages ()
 
void drawGlobalPlayerIcons (int bottom_margin)
 Draw players icons and, depending on the current mode, their time or their score (battle lives, egg collected, etc.).
 
void drawPlayerIcon (AbstractKart *kart, int x, int y, int w, bool is_local)
 Draw one player icon Takes care of icon looking different due to plumber, squashing, ...
 
void cleanupMessages (const float dt)
 Removes messages which have been displayed long enough. More...
 
void removeReferee ()
 
RaceGUIMultitouchgetMultitouchGUI ()
 
void recreateMultitouchGUI ()
 

Private Types

enum  AnimationState { AS_NONE, AS_SMALLER, AS_BIGGER }
 Animation state: none, getting smaller (old value), getting bigger (new number). More...
 

Private Member Functions

void drawEnergyMeter (int x, int y, const AbstractKart *kart, const core::recti &viewport, const core::vector2df &scaling)
 Energy meter that gets filled with nitro. More...
 
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 speedometer). More...
 
void drawLap (const AbstractKart *kart, const core::recti &viewport, const core::vector2df &scaling)
 Displays the lap of the kart. More...
 
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. More...
 
void drawMeterTexture (video::ITexture *meter_texture, video::S3DVertex vertices[], unsigned int count)
 
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, etc.) The variable measured by the meter is compared to the thresholds, and is then used to compute a point between the two points associated with the lower and upper threshold Then, a polygon is calculated linking all the previous points and the variable point which link back to the first point. More...
 
void drawGlobalMiniMap ()
 Display items that are shown once only (for all karts). More...
 
void drawGlobalTimer ()
 Displays the racing time on the screen.
 
void drawLiveDifference ()
 Displays the live difference with a ghost on screen.
 

Private Attributes

Materialm_speed_meter_icon
 
Materialm_speed_bar_icon
 
int m_minimap_ai_size
 The size of a single marker on the screen for AI karts, need not be a power of 2. More...
 
int m_minimap_player_size
 The size of a single marker on the screen or player karts, need not be a power of 2. More...
 
int m_map_rendered_width
 The width of the rendered mini map in pixels, must be a power of 2. More...
 
int m_map_rendered_height
 The height of the rendered mini map in pixels, must be a power of 2. More...
 
int m_map_width
 Width of the map in pixels on the screen, need not be a power of 2. More...
 
int m_map_height
 Height of the map in pixels on the screen, need not be a power of 2. More...
 
int m_map_left
 Distance of map from left side of screen. More...
 
int m_map_bottom
 Distance of map from bottom of screen. More...
 
int m_lap_width
 Maximum lap display length (either 9/9 or 99/99). More...
 
int m_timer_width
 Maximum string length for the timer.
 
int m_small_precise_timer_width
 Maximum string length for a small precise timer (like the live difference timer under a minute)
 
int m_big_precise_timer_width
 Maximum string length for a big precise timer (like the live difference timer over a minute)
 
int m_negative_timer_additional_width
 
int m_font_height
 Height of the digit font. More...
 
irr::video::ITexture * m_red_team
 Icon textures (stored as variables to not look up their location on every frame)
 
irr::video::ITexture * m_blue_team
 
irr::video::ITexture * m_red_flag
 
irr::video::ITexture * m_blue_flag
 
irr::video::ITexture * m_soccer_ball
 
irr::video::ITexture * m_heart_icon
 
irr::video::ITexture * m_champion
 Texture for the hit limit icon.
 
std::vector< AnimationStatem_animation_states
 
std::vector< float > m_rank_animation_duration
 How long the rank animation has been shown. More...
 
std::vector< int > m_last_ranks
 Stores the previous rank for each kart. More...
 
bool m_is_tutorial
 

Additional Inherited Members

- Public Attributes inherited from RaceGUIBase
bool m_enabled
 
- Protected Types inherited from RaceGUIBase
enum  PlungerState { PLUNGER_STATE_INIT, PLUNGER_STATE_SLOW_1, PLUNGER_STATE_SLOW_2, PLUNGER_STATE_FAST }
 State of the plunger: From the 'init' states the plunger switches between two slow moving states ('shakily moving') till the end of the plunger time is nearly reached, then it goes to a very fast moving state ('plunger blown off'). More...
 
- Protected Member Functions inherited from RaceGUIBase
void createRegularPolygon (unsigned int n, float radius, const core::vector2df &center, const video::SColor &color, video::S3DVertex *v, unsigned short int *index)
 Creates the 2D vertices for a regular polygon. More...
 
void drawAllMessages (const AbstractKart *kart, const core::recti &viewport, const core::vector2df &scaling)
 Displays all messages in the message queue.
 
void drawPowerupIcons (const AbstractKart *kart, const core::recti &viewport, const core::vector2df &scaling)
 Draws the powerup icons on the screen (called once for each player). More...
 
void drawGlobalMusicDescription ()
 Displays the description given for the music currently being played. More...
 
void drawGlobalReadySetGo ()
 Draws the ready-set-go message on the screen.
 
void drawGlobalGoal ()
 
void drawPlungerInFace (const Camera *camera, float dt)
 Draws the plunger-in-face if necessary. More...
 
void ignoreUnimportantMessages ()
 Instructs the base gui to ignore unimportant messages (like item messages).
 
- Protected Attributes inherited from RaceGUIBase
enum RaceGUIBase::PlungerState m_plunger_state
 
float m_plunger_move_time
 How long the plunger should stay in the current state. More...
 
core::vector2di m_plunger_offset
 Offset of the plunger. More...
 
core::vector2df m_plunger_speed
 
video::ITexture * m_gauge_empty
 The size of a single marker in pixels, must be a power of 2. More...
 
video::ITexture * m_gauge_full
 Default texture for nitro gauge. More...
 
video::ITexture * m_gauge_full_bright
 Highlight gauge, used when a kart uses nitro. More...
 
video::ITexture * m_gauge_goal
 
video::ITexture * m_icons_frame
 The frame around player karts in the mini map. More...
 
video::ITexture * m_lap_flag
 Texture for the lap icon.
 
RaceGUIMultitouchm_multitouch_gui
 
float m_dist_show_overlap
 Distance on track to begin showing overlap in drawGlobalPlayerIcons.
 
float m_icons_inertia
 can be zero
 
std::vector< core::vector2d< s32 > > m_previous_icons_position
 can be zero More...
 
std::vector< KartIconDisplayInfom_kart_display_infos
 This vector is passed to world to be filled with the current race data information. More...
 

Detailed Description

Handles the in-race GUI (messages, mini-map, rankings, timer, etc...)

Member Enumeration Documentation

◆ AnimationState

Animation state: none, getting smaller (old value), getting bigger (new number).

Constructor & Destructor Documentation

◆ RaceGUI()

RaceGUI::RaceGUI ( )

The constructor is called before anything is attached to the scene node.

So rendering to a texture can be done here. But world is not yet fully created, so only the race manager can be accessed safely.

Member Function Documentation

◆ computeVerticesForMeter()

unsigned int RaceGUI::computeVerticesForMeter ( core::vector2df  position[],
float  threshold[],
video::S3DVertex  vertices[],
unsigned int  vertices_count,
float  measure,
int  gauge_width,
int  gauge_height,
core::vector2df  offset 
)
private

This function computes a polygon used for drawing the measure for a meter (speedometer, etc.) The variable measured by the meter is compared to the thresholds, and is then used to compute a point between the two points associated with the lower and upper threshold Then, a polygon is calculated linking all the previous points and the variable point which link back to the first point.

This polygon is used for drawing.

Consider the following example :

A                E
                -|
                x
                |
             -D-|
          -w-|
     |-C--|

-B–v-|

If the measure is inferior to the first threshold, the function will create a triangle ABv with the position of v varying proportionally on a line between B and C ; at B with 0 and at C when it reaches the first threshold. If the measure is between the first and second thresholds, the function will create a quad ABCw, with w varying in the same way than v. If the measure exceds the higher threshold, the function will return the poly ABCDE.

Parameters
positionThe relative positions of the vertices.
thresholdThe thresholds at which the variable point switch from a segment to the next. The size of this array should be smaller by two than the position array. The last threshold determines the measure over which the meter is full
verticesWhere the results of the computation are put, for use by the calling function.
vertices_countThe maximum number of vertices to use. Should be superior or equal to the size of the arrays.
measureThe value of the variable measured by the meter.
gauge_widthThe width of the meter
gauge_heightThe height of the meter
offsetThe offset to position the meter

◆ drawEnergyMeter()

void RaceGUI::drawEnergyMeter ( int  x,
int  y,
const AbstractKart kart,
const core::recti &  viewport,
const core::vector2df &  scaling 
)
privatevirtual

Energy meter that gets filled with nitro.

This function is called from drawSpeedEnergyRank, which defines the correct position of the energy meter.

Parameters
xX position of the meter.
yY position of the meter.
kartKart to display the data for.
scalingScaling applied (in case of split screen)

Reimplemented from RaceGUIBase.

◆ drawGlobalMiniMap()

void RaceGUI::drawGlobalMiniMap ( )
private

Display items that are shown once only (for all karts).

Draws the mini map and the position of all karts on it.

◆ drawLap()

void RaceGUI::drawLap ( const AbstractKart kart,
const core::recti &  viewport,
const core::vector2df &  scaling 
)
private

Displays the lap of the kart.

Parameters
infoInfo object c

◆ drawRank()

void RaceGUI::drawRank ( const AbstractKart kart,
const core::vector2df &  offset,
float  min_ratio,
int  meter_width,
int  meter_height,
float  dt 
)
private

Draws the rank of a player.

Parameters
kartThe kart of the player.
offsetOffset of top left corner for this display (for splitscreen).
min_ratioScaling of the screen (for splitscreen).
meter_widthWidth of the meter (inside which the rank is shown).
meter_heightHeight of the meter (inside which the rank is shown).
dtTime step size.

◆ drawSpeedEnergyRank()

void RaceGUI::drawSpeedEnergyRank ( const AbstractKart kart,
const core::recti &  viewport,
const core::vector2df &  scaling,
float  dt 
)
private

Draws the speedometer, the display of available nitro, and the rank of the kart (inside the speedometer).

Parameters
kartThe kart for which to show the data.
viewportThe viewport to use.
scalingWhich scaling to apply to the speedometer.
dtTime step size.

◆ getMiniMapSize()

virtual const core::dimension2du RaceGUI::getMiniMapSize ( ) const
inlinevirtual

Returns the size of the texture on which to render the minimap to.

Implements RaceGUIBase.

◆ init()

void RaceGUI::init ( )
virtual

This is a second initialisation call (after the constructor) for the race gui.

This is called after the world has been initialised, e.g. all karts do exist (while the constructor is called before the karts are created). In the base gui this is used to initialise the referee data (which needs the start positions of the karts). Note that this function is (and must be called only once, after its constructor).

Precondition
All karts must be created, since this object defines the positions for the referees based on the karts.

Reimplemented from RaceGUIBase.

◆ renderGlobal()

void RaceGUI::renderGlobal ( float  dt)
virtual

Render all global parts of the race gui, i.e.

things that are only displayed once even in splitscreen.

Parameters
dtTimestep sized.

Reimplemented from RaceGUIBase.

◆ renderPlayerView()

void RaceGUI::renderPlayerView ( const Camera camera,
float  dt 
)
virtual

Render the details for a single player, i.e.

speed, energy, collectibles, ...

Parameters
kartPointer to the kart for which to render the view.

Reimplemented from RaceGUIBase.

◆ reset()

void RaceGUI::reset ( )
virtual

Reset the gui before a race.

It initialised all rank animation related values back to the default.

Reimplemented from RaceGUIBase.

Member Data Documentation

◆ m_font_height

int RaceGUI::m_font_height
private

Height of the digit font.

◆ m_lap_width

int RaceGUI::m_lap_width
private

Maximum lap display length (either 9/9 or 99/99).

◆ m_last_ranks

std::vector<int> RaceGUI::m_last_ranks
private

Stores the previous rank for each kart.

Used for the rank animation.

◆ m_map_bottom

int RaceGUI::m_map_bottom
private

Distance of map from bottom of screen.

◆ m_map_height

int RaceGUI::m_map_height
private

Height of the map in pixels on the screen, need not be a power of 2.

◆ m_map_left

int RaceGUI::m_map_left
private

Distance of map from left side of screen.

◆ m_map_rendered_height

int RaceGUI::m_map_rendered_height
private

The height of the rendered mini map in pixels, must be a power of 2.

◆ m_map_rendered_width

int RaceGUI::m_map_rendered_width
private

The width of the rendered mini map in pixels, must be a power of 2.

◆ m_map_width

int RaceGUI::m_map_width
private

Width of the map in pixels on the screen, need not be a power of 2.

◆ m_minimap_ai_size

int RaceGUI::m_minimap_ai_size
private

The size of a single marker on the screen for AI karts, need not be a power of 2.

◆ m_minimap_player_size

int RaceGUI::m_minimap_player_size
private

The size of a single marker on the screen or player karts, need not be a power of 2.

◆ m_rank_animation_duration

std::vector<float> RaceGUI::m_rank_animation_duration
private

How long the rank animation has been shown.


The documentation for this class was generated from the following files: