SuperTuxKart
|
Public Member Functions | |
KartPropertiesManager () | |
Constructor, only clears internal data structures. | |
~KartPropertiesManager () | |
Destructor. | |
const KartProperties * | getKartById (int i) const |
const KartProperties * | getKart (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 AbstractCharacteristic * | getBaseCharacteristic () const |
Get the characteristic that holds the base values. | |
const AbstractCharacteristic * | getDifficultyCharacteristic (const std::string &type) const |
Get a characteristic that holds the values for a certain difficulty. | |
const AbstractCharacteristic * | getKartTypeCharacteristic (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 AbstractCharacteristic * | getPlayerCharacteristic (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< KartProperties > | KartPropertiesVector |
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< AbstractCharacteristic > | m_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. | |
KartPropertiesManager::~KartPropertiesManager | ( | ) |
Destructor.
Removes all allocated data.
|
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.
dir | The directory to add. |
std::vector< std::string > KartPropertiesManager::getAllAvailableKarts | ( | ) | const |
Returns a list of all available kart identifiers.
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.
const int KartPropertiesManager::getKartId | ( | const std::string & | ident | ) | const |
Returns index of the kart properties with the given ident.
const std::vector< int > KartPropertiesManager::getKartsInGroup | ( | const std::string & | g | ) |
Returns a vector with the indices of all karts in the specified group.
g | The name of the group for which the kart indicies should be determined |
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.
count | Number of karts to select randomly. |
existing_karts | List of karts that should not be used. This is the list of karts selected by the players. |
ai_list | List of AI karts already selected (eg through the command line). The random AIs will also be added to this list. |
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.
void KartPropertiesManager::loadCharacteristics | ( | const XMLNode * | root | ) |
Loads the characteristics from the characteristics config file.
root | The xml node where the characteristics are stored. |
bool KartPropertiesManager::loadKart | ( | const std::string & | dir | ) |
Loads a single kart and (if not disabled) the corresponding 3d model.
filename | Full path to the kart config file. |
void KartPropertiesManager::removeKart | ( | const std::string & | ident | ) |
Remove a kart from the kart manager.
id | The kart id (i.e. name of the directory) to remove. |
void KartPropertiesManager::selectKartName | ( | const std::string & | kart_name | ) |
Sets a kart to be selected by specifying the identifier (name) of the kart.
kart_name | Name of the kart. |
void KartPropertiesManager::setHatMeshName | ( | const std::string & | hat_name | ) |
Sets the name of a mesh to use as a hat for all karts.
hat_name | Name of the hat mash. |
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.
karts | List of karts that are available on a client. |
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.
|
private |
All directories from which karts were loaded.
Needed by unlock_manager to load all challenges.
|
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.