Changeset 10479 for code/branches/core7/src/libraries/core/Core.cc
- Timestamp:
- May 25, 2015, 7:20:21 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core7/src/libraries/core/Core.cc
r10464 r10479 62 62 #include "commandline/CommandLineIncludes.h" 63 63 #include "config/ConfigFileManager.h" 64 #include "config/ConfigValueIncludes.h"65 #include "CoreIncludes.h"66 64 #include "DynLibManager.h" 67 65 #include "GameMode.h" … … 95 93 #endif 96 94 97 // register Core as an abstract class to avoid problems if the class hierarchy is created within Core-constructor98 RegisterAbstractClass(Core).inheritsFrom<Configurable>();99 100 95 Core::Core(const std::string& cmdLine) 101 96 : pathConfig_(NULL) … … 114 109 , graphicsScope_(NULL) 115 110 , bGraphicsLoaded_(false) 116 , bStartIOConsole_(true) 117 , lastLevelTimestamp_(0) 118 , ogreConfigTimestamp_(0) 119 , bDevMode_(false) 111 , config_(NULL) 120 112 , destructionHelper_(this) 121 113 { … … 188 180 // Do this soon after the ConfigFileManager has been created to open up the 189 181 // possibility to configure everything below here 190 RegisterObject(Core);191 182 orxout(internal_info) << "configuring Core" << endl; 192 this->setConfigValues(); 183 this->config_ = new CoreConfig(); 184 this->config_->setConfigValues(); // TODO: move this into CoreConfig constructor (but resolve dependency to Language) 193 185 194 186 // Set the correct log path and rewrite the log file with the correct log levels … … 197 189 #if !defined(ORXONOX_PLATFORM_APPLE) && !defined(ORXONOX_USE_WINMAIN) 198 190 // Create persistent IO console 199 if (CommandLineParser::getValue("noIOConsole").get<bool>()) 200 { 201 ModifyConfigValue(bStartIOConsole_, tset, false); 202 } 203 if (this->bStartIOConsole_) 191 if (CommandLineParser::getValue("noIOConsole").get<bool>() == false && this->config_->getStartIOConsole()) 204 192 { 205 193 orxout(internal_info) << "creating IO console" << endl; … … 248 236 { 249 237 orxout(internal_status) << "destroying Core object..." << endl; 250 251 // Remove us from the object lists again to avoid problems when destroying them252 this->unregisterObject();253 238 254 239 safeObjectDelete(&graphicsScope_); … … 261 246 safeObjectDelete(&ioConsole_); 262 247 safeObjectDelete(&loaderInstance_); 248 safeObjectDelete(&config_); 263 249 safeObjectDelete(&languageInstance_); 264 250 safeObjectDelete(&configFileManager_); … … 271 257 272 258 orxout(internal_status) << "finished destroying Core object" << endl; 273 }274 275 //! Function to collect the SetConfigValue-macro calls.276 void Core::setConfigValues()277 {278 SetConfigValueExternal(OutputManager::getInstance().getLogWriter()->configurableMaxLevel_,279 OutputManager::getInstance().getLogWriter()->getConfigurableSectionName(),280 OutputManager::getInstance().getLogWriter()->getConfigurableMaxLevelName(),281 OutputManager::getInstance().getLogWriter()->configurableMaxLevel_)282 .description("The maximum level of output shown in the log file")283 .callback(static_cast<BaseWriter*>(OutputManager::getInstance().getLogWriter()), &BaseWriter::changedConfigurableLevel);284 SetConfigValueExternal(OutputManager::getInstance().getLogWriter()->configurableAdditionalContextsMaxLevel_,285 OutputManager::getInstance().getLogWriter()->getConfigurableSectionName(),286 OutputManager::getInstance().getLogWriter()->getConfigurableAdditionalContextsMaxLevelName(),287 OutputManager::getInstance().getLogWriter()->configurableAdditionalContextsMaxLevel_)288 .description("The maximum level of output shown in the log file for additional contexts")289 .callback(static_cast<BaseWriter*>(OutputManager::getInstance().getLogWriter()), &BaseWriter::changedConfigurableAdditionalContextsLevel);290 SetConfigValueExternal(OutputManager::getInstance().getLogWriter()->configurableAdditionalContexts_,291 OutputManager::getInstance().getLogWriter()->getConfigurableSectionName(),292 OutputManager::getInstance().getLogWriter()->getConfigurableAdditionalContextsName(),293 OutputManager::getInstance().getLogWriter()->configurableAdditionalContexts_)294 .description("Additional output contexts shown in the log file")295 .callback(static_cast<BaseWriter*>(OutputManager::getInstance().getLogWriter()), &BaseWriter::changedConfigurableAdditionalContexts);296 297 SetConfigValue(bDevMode_, PathConfig::buildDirectoryRun())298 .description("Developer mode. If not set, hides some things from the user to not confuse him.")299 .callback(this, &Core::devModeChanged);300 SetConfigValue(language_, Language::getInstance().defaultLanguage_)301 .description("The language of the in game text")302 .callback(this, &Core::languageChanged);303 SetConfigValue(bInitRandomNumberGenerator_, true)304 .description("If true, all random actions are different each time you start the game")305 .callback(this, &Core::initRandomNumberGenerator);306 SetConfigValue(bStartIOConsole_, true)307 .description("Set to false if you don't want to use the IOConsole (for Lua debugging for instance)");308 SetConfigValue(lastLevelTimestamp_, 0)309 .description("Timestamp when the last level was started.");310 SetConfigValue(ogreConfigTimestamp_, 0)311 .description("Timestamp when the ogre config file was changed.");312 }313 314 /** Callback function for changes in the dev mode that affect debug levels.315 The function behaves according to these rules:316 - 'normal' mode is defined based on where the program was launched: if317 the launch path was the build directory, development mode \c on is318 normal, otherwise normal means development mode \c off.319 - Debug levels should not be hard configured (\c config instead of320 \c tconfig) in non 'normal' mode to avoid strange behaviour.321 - Changing the development mode from 'normal' to the other state will322 immediately change the debug levels to predefined values which can be323 reconfigured with \c tconfig.324 @note325 The debug levels for the IOConsole and the InGameConsole can be found326 in the Shell class. The same rules apply.327 */328 void Core::devModeChanged()329 {330 // Inform listeners331 ObjectList<DevModeListener>::iterator it = ObjectList<DevModeListener>::begin();332 for (; it != ObjectList<DevModeListener>::end(); ++it)333 it->devModeChanged(bDevMode_);334 }335 336 //! Callback function if the language has changed.337 void Core::languageChanged()338 {339 // Read the translation file after the language was configured340 Language::getInstance().readTranslatedLanguageFile();341 }342 343 void Core::initRandomNumberGenerator()344 {345 static bool bInitialized = false;346 if (!bInitialized && this->bInitRandomNumberGenerator_)347 {348 srand(static_cast<unsigned int>(time(0)));349 rand();350 bInitialized = true;351 }352 259 } 353 260 … … 429 336 } 430 337 431 //! Sets the language in the config-file back to the default.432 void Core::resetLanguage()433 {434 ResetConfigValue(language_);435 }436 437 338 /** 438 339 @note … … 511 412 } 512 413 } 513 514 void Core::updateLastLevelTimestamp()515 {516 ModifyConfigValue(lastLevelTimestamp_, set, static_cast<long long>(time(NULL)));517 }518 519 void Core::updateOgreConfigTimestamp()520 {521 ModifyConfigValue(ogreConfigTimestamp_, set, static_cast<long long>(time(NULL)));522 }523 524 525 RegisterAbstractClass(DevModeListener).inheritsFrom<Listable>();526 527 DevModeListener::DevModeListener()528 {529 RegisterObject(DevModeListener);530 }531 414 }
Note: See TracChangeset
for help on using the changeset viewer.