Changeset 3008
- Timestamp:
- May 21, 2009, 5:16:29 PM (16 years ago)
- Location:
- code/trunk/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/core/Loader.cc
r2710 r3008 30 30 31 31 #include <tinyxml/ticpp.h> 32 #include <boost/filesystem.hpp> 32 33 33 34 #include "XMLFile.h" … … 41 42 #include "util/Debug.h" 42 43 #include "util/Exception.h" 44 #include "Core.h" 43 45 44 46 namespace orxonox … … 210 212 return Loader::load(file, mask); 211 213 } 214 215 std::vector<std::string> Loader::getLevelList() 216 { 217 std::vector<std::string> levelList; 218 219 boost::filesystem::directory_iterator file(Core::getMediaPathString() + "levels"); 220 boost::filesystem::directory_iterator end; 221 222 while (file != end) 223 { 224 if (!boost::filesystem::is_directory(*file) && file->string()[file->string().length()-1] != '~') 225 { 226 std::string filename = file->path().leaf(); 227 if (filename.length() > 4) 228 levelList.push_back(filename.substr(0,filename.length()-4)); 229 } 230 ++file; 231 } 232 return levelList; 233 } 212 234 } -
code/trunk/src/core/Loader.h
r2087 r3008 57 57 58 58 static ClassTreeMask currentMask_s; 59 static std::vector<std::string> getLevelList(); 59 60 60 61 private: -
code/trunk/src/orxonox/gamestates/GSLevel.cc
r2928 r3008 60 60 SetCommandLineArgument(level, "presentation_dm.oxw").shortcut("l"); 61 61 SetConsoleCommand(GSLevel, showIngameGUI, true); 62 SetConsoleCommand(GSLevel, setLevel, true); 63 64 XMLFile* GSLevel::startFile_s = NULL; 62 65 63 66 GSLevel::GSLevel(const std::string& name) … … 68 71 , guiKeysOnlyInputState_(0) 69 72 , radar_(0) 70 , startFile_(0)71 73 , cameraManager_(0) 72 74 , levelManager_(0) … … 252 254 COUT(0) << "Loading level..." << std::endl; 253 255 std::string levelName; 254 CommandLine::getValue("level", &levelName); 255 startFile_ = new XMLFile(Core::getMediaPathString() + "levels" + '/' + levelName); 256 Loader::open(startFile_); 256 if (!startFile_s) 257 { 258 CommandLine::getValue("level", &levelName); 259 startFile_s = new XMLFile(Core::getMediaPathString() + "levels" + '/' + levelName); 260 } 261 Loader::open(startFile_s); 262 } 263 264 void GSLevel::setLevel(std::string levelName) 265 { 266 delete GSLevel::startFile_s; 267 GSLevel::startFile_s = new XMLFile(Core::getMediaPathString() + "levels" + '/' + levelName); 257 268 } 258 269 … … 265 276 ////////////////////////////////////////////////////////////////////////////////////////// 266 277 267 delete this->startFile_;278 delete startFile_s; 268 279 } 269 280 -
code/trunk/src/orxonox/gamestates/GSLevel.h
r2911 r3008 48 48 49 49 static void showIngameGUI(bool show); 50 static void setLevel(std::string levelName); 51 52 static XMLFile* startFile_s; 50 53 51 54 protected: … … 63 66 SimpleInputState* guiKeysOnlyInputState_; //!< input state if we only need the keys to use the GUI 64 67 Radar* radar_; //!< represents the Radar (not the HUD part) 65 XMLFile* startFile_; //!< current hard coded default level66 68 CameraManager* cameraManager_; //!< camera manager for this level 67 69 LevelManager* levelManager_; //!< global level manager -
code/trunk/src/orxonox/gui/GUIManager.cc
r2963 r3008 55 55 #include "ToluaBindCore.h" 56 56 #include "ToluaBindOrxonox.h" 57 #include "core/Loader.h" 57 58 58 59 extern "C" { … … 238 239 COUT(2) << "CEGUI Error: \"" << ex.getMessage() << "\" while executing code \"" << str << "\"" << std::endl; 239 240 } 241 } 242 243 /** 244 245 */ 246 void GUIManager::getLevelList() 247 { 248 lua_State* L = this->scriptModule_->getLuaState(); 249 lua_newtable(L); 250 251 std::vector<std::string> list = Loader::getLevelList(); 252 253 int j = 1; 254 for (std::vector<std::string>::iterator i = list.begin(); i != list.end(); i++) 255 { 256 lua_pushnumber(L,j); 257 lua_pushstring(L,i->c_str()); 258 lua_settable(L,-3); 259 j++; 260 } 261 lua_setglobal(L, "levellist"); 240 262 } 241 263 -
code/trunk/src/orxonox/gui/GUIManager.h
r2962 r3008 97 97 static GUIManager* getInstancePtr() { return singletonRef_s; } 98 98 99 void getLevelList(); //tolua_export 100 99 101 private: 100 102 GUIManager(const GUIManager& instance); //!< private constructor (this is a singleton class)
Note: See TracChangeset
for help on using the changeset viewer.