From d6490dc48c719e5c747db939c030dd470c7e7488 Mon Sep 17 00:00:00 2001 From: hikerstk Date: Tue, 29 Jul 2008 04:45:28 +0000 Subject: [PATCH] Missing updates in previous commit. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@2189 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- data/followtheleader.challenge | 17 ++ src/challenges/challenge.cpp | 23 ++- src/challenges/challenge.hpp | 12 +- src/challenges/challenge_data.cpp | 252 +++++++++++++++++++++++ src/challenges/challenge_data.hpp | 57 +++++ src/challenges/city_time.cpp | 53 ----- src/challenges/city_time.hpp | 37 ---- src/challenges/energy_math_class.cpp | 55 ----- src/challenges/energy_math_class.hpp | 36 ---- src/challenges/energy_shifting_sands.cpp | 58 ------ src/challenges/energy_shifting_sands.hpp | 36 ---- src/challenges/island_follow.cpp | 60 ------ src/challenges/island_follow.hpp | 34 --- src/challenges/jungle_follow.cpp | 59 ------ src/challenges/jungle_follow.hpp | 33 --- src/challenges/moon_and_back_gp.cpp | 64 ------ src/challenges/moon_and_back_gp.hpp | 36 ---- src/challenges/race_track_time.cpp | 54 ----- src/challenges/race_track_time.hpp | 36 ---- src/challenges/tollway_head2head.cpp | 57 ----- src/challenges/tollway_head2head.hpp | 35 ---- src/challenges/tollway_time.cpp | 53 ----- src/challenges/tollway_time.hpp | 36 ---- src/gui/char_sel.cpp | 101 ++++----- src/gui/game_mode.cpp | 18 +- src/gui/grand_prix_select.cpp | 53 +++-- src/gui/grand_prix_select.hpp | 12 +- src/gui/help_page_one.cpp | 2 +- 28 files changed, 446 insertions(+), 933 deletions(-) create mode 100644 data/followtheleader.challenge create mode 100755 src/challenges/challenge_data.cpp create mode 100755 src/challenges/challenge_data.hpp delete mode 100644 src/challenges/city_time.cpp delete mode 100644 src/challenges/city_time.hpp delete mode 100755 src/challenges/energy_math_class.cpp delete mode 100755 src/challenges/energy_math_class.hpp delete mode 100644 src/challenges/energy_shifting_sands.cpp delete mode 100644 src/challenges/energy_shifting_sands.hpp delete mode 100644 src/challenges/island_follow.cpp delete mode 100644 src/challenges/island_follow.hpp delete mode 100644 src/challenges/jungle_follow.cpp delete mode 100644 src/challenges/jungle_follow.hpp delete mode 100644 src/challenges/moon_and_back_gp.cpp delete mode 100644 src/challenges/moon_and_back_gp.hpp delete mode 100755 src/challenges/race_track_time.cpp delete mode 100755 src/challenges/race_track_time.hpp delete mode 100644 src/challenges/tollway_head2head.cpp delete mode 100644 src/challenges/tollway_head2head.hpp delete mode 100644 src/challenges/tollway_time.cpp delete mode 100644 src/challenges/tollway_time.hpp diff --git a/data/followtheleader.challenge b/data/followtheleader.challenge new file mode 100644 index 000000000..99416bfb5 --- /dev/null +++ b/data/followtheleader.challenge @@ -0,0 +1,17 @@ +;; -*- mode: lisp -*- + +(challenge + (id "penguinplaygroundgp") + (name _("Win Penguin Playground Grand\nPrix")) + (description _("Win Penguin Playground Grand\nPrix with 3 'Racer' Level AI karts.")) + (unlock-mode "followtheleader" _("Follow the Leader")) + (major "grandprix") + (minor "quickrace") + (gp "penguinplayground") + (difficulty "hard") + (karts 4) + (position 1) +) + +;; EOF ;; + diff --git a/src/challenges/challenge.cpp b/src/challenges/challenge.cpp index 6679804de..5d8683459 100755 --- a/src/challenges/challenge.cpp +++ b/src/challenges/challenge.cpp @@ -22,6 +22,8 @@ #include "world.hpp" #include "race_manager.hpp" #include "track_manager.hpp" +#include "kart_properties_manager.hpp" + #if defined(WIN32) && !defined(__CYGWIN__) # define snprintf _snprintf #endif @@ -93,6 +95,15 @@ void Challenge::addUnlockDifficultyReward(std::string internal_name, std::string m_feature.push_back(feature); } //----------------------------------------------------------------------------- +void Challenge::addUnlockKartReward(std::string internal_name, std::string user_name) +{ + UnlockableFeature feature; + feature.name = internal_name; + feature.type = UNLOCK_KART; + feature.user_name = user_name; + m_feature.push_back(feature); +} +//----------------------------------------------------------------------------- const std::string Challenge::getUnlockedMessage() const { std::string unlocked_message; @@ -109,10 +120,10 @@ const std::string Challenge::getUnlockedMessage() const switch(m_feature[n].type) { case UNLOCK_TRACK: - { + { // {} avoids compiler warning Track* track = track_manager->getTrack( m_feature[n].name ); snprintf(message, 127, _("New track '%s'\nnow available"), _(track->getName()) ); - break; + break; } case UNLOCK_MODE: snprintf(message, 127, _("New game mode\n'%s'\nnow available"), m_feature[n].user_name.c_str() ); @@ -123,9 +134,13 @@ const std::string Challenge::getUnlockedMessage() const case UNLOCK_DIFFICULTY: snprintf(message, 127, _("New difficulty\n'%s'\nnow available"), m_feature[n].user_name.c_str() ); break; - } + case UNLOCK_KART: + const KartProperties *kp=kart_properties_manager->getKart(m_feature[n].name ); + snprintf(message, 127, _("New kart\n'%s'\nnow available"), kp->getName()); + break; + } // switch unlocked_message += message; - } + } // for n return unlocked_message; } diff --git a/src/challenges/challenge.hpp b/src/challenges/challenge.hpp index 1aa014b87..5dbad6cac 100755 --- a/src/challenges/challenge.hpp +++ b/src/challenges/challenge.hpp @@ -31,6 +31,7 @@ enum REWARD_TYPE {UNLOCK_TRACK, UNLOCK_GP, UNLOCK_MODE, + UNLOCK_KART, UNLOCK_DIFFICULTY}; struct UnlockableFeature @@ -53,18 +54,21 @@ class Challenge std::vector m_prerequisites; // what needs to be done before accessing this challenge public: Challenge(std::string id, std::string name); + Challenge() {m_Id=""; m_Name="";} virtual ~Challenge() {}; - const std::string& getId() const {return m_Id; } - const std::string& getName() const {return m_Name; } - + const std::string& getId() const { return m_Id; } + const std::string& getName() const { return m_Name; } + void setName(const std::string& s) { m_Name = s; } + void setId(const std::string& s) { m_Id = s; } void addUnlockTrackReward(std::string track_name); void addUnlockModeReward(std::string internal_mode_name, std::string user_mode_name); void addUnlockGPReward(std::string gp_name); void addUnlockDifficultyReward(std::string internal_name, std::string user_name); + void addUnlockKartReward(std::string internal_name, std::string user_name); const std::string getUnlockedMessage() const; const std::vector& - getFeatures() const {return m_feature; } + getFeatures() const { return m_feature; } void setChallengeDescription(const std::string& d) {m_challenge_description=d; } const std::string& diff --git a/src/challenges/challenge_data.cpp b/src/challenges/challenge_data.cpp new file mode 100755 index 000000000..c7e4c4645 --- /dev/null +++ b/src/challenges/challenge_data.cpp @@ -0,0 +1,252 @@ +// $Id: challenge_data.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 + +#include "challenges/challenge_data.hpp" +#include "lisp/lisp.hpp" +#include "lisp/parser.hpp" +#include "translation.hpp" +#include "world.hpp" +#include "cup_data.hpp" +#include "grand_prix_manager.hpp" + +#if defined(WIN32) && !defined(__CYGWIN__) +# define snprintf _snprintf +#endif + + +ChallengeData::ChallengeData(const std::string& filename) +{ + m_filename = filename; + m_major = RaceManager::RM_SINGLE; + m_minor = RaceManager::RM_SINGLE; + m_difficulty = RaceManager::RD_EASY; + m_num_laps = -1; + m_num_karts = -1; + + m_time = -1.0f; + m_track_name = ""; + m_gp_id = ""; + m_energy = -1; + + lisp::Parser parser; + const lisp::Lisp* const ROOT = parser.parse(filename); + + const lisp::Lisp* const lisp = ROOT->getLisp("challenge"); + if(!lisp) + { + delete ROOT; + char msg[MAX_ERROR_MESSAGE_LENGTH]; + snprintf(msg, sizeof(msg), + "Couldn't load challenge '%s': no challenge node.", + filename.c_str()); + throw std::runtime_error(msg); + } + + std::string mode; + lisp->get("major", mode); + + if(mode=="grandprix") + m_major = RaceManager::RM_GRAND_PRIX; + else if(mode=="single") + m_major = RaceManager::RM_SINGLE; + else + error("major"); + + lisp->get ("minor", mode); + if(mode=="timetrial") + m_minor = RaceManager::RM_TIME_TRIAL; + else if(mode=="quickrace") + m_minor = RaceManager::RM_QUICK_RACE; + else if(mode=="followtheleader") + m_minor = RaceManager::RM_FOLLOW_LEADER; + else + error("minor"); + std::string s; + if(!lisp->get("name", s) ) error("name"); + setName(s); + if(!lisp->get("id", s) ) error("id"); + setId(s); + if(!lisp->get("description", s) ) error("description"); + setChallengeDescription(s); + if(!lisp->get("karts", m_num_karts) ) error("karts"); + // Position is optional except in GP and FTL + if(!lisp->get("position", m_position) && + (m_minor==RaceManager::RM_FOLLOW_LEADER || + m_major==RaceManager::RM_GRAND_PRIX)) + error("position"); + lisp->get("difficulty", s); + if(s=="easy") + m_difficulty = RaceManager::RD_EASY; + else if(s=="medium") + m_difficulty = RaceManager::RD_MEDIUM; + else if(s=="hard") + m_difficulty = RaceManager::RD_HARD; + else + error("difficulty"); + + lisp->get("time", m_time ); // one of time/position + lisp->get("position", m_position ); // must be set + if(m_time<0 && m_position<0) error("position/time"); + lisp->get("energy", m_energy ); // This is optional + if(m_major==RaceManager::RM_SINGLE) + { + if(!lisp->get("track", m_track_name )) error("track"); + if(!lisp->get("laps", m_num_laps ) && + m_minor!=RaceManager::RM_FOLLOW_LEADER) + error("laps"); + } + else // GP + { + if(!lisp->get("gp", m_gp_id )) error("gp"); + } + + getUnlocks(lisp, "unlock-track", UNLOCK_TRACK); + getUnlocks(lisp, "unlock-gp", UNLOCK_GP ); + getUnlocks(lisp, "unlock-mode", UNLOCK_MODE ); + getUnlocks(lisp, "unlock-difficulty", UNLOCK_DIFFICULTY); + getUnlocks(lisp, "unlock-kart", UNLOCK_KART); + + std::vector vec; + lisp->getVector("depend-on", vec); + for(unsigned int i=0; i v; + v.clear(); + + lisp->getVector(type, v); + for(unsigned int i=0; isetMajorMode(m_major); + if(m_major==RaceManager::RM_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->setNumPlayers(1); + } + else // GP + { + race_manager->setMinorMode(m_minor); + const CupData *cup = grand_prix_manager->getCup(m_gp_id); + race_manager->setGrandPrix(*cup); + race_manager->setDifficulty(m_difficulty); + race_manager->setNumKarts(m_num_karts); + race_manager->setNumPlayers(1); + //race_manager->setGrandPrix(); + } +} // setRace + +// ---------------------------------------------------------------------------- +bool ChallengeData::raceFinished() +{ + // GP's use the grandPrixFinished() function, so they can't be fulfilled here. + if(m_major==RaceManager::RM_GRAND_PRIX) return false; + + // Single races + // ------------ + std::string track_name = world->getTrack()->getIdent(); + if(track_name!=m_track_name ) return false; // wrong track + if((int)race_manager->getNumKarts()getPlayerKart(0); + if(m_energy>0 && kart->getNumHerring()0 && kart->getPosition()>m_position) return false; // too far behind + + // Follow the leader + // ----------------- + if(m_minor==RaceManager::RM_FOLLOW_LEADER) + { + // All possible conditions were already checked, so: must have been successful + return true; + } + // Quickrace / Timetrial + // --------------------- + if(kart->getLap()!=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 ChallengeData::grandPrixFinished() +{ + if (race_manager->getMajorMode() != RaceManager::RM_GRAND_PRIX || + race_manager->getMinorMode() != m_minor || + race_manager->getGrandPrix()->getId() != m_gp_id || + race_manager->getDifficulty()!= m_difficulty || + race_manager->getNumKarts() < (unsigned int)m_num_karts || + race_manager->getNumPlayers() > 1) return false; + + Kart* kart=world->getPlayerKart(0); + if(kart->getPosition()>m_position) return false; + return true; +} // grandPrixFinished \ No newline at end of file diff --git a/src/challenges/challenge_data.hpp b/src/challenges/challenge_data.hpp new file mode 100755 index 000000000..7d999c036 --- /dev/null +++ b/src/challenges/challenge_data.hpp @@ -0,0 +1,57 @@ +// $Id: challenge_data.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_CHALLENGE_DATA_H +#define HEADER_CHALLENGE_DATA_H + +#include +#include +#include + +#include "challenges/challenge.hpp" +#include "race_manager.hpp" + +class ChallengeData : public Challenge +{ +private: + RaceManager::RaceModeType m_major; + RaceManager::RaceModeType 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::vector m_depends_on; + std::vector m_unlock; + + std::string m_filename; + void getUnlocks(const lisp::Lisp *lisp, const char* type, REWARD_TYPE reward); + void error(const char *id); + +public: + ChallengeData(const std::string& filename); + void setRace() const; + virtual bool raceFinished(); + virtual bool grandPrixFinished(); +}; // ChallengeData + +#endif diff --git a/src/challenges/city_time.cpp b/src/challenges/city_time.cpp deleted file mode 100644 index 8f915d1fd..000000000 --- a/src/challenges/city_time.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// $Id$ -// -// 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 ruseful, -// 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 "translation.hpp" -#include "challenges/city_time.hpp" -#include "world.hpp" -#include "race_manager.hpp" - -CityTime::CityTime() : Challenge("citytime", _("Finish the City track in 5:20")) -{ - setChallengeDescription(_("Finish 3 laps on the City track\nwith 3 AI karts\nin under 5:20 minutes.")); - addUnlockTrackReward("snowtuxpeak"); - addDependency("junglefollow"); -} // CityTime -//----------------------------------------------------------------------------- -void CityTime::setRace() const { - race_manager->setMajorMode(RaceManager::RM_SINGLE); - race_manager->setMinorMode(RaceManager::RM_QUICK_RACE); - race_manager->setTrack("city"); - race_manager->setDifficulty(RaceManager::RD_EASY); - race_manager->setNumLaps(3); - race_manager->setNumKarts(4); - race_manager->setNumPlayers(1); -} // setRace - -//----------------------------------------------------------------------------- -bool CityTime::raceFinished() -{ - std::string track_name = world->getTrack()->getIdent(); - if(track_name!="city" ) return false; // wrong track - Kart* kart=world->getPlayerKart(0); - if(kart->getFinishTime()>320) return false; // too slow - if(kart->getLap()!=3 ) return false; // wrong number of laps - if(race_manager->getNumKarts()<4) return false; //not enough AI karts - return true; -} // raceFinished -//----------------------------------------------------------------------------- diff --git a/src/challenges/city_time.hpp b/src/challenges/city_time.hpp deleted file mode 100644 index 1b6b548c4..000000000 --- a/src/challenges/city_time.hpp +++ /dev/null @@ -1,37 +0,0 @@ -// $Id$ -// -// 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 CITY_TIME_H -#define CITY_TIME_H - - -#include "challenges/challenge.hpp" - -class CityTime : public Challenge -{ -public: - CityTime(); - virtual bool raceFinished(); - virtual void setRace() const; -}; // CityTime - - - - -#endif /*CITY_TIME_H*/ diff --git a/src/challenges/energy_math_class.cpp b/src/challenges/energy_math_class.cpp deleted file mode 100755 index 7c21148be..000000000 --- a/src/challenges/energy_math_class.cpp +++ /dev/null @@ -1,55 +0,0 @@ -// $Id: energy_math_class.cpp 1259 2007-09-24 12:28:19Z hiker $ -// -// 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 ruseful, -// 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 -#include "translation.hpp" -#include "challenges/energy_math_class.hpp" -#include "race_manager.hpp" -#include "world.hpp" - -EnergyMathClass::EnergyMathClass() : Challenge("energymathclass", _("Collect Coins in Math Class")) -{ - setChallengeDescription(_("Collect at least 6 points\nworth of coins\non three laps of\nOliver's Math Class\nin under 1 minute.")); - addUnlockTrackReward("crescentcrossing"); -} // EnergyMathClass - -//----------------------------------------------------------------------------- -void EnergyMathClass::setRace() const { - race_manager->setMajorMode(RaceManager::RM_SINGLE); - race_manager->setMajorMode(RaceManager::RM_QUICK_RACE); - race_manager->setTrack("olivermath"); - race_manager->setDifficulty(RaceManager::RD_EASY); - race_manager->setNumLaps(3); - race_manager->setNumKarts(1); - race_manager->setNumPlayers(1); - race_manager->setCoinTarget(6); -} // setRace -\ -//----------------------------------------------------------------------------- -bool EnergyMathClass::raceFinished() -{ - std::string track_name = world->getTrack()->getIdent(); - if(track_name!="olivermath") return false; // wrong track - Kart* kart=world->getPlayerKart(0); - if(kart->getFinishTime()>60) return false; // too slow - if(kart->getLap()!=3 ) return false; // wrong number of laps - if(kart->getNumHerring()<6 ) return false; // not enough herrings - return true; -} // raceFinished -//----------------------------------------------------------------------------- diff --git a/src/challenges/energy_math_class.hpp b/src/challenges/energy_math_class.hpp deleted file mode 100755 index 22fcee607..000000000 --- a/src/challenges/energy_math_class.hpp +++ /dev/null @@ -1,36 +0,0 @@ -// $Id: energy_math_class.hpp 1259 2007-09-24 12:28:19Z hiker $ -// -// 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_ENERGY_MATH_CLASS_H -#define HEADER_ENERGY_MATH_CLASS_H - -#include -#include - -#include "challenges/challenge.hpp" - -class EnergyMathClass : public Challenge -{ -public: - EnergyMathClass(); - virtual bool raceFinished(); - virtual void setRace() const; -}; // EnergyMathClass - -#endif diff --git a/src/challenges/energy_shifting_sands.cpp b/src/challenges/energy_shifting_sands.cpp deleted file mode 100644 index 6672317e7..000000000 --- a/src/challenges/energy_shifting_sands.cpp +++ /dev/null @@ -1,58 +0,0 @@ -// $Id$ -// -// 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 ruseful, -// 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 "translation.hpp" -#include "challenges/energy_shifting_sands.hpp" -#include "race_manager.hpp" -#include "world.hpp" - -EnergyShiftingSands::EnergyShiftingSands() : Challenge("energyshiftingsands", _("Collect the Pharaohs Treasure")) -{ - setChallengeDescription(_("Collect at least 9 coins\non 3 laps of Shifting Sands\nin under 2:20 minutes.")); - addUnlockGPReward("To the Moon and Back"); - // The energymathclass challenge must be done, otherwise GP can't be selected - addDependency("energymathclass"); - addDependency("racetracktime"); -} - -//----------------------------------------------------------------------------- -void EnergyShiftingSands::setRace() const { - race_manager->setMajorMode(RaceManager::RM_SINGLE); - race_manager->setMinorMode(RaceManager::RM_QUICK_RACE); - race_manager->setTrack("sandtrack"); - race_manager->setDifficulty(RaceManager::RD_EASY); - race_manager->setNumLaps(3); - race_manager->setNumKarts(1); - race_manager->setNumPlayers(1); - race_manager->setCoinTarget(9); -} // setRace - -//----------------------------------------------------------------------------- -bool EnergyShiftingSands::raceFinished() -{ - std::string track_name = world->getTrack()->getIdent(); - if(track_name!="sandtrack") return false; // wrong track - Kart* kart=world->getPlayerKart(0); - if(kart->getFinishTime()>140) return false; // too slow - if(kart->getLap()!=3 ) return false; // wrong number of laps - if(kart->getNumHerring()<9 ) return false; // not enough herrings - return true; - -} // raceFinished -//----------------------------------------------------------------------------- diff --git a/src/challenges/energy_shifting_sands.hpp b/src/challenges/energy_shifting_sands.hpp deleted file mode 100644 index 1024cc059..000000000 --- a/src/challenges/energy_shifting_sands.hpp +++ /dev/null @@ -1,36 +0,0 @@ -// $Id$ -// -// 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 ENERGY_SHIFTING_SANDS_H -#define ENERGY_SHIFTING_SANDS_H - - -#include "challenges/challenge.hpp" - -class EnergyShiftingSands : public Challenge -{ -public: - EnergyShiftingSands(); - virtual bool raceFinished(); - virtual void setRace() const; - -}; - - -#endif /*ENERGY_SHIFTING_SANDS_H*/ diff --git a/src/challenges/island_follow.cpp b/src/challenges/island_follow.cpp deleted file mode 100644 index beb07bf21..000000000 --- a/src/challenges/island_follow.cpp +++ /dev/null @@ -1,60 +0,0 @@ -// $Id$ -// -// 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 ruseful, -// 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 "translation.hpp" -#include "challenges/island_follow.hpp" -#include "world.hpp" -#include "race_manager.hpp" - -IslandFollow::IslandFollow() : Challenge("islandfollow", _("Follow the Leader on a\nDesert Island")) -{ - setChallengeDescription(_("Win a Follow the Leader race\nwith 3 AI karts\non a Desert Island.")); - addUnlockGPReward("At world's end"); - addDependency("moonandbackgp"); - addDependency("tollwaytime"); - addDependency("citytime"); -} // IslandFollow - -//----------------------------------------------------------------------------- -void IslandFollow::setRace() const { - race_manager->setMajorMode(RaceManager::RM_SINGLE); - race_manager->setMinorMode(RaceManager::RM_FOLLOW_LEADER); - race_manager->setTrack("islandtrack"); - race_manager->setDifficulty(RaceManager::RD_EASY); - race_manager->setNumLaps(3); - race_manager->setNumKarts(4); - race_manager->setNumPlayers(1); -} // setRace - -//----------------------------------------------------------------------------- -bool IslandFollow::raceFinished() -{ - std::string track_name = world->getTrack()->getIdent(); - if(track_name!="islandtrack" ) return false; // wrong track - if(race_manager->getNumKarts()<4) return false; //not enough AI karts - //Check if player came first - for(int i=0; i<(int)race_manager->getNumKarts(); i++) - { - const Kart* k=world->getKart(i); - if(k->isPlayerKart()) return k->getPosition()==2; - } - return false; - -} // raceFinished -//----------------------------------------------------------------------------- diff --git a/src/challenges/island_follow.hpp b/src/challenges/island_follow.hpp deleted file mode 100644 index 9117560e0..000000000 --- a/src/challenges/island_follow.hpp +++ /dev/null @@ -1,34 +0,0 @@ -// $Id$ -// -// 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 ISLAND_FOLLOW_H -#define ISLAND_FOLLOW_H - -#include "challenges/challenge.hpp" - -class IslandFollow : public Challenge -{ -public: - IslandFollow(); - virtual bool raceFinished(); - virtual void setRace() const; -}; // IslandFollow - - -#endif /*ISLAND_FOLLOW_H*/ diff --git a/src/challenges/jungle_follow.cpp b/src/challenges/jungle_follow.cpp deleted file mode 100644 index 80766461e..000000000 --- a/src/challenges/jungle_follow.cpp +++ /dev/null @@ -1,59 +0,0 @@ -// $Id$ -// -// 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 ruseful, -// 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 "translation.hpp" -#include "challenges/jungle_follow.hpp" -#include "world.hpp" -#include "race_manager.hpp" - -JungleFollow::JungleFollow() : Challenge("junglefollow", _("Follow the Leader in the Jungle")) -{ - setChallengeDescription(_("Win a Follow the Leader race\nwith 3 AI karts\nin the Amazonian Jungle.")); - addUnlockTrackReward("city"); - addDependency("penguinplaygroundgp"); - addDependency("racetracktime"); -} // JungleFollow - -//----------------------------------------------------------------------------- -void JungleFollow::setRace() const { - race_manager->setMajorMode(RaceManager::RM_SINGLE); - race_manager->setMinorMode(RaceManager::RM_FOLLOW_LEADER); - race_manager->setTrack("jungle"); - race_manager->setDifficulty(RaceManager::RD_EASY); - race_manager->setNumLaps(3); - race_manager->setNumKarts(4); - race_manager->setNumPlayers(1); -} // setRace - -//----------------------------------------------------------------------------- -bool JungleFollow::raceFinished() -{ - std::string track_name = world->getTrack()->getIdent(); - if(track_name!="jungle" ) return false; // wrong track - if(race_manager->getNumKarts()<4) return false; //not enough AI karts - //Check if player came first - for(int i=0; i<(int)race_manager->getNumKarts(); i++) - { - const Kart* k=world->getKart(i); - if(k->isPlayerKart()) return k->getPosition()==2; - } - return false; - -} // raceFinished -//----------------------------------------------------------------------------- diff --git a/src/challenges/jungle_follow.hpp b/src/challenges/jungle_follow.hpp deleted file mode 100644 index 50c319a77..000000000 --- a/src/challenges/jungle_follow.hpp +++ /dev/null @@ -1,33 +0,0 @@ -// $Id$ -// -// 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 JUNGLE_FOLLOW_H -#define JUNGLE_FOLLOW_H - -#include "challenges/challenge.hpp" - -class JungleFollow : public Challenge -{ -public: - JungleFollow(); - virtual bool raceFinished(); - virtual void setRace() const; -}; // JungleFollow - -#endif /*JUNGLE_FOLLOW_H*/ diff --git a/src/challenges/moon_and_back_gp.cpp b/src/challenges/moon_and_back_gp.cpp deleted file mode 100644 index cea92a9bd..000000000 --- a/src/challenges/moon_and_back_gp.cpp +++ /dev/null @@ -1,64 +0,0 @@ -// $Id$ -// -// 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 ruseful, -// 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 "translation.hpp" -#include "challenges/moon_and_back_gp.hpp" -#include "race_manager.hpp" -#include "world.hpp" - -MoonAndBackGP::MoonAndBackGP() : Challenge("moonandbackgp",_("Win To the Moon and Back\nGrand Prix")) -{ - setChallengeDescription(_("Win the To the Moon and Back\nGrand Prix with 3 'Racer'\nLevel AI karts.")); - addUnlockGPReward("Snag Drive"); - // The energyshiftingsands challenge must be done, otherwise gp2 can't be selected - // Thejunglefollow challenge must be done, to get city for gp3 - addDependency("energyshiftingsands"); - addDependency("junglefollow"); -} - -//----------------------------------------------------------------------------- -void MoonAndBackGP::setRace() const { - race_manager->setMajorMode(RaceManager::RM_GRAND_PRIX); - race_manager->setMinorMode(RaceManager::RM_QUICK_RACE); - CupData cup("gp2.cup"); - race_manager->setGrandPrix(cup); - race_manager->setDifficulty(RaceManager::RD_HARD); - race_manager->setNumKarts(4); - race_manager->setNumPlayers(1); -} // setRace - -//----------------------------------------------------------------------------- -bool MoonAndBackGP::grandPrixFinished() -{ - if (race_manager->getMajorMode() != RaceManager::RM_GRAND_PRIX || - race_manager->getMinorMode() != RaceManager::RM_QUICK_RACE || - race_manager->getGrandPrix()->getName() != _("To the Moon and Back") || - race_manager->getDifficulty()!= RaceManager::RD_HARD || - race_manager->getNumKarts() < 4 || - race_manager->getNumPlayers() > 1) return false; - // Check if the player was in top 3: - for(int i=0; i<(int)race_manager->getNumKarts(); i++) - { - const Kart* k=world->getKart(i); - if(k->isPlayerKart() && !k->isEliminated()) return k->getPosition()==1; - } - return false; - -} // grandPrixFinished -//----------------------------------------------------------------------------- diff --git a/src/challenges/moon_and_back_gp.hpp b/src/challenges/moon_and_back_gp.hpp deleted file mode 100644 index 77b18d9b5..000000000 --- a/src/challenges/moon_and_back_gp.hpp +++ /dev/null @@ -1,36 +0,0 @@ -// $Id$ -// -// 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 MOON_AND_BACK_GP_H -#define MOON_AND_BACK_GP_H - - -#include "challenges/challenge.hpp" - -class MoonAndBackGP : public Challenge -{ -public: - MoonAndBackGP(); - virtual bool grandPrixFinished(); - virtual void setRace() const; - -}; - - -#endif /*MOON_AND_BACK_GP_H*/ diff --git a/src/challenges/race_track_time.cpp b/src/challenges/race_track_time.cpp deleted file mode 100755 index f4e12d63f..000000000 --- a/src/challenges/race_track_time.cpp +++ /dev/null @@ -1,54 +0,0 @@ -// $Id: race_track_time.cpp 1259 2007-09-24 12:28:19Z hiker $ -// -// 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 ruseful, -// 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 -#include "translation.hpp" -#include "challenges/race_track_time.hpp" -#include "world.hpp" -#include "race_manager.hpp" - -RaceTrackTime::RaceTrackTime() : Challenge("racetracktime", _("Finish Race track in 1:15")) -{ - setChallengeDescription(_("Finish 3 laps in the Race track\nwith 3 AI karts\nin under 1:15 minutes.")); - addUnlockTrackReward("jungle"); -} // RaceTrackTime - -//----------------------------------------------------------------------------- -void RaceTrackTime::setRace() const { - race_manager->setMajorMode(RaceManager::RM_SINGLE); - race_manager->setMinorMode(RaceManager::RM_QUICK_RACE); - race_manager->setTrack("race"); - race_manager->setDifficulty(RaceManager::RD_EASY); - race_manager->setNumLaps(3); - race_manager->setNumKarts(4); - race_manager->setNumPlayers(1); -} // setRace - -//----------------------------------------------------------------------------- -bool RaceTrackTime::raceFinished() -{ - std::string track_name = world->getTrack()->getIdent(); - if(track_name!="race" ) return false; // wrong track - Kart* kart=world->getPlayerKart(0); - if(kart->getFinishTime()>75) return false; // too slow - if(kart->getLap()!=3 ) return false; // wrong number of laps - if(race_manager->getNumKarts()<4) return false; //not enough AI karts - return true; -} // raceFinished -//----------------------------------------------------------------------------- diff --git a/src/challenges/race_track_time.hpp b/src/challenges/race_track_time.hpp deleted file mode 100755 index 2e52b7a2f..000000000 --- a/src/challenges/race_track_time.hpp +++ /dev/null @@ -1,36 +0,0 @@ -// $Id: race_track_time.hpp 1259 2007-09-24 12:28:19Z hiker $ -// -// 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_RACE_TRACK_TIME_H -#define HEADER_RACE_TRACK_TIME_H - -#include -#include - -#include "challenges/challenge.hpp" - -class RaceTrackTime : public Challenge -{ -public: - RaceTrackTime(); - virtual bool raceFinished(); - virtual void setRace() const; -}; // RaceTrackTime - -#endif diff --git a/src/challenges/tollway_head2head.cpp b/src/challenges/tollway_head2head.cpp deleted file mode 100644 index 6556d03b1..000000000 --- a/src/challenges/tollway_head2head.cpp +++ /dev/null @@ -1,57 +0,0 @@ -// $Id$ -// -// 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 ruseful, -// 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 "translation.hpp" -#include "tollway_head2head.hpp" -#include "world.hpp" -#include "race_manager.hpp" - -TollwayHead2Head::TollwayHead2Head() : Challenge("tollwayhead", _("Win a Head to Head on\nTux Tollway")) -{ - setChallengeDescription(_("Win a 1 lap Head to Head\non Tux Tollway against 1 'Racer'\nlevel AI kart.")); - addUnlockTrackReward("fortmagma"); -} - -//----------------------------------------------------------------------------- -void TollwayHead2Head::setRace() const { - race_manager->setMajorMode(RaceManager::RM_SINGLE); - race_manager->setMinorMode(RaceManager::RM_TIME_TRIAL); - race_manager->setTrack("tuxtrack"); - race_manager->setDifficulty(RaceManager::RD_HARD); - race_manager->setNumLaps(1); - race_manager->setNumKarts(2); - race_manager->setNumPlayers(1); -} // setRace - -//----------------------------------------------------------------------------- -bool TollwayHead2Head::raceFinished() -{ - std::string track_name = world->getTrack()->getIdent(); - if(track_name!="tuxtrack" ) return false; // wrong track - Kart* kart=world->getPlayerKart(0); - if(kart->getLap()!=1 ) return false; // wrong number of laps - if(race_manager->getNumKarts()!=2 ) return false; //wrong number of AI karts - // Check if the player was first: - for(int i=0; i<(int)race_manager->getNumKarts(); i++) - { - const Kart* k=world->getKart(i); - if(k->isPlayerKart() && !k->isEliminated()) return k->getPosition()==1; - } - return false; -} // raceFinished diff --git a/src/challenges/tollway_head2head.hpp b/src/challenges/tollway_head2head.hpp deleted file mode 100644 index 2fb2a4e40..000000000 --- a/src/challenges/tollway_head2head.hpp +++ /dev/null @@ -1,35 +0,0 @@ -// $Id$ -// -// 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 TOLLWAY_HEAD2HEAD_H -#define TOLLWAY_HEAD2HEAD_H - - -#include "challenge.hpp" - -class TollwayHead2Head : public Challenge -{ -public: - TollwayHead2Head(); - virtual bool raceFinished(); - virtual void setRace() const; -}; // TollwayHead2Head - - -#endif /*TOLLWAY_HEAD2HHEAD*/ diff --git a/src/challenges/tollway_time.cpp b/src/challenges/tollway_time.cpp deleted file mode 100644 index b93987211..000000000 --- a/src/challenges/tollway_time.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// $Id$ -// -// 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 ruseful, -// 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 "translation.hpp" -#include "challenges/tollway_time.hpp" -#include "world.hpp" -#include "race_manager.hpp" - -TollwayTime::TollwayTime() : Challenge("tollwaytime", _("Finish Tux Tollway track in 3:00")) -{ - setChallengeDescription(_("Finish 3 laps on the Tux Tollway\ntrack with 3 AI karts\nin under 3:00 minutes.")); - addUnlockTrackReward("canyon"); -} // TollwayTime - -//----------------------------------------------------------------------------- -void TollwayTime::setRace() const { - race_manager->setMajorMode(RaceManager::RM_SINGLE); - race_manager->setMinorMode(RaceManager::RM_QUICK_RACE); - race_manager->setTrack("tuxtrack"); - race_manager->setDifficulty(RaceManager::RD_EASY); - race_manager->setNumLaps(3); - race_manager->setNumKarts(4); - race_manager->setNumPlayers(1); -} // setRace - -//----------------------------------------------------------------------------- -bool TollwayTime::raceFinished() -{ - std::string track_name = world->getTrack()->getIdent(); - if(track_name!="tuxtrack" ) return false; // wrong track - Kart* kart=world->getPlayerKart(0); - if(kart->getFinishTime()>180) return false; // too slow - if(kart->getLap()!=3 ) return false; // wrong number of laps - if(race_manager->getNumKarts()<4) return false; //not enough AI karts - return true; -} // raceFinished -//----------------------------------------------------------------------------- diff --git a/src/challenges/tollway_time.hpp b/src/challenges/tollway_time.hpp deleted file mode 100644 index d53a4e688..000000000 --- a/src/challenges/tollway_time.hpp +++ /dev/null @@ -1,36 +0,0 @@ -// $Id$ -// -// 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 TOLLWAY_TIME_H -#define TOLLWAY_TIME_H -#include -#include - -#include "challenges/challenge.hpp" - -class TollwayTime : public Challenge -{ -public: - TollwayTime(); - virtual bool raceFinished(); - virtual void setRace() const; -}; // TollwayTime - - -#endif /*TOLLWAY_TIME_H*/ diff --git a/src/gui/char_sel.cpp b/src/gui/char_sel.cpp index 04336ab2c..f4a7b6d32 100644 --- a/src/gui/char_sel.cpp +++ b/src/gui/char_sel.cpp @@ -149,30 +149,30 @@ CharSel::~CharSel() //----------------------------------------------------------------------------- void CharSel::updateScrollPosition() { - // Handle the special case of less karts (plus groups) than widgets. - // Some of the widgets then need to be disabled. - unsigned int start = 0, end=m_max_entries; - if(m_index_avail_karts.size()end) { - start = (unsigned int)(m_max_entries-m_index_avail_karts.size()+1)/2; - end = start+m_index_avail_karts.size()-1; + widget_manager->hideWgtRect (WTOK_NAME0 +i); + widget_manager->hideWgtRect (WTOK_RACER0+i); + widget_manager->hideWgtText (WTOK_NAME0 +i); + widget_manager->hideWgtTexture(WTOK_RACER0+i); + continue; } - for(unsigned int i=0; iend) - { - widget_manager->hideWgtRect (WTOK_NAME0 +i); - widget_manager->hideWgtRect (WTOK_RACER0+i); - widget_manager->hideWgtText (WTOK_NAME0 +i); - widget_manager->hideWgtTexture(WTOK_RACER0+i); - continue; - } - - // Otherwise enable the widgets again (just in case that they - // had been disabled before) - widget_manager->showWgtRect (WTOK_NAME0 +i); - widget_manager->showWgtText (WTOK_NAME0 +i); + // Otherwise enable the widgets again (just in case that they + // had been disabled before) + widget_manager->showWgtRect (WTOK_NAME0 +i); + widget_manager->showWgtText (WTOK_NAME0 +i); int indx = (i+m_offset)%m_index_avail_karts.size(); indx = m_index_avail_karts[indx]; @@ -183,15 +183,15 @@ void CharSel::updateScrollPosition() if(unlock_manager->isLocked(kp->getIdent())) continue; widget_manager->setWgtText(WTOK_NAME0 + i, kp->getName()); widget_manager->setWgtTexture(WTOK_RACER0 + i, kp->getIconFile() ); - widget_manager->showWgtTexture(WTOK_RACER0 + i); - widget_manager->showWgtRect(WTOK_RACER0 + i); + widget_manager->showWgtTexture(WTOK_RACER0 + i); + widget_manager->showWgtRect(WTOK_RACER0 + i); } else { const std::vector &groups=kart_properties_manager->getAllGroups(); widget_manager->setWgtText(WTOK_NAME0+i, groups[-indx-1]); - widget_manager->hideWgtTexture(WTOK_RACER0 + i); - widget_manager->hideWgtRect(WTOK_RACER0 + i); + widget_manager->hideWgtTexture(WTOK_RACER0 + i); + widget_manager->hideWgtRect(WTOK_RACER0 + i); } } // for i // set the 'selection changed' flag in the widget_manager, since update @@ -205,7 +205,7 @@ void CharSel::updateScrollPosition() //----------------------------------------------------------------------------- void CharSel::switchGroup() { - m_index_avail_karts.clear(); + m_index_avail_karts.clear(); // This loop is too long (since getNumberOfKarts returns all karts in all groups), // but the loop is left if no more kart is found. const std::vector &karts = @@ -223,28 +223,28 @@ void CharSel::switchGroup() const std::vector groups=kart_properties_manager->getAllGroups(); for(int i =0; i<(int)groups.size(); i++) { - // Only add groups other than the current one - if(groups[i]!=user_config->m_kart_group) m_index_avail_karts.push_back(-i-1); + // Only add groups other than the current one + if(groups[i]!=user_config->m_kart_group) m_index_avail_karts.push_back(-i-1); } if(m_index_avail_karts.size()>=m_max_entries) - { - m_offset = 0; - widget_manager->showWgtRect(WTOK_DOWN); - widget_manager->showWgtText(WTOK_DOWN); - widget_manager->showWgtRect(WTOK_UP); - widget_manager->showWgtText(WTOK_UP); - } - else - { - // Less entries than maximum -> set m_offset to a negative number, so - // that the actual existing entries are displayed - m_offset = - (int)(m_max_entries-m_index_avail_karts.size())/2-1; - widget_manager->hideWgtRect(WTOK_DOWN); - widget_manager->hideWgtText(WTOK_DOWN); - widget_manager->hideWgtRect(WTOK_UP); - widget_manager->hideWgtText(WTOK_UP); - } - + { + m_offset = 0; + widget_manager->showWgtRect(WTOK_DOWN); + widget_manager->showWgtText(WTOK_DOWN); + widget_manager->showWgtRect(WTOK_UP); + widget_manager->showWgtText(WTOK_UP); + } + else + { + // Less entries than maximum -> set m_offset to a negative number, so + // that the actual existing entries are displayed + m_offset = - (int)(m_max_entries-m_index_avail_karts.size())/2-1; + widget_manager->hideWgtRect(WTOK_DOWN); + widget_manager->hideWgtText(WTOK_DOWN); + widget_manager->hideWgtRect(WTOK_UP); + widget_manager->hideWgtText(WTOK_UP); + } + } // switchGroup //----------------------------------------------------------------------------- @@ -423,7 +423,7 @@ void CharSel::handle(GameAction action, int value) // Function checks the vector of previously selected karts and returns true if // kart i is in the vector and false if it is not. -bool CharSel::kartAvailable(int kart) +bool CharSel::kartAvailable(int kartid) { if (!kart_properties_manager->m_selected_karts.empty()) { @@ -431,9 +431,10 @@ bool CharSel::kartAvailable(int kart) for (it = kart_properties_manager->m_selected_karts.begin(); it < kart_properties_manager->m_selected_karts.end(); it++) { - if ( kart == *it) + if ( kartid == *it) return false; - } + } } - return true; + const KartProperties *kartprop=kart_properties_manager->getKartById(kartid); + return !unlock_manager->isLocked(kartprop->getIdent()); } // kartAvailable diff --git a/src/gui/game_mode.cpp b/src/gui/game_mode.cpp index a5d6614b1..bf53a121a 100644 --- a/src/gui/game_mode.cpp +++ b/src/gui/game_mode.cpp @@ -104,19 +104,25 @@ GameMode::GameMode() widget_manager->deactivateWgt(i); widget_manager->setWgtColor(i, WGT_WHITE); - widget_manager->setWgtTexture(i, "gui_lock.rgb", false); + widget_manager->setWgtLockTexture(i); widget_manager->showWgtTexture(i); } } - if(unlock_manager->isLocked("followleader")) + if(unlock_manager->isLocked("followtheleader")) { widget_manager->hideWgtText(WTOK_FOLLOW_LEADER_SINGLE); - widget_manager->setWgtColor(WTOK_FOLLOW_LEADER_SINGLE, WGT_GRAY); - widget_manager->setWgtTexture(WTOK_FOLLOW_LEADER_SINGLE, "gui_lock.rgb", false ); + widget_manager->deactivateWgt(WTOK_FOLLOW_LEADER_SINGLE); + widget_manager->setWgtLockTexture(WTOK_FOLLOW_LEADER_SINGLE); widget_manager->showWgtTexture(WTOK_FOLLOW_LEADER_SINGLE); - widget_manager->setWgtText(WTOK_FOLLOW_LEADER_SINGLE, - _("Fulfil challenge to unlock")); + //widget_manager->setWgtText(WTOK_FOLLOW_LEADER_SINGLE, + // _("Fulfil challenge to unlock")); + widget_manager->hideWgtText(WTOK_FOLLOW_LEADER_GP); + widget_manager->deactivateWgt(WTOK_FOLLOW_LEADER_GP); + widget_manager->setWgtLockTexture(WTOK_FOLLOW_LEADER_GP); + widget_manager->showWgtTexture(WTOK_FOLLOW_LEADER_GP); + //widget_manager->setWgtText(WTOK_FOLLOW_LEADER_GP, + // _("Fulfil challenge to unlock")); } w=widget_manager->addTextButtonWgt( WTOK_HELP, WIDTH, HEIGHT, _("Game mode help")); diff --git a/src/gui/grand_prix_select.cpp b/src/gui/grand_prix_select.cpp index 662be47fa..d25fe87b9 100644 --- a/src/gui/grand_prix_select.cpp +++ b/src/gui/grand_prix_select.cpp @@ -18,17 +18,15 @@ // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include -#include "file_manager.hpp" -#include "string_utils.hpp" #include "grand_prix_select.hpp" #include "widget_manager.hpp" #include "menu_manager.hpp" #include "race_manager.hpp" #include "track_manager.hpp" #include "material_manager.hpp" -#include "user_config.hpp" #include "unlock_manager.hpp" #include "translation.hpp" +#include "grand_prix_manager.hpp" enum WidgetTokens { @@ -49,22 +47,16 @@ GrandPrixSelect::GrandPrixSelect() : m_curr_track_img(0), m_clock(0.0f) widget_manager->switchOrder(); widget_manager->addEmptyWgt(WTOK_TITLE, 60, 7); - // Findout which grand prixs are available and load them - std::set result; - file_manager->listFiles(result, "data"); - int nId = 0; - for(std::set::iterator i = result.begin(); - i != result.end() ; i++) - { - if (StringUtils::has_suffix(*i, ".cup")) - { - CupData cup(*i); - if(unlock_manager->isLocked(cup.getName())) continue; - m_all_cups.push_back(cup); - widget_manager->addTextButtonWgt(WTOK_FIRSTPRIX + nId, 60, 7, cup.getName() ); - nId++; - } // if - } // for i + int nId=0; + m_gp_index.clear(); + for(unsigned int i=0; igetNumberOfGrandPrix(); i++) + { + const CupData *cup = grand_prix_manager->getCup(i); + if(unlock_manager->isLocked(cup->getName())) continue; + widget_manager->addTextButtonWgt(WTOK_FIRSTPRIX + nId, 60, 7, cup->getName() ); + m_gp_index.push_back(i); + nId++; + } // for i widget_manager->addEmptyWgt( WidgetManager::WGT_NONE, 100, 1 ); @@ -105,15 +97,15 @@ void GrandPrixSelect::update(float dt) if( widget_manager->selectionChanged() && !( SELECTED_TOKEN < WTOK_FIRSTPRIX )) { - const int CUP_NUM = SELECTED_TOKEN - WTOK_FIRSTPRIX; - const int NUM_TRACKS = (int)m_all_cups[CUP_NUM].getTrackCount(); + const int CUP_NUM = m_gp_index[SELECTED_TOKEN - WTOK_FIRSTPRIX]; + const CupData *cup = grand_prix_manager->getCup(CUP_NUM); + const int NUM_TRACKS = cup->getTrackCount(); - const CupData &cup = m_all_cups[CUP_NUM]; - widget_manager->setWgtText(WTOK_DESCRIPTION, cup.getDescription()); + widget_manager->setWgtText(WTOK_DESCRIPTION, cup->getDescription()); std::string track_list; - m_cup_tracks = m_all_cups[CUP_NUM].getTracks(); + m_cup_tracks = cup->getTracks(); for( int i = 0; i < NUM_TRACKS; ++i ) { @@ -142,14 +134,14 @@ void GrandPrixSelect::update(float dt) m_track_imgs.push_back(mat->getState()->getTextureHandle()); } - if( !( m_track_imgs.empty() )) + if( !m_track_imgs.empty() ) { m_clock = 0.0f; m_curr_track_img = 0; widget_manager->showWgtTexture( WTOK_IMG ); widget_manager->setWgtTexture( WTOK_IMG, - m_track_imgs[ m_curr_track_img ] ); + m_track_imgs[ m_curr_track_img ] ); widget_manager->setWgtColor( WTOK_IMG, WGT_WHITE ); } else @@ -159,7 +151,7 @@ void GrandPrixSelect::update(float dt) } } - if( !( m_track_imgs.empty() )) + if( !m_track_imgs.empty() ) { m_clock += dt; @@ -170,8 +162,8 @@ void GrandPrixSelect::update(float dt) ++m_curr_track_img; if( m_curr_track_img >= m_track_imgs.size() ) m_curr_track_img = 0; - widget_manager->setWgtTexture( WTOK_IMG, - m_track_imgs[ m_curr_track_img ] ); + widget_manager->setWgtTexture(WTOK_IMG, + m_track_imgs[ m_curr_track_img ] ); } } @@ -190,7 +182,8 @@ void GrandPrixSelect::select() menu_manager->popMenu(); return; } - race_manager->setGrandPrix(m_all_cups[CLICKED_TOKEN-WTOK_FIRSTPRIX]); + const CupData *cup=grand_prix_manager->getCup(m_gp_index[CLICKED_TOKEN-WTOK_FIRSTPRIX]); + race_manager->setGrandPrix(*cup); menu_manager->pushMenu(MENUID_RACE_OPTIONS); } // select diff --git a/src/gui/grand_prix_select.hpp b/src/gui/grand_prix_select.hpp index a50a5dbf0..af29af13b 100644 --- a/src/gui/grand_prix_select.hpp +++ b/src/gui/grand_prix_select.hpp @@ -26,12 +26,12 @@ class GrandPrixSelect: public BaseGUI { -private: - std::vector m_all_cups; - std::vector m_cup_tracks; - std::vector m_track_imgs; - unsigned int m_curr_track_img; - float m_clock; +private: + std::vector m_cup_tracks; + std::vector m_track_imgs; + std::vector m_gp_index; + unsigned int m_curr_track_img; + float m_clock; public: GrandPrixSelect(); ~GrandPrixSelect(); diff --git a/src/gui/help_page_one.cpp b/src/gui/help_page_one.cpp index f0c98cb30..60a6d04b3 100644 --- a/src/gui/help_page_one.cpp +++ b/src/gui/help_page_one.cpp @@ -136,7 +136,7 @@ _("If you see a button with a lock like the one to the right,\n\ you need to complete a challenge to unlock it.")); widget_manager->addImgWgt(WTOK_LOCK, 6, 8, 0); - widget_manager->setWgtTexture(WTOK_LOCK, "gui_help_lock.rgb", false); + widget_manager->setWgtLockTexture(WTOK_LOCK); widget_manager->breakLine(); widget_manager->addEmptyWgt( WidgetManager::WGT_NONE, 100, 1);