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