|
SuperTuxKart
|
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. | |
| void | setFavoriteTrackStatus (FavoriteStatus *status) |
| Adds a track to the special group of favorite tracks. More... | |
| void | clearFavoriteTrackStatus () |
| Clears the list of active favorite tracks, used e.g. More... | |
| 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... | |
| Track * | getTrack (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. | |
| 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. | |
| Track * | getTrack (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... | |
| 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. More... | |
Private Types | |
| enum | TrackGroupType { RACING_TRACK = 0 , BATTLE_ARENA , SOCCER_ARENA } |
| typedef std::vector< Track * > | Tracks |
| typedef std::map< std::string, std::vector< int > > | Group2Indices |
Private Member Functions | |
| void | updateAllGroups (const Track *track) |
| Updates the groups after a track was read in. More... | |
| void | updateGroups (TrackGroupType type, const Track *track) |
| void | removeTrackFromGroups (TrackGroupType type, const Track *track) |
| Remove the track from all groups it belongs to in a group type. More... | |
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 track indexes for each racing track group. | |
| Group2Indices | m_arena_groups |
| List of all arena indexes for each arena group. | |
| Group2Indices | m_soccer_arena_groups |
| List of all soccer arena indexes for each soccer arena group. | |
| 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. | |
| Group2Indices | m_track_groups_no_custom |
| Same as above but without user-defined groups. | |
| Group2Indices | m_arena_groups_no_custom |
| Group2Indices | m_soccer_arena_groups_no_custom |
| std::vector< bool > | m_track_avail |
| Flag if this track is available or not. More... | |
| FavoriteStatus * | m_current_favorite_status |
Static Private Attributes | |
| static std::vector< std::string > | m_track_search_path |
| All directories in which tracks are searched. | |
Simple class to load and manage track data, track names and such.
| TrackManager::TrackManager | ( | ) |
Constructor (currently empty).
The real work happens in loadTrackList.
|
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.
| dir | The directory to add. |
| void TrackManager::clearFavoriteTrackStatus | ( | ) |
Clears the list of active favorite tracks, used e.g.
when switching between player profiles.
| std::vector< std::string > TrackManager::getAllTrackIdentifiers | ( | ) |
Returns a list of all track identifiers.
Returns a list with all track identifiert.
|
inline |
Returns a list of all arenas in a given group.
| g | Name of the group. |
| int TrackManager::getNumberOfRaceTracks | ( | ) | const |
Returns the number of racing tracks.
Those are tracks that are not internal (like cut scenes), arenas, or soccer fields.
| Track * TrackManager::getTrack | ( | const std::string & | ident | ) | const |
Get TrackData by the track identifier.
| ident | Identifier = basename of the directory the track is in. |
|
inline |
Returns the track with a given index number.
| index | The index number of the track. |
|
inline |
Returns a list of all tracks in a given group.
| g | Name of the group. |
|
inline |
Checks if a certain track is available.
| n | Index of the track to check. |
| bool TrackManager::loadTrack | ( | const std::string & | dirname | ) |
Tries to load a track from a single directory.
Returns true if a track was successfully loaded.
| dirname | Name of the directory to load the track from. |
| void TrackManager::loadTrackList | ( | ) |
Load all .track files from all directories.
Loads all tracks from the track directory (data/track).
| 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.
| void TrackManager::removeTrack | ( | const std::string & | ident | ) |
Removes a track.
| ident | Identifier of the track (i.e. the name of the directory). |
|
private |
Remove the track from all groups it belongs to in a group type.
| type | The type of track groups (battle arena, soccer arena, racing track) |
| track | The track to be removed |
| void TrackManager::setFavoriteTrackStatus | ( | FavoriteStatus * | status | ) |
Adds a track to the special group of favorite tracks.
Adds a player's favorite track status to define the custom group.
We need to treat it specially, because the list of tracks in this group depends on the player-profile, not on the track data.
| 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.
| tracks | List of tracks to mark as unavilable. |
This is used by the network manager upon receiving the list of available tracks from a client.
| tracks | List of all track identifiere (available on a client). |
|
private |
Updates the groups after a track was read in.
| track | Pointer to the new track, whose groups are now analysed. |
|
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)