1) Added GrandPrix manager (so that a GP id instead of a potentially translated
GP name can be used). 2) Added support for challenges to be specified in .challenge files, converted all existing challenges to be specified in this kind of data file. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@2188 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
24f77c67dd
commit
88c0b07f69
8
data/grandprix/Makefile.am
Normal file
8
data/grandprix/Makefile.am
Normal file
@ -0,0 +1,8 @@
|
||||
# data/music
|
||||
|
||||
pkgdatadir = $(datadir)/games/@PACKAGE@/data/grandprix
|
||||
|
||||
pkgdata_DATA = $(shell find $(srcdir) -name "*.grandprix") \
|
||||
$(shell find $(srcdir) -name "*.challenge")
|
||||
|
||||
EXTRA_DIST = $(pkgdata_DATA)
|
19
data/grandprix/alltracks.challenge
Normal file
19
data/grandprix/alltracks.challenge
Normal file
@ -0,0 +1,19 @@
|
||||
;; -*- mode: lisp -*-
|
||||
|
||||
(challenge
|
||||
(id "worldsend")
|
||||
(name _("Win the At World's End\nGrand Prix"))
|
||||
(description _("Come first in the At World's End\nGrand Prix with 3 'Racer'\nLevel AI karts."))
|
||||
(unlock-gp "alltracks")
|
||||
(unlock-difficulty "skidding" _("Skidding Preview"))
|
||||
(depend-on "islandfollow" "racetracktime" "tollwaytime" "junglefollow" "citytime" "tollwayhead")
|
||||
(major "grandprix")
|
||||
(minor "quickrace")
|
||||
(gp "atworldsend")
|
||||
(difficulty "hard")
|
||||
(karts 4)
|
||||
(position 1)
|
||||
)
|
||||
|
||||
;; EOF ;;
|
||||
|
19
data/grandprix/atworldsend.challenge
Normal file
19
data/grandprix/atworldsend.challenge
Normal file
@ -0,0 +1,19 @@
|
||||
;; -*- mode: lisp -*-
|
||||
|
||||
(challenge
|
||||
(id "islandfollow")
|
||||
(name _("Follow the Leader on a\nDesert Island"))
|
||||
(description _("Win a Follow the Leader race\nwith 3 AI karts\non a Desert Island."))
|
||||
(unlock-gp "atworldsend")
|
||||
(depend-on "tothemoonandbackgp" "tollwaytime" "citytime")
|
||||
(major "single")
|
||||
(minor "followtheleader")
|
||||
(track "islandtrack")
|
||||
(difficulty "easy")
|
||||
(laps 3)
|
||||
(karts 4)
|
||||
(position 1)
|
||||
)
|
||||
|
||||
;; EOF ;;
|
||||
|
18
data/grandprix/snagdrive.challenge
Normal file
18
data/grandprix/snagdrive.challenge
Normal file
@ -0,0 +1,18 @@
|
||||
;; -*- mode: lisp -*-
|
||||
|
||||
(challenge
|
||||
(id "tothemoonandbackgp")
|
||||
(name _("Win To the Moon and Back\nGrand Prix"))
|
||||
(description _("Win the To the Moon and Back\nGrand Prix with 3 'Racer'\nLevel AI karts."))
|
||||
(unlock-gp "snagdrive")
|
||||
(depend-on "energyshiftingsands" "junglefollow")
|
||||
(major "grandprix")
|
||||
(minor "quickrace")
|
||||
(gp "tothemoonandback")
|
||||
(difficulty "hard")
|
||||
(karts 4)
|
||||
(position 1)
|
||||
)
|
||||
|
||||
;; EOF ;;
|
||||
|
20
data/grandprix/tothemoonandback.challenge
Normal file
20
data/grandprix/tothemoonandback.challenge
Normal file
@ -0,0 +1,20 @@
|
||||
;; -*- mode: lisp -*-
|
||||
|
||||
(challenge
|
||||
(id "energyshiftingsands")
|
||||
(name _("Collect the Pharaohs Treasure"))
|
||||
(description _("Collect at least 9 coins\non 3 laps of Shifting Sands\nin under 2:20 minutes."))
|
||||
(unlock-gp "tothemoonandback")
|
||||
(depend-on "energymathclass" "racetracktime")
|
||||
(major "single")
|
||||
(minor "quickrace")
|
||||
(track "sandtrack")
|
||||
(difficulty "easy")
|
||||
(karts 1)
|
||||
(laps 3)
|
||||
(energy 9)
|
||||
(time 140)
|
||||
)
|
||||
|
||||
;; EOF ;;
|
||||
|
@ -31,6 +31,7 @@ supertuxkart_SOURCES = main.cpp \
|
||||
actionmap.cpp actionmap.hpp \
|
||||
material.cpp material.hpp \
|
||||
material_manager.cpp material_manager.hpp \
|
||||
grand_prix_manager.cpp grand_prix_manager.hpp \
|
||||
attachment.cpp attachment.hpp \
|
||||
attachment_manager.cpp attachment_manager.hpp \
|
||||
collectable.cpp collectable.hpp \
|
||||
@ -93,17 +94,7 @@ supertuxkart_SOURCES = main.cpp \
|
||||
translation.cpp translation.hpp \
|
||||
player.hpp \
|
||||
challenges/challenge.hpp challenges/challenge.cpp \
|
||||
challenges/energy_math_class.cpp challenges/energy_math_class.hpp\
|
||||
challenges/penguin_playground_gp.cpp challenges/penguin_playground_gp.hpp \
|
||||
challenges/race_track_time.cpp challenges/race_track_time.hpp\
|
||||
challenges/tollway_time.cpp challenges/tollway_time.hpp \
|
||||
challenges/jungle_follow.cpp challenges/jungle_follow.hpp \
|
||||
challenges/energy_shifting_sands.cpp challenges/energy_shifting_sands.hpp \
|
||||
challenges/moon_and_back_gp.cpp challenges/moon_and_back_gp.hpp \
|
||||
challenges/city_time.cpp challenges/city_time.hpp \
|
||||
challenges/island_follow.cpp challenges/island_follow.hpp \
|
||||
challenges/worlds_end_gp.cpp challenges/worlds_end_gp.hpp \
|
||||
challenges/tollway_head2head.cpp challenges/tollway_head2head.hpp \
|
||||
challenges/challenge_data.hpp challenges/challenge_data.cpp \
|
||||
lisp/lisp.cpp lisp/lisp.hpp \
|
||||
lisp/lexer.cpp lisp/lexer.hpp \
|
||||
lisp/parser.cpp lisp/parser.hpp \
|
||||
|
@ -24,10 +24,13 @@
|
||||
#include "lisp/parser.hpp"
|
||||
#include "lisp/lisp.hpp"
|
||||
#include "cup_data.hpp"
|
||||
#include "string_utils.hpp"
|
||||
#include "track_manager.hpp"
|
||||
|
||||
CupData::CupData(const std::string filename_)
|
||||
CupData::CupData(const std::string filename)
|
||||
{
|
||||
m_filename = filename_;
|
||||
m_filename = filename;
|
||||
m_id = StringUtils::without_extension(filename);
|
||||
const lisp::Lisp* lisp = 0;
|
||||
try
|
||||
{
|
||||
@ -48,12 +51,26 @@ CupData::CupData(const std::string filename_)
|
||||
}
|
||||
catch(std::exception& err)
|
||||
{
|
||||
fprintf(stderr, "Error while reading cup file '%s'\n", filename_.c_str());
|
||||
fprintf(stderr, "Error while reading cup file '%s'\n", filename.c_str());
|
||||
fprintf(stderr, err.what());
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
|
||||
delete lisp;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
bool CupData::checkConsistency()
|
||||
{
|
||||
bool correct=true;
|
||||
for(unsigned int i=0; i<m_tracks.size(); i++)
|
||||
{
|
||||
if(!track_manager->getTrack(m_tracks[i]))
|
||||
{
|
||||
fprintf(stderr, "Grand Prix '%s': Track '%s' does not exist!",
|
||||
m_name.c_str(), m_tracks[i]);
|
||||
correct=false;
|
||||
}
|
||||
} // for i
|
||||
return correct;
|
||||
}
|
||||
/* EOF */
|
||||
|
@ -31,7 +31,8 @@
|
||||
of races that has to be completed one after the other */
|
||||
class CupData
|
||||
{
|
||||
std::string m_name; // The name of the cup
|
||||
std::string m_name; // The name of the cup - might be translated!
|
||||
std::string m_id; // Internal name of the cup, not translated
|
||||
std::string m_filename; // Original filename, only for error handling needed
|
||||
std::string m_description; // Description for this track
|
||||
std::string m_herring_style; // herring style which overwrites the track default
|
||||
@ -49,6 +50,7 @@ public:
|
||||
CupData (const std::string filename);
|
||||
CupData () {}; // empty for initialising
|
||||
const std::string& getName () const { return m_name; }
|
||||
const std::string& getId () const { return m_id; }
|
||||
const std::string& getDescription () const { return m_description; }
|
||||
const std::string& getHerringStyle() const { return m_herring_style; }
|
||||
const std::string& getFilename () const { return m_filename; }
|
||||
@ -59,6 +61,7 @@ public:
|
||||
size_t getTrackCount() const {return m_tracks.size(); }
|
||||
const int& getLaps(size_t lap_index) const {assert(lap_index < m_tracks.size());
|
||||
return m_laps[lap_index]; }
|
||||
bool checkConsistency();
|
||||
}
|
||||
; // CupData
|
||||
|
||||
|
73
src/grand_prix_manager.cpp
Normal file
73
src/grand_prix_manager.cpp
Normal file
@ -0,0 +1,73 @@
|
||||
// $Id: grand_prix_manager.cpp 2173 2008-07-21 01:55:41Z auria $
|
||||
//
|
||||
// SuperTuxKart - a fun racing game with go-kart
|
||||
// Copyright (C) 2008 Joerg Henrichs
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 3
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#include <set>
|
||||
|
||||
#include "string_utils.hpp"
|
||||
#include "file_manager.hpp"
|
||||
#include "grand_prix_manager.hpp"
|
||||
#include "unlock_manager.hpp"
|
||||
|
||||
GrandPrixManager *grand_prix_manager = NULL;
|
||||
|
||||
GrandPrixManager::GrandPrixManager()
|
||||
{
|
||||
// Findout which grand prixs are available and load them
|
||||
std::set<std::string> result;
|
||||
file_manager->listFiles(result, "data/grandprix");
|
||||
for(std::set<std::string>::iterator i = result.begin();
|
||||
i != result.end() ; i++)
|
||||
{
|
||||
if (StringUtils::has_suffix(*i, ".grandprix")) load("grandprix/"+*i);
|
||||
if (StringUtils::has_suffix(*i, ".challenge"))
|
||||
unlock_manager->addChallenge(file_manager->getConfigFile("grandprix/"+*i));
|
||||
} // for i
|
||||
} // GrandPrixManager
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
GrandPrixManager::~GrandPrixManager()
|
||||
{
|
||||
for(unsigned int i=0; i<m_cup_data.size(); i++)
|
||||
{
|
||||
delete m_cup_data[i];
|
||||
} // for i
|
||||
|
||||
} // ~GrandPrixManager
|
||||
// ----------------------------------------------------------------------------
|
||||
const CupData* GrandPrixManager::getCup(const std::string& s) const
|
||||
{
|
||||
for(unsigned int i=0; i<m_cup_data.size(); i++)
|
||||
if(m_cup_data[i]->getId()==s) return m_cup_data[i];
|
||||
return NULL;
|
||||
} // getCup
|
||||
// ----------------------------------------------------------------------------
|
||||
void GrandPrixManager::load(const std::string& filename)
|
||||
{
|
||||
m_cup_data.push_back(new CupData(filename));
|
||||
} // load
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void GrandPrixManager::checkConsistency()
|
||||
{
|
||||
for(unsigned int i=0; i<m_cup_data.size(); i++)
|
||||
{
|
||||
m_cup_data[i]->checkConsistency();
|
||||
}
|
||||
} // checkConsistency
|
||||
// ----------------------------------------------------------------------------
|
43
src/grand_prix_manager.hpp
Normal file
43
src/grand_prix_manager.hpp
Normal file
@ -0,0 +1,43 @@
|
||||
// $Id: grand_prix_manager.hpp 2173 2008-07-21 01:55:41Z auria $
|
||||
//
|
||||
// SuperTuxKart - a fun racing game with go-kart
|
||||
// Copyright (C) 2008 Joerg Henrichs
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 3
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#ifndef HEADER_GRAND_PRIX_MANAGER_H
|
||||
#define HEADER_GRAND_PRIX_MANAGER_H
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include "cup_data.hpp"
|
||||
|
||||
class GrandPrixManager
|
||||
{
|
||||
private:
|
||||
std::vector<CupData*> m_cup_data;
|
||||
public:
|
||||
GrandPrixManager();
|
||||
~GrandPrixManager();
|
||||
void load(const std::string &filename);
|
||||
const CupData* getCup(int i) const { return m_cup_data[i]; }
|
||||
const CupData* getCup(const std::string& s) const;
|
||||
unsigned int getNumberOfGrandPrix() const { return m_cup_data.size(); }
|
||||
void checkConsistency();
|
||||
|
||||
}; // GrandPrixManager
|
||||
|
||||
extern GrandPrixManager *grand_prix_manager;
|
||||
#endif
|
@ -679,6 +679,10 @@
|
||||
RelativePath="../../../src\attachment_manager.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\bowling.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="../../../src\callback_manager.cpp"
|
||||
>
|
||||
@ -715,6 +719,10 @@
|
||||
RelativePath="../../../src\game_manager.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\grand_prix_manager.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="../../../src\herring.cpp"
|
||||
>
|
||||
@ -859,10 +867,6 @@
|
||||
RelativePath="../../../src\sound_manager.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\spark.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="../../../src\ssg_help.cpp"
|
||||
>
|
||||
@ -1071,43 +1075,7 @@
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\challenges\city_time.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\challenges\energy_math_class.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\challenges\energy_shifting_sands.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\challenges\island_follow.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\challenges\jungle_follow.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\challenges\moon_and_back_gp.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\challenges\penguin_playground_gp.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\challenges\race_track_time.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\challenges\tollway_head2head.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\challenges\tollway_time.cpp"
|
||||
RelativePath="..\..\challenges\challenge_data.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
@ -1137,6 +1105,10 @@
|
||||
RelativePath="../../../src\auto_kart.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\bowling.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="../../../src\callback.hpp"
|
||||
>
|
||||
@ -1185,6 +1157,10 @@
|
||||
RelativePath="../../../src\game_manager.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\grand_prix_manager.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\gui\help_page_one.hpp"
|
||||
>
|
||||
@ -1361,10 +1337,6 @@
|
||||
RelativePath="../../../src\sound_manager.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\spark.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="../../../src\ssg_help.hpp"
|
||||
>
|
||||
@ -1577,43 +1549,7 @@
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\challenges\city_time.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\challenges\energy_math_class.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\challenges\energy_shifting_sands.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\challenges\island_follow.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\challenges\jungle_follow.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\challenges\moon_and_back_gp.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\challenges\penguin_playground_gp.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\challenges\race_track_time.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\challenges\tollway_head2head.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\challenges\tollway_time.hpp"
|
||||
RelativePath="..\..\challenges\challenge_data.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
|
20
src/main.cpp
20
src/main.cpp
@ -65,6 +65,7 @@
|
||||
#include "stk_config.hpp"
|
||||
#include "translation.hpp"
|
||||
#include "highscore_manager.hpp"
|
||||
#include "grand_prix_manager.hpp"
|
||||
#include "gui/menu_manager.hpp"
|
||||
#include "scene.hpp"
|
||||
|
||||
@ -413,6 +414,7 @@ void InitTuxkart()
|
||||
herring_manager = new HerringManager ();
|
||||
attachment_manager = new AttachmentManager ();
|
||||
highscore_manager = new HighscoreManager ();
|
||||
grand_prix_manager = new GrandPrixManager ();
|
||||
track_manager->loadTrackList();
|
||||
sound_manager->addMusicToTracks();
|
||||
|
||||
@ -424,6 +426,10 @@ void InitTuxkart()
|
||||
race_manager->setMajorMode (RaceManager::RM_SINGLE);
|
||||
race_manager->setMinorMode (RaceManager::RM_QUICK_RACE);
|
||||
race_manager->setDifficulty(RaceManager::RD_HARD);
|
||||
|
||||
// Consistency check for challenges, and enable all challenges
|
||||
// that have all prerequisites fulfilled
|
||||
grand_prix_manager->checkConsistency();
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
@ -530,17 +536,21 @@ int main(int argc, char *argv[] )
|
||||
|
||||
/* Program closing...*/
|
||||
|
||||
if (user_config->m_crashed) user_config->m_crashed = false;
|
||||
user_config->saveConfig();
|
||||
delete inputDriver;
|
||||
if(user_config)
|
||||
{
|
||||
// In case that abort is triggered before user_config exists
|
||||
if (user_config->m_crashed) user_config->m_crashed = false;
|
||||
user_config->saveConfig();
|
||||
}
|
||||
if(inputDriver) delete inputDriver; // if early crash avoid delete NULL
|
||||
|
||||
if (user_config->m_log_errors) //close logfiles
|
||||
if (user_config && user_config->m_log_errors) //close logfiles
|
||||
{
|
||||
fclose(stderr);
|
||||
fclose(stdout);
|
||||
}
|
||||
|
||||
delete highscore_manager;
|
||||
if(highscore_manager) delete highscore_manager;
|
||||
delete_fonts();
|
||||
|
||||
return 0 ;
|
||||
|
@ -75,6 +75,7 @@ void TrackManager::loadTrackList ()
|
||||
}
|
||||
FILE *f=fopen(config_file.c_str(),"r");
|
||||
if(!f) continue;
|
||||
fclose(f);
|
||||
|
||||
Track *track = new Track(config_file);
|
||||
m_tracks.push_back(track);
|
||||
|
@ -16,22 +16,16 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "unlock_manager.hpp"
|
||||
#include "race_manager.hpp"
|
||||
|
||||
#include "challenges/energy_math_class.hpp"
|
||||
#include "challenges/penguin_playground_gp.hpp"
|
||||
#include "challenges/race_track_time.hpp"
|
||||
#include "challenges/tollway_time.hpp"
|
||||
#include "challenges/jungle_follow.hpp"
|
||||
#include "challenges/energy_shifting_sands.hpp"
|
||||
#include "challenges/moon_and_back_gp.hpp"
|
||||
#include "challenges/city_time.hpp"
|
||||
#include "challenges/island_follow.hpp"
|
||||
#include "challenges/worlds_end_gp.hpp"
|
||||
#include "challenges/tollway_head2head.hpp"
|
||||
#include "file_manager.hpp"
|
||||
#include "string_utils.hpp"
|
||||
#include "user_config.hpp"
|
||||
#include "challenges/challenge_data.hpp"
|
||||
|
||||
UnlockManager* unlock_manager=0;
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -43,23 +37,87 @@ UnlockManager::UnlockManager()
|
||||
// in main).
|
||||
unlock_manager=this;
|
||||
|
||||
// Add all challenges:
|
||||
Challenge *c;
|
||||
c=new EnergyMathClass(); m_all_challenges[c->getId()]=c;
|
||||
c=new PenguinPlaygroundGP(); m_all_challenges[c->getId()]=c;
|
||||
c=new RaceTrackTime(); m_all_challenges[c->getId()]=c;
|
||||
c=new TollwayTime(); m_all_challenges[c->getId()]=c;
|
||||
c=new JungleFollow(); m_all_challenges[c->getId()]=c;
|
||||
c=new EnergyShiftingSands(); m_all_challenges[c->getId()]=c;
|
||||
c=new MoonAndBackGP(); m_all_challenges[c->getId()]=c;
|
||||
c=new CityTime(); m_all_challenges[c->getId()]=c;
|
||||
c=new IslandFollow(); m_all_challenges[c->getId()]=c;
|
||||
c=new WorldsEndGP(); m_all_challenges[c->getId()]=c;
|
||||
c=new TollwayHead2Head(); m_all_challenges[c->getId()]=c;
|
||||
|
||||
// Read challenges from .../data
|
||||
// -----------------------------
|
||||
std::set<std::string> result;
|
||||
file_manager->listFiles(result, "data");
|
||||
for(std::set<std::string>::iterator i = result.begin();
|
||||
i != result.end() ; i++)
|
||||
{
|
||||
if (StringUtils::has_suffix(*i, ".challenge"))
|
||||
addChallenge(file_manager->getConfigFile(*i));
|
||||
} // for i
|
||||
|
||||
// Read challenges from .../data/tracks/*
|
||||
// --------------------------------------
|
||||
std::set<std::string> dirs;
|
||||
file_manager->listFiles(dirs, file_manager->getTrackDir(), /*is_full_path*/ true);
|
||||
for(std::set<std::string>::iterator dir = dirs.begin(); dir != dirs.end(); dir++)
|
||||
{
|
||||
if(*dir=="." || *dir=="..") continue;
|
||||
std::string config_file;
|
||||
try
|
||||
{
|
||||
// getTrackFile appends dir, so it's opening: *dir/*dir.track
|
||||
config_file = file_manager->getTrackFile((*dir)+".track");
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
(void)e; // remove warning about unused variable
|
||||
continue;
|
||||
}
|
||||
// Check for a challenge file
|
||||
std::string challenge_file =
|
||||
StringUtils::without_extension(config_file)+".challenge";
|
||||
FILE *f=fopen(challenge_file.c_str(), "r");
|
||||
if(f)
|
||||
{
|
||||
fclose(f);
|
||||
addChallenge(new ChallengeData(challenge_file));
|
||||
}
|
||||
} // for dirs
|
||||
|
||||
// Load challenges from .../data/karts
|
||||
// -----------------------------------
|
||||
file_manager->listFiles(dirs, file_manager->getKartDir(),
|
||||
/*is_full_path*/ true);
|
||||
|
||||
// Find out which characters are available and load them
|
||||
for(std::set<std::string>::iterator i = dirs.begin();
|
||||
i != dirs.end(); i++)
|
||||
{
|
||||
std::string challenge_file;
|
||||
try
|
||||
{
|
||||
challenge_file = file_manager->getKartFile((*i)+".challenge");
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
(void)e; // remove warning about unused variable
|
||||
continue;
|
||||
}
|
||||
FILE *f=fopen(challenge_file.c_str(),"r");
|
||||
if(!f) continue;
|
||||
fclose(f);
|
||||
addChallenge(new ChallengeData(challenge_file));
|
||||
} // for i
|
||||
|
||||
// Hard coded challenges can be added here.
|
||||
|
||||
computeActive();
|
||||
|
||||
} // UnlockManager
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void UnlockManager::addChallenge(Challenge *c)
|
||||
{
|
||||
m_all_challenges[c->getId()]=c;
|
||||
} // addChallenge
|
||||
//-----------------------------------------------------------------------------
|
||||
void UnlockManager::addChallenge(const std::string& filename)
|
||||
{
|
||||
addChallenge(new ChallengeData(filename));
|
||||
} // addChallenge
|
||||
//-----------------------------------------------------------------------------
|
||||
std::vector<const Challenge*> UnlockManager::getActiveChallenges()
|
||||
{
|
||||
|
@ -38,6 +38,8 @@ private:
|
||||
void computeActive ();
|
||||
public:
|
||||
UnlockManager ();
|
||||
void addChallenge (Challenge *c);
|
||||
void addChallenge (const std::string& filename);
|
||||
void load (const lisp::Lisp*);
|
||||
void save (lisp::Writer* writer);
|
||||
std::vector<const Challenge*>
|
||||
|
@ -308,6 +308,7 @@ public:
|
||||
|
||||
void setWgtTexture(const int TOKEN, const int TEXTURE);
|
||||
void setWgtTexture(const int TOKEN, const std::string& FILENAME, const bool is_full_path=true);
|
||||
void setWgtLockTexture(const int token) {setWgtTexture(token, "gui_lock.rgb", false);}
|
||||
void showWgtTexture(const int TOKEN);
|
||||
void hideWgtTexture(const int TOKEN);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user