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

Simple class to load and manage track data, track names and such. More...

#include <track_manager.hpp>

Public Member Functions

 TrackManager ()
 Constructor (currently empty). More...
 
 ~TrackManager ()
 Delete all tracks.
 
std::vector< std::string > getAllTrackIdentifiers ()
 Returns a list of all track identifiers. More...
 
void loadTrackList ()
 Load all .track files from all directories. More...
 
void removeTrack (const std::string &ident)
 Removes a track. More...
 
bool loadTrack (const std::string &dirname)
 Tries to load a track from a single directory. More...
 
void removeAllCachedData ()
 Removes all cached data from all tracks. More...
 
int getNumberOfRaceTracks () const
 Returns the number of racing tracks. More...
 
TrackgetTrack (const std::string &ident) const
 Get TrackData by the track identifier. More...
 
void setUnavailableTracks (const std::vector< std::string > &tracks)
 Sets a list of track as being unavailable (e.g. More...
 
const std::vector< std::string > * getAllTrackDirs () const
 Returns a list of all directories that contain a track. More...
 
const std::vector< std::string > & getAllTrackGroups () const
 Returns a list of the names of all used track groups. More...
 
const std::vector< std::string > & getAllArenaGroups (bool soccer_arena=false) const
 Returns a list of the names of all used arena groups. More...
 
size_t getNumberOfTracks () const
 Returns the number of tracks. More...
 
TrackgetTrack (unsigned int index) const
 Returns the track with a given index number. More...
 
int getTrackIndexByIdent (const std::string &ident) const
 
bool isAvailable (unsigned int n) const
 Checks if a certain track is available. More...
 
const std::vector< int > & getTracksInGroup (const std::string &g)
 Returns a list of all tracks in a given group. More...
 
const std::vector< int > & getArenasInGroup (const std::string &g, bool soccer_arena=false)
 Returns a list of all arenas in a given group. More...
 

Static Public Member Functions

static void removeTrackSearchDirs ()
 
static void addTrackSearchDir (const std::string &dir)
 Adds a directory from which tracks are loaded. More...
 

Private Types

typedef std::vector< Track * > Tracks
 
typedef std::map< std::string, std::vector< int > > Group2Indices
 

Private Member Functions

void updateGroups (const Track *track)
 Updates the groups after a track was read in. More...
 

Private Attributes

std::vector< std::string > m_all_track_dirs
 All directories in which tracks were found. More...
 
Tracks m_tracks
 All track objects. More...
 
Group2Indices m_track_groups
 List of all racing track groups. More...
 
Group2Indices m_arena_groups
 List of all arena groups. More...
 
Group2Indices m_soccer_arena_groups
 List of all soccer arena groups. More...
 
std::vector< std::string > m_track_group_names
 List of the names of all groups containing tracks.
 
std::vector< std::string > m_arena_group_names
 List of the names of all groups containing arenas.
 
std::vector< std::string > m_soccer_arena_group_names
 List of the names of all groups containing soccer arenas.
 
std::vector< bool > m_track_avail
 Flag if this track is available or not. More...
 

Static Private Attributes

static std::vector< std::string > m_track_search_path
 All directories in which tracks are searched. More...
 

Detailed Description

Simple class to load and manage track data, track names and such.

Constructor & Destructor Documentation

◆ TrackManager()

TrackManager::TrackManager ( )

Constructor (currently empty).

The real work happens in loadTrackList.

Member Function Documentation

◆ addTrackSearchDir()

void TrackManager::addTrackSearchDir ( const std::string &  dir)
static

Adds a directory from which tracks are loaded.

The track manager checks if either this directory itself contains a track, and if any subdirectory contains a track.

Parameters
dirThe directory to add.

◆ getAllArenaGroups()

const std::vector<std::string>& TrackManager::getAllArenaGroups ( bool  soccer_arena = false) const
inline

Returns a list of the names of all used arena groups.

◆ getAllTrackDirs()

const std::vector<std::string>* TrackManager::getAllTrackDirs ( ) const
inline

Returns a list of all directories that contain a track.

◆ getAllTrackGroups()

const std::vector<std::string>& TrackManager::getAllTrackGroups ( ) const
inline

Returns a list of the names of all used track groups.

◆ getAllTrackIdentifiers()

std::vector< std::string > TrackManager::getAllTrackIdentifiers ( )

Returns a list of all track identifiers.

Returns a list with all track identifiert.

◆ getArenasInGroup()

const std::vector<int>& TrackManager::getArenasInGroup ( const std::string &  g,
bool  soccer_arena = false 
)
inline

Returns a list of all arenas in a given group.

Parameters
gName of the group.

◆ getNumberOfRaceTracks()

int TrackManager::getNumberOfRaceTracks ( ) const

Returns the number of racing tracks.

Those are tracks that are not internal (like cut scenes), arenas, or soccer fields.

◆ getNumberOfTracks()

size_t TrackManager::getNumberOfTracks ( ) const
inline

Returns the number of tracks.

◆ getTrack() [1/2]

Track * TrackManager::getTrack ( const std::string &  ident) const

Get TrackData by the track identifier.

Parameters
identIdentifier = basename of the directory the track is in.
Returns
The corresponding track object, or NULL if not found

◆ getTrack() [2/2]

Track* TrackManager::getTrack ( unsigned int  index) const
inline

Returns the track with a given index number.

Parameters
indexThe index number of the track.

◆ getTracksInGroup()

const std::vector<int>& TrackManager::getTracksInGroup ( const std::string &  g)
inline

Returns a list of all tracks in a given group.

Parameters
gName of the group.

◆ isAvailable()

bool TrackManager::isAvailable ( unsigned int  n) const
inline

Checks if a certain track is available.

Parameters
nIndex of the track to check.

◆ loadTrack()

bool TrackManager::loadTrack ( const std::string &  dirname)

Tries to load a track from a single directory.

Returns true if a track was successfully loaded.

Parameters
dirnameName of the directory to load the track from.

◆ loadTrackList()

void TrackManager::loadTrackList ( )

Load all .track files from all directories.

Loads all tracks from the track directory (data/track).

◆ removeAllCachedData()

void TrackManager::removeAllCachedData ( )

Removes all cached data from all tracks.

This is called when the screen resolution is changed and all textures need to be bound again.

◆ removeTrack()

void TrackManager::removeTrack ( const std::string &  ident)

Removes a track.

Parameters
identIdentifier of the track (i.e. the name of the directory).

◆ setUnavailableTracks()

void TrackManager::setUnavailableTracks ( const std::vector< std::string > &  tracks)

Sets a list of track as being unavailable (e.g.

Sets all tracks that are not in the list a to be unavailable.

in network mode the track is not on all connected machines.

Parameters
tracksList of tracks to mark as unavilable.

This is used by the network manager upon receiving the list of available tracks from a client.

Parameters
tracksList of all track identifiere (available on a client).

◆ updateGroups()

void TrackManager::updateGroups ( const Track track)
private

Updates the groups after a track was read in.

Parameters
trackPointer to the new track, whose groups are now analysed.

Member Data Documentation

◆ m_all_track_dirs

std::vector<std::string> TrackManager::m_all_track_dirs
private

All directories in which tracks were found.

◆ m_arena_groups

Group2Indices TrackManager::m_arena_groups
private

List of all arena groups.

◆ m_soccer_arena_groups

Group2Indices TrackManager::m_soccer_arena_groups
private

List of all soccer arena groups.

◆ m_track_avail

std::vector<bool> TrackManager::m_track_avail
private

Flag if this track is available or not.

Tracks are set unavailable if they are not available on all clients (applies only to network mode)

◆ m_track_groups

Group2Indices TrackManager::m_track_groups
private

List of all racing track groups.

◆ m_track_search_path

std::vector< std::string > TrackManager::m_track_search_path
staticprivate

All directories in which tracks are searched.

◆ m_tracks

Tracks TrackManager::m_tracks
private

All track objects.


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