Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 12, 2008, 10:53:51 PM (17 years ago)
Author:
landauf
Message:
  • added feature to add a callback function to configvalues. they get called if the value changes. an examples is in Core.cc.
  • changed the SetConfigValue macro and the Identifier::updateConfigValues() function to work properly with inherited classes in both possible cases: 1) they overwrite the config-value or 2) they don't. an example is ParticleProjectile that defines it's own speed_ configvalue.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core3/src/core/Core.cc

    r1586 r1596  
    9696    void Core::setConfigValues()
    9797    {
    98         SetConfigValue(softDebugLevelConsole_, 3).description("The maximal level of debug output shown in the console");
    99         SetConfigValue(softDebugLevelLogfile_, 3).description("The maximal level of debug output shown in the logfile");
    100         SetConfigValue(softDebugLevelShell_, 1).description("The maximal level of debug output shown in the ingame shell");
    101 
     98        SetConfigValue(softDebugLevelConsole_, 3).description("The maximal level of debug output shown in the console").callback(&Core::debugLevelChanged);
     99        SetConfigValue(softDebugLevelLogfile_, 3).description("The maximal level of debug output shown in the logfile").callback(&Core::debugLevelChanged);
     100        SetConfigValue(softDebugLevelShell_, 1).description("The maximal level of debug output shown in the ingame shell").callback(&Core::debugLevelChanged);
     101        SetConfigValue(language_, Language::getLanguage().defaultLanguage_).description("The language of the ingame text").callback(&Core::languageChanged);
     102    }
     103
     104    /**
     105        @brief Callback function if the debug level has changed.
     106    */
     107    void Core::debugLevelChanged()
     108    {
    102109        // softDebugLevel_ is the maximum of the 3 variables
    103110        this->softDebugLevel_ = this->softDebugLevelConsole_;
     
    111118        OutputHandler::setSoftDebugLevel(OutputHandler::LD_Logfile, this->softDebugLevelLogfile_);
    112119        OutputHandler::setSoftDebugLevel(OutputHandler::LD_Shell,   this->softDebugLevelShell_);
    113 
    114         std::string temp = this->language_;
    115         SetConfigValue(language_, Language::getLanguage().defaultLanguage_).description("The language of the ingame text");
    116 
    117         if (this->language_ != temp)
    118         {
    119             // Read the translation file after the language was configured
    120             Language::getLanguage().readTranslatedLanguageFile();
    121         }
     120    }
     121
     122    /**
     123        @brief Callback function if the language has changed.
     124    */
     125    void Core::languageChanged()
     126    {
     127        // Read the translation file after the language was configured
     128        Language::getLanguage().readTranslatedLanguageFile();
    122129    }
    123130
Note: See TracChangeset for help on using the changeset viewer.