Index: code/branches/gui/src/core/CommandLine.cc
===================================================================
--- code/branches/gui/src/core/CommandLine.cc	(revision 1663)
+++ code/branches/gui/src/core/CommandLine.cc	(revision 1663)
@@ -0,0 +1,134 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "CommandLine.h"
+
+namespace orxonox
+{
+    CommandLine::~CommandLine()
+    {
+        for (std::map<std::string, BaseCommandLineArgument*>::const_iterator it = cmdLineArgs_.begin();
+            it != cmdLineArgs_.end(); ++it)
+        {
+            delete it->second;
+        }
+    }
+    
+    CommandLine& CommandLine::_getInstance()
+    {
+        static CommandLine instance;
+        return instance;
+    }
+
+    void CommandLine::_parse(int argc, char** argv)
+    {
+        if (bFirstTimeParse_)
+        {
+            // first shove all the shortcuts in a map
+            for (std::map<std::string, BaseCommandLineArgument*>::const_iterator it = cmdLineArgs_.begin();
+                it != cmdLineArgs_.end(); ++it)
+            {
+                OrxAssert(cmdLineArgsShortcut_.find(it->second->getShortcut()) == cmdLineArgsShortcut_.end(),
+                    "Cannot have two command line shortcut with the same name.");
+                if (it->second->getShortcut() != "")
+                    cmdLineArgsShortcut_[it->second->getShortcut()] = it->second;
+            }
+            bFirstTimeParse_ = false;
+        }
+
+        std::string name;
+        std::string shortcut;
+        std::string val;
+        for (int i = 1; i < argc; ++i)
+        {
+            if (argv[i][0] == '-')
+            {
+                if (argv[i][1] <= 57 && argv[i][1] >= 48)
+                {
+                    // negative number as a value
+                    val += std::string(argv[i]) + " ";
+                }
+                else
+                {
+                    // save old data first
+                    if (name != "")
+                    {
+                        checkFullArgument(name, val);
+                        name = "";
+                        assert(shortcut == "");
+                    }
+                    else if (shortcut != "")
+                    {
+                        checkShortcut(shortcut, val);
+                        shortcut = "";
+                        assert(name == "");
+                    }
+
+                    if (argv[i][1] == '-')
+                    {
+                        // full name argument
+                        name = argv[i] + 2;
+                    }
+                    else
+                    {
+                        // short cut
+                        shortcut = argv[i] + 1;
+                    }
+                    val = "";
+                }
+            }
+            else // value
+            {
+                if (name == "" && shortcut == "")
+                {
+                    ThrowException(Argument, "Expected \"-\" or \"-\" in command line arguments.\n");
+                }
+
+                val += argv[i];
+            }
+        }
+    }
+
+    void CommandLine::checkFullArgument(const std::string& name, const std::string& value)
+    {
+        std::map<std::string, BaseCommandLineArgument*>::const_iterator it = cmdLineArgs_.find(name);
+        if (it == cmdLineArgs_.end())
+            ThrowException(Argument, "Command line argument '" + name + "' does not exist.");
+
+        it->second->parse(value);
+    }
+
+    void CommandLine::checkShortcut(const std::string& shortcut, const std::string& value)
+    {
+        std::map<std::string, BaseCommandLineArgument*>::const_iterator it = cmdLineArgsShortcut_.find(shortcut);
+        if (it == cmdLineArgsShortcut_.end())
+            ThrowException(Argument, "Command line shortcut '" + shortcut + "' does not exist.");
+
+        it->second->parse(value);
+    }
+}
Index: code/branches/gui/src/core/CommandLine.h
===================================================================
--- code/branches/gui/src/core/CommandLine.h	(revision 1663)
+++ code/branches/gui/src/core/CommandLine.h	(revision 1663)
@@ -0,0 +1,176 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _CommandLine_H__
+#define _CommandLine_H__
+
+#include "CorePrereqs.h"
+#include <map>
+#include "util/Convert.h"
+#include "Debug.h"
+#include "Exception.h"
+
+
+#define SetCommandLineArgument(name, defaultValue) \
+    BaseCommandLineArgument& CmdArgumentDummyBoolVar##name \
+    = orxonox::CommandLine::addCommandLineArgument(#name, defaultValue)
+
+namespace orxonox
+{
+    class _CoreExport BaseCommandLineArgument
+    {
+        friend class CommandLine;
+
+    public:
+        bool hasDefaultValue() const { return bHasDefaultValue_; }
+        const std::string& getName() const { return name_; }
+        const std::string& getShortcut() const { return shortcut_; }
+        BaseCommandLineArgument& setShortcut(const std::string& shortcut)
+        { this->shortcut_ = shortcut; return *this; }
+
+    protected:
+        BaseCommandLineArgument(const std::string& name)
+            : name_(name)
+            , bHasDefaultValue_(true)
+        { }
+
+        BaseCommandLineArgument(const BaseCommandLineArgument& instance);
+        virtual ~BaseCommandLineArgument() { }
+
+        virtual void parse(const std::string& value) = 0;
+
+        bool bHasDefaultValue_;
+
+    private:
+        std::string name_;
+        std::string shortcut_;
+    };
+
+
+    template <class T>
+    class CommandLineArgument : public BaseCommandLineArgument
+    {
+        friend class CommandLine;
+
+    public:
+        T getValue() const { return value_; }
+        T getDefaultValue() const { return defaultValue_; }
+
+    private:
+        CommandLineArgument(const std::string& name, const T& defaultValue)
+            : BaseCommandLineArgument(name)
+            , value_(defaultValue)
+            , defaultValue_(defaultValue)
+        { }
+
+        virtual void parse(const std::string& value);
+
+        T value_;
+        T defaultValue_;
+    };
+
+    template <class T>
+    void CommandLineArgument<T>::parse(const std::string& value)
+    {
+        if (convertValue(&this->value_, value))
+        {
+            this->bHasDefaultValue_ = false;
+        }
+        else
+        {
+            ThrowException(Argument, "Could not read command line argument '" + getName() + "'.");
+        }
+    }
+
+
+    class _CoreExport CommandLine
+    {
+    public:
+
+        static void parse(int argc, char** argv) { _getInstance()._parse(argc, argv); }
+
+        template <class T>
+        static const CommandLineArgument<T>* getCommandLineArgument(const std::string& name);
+        template <class T>
+        static BaseCommandLineArgument& addCommandLineArgument(const std::string& name,
+            const T& defaultValue);
+
+    private:
+        CommandLine() : bFirstTimeParse_(true) { }
+        CommandLine(const CommandLine& instance);
+        ~CommandLine();
+
+        static CommandLine& _getInstance();
+
+        void _parse(int argc, char** argv);
+        void checkFullArgument(const std::string& name, const std::string& value);
+        void checkShortcut(const std::string& shortcut, const std::string& value);
+
+        bool bFirstTimeParse_;
+
+        std::map<std::string, BaseCommandLineArgument*> cmdLineArgs_;
+        std::map<std::string, BaseCommandLineArgument*> cmdLineArgsShortcut_;
+    };
+
+
+    template <class T>
+    const CommandLineArgument<T>* CommandLine::getCommandLineArgument(const std::string& name)
+    {
+        std::map<std::string, BaseCommandLineArgument*>::const_iterator it = _getInstance().cmdLineArgs_.find(name);
+        if (it == _getInstance().cmdLineArgs_.end())
+        {
+            ThrowException(Argument, "Could find command line argument '" + name + "'.");
+        }
+        else
+        {
+            CommandLineArgument<T>* arg = dynamic_cast<CommandLineArgument<T>* >(it->second);
+            if (arg == 0)
+            {
+                ThrowException(Argument, "Could not convert command line argument value to requested type. " \
+                    "You should use exactly the same type as predefined.");
+            }
+            else
+            {
+                return arg;
+            }
+        }
+    }
+
+    template <class T>
+    BaseCommandLineArgument& CommandLine::addCommandLineArgument(const std::string& name,
+                                             const T& defaultValue)
+    {
+        std::map<std::string, BaseCommandLineArgument*>::const_iterator it = _getInstance().cmdLineArgs_.find(name);
+        OrxAssert(it == _getInstance().cmdLineArgs_.end(),
+            "Cannot add a command line argument with name '" + name + "' twice.");
+
+        return *(_getInstance().cmdLineArgs_[name] = new CommandLineArgument<T>(name, defaultValue));
+    }
+}
+
+#endif /* _CommandLine_H__ */
Index: code/branches/gui/src/core/CorePrereqs.h
===================================================================
--- code/branches/gui/src/core/CorePrereqs.h	(revision 1662)
+++ code/branches/gui/src/core/CorePrereqs.h	(revision 1663)
@@ -102,4 +102,8 @@
   class CommandEvaluation;
   class CommandExecutor;
+  class CommandLine;
+  class BaseCommandLineArgument;
+  template <class T>
+  class CommandLineArgument;
   class ConfigFile;
   class ConfigFileEntry;
Index: code/branches/gui/src/core/Exception.h
===================================================================
--- code/branches/gui/src/core/Exception.h	(revision 1662)
+++ code/branches/gui/src/core/Exception.h	(revision 1663)
@@ -59,4 +59,5 @@
             General,
             FileNotFound,
+            Argument,
             PluginsNotFound,
             InitialisationFailed,
@@ -119,4 +120,5 @@
             RETURN_EXCEPTION_CODE(General)
             RETURN_EXCEPTION_CODE(FileNotFound);
+            RETURN_EXCEPTION_CODE(Argument);
             RETURN_EXCEPTION_CODE(PluginsNotFound);
             RETURN_EXCEPTION_CODE(InitialisationFailed);
@@ -132,4 +134,5 @@
     CREATE_ORXONOX_EXCEPTION(General);
     CREATE_ORXONOX_EXCEPTION(FileNotFound);
+    CREATE_ORXONOX_EXCEPTION(Argument);
     CREATE_ORXONOX_EXCEPTION(PluginsNotFound);
     CREATE_ORXONOX_EXCEPTION(InitialisationFailed);
@@ -142,7 +145,7 @@
     // define an assert macro that can display a message
 #ifndef NDEBUG
-#define OrxAssert(condition, errorMessage) \
-    condition ? ((void)0) : (void)(orxonox::OutputHandler::getOutStream().setOutputLevel(ORX_ERROR) << errorMessage << std::endl); \
-    assert(condition)
+#define OrxAssert(assertion, errorMessage) \
+    assertion ? ((void)0) : (void)(orxonox::OutputHandler::getOutStream().setOutputLevel(ORX_ERROR) << errorMessage << std::endl); \
+    assert(assertion)
 #else
 #define OrxAssert(condition, errorMessage)  ((void)0)
Index: code/branches/gui/src/orxonox/Main.cc
===================================================================
--- code/branches/gui/src/orxonox/Main.cc	(revision 1662)
+++ code/branches/gui/src/orxonox/Main.cc	(revision 1663)
@@ -39,10 +39,8 @@
 
 #include "util/OrxonoxPlatform.h"
-#include "util/ArgReader.h"
 #include "core/SignalHandler.h"
 #include "core/Debug.h"
-#include "network/ClientConnection.h"
-#include "Settings.h"
-#include "Orxonox.h"
+#include "core/CommandLine.h"
+//#include "Orxonox.h"
 
 #include "gamestates/GSRoot.h"
@@ -80,40 +78,4 @@
 #endif
 
-bool parseCommandLine(int argc, char** argv)
-{
-    ArgReader args;
-    std::string errorStr = args.parse(argc, argv);
-    if (errorStr != "")
-    {
-        COUT(1) << "Command Line: Parsing failed.\n" << errorStr << std::endl;
-        return false;
-    }
-
-    // Argument reader parses the command line to check syntax.
-    // Settings Singleton then stores the arguments. It always
-    // expects a default value.
-    bool success = true;
-    success &= Settings::addCommandLineArgument<std::string>
-        ("mode",     args.getArgument("mode"),     "standalone");
-    success &= Settings::addCommandLineArgument<std::string>
-        ("dataPath", args.getArgument("dataPath"), "./");
-    success &= Settings::addCommandLineArgument<std::string>
-        ("ip",       args.getArgument("ip"),       "127.0.0.0");
-    success &= Settings::addCommandLineArgument<int>
-        ("port",     args.getArgument("port"),     NETWORK_PORT);
-
-    if (!success)
-        return false;
-
-    if (!args.allChecked())
-    {
-        COUT(1) << "Command Line: Parsing failed.\nNot all arguments were matched." << std::endl;
-        return false;
-    }
-
-    return true;
-}
-
-#include "core/GameState.h"
 
 #ifdef __cplusplus
@@ -123,13 +85,19 @@
 int main(int argc, char** argv)
 {
+    try
+    {
+        orxonox::CommandLine::parse(argc, argv);
+    }
+    catch (orxonox::ArgumentException& ex)
+    {
+        COUT(1) << ex.what() << std::endl;
+        COUT(0) << "Usage:" << std::endl << "orxonox [--mode client|server|dedicated|standalone] "
+                << "[--data PATH] [--ip IP] [--port PORT]" << std::endl;
+    }
+
+
     // create a signal handler (only works for linux)
     SignalHandler::getInstance()->doCatch(argv[0], "orxonox.log");
 
-    if (!parseCommandLine(argc, argv))
-    {
-        COUT(0) << "Usage:" << std::endl << "orxonox [--mode client|server|dedicated|standalone] "
-                << "[--data PATH] [--ip IP] [--port PORT]" << std::endl;
-        return 0;
-    }
 
 
@@ -181,5 +149,5 @@
 
 
-    Orxonox orxonoxInstance;
+    //Orxonox orxonoxInstance;
 
     try
Index: code/branches/gui/src/orxonox/Orxonox.cc
===================================================================
--- code/branches/gui/src/orxonox/Orxonox.cc	(revision 1662)
+++ code/branches/gui/src/orxonox/Orxonox.cc	(revision 1663)
@@ -108,5 +108,4 @@
     , bAbort_(false)
     , timefactor_(1.0f)
-    , mode_(GameMode::GM_Unspecified)
     , debugRefreshTime_(0.0f)
     , graphicsEngine_(0)
@@ -119,5 +118,5 @@
 
     //assert(singletonRef_s == 0);
-    OrxAssert(singletonRef_s == 0, "asdfasdfasdfasdfblahblah");
+    OrxAssert(singletonRef_s == 0, "Cannot instantiate Orxonox class twice");
     singletonRef_s = this;
   }
@@ -229,22 +228,13 @@
         setConfigValues();
 
-        const Settings::CommandLineArgument* mode = Settings::getCommandLineArgument("mode");
-        assert(mode);
-        if (!mode->bHasDefaultValue_)
-        {
-            Settings::setGameMode(mode->value_);
-            this->mode_ = Settings::getGameMode();
-        }
-        COUT(3) << "Orxonox: Game mode is " << mode_.name << "." << std::endl;
-
-        const Settings::CommandLineArgument* dataPath = Settings::getCommandLineArgument("dataPath");
-        assert(dataPath);
-        if (!dataPath->bHasDefaultValue_)
-        {
-            if (*dataPath->value_.getString().end() != '/' && *dataPath->value_.getString().end() != '\\')
-                Settings::tsetDataPath(dataPath->value_.getString() + "/");
-            else
-                Settings::tsetDataPath(dataPath->value_.getString());
-        }
+        //const Settings::CommandLineArgument* dataPath = Settings::getCommandLineArgument("dataPath");
+        //assert(dataPath);
+        //if (!dataPath->bHasDefaultValue_)
+        //{
+        //    if (*dataPath->value_.getString().end() != '/' && *dataPath->value_.getString().end() != '\\')
+        //        Settings::tsetDataPath(dataPath->value_.getString() + "/");
+        //    else
+        //        Settings::tsetDataPath(dataPath->value_.getString());
+        //}
 
         try
@@ -256,5 +246,5 @@
             graphicsEngine_->setup();       // creates ogre root and other essentials
 
-            if (mode_.showsGraphics)
+            if (Settings::showsGraphics())
             {
                 graphicsEngine_->loadRenderer();    // creates the render window
@@ -286,26 +276,4 @@
                 // We probably want to use std::cin to catch input (OIS uses DirectX or X server)
             }
-
-            bool showGUI = true;
-            if (mode_.mode != GameMode::Unspecified)
-            {
-                showGUI = false;
-                // a game mode was specified with the command line
-                // we therefore load the game and level directly
-
-                if (!loadLevel(this->mode_))
-                {
-                    COUT(1) << "Loading with predefined mode failed. Showing main menu." << std::endl;
-                    showGUI = true;
-                    mode_ = GameMode::GM_Unspecified;
-                }
-            }
-
-            if (showGUI)
-            {
-                // show main menu
-                GUIManager::getInstance().showGUI("MainMenu", 0);
-                GraphicsEngine::getInstance().getViewport()->setCamera(GUIManager::getInstance().getCamera());
-            }
         }
         catch (std::exception& ex)
@@ -316,62 +284,12 @@
         }
 
-        modeRequest_ = mode_;
         // here happens the game
         startRenderLoop();
 
-        if (mode_.mode == GameMode::Client)
-            network::Client::getSingleton()->closeConnection();
-
-        if (mode_.hasServer)
-            server_g->close();
-    }
-
-    /*static*/ void Orxonox::loadGame(const std::string& name)
-    {
-        const GameMode& mode = Settings::getGameMode(name);
-        if (mode.mode == GameMode::None)
-            return;
-
-        getInstance().modeRequest_ = mode;
-    }
-
-    bool Orxonox::loadLevel(const GameMode& mode)
-    {
-        bool success = true;
-
-        if (mode.showsGraphics)
-        {
-            // create Ogre SceneManager for the level
-            graphicsEngine_->createNewScene();
-
-            if (!loadPlayground())
-                return false;
-        }
-
-        switch (mode.mode)
-        {
-        case GameMode::Server:
-            success &= serverLoad();
-            break;
-        case GameMode::Client:
-            success &= clientLoad();
-            break;
-        case GameMode::Dedicated:
-            success &= serverLoad();
-            break;
-        case GameMode::Standalone:
-            success &= standaloneLoad();
-            break;
-        default: // never happens
-            assert(false);
-        }
-
-        if (success)
-        {
-            InputManager::getInstance().requestEnterState("game");
-            this->mode_ = mode;
-        }
-
-        return success;
+        //if (mode_.mode == GameMode::Client)
+        //    network::Client::getSingleton()->closeConnection();
+
+        //if (mode_.hasServer)
+        //    server_g->close();
     }
 
@@ -408,8 +326,8 @@
     COUT(0) << "Loading level in server mode" << std::endl;
 
-    assert(Settings::getCommandLineArgument("port"));
-    int serverPort = Settings::getCommandLineArgument("port")->value_;
-    //server_g = new network::Server(serverPort_);
-    server_g = network::Server::createSingleton(serverPort);
+    //assert(Settings::getCommandLineArgument("port"));
+    //int serverPort = Settings::getCommandLineArgument("port")->value_;
+    ////server_g = new network::Server(serverPort_);
+    //server_g = network::Server::createSingleton(serverPort);
 
     if (!loadScene())
@@ -428,13 +346,13 @@
     COUT(0) << "Loading level in client mode" << std::endl;\
 
-    assert(Settings::getCommandLineArgument("port"));
-    assert(Settings::getCommandLineArgument("ip"));
-    int serverPort = Settings::getCommandLineArgument("port")->value_;
-    std::string serverIP = Settings::getCommandLineArgument("ip")->value_;
-
-    if (serverIP.compare("") == 0)
-      client_g = network::Client::createSingleton();
-    else
-      client_g = network::Client::createSingleton(serverIP, serverPort);
+    //assert(Settings::getCommandLineArgument("port"));
+    //assert(Settings::getCommandLineArgument("ip"));
+    //int serverPort = Settings::getCommandLineArgument("port")->value_;
+    //std::string serverIP = Settings::getCommandLineArgument("ip")->value_;
+
+    //if (serverIP.compare("") == 0)
+    //  client_g = network::Client::createSingleton();
+    //else
+    //  client_g = network::Client::createSingleton(serverIP, serverPort);
 
     if(!client_g->establishConnection())
@@ -504,11 +422,4 @@
         float dt = (timeBeforeTick - timeBeforeTickOld) / 1000000.0;
 
-        // check whether we have to load a game
-        if (mode_.mode != modeRequest_.mode && mode_.mode == GameMode::Unspecified)
-        {
-            this->loadLevel(modeRequest_);
-            this->modeRequest_ = GameMode::GM_None;
-        }
-
 
         // tick the core (needs real time for input and tcl thread management)
@@ -552,5 +463,5 @@
         ogreRoot._fireFrameStarted(evt);
 
-        if (mode_.showsGraphics)
+        if (Settings::showsGraphics())
         {
           // Pump messages in all registered RenderWindows
Index: code/branches/gui/src/orxonox/Orxonox.h
===================================================================
--- code/branches/gui/src/orxonox/Orxonox.h	(revision 1662)
+++ code/branches/gui/src/orxonox/Orxonox.h	(revision 1663)
@@ -74,5 +74,4 @@
       Orxonox(Orxonox& instance);
 
-      bool loadLevel(const GameMode& mode);
       bool serverLoad();
       bool clientLoad();
@@ -91,8 +90,4 @@
       float                 timefactor_;       //!< A factor to change the gamespeed
 
-      // this is used to identify the mode (server/client/...) we're in
-      GameMode              mode_;
-      GameMode              modeRequest_;
-
       // config values
       float                 debugRefreshTime_;
Index: code/branches/gui/src/orxonox/OrxonoxPrereqs.h
===================================================================
--- code/branches/gui/src/orxonox/OrxonoxPrereqs.h	(revision 1662)
+++ code/branches/gui/src/orxonox/OrxonoxPrereqs.h	(revision 1663)
@@ -75,4 +75,5 @@
     class GraphicsEngine;
     class Orxonox;
+    class Settings;
 
     class RadarViewable;
Index: code/branches/gui/src/orxonox/Settings.cc
===================================================================
--- code/branches/gui/src/orxonox/Settings.cc	(revision 1662)
+++ code/branches/gui/src/orxonox/Settings.cc	(revision 1663)
@@ -42,18 +42,5 @@
 namespace orxonox
 {
-
-// Using a macro makes the above list much more readable.
-// Settings::addGameMode adds the mode in a map, so we can access game modes by string.
-#define CreateGameMode(name, showsGraphics, isMaster, hasServer)                                        \
-    const GameMode GameMode::GM_##name = { GameMode::name, showsGraphics, isMaster, hasServer, #name }; \
-    bool temporaryVariable##name = Settings::addGameMode(&GameMode::GM_##name)
-
-    //                          showsGraphics  isMaster  hasServer
-    CreateGameMode(None,        false,         false,    false);
-    CreateGameMode(Unspecified, true,          false,    false);
-    CreateGameMode(Server,      true,          true,     true );
-    CreateGameMode(Client,      true,          false,    false);
-    CreateGameMode(Standalone,  true,          true,     false);
-    CreateGameMode(Dedicated,   false,         true,     true );
+    Settings* Settings::singletonRef_s = 0;
 
     /**
@@ -62,20 +49,11 @@
     */
     Settings::Settings()
+        : bShowsGraphics_(false)
+        , bHasServer_(false)
     {
         RegisterRootObject(Settings);
-        gameMode_ = GameMode::GM_None;
+        assert(singletonRef_s == 0);
+        singletonRef_s = this;
         setConfigValues();
-    }
-
-    /**
-    @brief
-        Returns a unique instance of Core.
-    @return
-        The instance
-    */
-    Settings& Settings::getInstance()
-    {
-        static Settings instance;
-        return instance;
     }
 
@@ -110,45 +88,3 @@
     }
 
-    /**
-    @brief
-        Sets the game mode.
-    */
-    /*static*/ void Settings::setGameMode(const std::string& mode)
-    {
-        std::string modeL = getLowercase(mode);
-        std::map<std::string, const GameMode*>::const_iterator it = getInstance().gameModes_.find(modeL);
-        if (it != getInstance().gameModes_.end())
-            getInstance().gameMode_ = *(*it).second;
-        else
-        {
-            COUT(2) << "Warning: mode \"" << mode << "\" doesn't exist. "
-                    << "Defaulting to 'Standalone'" << std::endl;
-            getInstance().gameMode_ = GameMode::GM_Standalone;
-        }
-    }
-
-    /*static*/ bool Settings::addGameMode(const GameMode* mode)
-    {
-        getInstance().gameModes_[getLowercase(mode->name)] = mode;
-        return true;
-    }
-
-
-    /**
-    @brief
-        Gets an argument from the command line by name.
-    @return
-        Is 0 if name was not found.
-    */
-    /*static*/ const Settings::CommandLineArgument* Settings::getCommandLineArgument(const std::string &name)
-    {
-        std::map<std::string, CommandLineArgument>::const_iterator it = getInstance().commandArguments_.find(name);
-        if (it != getInstance().commandArguments_.end())
-        {
-            return &((*it).second);
-        }
-        else
-            return 0;
-    }
-
 }
Index: code/branches/gui/src/orxonox/Settings.h
===================================================================
--- code/branches/gui/src/orxonox/Settings.h	(revision 1662)
+++ code/branches/gui/src/orxonox/Settings.h	(revision 1663)
@@ -47,145 +47,42 @@
 namespace orxonox
 {
-    /**
-    @brief
-        Defines a bit field structure that holds the mode as enum plus
-        the attributes as single named bits.
-        Every different GameMode is stored as static const, but if you wish to
-        compare two modes, you will have to use the 'mode' member variable.
-    */
-    struct GameMode
+    class _OrxonoxExport Settings : public OrxonoxClass
     {
-        enum Mode
-        {
-            None,
-            Unspecified,
-            Server,
-            Client,
-            Standalone,
-            Dedicated,
-        };
+        friend class ClassIdentifier<Settings>;
+        friend class GSRoot;
 
-        Mode mode;
-        bool showsGraphics;
-        bool isMaster;
-        bool hasServer;
-        std::string name;
+    public:
+        static const std::string& getDataPath()
+        { assert(singletonRef_s); return singletonRef_s->dataPath_; }
+        static void tsetDataPath(const std::string& path)
+        { assert(singletonRef_s); singletonRef_s->_tsetDataPath(path); }
 
-        static const GameMode GM_None;
-        static const GameMode GM_Unspecified;
-        static const GameMode GM_Server;
-        static const GameMode GM_Client;
-        static const GameMode GM_Standalone;
-        static const GameMode GM_Dedicated;
-    };
+        // an alternative to a global game mode variable
+        static bool showsGraphics() { assert(singletonRef_s); return singletonRef_s->bShowsGraphics_; }
+        static bool hasServer()     { assert(singletonRef_s); return singletonRef_s->bHasServer_; }
 
 
-    class _OrxonoxExport Settings : public OrxonoxClass
-    {
-    public:
-        struct CommandLineArgument
-        {
-            std::string name_;
-            MultiTypeMath value_;
-            bool bHasDefaultValue_;
-        };
+    private:
+        // GSRoot has access to these
+        static void setShowsGraphics(bool val) { assert(singletonRef_s); singletonRef_s->bShowsGraphics_ = val; }
+        static void setHasServer    (bool val) { assert(singletonRef_s); singletonRef_s->bHasServer_     = val; }
+
+        Settings();
+        Settings(const Settings& instance);
+        ~Settings() { singletonRef_s = 0; }
+
+        static Settings& _getInstance() { assert(singletonRef_s); return *singletonRef_s; }
+        void _tsetDataPath(const std::string& path);
 
         void setConfigValues();
 
-        static const std::string& getDataPath();
-        static void tsetDataPath(const std::string& path);
+        bool bShowsGraphics_;                                  //!< global variable that tells whether to show graphics
+        bool bHasServer_;                                      //!< global variable that tells whether this is a server
 
-        static const GameMode& getGameMode();
-        static const GameMode& getGameMode(const std::string& name);
-        static void setGameMode(const GameMode& mode);
-        static void setGameMode(const std::string& mode);
-        static bool addGameMode(const GameMode* mode);
+        std::string dataPath_;                                 //!< Path to the game data
 
-        static const CommandLineArgument* getCommandLineArgument(const std::string& name);
-        template <class T>
-        static bool addCommandLineArgument(const std::string &name, const std::string& valueStr, const T& defaultValue);
-
-    private:
-        Settings();
-        Settings(const Settings& instance);
-        ~Settings() { }
-        static Settings& getInstance();
-
-        void _tsetDataPath(const std::string& path);
-
-        std::string dataPath_;                                        //!< Path to the game data
-        GameMode gameMode_;                                           //!< Current game mode
-        std::map<std::string, const GameMode*> gameModes_;            //!< Holds all game modes for easy string access
-        //! holds all command line arguments (even if not given!)
-        std::map<std::string, CommandLineArgument> commandArguments_;
+        static Settings* singletonRef_s;                       //!< Static pointer to the only instance.
     };
 
-    /**
-    @brief
-        Returns the relative path to the game data.
-    */
-    inline const std::string& Settings::getDataPath()
-    {
-        return getInstance().dataPath_;
-    }
-
-    inline void Settings::tsetDataPath(const std::string& path)
-    {
-        getInstance()._tsetDataPath(path);
-    }
-
-    inline const GameMode& Settings::getGameMode()
-    {
-        return getInstance().gameMode_;
-    }
-
-    inline const GameMode& Settings::getGameMode(const std::string& name)
-    {
-        if (getInstance().gameModes_.find(name) != getInstance().gameModes_.end())
-            return *getInstance().gameModes_[name];
-        else
-        {
-            COUT(2) << "Warning: GameMode '" << name << "' doesn't exist." << std::endl;
-            return GameMode::GM_None;
-        }
-    }
-
-    inline void Settings::setGameMode(const GameMode& mode)
-    {
-        getInstance().gameMode_ = mode;
-    }
-
-    /**
-    @brief
-        Adds one argument of the command line to the map of command line arguments.
-    @param name
-        Name of the command line option.
-    @param valueStr
-        The value of the command line option as string
-    @param defaultValue
-        Default value for the option (marked when used).
-    @return
-        Dummy return value to enable code execution before main().
-    */
-    template <class T>
-    bool Settings::addCommandLineArgument(const std::string &name, const std::string& valueStr, const T& defaultValue)
-    {
-        T value;
-        bool useDefault = false;
-        if (valueStr == "")
-        {
-            // note: ArgReader only returns "" for not found arguments, " " otherwise for empty ones.
-            value = defaultValue;
-            useDefault = true;
-        }
-        else if (!convertValue(&value, valueStr))
-        {
-            COUT(1) << "Command Line: Couldn't read option '" << name << "'." << std::endl;
-            return false;
-        }
-        CommandLineArgument arg = { name, MultiTypeMath(value), useDefault };
-        getInstance().commandArguments_[name] = arg;
-        return true;
-    }
 }
 
Index: code/branches/gui/src/orxonox/gamestates/GSLevel.cc
===================================================================
--- code/branches/gui/src/orxonox/gamestates/GSLevel.cc	(revision 1662)
+++ code/branches/gui/src/orxonox/gamestates/GSLevel.cc	(revision 1663)
@@ -35,4 +35,5 @@
 #include "core/input/KeyBinder.h"
 #include "core/Loader.h"
+#include "core/CommandLine.h"
 #include "overlays/console/InGameConsole.h"
 #include "gui/GUIManager.h"
@@ -45,4 +46,7 @@
 namespace orxonox
 {
+    SetCommandLineArgument(port, 55556).setShortcut("p");
+    SetCommandLineArgument(ip, std::string("127.0.0.0"));
+
     GSLevel::GSLevel()
         : GameState("level")
Index: code/branches/gui/src/orxonox/gamestates/GSRoot.cc
===================================================================
--- code/branches/gui/src/orxonox/gamestates/GSRoot.cc	(revision 1662)
+++ code/branches/gui/src/orxonox/gamestates/GSRoot.cc	(revision 1663)
@@ -38,4 +38,5 @@
 #include "core/TclBind.h"
 #include "core/Core.h"
+#include "core/CommandLine.h"
 #include "GraphicsEngine.h"
 #include "Settings.h"
@@ -43,6 +44,9 @@
 namespace orxonox
 {
+    SetCommandLineArgument(dataPath, std::string("./"));
+
     GSRoot::GSRoot()
         : GameState("root")
+        , settings_(0)
         , graphicsEngine_(0)
     {
@@ -64,12 +68,14 @@
         Factory::createClassHierarchy();
 
-        const Settings::CommandLineArgument* dataPath = Settings::getCommandLineArgument("dataPath");
-        assert(dataPath);
-        if (!dataPath->bHasDefaultValue_)
+        // instantiate Settings class
+        this->settings_ = new Settings();
+
+        const CommandLineArgument<std::string>* dataPath = CommandLine::getCommandLineArgument<std::string>("dataPath");
+        if (!dataPath->hasDefaultValue())
         {
-            if (*dataPath->value_.getString().end() != '/' && *dataPath->value_.getString().end() != '\\')
-                Settings::tsetDataPath(dataPath->value_.getString() + "/");
+            if (*dataPath->getValue().end() != '/' && *dataPath->getValue().end() != '\\')
+                Settings::tsetDataPath(dataPath->getValue() + "/");
             else
-                Settings::tsetDataPath(dataPath->value_.getString());
+                Settings::tsetDataPath(dataPath->getValue());
         }
 
@@ -89,6 +95,7 @@
     void GSRoot::leave()
     {
-        if (this->graphicsEngine_)
-            delete graphicsEngine_;
+        delete graphicsEngine_;
+
+        delete settings_;
     }
 
Index: code/branches/gui/src/orxonox/gamestates/GSRoot.h
===================================================================
--- code/branches/gui/src/orxonox/gamestates/GSRoot.h	(revision 1662)
+++ code/branches/gui/src/orxonox/gamestates/GSRoot.h	(revision 1663)
@@ -48,4 +48,5 @@
         void leave();
 
+        Settings*             settings_;
         GraphicsEngine*       graphicsEngine_;   //!< our dearest graphics engine <3
     };
Index: code/branches/gui/visual_studio/vc8/core.vcproj
===================================================================
--- code/branches/gui/visual_studio/vc8/core.vcproj	(revision 1662)
+++ code/branches/gui/visual_studio/vc8/core.vcproj	(revision 1663)
@@ -245,4 +245,8 @@
 				</File>
 				<File
+					RelativePath="..\..\src\core\CommandLine.cc"
+					>
+				</File>
+				<File
 					RelativePath="..\..\src\core\ConsoleCommand.cc"
 					>
@@ -507,4 +511,8 @@
 				</File>
 				<File
+					RelativePath="..\..\src\core\CommandLine.h"
+					>
+				</File>
+				<File
 					RelativePath="..\..\src\core\ConsoleCommand.h"
 					>
