SuperTuxKart
unlock_manager.hpp
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 
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 ();
57  void addChallenge (const std::string& filename);
58 
59  const ChallengeData *getChallengeData(const std::string& id);
60 
61  bool isSupportedVersion(const ChallengeData &challenge);
62 
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 
75 
76 }; // UnlockManager
77 
78 extern UnlockManager* unlock_manager;
79 #endif
the description of one challenge
Definition: challenge_data.hpp:35
The state of a challenge for one player.
Definition: challenge_status.hpp:53
Utility class, you can inherit from this class to disallow the assignment operator and copy construct...
Definition: no_copy.hpp:26
The base class for sound effects.
Definition: sfx_base.hpp:43
This class contains the progression through challenges for the story mode.
Definition: story_mode_status.hpp:49
main class to handle locking/challenges
Definition: unlock_manager.hpp:40
~UnlockManager()
Saves the challenge status.
Definition: unlock_manager.cpp:86
void addChallenge(const std::string &filename)
Reads a challenge from the given filename.
Definition: unlock_manager.cpp:173
void findWhatWasUnlocked(int pointsBefore, int pointsNow, std::vector< std::string > &tracks, std::vector< std::string > &gps, std::vector< std::string > &karts, std::vector< const ChallengeData * > &unlocked)
This functions finds what new tracks, GP and karts have been unlocked.
Definition: unlock_manager.cpp:251
bool unlockSpecial(ChallengeStatus *unlock_list, int max_req_in_lower_diff)
This functions sets as completed the "challenges" requiring some special conditions Returns true if t...
Definition: unlock_manager.cpp:324
void addOrFreeChallenge(ChallengeData *c)
If a challenge is supported by this binary (i.e.
Definition: unlock_manager.cpp:143
void playLockSound() const
Eye- (or rather ear-) candy.
Definition: unlock_manager.cpp:231
void addListChallenge(ChallengeData *c)
Add a challenge to the unlock challenges list.
Definition: unlock_manager.cpp:163
bool unlockByPoints(int points, ChallengeStatus *unlock_list)
This functions sets as completed the "challenges" requiring a certain number of points,...
Definition: unlock_manager.cpp:310
bool isSupportedVersion(const ChallengeData &challenge)
Test if the given challenge is supported by this binary.
Definition: unlock_manager.cpp:240
const ChallengeData * getChallengeData(const std::string &id)
Returns the challenge data for a challenge id, or NULL if no such challenge exist.
Definition: unlock_manager.cpp:198
StoryModeStatus * createStoryModeStatus(const XMLNode *node=NULL)
Creates a game slot.
Definition: unlock_manager.cpp:211
utility class used to parse XML files
Definition: xml_node.hpp:48