SuperTuxKart
Loading...
Searching...
No Matches
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.
 
 ~KartPropertiesManager ()
 Destructor.
 
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.
 
int getKartByGroup (const std::string &group, int i) const
 Returns the (global) index of the n-th kart of a given group.
 
void loadCharacteristics (const XMLNode *root)
 Loads the characteristics from the characteristics config file.
 
bool loadKart (const std::string &dir)
 Loads a single kart and (if not disabled) the corresponding 3d model.
 
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.
 
void removeKart (const std::string &id)
 Remove a kart from the kart manager.
 
const std::vector< int > getKartsInGroup (const std::string &g)
 Returns a vector with the indices of all karts in the specified group.
 
bool kartAvailable (int kartid)
 Returns true if a kart is available to be selected.
 
std::vector< std::string > getAllAvailableKarts () const
 Returns a list of all available kart identifiers.
 
void setUnavailableKarts (std::vector< std::string >)
 Marks all karts except the ones listed in the string vector to be unavailable.
 
void selectKartName (const std::string &kart_name)
 Sets a kart to be selected by specifying the identifier (name) of the kart.
 
bool testAndSetKart (int kartid)
 
void getRandomKartList (int count, RemoteKartInfoList *existing_karts, std::vector< std::string > *ai_list)
 Returns a list of randomly selected karts.
 
void setHatMeshName (const std::string &hat_name)
 Sets the name of a mesh to use as a hat for all karts.
 
const AbstractCharacteristicgetBaseCharacteristic () const
 Get the characteristic that holds the base values.
 
const AbstractCharacteristicgetDifficultyCharacteristic (const std::string &type) const
 Get a characteristic that holds the values for a certain difficulty.
 
const AbstractCharacteristicgetKartTypeCharacteristic (const std::string &type, const std::string &name) const
 Get a characteristic that holds the values for a kart type.
 
const std::string & getDefaultKartType () const
 
bool hasKartTypeCharacteristic (const std::string &type) const
 
const AbstractCharacteristicgetPlayerCharacteristic (const std::string &type) const
 Get a characteristic that holds the values for a player difficulty.
 
const std::vector< std::string > & getAllGroups () const
 Returns a list of all groups.
 
void clearAllSelectedKarts ()
 Clears all selected karts (used in networking only).
 
void removeLastSelectedKart ()
 Removed the last selected kart (used in networking only).
 
int getNumSelectedKarts () const
 Returns the number of selected karts (used in networking only).
 
void selectKart (int kartid)
 Sets a kartid to be selected (used in networking only).
 
const std::vector< std::string > * getAllKartDirs () const
 Returns all directories from which karts were loaded.
 
const unsigned int getNumberOfKarts () const
 Returns the number of karts.
 
void onDemandLoadKartTextures (const std::set< std::string > &kart_list, bool unload_unused=true)
 

Static Public Member Functions

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

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.
 
std::vector< std::string > m_all_groups
 List of all kart groups.
 
std::vector< std::string > m_kart_types
 List of all kart types.
 
std::map< std::string, std::vector< int > > m_groups_2_indices
 Mapping of group names to list of kart indices in each group.
 
std::vector< int > m_selected_karts
 Vector containing kart numbers that have been selected in multiplayer games.
 
std::vector< bool > m_kart_available
 Contains a flag for each kart indicating whether it is available on all clients or not.
 
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.
 

Constructor & Destructor Documentation

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

◆ getAllAvailableKarts()

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

Returns a list of all available kart identifiers.


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

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

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