Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 4, 2008, 8:06:38 PM (16 years ago)
Author:
rgrieder
Message:
  • added various error code in GraphicsEngine
  • Config values for plugins.cfg, resources.cfg and ogre.log
  • created Settings class for general orxonox settings like dataPath
  • rewrote ArgReader to support any type of argument that converValue can convert
  • There is now a possibility to use boolean arguments (either given or not)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/input/src/orxonox/Orxonox.cc

    r1524 r1531  
    2121 *
    2222 *   Author:
     23 *      Reto Grieder
     24 *   Co-authors:
    2325 *      Benjamin Knecht <beni_at_orxonox.net>, (C) 2007
    24  *   Co-authors:
    25  *      ...
    2626 *
    2727 */
     
    7373
    7474#include "GraphicsEngine.h"
     75#include "Settings.h"
    7576
    7677// FIXME: is this really file scope?
     
    166167   * @param path path to config (in home dir or something)
    167168   */
    168   bool Orxonox::init(int argc, char **argv, std::string path)
    169   {
    170     //TODO: find config file (assuming executable directory)
    171     //TODO: read config file
    172     //TODO: give config file to Ogre
     169  bool Orxonox::init(int argc, char **argv)
     170  {
     171#ifdef _DEBUG
     172    ConfigFileManager::getSingleton()->setFile(CFT_Settings, "orxonox_d.ini");
     173#else
     174    ConfigFileManager::getSingleton()->setFile(CFT_Settings, "orxonox.ini");
     175#endif
     176    Factory::createClassHierarchy();
     177
    173178    std::string mode;
    174     std::string dataPath;
     179    std::string tempDataPath;
    175180
    176181    ArgReader ar(argc, argv);
    177     ar.checkArgument("mode", mode, false);
    178     ar.checkArgument("data", dataPath, false);
    179     ar.checkArgument("ip", serverIp_, false);
    180     ar.checkArgument("port", serverPort_, false);
     182    ar.checkArgument("mode", &mode, false);
     183    ar.checkArgument("data", &tempDataPath, false);
     184    ar.checkArgument("ip",   &serverIp_, false);
     185    ar.checkArgument("port", &serverPort_, false);
    181186    if(ar.errorHandling())
     187    {
     188      COUT(1) << "Error while parsing command line arguments" << std::endl;
     189      COUT(1) << ar.getErrorString();
     190      COUT(0) << "Usage:" << std::endl << "orxonox [mode client|server|dedicated|standalone] "
     191        << "[--data PATH] [--ip IP] [--port PORT]" << std::endl;
    182192      return false;
     193    }
    183194
    184195    if (mode == "client")
     
    190201    else
    191202    {
    192       mode = "standalone";
     203      if (mode == "")
     204        mode = "standalone";
     205      if (mode != "standalone")
     206      {
     207        COUT(2) << "Warning: mode \"" << mode << "\" doesn't exist. "
     208          << "Defaulting to standalone" << std::endl;
     209        mode = "standalone";
     210      }
    193211      mode_ = STANDALONE;
    194212    }
    195213    COUT(3) << "Orxonox: Mode is " << mode << "." << std::endl;
     214
     215    if (tempDataPath != "")
     216    {
     217      if (tempDataPath[tempDataPath.size() - 1] != '/')
     218        tempDataPath += "/";
     219      Settings::tsetDataPath(tempDataPath);
     220    }
     221
     222    // initialise TCL
     223    TclBind::getInstance().setDataPath(Settings::getDataPath());
    196224
    197225    //if (mode_ == DEDICATED)
     
    202230    // procedure until the GUI is identical
    203231
    204     ConfigFileManager::getSingleton()->setFile(CFT_Settings, "orxonox.ini");
    205     Factory::createClassHierarchy();
    206 
    207232    ogre_ = &GraphicsEngine::getSingleton();
    208     if (!ogre_->setup(path))       // creates ogre root and other essentials
     233    if (!ogre_->setup())       // creates ogre root and other essentials
    209234      return false;
    210235
Note: See TracChangeset for help on using the changeset viewer.