Index: trunk/src/lib/graphics/text_engine/font.cc
===================================================================
--- trunk/src/lib/graphics/text_engine/font.cc	(revision 9406)
+++ trunk/src/lib/graphics/text_engine/font.cc	(revision 9869)
@@ -29,4 +29,5 @@
 #include "compiler.h"
 
+ObjectListDefinition(Font);
 
 Font::Font()
@@ -34,5 +35,4 @@
 {
   this->init();
-
 }
 
@@ -118,4 +118,5 @@
   Material::operator=(font);
   this->data = font.data;
+  this->setTexture(this->data->textureData());
 
   return *this;
@@ -130,6 +131,6 @@
   this->setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
 
-  this->setClassID(CL_FONT, "Font");
-  if (Font::defaultFontData.get() == NULL)
+  this->registerObject(this, Font::_objectList);
+  if (Font::defaultFontData.isNull())
   {
     Font::initDefaultFont();
@@ -138,5 +139,5 @@
 }
 
-FontDataPointer Font::defaultFontData(NULL);
+FontData::Pointer Font::defaultFontData(NULL);
 
 /**
@@ -146,5 +147,5 @@
 {
   // temporarily create a Font.
-  Font::defaultFontData = FontDataPointer(new FontData);
+  Font::defaultFontData = FontData::Pointer(new FontData);
   // apply the Data.
   Font::defaultFontData = Font(font_xpm).data;
@@ -159,5 +160,5 @@
 bool Font::loadFontFromTTF(const std::string& fontFile, unsigned int renderSize)
 {
-  this->data = FontDataPointer (new FontData());
+  this->data = FontData::Pointer (new FontData());
   bool retVal = this->data->loadFontFromTTF(fontFile, renderSize);
   if (!retVal)
@@ -174,5 +175,5 @@
 bool Font::loadFontFromSDL_Surface(SDL_Surface* surface)
 {
-  this->data = FontDataPointer (new FontData());
+  this->data = FontData::Pointer (new FontData());
   bool retVal = this->data->loadFontFromSDL_Surface(surface);
   if (!retVal)
@@ -196,5 +197,5 @@
 
 
-void Font::setTexture(const TextureDataPointer& texDataPointer)
+void Font::setTexture(const TextureData::Pointer& texDataPointer)
 {
   this->setDiffuseMap(texDataPointer);
Index: trunk/src/lib/graphics/text_engine/font.h
===================================================================
--- trunk/src/lib/graphics/text_engine/font.h	(revision 9406)
+++ trunk/src/lib/graphics/text_engine/font.h	(revision 9869)
@@ -19,5 +19,7 @@
 class Font : public Material
 {
-
+  ObjectListDeclaration(Font);
+public:
+  typedef FontData::Glyph Glyph;
 public:
   Font();
@@ -39,5 +41,5 @@
 
   /** @returns a Pointer to the Array of Glyphs */
-  inline Glyph** getGlyphArray() const { return this->data->getGlyphArray(); };
+  inline const Glyph* const * const getGlyphArray() const { return this->data->getGlyphArray(); };
 
   inline int getMaxHeight() const { return data->getMaxHeight(); };
@@ -50,14 +52,16 @@
   void debug() const;
 
+  void acquireData(const FontData::Pointer& data) { this->data = data; };
+  const FontData::Pointer& dataPointer() const { return data; };
 private:
   void init();
   static void initDefaultFont();
 
-  void setTexture(const TextureDataPointer& texDataPointer);
+  void setTexture(const TextureData::Pointer& texDataPointer);
 
 private:
-  FontDataPointer           data;                //!< A Data-Pointer to a Font.
+  FontData::Pointer         data;                //!< A Data-Pointer to a Font.
 
-  static FontDataPointer    defaultFontData;     //!< a default font, that is used, if other fonts were unable to be loaded.
+  static FontData::Pointer  defaultFontData;     //!< a default font, that is used, if other fonts were unable to be loaded.
 };
 
Index: trunk/src/lib/graphics/text_engine/font_data.h
===================================================================
--- trunk/src/lib/graphics/text_engine/font_data.h	(revision 9406)
+++ trunk/src/lib/graphics/text_engine/font_data.h	(revision 9869)
@@ -26,28 +26,32 @@
 #define FONT_DEFAULT_RENDER_SIZE     50            //!< At what Resolution to render fonts.
 
+class FontData
+{
+
+
+public:
+
 //! A struct for handling glyphs
 /**
  * a Glyph is one letter of a certain font
  */
-struct Glyph
-{
+  struct Glyph
+  {
   // Glyph-specific (size and so on)
-  Uint16   character;         //!< The character
-  float    minX;              //!< The minimum distance from the origin in X
-  float    maxX;              //!< The maximum distance from the origin in X
-  float    minY;              //!< The minimum distance from the origin in Y
-  float    maxY;              //!< The maximum distance from the origin in Y
-  float    width;             //!< The width of the Glyph
-  float    height;            //!< The height of the Glyph
-  float    bearingX;          //!< How much is right of the Origin
-  float    bearingY;          //!< How much is above the Origin
-  float    advance;           //!< How big a Glyph would be in monospace-mode
+    Uint16   character;         //!< The character
+    float    minX;              //!< The minimum distance from the origin in X
+    float    maxX;              //!< The maximum distance from the origin in X
+    float    minY;              //!< The minimum distance from the origin in Y
+    float    maxY;              //!< The maximum distance from the origin in Y
+    float    width;             //!< The width of the Glyph
+    float    height;            //!< The height of the Glyph
+    float    bearingX;          //!< How much is right of the Origin
+    float    bearingY;          //!< How much is above the Origin
+    float    advance;           //!< How big a Glyph would be in monospace-mode
 
-  GLfloat texCoord[4];        //!< Texture coordinates: 0:left, 1:right, 2: top, 3: bottom.
-};
+    GLfloat texCoord[4];        //!< Texture coordinates: 0:left, 1:right, 2: top, 3: bottom.
+  };
 
-
-class FontData
-{
+  typedef CountPointer<FontData> Pointer;
 public:
   FontData();
@@ -61,5 +65,5 @@
 
   /** @returns a Pointer to the Array of Glyphs */
-  inline Glyph** getGlyphArray() const { return this->glyphArray; };
+  inline const Glyph* const * const getGlyphArray() const { return this->glyphArray; };
 
   int getMaxHeight() const { return maxHeight; };
@@ -68,5 +72,5 @@
 
   /** @returns the Texture-Data of this FontData */
-  const TextureDataPointer& textureData() const { return texData; };
+  const TextureData::Pointer& textureData() const { return texData; };
 
   bool rebuild() { return texData->rebuild(); };
@@ -91,8 +95,6 @@
   int           maxDescent;          //!< Max Desent of the Font.
 
-  TextureDataPointer   texData;
+  TextureData::Pointer   texData;
 };
 
-typedef CountPointer<FontData> FontDataPointer;
-
 #endif /* _FONT_DATA_H */
Index: trunk/src/lib/graphics/text_engine/limited_width_text.cc
===================================================================
--- trunk/src/lib/graphics/text_engine/limited_width_text.cc	(revision 9406)
+++ trunk/src/lib/graphics/text_engine/limited_width_text.cc	(revision 9869)
@@ -19,4 +19,5 @@
 #include "font.h"
 
+ObjectListDefinition(LimitedWidthText);
 /**
  * @brief creates a new Text Element
@@ -27,5 +28,5 @@
     : Text(fontFile, textSize)
 {
-  this->setClassID(CL_LIMITED_WIDTH_TEXT, "LimitedWidthText");
+  this->registerObject(this, LimitedWidthText::_objectList);
 
   this->_dotsPosition = End;
@@ -75,5 +76,5 @@
   glRotatef(this->getAbsDir2D(), 0, 0, 1);
 
-  Glyph* tmpGlyph;
+  const Font::Glyph* tmpGlyph;
   float posX = 0.0f;
   glBegin(GL_QUADS);
Index: trunk/src/lib/graphics/text_engine/limited_width_text.h
===================================================================
--- trunk/src/lib/graphics/text_engine/limited_width_text.h	(revision 9406)
+++ trunk/src/lib/graphics/text_engine/limited_width_text.h	(revision 9869)
@@ -14,4 +14,5 @@
 class LimitedWidthText : public Text
 {
+  ObjectListDeclaration(LimitedWidthText);
   public:
     typedef enum {
Index: trunk/src/lib/graphics/text_engine/multi_line_text.cc
===================================================================
--- trunk/src/lib/graphics/text_engine/multi_line_text.cc	(revision 9406)
+++ trunk/src/lib/graphics/text_engine/multi_line_text.cc	(revision 9869)
@@ -19,4 +19,6 @@
 #include "font.h"
 
+ObjectListDefinition(MultiLineText);
+
 /**
  * @brief creates a new Text Element
@@ -27,5 +29,5 @@
   : Text(fontFile, textSize)
 {
-  this->setClassID(CL_MULTI_LINE_TEXT, "MultiLineText");
+  this->registerObject(this, MultiLineText::_objectList);
 
   this->lineSpacing = 1.0;
@@ -78,5 +80,5 @@
   glRotatef(this->getAbsDir2D(), 0, 0, 1);
 
-  Glyph* tmpGlyph;
+  const Font::Glyph* tmpGlyph;
   float posX = 0.0f;
   float posY = 0.0f;
Index: trunk/src/lib/graphics/text_engine/multi_line_text.h
===================================================================
--- trunk/src/lib/graphics/text_engine/multi_line_text.h	(revision 9406)
+++ trunk/src/lib/graphics/text_engine/multi_line_text.h	(revision 9869)
@@ -14,4 +14,5 @@
 class MultiLineText : public Text
 {
+  ObjectListDeclaration(MultiLineText);
   public:
     MultiLineText(const std::string& fontFile = "", unsigned int fontSize = TEXT_DEFAULT_SIZE, float lineWidth = 100.0);
Index: trunk/src/lib/graphics/text_engine/resource_font.cc
===================================================================
--- trunk/src/lib/graphics/text_engine/resource_font.cc	(revision 9869)
+++ trunk/src/lib/graphics/text_engine/resource_font.cc	(revision 9869)
@@ -0,0 +1,54 @@
+
+#include "resource_font.h"
+#include "substring.h"
+#include "multi_type.h"
+#include "debug.h"
+
+
+ResourceFont::ResourceFont(const std::string& fontName, unsigned int renderSize, const Resources::KeepLevel& keepLevel)
+  : Font(), Resource(&ResourceFont::type)
+{
+  assert(!fontName.empty());
+  Resources::StorePointer* ptr = this->acquireResource(fontName + ',' + MultiType((int)renderSize).getString());
+
+  if (ptr)
+  {
+    PRINTF(5)("FOUND FONT: %s\n", fontName.c_str());
+    this->Font::acquireData(static_cast<ResourceFont::FontResourcePointer*>(ptr)->ptr());
+  }
+  else
+  {
+    PRINTF(5)("NOT FOUND FONT: %s\n", fontName.c_str());
+    std::string fileName = this->Resource::locateFile(fontName);
+
+    this->Font::loadFontFromTTF(fileName, renderSize);
+    this->Resource::addResource(new ResourceFont::FontResourcePointer(fontName + ',' + MultiType((int)renderSize).getString(), keepLevel, this->Font::dataPointer()));
+  }
+}
+
+ResourceFont ResourceFont::createFromString(const std::string& loadString, const Resources::KeepLevel& keepLevel)
+{
+  SubString loadValues(loadString, ',');
+  std::string fontName;
+  unsigned int renderSize = 20;
+  if (loadValues.size() > 0)
+    fontName = loadValues[0];
+  if (loadValues.size() > 1)
+    renderSize = (unsigned int)MultiType(loadValues[2]).getInt();
+
+  return ResourceFont(fontName, renderSize, keepLevel);
+}
+
+
+
+Resources::tType<ResourceFont> ResourceFont::type("Font");
+
+
+
+
+
+ResourceFont::FontResourcePointer::FontResourcePointer(const std::string& loadString, const Resources::KeepLevel& keepLevel, const FontData::Pointer& data)
+    : Resources::StorePointer(loadString, keepLevel) , pointer(data)
+{}
+
+
Index: trunk/src/lib/graphics/text_engine/resource_font.h
===================================================================
--- trunk/src/lib/graphics/text_engine/resource_font.h	(revision 9869)
+++ trunk/src/lib/graphics/text_engine/resource_font.h	(revision 9869)
@@ -0,0 +1,36 @@
+/*!
+ * @file resource_font.h
+ * @brief Contains the ResourceFont class, that handles the Resource-specific loading part of the Font.
+ *
+ */
+
+#ifndef _RESOURCE_FONT_H
+#define _RESOURCE_FONT_H
+
+#include "util/loading/resource.h"
+#include "font.h"
+
+
+class ResourceFont : public Font, public Resources::Resource
+{
+public:
+  ResourceFont(const std::string& fontName, unsigned int renderSize, const Resources::KeepLevel& keepLevel = Resources::KeepLevel());
+  static ResourceFont createFromString(const std::string& loadString, const Resources::KeepLevel& keepLevel = Resources::KeepLevel());
+
+private:
+class FontResourcePointer : public Resources::StorePointer
+  {
+  public:
+    FontResourcePointer(const std::string& loadString, const Resources::KeepLevel& keepLevel, const FontData::Pointer& data);
+    inline const FontData::Pointer& ptr() const { return pointer; }
+    virtual bool last() const { return pointer.count() == 1; }
+  private:
+    FontData::Pointer pointer;
+  };
+
+private:
+  static Resources::tType<ResourceFont> type;
+};
+
+
+#endif /* _RESOURCE_FONT_H */
Index: trunk/src/lib/graphics/text_engine/text.cc
===================================================================
--- trunk/src/lib/graphics/text_engine/text.cc	(revision 9406)
+++ trunk/src/lib/graphics/text_engine/text.cc	(revision 9869)
@@ -17,8 +17,9 @@
 
 #include "text.h"
+#include "resource_font.h"
 #include "font.h"
-
-#include "util/loading/resource_manager.h"
 #include "debug.h"
+
+ObjectListDefinition(Text);
 
 /**
@@ -28,10 +29,13 @@
  */
 Text::Text(const std::string& fontFile, unsigned int textSize)
-    // : _font(fontFile, FONT_DEFAULT_RENDER_SIZE)
-{
-  this->setClassID(CL_TEXT, "Text");
+// : _font(fontFile, FONT_DEFAULT_RENDER_SIZE)
+{
+  this->registerObject(this, Text::_objectList);
 
   // initialize this Text
-  this->setFont(fontFile, FONT_DEFAULT_RENDER_SIZE);
+  if (!fontFile.empty())
+    this->setFont(fontFile, FONT_DEFAULT_RENDER_SIZE);
+  else
+    this->setFont("fonts/final_frontier.ttf", FONT_DEFAULT_RENDER_SIZE);
   this->_size = textSize;
   this->setSizeY2D(textSize);
@@ -44,5 +48,5 @@
     : _font()
 {
-  this->setClassID(CL_TEXT, "Text");
+  this->registerObject(this, Text::_objectList);
 
   *this = text;
@@ -169,22 +173,5 @@
 void Text::setFont(const std::string& fontFile, unsigned int fontSize)
 {
-  Font* newFont = NULL;
-  //  Font* oldFont = this->_font;
-
-  // load a new Font
-  if (!fontFile.empty())
-  {
-    newFont = (Font*)ResourceManager::getInstance()->load(fontFile, TTF, RP_GAME, (int)fontSize);
-    if (newFont == NULL)
-    {
-      //      newFont = &Font::();
-      PRINTF(2)("Font %s could not be loaded, probably file not found\n", fontFile.c_str());
-    }
-  }
-
-  if (newFont == NULL)
-    this->_font = Font();
-  else
-    this->_font = *newFont;
+  this->_font = ResourceFont(fontFile, fontSize);
 
   this->setupTextWidth();
@@ -233,5 +220,5 @@
   glRotatef(this->getAbsDir2D(), 0, 0, 1);
 
-  Glyph* tmpGlyph;
+  const Font::Glyph* tmpGlyph;
   float posX = 0.0f;
   glBegin(GL_QUADS);
Index: trunk/src/lib/graphics/text_engine/text.h
===================================================================
--- trunk/src/lib/graphics/text_engine/text.h	(revision 9406)
+++ trunk/src/lib/graphics/text_engine/text.h	(revision 9869)
@@ -26,4 +26,5 @@
 class Text : public Element2D
 {
+  ObjectListDeclaration(Text);
   public:
     Text(const std::string& fontFile = "", unsigned int fontSize = TEXT_DEFAULT_SIZE);
Index: trunk/src/lib/graphics/text_engine/text_engine.cc
===================================================================
--- trunk/src/lib/graphics/text_engine/text_engine.cc	(revision 9406)
+++ trunk/src/lib/graphics/text_engine/text_engine.cc	(revision 9869)
@@ -33,6 +33,4 @@
 
 #include "graphics_engine.h"
-#include "util/loading/resource_manager.h"
-#include "class_list.h"
 
 #include "debug.h"
@@ -40,4 +38,5 @@
 /// TEXT-ENGINE ///
 ///////////////////
+ObjectListDefinition(TextEngine);
 /**
  *  standard constructor
@@ -45,7 +44,7 @@
 TextEngine::TextEngine ()
 {
-   this->setClassID(CL_TEXT_ENGINE, "TextEngine");
-   this->setName("TextEngine");
-   this->enableFonts();
+  this->registerObject(this, TextEngine::_objectList);
+  this->setName("TextEngine");
+  this->enableFonts();
 }
 
@@ -62,18 +61,15 @@
 {
   // first remove all the remaining Texts (if any).
-  const std::list<BaseObject*>* textList = ClassList::getList(CL_TEXT);
-  if (textList != NULL)
-  {
-    while(textList->size() > 0)
-      delete dynamic_cast<Text*>(textList->front());
-  }
+  while (!Text::objectList().empty())
+    delete Text::objectList().front();
   // delete all remaining fonts (There should not be Anything to do here)
-  const std::list<BaseObject*>* fontList = ClassList::getList(CL_FONT);
-  if (fontList != NULL)
+
+  //const std::list<BaseObject*>* fontList = ClassList::getList(CL_FONT);
+  //if (fontList != NULL)
   {
     ///FIXME
-//    while (fontList->size() > 0)
+    //    while (fontList->size() > 0)
     {
-//      Font* font = dynamic_cast<Font*>(fontList->back());
+      //      Font* font = dynamic_cast<Font*>(fontList->back());
       //if (likely(font != Font::getDefaultFont()))
       //        ResourceManager::getInstance()->unload(font, RP_GAME);
@@ -91,10 +87,10 @@
 {
   if (!TTF_WasInit())
-    {
-      if(TTF_Init()==-1)
-        PRINTF(1)("TTF_Init: %s\n", TTF_GetError());
+  {
+    if(TTF_Init()==-1)
+      PRINTF(1)("TTF_Init: %s\n", TTF_GetError());
 
-      TextEngine::checkVersion();
-    }
+    TextEngine::checkVersion();
+  }
   else
     PRINTF(4)("Fonts already initialized\n");
@@ -107,8 +103,8 @@
 {
   if (TTF_WasInit())
-    {
-//      Font::removeDefaultFont();
-      TTF_Quit();
-    }
+  {
+    //      Font::removeDefaultFont();
+    TTF_Quit();
+  }
   else
     PRINTF(4)("Fonts were not initialized.\n");
@@ -122,15 +118,14 @@
 void TextEngine::debug() const
 {
-  const std::list<BaseObject*>* textList = ClassList::getList(CL_TEXT);
-  if (textList != NULL)
+  PRINT(0)("+-------------------------------+\n");
+  PRINT(0)("+ TEXT ENGINE DEBUG INFORMATION +\n");
+  PRINT(0)("+-------------------------------+\n");
+  PRINT(0)("Reference: %p; Text Counts: %d\n", this, Text::objectList().size());
+
+  for (ObjectList<Text>::const_iterator it = Text::objectList().begin();
+       it != Text::objectList().end();
+       ++it)
   {
-    PRINT(0)("+-------------------------------+\n");
-    PRINT(0)("+ TEXT ENGINE DEBUG INFORMATION +\n");
-    PRINT(0)("+-------------------------------+\n");
-    PRINT(0)("Reference: %p; Text Counts: %d\n", this, textList->size());
-
-    std::list<BaseObject*>::const_iterator text;
-    for ( text = textList->begin(); text != textList->end(); text++)
-      dynamic_cast<Text*>(*text)->debug();
+      (*it)->debug();
     PRINT(0)("+---------------------------TE--+\n");
   }
@@ -152,19 +147,19 @@
       compile_version.minor == link_version.minor &&
       compile_version.patch == link_version.patch)
-    {
-      return true;
-    }
+  {
+    return true;
+  }
   else
-    {
-      PRINTF(2)("compiled with SDL_ttf version: %d.%d.%d\n",
-                compile_version.major,
-                compile_version.minor,
-                compile_version.patch);
+  {
+    PRINTF(2)("compiled with SDL_ttf version: %d.%d.%d\n",
+              compile_version.major,
+              compile_version.minor,
+              compile_version.patch);
 
-      PRINTF(2)("running with SDL_ttf version: %d.%d.%d\n",
-                link_version.major,
-                link_version.minor,
-                link_version.patch);
-      return false;
-    }
+    PRINTF(2)("running with SDL_ttf version: %d.%d.%d\n",
+              link_version.major,
+              link_version.minor,
+              link_version.patch);
+    return false;
+  }
 }
Index: trunk/src/lib/graphics/text_engine/text_engine.h
===================================================================
--- trunk/src/lib/graphics/text_engine/text_engine.h	(revision 9406)
+++ trunk/src/lib/graphics/text_engine/text_engine.h	(revision 9869)
@@ -24,5 +24,6 @@
 class TextEngine : public BaseObject
 {
- public:
+  ObjectListDeclaration(TextEngine);
+  public:
   virtual ~TextEngine();
   /** @returns a Pointer to the only object of this Class */
