Delete old unsued files
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@12356 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
ff9f8503da
commit
16df188b03
@ -228,9 +228,6 @@ src/tracks/track_manager.cpp
|
||||
src/tracks/track_object.cpp
|
||||
src/tracks/track_object_manager.cpp
|
||||
src/tracks/track_sector.cpp
|
||||
src/tutorial/tutorial.cpp
|
||||
src/tutorial/tutorial_data.cpp
|
||||
src/tutorial/tutorial_manager.cpp
|
||||
src/utils/constants.cpp
|
||||
src/utils/leak_check.cpp
|
||||
src/utils/log.cpp
|
||||
@ -490,9 +487,6 @@ src/tracks/track_manager.hpp
|
||||
src/tracks/track_object.hpp
|
||||
src/tracks/track_object_manager.hpp
|
||||
src/tracks/track_sector.hpp
|
||||
src/tutorial/tutorial_data.hpp
|
||||
src/tutorial/tutorial.hpp
|
||||
src/tutorial/tutorial_manager.hpp
|
||||
src/utils/aligned_array.hpp
|
||||
src/utils/constants.hpp
|
||||
src/utils/interpolation_array.hpp
|
||||
|
13
src/main.cpp
13
src/main.cpp
@ -180,7 +180,6 @@
|
||||
#include "states_screens/dialogs/message_dialog.hpp"
|
||||
#include "tracks/track.hpp"
|
||||
#include "tracks/track_manager.hpp"
|
||||
#include "tutorial/tutorial_manager.hpp"
|
||||
#include "utils/constants.hpp"
|
||||
#include "utils/leak_check.hpp"
|
||||
#include "utils/log.hpp"
|
||||
@ -298,8 +297,8 @@ void gamepadVisualisation()
|
||||
|
||||
for (int b=0; b<SEvent::SJoystickEvent::NUMBER_OF_BUTTONS; b++)
|
||||
{
|
||||
position2di pos(btn_x + b*BTN_SIZE, btn_y);
|
||||
dimension2di size(BTN_SIZE, BTN_SIZE);
|
||||
core::position2di pos(btn_x + b*BTN_SIZE, btn_y);
|
||||
core::dimension2di size(BTN_SIZE, BTN_SIZE);
|
||||
|
||||
if (g.m_button_state[b])
|
||||
{
|
||||
@ -320,14 +319,14 @@ void gamepadVisualisation()
|
||||
{
|
||||
const float rate = g.m_axis[a] / 32767.0f;
|
||||
|
||||
position2di pos(axis_x, axis_y + a*axis_h);
|
||||
dimension2di size(axis_w, axis_h);
|
||||
core::position2di pos(axis_x, axis_y + a*axis_h);
|
||||
core::dimension2di size(axis_w, axis_h);
|
||||
|
||||
const bool deadzone = (abs(g.m_axis[a]) < DEADZONE_JOYSTICK);
|
||||
|
||||
core::recti fillbar(position2di(axis_x + axis_w/2,
|
||||
core::recti fillbar(core::position2di(axis_x + axis_w/2,
|
||||
axis_y + a*axis_h),
|
||||
dimension2di( (int)(axis_w/2*rate),
|
||||
core::dimension2di( (int)(axis_w/2*rate),
|
||||
axis_h) );
|
||||
fillbar.repair(); // dimension may be negative
|
||||
driver->draw2DRectangle (deadzone ? video::SColor(255,255,0,0)
|
||||
|
@ -1,2 +0,0 @@
|
||||
#include "tutorial.hpp"
|
||||
|
@ -1,126 +0,0 @@
|
||||
// SuperTuxKart - a fun racing game with go-kart
|
||||
// Copyright (C) 2010 Alejandro Santiago Varela
|
||||
//
|
||||
// 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 TUTORIAL_H
|
||||
#define TUTORIAL_H
|
||||
|
||||
/**
|
||||
* \defgroup tutorial
|
||||
*/
|
||||
|
||||
// External includes
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <fstream>
|
||||
#include <irrString.h>
|
||||
|
||||
// SuperTuxKart includes
|
||||
#include "utils/no_copy.hpp"
|
||||
|
||||
using namespace std; // To avoid using std:: all the time
|
||||
using namespace irr::core;
|
||||
class XMLNode;
|
||||
|
||||
/*enum REWARD_TYPE
|
||||
{UNLOCK_TRACK,
|
||||
UNLOCK_GP,
|
||||
UNLOCK_MODE,
|
||||
UNLOCK_KART,
|
||||
UNLOCK_DIFFICULTY};
|
||||
*/
|
||||
|
||||
/*struct UnlockableFeature
|
||||
{
|
||||
string name; // internal name
|
||||
stringw user_name; // not all types of feature have one
|
||||
REWARD_TYPE type;
|
||||
|
||||
const stringw getUnlockedMessage() const;
|
||||
};*/
|
||||
|
||||
|
||||
/**
|
||||
* \brief A class for all tutorials
|
||||
* \ingroup challenges
|
||||
*/
|
||||
class Tutorial : public NoCopy
|
||||
{
|
||||
private:
|
||||
// TBR ????
|
||||
enum {CH_INACTIVE, // tutorial not yet possible
|
||||
CH_ACTIVE, // challenge possible, but not yet solved
|
||||
CH_SOLVED} m_state; // challenge was solved
|
||||
|
||||
std::string m_Id; // short, internal name for this tutorial
|
||||
irr::core::stringw m_Name; // name used in menu for this tutorial
|
||||
irr::core::stringw m_tutorial_description; // Message the user gets when the feature is not yet unlocked
|
||||
// vector<UnlockableFeature> m_feature; // Features to unlock
|
||||
// vector<string> m_prerequisites; // what needs to be done before accessing this tutorial
|
||||
|
||||
public:
|
||||
// Constructors + Destructor
|
||||
Tutorial(const std::string &id, const std::string &name);
|
||||
Tutorial() {m_Id=""; m_Name="";m_state=CH_INACTIVE;}
|
||||
virtual ~Tutorial() {};
|
||||
|
||||
// Getters & Setters
|
||||
const std::string &getId() const { return m_Id;}
|
||||
irr::core::stringw getName() const { return m_Name;}
|
||||
const irr::core::stringw&
|
||||
getTutorialDescription() const {return m_tutorial_description; }
|
||||
void setName(const irr::core::stringw & s) { m_Name = s;}
|
||||
void setId(const std::string& s) { m_Id = s;}
|
||||
void setSolved() { m_state = CH_SOLVED;}
|
||||
void setActive() { m_state = CH_ACTIVE;}
|
||||
|
||||
|
||||
void addUnlockTrackReward (const std::string &track_name);
|
||||
void addUnlockModeReward (const std::string &internal_mode_name,
|
||||
const irr::core::stringw &user_mode_name);
|
||||
void setTutorialDescription(const irr::core::stringw& d)
|
||||
{m_tutorial_description=d;}
|
||||
void addUnlockGPReward(const std::string &gp_name);
|
||||
void addUnlockDifficultyReward(const std::string &internal_name,
|
||||
const irr::core::stringw &user_name);
|
||||
void addUnlockKartReward(const std::string &internal_name,
|
||||
const irr::core::stringw &user_name);
|
||||
|
||||
bool isSolved() const {return m_state==CH_SOLVED; }
|
||||
bool isActive() const {return m_state==CH_ACTIVE; }
|
||||
|
||||
|
||||
// File operations
|
||||
void load(const XMLNode* config);
|
||||
void save(ofstream& writer);
|
||||
// These functions are meant for customisation, e.g. load/save
|
||||
// additional state information specific to the tutorial
|
||||
virtual void loadAdditionalInfo(const XMLNode* config) {};
|
||||
virtual void saveAdditionalInfo(ofstream& writer) {};
|
||||
|
||||
// These functions are called when a race/gp is finished. It allows
|
||||
// the challenge to unlock features (when returning true), otherwise
|
||||
// the feature remains locked.
|
||||
virtual bool raceFinished() {return false;} // end of a race
|
||||
//virtual bool grandPrixFinished() {return false;} // end of a GP
|
||||
|
||||
/** sets the right parameters in RaceManager to try this tutorial */
|
||||
virtual void setRace() const = 0;
|
||||
|
||||
/** Checks if a tutorial is valid. */
|
||||
virtual void check() const = 0;
|
||||
};
|
||||
#endif // TUTORIAL_H
|
@ -1,311 +0,0 @@
|
||||
// SuperTuxKart - a fun racing game with go-kart
|
||||
// Copyright (C) 2010 Alejandro Santiago
|
||||
//
|
||||
// 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 "tutorial/tutorial_data.hpp"
|
||||
|
||||
#include <stdexcept>
|
||||
#include <iostream>
|
||||
|
||||
#include "karts/abstract_kart.hpp"
|
||||
#include "karts/kart_properties_manager.hpp"
|
||||
#include "modes/linear_world.hpp"
|
||||
#include "race/grand_prix_data.hpp"
|
||||
#include "race/grand_prix_manager.hpp"
|
||||
#include "race/race_manager.hpp"
|
||||
#include "tracks/track.hpp"
|
||||
#include "tracks/track_manager.hpp"
|
||||
#include "utils/translation.hpp"
|
||||
|
||||
TutorialData::TutorialData(const std::string& filename)
|
||||
#ifndef WIN32
|
||||
throw(std::runtime_error)
|
||||
#endif
|
||||
{
|
||||
m_filename = filename;
|
||||
m_major = RaceManager::MAJOR_MODE_SINGLE;
|
||||
m_minor = RaceManager::MINOR_MODE_NORMAL_RACE;
|
||||
m_difficulty = RaceManager::DIFFICULTY_EASY;
|
||||
m_num_laps = -1;
|
||||
m_num_karts = -1;
|
||||
m_time = -1.0f;
|
||||
m_track_name = "";
|
||||
m_gp_id = "";
|
||||
m_energy = -1;
|
||||
|
||||
std::string s_property;
|
||||
int i_property;
|
||||
|
||||
XMLNode *root = new XMLNode( filename );
|
||||
|
||||
// Check if the file have been load correctly
|
||||
if(!root || root->getName()!="tutorial")
|
||||
{
|
||||
delete root;
|
||||
std::ostringstream msg;
|
||||
msg << "Couldn't load tutorial '" << filename << "': no tutorial node.";
|
||||
throw std::runtime_error(msg.str());
|
||||
}
|
||||
// Start the loading process (ordered as it is on the file)
|
||||
|
||||
// ID
|
||||
if(!root->get("id", &s_property) )
|
||||
error("id");
|
||||
setId(s_property);
|
||||
|
||||
// Name
|
||||
if(!root->get("name", &s_property) )
|
||||
error("name");
|
||||
setName( _(s_property.c_str()) );
|
||||
|
||||
// Description
|
||||
if(!root->get("s_property", &s_property) )
|
||||
error("description");
|
||||
setTutorialDescription( _(s_property.c_str()) );
|
||||
|
||||
// Major
|
||||
root->get("major", &s_property);
|
||||
setMajor(s_property);
|
||||
|
||||
// Minor
|
||||
root->get("minor", &s_property);
|
||||
setMinor(s_property);
|
||||
|
||||
// Karts
|
||||
if(!root->get("karts", &i_property) )
|
||||
error("karts");
|
||||
setNumKarts(i_property);
|
||||
|
||||
|
||||
// Difficulty
|
||||
root->get("difficulty", &s_property);
|
||||
setDifficulty(s_property);
|
||||
|
||||
if(m_major==RaceManager::MAJOR_MODE_SINGLE)
|
||||
{
|
||||
// Track
|
||||
if (!root->get("track", &s_property ))
|
||||
error("track");
|
||||
setTrack(s_property);
|
||||
}
|
||||
|
||||
// Num Players
|
||||
root->get("num_players", &i_property);
|
||||
setNumPlayers(i_property);
|
||||
delete root;
|
||||
|
||||
} // TutorialData
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void TutorialData::error(const char *id) const
|
||||
{
|
||||
std::ostringstream msg;
|
||||
msg << "Undefined or incorrect value for '" << id
|
||||
<< "' in tutorial file '" << m_filename << "'.";
|
||||
|
||||
std::cerr << "TutorialData : " << msg.str() << std::endl;
|
||||
|
||||
throw std::runtime_error(msg.str());
|
||||
} // error
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Checks if this tutorial is valid, i.e. contains a valid track or a valid
|
||||
* GP. If incorrect data are found, STK is aborted with an error message.
|
||||
* (otherwise STK aborts when trying to do this challenge, which is worse).
|
||||
*/
|
||||
void TutorialData::check() const
|
||||
{
|
||||
if(m_major==RaceManager::MAJOR_MODE_SINGLE)
|
||||
{
|
||||
try
|
||||
{
|
||||
track_manager->getTrack(m_track_name);
|
||||
}
|
||||
catch(std::exception&)
|
||||
{
|
||||
error("track");
|
||||
}
|
||||
}
|
||||
else if(m_major==RaceManager::MAJOR_MODE_GRAND_PRIX)
|
||||
{
|
||||
const GrandPrixData* gp = grand_prix_manager->getGrandPrix(m_gp_id);
|
||||
|
||||
if (gp == NULL)
|
||||
{
|
||||
error("gp");
|
||||
}
|
||||
const bool gp_ok = gp->checkConsistency(false);
|
||||
if (!gp_ok)
|
||||
{
|
||||
error("gp");
|
||||
}
|
||||
}
|
||||
} // check
|
||||
|
||||
|
||||
void TutorialData::setRace() const
|
||||
{
|
||||
race_manager->setMajorMode(m_major);
|
||||
if(m_major==RaceManager::MAJOR_MODE_SINGLE)
|
||||
{
|
||||
race_manager->setMinorMode(m_minor);
|
||||
race_manager->setTrack(m_track_name);
|
||||
race_manager->setDifficulty(m_difficulty);
|
||||
race_manager->setNumLaps(m_num_laps);
|
||||
race_manager->setNumKarts(m_num_karts);
|
||||
race_manager->setNumLocalPlayers(1);
|
||||
race_manager->setCoinTarget(m_energy);
|
||||
}
|
||||
else // GP
|
||||
{
|
||||
race_manager->setMinorMode(m_minor);
|
||||
const GrandPrixData *gp = grand_prix_manager->getGrandPrix(m_gp_id);
|
||||
race_manager->setGrandPrix(*gp);
|
||||
race_manager->setDifficulty(m_difficulty);
|
||||
race_manager->setNumKarts(m_num_karts);
|
||||
race_manager->setNumLocalPlayers(1);
|
||||
}
|
||||
} // setRace
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
bool TutorialData::raceFinished()
|
||||
{
|
||||
// GP's use the grandPrixFinished() function, so they can't be fulfilled here.
|
||||
if(m_major==RaceManager::MAJOR_MODE_GRAND_PRIX) return false;
|
||||
|
||||
// Single races
|
||||
// ------------
|
||||
World *world = World::getWorld();
|
||||
std::string track_name = world->getTrack()->getIdent();
|
||||
if(track_name!=m_track_name ) return false; // wrong track
|
||||
if((int)world->getNumKarts()<m_num_karts ) return false; // not enough AI karts
|
||||
|
||||
AbstractKart* kart = world->getPlayerKart(0);
|
||||
if(m_energy>0 && kart->getEnergy() <m_energy ) return false; // not enough energy
|
||||
if(m_position>0 && kart->getPosition()>m_position) return false; // too far behind
|
||||
|
||||
// Follow the leader
|
||||
// -----------------
|
||||
if(m_minor==RaceManager::MINOR_MODE_FOLLOW_LEADER)
|
||||
{
|
||||
// All possible conditions were already checked, so: must have been successful
|
||||
return true;
|
||||
}
|
||||
// Quickrace / Timetrial
|
||||
// ---------------------
|
||||
// FIXME - encapsulate this better, each race mode needs to be able to specify
|
||||
// its own challenges and deal with them
|
||||
LinearWorld* lworld = dynamic_cast<LinearWorld*>(world);
|
||||
if(lworld != NULL)
|
||||
{
|
||||
if(lworld->getLapForKart( kart->getWorldKartId() ) != m_num_laps) return false; // wrong number of laps
|
||||
}
|
||||
if(m_time>0.0f && kart->getFinishTime()>m_time) return false; // too slow
|
||||
return true;
|
||||
} // raceFinished
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
bool TutorialData::grandPrixFinished()
|
||||
{
|
||||
// Note that we have to call race_manager->getNumKarts, since there
|
||||
// is no world objects to query at this stage.
|
||||
if (race_manager->getMajorMode() != RaceManager::MAJOR_MODE_GRAND_PRIX ||
|
||||
race_manager->getMinorMode() != m_minor ||
|
||||
race_manager->getGrandPrix()->getId() != m_gp_id ||
|
||||
race_manager->getDifficulty()!= m_difficulty ||
|
||||
race_manager->getNumberOfKarts() < (unsigned int)m_num_karts ||
|
||||
race_manager->getNumPlayers() > 1) return false;
|
||||
|
||||
// check if the player came first.
|
||||
//assert(World::getWorld() != NULL);
|
||||
// Kart* kart = World::getWorld()->getPlayerKart(0);
|
||||
//const int rank = race_manager->getKartGPRank(kart->getWorldKartId());
|
||||
const int rank = race_manager->getLocalPlayerGPRank(0);
|
||||
|
||||
//printf("getting rank for %s : %i \n", kart->getName().c_str(), rank );
|
||||
if (rank != 0) return false;
|
||||
|
||||
return true;
|
||||
} // grandPrixFinished
|
||||
|
||||
void TutorialData::setNumKarts(int num_karts)
|
||||
{
|
||||
this->m_num_karts= num_karts;
|
||||
}
|
||||
void TutorialData::setLaps(int num_laps)
|
||||
{
|
||||
this->m_num_laps = num_laps;
|
||||
}
|
||||
void TutorialData::setTrack(std::string track_name)
|
||||
{
|
||||
this->m_track_name == track_name;
|
||||
if (track_manager->getTrack(m_track_name) == NULL)
|
||||
error("track");
|
||||
}
|
||||
|
||||
void TutorialData::setDifficulty(std::string difficulty)
|
||||
{
|
||||
if(difficulty == "easy")
|
||||
this->m_difficulty = RaceManager::DIFFICULTY_EASY;
|
||||
else if(difficulty =="medium")
|
||||
this->m_difficulty = RaceManager::DIFFICULTY_MEDIUM;
|
||||
else if(difficulty =="hard")
|
||||
this->m_difficulty = RaceManager::DIFFICULTY_HARD;
|
||||
else
|
||||
error("difficulty");
|
||||
}
|
||||
|
||||
void TutorialData::setMinor(std::string minor)
|
||||
{
|
||||
if(minor=="timetrial")
|
||||
this->m_minor = RaceManager::MINOR_MODE_TIME_TRIAL;
|
||||
else if(minor=="quickrace")
|
||||
this->m_minor = RaceManager::MINOR_MODE_NORMAL_RACE;
|
||||
else if(minor=="followtheleader")
|
||||
this->m_minor = RaceManager::MINOR_MODE_FOLLOW_LEADER;
|
||||
else
|
||||
error("minor");
|
||||
}
|
||||
|
||||
void TutorialData::setMajor(std::string major)
|
||||
{
|
||||
if(major=="grandprix")
|
||||
this->m_major = RaceManager::MAJOR_MODE_GRAND_PRIX;
|
||||
else if(major=="single")
|
||||
this->m_major = RaceManager::MAJOR_MODE_SINGLE;
|
||||
else
|
||||
error("major");
|
||||
}
|
||||
|
||||
void TutorialData::setPosition(int position)
|
||||
{
|
||||
this->m_position = position;
|
||||
}
|
||||
|
||||
void TutorialData::setTime (float time)
|
||||
{
|
||||
this->m_time = time;
|
||||
}
|
||||
|
||||
void TutorialData::setEnergy(int energy)
|
||||
{
|
||||
m_energy = energy;
|
||||
}
|
||||
|
||||
void TutorialData::setNumPlayers (int num_players)
|
||||
{
|
||||
this->m_num_players = num_players;
|
||||
}
|
@ -1,79 +0,0 @@
|
||||
// SuperTuxKart - a fun racing game with go-kart
|
||||
// Copyright (C) 2010 Alejandro Santiago
|
||||
//
|
||||
// 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_TUTORIAL_DATA_HPP
|
||||
#define HEADER_TUTORIAL_DATA_HPP
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <stdio.h>
|
||||
#include <stdexcept>
|
||||
|
||||
#include "tutorial/tutorial.hpp"
|
||||
#include "race/race_manager.hpp"
|
||||
|
||||
/**
|
||||
* \ingroup tutorial
|
||||
*/
|
||||
class TutorialData : public Tutorial
|
||||
{
|
||||
private:
|
||||
RaceManager::MajorRaceModeType m_major;
|
||||
RaceManager::MinorRaceModeType m_minor;
|
||||
RaceManager::Difficulty m_difficulty;
|
||||
int m_num_laps;
|
||||
int m_position;
|
||||
int m_num_karts;
|
||||
float m_time;
|
||||
std::string m_gp_id;
|
||||
std::string m_track_name;
|
||||
int m_energy;
|
||||
std::string m_filename;
|
||||
int m_num_players;
|
||||
|
||||
|
||||
// void getUnlocks(const XMLNode *root, const std:: string type, REWARD_TYPE reward);
|
||||
void error(const char *id) const;
|
||||
|
||||
public:
|
||||
#ifdef WIN32
|
||||
TutorialData(const std::string& filename);
|
||||
#else
|
||||
TutorialData(const std::string& filename) throw(std::runtime_error);
|
||||
#endif
|
||||
|
||||
/** sets the right parameters in RaceManager to try this tutorial */
|
||||
void setRace() const;
|
||||
|
||||
void setEnergy(int m_energy);
|
||||
void setTime(float m_time);
|
||||
void setPosition(int position);
|
||||
void setDifficulty(std::string difficulty);
|
||||
void setTrack(std::string track_name);
|
||||
void setLaps(int num_laps);
|
||||
void setMajor(std::string major);
|
||||
void setMinor(std::string minor);
|
||||
void setNumKarts(int num_karts);
|
||||
void setNumPlayers(int num_players);
|
||||
|
||||
virtual void check() const;
|
||||
virtual bool raceFinished();
|
||||
virtual bool grandPrixFinished();
|
||||
|
||||
}; // TutorialData
|
||||
|
||||
#endif // HEADER_TUTORIAL_DATA_HPP
|
@ -1,169 +0,0 @@
|
||||
// SuperTuxKart - a fun racing game with go-kart
|
||||
// Copyright (C) 2010 Alejandro Santiago
|
||||
//
|
||||
// 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 "tutorial/tutorial_manager.hpp"
|
||||
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <stdio.h>
|
||||
#include <iostream>
|
||||
|
||||
#include "audio/sfx_base.hpp"
|
||||
#include "audio/sfx_manager.hpp"
|
||||
#include "config/user_config.hpp"
|
||||
#include "io/file_manager.hpp"
|
||||
#include "karts/kart_properties_manager.hpp"
|
||||
#include "race/race_manager.hpp"
|
||||
#include "tracks/track_manager.hpp"
|
||||
#include "utils/string_utils.hpp"
|
||||
|
||||
TutorialManager * m_tutorial_manager=0;
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
TutorialManager::TutorialManager()
|
||||
{
|
||||
// The global variable 'tutorial_manager' is needed in the tutorials,
|
||||
// but it's not set yet - so we define it here (and it gets re-assign
|
||||
// in main).
|
||||
m_tutorial_manager = this;
|
||||
|
||||
// -----------------------------
|
||||
std::set<std::string> result;
|
||||
file_manager->listFiles(result, "data/tutorials");
|
||||
for(std::set<std::string>::iterator i = result.begin();
|
||||
i != result.end() ; i++)
|
||||
{
|
||||
if (StringUtils::hasSuffix(*i, ".tutorial"))
|
||||
addTutorial(file_manager->getDataFile("tutorials/"+*i));
|
||||
}
|
||||
|
||||
// Hard coded challenges can be added here.
|
||||
load();
|
||||
|
||||
} // UnlockManager
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
** Saves the challenge status.
|
||||
*/
|
||||
TutorialManager::~TutorialManager()
|
||||
{
|
||||
//save();
|
||||
|
||||
// sfx_manager is destroyed before UnlockManager is, so SFX will be already deleted
|
||||
// sfx_manager->deleteSFX(m_locked_sound);
|
||||
} // ~UnlockManager
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void TutorialManager::addTutorial(Tutorial * m_tutorial)
|
||||
{
|
||||
m_tutorials_list[m_tutorial->getId()]=m_tutorial;
|
||||
} // addTutorial
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void TutorialManager::addTutorial(const std::string& filename)
|
||||
{
|
||||
TutorialData* m_tutorial = NULL;
|
||||
try
|
||||
{
|
||||
m_tutorial = new TutorialData(filename);
|
||||
m_tutorial->check();
|
||||
}
|
||||
catch (std::runtime_error& ex)
|
||||
{
|
||||
std::cerr << "\n/!\\ An error occurred while loading tutorial file '" << filename << "' : "
|
||||
<< ex.what() << " : tutorial will be ignored.\n\n";
|
||||
if (m_tutorial != NULL) delete m_tutorial;
|
||||
return;
|
||||
}
|
||||
addTutorial(m_tutorial);
|
||||
|
||||
} // addChallenge
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
std::vector<const Tutorial*> TutorialManager::getTutorialsList()
|
||||
{
|
||||
std::vector<const Tutorial*> all_active;
|
||||
for(TutorialsList::iterator i = m_tutorials_list.begin();
|
||||
i!=m_tutorials_list.end(); i++)
|
||||
{
|
||||
if(i->second->isActive()) all_active.push_back(i->second);
|
||||
}
|
||||
return all_active;
|
||||
} // getActiveChallenges
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
const Tutorial* TutorialManager::getTutorial(const std::string& id)
|
||||
{
|
||||
if(m_tutorials_list.find(id) == m_tutorials_list.end()) return NULL;
|
||||
return m_tutorials_list[id];
|
||||
} // getTutorial
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
** This is called from user_config when reading the config file
|
||||
*/
|
||||
void TutorialManager::load()
|
||||
{
|
||||
const std::string filename=file_manager->getChallengeFile("tutorials.xml");
|
||||
XMLNode* root = file_manager->createXMLTree(filename);
|
||||
if(!root || root->getName() != "tutorials")
|
||||
{
|
||||
std::cerr << "Tutorial file '" << filename << "' will be created."
|
||||
<< std::endl;
|
||||
//save();
|
||||
|
||||
if (root) delete root;
|
||||
return;
|
||||
}
|
||||
|
||||
for(TutorialsList::iterator i = m_tutorials_list.begin();
|
||||
i!= m_tutorials_list.end(); i++)
|
||||
{
|
||||
// i->second->load(root);
|
||||
}
|
||||
delete root;
|
||||
} // load
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//void TutorialManager::save()
|
||||
//{
|
||||
// std::ofstream tutorial_file;
|
||||
//std::string filename = file_manager->getChallengeFile("tutorial.xml");
|
||||
//challenge_file.open(filename.c_str());
|
||||
|
||||
//if(!challenge_file.is_open())
|
||||
//{
|
||||
// std::cerr << "Failed to open " << filename << " for writing, challenges won't be saved\n";
|
||||
// return;
|
||||
//}
|
||||
|
||||
//challenge_file << "<?xml version=\"1.0\"?>\n";
|
||||
//challenge_file << "<challenges>\n";
|
||||
//
|
||||
//for(AllChallengesType::iterator i = m_all_challenges.begin();
|
||||
// i!= m_all_challenges.end(); i++)
|
||||
//{
|
||||
// i->second->save(challenge_file);
|
||||
//}
|
||||
//
|
||||
//challenge_file << "</challenges>\n\n";
|
||||
//challenge_file.close();
|
||||
//} // save
|
||||
|
||||
|
@ -1,61 +0,0 @@
|
||||
// SuperTuxKart - a fun racing game with go-kart
|
||||
// Copyright (C) 2010 Alejandro Santiago
|
||||
//
|
||||
// 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 TUTORIALMANAGER_H
|
||||
#define TUTORIALMANAGER_H
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "tutorial/tutorial.hpp"
|
||||
#include "tutorial/tutorial_data.hpp"
|
||||
|
||||
#include "utils/no_copy.hpp"
|
||||
|
||||
#include <fstream>
|
||||
|
||||
class XMLNode;
|
||||
|
||||
/**
|
||||
* \brief main class to handle the tutorials list
|
||||
* \ingroup tutorial
|
||||
*/
|
||||
class TutorialManager : public NoCopy
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
typedef std::map<std::string, Tutorial*> TutorialsList;
|
||||
TutorialsList m_tutorials_list;
|
||||
|
||||
void load ();
|
||||
|
||||
public:
|
||||
TutorialManager ();
|
||||
~TutorialManager ();
|
||||
void addTutorial (Tutorial * m_tutorial);
|
||||
void addTutorial (const std::string& filename);
|
||||
|
||||
vector <const Tutorial*> getTutorialsList();
|
||||
|
||||
const Tutorial *getTutorial (const std::string& id);
|
||||
|
||||
void raceFinished ();
|
||||
|
||||
}; // TutorialManager
|
||||
|
||||
extern TutorialManager * m_tutorial_manager;
|
||||
#endif // TUTORIALMANAGER_H
|
Loading…
Reference in New Issue
Block a user