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

Static Public Member Functions

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

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.
 

Private Attributes

std::vector< std::string > m_all_track_dirs
 All directories in which tracks were found.
 
Tracks m_tracks
 All track objects.
 
Group2Indices m_track_groups
 List of all racing track groups.
 
Group2Indices m_arena_groups
 List of all arena groups.
 
Group2Indices m_soccer_arena_groups
 List of all soccer arena groups.
 
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.
 

Static Private Attributes

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

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.

◆ 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.

◆ 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_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)


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