tutorial new classes, VC project and main menu screen.

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@7043 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
aeonphyxius
2010-12-16 22:57:13 +00:00
parent 5bbbea2d3c
commit d672a5446b
10 changed files with 388 additions and 8 deletions

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Version="9,00"
Name="supertuxkart"
ProjectGUID="{B1BC2764-1A43-4800-A654-788B0D05EDA2}"
RootNamespace="supertuxkart"
@@ -1042,6 +1042,10 @@
RelativePath="..\..\states_screens\tracks_screen.cpp"
>
</File>
<File
RelativePath="..\..\states_screens\tutorial_screen.cpp"
>
</File>
<Filter
Name="dialogs"
>
@@ -1107,6 +1111,18 @@
>
</File>
</Filter>
<Filter
Name="tutorial"
>
<File
RelativePath="..\..\tutorial\tutorial.cpp"
>
</File>
<File
RelativePath="..\..\tutorial\tutorial_manager.cpp"
>
</File>
</Filter>
</Filter>
<Filter
Name="Headerdateien"
@@ -1932,6 +1948,10 @@
RelativePath="..\..\states_screens\tracks_screen.hpp"
>
</File>
<File
RelativePath="..\..\states_screens\tutorial_screen.hpp"
>
</File>
<Filter
Name="dialogs"
>
@@ -1997,6 +2017,18 @@
>
</File>
</Filter>
<Filter
Name="tutorial"
>
<File
RelativePath="..\..\tutorial\tutorial.hpp"
>
</File>
<File
RelativePath="..\..\tutorial\tutorial_manager.hpp"
>
</File>
</Filter>
</Filter>
<Filter
Name="Ressourcendateien"

View File

@@ -0,0 +1,72 @@
// SuperTuxKart - a fun racing game with go-kart
// Copyright (C) 2006 SuperTuxKart-Team
//
// 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 "modes/game_tutorial.hpp"
//#include "challenges/unlock_manager.hpp"
//#include "config/user_config.hpp"
//-----------------------------------------------------------------------------
GameTutorial::GameTutorial() : LinearWorld()
{
WorldStatus::setClockMode(CLOCK_CHRONO);
} // GameTutorial
//-----------------------------------------------------------------------------
/** Returns true if the race is finished, i.e. all player karts are finished.
*/
bool GameTutorial::isRaceOver()
{
// The race is over if all players have finished the race. Remaining
// times for AI opponents will be estimated in enterRaceOverState
return race_manager->allPlayerFinished();
} // isRaceOver
/*
//-----------------------------------------------------------------------------
void GameTutorial::getDefaultCollectibles(int& collectible_type, int& amount)
{
// in time trial mode, give zippers
if(race_manager->getMinorMode() == RaceManager::MINOR_MODE_TIME_TRIAL)
{
collectible_type = PowerupManager::POWERUP_ZIPPER;
amount = race_manager->getNumLaps();
}
else World::getDefaultCollectibles(collectible_type, amount);
} // getDefaultCollectibles
*/
//-----------------------------------------------------------------------------
/** Returns if this mode supports bonus boxes or not.
*/
/*
bool GameTutorial::haveBonusBoxes()
{
// in time trial mode, don't use bonus boxes
return race_manager->getMinorMode() != RaceManager::MINOR_MODE_TIME_TRIAL;
} // haveBonusBoxes
*/
//-----------------------------------------------------------------------------
/** Returns an identifier for this race.
*/
/*
std::string GameTutorial::getIdent() const
{
if(race_manager->getMinorMode() == RaceManager::MINOR_MODE_TIME_TRIAL)
return IDENT_TTRIAL;
else
return IDENT_STD;
} // getIdent
*/

View File

@@ -0,0 +1,57 @@
// SuperTuxKart - a fun racing game with go-kart
// Copyright (C) 2004 SuperTuxKart-Team
//
// 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 _game_tutorial_hpp_
#define _game_tutorial_hpp_
#include "modes/linear_world.hpp"
//#include "states_screens/race_gui_base.hpp"
/**
* \brief An implementation of World, based on LinearWorld, to provide the tutorial game mode
* \ingroup modes
*/
class GameTutorial : public LinearWorld
{
protected:
// clock events
virtual bool isRaceOver();
private:
public:
GameTutorial();
virtual ~GameTutorial() {};
// clock events
/*virtual void countdownReachedZero();
// overriding World methods
/*
virtual void restartRace();
virtual std::string getIdent() const;
float getClockStartTime();
virtual bool useFastMusicNearEnd() const { return false; }
virtual RaceGUIBase::KartIconDisplayInfo* getKartsDisplayInfo();
virtual bool isRaceOver();
virtual bool raceHasLaps(){ return false; }
*/
};
#endif

View File

@@ -226,10 +226,10 @@ void MainMenuScreen::eventCallback(Widget* widget, const std::string& name, cons
{
StateManager::get()->pushScreen(ChallengesScreen::getInstance());
}
else if (selection == "tutorial")
{
//FIXME missing atm! StateManager::get()->pushScreen(TutorialScreen::getInstance());
}
else if (selection == "tutorial")
{
StateManager::get()->pushScreen(TutorialScreen::getInstance());
}
#ifdef ADDONS_MANAGER
else if (selection == "addons")
{

View File

@@ -1,5 +1,5 @@
// SuperTuxKart - a fun racing game with go-kart
// Copyright (C) 2009 Marianne Gagnon
// 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
@@ -46,7 +46,6 @@ DEFINE_SCREEN_SINGLETON( TutorialScreen );
TutorialScreen::TutorialScreen() : Screen("tutorial.stkgui")
{
}
// ------------------------------------------------------------------------------------------------------

View File

@@ -1,5 +1,5 @@
// SuperTuxKart - a fun racing game with go-kart
// Copyright (C) 2009 Alejandro Santiago
// 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

View File

@@ -0,0 +1,2 @@
#include "tutorial.hpp"

124
src/tutorial/tutorial.hpp Normal file
View File

@@ -0,0 +1,124 @@
// 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 <irrlicht.h>
// SuperTuxKart includes
#include "utils/no_copy.hpp"
using namespace std; // To avoid using std:: all the time
class XMLNode;
enum REWARD_TYPE
{UNLOCK_TRACK,
UNLOCK_GP,
UNLOCK_MODE,
UNLOCK_KART,
UNLOCK_DIFFICULTY};
struct UnlockableFeature
{
string name; // internal name
irr::core::stringw user_name; // not all types of feature have one
REWARD_TYPE type;
const irr::core::stringw getUnlockedMessage() const;
};
/**
* \brief A class for all tutorials
* \ingroup challenges
*/
class Tutorial : public NoCopy
{
private:
enum {CH_INACTIVE, // challenge not yet possible
CH_ACTIVE, // challenge possible, but not yet solved
CH_SOLVED} m_state; // challenge was solved
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_challenge_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 string &id, const string &name);
Tutorial() {m_Id=""; m_Name="";m_state=CH_INACTIVE;}
virtual ~Tutorial() {};
const string &getId() const { return m_Id; }
const irr::core::stringw &getName() const { return m_Name; }
void setName(const irr::core::stringw & s) { m_Name = s; }
void setId(const string& s) { m_Id = s; }
void addUnlockTrackReward(const string &track_name);
void addUnlockModeReward(const string &internal_mode_name,
const irr::core::stringw &user_mode_name);
void addUnlockGPReward(const string &gp_name);
void addUnlockDifficultyReward(const string &internal_name,
const irr::core::stringw &user_name);
void addUnlockKartReward(const string &internal_name,
const irr::core::stringw &user_name);
const vector<UnlockableFeature>&
getFeatures() const { return m_feature; }
void setChallengeDescription(const irr::core::stringw& d)
{m_challenge_description=d; }
const irr::core::stringw&
getChallengeDescription() const {return m_challenge_description; }
void addDependency(const string id) {m_prerequisites.push_back(id); }
bool isSolved() const {return m_state==CH_SOLVED; }
bool isActive() const {return m_state==CH_ACTIVE; }
void setSolved() {m_state = CH_SOLVED; }
void setActive() {m_state = CH_ACTIVE; }
const vector<string>&
getPrerequisites() const {return m_prerequisites; }
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 challenge
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

View File

@@ -0,0 +1,11 @@
#include "tutorial_manager.hpp"
TutorialManager::TutorialManager()
{
//ctor
}
TutorialManager::~TutorialManager()
{
//dtor
}

View File

@@ -0,0 +1,83 @@
// 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 "utils/no_copy.hpp"
#include <fstream>
class XMLNode;
class SFXBase;
using namespace std;
/**
* \brief main class to handle the tutorials list
* \ingroup tutorial
*/
class TutorialManager : public NoCopy
{
private:
SFXBase *m_locked_sound;
typedef map<string, Tutorial*> AllChallengesType;
AllChallengesType m_all_tutorial;
map<string, bool> m_locked_tutorials;
vector<const Tutorial*> m_unlocked_tutorials;
void computeActive ();
void load ();
void unlockFeature (Tutorial* t, bool do_save=true);
public:
TutorialManager ();
~TutorialManager ();
void addTutorial (Tutorial *t);
void addTutorial (const string& filename);
void save ();
vector<const Tutorial*> getActiveTutorials();
/** Returns the list of recently unlocked features (e.g. call at the end of a
race to know if any features were unlocked) */
const vector<const Tutorial*> getRecentlyUnlockedFeatures() {return m_unlocked_tutorials;}
/** Clear the list of recently unlocked challenges */
void clearUnlocked () {m_unlocked_tutorials.clear(); }
/** Returns a complete list of all solved challenges */
const vector<const Tutorial*> getUnlockedTutorials();
/** Returns the list of currently inaccessible (locked) challenges */
const vector<const Tutorial*> getLockedTutorials();
const Tutorial *getTutorial (const string& id);
void raceFinished ();
void grandPrixFinished ();
void lockFeature (Tutorial* tutorial);
bool isLocked (const string& feature);
/** Eye- (or rather ear-) candy. Play a sound when user tries to access a locked area */
void playLockSound() const;
}; // UnlockManager
//extern UnlockManager* unlock_manager;
#endif // TUTORIALMANAGER_H