Index: orxonox/trunk/src/orxonox.cc
===================================================================
--- orxonox/trunk/src/orxonox.cc	(revision 4756)
+++ orxonox/trunk/src/orxonox.cc	(revision 4766)
@@ -43,4 +43,5 @@
 #include "cd_engine.h"
 
+#include "substring.h"
 #include "class_list.h"
 
@@ -59,9 +60,10 @@
 {
   this->setClassID(CL_ORXONOX, "Orxonox");
-  this->setName("orxonox");
+  this->setName("orxonox-main");
 
   this->resourceManager = NULL;
   this->objectManager = NULL;
   this->eventHandler = NULL;
+  this->iniParser = NULL;
 
   this->argc = 0;
@@ -74,6 +76,6 @@
 Orxonox::~Orxonox ()
 {
-  int i = 0;
-  Orxonox::singletonRef = NULL;
+  delete this->iniParser;
+
   delete GraphicsEngine::getInstance(); // deleting the Graphics
   delete TextEngine::getInstance();
@@ -84,31 +86,32 @@
   delete EventHandler::getInstance();
   delete Factory::getFirst();
+  delete SoundEngine::getInstance();
 
   ClassList::debug(0);
-}
-
-/** \brief this is a singleton class to prevent duplicates */
-Orxonox* Orxonox::singletonRef = 0;
-
-/**
-   \returns reference or new Object of Orxonox if not existent.
-*/
-Orxonox* Orxonox::getInstance ()
-{
-  if (singletonRef == NULL)
-    singletonRef = new Orxonox();
-  return singletonRef;
-}
-
-/**
-   \brief this finds the config file
-
-   Since the config file varies from user to user and since one may want to specify different config files
-   for certain occasions or platforms this function finds the right config file for every occasion and stores
-   it's path and name into configfilename
-*/
-void Orxonox::getConfigFile (int argc, char** argv)
-{
-  strcpy (configfilename, "~/.orxonox/orxonox.conf");
+
+  PRINT(3)("===================================================\n" \
+      "Thanks for playing orxonox.\n" \
+      "visit: http://www.orxonox.ethz.ch for new versions.\n" \
+      "===================================================\n");
+
+  Orxonox::singletonRef = NULL;
+}
+
+/**
+ * @brief this is a singleton class to prevent duplicates
+ */
+Orxonox* Orxonox::singletonRef = NULL;
+
+/**
+ * @brief this finds the config file
+ * @returns the new config-fileName
+ * Since the config file varies from user to user and since one may want to specify different config files
+ * for certain occasions or platforms this function finds the right config file for every occasion and stores
+ * it's path and name into configfilename
+*/
+const char* Orxonox::getConfigFile (int argc, char** argv)
+{
+  strcpy (this->configFileName, DEFAULT_CONFIG_FILE);
+  this->iniParser = new IniParser(this->configFileName);
 }
 
@@ -123,15 +126,14 @@
   // config file
 
-  getConfigFile (argc, argv);
+  // initialize the Config-file
+  this->getConfigFile(argc, argv);
+
+
   SDL_Init (SDL_INIT_TIMER);
   // initialize everything
-  printf("> Initializing resources\n");
   if( initResources () == -1) return -1;
-
   if( initVideo() == -1) return -1;
   if( initSound() == -1) return -1;
-  PRINT(3)("> Initializing input\n");
   if( initInput() == -1) return -1;
-  PRINT(3)("> Initializing networking\n");
   if( initNetworking () == -1) return -1;
   //printf("> Initializing world\n");
@@ -149,9 +151,15 @@
 
   GraphicsEngine::getInstance();
-  GraphicsEngine::getInstance()->setWindowName("orxonox " PACKAGE_VERSION, "orxonox " PACKAGE_VERSION);
-
-  return 0;
-}
-
+  GraphicsEngine::getInstance()->setWindowName(PACKAGE_NAME " " PACKAGE_VERSION, PACKAGE_NAME " " PACKAGE_VERSION);
+
+
+  SubString resolution(this->iniParser->getVar(CONFIG_NAME_RESOLUTION, CONFIG_SECTION_VIDEO, "640x480"), 'x');
+  GraphicsEngine::getInstance()->setResolution(atoi(resolution.getString(0)), atoi(resolution.getString(1)), 16);
+
+//  const char* fullscreen = this->iniParser->getVar(CONFIG_NAME_FULLSCREEN, CONFIG_SECTION_VIDEO, 0);
+//  GraphicsEngine::getInstance()->setFullscreen(false);
+
+  return 0;
+}
 
 /**
@@ -168,8 +176,10 @@
 
 /**
-   \brief initializes input functions
+ * @brief initializes input functions
 */
 int Orxonox::initInput()
 {
+  PRINT(3)("> Initializing input\n");
+
   this->eventHandler = EventHandler::getInstance();
   this->eventHandler->init();
@@ -180,75 +190,76 @@
 
 /**
-   \brief initializes network system
+* @brief initializes network system
 */
 int Orxonox::initNetworking()
 {
-  printf("Not yet implemented\n");
-  return 0;
-}
-
-
-/**
-   \brief initializes and loads resource files
-*/
-int Orxonox::initResources()
-{
-   PRINT(3)("initializing ResourceManager\n");
-   resourceManager = ResourceManager::getInstance();
+  PRINT(3)("> Initializing networking\n");
+
+  printf("  ---Not yet implemented-FIXME--\n");
+  return 0;
+}
+
+
+/**
+ * @brief initializes and loads resource files
+ */
+ int Orxonox::initResources()
+{
+  PRINTF(3)("> Initializing resources\n");
+
+  PRINT(3)("initializing ResourceManager\n");
+  resourceManager = ResourceManager::getInstance();
 
   // create parser
-   IniParser parser (DEFAULT_CONFIG_FILE);
-   if( parser.getSection (CONFIG_SECTION_DATA) == -1)
-   {
-     PRINTF(1)("Could not find Section %s in %s\n", CONFIG_SECTION_DATA, DEFAULT_CONFIG_FILE);
-     return -1;
-   }
-   char namebuf[256];
-   char valuebuf[256];
-   memset (namebuf, 0, 256);
-   memset (valuebuf, 0, 256);
-
-   while( parser.nextVar (namebuf, valuebuf) != -1)
-   {
-     if (!strcmp(namebuf, CONFIG_NAME_DATADIR))
-     {
+  if( this->iniParser->getSection (CONFIG_SECTION_DATA) == -1)
+  {
+    PRINTF(1)("Could not find Section %s in %s\n", CONFIG_SECTION_DATA, DEFAULT_CONFIG_FILE);
+    return -1;
+  }
+  char namebuf[256];
+  char valuebuf[256];
+  memset (namebuf, 0, 256);
+  memset (valuebuf, 0, 256);
+
+  while( this->iniParser->nextVar (namebuf, valuebuf) != -1)
+  {
+    if (!strcmp(namebuf, CONFIG_NAME_DATADIR))
+    {
           //  printf("Not yet implemented\n");
-       if (!resourceManager->setDataDir(valuebuf))
-       {
-         PRINTF(1)("Data Could not be located\n");
-         exit(-1);
-       }
-     }
-
-     memset (namebuf, 0, 256);
-     memset (valuebuf, 0, 256);
-   }
-
-   if (!resourceManager->checkDataDir(DEFAULT_DATA_DIR_CHECKFILE))
-   {
-     PRINTF(1)("The DataDirectory %s could not be verified\nPlease Change in File %s Section %s Entry %s to a suitable value\n",
-     resourceManager->getDataDir(),
-     DEFAULT_CONFIG_FILE,
-     CONFIG_SECTION_DATA,
-     CONFIG_NAME_DATADIR);
-     exit(-1);
-   }
+      if (!resourceManager->setDataDir(valuebuf))
+      {
+        PRINTF(1)("Data Could not be located\n");
+        exit(-1);
+      }
+    }
+
+    memset (namebuf, 0, 256);
+    memset (valuebuf, 0, 256);
+  }
+
+  if (!resourceManager->checkDataDir(DEFAULT_DATA_DIR_CHECKFILE))
+  {
+    PRINTF(1)("The DataDirectory %s could not be verified\n" \
+              "  Please Change in File %s Section %s Entry %s to a suitable value\n",
+              resourceManager->getDataDir(),
+              DEFAULT_CONFIG_FILE,
+              CONFIG_SECTION_DATA,
+              CONFIG_NAME_DATADIR);
+    exit(-1);
+  }
    //! \todo this is a hack and should be loadable
-   resourceManager->addImageDir(ResourceManager::getInstance()->getFullName("maps/"));
-   resourceManager->debug();
-
-   PRINT(3)("initializing TextEngine\n");
-   TextEngine::getInstance();
-
-   PRINT(3)("initializing ObjectManager\n");
-   this->objectManager = ObjectManager::getInstance();
-
-   CDEngine::getInstance();
-
-   return 0;
-}
-
-
-
+  resourceManager->addImageDir(ResourceManager::getInstance()->getFullName("maps/"));
+  resourceManager->debug();
+
+  PRINT(3)("initializing TextEngine\n");
+  TextEngine::getInstance();
+
+  PRINT(3)("initializing ObjectManager\n");
+  this->objectManager = ObjectManager::getInstance();
+
+  CDEngine::getInstance();
+
+  return 0;
+}
 
 /**
@@ -299,4 +310,9 @@
 bool showGui = false;
 
+
+
+/**********************************
+*** ORXONOX MAIN STARTING POINT ***
+**********************************/
 /**
    \brief main function
@@ -306,5 +322,4 @@
 int main(int argc, char** argv)
 {
-
   // here the pre-arguments are loaded, these are needed to go either to orxonx itself, Help, or Benchmark.
   int i;
@@ -337,13 +352,19 @@
 
 
+
+/**
+ * starts orxonox
+ * @param argc parameters count given to orxonox
+ * @param argv parameters given to orxonox
+ */
 int startOrxonox(int argc, char** argv)
 {
   // checking for existence of the configuration-files
   if (showGui ||
-      !ResourceManager::isFile("~/.orxonox/orxonox.conf") ||
-      ResourceManager::isFile("~/.orxonox/orxonox.lock"))
-    {
-      if (ResourceManager::isFile("~/.orxonox/orxonox.lock"))
-        ResourceManager::deleteFile("~/.orxonox/orxonox.lock");
+      !ResourceManager::isFile(DEFAULT_CONFIG_FILE) ||
+      ResourceManager::isFile(DEFAULT_LOCK_FILE))
+    {
+      if (ResourceManager::isFile(DEFAULT_LOCK_FILE))
+        ResourceManager::deleteFile(DEFAULT_LOCK_FILE);
 
       // starting the GUI
@@ -359,5 +380,5 @@
   PRINT(0)(">>> Starting Orxonox <<<\n");
 
-  ResourceManager::touchFile("~/.orxonox/orxonox.lock");
+  ResourceManager::touchFile(DEFAULT_LOCK_FILE);
 
   Orxonox *orx = Orxonox::getInstance();
