Changeset 2710 for code/trunk/src/orxonox/gamestates
- Timestamp:
- Feb 28, 2009, 7:46:37 PM (16 years ago)
- Location:
- code/trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:ignore deleted
- Property svn:mergeinfo changed
-
code/trunk/src/orxonox/gamestates/CMakeLists.txt
- Property svn:eol-style set to native
r2131 r2710 1 SET(SRC_FILES1 ADD_SOURCE_FILES(ORXONOX_SRC_FILES 2 2 GSDedicated.cc 3 3 GSClient.cc … … 10 10 GSStandalone.cc 11 11 ) 12 13 ADD_SOURCE_FILES(SRC_FILES) -
code/trunk/src/orxonox/gamestates/GSGraphics.cc
r2662 r2710 31 31 32 32 #include <fstream> 33 #include <boost/filesystem.hpp> 34 33 35 #include <OgreCompositorManager.h> 34 36 #include <OgreConfigFile.h> … … 43 45 #include <OgreWindowEventUtilities.h> 44 46 47 #include "SpecialConfig.h" 45 48 #include "util/Debug.h" 46 49 #include "util/Exception.h" 50 #include "util/String.h" 51 #include "util/SubString.h" 47 52 #include "core/ConsoleCommand.h" 48 53 #include "core/ConfigValueIncludes.h" … … 57 62 #include "gui/GUIManager.h" 58 63 #include "tools/WindowEventListener.h" 59 #include "Settings.h"60 64 61 65 // for compatibility … … 92 96 SetConfigValue(ogreConfigFile_, "ogre.cfg") 93 97 .description("Location of the Ogre config file"); 94 SetConfigValue(ogrePluginsFile_, "plugins.cfg") 95 .description("Location of the Ogre plugins file"); 98 SetConfigValue(ogrePluginsFolder_, ORXONOX_OGRE_PLUGINS_FOLDER) 99 .description("Folder where the Ogre plugins are located."); 100 SetConfigValue(ogrePlugins_, ORXONOX_OGRE_PLUGINS) 101 .description("Comma separated list of all plugins to load."); 96 102 SetConfigValue(ogreLogFile_, "ogre.log") 97 103 .description("Logfile for messages from Ogre. Use \"\" to suppress log file creation."); … … 102 108 SetConfigValue(ogreLogLevelCritical_, 2) 103 109 .description("Corresponding orxonox debug level for ogre Critical"); 104 SetConfigValue(defaultMasterKeybindings_, "def_masterKeybindings.ini")105 .description("Filename of default master keybindings.");106 110 } 107 111 … … 115 119 // Ogre setup procedure 116 120 setupOgre(); 121 // load all the required plugins for Ogre 122 loadOgrePlugins(); 123 // read resource declaration file 117 124 this->declareResources(); 118 this->loadRenderer(); // creates the render window 125 // Reads ogre config and creates the render window 126 this->loadRenderer(); 127 119 128 // TODO: Spread this so that this call only initialises things needed for the Console and GUI 120 129 this->initialiseResources(); … … 127 136 // load debug overlay 128 137 COUT(3) << "Loading Debug Overlay..." << std::endl; 129 this->debugOverlay_ = new XMLFile( Settings::getDataPath() + "overlay/debug.oxo");138 this->debugOverlay_ = new XMLFile((Core::getMediaPath() / "overlay" / "debug.oxo").file_string()); 130 139 Loader::open(debugOverlay_); 131 140 … … 138 147 // Configure master input state with a KeyBinder 139 148 masterKeyBinder_ = new KeyBinder(); 140 masterKeyBinder_->loadBindings("masterKeybindings.ini" , defaultMasterKeybindings_);149 masterKeyBinder_->loadBindings("masterKeybindings.ini"); 141 150 inputManager_->getMasterInputState()->addKeyHandler(masterKeyBinder_); 142 151 … … 200 209 delete this->ogreRoot_; 201 210 202 //#if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32203 211 // delete the ogre log and the logManager (since we have created it). 204 212 this->ogreLogger_->getDefaultLog()->removeListener(this); 205 213 this->ogreLogger_->destroyLog(Ogre::LogManager::getSingleton().getDefaultLog()); 206 214 delete this->ogreLogger_; 207 //#endif208 215 209 216 delete graphicsEngine_; … … 276 283 COUT(3) << "Setting up Ogre..." << std::endl; 277 284 278 // TODO: LogManager doesn't work on oli platform. The why is yet unknown. 279 //#if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32 285 if (ogreConfigFile_ == "") 286 { 287 COUT(2) << "Warning: Ogre config file set to \"\". Defaulting to config.cfg" << std::endl; 288 ModifyConfigValue(ogreConfigFile_, tset, "config.cfg"); 289 } 290 if (ogreLogFile_ == "") 291 { 292 COUT(2) << "Warning: Ogre log file set to \"\". Defaulting to ogre.log" << std::endl; 293 ModifyConfigValue(ogreLogFile_, tset, "ogre.log"); 294 } 295 296 boost::filesystem::path ogreConfigFilepath(Core::getConfigPath() / this->ogreConfigFile_); 297 boost::filesystem::path ogreLogFilepath(Core::getLogPath() / this->ogreLogFile_); 298 280 299 // create a new logManager 300 // Ogre::Root will detect that we've already created a Log 281 301 ogreLogger_ = new Ogre::LogManager(); 282 302 COUT(4) << "Ogre LogManager created" << std::endl; … … 284 304 // create our own log that we can listen to 285 305 Ogre::Log *myLog; 286 if (this->ogreLogFile_ == "") 287 myLog = ogreLogger_->createLog("ogre.log", true, false, true); 288 else 289 myLog = ogreLogger_->createLog(this->ogreLogFile_, true, false, false); 306 myLog = ogreLogger_->createLog(ogreLogFilepath.file_string(), true, false, false); 290 307 COUT(4) << "Ogre Log created" << std::endl; 291 308 292 309 myLog->setLogDetail(Ogre::LL_BOREME); 293 310 myLog->addListener(this); 294 //#endif 295 296 // Root will detect that we've already created a Log 311 297 312 COUT(4) << "Creating Ogre Root..." << std::endl; 298 313 299 if (ogrePluginsFile_ == "")300 {301 COUT(2) << "Warning: Ogre plugins file set to \"\". Defaulting to plugins.cfg" << std::endl;302 ModifyConfigValue(ogrePluginsFile_, tset, "plugins.cfg");303 }304 if (ogreConfigFile_ == "")305 {306 COUT(2) << "Warning: Ogre config file set to \"\". Defaulting to config.cfg" << std::endl;307 ModifyConfigValue(ogreConfigFile_, tset, "config.cfg");308 }309 if (ogreLogFile_ == "")310 {311 COUT(2) << "Warning: Ogre log file set to \"\". Defaulting to ogre.log" << std::endl;312 ModifyConfigValue(ogreLogFile_, tset, "ogre.log");313 }314 315 314 // check for config file existence because Ogre displays (caught) exceptions if not 316 std::ifstream probe; 317 probe.open(ogreConfigFile_.c_str()); 318 if (!probe) 315 if (!boost::filesystem::exists(ogreConfigFilepath)) 319 316 { 320 317 // create a zero sized file 321 318 std::ofstream creator; 322 creator.open(ogreConfigFile _.c_str());319 creator.open(ogreConfigFilepath.file_string().c_str()); 323 320 creator.close(); 324 321 } 325 else 326 probe.close(); 327 328 ogreRoot_ = new Ogre::Root(ogrePluginsFile_, ogreConfigFile_, ogreLogFile_); 329 330 #if 0 // Ogre 1.4.3 doesn't yet support setDebugOutputEnabled(.) 331 #if ORXONOX_PLATFORM != ORXONOX_PLATFORM_WIN32 332 // tame the ogre ouput so we don't get all the mess in the console 333 Ogre::Log* defaultLog = Ogre::LogManager::getSingleton().getDefaultLog(); 334 defaultLog->setDebugOutputEnabled(false); 335 defaultLog->setLogDetail(Ogre::LL_BOREME); 336 defaultLog->addListener(this); 337 #endif 338 #endif 322 323 // Leave plugins file empty. We're going to do that part manually later 324 ogreRoot_ = new Ogre::Root("", ogreConfigFilepath.file_string(), ogreLogFilepath.file_string()); 339 325 340 326 COUT(3) << "Ogre set up done." << std::endl; 327 } 328 329 void GSGraphics::loadOgrePlugins() 330 { 331 // just to make sure the next statement doesn't segfault 332 if (ogrePluginsFolder_ == "") 333 ogrePluginsFolder_ = "."; 334 335 boost::filesystem::path folder(ogrePluginsFolder_); 336 // Do some SubString magic to get the comma separated list of plugins 337 SubString plugins(ogrePlugins_, ",", " ", false, 92, false, 34, false, 40, 41, false, '\0'); 338 for (unsigned int i = 0; i < plugins.size(); ++i) 339 ogreRoot_->loadPlugin((folder / plugins[i]).file_string()); 341 340 } 342 341 … … 357 356 try 358 357 { 359 cf.load( Settings::getDataPath() + resourceFile_);358 cf.load((Core::getMediaPath() / resourceFile_).file_string()); 360 359 } 361 360 catch (...) … … 383 382 384 383 Ogre::ResourceGroupManager::getSingleton().addResourceLocation( 385 std::string(Settings::getDataPath() + archName), typeName, secName);384 (Core::getMediaPath() / archName).directory_string(), typeName, secName); 386 385 } 387 386 } -
code/trunk/src/orxonox/gamestates/GSGraphics.h
r2662 r2710 60 60 61 61 void setupOgre(); 62 void loadOgrePlugins(); 62 63 void declareResources(); 63 64 void loadRenderer(); … … 98 99 std::string resourceFile_; //!< resources file name 99 100 std::string ogreConfigFile_; //!< ogre config file name 100 std::string ogrePluginsFile_; //!< ogre plugins file name 101 std::string ogrePluginsFolder_; //!< Folder where the Ogre plugins are located 102 std::string ogrePlugins_; //!< Comma separated list of all plugins to load 101 103 std::string ogreLogFile_; //!< log file name for Ogre log messages 102 104 int ogreLogLevelTrivial_; //!< Corresponding Orxonx debug level for LL_TRIVIAL 103 105 int ogreLogLevelNormal_; //!< Corresponding Orxonx debug level for LL_NORMAL 104 106 int ogreLogLevelCritical_; //!< Corresponding Orxonx debug level for LL_CRITICAL 105 std::string defaultMasterKeybindings_; //!< Filename of default master keybindings.106 107 107 108 // console commands -
code/trunk/src/orxonox/gamestates/GSLevel.cc
r2662 r2710 46 46 #include "LevelManager.h" 47 47 #include "PlayerManager.h" 48 #include "Settings.h"49 48 50 49 namespace orxonox … … 76 75 { 77 76 SetConfigValue(keyDetectorCallbackCode_, "KeybindBindingStringKeyName="); 78 SetConfigValue(defaultKeybindings_, "def_keybindings.ini")79 .description("Filename of default keybindings.");80 77 } 81 78 … … 86 83 inputState_ = InputManager::getInstance().createInputState<SimpleInputState>("game", 20); 87 84 keyBinder_ = new KeyBinder(); 88 keyBinder_->loadBindings("keybindings.ini" , defaultKeybindings_);85 keyBinder_->loadBindings("keybindings.ini"); 89 86 inputState_->setHandler(keyBinder_); 90 87 … … 205 202 std::string levelName; 206 203 CommandLine::getValue("level", &levelName); 207 startFile_ = new XMLFile( Settings::getDataPath() + std::string("levels/")+ levelName);204 startFile_ = new XMLFile(Core::getMediaPathString() + "levels" + CP_SLASH + levelName); 208 205 Loader::open(startFile_); 209 206 } -
code/trunk/src/orxonox/gamestates/GSLevel.h
r2662 r2710 66 66 //##### ConfigValues ##### 67 67 std::string keyDetectorCallbackCode_; 68 //! Filename of default keybindings.69 std::string defaultKeybindings_;70 68 71 69 // console commands -
code/trunk/src/orxonox/gamestates/GSRoot.cc
r2662 r2710 44 44 #include "tools/Timer.h" 45 45 #include "objects/Tickable.h" 46 #include "Settings.h" 47 48 #if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32 46 47 #ifdef ORXONOX_PLATFORM_WINDOWS 49 48 # ifndef WIN32_LEAN_AND_MEAN 50 49 # define WIN32_LEAN_AND_MEAN … … 63 62 namespace orxonox 64 63 { 65 SetCommandLineArgument(dataPath, "").information("PATH");66 64 SetCommandLineArgument(limitToCPU, 1).information("0: off | #cpu"); 67 65 … … 71 69 , bPaused_(false) 72 70 , timeFactorPauseBackup_(1.0f) 73 , settings_(0)74 71 , tclBind_(0) 75 72 , tclThreadManager_(0) … … 113 110 this->luaBind_ = new LuaBind(); 114 111 115 // instantiate Settings class116 this->settings_ = new Settings();117 118 std::string dataPath = CommandLine::getValue("dataPath");119 if (dataPath != "")120 {121 if (*dataPath.end() != '/' && *dataPath.end() != '\\')122 Settings::tsetDataPath(dataPath + "/");123 else124 Settings::tsetDataPath(dataPath);125 }126 127 112 // initialise TCL 128 this->tclBind_ = new TclBind( Settings::getDataPath());113 this->tclBind_ = new TclBind(Core::getMediaPathPOSIXString()); 129 114 this->tclThreadManager_ = new TclThreadManager(tclBind_->getTclInterpreter()); 130 115 … … 182 167 delete this->tclBind_; 183 168 184 delete this->settings_;185 169 delete this->luaBind_; 186 170 … … 269 253 void GSRoot::setThreadAffinity(unsigned int limitToCPU) 270 254 { 271 #if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32255 #ifdef ORXONOX_PLATFORM_WINDOWS 272 256 // Get the current process core mask 273 257 DWORD procMask; -
code/trunk/src/orxonox/gamestates/GSRoot.h
r2662 r2710 81 81 bool bPaused_; 82 82 float timeFactorPauseBackup_; 83 Settings* settings_;84 83 TclBind* tclBind_; 85 84 TclThreadManager* tclThreadManager_;
Note: See TracChangeset
for help on using the changeset viewer.