Index: /branches/new_class_id/src/lib/coord/p_node.cc
===================================================================
--- /branches/new_class_id/src/lib/coord/p_node.cc	(revision 9789)
+++ /branches/new_class_id/src/lib/coord/p_node.cc	(revision 9790)
@@ -81,5 +81,5 @@
   // remove the Node, delete it's children (if required).
   PNode* last = NULL;
-  this->debugNode(0);
+  //this->debugNode(0);
 
   while(!this->children.empty())
Index: /branches/new_class_id/src/lib/graphics/importer/resource_texture.cc
===================================================================
--- /branches/new_class_id/src/lib/graphics/importer/resource_texture.cc	(revision 9789)
+++ /branches/new_class_id/src/lib/graphics/importer/resource_texture.cc	(revision 9790)
@@ -2,5 +2,5 @@
 
 #include "resource_texture.h"
-
+#include "debug.h"
 
 
@@ -12,10 +12,10 @@
   if (ptr)
   {
-    printf("FOUNT TEXTURE: %s\n", imageName.c_str());
+    PRINTF(5)("FOUNT TEXTURE: %s\n", imageName.c_str());
     this->acquireData(static_cast<ResourceTexture::TextureResourcePointer*>(ptr)->ptr());
   }
   else
   {
-    printf("NOT FOUNT TEXTURE: %s\n", imageName.c_str());
+    PRINTF(5)("NOT FOUNT TEXTURE: %s\n", imageName.c_str());
     std::string fileName = this->NewResource::locateFile(imageName);
     this->Texture::loadImage(fileName, target);
Index: /branches/new_class_id/src/lib/util/Makefile.am
===================================================================
--- /branches/new_class_id/src/lib/util/Makefile.am	(revision 9789)
+++ /branches/new_class_id/src/lib/util/Makefile.am	(revision 9790)
@@ -16,4 +16,5 @@
 		\
 		loading/resource_manager.cc \
+		loading/new_resource_manager.cc \
 		loading/resource.cc \
 		loading/game_loader.cc \
@@ -66,4 +67,5 @@
 		\
 		loading/resource_manager.h \
+		loading/new_resource_manager.h \
 		loading/resource.h \
 		loading/game_loader.h \
Index: /branches/new_class_id/src/lib/util/loading/new_resource_manager.cc
===================================================================
--- /branches/new_class_id/src/lib/util/loading/new_resource_manager.cc	(revision 9790)
+++ /branches/new_class_id/src/lib/util/loading/new_resource_manager.cc	(revision 9790)
@@ -0,0 +1,67 @@
+/*
+   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: Benjamin Grauer
+   co-programmer: Patrick Boenzli
+*/
+
+#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_LOAD
+
+#include "new_resource_manager.h"
+#include "debug.h"
+
+#include <algorithm>
+#include <assert.h>
+
+ObjectListDefinition(NewResourceManager);
+
+/**
+ * @brief standard constructor
+*/
+NewResourceManager::NewResourceManager ()
+{
+  this->registerObject(this, NewResourceManager::_objectList);
+  this->setName("NewResourceManager");
+
+  //this->dataDir = "./";
+  this->tryDataDir("./data");
+}
+
+//! Singleton Reference to the NewResourceManager
+NewResourceManager* NewResourceManager::singletonRef = NULL;
+
+/**
+ * @brief standard destructor
+*/
+NewResourceManager::~NewResourceManager ()
+{
+  // deleting the Resources-List
+  //this->unloadAllByPriority(RP_GAME);
+
+//   if (!this->resourceList.empty())
+//     PRINTF(1)("Not removed all Resources, since there are still %d resources registered\n", this->resourceList.size());
+
+  NewResourceManager::singletonRef = NULL;
+}
+
+
+
+/**
+ * @brief outputs debug information about the NewResourceManager
+ */
+void NewResourceManager::debug() const
+{
+  PRINT(0)("=RM===================================\n");
+  PRINT(0)("= RESOURCE-MANAGER DEBUG INFORMATION =\n");
+  PRINT(0)("======================================\n");
+
+  PRINT(0)("==================================RM==\n");
+}
Index: /branches/new_class_id/src/lib/util/loading/new_resource_manager.h
===================================================================
--- /branches/new_class_id/src/lib/util/loading/new_resource_manager.h	(revision 9790)
+++ /branches/new_class_id/src/lib/util/loading/new_resource_manager.h	(revision 9790)
@@ -0,0 +1,39 @@
+/*!
+ * @file new_resource_manager.h
+ */
+
+#ifndef _NEW_RESOURCE_MANAGER_H
+#define _NEW_RESOURCE_MANAGER_H
+
+#include "resource.h"
+#include "filesys/file.h"
+#include "filesys/directory.h"
+
+class NewResourceManager : public BaseObject
+{
+  ObjectListDeclaration(NewResourceManager);
+public:
+  virtual ~NewResourceManager();
+  /** @returns a Pointer to the only object of this Class */
+  inline static NewResourceManager* getInstance() { if (!singletonRef) singletonRef = new NewResourceManager();  return singletonRef; };
+
+  bool tryDataDir(const std::string& dataDir);
+  bool verifyDataDir(const std::string& fileInside);
+
+  bool unloadAllByPriority();
+
+  void debug() const;
+
+  // utility functions for handling files in and around the data-directory
+  static std::string getFullName(const std::string& fileName);
+  static bool isInDataDir(const std::string& fileName);
+
+private:
+  NewResourceManager();
+
+private:
+  static NewResourceManager*    singletonRef;       //!< singleton Reference
+
+};
+
+#endif /* _RESOURCE_MANAGER_H */
Index: /branches/new_class_id/src/lib/util/loading/resource.cc
===================================================================
--- /branches/new_class_id/src/lib/util/loading/resource.cc	(revision 9789)
+++ /branches/new_class_id/src/lib/util/loading/resource.cc	(revision 9790)
@@ -14,12 +14,11 @@
 */
 
-#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_LOADING
+#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_LOAD
 
 #include "resource.h"
 #include "filesys/file.h"
+#include "debug.h"
 
 ObjectListDefinition(NewResource);
-
-
 std::vector<NewResource::Type*>    NewResource::_resourceTypes;
 
@@ -36,10 +35,4 @@
 {
   this->registerObject(this, NewResource::_objectList);
-
-  if(this->_type->id() == -1)
-  {
-    NewResource::_resourceTypes.push_back(this->_type);
-    this->_type->setID(NewResource::_resourceTypes.size()-1);
-  }
 }
 
@@ -53,14 +46,36 @@
 
 
-std::string NewResource::locateFile(const std::string& fileName)
+std::string NewResource::locateFile(const std::string& fileName) const
 {
   if (File(fileName).exists())
     return fileName;
-  else if ((NewResource::_mainGlobalPath+File(fileName)) . exists() )
+  else if ((NewResource::_mainGlobalPath + File(fileName)).exists() )
     return (NewResource::_mainGlobalPath + File(fileName)).name();
 
+  printf("LOCATED %s\n", locateFileInSubDir(Directory("/home/bensch/svn/orxonox/data/"), fileName).c_str());
+
   return std::string("/home/bensch/svn/orxonox/data/") + fileName;
-
-}
+}
+
+/**
+ * @brief tests in all the SubDirectories defined in Resource under Directory if the fileName exists.
+ * @param directory the directory to in what to search for all subdirectories for.
+ * @param fileName the Name of the File to query for
+ * @return true on success.
+ */
+std::string NewResource::locateFileInSubDir(const Directory& directory, const std::string& fileName) const
+{
+  std::vector<Directory>::const_iterator it;
+  for (it = this->_type->resourceSubPaths().begin(); it != this->_type->resourceSubPaths().end(); ++it)
+  {
+    Directory dir = directory + (*it);
+    File file = dir + File(fileName);
+    printf("Testing %s (from %s in directory %s)\n", file.name().c_str(), fileName.c_str(), dir.name().c_str());
+    if ((dir+ File(fileName)).exists())
+      return (dir+File(fileName)).name();
+  }
+  return "";
+}
+
 
 
@@ -99,12 +114,57 @@
 
 
-
-
-
-
-
-
-
-std::vector<std::string>  NewResource::KeepLevel::_keepLevelNames;
+void NewResource::registerType(NewResource::Type* type)
+{
+  NewResource::debug();
+  if(type->id() == -1)
+  {
+    NewResource::_resourceTypes.push_back(type);
+    type->setID(NewResource::_resourceTypes.size()-1);
+  }
+  NewResource::debug();
+}
+
+bool NewResource::addResourcePath(const std::string& resourceName, const std::string& pathName)
+{
+  std::vector<NewResource::Type*>::iterator it;
+  for (it = NewResource::_resourceTypes.begin(); it != NewResource::_resourceTypes.end(); ++it)
+    if (*(*it) == resourceName)
+      return (*it)->addResourcePath(pathName);
+  PRINTF(2)("ResourcePath %s could not be added to the ResourceType %s\n", pathName.c_str(), resourceName.c_str());
+  return false;
+}
+
+bool NewResource::addResourceSubPath(const std::string& resourceName, const std::string& pathName)
+{
+  std::vector<NewResource::Type*>::iterator it;
+  for (it = NewResource::_resourceTypes.begin(); it != NewResource::_resourceTypes.end(); ++it)
+    if (*(*it) == resourceName)
+      return (*it)->addResourceSubPath(pathName);
+  PRINTF(2)("ResourceSubPath %s could not be added to the ResourceType %s\n", pathName.c_str(), resourceName.c_str());
+  return false;
+}
+
+
+
+void NewResource::debug()
+{
+  PRINT(0)("==================================\n");
+  PRINT(0)("DEBUG output for all Resources\n");
+  PRINT(0)("==================================\n");
+
+  PRINT(0)("Listing %d Types: \n", NewResource::_resourceTypes.size());
+  std::vector<NewResource::Type*>::iterator it;
+  for (it = NewResource::_resourceTypes.begin(); it != NewResource::_resourceTypes.end(); ++it)
+    PRINT(0)("ResourceType '%s'\n", (*it)->storedClassID().name().c_str());
+
+  PRINT(0)("==================================\n");
+
+}
+
+
+
+
+
+std::vector<std::string> NewResource::KeepLevel::_keepLevelNames;
 void NewResource::KeepLevel::defineKeepLevelName(unsigned int level, const std::string& name)
 {
@@ -115,4 +175,9 @@
 
 
+NewResource::Type::Type(const ClassID& classID)
+    : _id(-1), _classID(classID)
+{
+  NewResource::registerType(this);
+}
 
 void NewResource::Type::addResource(NewResource::StorePointer* resource)
@@ -121,4 +186,26 @@
 
 }
+
+bool NewResource::Type::addResourcePath(const std::string& path)
+{
+  std::vector<Directory>::const_iterator it;
+  for (it = this->_resourcePaths.begin(); it != this->_resourcePaths.end(); ++it)
+    if ((*it) == path)
+      return false;
+  this->_resourcePaths.push_back(path);
+  return true;
+
+}
+
+bool NewResource::Type::addResourceSubPath(const std::string& subPath)
+{
+  std::vector<Directory>::const_iterator it;
+  for (it = this->_resourceSubPaths.begin(); it != this->_resourceSubPaths.end(); ++it)
+    if ((*it) == subPath)
+      return false;
+  this->_resourceSubPaths.push_back(subPath);
+  return true;
+}
+
 
 
Index: /branches/new_class_id/src/lib/util/loading/resource.h
===================================================================
--- /branches/new_class_id/src/lib/util/loading/resource.h	(revision 9789)
+++ /branches/new_class_id/src/lib/util/loading/resource.h	(revision 9790)
@@ -53,16 +53,18 @@
   {
   public:
-    Type(const ClassID& classID) : _id(-1), _classID(classID) { };
+    Type(const ClassID& classID);
+    bool operator==(const ClassID& classID) const { return this->_classID == classID; };
+    bool operator==(const std::string& resourceName) const { return this->_classID.name() == resourceName; };
 
     void addExtension(const std::string& extension);
 
-    void addResourcePath(const std::string& path);
-    void addResourceSubPath(const std::string& subPath);
+    bool addResourcePath(const std::string& path);
+    bool addResourceSubPath(const std::string& subPath);
 
     /// Retrieve Functions
     const ClassID& storedClassID() const { return _classID; };
     int id() const { return _id; };
-    const std::vector<std::string>& resourcePaths() const { return _resourcePaths; };
-    const std::vector<std::string>& resourceSubPaths() const { return _resourceSubPaths; };
+    const std::vector<Directory>& resourcePaths() const { return _resourcePaths; };
+    const std::vector<Directory>& resourceSubPaths() const { return _resourceSubPaths; };
     const std::vector<NewResource::StorePointer*>& storedResources() const { return _storedResources; };
 
@@ -73,6 +75,6 @@
     int                             _id;
     const ClassID&                  _classID;
-    std::vector<std::string>        _resourcePaths;
-    std::vector<std::string>        _resourceSubPaths;
+    std::vector<Directory>          _resourcePaths;
+    std::vector<Directory>          _resourceSubPaths;
     std::vector<std::string>        _fileExtensions;
 
@@ -88,5 +90,5 @@
   virtual bool unload() { return false; };
 
-  std::string locateFile(const std::string& fileName);
+  std::string locateFile(const std::string& fileName) const;
 
 
@@ -95,5 +97,10 @@
   static void addGlobalPath(const Directory& directory);
 
+  static bool addResourcePath(const std::string& resourceName, const std::string& pathName);
+  static bool addResourceSubPath(const std::string& resourceName, const std::string& pathName);
 
+  static void registerType(NewResource::Type* type);
+
+  static void debug();
 protected:
   NewResource::StorePointer* acquireResource(const std::string& loadString);
@@ -101,9 +108,12 @@
 
 private:
+  std::string locateFileInSubDir(const Directory& directory, const std::string& fileName) const;
+
+private:
   NewResource::StorePointer*       _pointer;                         //!< Virtual Pointer to the ResourceData.
-  NewResource::Type*          _type;                            //!< Type of the NewResource.
+  NewResource::Type*               _type;                            //!< Type of the NewResource.
 
 
-  static std::vector<NewResource::Type*>    _resourceTypes;
+  static std::vector<NewResource::Type*>  _resourceTypes;
 
   //! GLOBALS
Index: /branches/new_class_id/src/orxonox.cc
===================================================================
--- /branches/new_class_id/src/orxonox.cc	(revision 9789)
+++ /branches/new_class_id/src/orxonox.cc	(revision 9790)
@@ -367,10 +367,8 @@
   }
 
-
+  NewResource::debug();
   //! @todo this is a hack and should be loadable
-  std::string imageDir = ResourceManager::getInstance()->getFullName("maps");
-  ResourceManager::getInstance()->addImageDir(imageDir);
-  imageDir = ResourceManager::getInstance()->getFullName("pictures");
-  ResourceManager::getInstance()->addImageDir(imageDir);
+  NewResource::addResourceSubPath("Texture", "maps");
+  NewResource::addResourceSubPath("Texture", "pictures");
 
   //  DynamicLoader::loadDyLib("libtest.so");
