Index: branches/preferences/src/defs/class_id.h
===================================================================
--- branches/preferences/src/defs/class_id.h	(revision 7233)
+++ branches/preferences/src/defs/class_id.h	(revision 7234)
@@ -96,4 +96,5 @@
   CL_MASK_LOWLEVEL_CLASS        =    0x00000fff,
 
+  CL_PREFERENCES                =    0X00000f51,
 
   /// SINGLETON classes (range from 0x00000000 to 0x000000ff)
Index: branches/preferences/src/lib/parser/Makefile.am
===================================================================
--- branches/preferences/src/lib/parser/Makefile.am	(revision 7233)
+++ branches/preferences/src/lib/parser/Makefile.am	(revision 7234)
@@ -1,5 +1,6 @@
 SUBDIRS = \
           tinyxml \
-	  ini_parser
+	  			ini_parser \
+	  			preferences
 
 
Index: branches/preferences/src/lib/parser/ini_parser/ini_parser.cc
===================================================================
--- branches/preferences/src/lib/parser/ini_parser/ini_parser.cc	(revision 7233)
+++ branches/preferences/src/lib/parser/ini_parser/ini_parser.cc	(revision 7234)
@@ -392,4 +392,77 @@
 }
 
+/**
+ * @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 char* entryName, const char* value, const char* sectionName)
+{
+  std::list<IniSection>::iterator section;
+
+  if (sectionName != NULL)
+  {
+    for (section = this->sections.begin(); section != this->sections.end(); section++)
+      if (!strcmp((*section).name, sectionName))
+        break;
+  }
+  else
+    section = this->currentSection;
+
+  if (section == this->sections.end())
+  {
+    IniSection sec;
+    sec.comment = NULL;
+    sec.name = new char[strlen(sectionName)+1];
+    strcpy(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, entryName);
+    return false;
+  }
+  else
+  {
+    //try find item
+    std::list<IniEntry>::iterator entry;
+    for (entry = section->entries.begin(); entry!=section->entries.end(); entry++)
+      if (!strcmp( entry->name, entryName ))
+        break;
+
+    //found it?
+    if ( entry != section->entries.end() )
+    {
+      if ( entry->value != NULL )
+      {
+        delete[] entry->value;
+      }
+      entry->value = new char[strlen(value)+1];
+      strcpy(entry->value, value);
+
+      return true;
+    }
+
+    //not found -> create it
+    (*section).entries.push_back(IniEntry());
+    (*section).entries.back().comment = NULL;
+    (*section).entries.back().name = new char[strlen(entryName)+1];
+    strcpy((*section).entries.back().name, entryName);
+    (*section).entries.back().value = new char[strlen(value)+1];
+    strcpy((*section).entries.back().value, value);
+    PRINTF(5)("Added Entry %s with Value '%s' to Section %s\n",
+    (*section).entries.back().name,
+    (*section).entries.back().value,
+    (*section).name);
+    this->currentEntry = --(*section).entries.end();
+    return true;
+  }
+}
+
 
 /**
Index: branches/preferences/src/lib/parser/preferences/Makefile.am
===================================================================
--- branches/preferences/src/lib/parser/preferences/Makefile.am	(revision 7234)
+++ branches/preferences/src/lib/parser/preferences/Makefile.am	(revision 7234)
@@ -0,0 +1,16 @@
+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: branches/preferences/src/lib/parser/preferences/cmd_line_prefs_reader.cc
===================================================================
--- branches/preferences/src/lib/parser/preferences/cmd_line_prefs_reader.cc	(revision 7234)
+++ branches/preferences/src/lib/parser/preferences/cmd_line_prefs_reader.cc	(revision 7234)
@@ -0,0 +1,38 @@
+/*
+   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"
+
+using namespace std;
+
+/**
+ * standard constructor
+*/
+CmdLinePrefsReader::CmdLinePrefsReader(int argc, char** argv)
+{
+
+}
+
+
+/**
+ * standard deconstructor
+*/
+CmdLinePrefsReader::~CmdLinePrefsReader ()
+{
+}
+
+
Index: branches/preferences/src/lib/parser/preferences/cmd_line_prefs_reader.h
===================================================================
--- branches/preferences/src/lib/parser/preferences/cmd_line_prefs_reader.h	(revision 7234)
+++ branches/preferences/src/lib/parser/preferences/cmd_line_prefs_reader.h	(revision 7234)
@@ -0,0 +1,22 @@
+/*!
+ * @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"
+
+//! A class for reading commandline arguments into Preferences
+class CmdLinePrefsReader {
+
+ public:
+   CmdLinePrefsReader(int argc, char** argv);
+   virtual ~CmdLinePrefsReader();
+
+
+};
+
+#endif /* _PROTO_CLASS_H */
Index: branches/preferences/src/lib/parser/preferences/ini_file_prefs_reader.cc
===================================================================
--- branches/preferences/src/lib/parser/preferences/ini_file_prefs_reader.cc	(revision 7234)
+++ branches/preferences/src/lib/parser/preferences/ini_file_prefs_reader.cc	(revision 7234)
@@ -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 char * 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()!=NULL);
+
+  /*iniParser.firstVar();
+
+  Preferences* prefs = Preferences::getInstance();
+
+  while ( iniParser.nextVar() )
+  {
+    prefs->setString( iniParser.getCurrentSection(), iniParser.getCurrentName(), iniParser.getCurrentValue(), true );
+}*/
+}
+
+
+/**
+ * standard deconstructor
+*/
+IniFilePrefsReader::~IniFilePrefsReader ()
+{
+}
+
+
Index: branches/preferences/src/lib/parser/preferences/ini_file_prefs_reader.h
===================================================================
--- branches/preferences/src/lib/parser/preferences/ini_file_prefs_reader.h	(revision 7234)
+++ branches/preferences/src/lib/parser/preferences/ini_file_prefs_reader.h	(revision 7234)
@@ -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 char* fileName);
+   virtual ~IniFilePrefsReader();
+
+
+};
+
+#endif /* _INI_FILE_PREFS_READER_H */
Index: branches/preferences/src/lib/util/preferences.cc
===================================================================
--- branches/preferences/src/lib/util/preferences.cc	(revision 7234)
+++ branches/preferences/src/lib/util/preferences.cc	(revision 7234)
@@ -0,0 +1,302 @@
+/*
+   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 = NULL;
+}
+
+/**
+ *  the singleton reference to this class
+ */
+Preferences* Preferences::singletonRef = NULL;
+
+/**
+   @brief standard deconstructor
+ */
+Preferences::~Preferences ()
+{
+  Preferences::singletonRef = NULL;
+
+  if ( this->fileName )
+  {
+    delete this->fileName;
+    this->fileName = 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 char* section, const char* name)
+{
+  std::list<prefSection>::const_iterator it = data.begin();
+
+  for ( ; it!=data.end(); it++)
+  {
+    if ( strcmp(it->sectionName, section) == 0 )
+    {
+      std::list<prefItem>::const_iterator it2 = it->items.begin();
+
+      for ( ; it2!=it->items.end(); it2++)
+      {
+        if ( strcmp(it2->name, name) == 0 )
+          return true;
+      }
+
+      break;
+    }
+  }
+
+  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 char* section, const char* name, const char* 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 char* section, const char* 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 char* section, const char* 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 char* Preferences::getString(const char* section, const char* name, const char* 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 char* section, const char* 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 char* section, const char* 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 char* section, const char* name, MultiType& value, bool dontSetModified)
+{
+  std::list<prefSection>::iterator it = data.begin();
+
+  for ( ; it!=data.end(); it++)
+  {
+    if ( strcmp(it->sectionName, section) == 0 )
+    {
+      std::list<prefItem>::iterator it2 = it->items.begin();
+
+      for ( ; it2!=it->items.end(); it2++)
+      {
+        if ( strcmp(it2->name, name) == 0 )
+        {
+          if (!dontSetModified)
+            it2->modified = strcmp(value.getString(), it2->value.getString())!=0;
+
+          it2->value = value;
+
+          return;
+        }
+      }
+      prefItem item;
+      item.value = value;
+      item.modified = !dontSetModified;
+      item.name = new char[strlen(name)+1];
+      strcpy( item.name, name );
+      it->items.push_back(item);
+      return;
+    }
+  }
+
+  prefItem item;
+  item.value = value;
+  item.modified = !dontSetModified;
+  item.name = new char[strlen(name)+1];
+  strcpy( item.name, name );
+
+  prefSection sec;
+  sec.items.push_back(item);
+  sec.sectionName = new char[strlen(section)+1];
+  strcpy( 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 char* section, const char* name,const MultiType& defaultValue)
+{
+  std::list<prefSection>::const_iterator it = data.begin();
+
+  for ( ; it!=data.end(); it++)
+  {
+    if ( strcmp(it->sectionName, section) == 0 )
+    {
+      std::list<prefItem>::const_iterator it2 = it->items.begin();
+
+      for ( ; it2!=it->items.end(); it2++)
+      {
+        if ( strcmp(it2->name, name) == 0 )
+        {
+          return it2->value;
+        }
+      }
+
+      break;
+    }
+  }
+
+  return defaultValue;
+}
+
+void Preferences::setUserIni(const char* fileName)
+{
+  if ( this->fileName != NULL )
+  {
+    delete this->fileName;
+  }
+
+  this->fileName = new char[strlen(fileName)+1];
+  strcpy(this->fileName, fileName);
+}
+
+bool Preferences::save()
+{
+  if ( this->fileName == NULL )
+  {
+    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);
+    std::list<prefItem>::iterator it2 = it->items.begin();
+
+    for ( ; it2!=it->items.end(); it2++)
+    {
+      PRINTF(0)("--> %s = '%s'%s\n", it2->name, it2->value.getString(), ((!it2->modified)?"":" <modified>"));
+    }
+  }
+}
+
+
Index: branches/preferences/src/lib/util/preferences.h
===================================================================
--- branches/preferences/src/lib/util/preferences.h	(revision 7234)
+++ branches/preferences/src/lib/util/preferences.h	(revision 7234)
@@ -0,0 +1,70 @@
+/*!
+ * @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 {
+  char* name;
+  MultiType value;
+  bool modified;
+} prefItem;
+
+typedef struct {
+  char* 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 exists(const char* section, const char* name);
+
+   void setString(const char* section, const char* name, const char* value, bool dontSetModified = false);
+   void setInt(const char* section, const char* name, int value, bool dontSetModified = false);
+   void setFloat(const char* section, const char* name, float value, bool dontSetModified = false);
+   void setMultiType(const char* section, const char* name, MultiType& value, bool dontSetModified = false);
+
+   const char* getString(const char* section, const char* name, const char* defaultValue);
+   int getInt(const char* section, const char* name, int defaultValue);
+   float getFloat(const char* section, const char* name, float defaultValue);
+   MultiType getMultiType(const char* section, const char* name, const MultiType& defaultValue);
+
+   void setUserIni(const char* fileName);
+
+   bool save();
+
+
+   void debug();
+
+
+ private:
+   Preferences(void);
+   static Preferences* singletonRef;
+
+   std::list<prefSection> data;
+
+   std::list<IniFilePrefsReader*> iniFilePrefsReaders;
+
+   char* fileName;
+
+};
+
+#endif /* _PREFERENCES_H */
Index: branches/preferences/src/orxonox.cc
===================================================================
--- branches/preferences/src/orxonox.cc	(revision 7233)
+++ branches/preferences/src/orxonox.cc	(revision 7234)
@@ -58,5 +58,5 @@
 
 #include "state.h"
-
+#include "lib/parser/preferences/cmd_line_prefs_reader.h"
 #include <string.h>
 
@@ -403,5 +403,7 @@
 int main(int argc, char** argv)
 {
-  int i;
+  CmdLinePrefsReader prefs(argc, argv);
+
+  /*int i;
   for(i = 1; i < argc; ++i)
   {
@@ -416,7 +418,8 @@
     else if(!strcmp( "--license", argv[i])  || !strcmp("-l", argv[i]))
       return PRINT(0)(ORXONOX_LICENSE_SHORT);
-  }
-
-  return startOrxonox(argc, argv, NULL, -1);
+}
+
+  return startOrxonox(argc, argv, NULL, -1);*/
+  return 0;
 }
 
