Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Feb 20, 2009, 5:32:04 PM (16 years ago)
Author:
rgrieder
Message:

Fixed install target:

  • log and config file go a to separate folder each
  • The SignalHandler crash log is now "orxonox_crash.log" to avoid opening the file twice which might result in problems
  • moved tcl scripts to media/tcl8.#/ as a temporary solution. I've also created a ticket to fix this.
  • UPDATE YOUR MEDIA REPOSITORY
  • orxonox.log pre-main gets written to either %TEMP% (windows) or /tmp (Unix) and when the path was set, the content is copied.
  • removed Settings class and moved media path to Core
  • media, log and config path are now all in Core where only the media path can be configured via ini file or command line
  • Core::isDevBuild() tells whether we are running in the build or the installation directory (determined by the presence of "orxonox_dev_build.kepp_me" in the binary dir)
  • renamed Settings::getDataPath to Core::getMediaPath
Location:
code/branches/buildsystem3/src
Files:
2 deleted
24 edited

Legend:

Unmodified
Added
Removed
  • code/branches/buildsystem3/src/CMakeLists.txt

    r2670 r2685  
    6565INCLUDE(CheckIncludeFileCXX)
    6666CHECK_INCLUDE_FILE_CXX(iso646.h HAVE_ISO646_H)
     67
     68# XCode and Visual Studio support multiple configurations. In order to tell the
     69# which one we have to define the macros separately for each configuration
     70ADD_COMPILER_FLAGS("-DCMAKE_BUILD_TYPE=Debug"          Debug)
     71ADD_COMPILER_FLAGS("-DCMAKE_BIULD_TYPE=Release"        Release)
     72ADD_COMPILER_FLAGS("-DCMAKE_BUILD_TYPE=RelWithDebInfo" RelWithDebInfo)
     73ADD_COMPILER_FLAGS("-DCMAKE_BUILD_TYPE=MinSizeRel"     MinSizeRel)
    6774
    6875SET(GENERATED_FILE_COMMENT
  • code/branches/buildsystem3/src/OrxonoxConfig.h.in

    r2673 r2685  
    164164
    165165#cmakedefine HAVE_STDDEF_H
     166/* Quite large, do not include unless necessary
    166167#ifdef HAVE_STDDEF_H
    167168#  include <stddef.h>
    168169#endif
     170*/
    169171
    170172/* Visual Leak Detector looks for memory leaks */
     
    185187#cmakedefine USE_DEPENDENCY_PACKAGE
    186188
     189/* Using MSVC or XCode IDE */
     190#cmakedefine CMAKE_CONFIGURATION_TYPES
     191
     192/* Macros used in the next section */
     193#define MACRO_CONCATENATE(str1, str2) str1##str2
     194#define MACRO_QUOTEME_AUX(x) #x
     195#define MACRO_QUOTEME(x) MACRO_QUOTEME_AUX(x)
     196
    187197/* Handle default ConfigValues */
    188198namespace orxonox
    189199{
    190 #ifdef ORXONOX_PLATFORM_WINDOWS
    191     const char* const ORXONOX_MEDIA_PATH("../media");
    192 #elif defined(ORXONOX_PLATFORM_LINUX)
    193     const char* const ORXONOX_MEDIA_PATH("../../share/orxonox");
    194 #else
    195     /* TODO: Apple? */
    196     const char* const ORXONOX_MEDIA_PATH("../../share/orxonox");
     200    const char* const ORXONOX_MEDIA_INSTALL_PATH ("@ORXONOX_MEDIA_INSTALL_PATH@/");
     201    const char* const ORXONOX_CONFIG_INSTALL_PATH("@ORXONOX_CONFIG_INSTALL_PATH@/");
     202    const char* const ORXONOX_LOG_INSTALL_PATH   ("@ORXONOX_LOG_INSTALL_PATH@/");
     203
     204    const char* const ORXONOX_MEDIA_DEV_PATH     ("@ORXONOX_MEDIA_DEV_PATH@/");
     205#ifdef CMAKE_CONFIGURATION_TYPES
     206    const char* const ORXONOX_CONFIG_DEV_PATH    ("@ORXONOX_CONFIG_DEV_PATH@/" MACRO_QUOTEME(CMAKE_BUILD_TYPE) "/");
     207    const char* const ORXONOX_LOG_DEV_PATH       ("@ORXONOX_LOG_DEV_PATH@/"    MACRO_QUOTEME(CMAKE_BUILD_TYPE) "/");
     208#else
     209    const char* const ORXONOX_CONFIG_DEV_PATH    ("@ORXONOX_CONFIG_DEV_PATH@/");
     210    const char* const ORXONOX_LOG_DEV_PATH       ("@ORXONOX_LOG_DEV_PATH@/");
    197211#endif
    198212   
     213    /* OGRE Plugins */
    199214#ifdef NDEBUG
    200215    const char* const ORXONOX_OGRE_PLUGINS("@OGRE_PLUGINS_RELEASE@");
     
    214229}
    215230
    216 
    217231#endif /* _OrxonoxConfig_H__ */
  • code/branches/buildsystem3/src/core/CMakeLists.txt

    r2664 r2685  
    7070IF(GCC_NO_SYSTEM_HEADER_SUPPORT)
    7171  # Get around displaying a few hundred lines of warning code
    72   SET_SOURCE_FILES_PROPERTIES(ArgumentCompletionFunctions.cc PROPERTIES COMPILE_FLAGS "-w")
     72  SET_SOURCE_FILES_PROPERTIES(
     73    ArgumentCompletionFunctions.cc
     74    CommandLine.cc
     75    ConfigFileManager.cc
     76    Language.cc
     77    LuaBind.cc
     78    input/KeyBinder.cc
     79    PROPERTIES COMPILE_FLAGS "-Wno-sign-compare")
    7380ENDIF()
    7481
  • code/branches/buildsystem3/src/core/CommandLine.cc

    r2662 r2685  
    2929#include "CommandLine.h"
    3030
     31#include <boost/filesystem.hpp>
    3132#include "util/String.h"
    3233#include "util/SubString.h"
     34#include "Core.h"
    3335
    3436namespace orxonox
     
    299301        this->_parse(args);
    300302
     303        std::string filename = CommandLine::getValue("optionsFile").getString();
     304        boost::filesystem::path folder(Core::getConfigPath());
     305        boost::filesystem::path filepath(folder/filename);
     306
    301307        // look for additional arguments in given file or start.ini as default
    302308        // They will not overwrite the arguments given directly
    303309        std::ifstream file;
    304         std::string filename = CommandLine::getValue("optionsFile").getString();
    305         file.open(filename.c_str());
     310        file.open(filepath.native_file_string().c_str());
    306311        args.clear();
    307312        if (file)
  • code/branches/buildsystem3/src/core/ConfigFileManager.cc

    r2662 r2685  
    3030
    3131#include <cassert>
     32#include <boost/filesystem.hpp>
     33
    3234#include "util/Convert.h"
    3335#include "util/String.h"
    3436#include "ConsoleCommand.h"
    3537#include "ConfigValueContainer.h"
     38#include "Core.h"
    3639
    3740namespace orxonox
     
    223226        this->clear();
    224227
     228        boost::filesystem::path filepath(Core::getConfigPath() + "/" + this->filename_);
     229
    225230        // This creates the config file if it's not existing
    226231        std::ofstream createFile;
    227         createFile.open(this->filename_.c_str(), std::fstream::app);
     232        createFile.open(filepath.native_file_string().c_str(), std::fstream::app);
    228233        createFile.close();
    229234
    230235        // Open the file
    231236        std::ifstream file;
    232         file.open(this->filename_.c_str(), std::fstream::in);
     237        file.open(filepath.native_file_string().c_str(), std::fstream::in);
    233238
    234239        if (!file.is_open())
     
    337342    void ConfigFile::save() const
    338343    {
     344        boost::filesystem::path filepath(Core::getConfigPath() + "/" + this->filename_);
     345
    339346        std::ofstream file;
    340         file.open(this->filename_.c_str(), std::fstream::out);
     347        file.open(filepath.native_file_string().c_str(), std::fstream::out);
    341348        file.setf(std::ios::fixed, std::ios::floatfield);
    342349        file.precision(6);
  • code/branches/buildsystem3/src/core/Core.cc

    r2662 r2685  
    3737#include "CoreIncludes.h"
    3838#include "ConfigValueIncludes.h"
     39#include "LuaBind.h"
     40#include "CommandLine.h"
    3941
    4042namespace orxonox
     
    4648    bool Core::bIsMaster_s      = false;
    4749
     50    bool Core::isDevBuild_s     = false;
     51    std::string Core::configPath_s(ORXONOX_CONFIG_INSTALL_PATH); // from OrxonoxConfig.h
     52    std::string Core::logPath_s   (ORXONOX_LOG_INSTALL_PATH);    // from OrxonoxConfig.h
     53
    4854    Core* Core::singletonRef_s = 0;
     55
     56    SetCommandLineArgument(mediaPath, "").information("PATH");
    4957
    5058    /**
     
    5866        assert(Core::singletonRef_s == 0);
    5967        Core::singletonRef_s = this;
     68
    6069        this->bInitializeRandomNumberGenerator_ = false;
    61 
    6270        this->setConfigValues();
     71
     72        // Set the correct log path. Before this call, /tmp (Unix) or %TEMP% was used
     73        OutputHandler::getOutStream().setLogPath(Core::logPath_s);
     74
     75        // Possible media path override by the command line
     76        if (!CommandLine::getArgument("mediaPath")->hasDefaultValue())
     77        {
     78            std::string mediaPath = CommandLine::getValue("mediaPath");
     79            Core::tsetMediaPath(mediaPath);
     80        }
    6381    }
    6482
     
    7795    void Core::setConfigValues()
    7896    {
    79         SetConfigValue(softDebugLevelConsole_, 3).description("The maximal level of debug output shown in the console").callback(this, &Core::debugLevelChanged);
    80         SetConfigValue(softDebugLevelLogfile_, 3).description("The maximal level of debug output shown in the logfile").callback(this, &Core::debugLevelChanged);
    81         SetConfigValue(softDebugLevelShell_, 1).description("The maximal level of debug output shown in the ingame shell").callback(this, &Core::debugLevelChanged);
     97#ifdef NDEBUG
     98        const unsigned int defaultLevelConsole = 1;
     99        const unsigned int defaultLevelLogfile = 3;
     100        const unsigned int defaultLevelShell   = 1;
     101#else
     102        const unsigned int defaultLevelConsole = 3;
     103        const unsigned int defaultLevelLogfile = 4;
     104        const unsigned int defaultLevelShell   = 3;
     105#endif
     106        SetConfigValue(softDebugLevelConsole_, defaultLevelConsole)
     107            .description("The maximal level of debug output shown in the console").callback(this, &Core::debugLevelChanged);
     108        SetConfigValue(softDebugLevelLogfile_, defaultLevelLogfile)
     109            .description("The maximal level of debug output shown in the logfile").callback(this, &Core::debugLevelChanged);
     110        SetConfigValue(softDebugLevelShell_, defaultLevelShell)
     111            .description("The maximal level of debug output shown in the ingame shell").callback(this, &Core::debugLevelChanged);
     112
    82113        SetConfigValue(language_, Language::getLanguage().defaultLanguage_).description("The language of the ingame text").callback(this, &Core::languageChanged);
    83114        SetConfigValue(bInitializeRandomNumberGenerator_, true).description("If true, all random actions are different each time you start the game").callback(this, &Core::initializeRandomNumberGenerator);
     115
     116        // Media path (towards config and log path) is ini-configurable
     117        const char* defaultMediaPath = ORXONOX_MEDIA_INSTALL_PATH;
     118        if (Core::isDevBuild())
     119            defaultMediaPath = ORXONOX_MEDIA_DEV_PATH;
     120
     121        SetConfigValue(mediaPath_, defaultMediaPath)
     122            .description("Relative path to the game data.").callback(this, &Core::mediaPathChanged);
     123
    84124    }
    85125
     
    109149        // Read the translation file after the language was configured
    110150        Language::getLanguage().readTranslatedLanguageFile();
     151    }
     152
     153    /**
     154    @brief
     155        Callback function if the media path has changed.
     156    */
     157    void Core::mediaPathChanged()
     158    {
     159        if (mediaPath_ != "" && mediaPath_[mediaPath_.size() - 1] != '/')
     160        {
     161            ModifyConfigValue(mediaPath_, set, mediaPath_ + "/");
     162        }
     163
     164        if (mediaPath_ == "")
     165        {
     166            ModifyConfigValue(mediaPath_, set, "/");
     167            COUT(2) << "Warning: Data path set to \"/\", is that really correct?" << std::endl;
     168        }
    111169    }
    112170
     
    177235    }
    178236
     237    /**
     238    @brief
     239        Temporary sets the media path
     240    @param path
     241        The new media path
     242    */
     243    void Core::_tsetMediaPath(const std::string& path)
     244    {
     245        if (*path.end() != '/' && *path.end() != '\\')
     246        {
     247            ModifyConfigValue(mediaPath_, tset, path + "/");
     248        }
     249        else
     250        {
     251            ModifyConfigValue(mediaPath_, tset, path);
     252        }
     253    }
     254
    179255    void Core::initializeRandomNumberGenerator()
    180256    {
     
    187263        }
    188264    }
     265
     266    /*static*/ void Core::setDevBuild()
     267    {
     268        // Be careful never to call this function before main()!
     269
     270        Core::isDevBuild_s = true;
     271        // Constants taken from OrxonoxConfig.h
     272        Core::configPath_s = ORXONOX_CONFIG_DEV_PATH;
     273        Core::logPath_s    = ORXONOX_LOG_DEV_PATH;
     274    }
    189275}
  • code/branches/buildsystem3/src/core/Core.h

    r2662 r2685  
    4444#include "util/OutputHandler.h"
    4545
     46// Only allow main to access setDevBuild, so we need a forward declaration
     47int main(int, char**);
     48
    4649namespace orxonox
    4750{
     
    4952    class _CoreExport Core : public OrxonoxClass
    5053    {
     54        friend int ::main(int, char**); // sets isDevBuild_s
     55
    5156        public:
    5257            Core();
    5358            ~Core();
    5459            void setConfigValues();
    55             void debugLevelChanged();
    56             void languageChanged();
    5760
    5861            static Core& getInstance() { assert(Core::singletonRef_s); return *Core::singletonRef_s; }
     
    6265            static const std::string& getLanguage();
    6366            static void  resetLanguage();
     67
     68            static bool isDevBuild() { return Core::isDevBuild_s; }
     69
     70            static const std::string& getMediaPath()
     71            { assert(singletonRef_s); return singletonRef_s->mediaPath_; }
     72            static void tsetMediaPath(const std::string& path)
     73            { assert(singletonRef_s); singletonRef_s->_tsetMediaPath(path); }
     74            static const std::string& getConfigPath() { return configPath_s; }
     75            static const std::string& getLogPath()    { return logPath_s; }
    6476
    6577            // fast access global variables.
     
    7991            void resetLanguageIntern();
    8092            void initializeRandomNumberGenerator();
     93            void debugLevelChanged();
     94            void languageChanged();
     95            void mediaPathChanged();
     96            void _tsetMediaPath(const std::string& path);
     97
     98            static void setDevBuild();
    8199
    82100            int softDebugLevel_;                            //!< The debug level
     
    85103            int softDebugLevelShell_;                       //!< The debug level for the ingame shell
    86104            std::string language_;                          //!< The language
    87             bool bInitializeRandomNumberGenerator_;          //!< If true, srand(time(0)) is called
     105            bool bInitializeRandomNumberGenerator_;         //!< If true, srand(time(0)) is called
     106            std::string mediaPath_;                         //!< Path to the data/media file folder
    88107
    89108            static bool bShowsGraphics_s;                   //!< global variable that tells whether to show graphics
     
    93112            static bool bIsMaster_s;
    94113
     114            static bool isDevBuild_s;                       //!< True for builds in the build directory (not installed)
     115            static std::string configPath_s;                //!< Path to the config file folder
     116            static std::string logPath_s;                   //!< Path to the log file folder
     117
    95118            static Core* singletonRef_s;
    96119    };
  • code/branches/buildsystem3/src/core/Language.cc

    r2662 r2685  
    3535
    3636#include <fstream>
     37#include <boost/filesystem.hpp>
    3738
    3839#include "Core.h"
     
    205206        COUT(4) << "Read default language file." << std::endl;
    206207
     208        boost::filesystem::path folder(Core::getConfigPath());
     209        boost::filesystem::path filepath(folder/getFilename(this->defaultLanguage_));
     210
    207211        // This creates the file if it's not existing
    208212        std::ofstream createFile;
    209         createFile.open(getFilename(this->defaultLanguage_).c_str(), std::fstream::app);
     213        createFile.open(filepath.native_file_string().c_str(), std::fstream::app);
    210214        createFile.close();
    211215
    212216        // Open the file
    213217        std::ifstream file;
    214         file.open(getFilename(this->defaultLanguage_).c_str(), std::fstream::in);
     218        file.open(filepath.native_file_string().c_str(), std::fstream::in);
    215219
    216220        if (!file.is_open())
     
    254258        COUT(4) << "Read translated language file (" << Core::getLanguage() << ")." << std::endl;
    255259
     260        boost::filesystem::path folder(Core::getConfigPath());
     261        boost::filesystem::path filepath(folder/getFilename(Core::getLanguage()));
     262
    256263        // Open the file
    257264        std::ifstream file;
    258         file.open(getFilename(Core::getLanguage()).c_str(), std::fstream::in);
     265        file.open(filepath.native_file_string().c_str(), std::fstream::in);
    259266
    260267        if (!file.is_open())
     
    308315        COUT(4) << "Language: Write default language file." << std::endl;
    309316
     317        boost::filesystem::path folder(Core::getConfigPath());
     318        boost::filesystem::path filepath(folder/getFilename(this->defaultLanguage_));
     319
    310320        // Open the file
    311321        std::ofstream file;
    312         file.open(getFilename(this->defaultLanguage_).c_str(), std::fstream::out);
     322        file.open(filepath.native_file_string().c_str(), std::fstream::out);
    313323
    314324        if (!file.is_open())
  • code/branches/buildsystem3/src/core/LuaBind.cc

    r2664 r2685  
    3737}
    3838#include <tolua/tolua++.h>
    39 
     39#include <boost/filesystem.hpp>
     40
     41#include "util/String.h"
     42#include "util/Debug.h"
    4043#include "ToluaBindCore.h"
    41 #include "util/String.h"
    42 #include "CoreIncludes.h"
     44#include "Core.h"
    4345
    4446namespace orxonox
     
    5052    assert(LuaBind::singletonRef_s == 0);
    5153    LuaBind::singletonRef_s = this;
     54
     55    this->includePath_ = Core::getMediaPath();
    5256
    5357    luaState_ = lua_open();
     
    8286  void LuaBind::loadFile(std::string filename, bool luaTags)
    8387  {
     88    boost::filesystem::path filepath(filename);
     89
    8490    output_ = "";
    8591    std::ifstream file;
    86     file.open(filename.c_str(), std::fstream::in);
     92    file.open(filepath.native_file_string().c_str(), std::fstream::in);
    8793
    8894    if (!file.is_open())
  • code/branches/buildsystem3/src/core/input/KeyBinder.cc

    r2662 r2685  
    3636#include <fstream>
    3737#include <string>
     38#include <boost/filesystem.hpp>
    3839
    3940#include "util/Convert.h"
     
    4243#include "core/CoreIncludes.h"
    4344#include "core/ConfigFileManager.h"
     45#include "core/Core.h"
    4446#include "InputCommands.h"
    4547#include "InputManager.h"
     
    253255            return;
    254256
     257        boost::filesystem::path folder(Core::getConfigPath());
     258        boost::filesystem::path filepath(folder/filename);
     259
    255260        // get bindings from default file if filename doesn't exist.
    256261        std::ifstream infile;
    257         infile.open(filename.c_str());
     262        infile.open(filepath.native_file_string().c_str());
    258263        if (!infile)
    259264        {
  • code/branches/buildsystem3/src/orxonox/CMakeLists.txt

    r2673 r2685  
    2525  PawnManager.cc
    2626  PlayerManager.cc
    27   Settings.cc
    2827)
    2928ADD_SUBDIRECTORY(gamestates)
     
    4342IF(GCC_NO_SYSTEM_HEADER_SUPPORT)
    4443  # Get around displaying a few hundred lines of warning code
    45   SET_SOURCE_FILES_PROPERTIES(gamestates/GSGraphics.cc PROPERTIES COMPILE_FLAGS "-w")
     44  SET_SOURCE_FILES_PROPERTIES(
     45    gamestates/GSGraphics.cc
     46    gui/GUIManager.cc
     47    PROPERTIES COMPILE_FLAGS "-Wno-sign-compare"
     48  )
    4649ENDIF()
    4750
  • code/branches/buildsystem3/src/orxonox/Main.cc

    r2664 r2685  
    3030 /**
    3131 @file
    32  @brief Entry point of the program. Platform specific code.
     32 @brief Entry point of the program.
    3333  */
    3434
     
    3737#include <exception>
    3838#include <cassert>
     39#include <fstream>
    3940
    4041#include "OrxonoxConfig.h"
     
    8586
    8687
    87 //#ifdef __cplusplus
    88 //extern "C" {
    89 //#endif
    90 
    9188SetCommandLineArgument(settingsFile, "orxonox.ini");
     89SetCommandLineArgument(configFileDirectory, "");
    9290
    9391int main(int argc, char** argv)
     
    9593    using namespace orxonox;
    9694
    97     // create a signal handler (only works for linux)
     95    // First, determine whether we have an installed or a binary dir run
     96    // The latter occurs when simply running from the build directory
     97    std::ifstream probe;
     98    probe.open("orxonox_dev_build.keep_me");
     99    if (probe)
     100    {
     101        Core::setDevBuild();
     102        probe.close();
     103    }
     104
     105    // create a signal handler (only active for linux)
    98106    SignalHandler signalHandler;
    99     signalHandler.doCatch(argv[0], "orxonox.log");
     107    signalHandler.doCatch(argv[0], Core::getLogPath() + "orxonox_crash.log");
    100108
    101109    // Parse command line arguments
     
    157165    return 0;
    158166}
    159 
    160 //#ifdef __cplusplus
    161 //}
    162 //#endif
  • code/branches/buildsystem3/src/orxonox/gamestates/GSGraphics.cc

    r2664 r2685  
    6161#include "gui/GUIManager.h"
    6262#include "tools/WindowEventListener.h"
    63 #include "Settings.h"
    6463
    6564// for compatibility
     
    138137        // load debug overlay
    139138        COUT(3) << "Loading Debug Overlay..." << std::endl;
    140         this->debugOverlay_ = new XMLFile(Settings::getDataPath() + "overlay/debug.oxo");
     139        this->debugOverlay_ = new XMLFile(Core::getMediaPath() + "overlay/debug.oxo");
    141140        Loader::open(debugOverlay_);
    142141
     
    211210        delete this->ogreRoot_;
    212211
    213 //#ifdef ORXONOX_PLATFORM_WINDOWS
    214212        // delete the ogre log and the logManager (since we have created it).
    215213        this->ogreLogger_->getDefaultLog()->removeListener(this);
    216214        this->ogreLogger_->destroyLog(Ogre::LogManager::getSingleton().getDefaultLog());
    217215        delete this->ogreLogger_;
    218 //#endif
    219216
    220217        delete graphicsEngine_;
     
    287284        COUT(3) << "Setting up Ogre..." << std::endl;
    288285
    289         // TODO: LogManager doesn't work on oli platform. The why is yet unknown.
    290 //#ifdef ORXONOX_PLATFORM_WINDOWS
     286        if (ogreConfigFile_ == "")
     287        {
     288            COUT(2) << "Warning: Ogre config file set to \"\". Defaulting to config.cfg" << std::endl;
     289            ModifyConfigValue(ogreConfigFile_, tset, "config.cfg");
     290        }
     291        if (ogreLogFile_ == "")
     292        {
     293            COUT(2) << "Warning: Ogre log file set to \"\". Defaulting to ogre.log" << std::endl;
     294            ModifyConfigValue(ogreLogFile_, tset, "ogre.log");
     295        }
     296
     297        boost::filesystem::path ogreConfigFilepath(Core::getConfigPath() + ogreConfigFile_);
     298        boost::filesystem::path ogreLogFilepath(Core::getLogPath() + ogreLogFile_);
     299
    291300        // create a new logManager
     301        // Ogre::Root will detect that we've already created a Log
    292302        ogreLogger_ = new Ogre::LogManager();
    293303        COUT(4) << "Ogre LogManager created" << std::endl;
     
    295305        // create our own log that we can listen to
    296306        Ogre::Log *myLog;
    297         if (this->ogreLogFile_ == "")
    298             myLog = ogreLogger_->createLog("ogre.log", true, false, true);
    299         else
    300             myLog = ogreLogger_->createLog(this->ogreLogFile_, true, false, false);
     307        myLog = ogreLogger_->createLog(ogreLogFilepath.native_file_string(), true, false, false);
    301308        COUT(4) << "Ogre Log created" << std::endl;
    302309
    303310        myLog->setLogDetail(Ogre::LL_BOREME);
    304311        myLog->addListener(this);
    305 //#endif
    306 
    307         // Root will detect that we've already created a Log
     312
    308313        COUT(4) << "Creating Ogre Root..." << std::endl;
    309 
    310         if (ogreConfigFile_ == "")
    311         {
    312             COUT(2) << "Warning: Ogre config file set to \"\". Defaulting to config.cfg" << std::endl;
    313             ModifyConfigValue(ogreConfigFile_, tset, "config.cfg");
    314         }
    315         if (ogreLogFile_ == "")
    316         {
    317             COUT(2) << "Warning: Ogre log file set to \"\". Defaulting to ogre.log" << std::endl;
    318             ModifyConfigValue(ogreLogFile_, tset, "ogre.log");
    319         }
    320314
    321315        // check for config file existence because Ogre displays (caught) exceptions if not
    322316        std::ifstream probe;
    323         probe.open(ogreConfigFile_.c_str());
     317        probe.open(ogreConfigFilepath.native_file_string().c_str());
    324318        if (!probe)
    325319        {
    326320            // create a zero sized file
    327321            std::ofstream creator;
    328             creator.open(ogreConfigFile_.c_str());
     322            creator.open(ogreConfigFilepath.native_file_string().c_str());
    329323            creator.close();
    330324        }
     
    333327
    334328        // Leave plugins file empty. We're going to do that part manually later
    335         ogreRoot_ = new Ogre::Root("", ogreConfigFile_, ogreLogFile_);
    336 
    337 #if 0 // Ogre 1.4.3 doesn't yet support setDebugOutputEnabled(.)
    338 #ifndef ORXONOX_PLATFORM_WINDOWS
    339         // tame the ogre ouput so we don't get all the mess in the console
    340         Ogre::Log* defaultLog = Ogre::LogManager::getSingleton().getDefaultLog();
    341         defaultLog->setDebugOutputEnabled(false);
    342         defaultLog->setLogDetail(Ogre::LL_BOREME);
    343         defaultLog->addListener(this);
    344 #endif
    345 #endif
     329        ogreRoot_ = new Ogre::Root("", ogreConfigFilepath.native_file_string(), ogreLogFilepath.native_file_string());
    346330
    347331        COUT(3) << "Ogre set up done." << std::endl;
     
    377361        try
    378362        {
    379             cf.load(Settings::getDataPath() + resourceFile_);
     363            cf.load(Core::getMediaPath() + resourceFile_);
    380364        }
    381365        catch (...)
     
    403387
    404388                    Ogre::ResourceGroupManager::getSingleton().addResourceLocation(
    405                         std::string(Settings::getDataPath() + archName), typeName, secName);
     389                        std::string(Core::getMediaPath() + archName), typeName, secName);
    406390                }
    407391            }
  • code/branches/buildsystem3/src/orxonox/gamestates/GSLevel.cc

    r2662 r2685  
    4646#include "LevelManager.h"
    4747#include "PlayerManager.h"
    48 #include "Settings.h"
    4948
    5049namespace orxonox
     
    205204        std::string levelName;
    206205        CommandLine::getValue("level", &levelName);
    207         startFile_ = new XMLFile(Settings::getDataPath() + std::string("levels/") + levelName);
     206        startFile_ = new XMLFile(Core::getMediaPath() + std::string("levels/") + levelName);
    208207        Loader::open(startFile_);
    209208    }
  • code/branches/buildsystem3/src/orxonox/gamestates/GSRoot.cc

    r2664 r2685  
    4444#include "tools/Timer.h"
    4545#include "objects/Tickable.h"
    46 #include "Settings.h"
    4746
    4847#ifdef ORXONOX_PLATFORM_WINDOWS
    49 #  ifndef WIN32_LEAN_AND_MEAN
    50 #    define WIN32_LEAN_AND_MEAN
    51 #  endif
    52 #  include "windows.h"
    53 
    54    //Get around Windows hackery
    55 #  ifdef max
    56 #    undef max
    57 #  endif
    58 #  ifdef min
    59 #    undef min
    60 #  endif
     48#  include <winbase.h>
    6149#endif
    6250
    6351namespace orxonox
    6452{
    65     SetCommandLineArgument(dataPath, "").information("PATH");
    6653    SetCommandLineArgument(limitToCPU, 1).information("0: off | #cpu");
    6754
     
    7158        , bPaused_(false)
    7259        , timeFactorPauseBackup_(1.0f)
    73         , settings_(0)
    7460        , tclBind_(0)
    7561        , tclThreadManager_(0)
     
    11399        this->luaBind_ = new LuaBind();
    114100
    115         // instantiate Settings class
    116         this->settings_ = new Settings();
    117 
    118         std::string dataPath = CommandLine::getValue("dataPath");
    119         if (dataPath != "")
    120         {
    121             if (*dataPath.end() != '/' && *dataPath.end() != '\\')
    122                 Settings::tsetDataPath(dataPath + "/");
    123             else
    124                 Settings::tsetDataPath(dataPath);
    125         }
    126 
    127101        // initialise TCL
    128         this->tclBind_ = new TclBind(Settings::getDataPath());
     102        this->tclBind_ = new TclBind(Core::getMediaPath());
    129103        this->tclThreadManager_ = new TclThreadManager(tclBind_->getTclInterpreter());
    130104
     
    182156        delete this->tclBind_;
    183157
    184         delete this->settings_;
    185158        delete this->luaBind_;
    186159
  • code/branches/buildsystem3/src/orxonox/gamestates/GSRoot.h

    r2662 r2685  
    8181        bool                  bPaused_;
    8282        float                 timeFactorPauseBackup_;
    83         Settings*             settings_;
    8483        TclBind*              tclBind_;
    8584        TclThreadManager*     tclThreadManager_;
  • code/branches/buildsystem3/src/orxonox/gui/GUIManager.cc

    r2664 r2685  
    3636#include "GUIManager.h"
    3737
     38#include <boost/filesystem.hpp>
    3839#include <OgreRenderWindow.h>
    3940#include <OgreRoot.h>
    4041#include <CEGUI.h>
     42#include <CEGUIDefaultLogger.h>
    4143#include <ogreceguirenderer/OgreCEGUIRenderer.h>
    4244#ifdef CEGUILUA_USE_INTERNAL_LIBRARY
     
    148150                this->luaState_ = this->scriptModule_->getLuaState();
    149151
     152                // Create our own logger to specify the filepath
     153                boost::filesystem::path ceguiLogFilepath(Core::getLogPath() + "cegui.log");
     154                this->ceguiLogger_ = new DefaultLogger();
     155                this->ceguiLogger_->setLogFilename(ceguiLogFilepath.native_file_string());
     156                // set the log level according to ours (translate by subtracting 1)
     157                this->ceguiLogger_->setLoggingLevel(
     158                    (LoggingLevel)(Core::getSoftDebugLevel(OutputHandler::LD_Logfile) - 1));
     159
    150160                // create the CEGUI system singleton
    151161                this->guiSystem_ = new System(this->guiRenderer_, this->resourceProvider_, 0, this->scriptModule_);
    152 
    153                 // set the log level according to ours (translate by subtracting 1)
    154                 Logger::getSingleton().setLoggingLevel(
    155                     (LoggingLevel)(Core::getSoftDebugLevel(OutputHandler::LD_Logfile) - 1));
    156162
    157163                // do this after 'new CEGUI::Sytem' because that creates the lua state in the first place
  • code/branches/buildsystem3/src/orxonox/gui/GUIManager.h

    r2664 r2685  
    4141#include <CEGUISystem.h>
    4242#include "core/input/InputInterfaces.h"
     43
     44// Forward declaration
     45namespace CEGUI { class DefaultLogger; }
    4346
    4447// tolua_begin
     
    119122        CEGUI::ResourceProvider*  resourceProvider_;
    120123        CEGUI::LuaScriptModule*   scriptModule_;
     124        CEGUI::DefaultLogger*     ceguiLogger_;
    121125        CEGUI::System*            guiSystem_;
    122126        CEGUI::Imageset*          backgroundImage_;
  • code/branches/buildsystem3/src/orxonox/objects/Level.cc

    r2664 r2685  
    3535#include "core/XMLFile.h"
    3636#include "core/Template.h"
     37#include "core/Core.h"
    3738
    38 #include "Settings.h"
    3939#include "LevelManager.h"
    4040#include "objects/infos/PlayerInfo.h"
     
    5555        this->xmlfilename_ = this->getFilename();
    5656
    57         if (this->xmlfilename_.length() >= Settings::getDataPath().length())
    58             this->xmlfilename_ = this->xmlfilename_.substr(Settings::getDataPath().length());
     57        if (this->xmlfilename_.length() >= Core::getMediaPath().length())
     58            this->xmlfilename_ = this->xmlfilename_.substr(Core::getMediaPath().length());
    5959    }
    6060
     
    9797        mask.include(Class(OverlayGroup)); // HACK to include the ChatOverlay
    9898
    99         this->xmlfile_ = new XMLFile(Settings::getDataPath() + this->xmlfilename_, mask);
     99        this->xmlfile_ = new XMLFile(Core::getMediaPath() + this->xmlfilename_, mask);
    100100
    101101        Loader::open(this->xmlfile_);
  • code/branches/buildsystem3/src/orxonox/objects/gametypes/Gametype.cc

    r2662 r2685  
    4343#include "objects/worldentities/SpawnPoint.h"
    4444#include "objects/worldentities/Camera.h"
    45 #include "Settings.h"
    4645
    4746#include "network/Host.h"
  • code/branches/buildsystem3/src/util/OutputBuffer.cc

    r2171 r2685  
    6868    OutputBuffer& OutputBuffer::operator<<(std::ostream& (*manipulator)(std::ostream&))
    6969    {
    70                 this->stream_ << manipulator;
    71                 this->callListeners();
    72                 return *this;
     70        this->stream_ << manipulator;
     71        this->callListeners();
     72        return *this;
    7373    }
    7474
     
    7979    OutputBuffer& OutputBuffer::operator<<(std::ios& (*manipulator)(std::ios&))
    8080    {
    81                 this->stream_ << manipulator;
    82                 this->callListeners();
    83                 return *this;
     81        this->stream_ << manipulator;
     82        this->callListeners();
     83        return *this;
    8484    }
    8585
     
    9090    OutputBuffer& OutputBuffer::operator<<(std::ios_base& (*manipulator)(std::ios_base&))
    9191    {
    92                 this->stream_ << manipulator;
    93                 this->callListeners();
    94                 return *this;
     92        this->stream_ << manipulator;
     93        this->callListeners();
     94        return *this;
    9595    }
    9696
  • code/branches/buildsystem3/src/util/OutputHandler.cc

    r2662 r2685  
    3333
    3434#include "OutputHandler.h"
    35 #include <time.h>
     35
     36#include <ctime>
     37#include <cstdlib>
    3638
    3739namespace orxonox
     
    4143        @param logfilename The name of the logfile
    4244    */
    43     OutputHandler::OutputHandler(const std::string& logfilename)
    44     {
     45    OutputHandler::OutputHandler()
     46    {
     47#ifdef ORXONOX_PLATFORM_WINDOWS
     48        char* pTempDir = getenv("TEMP");
     49        this->logfilename_ = std::string(pTempDir) + "/orxonox.log";
     50#else
     51        this->logfilename_ = "/tmp/orxonox.log";
     52#endif
     53#ifdef NDEBUG
     54        this->softDebugLevel_[LD_All] = this->softDebugLevel_[LD_Logfile] = 2;
     55        this->softDebugLevel_[LD_Console] = this->softDebugLevel_[LD_Shell] = 1;
     56#else
     57        this->softDebugLevel_[LD_All] = this->softDebugLevel_[LD_Logfile] = 3;
     58        this->softDebugLevel_[LD_Console] = this->softDebugLevel_[LD_Shell] = 2;
     59#endif
     60
    4561        this->outputBuffer_ = &this->fallbackBuffer_;
    46         this->softDebugLevel_[0] = this->softDebugLevel_[1] = this->softDebugLevel_[2] = this->softDebugLevel_[3] = 2;
    47         this->logfilename_ = logfilename;
    4862        this->logfile_.open(this->logfilename_.c_str(), std::fstream::out);
    4963
     
    5367        timeinfo = localtime(&rawtime);
    5468
    55         this->logfile_ << "Started log at " << asctime(timeinfo) << std::endl;
     69        this->logfile_ << "Started log on " << asctime(timeinfo) << std::endl;
    5670        this->logfile_.flush();
    5771    }
     
    7286    OutputHandler& OutputHandler::getOutStream()
    7387    {
    74         static OutputHandler orxout("orxonox.log");
     88        static OutputHandler orxout;
    7589        return orxout;
    7690    }
     
    112126
    113127    /**
     128        @brief Sets the path where to create orxonox.log
     129        @param Path string with trailing slash
     130    */
     131    void OutputHandler::setLogPath(const std::string& path)
     132    {
     133        OutputHandler::getOutStream().logfile_.close();
     134        // store old content
     135        std::ifstream old;
     136        old.open(OutputHandler::getOutStream().logfilename_.c_str());
     137        OutputHandler::getOutStream().logfilename_ = path + "orxonox.log";
     138        OutputHandler::getOutStream().logfile_.open(OutputHandler::getOutStream().logfilename_.c_str(), std::fstream::out);
     139        OutputHandler::getOutStream().logfile_ << old.rdbuf();
     140        old.close();
     141        OutputHandler::getOutStream().logfile_.flush();
     142    }
     143
     144    /**
    114145        @brief Overloaded << operator, redirects the output to the console and the logfile.
    115146        @param sb The streambuffer that should be shown in the console
  • code/branches/buildsystem3/src/util/OutputHandler.h

    r2662 r2685  
    101101            static int getSoftDebugLevel(OutputHandler::OutputDevice device = OutputHandler::LD_All);
    102102
     103            static void setLogPath(const std::string& path);
     104
    103105            void setOutputBuffer(OutputBuffer* buffer);
    104106
     
    142144
    143145        private:
    144             explicit OutputHandler(const std::string& logfilename);
    145             OutputHandler(const OutputHandler& oh);  // don't copy
     146            explicit OutputHandler();
     147            OutputHandler(const OutputHandler& oh);
    146148            virtual ~OutputHandler();
    147149
  • code/branches/buildsystem3/src/util/SignalHandler.cc

    r2664 r2685  
    159159      }
    160160
    161       COUT(0) << "recieved signal " << sigName.c_str() << std::endl << "try to write backtrace to file orxonox.log" << std::endl;
     161      COUT(0) << "recieved signal " << sigName.c_str() << std::endl << "try to write backtrace to file orxonox_crash.log" << std::endl;
    162162
    163163      int sigPipe[2];
Note: See TracChangeset for help on using the changeset viewer.