Index: /trunk/AUTHORS
===================================================================
--- /trunk/AUTHORS	(revision 7255)
+++ /trunk/AUTHORS	(revision 7256)
@@ -1,9 +1,16 @@
 orxonox-crew: <orxonox-dev@mail.datacore.ch>
 
+Maintainers:
 Patrick Boenzli <patrick@orxonox.ethz.ch>
 Benjamin Grauer <bensch@orxonox.ethz.ch>
+
+Developers:
+Christian Meyer
+David Gruetter
+
+Coders:
 Simon Hofmann
-David Gruetter
 Johannes Bader
 Adrian Buerli
-Christian Meyer
+
+
Index: /trunk/configure.ac
===================================================================
--- /trunk/configure.ac	(revision 7255)
+++ /trunk/configure.ac	(revision 7256)
@@ -646,4 +646,6 @@
                  src/lib/parser/tinyxml/Makefile
                  src/lib/parser/ini_parser/Makefile
+                 src/lib/parser/cmdline_parser/Makefile
+		 src/lib/parser/preferences/Makefile
                  src/util/Makefile
                  src/world_entities/Makefile
Index: /trunk/src/defs/class_id.h
===================================================================
--- /trunk/src/defs/class_id.h	(revision 7255)
+++ /trunk/src/defs/class_id.h	(revision 7256)
@@ -96,4 +96,5 @@
   CL_MASK_LOWLEVEL_CLASS        =    0x00000fff,
 
+  CL_PREFERENCES                =    0X00000f51,
 
   /// SINGLETON classes (range from 0x00000000 to 0x000000ff)
Index: /trunk/src/defs/globals.h
===================================================================
--- /trunk/src/defs/globals.h	(revision 7255)
+++ /trunk/src/defs/globals.h	(revision 7256)
@@ -27,4 +27,6 @@
 #define   DEFAULT_DATA_DIR                 DATADIR "/orxonox/"
 #define   DEFAULT_DATA_DIR_CHECKFILE       "data.oxd"
+
+#define   DEFAULT_ORXONOX_PORT             9999
 
 // Defines all the Sections of the Config (in Gui and orxonox)
Index: /trunk/src/lib/BuildLibs.am
===================================================================
--- /trunk/src/lib/BuildLibs.am	(revision 7255)
+++ /trunk/src/lib/BuildLibs.am	(revision 7256)
@@ -15,5 +15,8 @@
                 $(LIB_PREFIX)/graphics/spatial_separation/libORXquadtree.a \
                 $(LIB_PREFIX)/parser/tinyxml/libtinyxml.a \
+                $(LIB_PREFIX)/parser/preferences/libPrefsParser.a \
+                $(LIB_PREFIX)/parser/cmdline_parser/libCmdLineParser.a \
                 $(LIB_PREFIX)/parser/ini_parser/libIniParser.a \
                 $(LIB_PREFIX)/shell/libORXshell.a \
-                $(LIB_PREFIX)/math/libORXmath.a
+                $(LIB_PREFIX)/math/libORXmath.a \
+                $(LIB_PREFIX)/libORXlibs.a
Index: /trunk/src/lib/Makefile.am
===================================================================
--- /trunk/src/lib/Makefile.am	(revision 7255)
+++ /trunk/src/lib/Makefile.am	(revision 7256)
@@ -23,4 +23,5 @@
 		util/loading/factory.cc \
 		util/loading/dynamic_loader.cc \
+		util/preferences.cc \
 		\
 		data/data_tank.cc
@@ -39,4 +40,5 @@
 		util/executor/executor_specials.h \
 		util/executor/functor_list.h \
+		util/preferences.h \
 		\
 		util/loading/resource_manager.h \
Index: /trunk/src/lib/event/event_handler.cc
===================================================================
--- /trunk/src/lib/event/event_handler.cc	(revision 7255)
+++ /trunk/src/lib/event/event_handler.cc	(revision 7256)
@@ -88,10 +88,10 @@
  * this has to be called before the use of the event handler
 */
-void EventHandler::init(IniParser* iniParser)
+void EventHandler::init()
 {
   if (this->keyMapper == NULL)
   {
     this->keyMapper = new KeyMapper();
-    this->keyMapper->loadKeyBindings(iniParser);
+    this->keyMapper->loadKeyBindings();
   }
 }
Index: /trunk/src/lib/event/event_handler.h
===================================================================
--- /trunk/src/lib/event/event_handler.h	(revision 7255)
+++ /trunk/src/lib/event/event_handler.h	(revision 7256)
@@ -15,5 +15,4 @@
 // FORWARD DECLARATION
 class EventListener;
-class IniParser;
 
 //! The one Event Handler from Orxonox
@@ -24,5 +23,5 @@
   /** @returns a Pointer to the only object of this Class */
   inline static EventHandler* getInstance() { if (!singletonRef) singletonRef = new EventHandler();  return singletonRef; };
-  void init(IniParser* iniParser);
+  void init();
 
   /** @param state: to which the event handler shall change */
Index: /trunk/src/lib/event/key_mapper.cc
===================================================================
--- /trunk/src/lib/event/key_mapper.cc	(revision 7255)
+++ /trunk/src/lib/event/key_mapper.cc	(revision 7256)
@@ -25,4 +25,5 @@
 #include "globals.h"
 #include "parser/ini_parser/ini_parser.h"
+#include "util/preferences.h"
 #include "key_names.h"
 #include "debug.h"
@@ -145,5 +146,5 @@
 
   iniParser->firstVar();
-  while(iniParser->getCurrentName() != "")
+  while( iniParser->getCurrentName() != "" )
   {
     PRINTF(3)("Keys: Parsing %s, %s now.\n", iniParser->getCurrentName(), iniParser->getCurrentValue());
@@ -164,5 +165,5 @@
 
   iniParser->firstVar();
-  while(iniParser->getCurrentName() != "")
+  while( iniParser->getCurrentName() != "" )
   {
     PRINTF(3)("MISC: Parsing %s, %s now.\n", iniParser->getCurrentName(), iniParser->getCurrentValue());
@@ -170,4 +171,40 @@
     this->mapKeys(iniParser->getCurrentName(), index);
     iniParser->nextVar();
+  }
+}
+
+void KeyMapper::loadKeyBindings()
+{
+  if( !Preferences::getInstance()->sectionExists(CONFIG_SECTION_PLAYER "1"))
+  {
+    PRINTF(1)("Could not find key bindings " CONFIG_SECTION_PLAYER"1\n");
+    return;
+  }
+  int* index;
+
+  std::list<std::string> keys = Preferences::getInstance()->listKeys(CONFIG_SECTION_PLAYER "1");
+  for ( std::list<std::string>::const_iterator it = keys.begin(); it!=keys.end(); it++ )
+  {
+    PRINTF(3)("Keys: Parsing %s, %s now.\n", it->c_str(), Preferences::getInstance()->getString(CONFIG_SECTION_PLAYER "1", *it, "").c_str());
+    // map the name to an sdl index
+    index = nameToIndex (Preferences::getInstance()->getString(CONFIG_SECTION_PLAYER "1", *it, ""));
+    // map the index to a internal name
+    this->mapKeys(*it, index);
+  }
+
+
+  // PARSE MISC SECTION
+  if( !Preferences::getInstance()->sectionExists (CONFIG_SECTION_MISC_KEYS))
+  {
+    PRINTF(1)("Could not find key bindings " CONFIG_SECTION_MISC_KEYS "\n");
+    return;
+  }
+
+  keys = Preferences::getInstance()->listKeys(CONFIG_SECTION_MISC_KEYS);
+  for ( std::list<std::string>::const_iterator it = keys.begin(); it!=keys.end(); it++ )
+  {
+    PRINTF(3)("MISC: Parsing %s, %s now.\n", it->c_str(), Preferences::getInstance()->getString(CONFIG_SECTION_MISC_KEYS, *it, "").c_str());
+    index = nameToIndex (Preferences::getInstance()->getString(CONFIG_SECTION_MISC_KEYS, *it, ""));
+    this->mapKeys(*it, index);
   }
 }
Index: /trunk/src/lib/event/key_mapper.h
===================================================================
--- /trunk/src/lib/event/key_mapper.h	(revision 7255)
+++ /trunk/src/lib/event/key_mapper.h	(revision 7256)
@@ -29,5 +29,6 @@
   virtual ~KeyMapper();
 
-  void loadKeyBindings(const std::string& fileName = "" );
+  void loadKeyBindings(const std::string& fileName );
+  void loadKeyBindings();
   void loadKeyBindings(IniParser* iniParser);
 
Index: /trunk/src/lib/graphics/graphics_engine.cc
===================================================================
--- /trunk/src/lib/graphics/graphics_engine.cc	(revision 7255)
+++ /trunk/src/lib/graphics/graphics_engine.cc	(revision 7256)
@@ -29,5 +29,5 @@
 #include "debug.h"
 
-#include "parser/ini_parser/ini_parser.h"
+#include "util/preferences.h"
 #include "substring.h"
 #include "text.h"
@@ -150,17 +150,16 @@
 /**
  * loads the GraphicsEngine's settings from a given ini-file and section
- * @param iniParser the iniParser to load from
- * @param section the Section in the ini-file to load from
  * @returns nothing usefull
  */
-int GraphicsEngine::initFromIniFile(IniParser* iniParser)
+int GraphicsEngine::initFromPreferences()
 {
   // looking if we are in fullscreen-mode
-  const std::string fullscreen = iniParser->getVar(CONFIG_NAME_FULLSCREEN, CONFIG_SECTION_VIDEO, "0");
+  const std::string fullscreen = Preferences::getInstance()->getString(CONFIG_SECTION_VIDEO, CONFIG_NAME_FULLSCREEN, "0");
+
   if (fullscreen[0] == '1' || fullscreen == "true")
     this->fullscreenFlag = SDL_FULLSCREEN;
 
   // looking if we are in fullscreen-mode
-  const std::string textures = iniParser->getVar(CONFIG_NAME_TEXTURES, CONFIG_SECTION_VIDEO_ADVANCED, "0");
+  const std::string textures = Preferences::getInstance()->getString(CONFIG_SECTION_VIDEO_ADVANCED, CONFIG_NAME_TEXTURES, "0");
   if (textures[0] == '1' || textures == "true")
     Texture::setTextureEnableState(true);
@@ -169,5 +168,5 @@
 
   // searching for a usefull resolution
-  SubString resolution(iniParser->getVar(CONFIG_NAME_RESOLUTION, CONFIG_SECTION_VIDEO, "640x480").c_str(), 'x'); ///FIXME
+  SubString resolution(Preferences::getInstance()->getString(CONFIG_SECTION_VIDEO, CONFIG_NAME_RESOLUTION, "640x480").c_str(), 'x'); ///FIXME
   //resolution.debug();
   MultiType x = resolution.getString(0), y = resolution.getString(1);
Index: /trunk/src/lib/graphics/graphics_engine.h
===================================================================
--- /trunk/src/lib/graphics/graphics_engine.h	(revision 7255)
+++ /trunk/src/lib/graphics/graphics_engine.h	(revision 7256)
@@ -20,5 +20,4 @@
 // Forward Declaration
 class Text;
-class IniParser;
 class WorldEntity;
 class GraphicsEffect;
@@ -39,5 +38,5 @@
 
     int init();
-    int initFromIniFile(IniParser* iniParser);
+    int initFromPreferences();
 
     void setWindowName(const std::string& windowName, const std::string& icon);
Index: /trunk/src/lib/network/network_manager.cc
===================================================================
--- /trunk/src/lib/network/network_manager.cc	(revision 7255)
+++ /trunk/src/lib/network/network_manager.cc	(revision 7256)
@@ -88,8 +88,8 @@
  * @param hostName: the name of the destination host
  */
-int NetworkManager::establishConnection(const char* name, unsigned int port)
+int NetworkManager::establishConnection(const std::string & name, unsigned int port)
 {
   IPaddress ipAddress;
-  int error = SDLNet_ResolveHost(&ipAddress, name, port);
+  int error = SDLNet_ResolveHost(&ipAddress, name.c_str(), port);
   if( error == -1) {
     printf("\n\nerror on address resolution, program inconsistency\n\n");
Index: /trunk/src/lib/network/network_manager.h
===================================================================
--- /trunk/src/lib/network/network_manager.h	(revision 7255)
+++ /trunk/src/lib/network/network_manager.h	(revision 7256)
@@ -36,5 +36,5 @@
     void shutdown();
 
-    int establishConnection(const char* name, unsigned int port);
+    int establishConnection( const std::string & name, unsigned int port);
     int createServer(unsigned int port);
 
Index: /trunk/src/lib/parser/Makefile.am
===================================================================
--- /trunk/src/lib/parser/Makefile.am	(revision 7255)
+++ /trunk/src/lib/parser/Makefile.am	(revision 7256)
@@ -1,5 +1,7 @@
 SUBDIRS = \
           tinyxml \
-	  ini_parser
+	  ini_parser \
+	  preferences \
+	  cmdline_parser
 
 
Index: /trunk/src/lib/parser/cmdline_parser/Makefile.am
===================================================================
--- /trunk/src/lib/parser/cmdline_parser/Makefile.am	(revision 7256)
+++ /trunk/src/lib/parser/cmdline_parser/Makefile.am	(revision 7256)
@@ -0,0 +1,10 @@
+
+noinst_LIBRARIES = libCmdLineParser.a
+
+libCmdLineParser_a_SOURCES = cmdline_parser.cc
+
+libCmdLineParser_a_CPPFLAGS = "-DNO_SHELL"
+
+noinst_HEADERS = cmdline_parser.h
+
+
Index: /trunk/src/lib/parser/cmdline_parser/cmdline_parser.cc
===================================================================
--- /trunk/src/lib/parser/cmdline_parser/cmdline_parser.cc	(revision 7256)
+++ /trunk/src/lib/parser/cmdline_parser/cmdline_parser.cc	(revision 7256)
@@ -0,0 +1,252 @@
+/*
+   orxonox - the future of 3D-vertical-scrollers
+
+   Copyright (C) 2004 orx
+
+   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, or (at your option)
+   any later version.
+
+   ### File Specific:
+   main-programmer: Christoph Renner
+   co-programmer: 
+*/
+
+#include "cmdline_parser.h"
+
+#include "src/lib/util/substring.h"
+
+using namespace std;
+
+
+/**
+ * standard constructor
+ */
+CmdLineParser::CmdLineParser ()
+{
+}
+
+
+/**
+ * standard deconstructor
+ */
+CmdLineParser::~CmdLineParser ()
+{
+}
+
+
+bool CmdLineParser::add( int id, const std::string & longOption, char shortOption, int numArgs, const std::string & argNames, const std::string& help, bool back )
+{
+  ArgTableEntry entry;
+  
+  entry.id = id;
+  entry.longOption = longOption;
+  entry.shortOption = shortOption;
+  entry.numArgs = numArgs;
+  entry.argNames = argNames;
+  entry.help = help;
+  
+  if ( back )
+    argTable.push_back( entry );
+  else
+    argTable.push_front( entry );
+}
+
+
+bool CmdLineParser::parse( ArgParserCallback cb, void * data, int argc, char ** argv )
+{
+  this->exeName = argv[0];
+  
+  //put all args in vector
+  std::vector<std::string> args;
+  
+  for ( int i = 1; i<argc; i++ )
+  {
+    std::string s = argv[i];
+    
+    if ( s.find( "=" ) == std::string::npos )
+    {
+      args.push_back(s);
+    }
+    else
+    {
+      std::string op = s;
+      std::string ar = s;
+      op.erase( op.find("=") );
+      ar.erase( 0, ar.find("=")+1);
+      
+      //PRINTF(0)("'%s' '%s'\n", op.c_str(), ar.c_str());
+      args.push_back( op );
+      args.push_back( ar );
+    }
+  }
+  
+  int i = 0;
+  
+  ArgTable::iterator it;
+  bool finish;
+  bool found;
+  
+  while ( i < args.size() )
+  {
+    found = false;
+    for ( it = argTable.begin(); it != argTable.end(); it++ )
+    {
+      if ( matches( *it, args[i], finish ) )
+      {
+        found = true;
+        
+        if ( it->numArgs + i >= args.size() )
+        {
+          PRINTF(1)( "%s needs %d arguments!\n", args[i].c_str(), it->numArgs );
+          return false;
+        }
+        
+        std::vector<MultiType> argArgs;
+        
+        for ( int j = 1; j <= it->numArgs; j++ )
+          argArgs.push_back( args[i+j] );
+        
+        if ( !cb( *it, data, args[i], argArgs ) )
+          return false;
+        
+        i += it->numArgs + 1;
+        
+        if ( finish )
+          break;
+        else 
+        {
+          assert( it->numArgs == 0 );
+        }
+      }
+    }
+    
+    if ( !found )
+    {
+      PRINTF(1)("%s: illegal option\n", args[i].c_str());
+      return false;
+    }
+  }
+  
+  return true;
+}
+
+bool CmdLineParser::matches( ArgTableEntry entry, std::string arg, bool & finish )
+{
+  finish = true;
+  
+  if ( arg.length() < 2 )
+    return false;
+  
+  if ( arg[0] == '-' )
+  {
+    if ( arg[1] == '-' )
+    {
+      arg.erase( 0, 2 );
+      
+      if ( entry.longOption.find('%') != std::string::npos )
+      {
+        //TODO implement bether match algo
+        assert( entry.longOption.find('%') == entry.longOption.length()-1 );
+        std::string lo = entry.longOption;
+        lo.erase( lo.length()-1, 1 );
+        //PRINTF(0)("%s %s\n", arg.c_str(), lo.c_str());
+        return arg.find( lo ) == 0;
+      }
+      else
+      {
+        return arg.find( entry.longOption ) != std::string::npos;
+      }
+    }
+    else
+    {
+      if ( arg.length() != 2 && entry.numArgs != 0 )
+      {
+        PRINTF(1)("using multiple flags together is only alowed if none needs an arugument. %s needs %d arguments\n", entry.shortOption, entry.numArgs);
+        return false;
+      }
+      finish = arg.length()==2;
+      return arg.find(entry.shortOption) != std::string::npos;
+    }
+  }
+}
+
+void CmdLineParser::showHelp()
+{
+  printf("Usage: %s [options]\n", exeName.c_str());
+  printf("\n");
+  
+  std::list<std::vector<std::string> > output;
+  
+  for ( ArgTable::iterator it = argTable.begin(); it != argTable.end(); it++ )
+  {
+    output.push_back( std::vector<std::string>() );
+    
+    SubString substr( it->argNames );
+    std::string args;
+    assert( it->numArgs == substr.getCount() );
+      
+    for ( int i = 0; i<it->numArgs; i++ )
+    {
+      args += " [" + substr[i] + "]";
+    }
+    
+    if ( it->shortOption != '\0' )
+    {
+      output.back().push_back( " -" + std::string((char*)&it->shortOption, 1) );
+      output.back().back() += args;
+    }
+    else
+      output.back().push_back( "" );
+    
+    if ( it->longOption != "" )
+    {
+      output.back().push_back( "--" + it->longOption );
+      
+      output.back().back() += args;
+    }
+    else
+      output.back().push_back( "" );
+    
+    output.back().push_back( it->help );
+  }
+  
+  output.push_back( std::vector<std::string>() );
+  output.back().push_back( "Option" );
+  output.back().push_back( "Long option" );
+  output.back().push_back( "Description" );
+  
+  output.reverse();
+  
+  int maxShort = 0;
+  int maxLong = 0;
+  
+  std::list<std::vector<std::string> >::const_iterator it;
+  
+  for ( it = output.begin(); it != output.end(); it++ )
+  {
+    if ( (*it)[0].length() > maxShort )
+      maxShort = (*it)[0].length();
+    
+    if ( (*it)[1].length() > maxLong )
+      maxLong = (*it)[1].length();
+  }
+  
+  for ( it = output.begin(); it != output.end(); it++ )
+  {
+    printf("%s ", (*it)[0].c_str());
+    
+    for ( int i = 0; i<maxShort-(*it)[0].length(); i++ )
+      printf(" ");
+    
+    printf("%s ", (*it)[1].c_str());
+    
+    for ( int i = 0; i<maxLong-(*it)[1].length(); i++ )
+      printf(" ");
+    
+    printf("%s\n", (*it)[2].c_str());
+  }
+  
+  exit(0);
+}
Index: /trunk/src/lib/parser/cmdline_parser/cmdline_parser.h
===================================================================
--- /trunk/src/lib/parser/cmdline_parser/cmdline_parser.h	(revision 7256)
+++ /trunk/src/lib/parser/cmdline_parser/cmdline_parser.h	(revision 7256)
@@ -0,0 +1,53 @@
+/*!
+ * @file cmdline_parser.h
+ * @brief Definition of ...
+ */
+
+#ifndef _CMD_LINE_PARSER_H
+#define _CMD_LINE_PARSER_H
+
+#include <list>
+#include <string>
+#include <vector>
+
+#include "src/defs/debug.h"
+#include "src/lib/util/multi_type.h"
+
+
+struct ArgTableEntry
+{
+  int         id;
+  std::string longOption;
+  char        shortOption;
+  int         numArgs;
+  std::string argNames;
+  std::string help;
+};
+
+typedef std::list<ArgTableEntry> ArgTable;
+
+typedef bool (*ArgParserCallback)( ArgTableEntry, void*, const std::string &, const std::vector<MultiType> & );
+
+
+//! A class for parsing command line arguments
+class CmdLineParser {
+
+  public:
+    CmdLineParser();
+    virtual ~CmdLineParser();
+    
+    bool add( int id, const std::string& longOption, char shortOption, int numArgs, const std::string & argNames, const std::string& help, bool back=false );
+
+    bool parse( ArgParserCallback cb, void* data, int argc, char** argv );
+    
+    void showHelp();
+    
+  private:
+    ArgTable argTable;
+    std::string exeName;
+    
+    inline bool matches( ArgTableEntry entry, std::string arg, bool & finish );
+
+};
+
+#endif /* _CMD_LINE_PARSER_H */
Index: /trunk/src/lib/parser/ini_parser/ini_parser.cc
===================================================================
--- /trunk/src/lib/parser/ini_parser/ini_parser.cc	(revision 7255)
+++ /trunk/src/lib/parser/ini_parser/ini_parser.cc	(revision 7256)
@@ -392,4 +392,69 @@
 }
 
+/**
+ * @brief edits the entry speciefied by entryName in sectionName/currentSection or creates it if it doesn't exist
+ * @param entryName the Name of the Entry to add
+ * @param value the value to assign to this entry
+ * @param sectionName if NULL then this entry will be set to the currentSection
+ * otherwise to the section refered to by sectionName.
+ * If both are NULL no entry will be added
+ * @return true if everything is ok false on error
+ */
+bool IniParser::editVar(const std::string& entryName, const std::string& value, const std::string& sectionName)
+{
+  std::list<IniSection>::iterator section;
+
+  if (!sectionName.empty())
+  {
+    for (section = this->sections.begin(); section != this->sections.end(); section++)
+      if ((*section).name == sectionName)
+        break;
+  }
+  else
+    section = this->currentSection;
+
+  if (section == this->sections.end())
+  {
+    IniSection sec;
+    sec.comment = "";
+    sec.name = sectionName;
+    section = this->sections.insert(this->sections.end(), sec);
+  }
+
+  if (section == this->sections.end())
+  {
+    PRINTF(2)("section '%s' not found for value '%s'\n", sectionName.c_str(), entryName.c_str());
+    return false;
+  }
+  else
+  {
+    //try find item
+    std::list<IniEntry>::iterator entry;
+    for (entry = section->entries.begin(); entry!=section->entries.end(); entry++)
+      if (entry->name == entryName )
+        break;
+
+    //found it?
+    if ( entry != section->entries.end() )
+    {
+      entry->value = value;
+
+      return true;
+    }
+
+    //not found -> create it
+    (*section).entries.push_back(IniEntry());
+    (*section).entries.back().comment = "";
+    (*section).entries.back().name = entryName;
+    (*section).entries.back().value = value;
+    PRINTF(5)("Added Entry %s with Value '%s' to Section %s\n",
+    (*section).entries.back().name.c_str(),
+    (*section).entries.back().value.c_str(),
+    (*section).name);
+    this->currentEntry = --(*section).entries.end();
+    return true;
+  }
+}
+
 
 /**
Index: /trunk/src/lib/parser/ini_parser/ini_parser.h
===================================================================
--- /trunk/src/lib/parser/ini_parser/ini_parser.h	(revision 7255)
+++ /trunk/src/lib/parser/ini_parser/ini_parser.h	(revision 7256)
@@ -69,4 +69,5 @@
     bool addVar(const std::string& entryName, const std::string& value, const std::string& sectionName = "" );
     const std::string& getVar(const std::string& entryName, const std::string& sectionName, const std::string& defaultValue = "") const;
+    bool IniParser::editVar(const std::string& entryName, const std::string& value, const std::string& sectionName = "");
     void setEntryComment(const std::string& comment, const std::string& entryName, const std::string& sectionName);
     const std::string& getEntryComment(const std::string& entryName, const std::string& sectionName) const;
Index: /trunk/src/lib/parser/preferences/Makefile.am
===================================================================
--- /trunk/src/lib/parser/preferences/Makefile.am	(revision 7256)
+++ /trunk/src/lib/parser/preferences/Makefile.am	(revision 7256)
@@ -0,0 +1,13 @@
+MAINSRCDIR=../../..
+include $(MAINSRCDIR)/defs/include_paths.am
+
+noinst_LIBRARIES = libPrefsParser.a
+
+libPrefsParser_a_SOURCES = \
+		cmd_line_prefs_reader.cc \
+		ini_file_prefs_reader.cc
+
+
+noinst_HEADERS = \
+		cmd_line_prefs_reader.h \
+		ini_file_prefs_reader.h
Index: /trunk/src/lib/parser/preferences/cmd_line_prefs_reader.cc
===================================================================
--- /trunk/src/lib/parser/preferences/cmd_line_prefs_reader.cc	(revision 7256)
+++ /trunk/src/lib/parser/preferences/cmd_line_prefs_reader.cc	(revision 7256)
@@ -0,0 +1,158 @@
+/*
+   orxonox - the future of 3D-vertical-scrollers
+
+   Copyright (C) 2004 orx
+
+   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, or (at your option)
+   any later version.
+
+   ### File Specific:
+   main-programmer: Christoph Renner
+   co-programmer: ...
+*/
+
+//#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_
+
+#include "cmd_line_prefs_reader.h"
+
+#include "preferences.h"
+
+using namespace std;
+
+RegistredArgs CmdLinePrefsReader::regArgs;
+
+/**
+ * standard constructor
+*/
+CmdLinePrefsReader::CmdLinePrefsReader( )
+{
+
+}
+
+
+/**
+ * standard deconstructor
+*/
+CmdLinePrefsReader::~CmdLinePrefsReader ()
+{
+}
+
+bool CmdLinePrefsReader::callBack( ArgTableEntry entry, void * data, const std::string & arg, const std::vector<MultiType> & argArgs )
+{
+  CallbackData * cbd = (CallbackData *)data;
+  
+  switch ( entry.id )
+  {
+    case ID_SET_INI:
+    {
+      std::string section = arg;
+      section.erase( 0, entry.longOption.length()+1 );
+      std::string key = section;
+      section.erase( section.find(".") );
+      key.erase( 0, key.find(".")+1 );
+      //PRINTF(0)("SECTION '%s', KEY '%s'\n", section.c_str(), key.c_str());
+      
+      if ( key == "" || section == "" || argArgs.size() != 1 )
+      {
+        PRINTF(1)("usage: --set-section.key=value\n");
+        return false;
+      }
+      
+      //Preferences::getInstance()->setMultiType( section, key, argArgs[0], true );
+      cbd->iniEntries.push_back( IniEntry() );
+      cbd->iniEntries.back().section = section;
+      cbd->iniEntries.back().key = key;
+      cbd->iniEntries.back().value = argArgs[0].getString();
+      return true;
+    }
+    case ID_HELP:
+      cbd->parser->showHelp();
+      return true;
+  }
+  
+  if ( entry.id >= ID_PREFS && entry.id - ID_PREFS < regArgs.size() )
+  {
+    if ( regArgs[entry.id - ID_PREFS].value == "%arg%" )
+    {
+      assert( argArgs.size() == 1 );
+      
+      cbd->iniEntries.push_back( IniEntry() );
+      cbd->iniEntries.back().section = regArgs[entry.id - ID_PREFS].section;
+      cbd->iniEntries.back().key = regArgs[entry.id - ID_PREFS].key;
+      cbd->iniEntries.back().value = argArgs[0].getString();
+    }
+    else
+    {
+      cbd->iniEntries.push_back( IniEntry() );
+      cbd->iniEntries.back().section = regArgs[entry.id - ID_PREFS].section;
+      cbd->iniEntries.back().key = regArgs[entry.id - ID_PREFS].key;
+      cbd->iniEntries.back().value = regArgs[entry.id - ID_PREFS].value;
+    }
+  }
+  else
+  {
+    assert(false);
+  }
+  
+  return true;
+}
+
+
+bool CmdLinePrefsReader::parse( int argc, char ** argv )
+{
+  CmdLineParser parser;
+  
+  parser.add( ID_HELP, "help", 'h', 0, "", "Shows this help");
+  
+  for ( int i = 0; i<regArgs.size(); i++ )
+  {
+    if ( regArgs[i].value == "%arg%" )
+    {
+      parser.add( ID_PREFS + i, regArgs[i].longOption, regArgs[i].shortOption, 1, regArgs[i].argName, regArgs[i].help );
+    }
+    else
+    {
+      parser.add( ID_PREFS + i, regArgs[i].longOption, regArgs[i].shortOption, 0, "", regArgs[i].help );
+    }
+  }
+  
+  parser.add( ID_SET_INI, "set-%", '\0', 1, "value", "Override a configuration element." );
+  
+  CallbackData cbd;
+  
+  cbd.parser = &parser;
+  
+  if ( parser.parse( &callBack, &cbd, argc, argv ) )
+  {
+    std::list<IniEntry>::const_iterator it;
+    for ( it = cbd.iniEntries.begin(); it != cbd.iniEntries.end(); it++ )
+    {
+      Preferences::getInstance()->setString( it->section, it->key, it->value, true);
+    }
+  }
+  else
+  {
+    exit(EXIT_FAILURE);
+  }
+  
+  return true;
+}
+
+bool CmdLinePrefsReader::registerArgument( const char shortOption, const std::string & longOption, const std::string & section, const std::string & key, const std::string & help, const std::string & argName, const std::string & value )
+{
+  RegistredArgument arg;
+  
+  arg.longOption = longOption;
+  arg.shortOption = shortOption;
+  arg.value = value;
+  arg.help = help;
+  arg.argName = argName;
+  arg.section = section;
+  arg.key = key;
+  
+  regArgs.push_back( arg );
+}
+
+
Index: /trunk/src/lib/parser/preferences/cmd_line_prefs_reader.h
===================================================================
--- /trunk/src/lib/parser/preferences/cmd_line_prefs_reader.h	(revision 7256)
+++ /trunk/src/lib/parser/preferences/cmd_line_prefs_reader.h	(revision 7256)
@@ -0,0 +1,72 @@
+/*!
+ * @file proto_class.h
+ * @brief Definition of CmdLinePrefsReader
+*/
+
+#ifndef _CMD_LINE_PREFS_READER_H
+#define _CMD_LINE_PREFS_READER_H
+
+#include "stdincl.h"
+#include "debug.h"
+
+#include "src/lib/parser/cmdline_parser/cmdline_parser.h"
+
+struct IniEntry
+{
+  std::string section;
+  std::string key;
+  std::string value;
+};
+
+struct CallbackData
+{
+  std::list<IniEntry> iniEntries;
+  CmdLineParser * parser;
+};
+
+struct RegistredArgument
+{
+  char shortOption;
+  std::string longOption;
+  std::string value;
+  std::string help;
+  std::string argName;
+  std::string section;
+  std::string key;
+};
+
+typedef std::vector<RegistredArgument> RegistredArgs;
+
+enum
+{
+  ID_SET_INI = 1,
+  ID_HELP,
+  ID_PREFS
+};
+
+#define REGISTER_ARG_FLAG(shortOption,longOption,section,key,description,value) bool _ARGVAR_##shortOption##_##longOption = CmdLinePrefsReader::registerArgument(#shortOption[0],#longOption,section,key,description,"",value) 
+
+#define REGISTER_ARG_ARG(shortOption,longOption,section,key,description,argname) bool _ARGVAR_##shortOption##_##longOption = CmdLinePrefsReader::registerArgument(#shortOption[0],#longOption,section,key,description,argname) 
+
+//! A class for reading commandline arguments into Preferences
+class CmdLinePrefsReader 
+{
+
+ public:
+   CmdLinePrefsReader();
+   virtual ~CmdLinePrefsReader();
+
+    bool parse(int argc, char** argv);
+    
+    static bool registerArgument( const char shortOption, const std::string & longOption, const std::string & section, const std::string & key, const std::string & help,  const std::string & argName = "", const std::string & value = "%arg%" );
+    
+    static bool asdf;
+    
+  private:
+    static bool callBack( ArgTableEntry entry, void* data, const std::string & arg, const std::vector<MultiType> & argArgs );
+    
+    static RegistredArgs regArgs;
+
+};
+
+#endif /* _PROTO_CLASS_H */
Index: /trunk/src/lib/parser/preferences/ini_file_prefs_reader.cc
===================================================================
--- /trunk/src/lib/parser/preferences/ini_file_prefs_reader.cc	(revision 7256)
+++ /trunk/src/lib/parser/preferences/ini_file_prefs_reader.cc	(revision 7256)
@@ -0,0 +1,63 @@
+/*
+   orxonox - the future of 3D-vertical-scrollers
+
+   Copyright (C) 2004 orx
+
+   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, or (at your option)
+   any later version.
+
+   ### File Specific:
+   main-programmer: Christoph Renner
+   co-programmer: ...
+*/
+
+//#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_
+
+#include "ini_file_prefs_reader.h"
+
+using namespace std;
+
+
+/**
+ * standard constructor
+*/
+IniFilePrefsReader::IniFilePrefsReader ( const std::string& fileName )
+{
+  IniParser iniParser;
+
+  if ( !iniParser.readFile( fileName ) )
+    return;
+
+  Preferences* prefs = Preferences::getInstance();
+
+  iniParser.firstSection();
+
+  do
+  {
+    do
+    {
+      prefs->setString( iniParser.getCurrentSection(), iniParser.getCurrentName(), iniParser.getCurrentValue(), true );
+    } while (iniParser.nextVar());
+  } while ( iniParser.nextSection() != "" );
+
+  /*iniParser.firstVar();
+
+  Preferences* prefs = Preferences::getInstance();
+
+  while ( iniParser.nextVar() )
+  {
+    prefs->setString( iniParser.getCurrentSection(), iniParser.getCurrentName(), iniParser.getCurrentValue(), true );
+}*/
+}
+
+
+/**
+ * standard deconstructor
+*/
+IniFilePrefsReader::~IniFilePrefsReader ()
+{
+}
+
+
Index: /trunk/src/lib/parser/preferences/ini_file_prefs_reader.h
===================================================================
--- /trunk/src/lib/parser/preferences/ini_file_prefs_reader.h	(revision 7256)
+++ /trunk/src/lib/parser/preferences/ini_file_prefs_reader.h	(revision 7256)
@@ -0,0 +1,23 @@
+/*!
+ * @file ini_file_prefs_reader.h
+ * @brief Definition of IniFilePrefsReader
+*/
+
+#ifndef _INI_FILE_PREFS_READER_H
+#define _INI_FILE_PREFS_READER_H
+
+#include "src/lib/parser/ini_parser/ini_parser.h"
+#include "src/lib/util/preferences.h"
+
+
+//! A class for reading inifiles into Preferences
+class IniFilePrefsReader {
+
+ public:
+   IniFilePrefsReader(const std::string& fileName);
+   virtual ~IniFilePrefsReader();
+
+
+};
+
+#endif /* _INI_FILE_PREFS_READER_H */
Index: /trunk/src/lib/sound/sound_engine.cc
===================================================================
--- /trunk/src/lib/sound/sound_engine.cc	(revision 7255)
+++ /trunk/src/lib/sound/sound_engine.cc	(revision 7256)
@@ -26,5 +26,5 @@
 #include "util/loading/resource_manager.h"
 #include "debug.h"
-#include "parser/ini_parser/ini_parser.h"
+#include "util/preferences.h"
 #include "globals.h"
 
@@ -95,15 +95,14 @@
 /**
  * loads the settings of the SoundEngine from an ini-file
- * @param iniParser the IniParser of the inifile
  */
-void SoundEngine::loadSettings(IniParser* iniParser)
-{
-  MultiType channels = iniParser->getVar(CONFIG_NAME_AUDIO_CHANNELS, CONFIG_SECTION_AUDIO, "32");
+void SoundEngine::loadSettings()
+{
+  MultiType channels = Preferences::getInstance()->getString(CONFIG_SECTION_AUDIO, CONFIG_NAME_AUDIO_CHANNELS, "32");
   this->maxSourceCount = channels.getInt();
 
-  MultiType effectsVolume = iniParser->getVar(CONFIG_NAME_EFFECTS_VOLUME, CONFIG_SECTION_AUDIO, "80");
+  MultiType effectsVolume = Preferences::getInstance()->getString(CONFIG_SECTION_AUDIO, CONFIG_NAME_EFFECTS_VOLUME, "80");
   this->effectsVolume = effectsVolume.getFloat()/100.0;
 
-  MultiType musicVolume = iniParser->getVar(CONFIG_NAME_MUSIC_VOLUME, CONFIG_SECTION_AUDIO, "75");
+  MultiType musicVolume = Preferences::getInstance()->getString(CONFIG_SECTION_AUDIO, CONFIG_NAME_MUSIC_VOLUME, "75");
   this->musicVolume = musicVolume.getFloat()/100.0;
 }
Index: /trunk/src/lib/sound/sound_engine.h
===================================================================
--- /trunk/src/lib/sound/sound_engine.h	(revision 7255)
+++ /trunk/src/lib/sound/sound_engine.h	(revision 7256)
@@ -31,5 +31,5 @@
     inline static SoundEngine* getInstance() { if (!SoundEngine::singletonRef) SoundEngine::singletonRef = new SoundEngine();  return SoundEngine::singletonRef; };
 
-    void loadSettings(IniParser* iniParser);
+    void loadSettings();
 
     SoundSource* createSource(const std::string& fileName, PNode* sourceNode = NULL);
Index: /trunk/src/lib/util/preferences.cc
===================================================================
--- /trunk/src/lib/util/preferences.cc	(revision 7256)
+++ /trunk/src/lib/util/preferences.cc	(revision 7256)
@@ -0,0 +1,337 @@
+/*
+   orxonox - the future of 3D-vertical-scrollers
+
+   Copyright (C) 2004 orx
+
+   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, or (at your option)
+   any later version.
+
+   ### File Specific:
+   main-programmer: Christoph Renner
+   co-programmer: ...
+*/
+
+//#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY
+
+#include "preferences.h"
+
+using namespace std;
+
+
+/**
+ * standard constructor
+ */
+Preferences::Preferences ()
+{
+   this->setClassID(CL_PREFERENCES, "Preferences");
+   this->setName("Preferences");
+   this->fileName = "";
+}
+
+/**
+ *  the singleton reference to this class
+ */
+Preferences* Preferences::singletonRef = NULL;
+
+/**
+   @brief standard deconstructor
+ */
+Preferences::~Preferences ()
+{
+  Preferences::singletonRef = NULL;
+}
+
+/**
+ * Check if this item exists
+ * @param section name of the section
+ * @param name name of the item to check
+ * @return true if the item exists
+ */
+bool Preferences::exists( const std::string& section, const std::string& name)
+{
+  std::list<prefSection>::const_iterator it = data.begin();
+
+  for ( ; it!=data.end(); it++)
+  {
+    if ( it->sectionName == section )
+    {
+      std::list<prefItem>::const_iterator it2 = it->items.begin();
+
+      for ( ; it2!=it->items.end(); it2++)
+      {
+        if ( it2->name == name )
+          return true;
+      }
+
+      break;
+    }
+  }
+
+  return false;
+}
+
+/**
+ * Check if this section exists
+ * @param section name of the section
+ * @param name name of the item to check
+ * @return true if the item exists
+ */
+bool Preferences::sectionExists( const std::string& section )
+{
+  std::list<prefSection>::const_iterator it = data.begin();
+
+  for ( ; it!=data.end(); it++)
+  {
+    if ( it->sectionName == section )
+    {
+      return true;
+    }
+  }
+
+  return false;
+}
+
+/**
+ * Sets the value of an item. Creates it if doesn't exits.
+ * @param section name of the section
+ * @param name name of the item
+ * @param value value
+ */
+void Preferences::setString(const std::string& section, const std::string& name, const std::string& value, bool dontSetModified)
+{
+  MultiType t(value);
+  setMultiType(section, name, t, dontSetModified);
+}
+
+/**
+ * Sets the value of an item. Creates it if doesn't exits.
+ * @param section name of the section
+ * @param name name of the item
+ * @param value value
+ */
+void Preferences::setInt(const std::string& section, const std::string& name, int value, bool dontSetModified)
+{
+  MultiType t(value);
+  setMultiType(section, name, t, dontSetModified);
+}
+
+/**
+ * Sets the value of an item. Creates it if doesn't exits.
+ * @param section name of the section
+ * @param name name of the item
+ * @param value value
+ */
+void Preferences::setFloat(const std::string& section, const std::string& name, float value, bool dontSetModified)
+{
+  MultiType t(value);
+  setMultiType(section, name, t, dontSetModified);
+}
+
+/**
+ * Get the value of an item
+ * @param section name of the section
+ * @param name name of the item to check
+ * @param defaultValue value to return if item doesn't exist
+ * @return value of the item if found. defaultValue else
+ */
+const std::string Preferences::getString(const std::string& section, const std::string& name, const std::string& defaultValue)
+{
+  return getMultiType(section, name, MultiType(defaultValue)).getString();
+}
+
+/**
+ * Get the value of an item
+ * @param section name of the section
+ * @param name name of the item to check
+ * @param defaultValue value to return if item doesn't exist
+ * @return value of the item if found. defaultValue else
+ */
+int Preferences::getInt(const std::string& section, const std::string& name, int defaultValue)
+{
+  return getMultiType(section, name, MultiType(defaultValue)).getInt();
+}
+
+/**
+ * Get the value of an item
+ * @param section name of the section
+ * @param name name of the item to check
+ * @param defaultValue value to return if item doesn't exist
+ * @return value of the item if found. defaultValue else
+ */
+float Preferences::getFloat(const std::string& section, const std::string& name, float defaultValue)
+{
+  return getMultiType(section, name, MultiType(defaultValue)).getFloat();
+}
+
+/**
+ * Sets the value of an item. Creates it if doesn't exits.
+ * @param section name of the section
+ * @param name name of the item
+ * @param value value
+ */
+void Preferences::setMultiType(const std::string& section, const std::string& name, const MultiType& value, bool dontSetModified)
+{
+  std::list<prefSection>::iterator it = data.begin();
+
+  for ( ; it!=data.end(); it++)
+  {
+    if ( it->sectionName == section )
+    {
+      std::list<prefItem>::iterator it2 = it->items.begin();
+
+      for ( ; it2!=it->items.end(); it2++)
+      {
+        if ( it2->name == name )
+        {
+          if (!dontSetModified)
+            it2->modified = value.getString() != it2->value.getString();
+
+          it2->value = value;
+
+          return;
+        }
+      }
+      prefItem item;
+      item.value = value;
+      item.modified = !dontSetModified;
+      item.name = name;
+      it->items.push_back(item);
+      return;
+    }
+  }
+
+  prefItem item;
+  item.value = value;
+  item.modified = !dontSetModified;
+  item.name = name;
+
+  prefSection sec;
+  sec.items.push_back(item);
+  sec.sectionName = section;
+  data.push_back( sec );
+}
+
+/**
+ * Get the value of an item
+ * @param section name of the section
+ * @param name name of the item to check
+ * @param defaultValue value to return if item doesn't exist
+ * @return value of the item if found. defaultValue else
+ */
+MultiType Preferences::getMultiType(const std::string& section, const std::string& name,const MultiType& defaultValue)
+{
+  std::list<prefSection>::const_iterator it = data.begin();
+
+  for ( ; it!=data.end(); it++)
+  {
+    if ( it->sectionName == section )
+    {
+      std::list<prefItem>::const_iterator it2 = it->items.begin();
+
+      for ( ; it2!=it->items.end(); it2++)
+      {
+        if ( it2->name == name )
+        {
+          return it2->value;
+        }
+      }
+
+      break;
+    }
+  }
+
+  return defaultValue;
+}
+
+void Preferences::setUserIni(const std::string& fileName)
+{
+  this->fileName = fileName;
+}
+
+bool Preferences::save()
+{
+  if ( this->fileName == "" )
+  {
+    PRINTF(1)("You must call setUserIni before you can call save()\n");
+    return false;
+  }
+  IniParser iniParser(this->fileName);
+
+  if ( !iniParser.isOpen() )
+    return false;
+
+  std::list<prefSection>::iterator it = data.begin();
+  bool didChanges = false;
+  for ( ; it!=data.end(); it++)
+  {
+    std::list<prefItem>::iterator it2 = it->items.begin();
+
+    for ( ; it2!=it->items.end(); it2++)
+    {
+      if ( it2->modified )
+      {
+        iniParser.editVar(it2->name, it2->value.getString(), it->sectionName);
+        didChanges = true;
+      }
+    }
+  }
+
+  if ( didChanges )
+  {
+    iniParser.writeFile( this->fileName );
+  }
+
+  return true;
+}
+
+/**
+ * prints out all section with its items and values
+ */
+void Preferences::debug()
+{
+  std::list<prefSection>::iterator it = data.begin();
+
+  for ( ; it!=data.end(); it++)
+  {
+    PRINTF(0)("%s\n", it->sectionName.c_str());
+    std::list<prefItem>::iterator it2 = it->items.begin();
+
+    for ( ; it2!=it->items.end(); it2++)
+    {
+      PRINTF(0)("--> %s = '%s'%s\n", it2->name.c_str(), it2->value.getString().c_str(), ((!it2->modified)?"":" <modified>"));
+    }
+  }
+}
+
+/**
+ * list all keys in section
+ * @param section section
+ * @return list of keys
+ */
+std::list< std::string > Preferences::listKeys( const std::string section )
+{
+  std::list<std::string> lst;
+  
+  std::list<prefSection>::const_iterator it = data.begin();
+
+  for ( ; it!=data.end(); it++)
+  {
+    if ( it->sectionName == section )
+    {
+      std::list<prefItem>::const_iterator it2 = it->items.begin();
+
+      for ( ; it2!=it->items.end(); it2++)
+      {
+        lst.push_back( it2->name );
+      }
+
+      break;
+    }
+  }
+
+  return lst;
+}
+
+
Index: /trunk/src/lib/util/preferences.h
===================================================================
--- /trunk/src/lib/util/preferences.h	(revision 7256)
+++ /trunk/src/lib/util/preferences.h	(revision 7256)
@@ -0,0 +1,72 @@
+/*!
+ * @file proto_singleton.h
+ * @brief Definition of the ... singleton Class
+*/
+
+#ifndef _PREFERENCES_H
+#define _PREFERENCES_H
+
+#include "base_object.h"
+#include "multi_type.h"
+#include "lib/parser/ini_parser/ini_parser.h"
+
+// FORWARD DECLARATION
+
+class IniFilePrefsReader;
+
+typedef struct {
+  std::string name;
+  MultiType value;
+  bool modified;
+} prefItem;
+
+typedef struct {
+  std::string sectionName;
+  std::list<prefItem> items;
+} prefSection ;
+
+
+//! A default singleton class.
+class Preferences : public BaseObject {
+
+ public:
+   virtual ~Preferences(void);
+  /** @returns a Pointer to the only object of this Class */
+   inline static Preferences* getInstance(void) { if (!singletonRef) singletonRef = new Preferences();  return singletonRef; };
+
+   //check if this entry exists
+   bool sectionExists(const std::string& section );
+   bool exists(const std::string& section, const std::string& name);
+
+   void setString(const std::string& section, const std::string& name, const std::string& value, bool dontSetModified = false);
+   void setInt(const std::string& section, const std::string& name, int value, bool dontSetModified = false);
+   void setFloat(const std::string& section, const std::string& name, float value, bool dontSetModified = false);
+   void setMultiType(const std::string& section, const std::string& name, const MultiType& value, bool dontSetModified = false);
+
+   const std::string getString(const std::string& section, const std::string& name, const std::string& defaultValue);
+   int getInt(const std::string& section, const std::string& name, int defaultValue);
+   float getFloat(const std::string& section, const std::string& name, float defaultValue);
+   MultiType getMultiType(const std::string& section, const std::string& name, const MultiType& defaultValue);
+
+   void setUserIni(const std::string& fileName);
+
+   bool save();
+
+   void debug();
+   
+   std::list<std::string> listKeys( const std::string section );
+
+
+ private:
+   Preferences(void);
+   static Preferences* singletonRef;
+
+   std::list<prefSection> data;
+
+   std::list<IniFilePrefsReader*> iniFilePrefsReaders;
+
+   std::string fileName;
+
+};
+
+#endif /* _PREFERENCES_H */
Index: /trunk/src/orxonox.cc
===================================================================
--- /trunk/src/orxonox.cc	(revision 7255)
+++ /trunk/src/orxonox.cc	(revision 7256)
@@ -58,5 +58,6 @@
 
 #include "state.h"
-
+#include "lib/parser/preferences/cmd_line_prefs_reader.h"
+#include "lib/parser/preferences/ini_file_prefs_reader.h"
 #include <string.h>
 
@@ -66,4 +67,11 @@
 
 SHELL_COMMAND(restart, Orxonox, restart);
+
+REGISTER_ARG_FLAG( l, license, "misc", "showLicenseAndExit", "Prints the licence and exit",    "1" );
+REGISTER_ARG_FLAG( c, client,  "game", "gameType",           "Connect to Server (-H)",         "multiplayer_client" );
+REGISTER_ARG_FLAG( s, server,  "game", "gameType",           "Start Orxonox as Game Server",   "multiplayer_server" );
+REGISTER_ARG_ARG(  H, host,    "game", "host",               "Host to connect to",             "host");
+REGISTER_ARG_ARG(  p, port,    "game", "port",               "Port to use",                    "port" );
+REGISTER_ARG_FLAG( g, gui,     "game", "showGui",            "starts the orxonox with the configuration GUI", "1");
 
 /**
@@ -77,11 +85,9 @@
   this->setName("orxonox-main");
 
-  this->iniParser = NULL;
-
   this->argc = 0;
   this->argv = NULL;
 
   /* this way, there is no network enabled: */
-  this->serverName = NULL;
+  this->serverName = "";
   this->port = -1;
 
@@ -114,7 +120,4 @@
   // output-buffer
   delete ShellBuffer::getInstance();
-
-  // orxonox class-stuff
-  delete this->iniParser;
 
   SDL_QuitSubSystem(SDL_INIT_TIMER);
@@ -175,5 +178,5 @@
   else
     this->configFileName = ResourceManager::homeDirCheck(DEFAULT_CONFIG_FILE);
-  this->iniParser = new IniParser(this->configFileName);
+
   PRINTF(3)("Parsed Config File: '%s'\n", this->configFileName);
 }
@@ -182,5 +185,5 @@
  * initialize Orxonox with command line
  */
-int Orxonox::init (int argc, char** argv, const char* name, int port)
+int Orxonox::init (int argc, char** argv, const std::string & name, int port)
 {
   this->argc = argc;
@@ -227,5 +230,5 @@
   GraphicsEngine::getInstance();
 
-  GraphicsEngine::getInstance()->initFromIniFile(this->iniParser);
+  GraphicsEngine::getInstance()->initFromPreferences();
 
   std::string iconName = ResourceManager::getFullName("pictures/fighter-top-32x32.bmp");
@@ -247,5 +250,5 @@
   SoundEngine::getInstance();
 
-  SoundEngine::getInstance()->loadSettings(this->iniParser);
+  SoundEngine::getInstance()->loadSettings();
   SoundEngine::getInstance()->initAudio();
   return 0;
@@ -260,5 +263,5 @@
   PRINT(3)("> Initializing input\n");
 
-  EventHandler::getInstance()->init(this->iniParser);
+  EventHandler::getInstance()->init();
   EventHandler::getInstance()->subscribe(GraphicsEngine::getInstance(), ES_ALL, EV_VIDEO_RESIZE);
 
@@ -274,5 +277,5 @@
   PRINT(3)("> Initializing networking\n");
 
-  if( this->serverName != NULL) // we are a client
+  if( this->serverName != "") // we are a client
   {
     State::setOnline(true);
@@ -299,5 +302,5 @@
   // init the resource manager
   std::string dataPath;
-  if ((dataPath = this->iniParser->getVar(CONFIG_NAME_DATADIR, CONFIG_SECTION_DATA))!= "")
+  if ((dataPath = Preferences::getInstance()->getString(CONFIG_SECTION_DATA, CONFIG_NAME_DATADIR, ""))!= "")
   {
     if (!ResourceManager::getInstance()->setDataDir(dataPath) &&
@@ -403,49 +406,25 @@
 int main(int argc, char** argv)
 {
-  int i;
-  for(i = 1; i < argc; ++i)
-  {
-    if(     !strcmp( "--help", argv[i])     || !strcmp("-h", argv[i]))
-      return showHelp(argc, argv);
-    else if(!strcmp( "--gui", argv[i])      || !strcmp("-g", argv[i]))
-      showGui = true;
-    else if(!strcmp( "--client", argv[i])   || !strcmp("-c", argv[i]))
-      return startNetworkOrxonox(argc, argv);
-    else if(!strcmp( "--server", argv[i])   || !strcmp("-s", argv[i]))
-      return startNetworkOrxonox(argc, argv);
-    else if(!strcmp( "--license", argv[i])  || !strcmp("-l", argv[i]))
-      return PRINT(0)(ORXONOX_LICENSE_SHORT);
-  }
-
-  return startOrxonox(argc, argv, NULL, -1);
-}
-
-
-
-int showHelp(int argc, char** argv)
-{
-  PRINT(0)("Orxonox Version %s\n", PACKAGE_VERSION);
-  PRINT(0)(" Starts Orxonox - The most furious 3D Action Game :)\n");
-  PRINT(0)("\n");
-  PRINT(0)("Common options:\n");
-  PRINT(0)(" -g, --gui                        starts the orxonox with the configuration GUI \n");
-  PRINT(0)(" -h, --help                       shows this help\n");
-  PRINT(0)("\n");
-  PRINT(0)("Network options:\n");
-  PRINT(0)(" -s, --server [port]              starts Orxonox and listens on the [port] for players\n");
-  PRINT(0)(" -c, --client [hostname] [port]   starts Orxonox as a Client\n");
-  PRINT(0)(" -c, --client [ip address] [port] starts Orxonox as a Client\n");
-  PRINT(0)("\n");
-  PRINT(0)("Other options:\n");
-  PRINT(0)("     --license     prints the licence and exit\n\n");
-  PRINT(0)("\n");
-
-  //   {
-  //     Gui* gui = new Gui(argc, argv);
-  //     gui->printHelp();
-  //     delete gui;
-  //   }
-}
-
+  CmdLinePrefsReader prefs;
+  
+  IniFilePrefsReader ini(ResourceManager::homeDirCheck(DEFAULT_CONFIG_FILE));
+  
+  prefs.parse(argc, argv);
+  
+  if ( Preferences::getInstance()->getString("misc", "showLicenseAndExit", "") == "1" )
+  {
+    PRINT(0)(ORXONOX_LICENSE_SHORT);
+    return 0;
+  }
+  
+  if( Preferences::getInstance()->getString("game", "showGui", "") == "1" )
+    showGui = true;
+  else if( Preferences::getInstance()->getString( "game", "gameType", "" ) == "multiplayer_server" ||
+           Preferences::getInstance()->getString( "game", "gameType", "" ) == "multiplayer_client" )
+    return startNetworkOrxonox(argc, argv);
+  
+  return startOrxonox(argc, argv, "", -1);
+  return 0;
+}
 
 
@@ -459,37 +438,28 @@
 {
 
-  int i;
-  for(i = 0; i < argc; ++i )
-  {
-    if( !strcmp( "--client", argv[i]) || !strcmp("-c", argv[i]))
+  std::string gameType = Preferences::getInstance()->getString( "game", "gameType", "" );
+  
+  if ( gameType == "multiplayer_client" )
+  {
+    int port = Preferences::getInstance()->getInt( "game", "port", DEFAULT_ORXONOX_PORT );
+    std::string host = Preferences::getInstance()->getString( "game", "host", "" );
+    
+    if ( host == "" )
     {
-      if( argc <= (i+2))
-      {
-        printf(" Wrong arguments try following notations:\n");
-        printf("   --client [server ip address] [port number]\n");
-        printf("   --client [dns name] [port number]\n");
-        return 0;
-      }
-
-      const char* name = argv[i+1];
-      int port = atoi(argv[i+2]);
-      printf("Starting Orxonox as client: connecting to %s, on port %i\n", name, port);
-
-      startOrxonox(argc, argv, name, port);
+      printf("You need to specify a host to connect to ( -H <host> )\n");
+      return 1;
     }
-    else if( !strcmp( "--server", argv[i]) || !strcmp("-s", argv[i]))
-    {
-      if( argc <= (i+1))
-      {
-        printf(" Wrong arguments try following notations:\n");
-        printf("   --server [port number]\n");
-        return 0;
-      }
-
-      int port = atoi(argv[i+1]);
-      printf("Starting Orxonox as server, listening on port %i\n", port);
-
-      startOrxonox(argc, argv, NULL, port);
-    }
+    
+    printf("Starting Orxonox as client: connecting to %s, on port %i\n", host.c_str(), port);
+    
+    startOrxonox(argc, argv, host.c_str(), port);
+  }
+  else if ( gameType == "multiplayer_server" )
+  {
+    int port = Preferences::getInstance()->getInt( "game", "port", DEFAULT_ORXONOX_PORT );
+    
+    printf("Starting Orxonox as server: listening on port %i\n", port);
+    
+    startOrxonox(argc, argv, "", port);
   }
 }
@@ -502,5 +472,5 @@
  * @param argv parameters given to orxonox
  */
-int startOrxonox(int argc, char** argv, const char* name, int port)
+int startOrxonox(int argc, char** argv, const std::string & name, int port)
 {
   // checking for existence of the configuration-files, or if the lock file is still used
Index: /trunk/src/orxonox.h
===================================================================
--- /trunk/src/orxonox.h	(revision 7255)
+++ /trunk/src/orxonox.h	(revision 7256)
@@ -11,5 +11,4 @@
 class WorldEntity;
 class GameLoader;
-class IniParser;
 
 //! orxonox core singleton class
@@ -23,5 +22,5 @@
   inline static Orxonox* getInstance() { if (!singletonRef) singletonRef = new Orxonox();  return singletonRef; };
 
-  int init(int argc, char** argv, const char* name, int port);
+  int init(int argc, char** argv, const std::string & name, int port);
 
   void restart();
@@ -31,6 +30,4 @@
  private:
   Orxonox ();
-
-  void parseIniFile(const std::string& fileName);
 
   int initResources ();
@@ -46,5 +43,4 @@
   static Orxonox*   singletonRef;            //!< singleton reference to orxonox
 
-  IniParser*        iniParser;               //!< Reference to the ini-parser used in orxonox
   std::string       configFileName;          //!< Filename of the configuration-file.
   GameLoader*       gameLoader;              //!< The gameLoader
@@ -53,5 +49,5 @@
   char**            argv;                    //!< Values of th Arguments of orxonox.
 
-  const char*       serverName;              //!< Name of the Orxonox client if == NULL -> server
+  std::string       serverName;              //!< Name of the Orxonox client if == "" -> server
   int               port;                    //!< number of the network port of the server/client if == -1 no network
 };
@@ -61,8 +57,7 @@
 // Start-up functions //
 ////////////////////////
-int showHelp(int argc, char** argv);
-int showLicense();
+
 int startNetworkOrxonox(int argc, char** argv);
-int startOrxonox(int argc, char** argv, const char* clientName, int port);
+int startOrxonox(int argc, char** argv, const std::string & clientName, int port);
 
 #endif /* _ORXONOX_H */
Index: /trunk/src/subprojects/framework.cc
===================================================================
--- /trunk/src/subprojects/framework.cc	(revision 7255)
+++ /trunk/src/subprojects/framework.cc	(revision 7256)
@@ -23,5 +23,5 @@
 #include "util/loading/resource_manager.h"
 #include "camera.h"
-#include "parser/ini_parser/ini_parser.h"
+#include "util/preferences.h"
 #include "globals.h"
 
@@ -30,16 +30,10 @@
 void Framework::init(void)
 {
-  // create parser
-  char* configFileName = ResourceManager::homeDirCheck(DEFAULT_CONFIG_FILE);
-
-  IniParser iniParser (configFileName);
-  delete configFileName;
-
-  GraphicsEngine::getInstance()->initFromIniFile(&iniParser);
+  GraphicsEngine::getInstance()->initFromPreferences();
 
   LightManager::getInstance();
 
   const char* dataPath;
-  if ((dataPath = iniParser.getVar(CONFIG_NAME_DATADIR, CONFIG_SECTION_DATA))!= NULL)
+  if ((dataPath = Preferences::getInstance()->getString(CONFIG_SECTION_DATA, CONFIG_NAME_DATADIR, ""))!= NULL)
   {
     if (!ResourceManager::getInstance()->setDataDir(dataPath))
