SuperTuxKart
|
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 |
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
GrandPrixData::GrandPrixData | ( | const std::string & | filename, |
enum GPGroupType | group | ||
) |
Load the GrandPrixData from the given filename.
Loads a grand prix definition from a file.
filename | Name of the file to load. |
void GrandPrixData::changeReverse | ( | const GPReverseType | use_reverse | ) |
Updates the GP data with newly decided reverse requirements.
use_reverse | How reverse setting for each track is to be determined. |
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.
number_of_tracks | How many tracks should be in the random list. |
track_group | From which group to select the tracks. |
bool GrandPrixData::checkConsistency | ( | bool | log_error = true | ) | const |
Checks if the grand prix data are consistent.
log_error | If errors should be sent to the logger. |
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.
number_of_tracks | How many tracks to select. |
track_group | From which track group to select the tracks. |
use_reverse | How the reverse setting is to be determined. |
new_tracks | If 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). |
|
inline |
std::vector< int > GrandPrixData::getLaps | ( | const bool | includeLocked = false | ) | const |
Returns the laps for each available track of the grand prix.
include_locked | If data for locked tracks should be included or not. |
irr::core::stringw GrandPrixData::getName | ( | ) | const |
|
virtual |
Returns the number of tracks in this grand prix.
include_locked | If data for locked tracks should be included or not. |
std::vector< bool > GrandPrixData::getReverse | ( | const bool | includeLocked = false | ) | const |
Returns the reverse setting for each available grand prix.
include_locked | If data for locked tracks should be included or not. |
|
virtual |
Returns the list of tracks that is available (i.e.
unlocked) of this grand prix.
include_locked | If data for locked tracks should be included or not. |
|
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
id | Name of the track to test. |
include_locked | If set to true, all tracks (including locked tracks) are considered to be available. |
void GrandPrixData::reload | ( | ) |
Load the grand prix from the file set by the constructor or the grand prix editor.
Reloads grand prix from file.
void GrandPrixData::setEditable | ( | const bool | editable | ) |
Sets if this grand prix can be edited.
editable | New value. |
void GrandPrixData::setFilename | ( | const std::string & | filename | ) |
Sets the filename of this grand prix.
filename | New filename. |
void GrandPrixData::setGroup | ( | const enum GPGroupType | group | ) |
Sets the group of this grand prix.
editable | New value. |
void GrandPrixData::setId | ( | const std::string & | id | ) |
Sets the id of this grand prix.
id | The new id. |
void GrandPrixData::setName | ( | const irr::core::stringw & | name | ) |
Sets the name of the grand prix.
name | New name. |
|
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').