Removed need to call drv_init when using --list-karts. This
1) avoids opening of the STK window 2) removes problem with drv_deinit not being called (resulting potentially in wrong screen resolutions when STK finishes) and is faster (based on a patch by Paul Elms). git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@1290 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
a8c2de27cb
commit
f16dcff123
@ -45,7 +45,8 @@ KartProperties::KartProperties() : m_icon_material(0), m_model(0)
|
|||||||
{} // KartProperties
|
{} // KartProperties
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void KartProperties::load(const std::string filename, const std::string node)
|
void KartProperties::load(const std::string filename, const std::string node,
|
||||||
|
bool dont_load_models)
|
||||||
{
|
{
|
||||||
|
|
||||||
init_defaults();
|
init_defaults();
|
||||||
@ -79,8 +80,8 @@ void KartProperties::load(const std::string filename, const std::string node)
|
|||||||
// Load material
|
// Load material
|
||||||
m_icon_material = material_manager->getMaterial(m_icon_file);
|
m_icon_material = material_manager->getMaterial(m_icon_file);
|
||||||
|
|
||||||
// Load model
|
// Load model, except when called as part of --list-karts
|
||||||
if(m_model_file.length()>0)
|
if(m_model_file.length()>0 && !dont_load_models)
|
||||||
{
|
{
|
||||||
m_model = loader->load(m_model_file, CB_KART, false);
|
m_model = loader->load(m_model_file, CB_KART, false);
|
||||||
ssgStripify(m_model);
|
ssgStripify(m_model);
|
||||||
|
@ -106,7 +106,8 @@ public:
|
|||||||
virtual void init_defaults ();
|
virtual void init_defaults ();
|
||||||
virtual void getAllData (const lisp::Lisp* lisp);
|
virtual void getAllData (const lisp::Lisp* lisp);
|
||||||
virtual void load (const std::string filename,
|
virtual void load (const std::string filename,
|
||||||
const std::string node="tuxkart-kart");
|
const std::string node="tuxkart-kart",
|
||||||
|
bool dont_load_models=false);
|
||||||
|
|
||||||
Material* getIconMaterial () const {return m_icon_material; }
|
Material* getIconMaterial () const {return m_icon_material; }
|
||||||
ssgEntity* getModel () const {return m_model; }
|
ssgEntity* getModel () const {return m_model; }
|
||||||
|
@ -55,13 +55,13 @@ void KartPropertiesManager::removeTextures()
|
|||||||
} // removeTextures
|
} // removeTextures
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void KartPropertiesManager::loadKartData()
|
void KartPropertiesManager::loadKartData(bool dont_load_models)
|
||||||
{
|
{
|
||||||
m_max_steer_angle = -1.0f;
|
m_max_steer_angle = -1.0f;
|
||||||
std::set<std::string> result;
|
std::set<std::string> result;
|
||||||
loader->listFiles(result, "data");
|
loader->listFiles(result, "data");
|
||||||
|
|
||||||
// Findout which characters are available and load them
|
// Find out which characters are available and load them
|
||||||
for(std::set<std::string>::iterator i = result.begin();
|
for(std::set<std::string>::iterator i = result.begin();
|
||||||
i != result.end(); ++i)
|
i != result.end(); ++i)
|
||||||
{
|
{
|
||||||
@ -69,7 +69,7 @@ void KartPropertiesManager::loadKartData()
|
|||||||
{
|
{
|
||||||
KartProperties* kp = new KartProperties();
|
KartProperties* kp = new KartProperties();
|
||||||
std::string tmp= std::string("data")+DIR_SEPARATOR + *i;
|
std::string tmp= std::string("data")+DIR_SEPARATOR + *i;
|
||||||
kp->load(tmp.c_str());
|
kp->load(tmp.c_str(), "tuxkart-kart", dont_load_models);
|
||||||
m_karts_properties.push_back(kp);
|
m_karts_properties.push_back(kp);
|
||||||
if(kp->getMaxSteerAngle() > m_max_steer_angle)
|
if(kp->getMaxSteerAngle() > m_max_steer_angle)
|
||||||
{
|
{
|
||||||
|
@ -40,7 +40,7 @@ public:
|
|||||||
const KartProperties* getKartById (int i);
|
const KartProperties* getKartById (int i);
|
||||||
const KartProperties* getKart (const std::string IDENT);
|
const KartProperties* getKart (const std::string IDENT);
|
||||||
const int getKartId (const std::string IDENT);
|
const int getKartId (const std::string IDENT);
|
||||||
void loadKartData ();
|
void loadKartData (bool dont_load_models=false);
|
||||||
const float getMaximumSteeringAngle() {return m_max_steer_angle;}
|
const float getMaximumSteeringAngle() {return m_max_steer_angle;}
|
||||||
const unsigned int getNumberOfKarts () {return m_karts_properties.size();}
|
const unsigned int getNumberOfKarts () {return m_karts_properties.size();}
|
||||||
|
|
||||||
|
@ -197,9 +197,8 @@ int handleCmdLine(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
else if( !strcmp(argv[i], "--list-karts") )
|
else if( !strcmp(argv[i], "--list-karts") )
|
||||||
{
|
{
|
||||||
// --list-karts seems to need a drv_init() ???
|
bool dont_load_models=true;
|
||||||
drv_init();
|
kart_properties_manager->loadKartData(dont_load_models) ;
|
||||||
kart_properties_manager->loadKartData () ;
|
|
||||||
|
|
||||||
fprintf ( stdout, _(" Available karts:\n") );
|
fprintf ( stdout, _(" Available karts:\n") );
|
||||||
for (unsigned int i = 0; NULL != kart_properties_manager->getKartById(i); i++)
|
for (unsigned int i = 0; NULL != kart_properties_manager->getKartById(i); i++)
|
||||||
|
Loading…
Reference in New Issue
Block a user