Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 2, 2008, 12:09:55 AM (17 years ago)
Author:
rgrieder
Message:

Finally managed to have a master InputState which enables:

  • Console always opens
  • Debug overlay toggles visibility in gui mode too

Had to change several other code:

  • ConfigFileManager uses special class instead of enum for ConfigFileType
  • You can add an arbitrary config file and get the ConfigFileType
  • ConfigFileManager is an Ogre singleton too. Created in Main.cc
  • CommandLineArgument "optionsFile" specifies another file for command line arguments
  • CommandLineArgument "settingsFile" declares the file used for settings (orxonox.ini)
  • changed all fileNames to filenames
  • "Loaded config file blah" now uses COUT(3) instead of COUT(0)
  • fixed a bug in ConfigFileManager::load() that cause orxonox.ini to double its size after every call
File:
1 edited

Legend:

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

    r2003 r2101  
    3030
    3131#include "util/String.h"
     32#include "util/SubString.h"
    3233
    3334namespace orxonox
    3435{
     36    SetCommandLineArgument(optionsFile, "start.ini").shortcut("o");
     37
    3538    /**
    3639    @brief
     
    274277        }
    275278    }
     279
     280    /**
     281    @brief
     282        Parses both command line and start.ini for CommandLineArguments.
     283    */
     284    void CommandLine::_parseAll(int argc, char** argv)
     285    {
     286        // parse command line first
     287        std::vector<std::string> args;
     288        for (int i = 1; i < argc; ++i)
     289            args.push_back(argv[i]);
     290        this->_parse(args);
     291
     292        // look for additional arguments in given file or start.ini as default
     293        // They will not overwrite the arguments given directly
     294        std::ifstream file;
     295        std::string filename = CommandLine::getValue("optionsFile").getString();
     296        file.open(filename.c_str());
     297        args.clear();
     298        if (file)
     299        {
     300            while (!file.eof())
     301            {
     302                std::string line;
     303                std::getline(file, line);
     304                line = removeTrailingWhitespaces(line);
     305                //if (!(line[0] == '#' || line[0] == '%'))
     306                //{
     307                SubString tokens(line, " ", " ", false, 92, false, 34, false, 40, 41, false, '#');
     308                for (unsigned i = 0; i < tokens.size(); ++i)
     309                    if (tokens[i][0] != '#')
     310                        args.push_back(tokens[i]);
     311                //args.insert(args.end(), tokens.getAllStrings().begin(), tokens.getAllStrings().end());
     312                //}
     313            }
     314            file.close();
     315        }
     316        else
     317        {
     318            COUT(2) << "Warning: Could not find " << filename
     319                    << " to get additional command line arguments." << std::endl;
     320        }
     321
     322        try
     323        {
     324            _parse(args);
     325        }
     326        catch (orxonox::ArgumentException& ex)
     327        {
     328            COUT(1) << "An Exception occured while parsing " << filename << std::endl;
     329            throw(ex);
     330        }
     331    }
    276332}
Note: See TracChangeset for help on using the changeset viewer.