Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 1690 for code/branches


Ignore:
Timestamp:
Aug 31, 2008, 8:39:13 PM (16 years ago)
Author:
rgrieder
Message:

Added support to specify the command line arguments in start.ini (uses the same formatting). '#' is the comment character.

Location:
code/branches/gui/src/core
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • code/branches/gui/src/core/CommandLine.cc

    r1664 r1690  
    2828
    2929#include "CommandLine.h"
     30
     31#include "util/String.h"
    3032
    3133namespace orxonox
     
    108110
    109111                        // save old data first
     112                        value = removeTrailingWhitespaces(value);
    110113                        if (name != "")
    111114                        {
     
    152155
    153156        // parse last argument
     157        value = removeTrailingWhitespaces(value);
    154158        if (name != "")
    155159        {
  • code/branches/gui/src/core/GameState.cc

    r1689 r1690  
    5959    GameStateBase::~GameStateBase()
    6060    {
    61         OrxAssert(!isInSubtree(getCurrentState()), "Deleting an active GameState is a very bad idea..");
     61        OrxAssert(this->operation_.active == false, "Deleting an active GameState is a very bad idea..");
    6262    }
    6363
  • code/branches/gui/src/core/GameState.h

    r1689 r1690  
    139139    {
    140140    public:
    141         GameState(const std::string& name) : GameStateBase(name) { }
     141        GameState(const std::string& name)
     142            : GameStateBase(name)
     143            , parent_(0)
     144        { }
    142145        virtual ~GameState() { }
    143146
  • code/branches/gui/src/core/RootGameState.cc

    r1689 r1690  
    2929#include "RootGameState.h"
    3030
     31#include "util/String.h"
     32#include "util/SubString.h"
    3133#include "Clock.h"
    3234#include "Debug.h"
     
    129131    void RootGameState::start(int argc, char** argv)
    130132    {
    131         parseCommandLine(argc, argv);
     133        parseArguments(argc, argv);
    132134
    133135        this->activate();
     
    152154    }
    153155
    154     void RootGameState::parseCommandLine(int argc, char** argv)
    155     {
     156    /**
     157    @brief
     158        Parses both command line and start.ini for CommandLineArguments.
     159    */
     160    void RootGameState::parseArguments(int argc, char** argv)
     161    {
     162        // parse command line first
    156163        std::vector<std::string> args;
    157164        for (int i = 1; i < argc; ++i)
     
    167174            COUT(0) << "Usage:" << std::endl << "orxonox " << CommandLine::getUsageInformation() << std::endl;
    168175        }
     176
     177        // look for additional arguments in start.ini
     178        std::ifstream file;
     179        file.open("start.ini");
     180        args.clear();
     181        if (file)
     182        {
     183            while (!file.eof())
     184            {
     185                std::string line;
     186                std::getline(file, line);
     187                line = removeTrailingWhitespaces(line);
     188                //if (!(line[0] == '#' || line[0] == '%'))
     189                //{
     190                SubString tokens(line, " ", " ", false, 92, false, 34, false, 40, 41, false, '#');
     191                for (unsigned i = 0; i < tokens.size(); ++i)
     192                    if (tokens[i][0] != '#')
     193                        args.push_back(tokens[i]);
     194                //args.insert(args.end(), tokens.getAllStrings().begin(), tokens.getAllStrings().end());
     195                //}
     196            }
     197            file.close();
     198        }
     199
     200        try
     201        {
     202            orxonox::CommandLine::parse(args);
     203        }
     204        catch (orxonox::ArgumentException& ex)
     205        {
     206            COUT(1) << "An Exception occured while parsing start.ini" << std::endl;
     207            COUT(1) << ex.what() << std::endl;
     208            COUT(0) << "Usage:" << std::endl << "orxonox " << CommandLine::getUsageInformation() << std::endl;
     209        }
    169210    }
    170211}
  • code/branches/gui/src/core/RootGameState.h

    r1689 r1690  
    4848        void gotoState(const std::string& name);
    4949
    50         void parseCommandLine(int argc, char** argv);
     50        void parseArguments(int argc, char** argv);
    5151
    5252        std::string           stateRequest_;
Note: See TracChangeset for help on using the changeset viewer.