1 // 2 // SuperTuxKart - a fun racing game with go-kart 3 // Copyright (C) 2008-2015 Joerg Henrichs 4 // 5 // This program is free software; you can redistribute it and/or 6 // modify it under the terms of the GNU General Public License 7 // as published by the Free Software Foundation; either version 3 8 // of the License, or (at your option) any later version. 9 // 10 // This program is distributed in the hope that it will be useful, 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 // GNU General Public License for more details. 14 // 15 // You should have received a copy of the GNU General Public License 16 // along with this program; if not, write to the Free Software 17 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 19 #ifndef HEADER_UNLOCK_MANAGER_HPP 20 #define HEADER_UNLOCK_MANAGER_HPP 21 22 #include <map> 23 24 #include "challenges/challenge_data.hpp" 25 #include "challenges/story_mode_status.hpp" 26 27 #include "utils/no_copy.hpp" 28 #include "utils/ptr_vector.hpp" 29 30 #include <fstream> 31 32 class XMLNode; 33 class SFXBase; 34 35 /** 36 * \brief main class to handle locking/challenges 37 * \ingroup challenges 38 */ 39 class UnlockManager : public NoCopy 40 { 41 private: 42 SFXBase *m_locked_sound; 43 44 typedef std::map<std::string, ChallengeData*> AllChallengesType; 45 AllChallengesType m_all_challenges; 46 47 /* The challenges who don't have a race, only unlockables */ 48 AllChallengesType m_list_challenges; 49 50 void readAllChallengesInDirs(const std::vector<std::string>* all_dirs); 51 52 public: 53 UnlockManager (); 54 ~UnlockManager (); 55 void addOrFreeChallenge(ChallengeData *c); 56 void addListChallenge(ChallengeData *c); 57 void addChallenge (const std::string& filename); 58 59 const ChallengeData *getChallengeData(const std::string& id); 60 61 bool isSupportedVersion(const ChallengeData &challenge); 62 63 /** Eye- (or rather ear-) candy. Play a sound when user tries to access a locked area */ 64 void playLockSound() const; 65 66 void findWhatWasUnlocked(int pointsBefore, int pointsNow, 67 std::vector<std::string>& tracks, 68 std::vector<std::string>& gps, 69 std::vector<std::string>& karts, 70 std::vector<const ChallengeData*>& unlocked); 71 bool unlockByPoints(int points, ChallengeStatus* unlock_list); 72 bool unlockSpecial(ChallengeStatus* unlock_list, int max_req_in_lower_diff); 73 74 StoryModeStatus *createStoryModeStatus(const XMLNode *node=NULL); 75 76 }; // UnlockManager 77 78 extern UnlockManager* unlock_manager; 79 #endif 80