SuperTuxKart
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
GrandPrixData Class Reference

Simple class that hold the data relevant to a 'grand_prix', aka. More...

#include <grand_prix_data.hpp>

Public Types

enum  GPGroupType {
  GP_NONE = 0 , GP_STANDARD , GP_USER_DEFINED , GP_ADDONS ,
  GP_GROUP_COUNT
}
 Used to classify GPs into groups. More...
 
enum  GPReverseType { GP_NO_REVERSE = 0 , GP_ALL_REVERSE = 1 , GP_RANDOM_REVERSE = 2 , GP_DEFAULT_REVERSE = 3 }
 Used to define the reverse setting when creating a random GP: No reverse, all reverse (if available on the track), random selection.
 

Public Member Functions

 GrandPrixData (const std::string &filename, enum GPGroupType group)
 Load the GrandPrixData from the given filename.
 
 GrandPrixData ()
 Needed for simple creation of an instance of GrandPrixData.
 
virtual std::vector< std::string > getTrackNames (const bool includeLocked=false) const
 Returns the list of tracks that is available (i.e.
 
virtual unsigned int getNumberOfTracks (const bool includeLocked=false) const
 Returns the number of tracks in this grand prix.
 
void changeTrackNumber (const unsigned int number_of_tracks, const std::string &track_group)
 Either adds or removes tracks to get the requested numder of tracks in a random GP.
 
void changeReverse (const GPReverseType use_reverse)
 Updates the GP data with newly decided reverse requirements.
 
void createRandomGP (const unsigned int number_of_tracks, const std::string &track_group, const GPReverseType use_reverse, bool new_tracks=false)
 Creates a random grand prix from the specified parameters.
 
void setId (const std::string &id)
 Sets the id of this grand prix.
 
void setName (const irr::core::stringw &name)
 Sets the name of the grand prix.
 
void setFilename (const std::string &filename)
 Sets the filename of this grand prix.
 
void setEditable (const bool editable)
 Sets if this grand prix can be edited.
 
void setGroup (const enum GPGroupType group)
 Sets the group of this grand prix.
 
void reload ()
 Load the grand prix from the file set by the constructor or the grand prix editor.
 
bool writeToFile ()
 Saves the grand prix data to a file.
 
bool checkConsistency (bool log_error=true) const
 Checks if the grand prix data are consistent.
 
std::vector< int > getLaps (const bool includeLocked=false) const
 Returns the laps for each available track of the grand prix.
 
std::vector< bool > getReverse (const bool includeLocked=false) const
 Returns the reverse setting for each available grand prix.
 
bool isEditable () const
 Returns true if this grand prix can be edited.
 
const std::string & getTrackId (const unsigned int track) const
 
irr::core::stringw getTrackName (const unsigned int track) const
 Returns the (translated) name of the track with the specified index.
 
bool containsUnavailableTracks () const
 
unsigned int getLaps (const unsigned int track) const
 
bool getReverse (const unsigned int track) const
 
void moveUp (const unsigned int track)
 
void moveDown (const unsigned int track)
 
void addTrack (Track *track, unsigned int laps, bool reverse, int position=-1)
 
void editTrack (unsigned int index, Track *track, unsigned int laps, bool reverse)
 
void remove (const unsigned int track)
 
irr::core::stringw getName () const
 
const std::string & getId () const
 
bool isRandomGP () const
 Returns true if this GP is a random GP.
 
const std::string & getFilename () const
 Returns the filename of the grand prix xml file.
 
enum GPGroupType getGroup () const
 
enum GPReverseType getReverseType () const
 

Static Public Member Functions

static const char * getRandomGPID ()
 
static irr::core::stringw getRandomGPName ()
 
static irr::core::stringw reverseTypeToString (GPReverseType reverse_type)
 

Protected Attributes

std::vector< std::string > m_tracks
 The ident of the tracks in this grand prix in their right order, ident means the filename of the .track file without .track extension (ie.
 

Private Member Functions

bool isTrackAvailable (const std::string &id, bool includeLocked) const
 In the last GP Fort Magma can not be used untill the final challenge.
 

Private Attributes

irr::core::stringw m_name
 The name of the grand prix.
 
std::string m_id
 Internal name of the grand prix, not translated.
 
std::string m_filename
 Original filename, only for error handling needed.
 
std::vector< int > m_laps
 The number of laps that each track will be raced, in the right order.
 
std::vector< bool > m_reversed
 Whether the track in question should be done in reverse mode.
 
bool m_editable
 Wether the user can edit this grand prix or not.
 
enum GPGroupType m_group
 Group to which this GP belongs.
 
GPReverseType m_reverse_type
 

Detailed Description

Simple class that hold the data relevant to a 'grand_prix', aka.

a number of races that has to be completed one after the other

Member Enumeration Documentation

◆ GPGroupType

Used to classify GPs into groups.

Enumerator
GP_NONE 

No group.

GP_STANDARD 

Standard GP, included with the game.

GP_USER_DEFINED 

Created by the user.

GP_ADDONS 

Add-on GP.

GP_GROUP_COUNT 

Number of groups.

Constructor & Destructor Documentation

◆ GrandPrixData()

GrandPrixData::GrandPrixData ( const std::string &  filename,
enum GPGroupType  group 
)

Load the GrandPrixData from the given filename.

Loads a grand prix definition from a file.

Parameters
filenameName of the file to load.

Member Function Documentation

◆ changeReverse()

void GrandPrixData::changeReverse ( const GPReverseType  use_reverse)

Updates the GP data with newly decided reverse requirements.

Parameters
use_reverseHow reverse setting for each track is to be determined.

◆ changeTrackNumber()

void GrandPrixData::changeTrackNumber ( const unsigned int  number_of_tracks,
const std::string &  track_group 
)

Either adds or removes tracks to get the requested numder of tracks in a random GP.

Parameters
number_of_tracksHow many tracks should be in the random list.
track_groupFrom which group to select the tracks.

◆ checkConsistency()

bool GrandPrixData::checkConsistency ( bool  log_error = true) const

Checks if the grand prix data are consistent.

Parameters
log_errorIf errors should be sent to the logger.

◆ createRandomGP()

void GrandPrixData::createRandomGP ( const unsigned int  number_of_tracks,
const std::string &  track_group,
const GPReverseType  use_reverse,
bool  new_tracks = false 
)

Creates a random grand prix from the specified parameters.

Parameters
number_of_tracksHow many tracks to select.
track_groupFrom which track group to select the tracks.
use_reverseHow the reverse setting is to be determined.
new_tracksIf true, new tracks are selected, otherwise existing tracks will not be changed (used to e.g. increase the number of tracks in an already existing random grand prix).

◆ getId()

const std::string & GrandPrixData::getId ( ) const
inline
Returns
the internal indentifier of the Grand Prix (not translated)

◆ getLaps()

std::vector< int > GrandPrixData::getLaps ( const bool  includeLocked = false) const

Returns the laps for each available track of the grand prix.

Parameters
include_lockedIf data for locked tracks should be included or not.
Returns
a std::vector containing the laps for each grand prix.

◆ getName()

irr::core::stringw GrandPrixData::getName ( ) const
Returns
the (potentially translated) user-visible name of the Grand Prix, m_editable is true if it's custom GP name.

◆ getNumberOfTracks()

unsigned int GrandPrixData::getNumberOfTracks ( const bool  includeLocked = false) const
virtual

Returns the number of tracks in this grand prix.

Parameters
include_lockedIf data for locked tracks should be included or not.

◆ getReverse()

std::vector< bool > GrandPrixData::getReverse ( const bool  includeLocked = false) const

Returns the reverse setting for each available grand prix.

Parameters
include_lockedIf data for locked tracks should be included or not.
Returns
A copy of alist with the reverse status for each track.

◆ getTrackNames()

std::vector< std::string > GrandPrixData::getTrackNames ( const bool  includeLocked = false) const
virtual

Returns the list of tracks that is available (i.e.

unlocked) of this grand prix.

Parameters
include_lockedIf data for locked tracks should be included or not.
Returns
A copy of the list of available tracks in this grand prix.

◆ isTrackAvailable()

bool GrandPrixData::isTrackAvailable ( const std::string &  id,
bool  include_locked 
) const
private

In the last GP Fort Magma can not be used untill the final challenge.

Returns true if the track is available.

In order to provide still 5 tracks/GP, the last GP is only using 4 tracks in story mode, but once nolok is unlocked Fort Magma becomes available (i.e. if nolok is unlocked, Fort Magma is available, otherwise not).

This is used to test if Fort Magma is available (this way FortMagma is not used in the last Grand Prix in story mode, but will be available once all challenges are done and nolok is unlocked). It also prevents people from using the grand prix editor as a way to play tracks that still haven't been unlocked

Parameters
idName of the track to test.
include_lockedIf set to true, all tracks (including locked tracks) are considered to be available.

◆ reload()

void GrandPrixData::reload ( )

Load the grand prix from the file set by the constructor or the grand prix editor.

Reloads grand prix from file.

◆ setEditable()

void GrandPrixData::setEditable ( const bool  editable)

Sets if this grand prix can be edited.

Parameters
editableNew value.

◆ setFilename()

void GrandPrixData::setFilename ( const std::string &  filename)

Sets the filename of this grand prix.

Parameters
filenameNew filename.

◆ setGroup()

void GrandPrixData::setGroup ( const enum GPGroupType  group)

Sets the group of this grand prix.

Parameters
editableNew value.

◆ setId()

void GrandPrixData::setId ( const std::string &  id)

Sets the id of this grand prix.

Parameters
idThe new id.

◆ setName()

void GrandPrixData::setName ( const irr::core::stringw &  name)

Sets the name of the grand prix.

Parameters
nameNew name.

Member Data Documentation

◆ m_tracks

std::vector<std::string> GrandPrixData::m_tracks
protected

The ident of the tracks in this grand prix in their right order, ident means the filename of the .track file without .track extension (ie.

'volcano').


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