Changeset 5782 for sandbox/src/libraries/core/Core.cc
- Timestamp:
- Sep 24, 2009, 11:32:39 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sandbox/src/libraries/core/Core.cc
r5759 r5782 63 63 #include "util/SignalHandler.h" 64 64 #include "Clock.h" 65 #include "CommandExecutor.h"66 65 #include "CommandLine.h" 67 66 #include "ConfigFileManager.h" … … 70 69 #include "DynLibManager.h" 71 70 #include "Factory.h" 72 #include "GameMode.h"73 #include "GraphicsManager.h"74 #include "GUIManager.h"75 71 #include "Identifier.h" 76 72 #include "Language.h" 77 73 #include "LuaState.h" 78 #include "Shell.h"79 #include "TclBind.h"80 #include "TclThreadManager.h"81 #include "input/InputManager.h"82 74 83 75 // Boost 1.36 has some issues with deprecated functions that have been omitted … … 117 109 RegisterRootObject(CoreConfiguration); 118 110 this->setConfigValues(); 119 120 // External data directory only exists for dev runs121 if (Core::isDevelopmentRun())122 {123 // Possible data path override by the command line124 if (!CommandLine::getArgument("externalDataPath")->hasDefaultValue())125 tsetExternalDataPath(CommandLine::getValue("externalDataPath"));126 }127 111 } 128 112 … … 194 178 } 195 179 196 /**197 @brief198 Temporary sets the external data path199 @param path200 The new data path201 */202 void tsetExternalDataPath(const std::string& path)203 {204 externalDataPath_ = boost::filesystem::path(path);205 }206 207 180 void initializeRandomNumberGenerator() 208 181 { … … 228 201 boost::filesystem::path modulePath_; //!< Path to the modules 229 202 boost::filesystem::path dataPath_; //!< Path to the data file folder 230 boost::filesystem::path externalDataPath_; //!< Path to the external data file folder231 203 boost::filesystem::path configPath_; //!< Path to the config file folder 232 204 boost::filesystem::path logPath_; //!< Path to the log file folder … … 237 209 // Cleanup guard for identifier destruction (incl. XMLPort, configValues, consoleCommands) 238 210 : identifierDestroyer_(Identifier::destroyAllIdentifiers) 239 // Cleanup guard for external console commands that don't belong to an Identifier240 , consoleCommandDestroyer_(CommandExecutor::destroyExternalCommands)241 211 , configuration_(new CoreConfiguration()) // Don't yet create config values! 242 212 , bDevRun_(false) 243 , bGraphicsLoaded_(false)244 213 { 245 214 // Set the hard coded fixed paths … … 339 308 // possibility to configure everything below here 340 309 this->configuration_->initialise(); 341 342 // Load OGRE excluding the renderer and the render window343 this->graphicsManager_.reset(new GraphicsManager(false));344 345 // initialise Tcl346 this->tclBind_.reset(new TclBind(Core::getDataPathString()));347 this->tclThreadManager_.reset(new TclThreadManager(tclBind_->getTclInterpreter()));348 349 // create a shell350 this->shell_.reset(new Shell());351 310 } 352 311 … … 357 316 Core::~Core() 358 317 { 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 window367 graphicsManager_->upgradeToGraphics();368 369 // Calls the InputManager which sets up the input devices.370 inputManager_.reset(new InputManager());371 372 // load the CEGUI interface373 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 system388 try389 { this->graphicsManager_.reset(new GraphicsManager(false)); }390 catch (...)391 {392 COUT(0) << "An exception occurred during 'unloadGraphics':" << Exception::handleMessage() << std::endl393 << "Another exception might be being handled which may lead to undefined behaviour!" << std::endl394 << "Terminating the program." << std::endl;395 abort();396 }397 398 bGraphicsLoaded_ = false;399 318 } 400 319 … … 457 376 } 458 377 459 /*static*/ void Core::tsetExternalDataPath(const std::string& path)460 {461 getInstance().configuration_->tsetExternalDataPath(path);462 }463 464 378 /*static*/ const boost::filesystem::path& Core::getDataPath() 465 379 { … … 469 383 { 470 384 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() + '/';480 385 } 481 386 … … 659 564 { 660 565 configuration_->dataPath_ = specialConfig::dataDevDirectory; 661 configuration_->externalDataPath_ = specialConfig::externalDataDevDirectory;662 566 configuration_->configPath_ = specialConfig::configDevDirectory; 663 567 configuration_->logPath_ = specialConfig::logDevDirectory; … … 725 629 void Core::preUpdate(const Clock& time) 726 630 { 727 if (this->bGraphicsLoaded_)728 {729 // process input events730 this->inputManager_->update(time);731 // process gui events732 this->guiManager_->update(time);733 }734 // process thread commands735 this->tclThreadManager_->update(time);736 631 } 737 632 738 633 void Core::postUpdate(const Clock& time) 739 634 { 740 if (this->bGraphicsLoaded_)741 {742 // Render (doesn't throw)743 this->graphicsManager_->update(time);744 }745 635 } 746 636 }
Note: See TracChangeset
for help on using the changeset viewer.