Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

Campaignmenu improved, it's now possible to only show single levels and not all together.

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