Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Aug 20, 2008, 10:30:28 PM (16 years ago)
Author:
rgrieder
Message:

Added CommandLine class.
You can now call SetCommandLineArgument like SetConsoleCommand and hereby define a new command line argument. They are passed in main() and then they can be accessed by commandLine::getCommandLineArgument().

Location:
code/branches/gui/src/orxonox/gamestates
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/gui/src/orxonox/gamestates/GSLevel.cc

    r1662 r1663  
    3535#include "core/input/KeyBinder.h"
    3636#include "core/Loader.h"
     37#include "core/CommandLine.h"
    3738#include "overlays/console/InGameConsole.h"
    3839#include "gui/GUIManager.h"
     
    4546namespace orxonox
    4647{
     48    SetCommandLineArgument(port, 55556).setShortcut("p");
     49    SetCommandLineArgument(ip, std::string("127.0.0.0"));
     50
    4751    GSLevel::GSLevel()
    4852        : GameState("level")
  • code/branches/gui/src/orxonox/gamestates/GSRoot.cc

    r1662 r1663  
    3838#include "core/TclBind.h"
    3939#include "core/Core.h"
     40#include "core/CommandLine.h"
    4041#include "GraphicsEngine.h"
    4142#include "Settings.h"
     
    4344namespace orxonox
    4445{
     46    SetCommandLineArgument(dataPath, std::string("./"));
     47
    4548    GSRoot::GSRoot()
    4649        : GameState("root")
     50        , settings_(0)
    4751        , graphicsEngine_(0)
    4852    {
     
    6468        Factory::createClassHierarchy();
    6569
    66         const Settings::CommandLineArgument* dataPath = Settings::getCommandLineArgument("dataPath");
    67         assert(dataPath);
    68         if (!dataPath->bHasDefaultValue_)
     70        // instantiate Settings class
     71        this->settings_ = new Settings();
     72
     73        const CommandLineArgument<std::string>* dataPath = CommandLine::getCommandLineArgument<std::string>("dataPath");
     74        if (!dataPath->hasDefaultValue())
    6975        {
    70             if (*dataPath->value_.getString().end() != '/' && *dataPath->value_.getString().end() != '\\')
    71                 Settings::tsetDataPath(dataPath->value_.getString() + "/");
     76            if (*dataPath->getValue().end() != '/' && *dataPath->getValue().end() != '\\')
     77                Settings::tsetDataPath(dataPath->getValue() + "/");
    7278            else
    73                 Settings::tsetDataPath(dataPath->value_.getString());
     79                Settings::tsetDataPath(dataPath->getValue());
    7480        }
    7581
     
    8995    void GSRoot::leave()
    9096    {
    91         if (this->graphicsEngine_)
    92             delete graphicsEngine_;
     97        delete graphicsEngine_;
     98
     99        delete settings_;
    93100    }
    94101
  • code/branches/gui/src/orxonox/gamestates/GSRoot.h

    r1662 r1663  
    4848        void leave();
    4949
     50        Settings*             settings_;
    5051        GraphicsEngine*       graphicsEngine_;   //!< our dearest graphics engine <3
    5152    };
Note: See TracChangeset for help on using the changeset viewer.