Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Aug 21, 2008, 9:23:11 PM (16 years ago)
Author:
rgrieder
Message:
  • Finished CommandLineArgument completely. You can also use SetCommandLineSwitch to define boolean switches.
  • Added StaticConversion to Covert.h (compile time type conversion checking)
  • Fixed a bug in Exception
  • Added getAllStrings() to SubString
Location:
code/branches/gui/src/orxonox/gamestates
Files:
3 edited

Legend:

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

    r1663 r1664  
    4646namespace orxonox
    4747{
    48     SetCommandLineArgument(port, 55556).setShortcut("p");
    49     SetCommandLineArgument(ip, std::string("127.0.0.0"));
     48    SetCommandLineArgument(port, 55556).setShortcut("p").setInformation("PORT");
     49    SetCommandLineArgument(ip, "127.0.0.0").setInformation("#.#.#.#");
    5050
    5151    GSLevel::GSLevel()
  • code/branches/gui/src/orxonox/gamestates/GSRoot.cc

    r1663 r1664  
    3030#include "GSRoot.h"
    3131
     32#include "util/SubString.h"
    3233#include "core/Factory.h"
    3334#include "core/ConfigFileManager.h"
    3435#include "core/ConfigValueIncludes.h"
    3536#include "core/ConsoleCommand.h"
     37#include "core/CommandLine.h"
    3638#include "core/Debug.h"
    3739#include "core/Exception.h"
     
    4446namespace orxonox
    4547{
    46     SetCommandLineArgument(dataPath, std::string("./"));
     48    SetCommandLineArgument(dataPath, "").setInformation("PATH");
    4749
    4850    GSRoot::GSRoot()
     
    5557    GSRoot::~GSRoot()
    5658    {
     59    }
     60
     61    //SetCommandLineArgument(asdf1, "haha").setShortcut("a").setUsageInformation("1|2|3");
     62    //SetCommandLineArgument(asdf2, 3).setShortcut("b");
     63    //SetCommandLineArgument(asdf3, Vector2()).setShortcut("c");
     64    //SetCommandLineArgument(adsf4, 1.4f).setShortcut("d");
     65    //SetCommandLineSwitch(showGraphics).setShortcut("g");
     66
     67    void GSRoot::feedCommandLine(int argc, char** argv)
     68    {
     69        std::vector<std::string> args;
     70        for (int i = 1; i < argc; ++i)
     71            args.push_back(argv[i]);
     72
     73        //std::string line = "-a --asdf3 (3,3) -d -5 -b - 5.4";
     74        //SubString tokens(line, " ", " ", false, 92, false, 34, true, 40, 41, false, 0);
     75
     76        try
     77        {
     78            orxonox::CommandLine::parse(args);
     79            //CommandLine::parse(tokens.getAllStrings());
     80        }
     81        catch (orxonox::ArgumentException& ex)
     82        {
     83            COUT(1) << ex.what() << std::endl;
     84            COUT(0) << "Usage:" << std::endl << "orxonox " << CommandLine::getUsageInformation() << std::endl;
     85        }
    5786    }
    5887
     
    71100        this->settings_ = new Settings();
    72101
    73         const CommandLineArgument<std::string>* dataPath = CommandLine::getCommandLineArgument<std::string>("dataPath");
    74         if (!dataPath->hasDefaultValue())
     102        std::string dataPath;
     103        CommandLine::getCommandLineValue("dataPath", &dataPath);
     104        if (dataPath != "")
    75105        {
    76             if (*dataPath->getValue().end() != '/' && *dataPath->getValue().end() != '\\')
    77                 Settings::tsetDataPath(dataPath->getValue() + "/");
     106            if (*dataPath.end() != '/' && *dataPath.end() != '\\')
     107                Settings::tsetDataPath(dataPath + "/");
    78108            else
    79                 Settings::tsetDataPath(dataPath->getValue());
     109                Settings::tsetDataPath(dataPath);
    80110        }
    81111
     
    91121        functor->setObject(this);
    92122        CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor, "loadGame"));
     123
     124        requestState("gui");
    93125    }
    94126
  • code/branches/gui/src/orxonox/gamestates/GSRoot.h

    r1663 r1664  
    4141        ~GSRoot();
    4242
     43        void feedCommandLine(int argc, char** argv);
    4344        bool tick(float dt);
    4445        void loadGame(const std::string& name);
Note: See TracChangeset for help on using the changeset viewer.