Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

The Campaign menu now works. The levels are structured in a tree. If one goes the left branch, the right one can't be taken anymore. The last challenge is to save the progress in the config variables. to set does work, but not to modify those variables.

  • Property svn:eol-style set to native
File size: 5.5 KB
Line 
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:
25 *      Damian 'Mozork' Frick
26 *      Matthias Binder
27 *
28 */
29
30/**
31    @file LevelManager.h
32    @brief Definition of the LevelManager singleton.
33    @ingroup Orxonox
34*/
35
36#ifndef _LevelManager_H__
37#define _LevelManager_H__
38
39#include "OrxonoxPrereqs.h"
40
41#include <cassert>
42#include <list>
43#include <map>
44#include <string>
45
46#include "LevelInfo.h"
47
48#include "util/Singleton.h"
49#include "core/config/Configurable.h"
50#include "LevelStatus.h"
51
52
53// tolua_begin
54namespace orxonox
55{
56
57    /**
58    @brief
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").
61
62    @author
63        Fabian 'x3n' Landau
64
65    @author
66        Damian 'Mozork' Frick
67
68
69    @ingroup Orxonox1
70    */
71
72
73
74
75    class _OrxonoxExport LevelManager
76    // tolua_end
77        : public Singleton<LevelManager>, public Configurable
78    { // tolua_export
79            friend class Singleton<LevelManager>;
80        public:
81            LevelManager();
82            virtual ~LevelManager();
83
84            //void setLevelStatus(const int integer);
85            void buildallLevelStatus();
86            void updateAllLevelStatus();
87            void setLevelStatus(const std::string& LevelWon);
88
89
90            void setConfigValues(); //!< Set the config values for this object.
91
92            void requestActivity(Level* level); //!< Request activity for the input Level.
93            void releaseActivity(Level* level); //!< Release activity for the input Level.
94
95            Level* getActiveLevel(); //!< Get the currently active Level.
96
97            // tolua_begin
98            void updatewon(int lastwon);
99            int missionactivate(int index);
100            void setDefaultLevel(const std::string& levelName); //!< Set the default Level.
101            /**
102            @brief Get the default level.
103            @return Returns the filename of the default level.
104            */
105            const std::string& getDefaultLevel() const
106                { return defaultLevelName_; }
107            unsigned int getNumberOfLevels(void);
108            LevelInfoItem* getAvailableLevelListItem(unsigned int index); //!< Get the LevelInfoItem at the given index in the list of available Levels.
109
110            //void setLastFinishedCampaignMission(const std::string& lastFinishedCampaignMission);
111            inline const std::string& getLastWonMission() const
112                { return this->lastWonMission_; }
113
114            inline unsigned int getNumberOfCampaignMissions()
115                { return this->campaignMissions_.size(); }
116
117            inline const std::string& getCampaignMission(unsigned int index)
118                { return this->campaignMissions_[index]; }
119
120
121            /**
122            @brief Get the instance of the LevelManager.
123            @return Returns the instance of the LevelManager.
124            */
125            static LevelManager& getInstance()
126                { return Singleton<LevelManager>::getInstance(); }
127            // tolua_end
128
129        private:
130            // non-copyable:
131            LevelManager(const LevelManager&) = delete;
132            LevelManager& operator=(const LevelManager&) = delete;
133
134            void activateNextLevel(); //!< Activate the next level.
135
136            void compileAvailableLevelList(void); //!< Compile the list of available Levels.
137            void updateAvailableLevelList(void); //!< Update the list of available Levels.
138
139            std::list<Level*> levels_; //!< A list of all the Levels whose activity has been requested, in the order in which they will become active.
140            std::set<LevelInfoItem*, LevelInfoCompare> availableLevels_; //!< The set of available Levels sorted alphabetically according to the name of the Level.
141
142            // Helpers to allow fast access to the availableLevels list.
143            unsigned int nextIndex_; //! The next expected index to be accessed.
144            std::set<LevelInfoItem*, LevelInfoCompare>::iterator nextLevel_; //! The next expected Level to be accessed.
145
146            // config values
147            std::string defaultLevelName_;
148            std::string lastWonMission_;
149            std::vector<std::string> campaignMissions_;
150            std::vector<int> allLevelWon_;
151            std::vector<LevelStatus> allLevelStatus_;
152
153
154
155            static LevelManager* singletonPtr_s;
156    }; // tolua_export
157} // tolua_export
158
159#endif /* _LevelManager_H__ */
Note: See TracBrowser for help on using the repository browser.