SuperTuxKart
Public Member Functions | Static Public Member Functions | Protected Types | Protected Attributes | Private Attributes | Static Private Attributes | List of all members
KartPropertiesManager Class Reference
Inheritance diagram for KartPropertiesManager:
Inheritance graph
[legend]

Public Member Functions

 KartPropertiesManager ()
 Constructor, only clears internal data structures. More...
 
 ~KartPropertiesManager ()
 Destructor. More...
 
const KartPropertiesgetKartById (int i) const
 
const KartPropertiesgetKart (const std::string &ident) const
 
const int getKartId (const std::string &ident) const
 Returns index of the kart properties with the given ident. More...
 
int getKartByGroup (const std::string &group, int i) const
 Returns the (global) index of the n-th kart of a given group. More...
 
void loadCharacteristics (const XMLNode *root)
 Loads the characteristics from the characteristics config file. More...
 
bool loadKart (const std::string &dir)
 Loads a single kart and (if not disabled) the corresponding 3d model. More...
 
void loadAllKarts (bool loading_icon=true)
 Loads all kart properties and models.
 
void unloadAllKarts ()
 Removes all karts from the KartPropertiesManager, so that they can be reloade. More...
 
void removeKart (const std::string &id)
 Remove a kart from the kart manager. More...
 
const std::vector< int > getKartsInGroup (const std::string &g)
 Returns a vector with the indices of all karts in the specified group. More...
 
bool kartAvailable (int kartid)
 Returns true if a kart is available to be selected. More...
 
std::vector< std::string > getAllAvailableKarts () const
 Returns a list of all available kart identifiers. More...
 
void setUnavailableKarts (std::vector< std::string >)
 Marks all karts except the ones listed in the string vector to be unavailable. More...
 
void selectKartName (const std::string &kart_name)
 Sets a kart to be selected by specifying the identifier (name) of the kart. More...
 
bool testAndSetKart (int kartid)
 
void getRandomKartList (int count, RemoteKartInfoList *existing_karts, std::vector< std::string > *ai_list)
 Returns a list of randomly selected karts. More...
 
void setHatMeshName (const std::string &hat_name)
 Sets the name of a mesh to use as a hat for all karts. More...
 
const AbstractCharacteristicgetBaseCharacteristic () const
 Get the characteristic that holds the base values. More...
 
const AbstractCharacteristicgetDifficultyCharacteristic (const std::string &type) const
 Get a characteristic that holds the values for a certain difficulty. More...
 
const AbstractCharacteristicgetKartTypeCharacteristic (const std::string &type, const std::string &name) const
 Get a characteristic that holds the values for a kart type. More...
 
const AbstractCharacteristicgetPlayerCharacteristic (const std::string &type) const
 Get a characteristic that holds the values for a player difficulty. More...
 
const std::vector< std::string > & getAllGroups () const
 Returns a list of all groups. More...
 
void clearAllSelectedKarts ()
 Clears all selected karts (used in networking only). More...
 
void removeLastSelectedKart ()
 Removed the last selected kart (used in networking only). More...
 
int getNumSelectedKarts () const
 Returns the number of selected karts (used in networking only). More...
 
void selectKart (int kartid)
 Sets a kartid to be selected (used in networking only). More...
 
const std::vector< std::string > * getAllKartDirs () const
 Returns all directories from which karts were loaded. More...
 
const unsigned int getNumberOfKarts () const
 Returns the number of karts. More...
 

Static Public Member Functions

static void removeKartSearchDirs ()
 
static void addKartSearchDir (const std::string &s)
 Adds a directory from which karts are loaded. More...
 

Protected Types

typedef PtrVector< KartPropertiesKartPropertiesVector
 

Protected Attributes

KartPropertiesVector m_karts_properties
 All available kart configurations.
 

Private Attributes

std::vector< std::string > m_all_kart_dirs
 All directories from which karts were loaded. More...
 
std::vector< std::string > m_all_groups
 List of all kart groups. More...
 
std::vector< std::string > m_kart_types
 List of all kart types. More...
 
std::map< std::string, std::vector< int > > m_groups_2_indices
 Mapping of group names to list of kart indices in each group. More...
 
std::vector< int > m_selected_karts
 Vector containing kart numbers that have been selected in multiplayer games. More...
 
std::vector< bool > m_kart_available
 Contains a flag for each kart indicating wether it is available on all clients or not. More...
 
std::unique_ptr< AbstractCharacteristicm_base_characteristic
 
std::map< std::string, std::unique_ptr< AbstractCharacteristic > > m_difficulty_characteristics
 
std::map< std::string, std::unique_ptr< AbstractCharacteristic > > m_kart_type_characteristics
 
std::map< std::string, std::unique_ptr< AbstractCharacteristic > > m_player_characteristics
 

Static Private Attributes

static std::vector< std::string > m_kart_search_path
 The list of all directories in which to search for karts. More...
 

Constructor & Destructor Documentation

◆ KartPropertiesManager()

KartPropertiesManager::KartPropertiesManager ( )

Constructor, only clears internal data structures.

◆ ~KartPropertiesManager()

KartPropertiesManager::~KartPropertiesManager ( )

Destructor.

Removes all allocated data.

Member Function Documentation

◆ addKartSearchDir()

void KartPropertiesManager::addKartSearchDir ( const std::string &  s)
static

Adds a directory from which karts are loaded.

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

Parameters
dirThe directory to add.

◆ clearAllSelectedKarts()

void KartPropertiesManager::clearAllSelectedKarts ( )
inline

Clears all selected karts (used in networking only).

◆ getAllAvailableKarts()

std::vector< std::string > KartPropertiesManager::getAllAvailableKarts ( ) const

Returns a list of all available kart identifiers.

◆ getAllGroups()

const std::vector<std::string>& KartPropertiesManager::getAllGroups ( ) const
inline

Returns a list of all groups.

◆ getAllKartDirs()

const std::vector<std::string>* KartPropertiesManager::getAllKartDirs ( ) const
inline

Returns all directories from which karts were loaded.

◆ getBaseCharacteristic()

const AbstractCharacteristic* KartPropertiesManager::getBaseCharacteristic ( ) const
inline

Get the characteristic that holds the base values.

◆ getDifficultyCharacteristic()

const AbstractCharacteristic * KartPropertiesManager::getDifficultyCharacteristic ( const std::string &  type) const

Get a characteristic that holds the values for a certain difficulty.

◆ getKartByGroup()

int KartPropertiesManager::getKartByGroup ( const std::string &  group,
int  n 
) const

Returns the (global) index of the n-th kart of a given group.

If there is no such kart, -1 is returned.

◆ getKartId()

const int KartPropertiesManager::getKartId ( const std::string &  ident) const

Returns index of the kart properties with the given ident.

Returns
Index of kart (between 0 and number of karts - 1).

◆ getKartsInGroup()

const std::vector< int > KartPropertiesManager::getKartsInGroup ( const std::string &  g)

Returns a vector with the indices of all karts in the specified group.

Parameters
gThe name of the group for which the kart indicies should be determined
Returns
A vector of indices with the karts in the given group.

◆ getKartTypeCharacteristic()

const AbstractCharacteristic * KartPropertiesManager::getKartTypeCharacteristic ( const std::string &  type,
const std::string &  name 
) const

Get a characteristic that holds the values for a kart type.

◆ getNumberOfKarts()

const unsigned int KartPropertiesManager::getNumberOfKarts ( ) const
inline

Returns the number of karts.

◆ getNumSelectedKarts()

int KartPropertiesManager::getNumSelectedKarts ( ) const
inline

Returns the number of selected karts (used in networking only).

◆ getPlayerCharacteristic()

const AbstractCharacteristic * KartPropertiesManager::getPlayerCharacteristic ( const std::string &  type) const

Get a characteristic that holds the values for a player difficulty.

◆ getRandomKartList()

void KartPropertiesManager::getRandomKartList ( int  count,
RemoteKartInfoList *  existing_karts,
std::vector< std::string > *  ai_list 
)

Returns a list of randomly selected karts.

This list firstly contains karts in the currently selected group, but which are not in the list of 'existing karts'. If not enough karts are available in the current group, karts from all other groups are used to fill up the list. This is used by the race manager to select the AI karts.

Parameters
countNumber of karts to select randomly.
existing_kartsList of karts that should not be used. This is the list of karts selected by the players.
ai_listList of AI karts already selected (eg through the command line). The random AIs will also be added to this list.

◆ kartAvailable()

bool KartPropertiesManager::kartAvailable ( int  kartid)

Returns true if a kart is available to be selected.

A kart is available to be selected if it is available on all clients (i.e. m_kart_available is true), not yet selected, and not locked.

◆ loadCharacteristics()

void KartPropertiesManager::loadCharacteristics ( const XMLNode root)

Loads the characteristics from the characteristics config file.

Parameters
rootThe xml node where the characteristics are stored.

◆ loadKart()

bool KartPropertiesManager::loadKart ( const std::string &  dir)

Loads a single kart and (if not disabled) the corresponding 3d model.

Parameters
filenameFull path to the kart config file.

◆ removeKart()

void KartPropertiesManager::removeKart ( const std::string &  ident)

Remove a kart from the kart manager.

Parameters
idThe kart id (i.e. name of the directory) to remove.

◆ removeLastSelectedKart()

void KartPropertiesManager::removeLastSelectedKart ( )
inline

Removed the last selected kart (used in networking only).

◆ selectKart()

void KartPropertiesManager::selectKart ( int  kartid)
inline

Sets a kartid to be selected (used in networking only).

◆ selectKartName()

void KartPropertiesManager::selectKartName ( const std::string &  kart_name)

Sets a kart to be selected by specifying the identifier (name) of the kart.

Parameters
kart_nameName of the kart.

◆ setHatMeshName()

void KartPropertiesManager::setHatMeshName ( const std::string &  hat_name)

Sets the name of a mesh to use as a hat for all karts.

Parameters
hat_nameName of the hat mash.

◆ setUnavailableKarts()

void KartPropertiesManager::setUnavailableKarts ( std::vector< std::string >  karts)

Marks all karts except the ones listed in the string vector to be unavailable.

This function is used on a client when receiving the list of karts from a client to mark all other karts as unavailable.

Parameters
kartsList of karts that are available on a client.

◆ unloadAllKarts()

void KartPropertiesManager::unloadAllKarts ( )

Removes all karts from the KartPropertiesManager, so that they can be reloade.

This is necessary after a change of the screen resolution.

Member Data Documentation

◆ m_all_groups

std::vector<std::string> KartPropertiesManager::m_all_groups
private

List of all kart groups.

◆ m_all_kart_dirs

std::vector<std::string> KartPropertiesManager::m_all_kart_dirs
private

All directories from which karts were loaded.

Needed by unlock_manager to load all challenges.

◆ m_groups_2_indices

std::map<std::string, std::vector<int> > KartPropertiesManager::m_groups_2_indices
private

Mapping of group names to list of kart indices in each group.

◆ m_kart_available

std::vector<bool> KartPropertiesManager::m_kart_available
private

Contains a flag for each kart indicating wether it is available on all clients or not.

◆ m_kart_search_path

std::vector< std::string > KartPropertiesManager::m_kart_search_path
staticprivate

The list of all directories in which to search for karts.

◆ m_kart_types

std::vector<std::string> KartPropertiesManager::m_kart_types
private

List of all kart types.

◆ m_selected_karts

std::vector<int> KartPropertiesManager::m_selected_karts
private

Vector containing kart numbers that have been selected in multiplayer games.

This it used to ensure the same kart can not be selected more than once.


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