Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/bindermFS16/src/orxonox/LevelManager.h @ 11238

Last change on this file since 11238 was 11194, checked in by binderm, 8 years ago

final commit

  • Property svn:eol-style set to native
File size: 5.4 KB
RevLine 
[2072]1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
23 *      Fabian 'x3n' Landau
24 *   Co-authors:
[7802]25 *      Damian 'Mozork' Frick
[11191]26 *      Matthias Binder
[2072]27 *
28 */
29
[7804]30/**
31    @file LevelManager.h
32    @brief Definition of the LevelManager singleton.
33    @ingroup Orxonox
34*/
35
[2072]36#ifndef _LevelManager_H__
37#define _LevelManager_H__
38
39#include "OrxonoxPrereqs.h"
40
[3196]41#include <cassert>
[2072]42#include <list>
[7648]43#include <map>
[3304]44#include <string>
[3370]45
[7802]46#include "LevelInfo.h"
47
[3370]48#include "util/Singleton.h"
[9667]49#include "core/config/Configurable.h"
[11186]50#include "LevelStatus.h"
[2072]51
[11173]52
[3280]53// tolua_begin
[2072]54namespace orxonox
55{
[7802]56
57    /**
58    @brief
[7803]59        The LevelManager keeps track of @ref orxonox::Level "Levels" whose activity has been requested and activates the @ref orxonox::Level "Levels" in the list in a FIFO manner with exactly one Level (the first in the list) being active at all times (unless the list is empty).
60        It also serves as an access point to get a list of all available @ref orxonox::Level "Levels" (or rather their respective @ref orxonox::LevelInfoItem "LevelInfoItems").
[7802]61
62    @author
63        Fabian 'x3n' Landau
64
65    @author
66        Damian 'Mozork' Frick
[7804]67
[11173]68
69    @ingroup Orxonox1
[7802]70    */
[11173]71
72
73
74
[2171]75    class _OrxonoxExport LevelManager
[3280]76    // tolua_end
[9667]77        : public Singleton<LevelManager>, public Configurable
[3280]78    { // tolua_export
[3370]79            friend class Singleton<LevelManager>;
[2072]80        public:
81            LevelManager();
82            virtual ~LevelManager();
83
[11180]84            void buildallLevelStatus();
[11186]85            void updateAllLevelStatus();
86            void setLevelStatus(const std::string& LevelWon);
[11173]87
88
[7802]89            void setConfigValues(); //!< Set the config values for this object.
[3280]90
[7802]91            void requestActivity(Level* level); //!< Request activity for the input Level.
92            void releaseActivity(Level* level); //!< Release activity for the input Level.
[11173]93
[7802]94            Level* getActiveLevel(); //!< Get the currently active Level.
[2072]95
[7802]96            // tolua_begin
[11186]97            void updatewon(int lastwon);
[11180]98            int missionactivate(int index);
[7802]99            void setDefaultLevel(const std::string& levelName); //!< Set the default Level.
100            /**
101            @brief Get the default level.
102            @return Returns the filename of the default level.
103            */
104            const std::string& getDefaultLevel() const
105                { return defaultLevelName_; }
106            unsigned int getNumberOfLevels(void);
107            LevelInfoItem* getAvailableLevelListItem(unsigned int index); //!< Get the LevelInfoItem at the given index in the list of available Levels.
[3280]108
[11186]109            inline const std::string& getLastWonMission() const
110                { return this->lastWonMission_; }
[10258]111
112            inline unsigned int getNumberOfCampaignMissions()
113                { return this->campaignMissions_.size(); }
[11173]114
[10258]115            inline const std::string& getCampaignMission(unsigned int index)
116                { return this->campaignMissions_[index]; }
117
[11173]118
[7802]119            /**
120            @brief Get the instance of the LevelManager.
121            @return Returns the instance of the LevelManager.
122            */
123            static LevelManager& getInstance()
124                { return Singleton<LevelManager>::getInstance(); }
125            // tolua_end
[2072]126
127        private:
[11071]128            // non-copyable:
129            LevelManager(const LevelManager&) = delete;
130            LevelManager& operator=(const LevelManager&) = delete;
[2072]131
[7802]132            void activateNextLevel(); //!< Activate the next level.
[2072]133
[7802]134            void compileAvailableLevelList(void); //!< Compile the list of available Levels.
135            void updateAvailableLevelList(void); //!< Update the list of available Levels.
[7648]136
[7802]137            std::list<Level*> levels_; //!< A list of all the Levels whose activity has been requested, in the order in which they will become active.
138            std::set<LevelInfoItem*, LevelInfoCompare> availableLevels_; //!< The set of available Levels sorted alphabetically according to the name of the Level.
[3196]139
[7802]140            // Helpers to allow fast access to the availableLevels list.
141            unsigned int nextIndex_; //! The next expected index to be accessed.
[8079]142            std::set<LevelInfoItem*, LevelInfoCompare>::iterator nextLevel_; //! The next expected Level to be accessed.
[7802]143
[3280]144            // config values
145            std::string defaultLevelName_;
[11186]146            std::string lastWonMission_;
[10258]147            std::vector<std::string> campaignMissions_;
[11194]148            std::vector<int> allLevelWon_;                  //level i is won if allLevelWon_[i]=1
149            std::vector<LevelStatus*> allLevelStatus_;
[3280]150
[11173]151
152
[3370]153            static LevelManager* singletonPtr_s;
[3280]154    }; // tolua_export
155} // tolua_export
[2072]156
157#endif /* _LevelManager_H__ */
Note: See TracBrowser for help on using the repository browser.