Changeset 5781 for code/trunk/src/libraries/core/Core.cc
- Timestamp:
- Sep 24, 2009, 11:02:42 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/libraries/core/Core.cc
r5774 r5781 63 63 #include "util/SignalHandler.h" 64 64 #include "Clock.h" 65 #include "CommandExecutor.h" 65 66 #include "CommandLine.h" 66 67 #include "ConfigFileManager.h" … … 69 70 #include "DynLibManager.h" 70 71 #include "Factory.h" 72 #include "GameMode.h" 73 #include "GraphicsManager.h" 74 #include "GUIManager.h" 71 75 #include "Identifier.h" 72 76 #include "Language.h" 73 77 #include "LuaState.h" 78 #include "Shell.h" 79 #include "TclBind.h" 80 #include "TclThreadManager.h" 81 #include "input/InputManager.h" 74 82 75 83 // Boost 1.36 has some issues with deprecated functions that have been omitted … … 109 117 RegisterRootObject(CoreConfiguration); 110 118 this->setConfigValues(); 119 120 // External data directory only exists for dev runs 121 if (Core::isDevelopmentRun()) 122 { 123 // Possible data path override by the command line 124 if (!CommandLine::getArgument("externalDataPath")->hasDefaultValue()) 125 tsetExternalDataPath(CommandLine::getValue("externalDataPath")); 126 } 111 127 } 112 128 … … 178 194 } 179 195 196 /** 197 @brief 198 Temporary sets the external data path 199 @param path 200 The new data path 201 */ 202 void tsetExternalDataPath(const std::string& path) 203 { 204 externalDataPath_ = boost::filesystem::path(path); 205 } 206 180 207 void initializeRandomNumberGenerator() 181 208 { … … 201 228 boost::filesystem::path modulePath_; //!< Path to the modules 202 229 boost::filesystem::path dataPath_; //!< Path to the data file folder 230 boost::filesystem::path externalDataPath_; //!< Path to the external data file folder 203 231 boost::filesystem::path configPath_; //!< Path to the config file folder 204 232 boost::filesystem::path logPath_; //!< Path to the log file folder … … 209 237 // Cleanup guard for identifier destruction (incl. XMLPort, configValues, consoleCommands) 210 238 : identifierDestroyer_(Identifier::destroyAllIdentifiers) 239 // Cleanup guard for external console commands that don't belong to an Identifier 240 , consoleCommandDestroyer_(CommandExecutor::destroyExternalCommands) 211 241 , configuration_(new CoreConfiguration()) // Don't yet create config values! 212 242 , bDevRun_(false) 243 , bGraphicsLoaded_(false) 213 244 { 214 245 // Set the hard coded fixed paths … … 308 339 // possibility to configure everything below here 309 340 this->configuration_->initialise(); 341 342 // Load OGRE excluding the renderer and the render window 343 this->graphicsManager_.reset(new GraphicsManager(false)); 344 345 // initialise Tcl 346 this->tclBind_.reset(new TclBind(Core::getDataPathString())); 347 this->tclThreadManager_.reset(new TclThreadManager(tclBind_->getTclInterpreter())); 348 349 // create a shell 350 this->shell_.reset(new Shell()); 310 351 } 311 352 … … 316 357 Core::~Core() 317 358 { 359 } 360 361 void Core::loadGraphics() 362 { 363 // Any exception should trigger this, even in upgradeToGraphics (see its remarks) 364 Loki::ScopeGuard unloader = Loki::MakeObjGuard(*this, &Core::unloadGraphics); 365 366 // Upgrade OGRE to receive a render window 367 graphicsManager_->upgradeToGraphics(); 368 369 // Calls the InputManager which sets up the input devices. 370 inputManager_.reset(new InputManager()); 371 372 // load the CEGUI interface 373 guiManager_.reset(new GUIManager(graphicsManager_->getRenderWindow(), 374 inputManager_->getMousePosition(), graphicsManager_->isFullScreen())); 375 376 unloader.Dismiss(); 377 378 bGraphicsLoaded_ = true; 379 } 380 381 void Core::unloadGraphics() 382 { 383 this->guiManager_.reset();; 384 this->inputManager_.reset();; 385 this->graphicsManager_.reset(); 386 387 // Load Ogre::Root again, but without the render system 388 try 389 { this->graphicsManager_.reset(new GraphicsManager(false)); } 390 catch (...) 391 { 392 COUT(0) << "An exception occurred during 'unloadGraphics':" << Exception::handleMessage() << std::endl 393 << "Another exception might be being handled which may lead to undefined behaviour!" << std::endl 394 << "Terminating the program." << std::endl; 395 abort(); 396 } 397 398 bGraphicsLoaded_ = false; 318 399 } 319 400 … … 376 457 } 377 458 459 /*static*/ void Core::tsetExternalDataPath(const std::string& path) 460 { 461 getInstance().configuration_->tsetExternalDataPath(path); 462 } 463 378 464 /*static*/ const boost::filesystem::path& Core::getDataPath() 379 465 { … … 383 469 { 384 470 return getInstance().configuration_->dataPath_.string() + '/'; 471 } 472 473 /*static*/ const boost::filesystem::path& Core::getExternalDataPath() 474 { 475 return getInstance().configuration_->externalDataPath_; 476 } 477 /*static*/ std::string Core::getExternalDataPathString() 478 { 479 return getInstance().configuration_->externalDataPath_.string() + '/'; 385 480 } 386 481 … … 564 659 { 565 660 configuration_->dataPath_ = specialConfig::dataDevDirectory; 661 configuration_->externalDataPath_ = specialConfig::externalDataDevDirectory; 566 662 configuration_->configPath_ = specialConfig::configDevDirectory; 567 663 configuration_->logPath_ = specialConfig::logDevDirectory; … … 629 725 void Core::preUpdate(const Clock& time) 630 726 { 727 if (this->bGraphicsLoaded_) 728 { 729 // process input events 730 this->inputManager_->update(time); 731 // process gui events 732 this->guiManager_->update(time); 733 } 734 // process thread commands 735 this->tclThreadManager_->update(time); 631 736 } 632 737 633 738 void Core::postUpdate(const Clock& time) 634 739 { 740 if (this->bGraphicsLoaded_) 741 { 742 // Render (doesn't throw) 743 this->graphicsManager_->update(time); 744 } 635 745 } 636 746 }
Note: See TracChangeset
for help on using the changeset viewer.