Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/orxonox/LevelManager.h @ 7802

Last change on this file since 7802 was 7802, checked in by dafrick, 13 years ago

Making the level list in the LevelManager (and as consequence the level list displayed by the GUI) alphabetically sorted. Also some cleanup and documented LevelManager.

  • Property svn:eol-style set to native
File size: 4.1 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#ifndef _LevelManager_H__
30#define _LevelManager_H__
31
32#include "OrxonoxPrereqs.h"
33
34#include <cassert>
35#include <list>
36#include <map>
37#include <string>
38
39#include "LevelInfo.h"
40
41#include "util/Singleton.h"
42#include "core/OrxonoxClass.h"
43
44// tolua_begin
45namespace orxonox
46{
47
48    /**
49    @brief
50        The LevelManager keeps track of @ref orxonox::Level "Levels" whose activity has been requested and serves as an access point to get a list of all available @ref orxonox::Level "Levels" (or rather their respective @ref orxonox::LevelInfoItem "LevelInfoItems").
51
52    @author
53        Fabian 'x3n' Landau
54
55    @author
56        Damian 'Mozork' Frick
57    */
58    class _OrxonoxExport LevelManager
59    // tolua_end
60        : public Singleton<LevelManager>, public OrxonoxClass
61    { // tolua_export
62            friend class Singleton<LevelManager>;
63        public:
64            LevelManager();
65            virtual ~LevelManager();
66
67            void setConfigValues(); //!< Set the config values for this object.
68
69            void requestActivity(Level* level); //!< Request activity for the input Level.
70            void releaseActivity(Level* level); //!< Release activity for the input Level.
71            Level* getActiveLevel(); //!< Get the currently active Level.
72
73            // tolua_begin
74            void setDefaultLevel(const std::string& levelName); //!< Set the default Level.
75            /**
76            @brief Get the default level.
77            @return Returns the filename of the default level.
78            */
79            const std::string& getDefaultLevel() const
80                { return defaultLevelName_; }
81            unsigned int getNumberOfLevels(void);
82            LevelInfoItem* getAvailableLevelListItem(unsigned int index); //!< Get the LevelInfoItem at the given index in the list of available Levels.
83
84            /**
85            @brief Get the instance of the LevelManager.
86            @return Returns the instance of the LevelManager.
87            */
88            static LevelManager& getInstance()
89                { return Singleton<LevelManager>::getInstance(); }
90            // tolua_end
91
92        private:
93            LevelManager(const LevelManager&);
94
95            void activateNextLevel(); //!< Activate the next level.
96
97            void compileAvailableLevelList(void); //!< Compile the list of available Levels.
98            void updateAvailableLevelList(void); //!< Update the list of available Levels.
99
100            std::list<Level*> levels_; //!< A list of all the Levels whose activity has been requested, in the order in which they will become active.
101            std::set<LevelInfoItem*, LevelInfoCompare> availableLevels_; //!< The set of available Levels sorted alphabetically according to the name of the Level.
102
103            // Helpers to allow fast access to the availableLevels list.
104            unsigned int nextIndex_; //! The next expected index to be accessed.
105            std::set<LevelInfoItem*, LevelInfoCompare>::iterator nextLevel_; //! The nex expected Level to be accessed.
106
107            // config values
108            std::string defaultLevelName_;
109
110            static LevelManager* singletonPtr_s;
111    }; // tolua_export
112} // tolua_export
113
114#endif /* _LevelManager_H__ */
Note: See TracBrowser for help on using the repository browser.