Changeset 3339 for code/branches/resource/src/orxonox
- Timestamp:
- Jul 23, 2009, 8:04:51 PM (15 years ago)
- Location:
- code/branches/resource/src/orxonox
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/resource/src/orxonox/LevelManager.cc
r3280 r3339 30 30 31 31 #include <map> 32 #include <boost/filesystem.hpp> 32 33 33 34 #include "core/CommandLine.h" 34 35 #include "core/ConfigValueIncludes.h" 35 36 #include "core/CoreIncludes.h" 37 #include "core/Loader.h" 36 38 #include "PlayerManager.h" 37 39 #include "objects/Level.h" … … 120 122 } 121 123 122 const std::string& LevelManager::getDefaultLevel() 124 const std::string& LevelManager::getDefaultLevel() const 123 125 { 124 126 return defaultLevelName_; 125 127 } 128 129 std::string LevelManager::getAvailableLevelListItem(unsigned int index) const 130 { 131 if (index >= availableLevels_.size()) 132 return std::string(); 133 else 134 return availableLevels_[index]; 135 } 136 137 void LevelManager::compileAvailableLevelList() 138 { 139 availableLevels_.clear(); 140 141 boost::filesystem::directory_iterator file(Core::getMediaPathString() + "levels"); 142 boost::filesystem::directory_iterator end; 143 144 while (file != end) 145 { 146 if (!boost::filesystem::is_directory(*file) && file->string()[file->string().length()-1] != '~') 147 { 148 std::string filename = file->path().leaf(); 149 if (filename.length() > 4) 150 availableLevels_.push_back(filename.substr(0,filename.length()-4)); 151 } 152 ++file; 153 } 154 } 126 155 } -
code/branches/resource/src/orxonox/LevelManager.h
r3304 r3339 55 55 56 56 void setDefaultLevel(const std::string& levelName); //tolua_export 57 const std::string& getDefaultLevel(); //tolua_export 57 const std::string& getDefaultLevel() const; //tolua_export 58 void compileAvailableLevelList(); //tolua_export 59 std::string getAvailableLevelListItem(unsigned int index) const; //tolua_export 58 60 59 61 static LevelManager* getInstancePtr() { return singletonRef_s; } … … 66 68 67 69 std::list<Level*> levels_s; 70 std::vector<std::string> availableLevels_; 68 71 69 72 // config values -
code/branches/resource/src/orxonox/gamestates/GSMainMenu.cc
r3327 r3339 67 67 68 68 // show main menu 69 GUIManager::getInstance().showGUI("mainmenu_ 3");69 GUIManager::getInstance().showGUI("mainmenu_4"); 70 70 GUIManager::getInstance().setCamera(this->camera_); 71 71 GraphicsManager::getInstance().setCamera(this->camera_); -
code/branches/resource/src/orxonox/gui/GUIManager.cc
r3338 r3339 61 61 #include "ToluaBindCore.h" 62 62 #include "ToluaBindOrxonox.h" 63 #include "core/Loader.h"64 63 65 64 namespace orxonox … … 88 87 89 88 static CEGUI::MouseButton convertButton(MouseButtonCode::ByEnum button); 89 90 90 GUIManager* GUIManager::singletonRef_s = 0; 91 91 … … 157 157 Destructor of the GUIManager 158 158 159 Basically shuts down CEGUI and destroys the Lua engine and afterwards the interface to the Ogre engine.159 Basically shuts down CEGUI (member smart pointers) but first unloads our Tolua modules. 160 160 */ 161 161 GUIManager::~GUIManager() … … 174 174 Calls main Lua script 175 175 @todo 176 Replace loadGUI.lua with loadGUI_2.lua after merging this back to trunk.177 However CEGUI is able to execute a startup script. We could maybe put this call in this startup code.178 179 176 This function calls the main Lua script for our GUI. 180 177 … … 183 180 void GUIManager::loadLuaCode() 184 181 { 185 try 186 { 187 // set datapath for GUI data 188 lua_pushfstring(this->scriptModule_->getLuaState(), Core::getMediaPathString().c_str()); 189 lua_setglobal(this->scriptModule_->getLuaState(), "datapath"); 190 // call main Lua script 191 this->scriptModule_->executeScriptFile("loadGUI_3.lua", "GUI"); 192 } 193 catch (CEGUI::Exception& ex) 194 { 195 #if CEGUI_VERSION_MINOR < 6 196 throw GeneralException(ex.getMessage().c_str()); 197 #else 198 throw GeneralException(ex.getMessage().c_str(), ex.getLine(), 199 ex.getFileName().c_str(), ex.getName().c_str()); 200 #endif 201 } 182 // set datapath for GUI data 183 lua_pushfstring(this->scriptModule_->getLuaState(), Core::getMediaPathString().c_str()); 184 lua_setglobal(this->scriptModule_->getLuaState(), "datapath"); 185 // call main Lua script 186 this->scriptModule_->executeScriptFile("loadGUI_3.lua", "GUI"); 202 187 } 203 188 … … 216 201 assert(guiSystem_); 217 202 guiSystem_->injectTimePulse(time.getDeltaTime()); 218 }219 220 /**221 222 */223 void GUIManager::getLevelList()224 {225 lua_State* L = this->scriptModule_->getLuaState();226 lua_newtable(L);227 228 std::vector<std::string> list = Loader::getLevelList();229 230 int j = 1;231 for (std::vector<std::string>::iterator i = list.begin(); i != list.end(); i++)232 {233 lua_pushnumber(L,j);234 lua_pushstring(L,i->c_str());235 lua_settable(L,-3);236 j++;237 }238 lua_setglobal(L, "levellist");239 203 } 240 204 -
code/branches/resource/src/orxonox/gui/GUIManager.h
r3338 r3339 47 47 #include "core/input/InputHandler.h" 48 48 49 // tolua_begin50 49 namespace orxonox 51 50 { … … 61 60 Those input events are then injected into CEGUI in Lua. 62 61 */ 63 class _OrxonoxExport GUIManager 64 // tolua_end 65 : public InputHandler 66 // tolua_begin 62 class _OrxonoxExport GUIManager : public InputHandler 67 63 { 68 // tolua_end69 64 public: 70 65 GUIManager(Ogre::RenderWindow* renderWindow); … … 78 73 void setCamera(Ogre::Camera* camera); 79 74 80 static GUIManager& getInstance() { assert(singletonRef_s); return *singletonRef_s; } // tolua_export75 static GUIManager& getInstance() { assert(singletonRef_s); return *singletonRef_s; } 81 76 static GUIManager* getInstancePtr() { return singletonRef_s; } 82 77 83 void getLevelList(); //tolua_export84 85 78 private: 86 GUIManager(const GUIManager& instance); //!< private constructor (this is a singleton class)79 GUIManager(const GUIManager& instance); //!< private and undefined copy c'tor (this is a singleton class) 87 80 88 81 void loadLuaCode(); … … 108 101 static GUIManager* singletonRef_s; //!< Singleton reference to GUIManager 109 102 110 }; // tolua_export111 } // tolua_export103 }; 104 } 112 105 113 106 #endif /* _GUIManager_H__ */
Note: See TracChangeset
for help on using the changeset viewer.