Back to index

supertuxkart  0.5+dfsg1
unlock_manager.hpp
Go to the documentation of this file.
00001 //  $Id: challenge_manager.hpp 1259 2007-09-24 12:28:19Z hiker $
00002 //
00003 //  SuperTuxKart - a fun racing game with go-kart
00004 //  Copyright (C) 2008 Joerg Henrichs
00005 //
00006 //  This program is free software; you can redistribute it and/or
00007 //  modify it under the terms of the GNU General Public License
00008 //  as published by the Free Software Foundation; either version 2
00009 //  of the License, or (at your option) any later version.
00010 //
00011 //  This program is distributed in the hope that it will be useful,
00012 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 //  GNU General Public License for more details.
00015 //
00016 //  You should have received a copy of the GNU General Public License
00017 //  along with this program; if not, write to the Free Software
00018 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00019 
00020 #ifndef HEADER_UNLOCK_MANAGER_H
00021 #define HEADER_UNLOCK_MANAGER_H
00022 
00023 #include <map>
00024 
00025 #include "challenges/challenge.hpp"
00026 #include "lisp/lisp.hpp"
00027 #include "lisp/parser.hpp"
00028 #include "lisp/writer.hpp"
00029 
00030 class UnlockManager
00031 {
00032 private:
00033     typedef std::map<std::string, Challenge*> AllChallengesType;
00034     AllChallengesType             m_all_challenges;
00035     std::map<std::string, bool>   m_locked_features;
00036     std::vector<const Challenge*> m_unlocked_features;
00037     Challenge *getChallenge      (const std::string& id);
00038     void       computeActive     ();
00039 public:
00040                UnlockManager    ();
00041     void       load             (const lisp::Lisp*);
00042     void       save             (lisp::Writer* writer);
00043     std::vector<const Challenge*> 
00044                getActiveChallenges();
00045     const std::vector<const Challenge*> 
00046                getUnlockedFeatures() {return m_unlocked_features;}
00047 
00048     void       clearUnlocked      () {m_unlocked_features.clear(); }
00049     void       raceFinished       ();
00050     void       grandPrixFinished  ();
00051     void       unlockFeature      (Challenge* c, bool save=true);
00052     void       lockFeature        (Challenge* challenge);
00053     bool       isLocked           (const std::string& feature);
00054 };   // UnlockManager
00055 
00056 extern UnlockManager* unlock_manager;
00057 #endif