Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Aug 13, 2009, 9:12:24 PM (15 years ago)
Author:
rgrieder
Message:

Prepared build system for an external media directory.
This revision only runs in console mode! (tcl files working again)

File:
1 edited

Legend:

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

    r5614 r5641  
    8585    Core* Core::singletonPtr_s  = 0;
    8686
    87     SetCommandLineArgument(mediaPath, "").information("Path to the media/data files");
     87    SetCommandLineArgument(externalMediaPath, "").information("Path to the external media files");
    8888    SetCommandLineOnlyArgument(writingPathSuffix, "").information("Additional subfolder for config and log files");
    8989    SetCommandLineArgument(settingsFile, "orxonox.ini").information("THE configuration file");
     
    110110            this->setConfigValues();
    111111
    112             // Possible media path override by the command line
    113             if (!CommandLine::getArgument("mediaPath")->hasDefaultValue())
    114                 tsetMediaPath(CommandLine::getValue("mediaPath"));
     112            // External media directory only exists for dev runs
     113            if (Core::isDevelopmentRun())
     114            {
     115                // Possible media path override by the command line
     116                if (!CommandLine::getArgument("externalMediaPath")->hasDefaultValue())
     117                    tsetExternalMediaPath(CommandLine::getValue("externalMediaPath"));
     118            }
    115119        }
    116120
     
    145149                .description("If true, all random actions are different each time you start the game")
    146150                .callback(this, &CoreConfiguration::initializeRandomNumberGenerator);
    147 
    148             // Only show this config value for development builds
    149             if (Core::isDevelopmentRun())
    150             {
    151                 SetConfigValue(mediaPathString_, mediaPath_.string())
    152                     .description("Relative path to the game data.")
    153                     .callback(this, &CoreConfiguration::mediaPathChanged);
    154             }
    155151        }
    156152
     
    183179
    184180        /**
    185         @brief
    186             Callback function if the media path has changed.
    187         */
    188         void mediaPathChanged()
    189         {
    190             mediaPath_ = boost::filesystem::path(this->mediaPathString_);
    191         }
    192 
    193         /**
    194181            @brief Sets the language in the config-file back to the default.
    195182        */
     
    205192            The new media path
    206193        */
    207         void tsetMediaPath(const std::string& path)
    208         {
    209             if (Core::isDevelopmentRun())
    210             {
    211                 ModifyConfigValue(mediaPathString_, tset, path);
    212             }
    213             else
    214             {
    215                 // Manual 'config' value without the file entry
    216                 mediaPathString_ = path;
    217                 this->mediaPathChanged();
    218             }
     194        void tsetExternalMediaPath(const std::string& path)
     195        {
     196            mediaPath_ = boost::filesystem::path(path);
    219197        }
    220198
     
    236214        std::string language_;                          //!< The language
    237215        bool bInitializeRandomNumberGenerator_;         //!< If true, srand(time(0)) is called
    238         std::string mediaPathString_;                   //!< Path to the data/media file folder as string
    239216
    240217        //! Path to the parent directory of the ones above if program was installed with relativ pahts
     
    242219        boost::filesystem::path executablePath_;        //!< Path to the executable
    243220        boost::filesystem::path mediaPath_;             //!< Path to the media file folder
     221        boost::filesystem::path externalMediaPath_;     //!< Path to the media file folder
    244222        boost::filesystem::path configPath_;            //!< Path to the config file folder
    245223        boost::filesystem::path logPath_;               //!< Path to the log file folder
     
    423401    }
    424402
    425     /*static*/ void Core::tsetMediaPath(const std::string& path)
    426     {
    427         getInstance().configuration_->tsetMediaPath(path);
     403    /*static*/ void Core::tsetExternalMediaPath(const std::string& path)
     404    {
     405        getInstance().configuration_->tsetExternalMediaPath(path);
    428406    }
    429407
     
    435413    {
    436414        return getInstance().configuration_->mediaPath_.string() + '/';
     415    }
     416
     417    /*static*/ const boost::filesystem::path& Core::getExternalMediaPath()
     418    {
     419        return getInstance().configuration_->externalMediaPath_;
     420    }
     421    /*static*/ std::string Core::getExternalMediaPathString()
     422    {
     423        return getInstance().configuration_->externalMediaPath_.string() + '/';
    437424    }
    438425
     
    574561            COUT(1) << "Running from the build tree." << std::endl;
    575562            Core::bDevRun_ = true;
    576             configuration_->mediaPath_  = ORXONOX_MEDIA_DEV_PATH;
    577             configuration_->configPath_ = ORXONOX_CONFIG_DEV_PATH;
    578             configuration_->logPath_    = ORXONOX_LOG_DEV_PATH;
     563            configuration_->mediaPath_  = specialConfig::mediaDevDirectory;
     564            configuration_->externalMediaPath_ = specialConfig::externalMediaDevDirectory;
     565            configuration_->configPath_ = specialConfig::configDevDirectory;
     566            configuration_->logPath_    = specialConfig::logDevDirectory;
    579567        }
    580568        else
     
    582570#ifdef INSTALL_COPYABLE // --> relative paths
    583571            // Also set the root path
    584             boost::filesystem::path relativeExecutablePath(ORXONOX_RUNTIME_INSTALL_PATH);
     572            boost::filesystem::path relativeExecutablePath(specialConfig::defaultRuntimePath);
    585573            configuration_->rootPath_ = configuration_->executablePath_;
    586574            while (!boost::filesystem::equivalent(configuration_->rootPath_ / relativeExecutablePath, configuration_->executablePath_)
     
    591579
    592580            // Using paths relative to the install prefix, complete them
    593             configuration_->mediaPath_  = configuration_->rootPath_ / ORXONOX_MEDIA_INSTALL_PATH;
    594             configuration_->configPath_ = configuration_->rootPath_ / ORXONOX_CONFIG_INSTALL_PATH;
    595             configuration_->logPath_    = configuration_->rootPath_ / ORXONOX_LOG_INSTALL_PATH;
     581            configuration_->mediaPath_  = configuration_->rootPath_ / specialConfig::defaultMediaPath;
     582            configuration_->configPath_ = configuration_->rootPath_ / specialConfig::defaultConfigPath;
     583            configuration_->logPath_    = configuration_->rootPath_ / specialConfig::defaultLogPath;
    596584#else
    597585            // There is no root path, so don't set it at all
    598586
    599             configuration_->mediaPath_  = ORXONOX_MEDIA_INSTALL_PATH;
     587            configuration_->mediaPath_  = specialConfig::mediaInstallDirectory;
    600588
    601589            // Get user directory
     
    610598            userDataPath /= ".orxonox";
    611599
    612             configuration_->configPath_ = userDataPath / ORXONOX_CONFIG_INSTALL_PATH;
    613             configuration_->logPath_    = userDataPath / ORXONOX_LOG_INSTALL_PATH;
     600            configuration_->configPath_ = userDataPath / specialConfig::defaultConfigPath;
     601            configuration_->logPath_    = userDataPath / specialConfig::defaultLogPath;
    614602#endif
    615603        }
Note: See TracChangeset for help on using the changeset viewer.