Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jul 4, 2011, 2:47:44 AM (13 years ago)
Author:
rgrieder
Message:

Merged unity_build branch back to trunk.

Features:

  • Implemented fully automatic build units to speed up compilation if requested
  • Added DOUT macro for quick debug output
  • Activated text colouring in the POSIX IOConsole
  • DeclareToluaInterface is not necessary anymore

Improvements:

  • Output levels now change appropriately when switch back and forth from dev mode
  • Log level for the file output is now also correct during startup
  • Removed some header file dependencies in core and tools to speed up compilation

no more file for command line options

  • Improved util::tribool by adapting some concepts from boost::tribool

Regressions:

  • It is not possible anymore to specify command line arguments in an extra file because we've got config values for that purpose.
Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/libraries/core/Core.cc

    r8505 r8729  
    6969#include "Language.h"
    7070#include "LuaState.h"
     71#include "ObjectList.h"
    7172#include "command/ConsoleCommand.h"
    7273#include "command/IOConsole.h"
     
    131132
    132133        // Parse command line arguments AFTER the modules have been loaded (static code!)
    133         CommandLineParser::parseCommandLine(cmdLine);
     134        CommandLineParser::parse(cmdLine);
    134135
    135136        // Set configurable paths like log, config and media
     
    143144        // Set the correct log path. Before this call, /tmp (Unix) or %TEMP% (Windows) was used
    144145        OutputHandler::getInstance().setLogPath(PathConfig::getLogPathString());
    145 
    146         // Parse additional options file now that we know its path
    147         CommandLineParser::parseFile();
    148146
    149147#ifdef ORXONOX_PLATFORM_WINDOWS
     
    168166        RegisterRootObject(Core);
    169167        this->setConfigValues();
     168        // Rewrite the log file with the correct log levels
     169        OutputHandler::getInstance().rewriteLogFile();
    170170
    171171#if !defined(ORXONOX_PLATFORM_APPLE) && !defined(ORXONOX_USE_WINMAIN)
     
    230230    }
    231231
     232    namespace DefaultLevelLogFile
     233    {
     234        const OutputLevel::Value Dev  = OutputLevel::Debug;
     235        const OutputLevel::Value User = OutputLevel::Info;
     236    }
     237
    232238    //! Function to collect the SetConfigValue-macro calls.
    233239    void Core::setConfigValues()
    234240    {
    235 #ifdef ORXONOX_RELEASE
    236         const unsigned int defaultLevelLogFile = 3;
    237 #else
    238         const unsigned int defaultLevelLogFile = 4;
    239 #endif
    240         SetConfigValueExternal(softDebugLevelLogFile_, "OutputHandler", "softDebugLevelLogFile", defaultLevelLogFile)
    241             .description("The maximum level of debug output shown in the log file");
    242         OutputHandler::getInstance().setSoftDebugLevel(OutputHandler::logFileOutputListenerName_s, this->softDebugLevelLogFile_);
     241        // Choose the default level according to the path Orxonox was started (build directory or not)
     242        OutputLevel::Value defaultLogLevel = (PathConfig::buildDirectoryRun() ? DefaultLevelLogFile::Dev : DefaultLevelLogFile::User);
     243
     244        SetConfigValueExternal(debugLevelLogFile_, "OutputHandler", "debugLevelLogFile", defaultLogLevel)
     245            .description("The maximum level of debug output written to the log file");
     246        OutputHandler::getInstance().setSoftDebugLevel("LogFile", debugLevelLogFile_);
    243247
    244248        SetConfigValue(bDevMode_, PathConfig::buildDirectoryRun())
    245             .description("Developer mode. If not set, hides some things from the user to not confuse him.");
     249            .description("Developer mode. If not set, hides some things from the user to not confuse him.")
     250            .callback(this, &Core::devModeChanged);
    246251        SetConfigValue(language_, Language::getInstance().defaultLanguage_)
    247252            .description("The language of the in game text")
     
    258263    }
    259264
     265    /** Callback function for changes in the dev mode that affect debug levels.
     266        The function behaves according to these rules:
     267        - 'normal' mode is defined based on where the program was launched: if
     268          the launch path was the build directory, development mode \c on is
     269          normal, otherwise normal means development mode \c off.
     270        - Debug levels should not be hard configured (\c config instead of
     271          \c tconfig) in non 'normal' mode to avoid strange behaviour.
     272        - Changing the development mode from 'normal' to the other state will
     273          immediately change the debug levels to predefined values which can be
     274          reconfigured with \c tconfig.
     275    @note
     276        The debug levels for the IOConsole and the InGameConsole can be found
     277        in the Shell class. The same rules apply.
     278    */
     279    void Core::devModeChanged()
     280    {
     281        bool isNormal = (bDevMode_ == PathConfig::buildDirectoryRun());
     282        if (isNormal)
     283        {
     284            ModifyConfigValueExternal(debugLevelLogFile_, "debugLevelLogFile", update);
     285        }
     286        else
     287        {
     288            OutputLevel::Value level = (bDevMode_ ? DefaultLevelLogFile::Dev : DefaultLevelLogFile::User);
     289            ModifyConfigValueExternal(debugLevelLogFile_, "debugLevelLogFile", tset, level);
     290        }
     291
     292        // Inform listeners
     293        ObjectList<DevModeListener>::iterator it = ObjectList<DevModeListener>::begin();
     294        for (; it != ObjectList<DevModeListener>::end(); ++it)
     295            it->devModeChanged(bDevMode_);
     296    }
     297
    260298    //! Callback function if the language has changed.
    261299    void Core::languageChanged()
     
    440478        ModifyConfigValue(ogreConfigTimestamp_, set, static_cast<long long>(time(NULL)));
    441479    }
     480
     481
     482    DevModeListener::DevModeListener()
     483    {
     484        RegisterRootObject(DevModeListener);
     485    }
    442486}
Note: See TracChangeset for help on using the changeset viewer.