Index: code/branches/hud/src/orxonox/overlays/OverlayText.cc
===================================================================
--- code/branches/hud/src/orxonox/overlays/HUDText.cc	(revision 1614)
+++ code/branches/hud/src/orxonox/overlays/OverlayText.cc	(revision 1615)
@@ -28,5 +28,5 @@
 
 #include "OrxonoxStableHeaders.h"
-#include "HUDText.h"
+#include "OverlayText.h"
 
 #include <OgreOverlayManager.h>
@@ -35,70 +35,71 @@
 
 #include "util/Convert.h"
+#include "util/String.h"
 
 namespace orxonox
 {
-  CreateFactory(HUDText);
+    CreateFactory(OverlayText);
 
-  using namespace Ogre;
-
-  HUDText::HUDText()
-    : text_(0)
-  {
-    RegisterObject(HUDText);
-  }
-
-  HUDText::~HUDText()
-  {
-    if (this->isInitialized())
+    OverlayText::OverlayText()
+        : text_(0)
     {
-      if (this->text_)
-          OverlayManager::getSingleton().destroyOverlayElement(this->text_);
-    }
-  }
-
-  void HUDText::XMLPort(Element& xmlElement, XMLPort::Mode mode)
-  {
-    OrxonoxOverlay::XMLPort(xmlElement, mode);
-
-    if (mode == XMLPort::LoadObject)
-    {
-      this->text_ = static_cast<TextAreaOverlayElement*>(Ogre::OverlayManager::getSingleton().createOverlayElement("TextArea", getName() + "_Text"));
-      this->text_->setCharHeight(1.0f);
-      this->text_->setFontName("Monofur");
-
-      this->background_->addChild(this->text_);
+        RegisterObject(OverlayText);
     }
 
-    XMLPortParam(HUDText, "font", setFont, getFont, xmlElement, mode);
-    XMLPortParam(HUDText, "caption", setCaption, getCaption, xmlElement, mode);
+    OverlayText::~OverlayText()
+    {
+        if (this->text_)
+            Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->text_);
+    }
 
-    if (mode == XMLPort::LoadObject)
+    void OverlayText::XMLPort(Element& xmlElement, XMLPort::Mode mode)
     {
-      this->text_->setCaption(this->caption_);
+        if (mode == XMLPort::LoadObject)
+        {
+            // setting this to true makes the text more readable when the
+            // resolution aspect is far from 1.0
+            this->bCorrectAspect_ = true; // can be overridden by xml
+        }
+
+        OrxonoxOverlay::XMLPort(xmlElement, mode);
+
+        if (mode == XMLPort::LoadObject)
+        {
+            this->text_ = static_cast<Ogre::TextAreaOverlayElement*>(Ogre::OverlayManager::getSingleton()
+                .createOverlayElement("TextArea", "OverlayText_text_" + getUniqueNumberStr()));
+            this->text_->setCharHeight(1.0f);
+            this->text_->setFontName("Monofur");
+
+            this->background_->addChild(this->text_);
+        }
+
+        XMLPortParam(OverlayText, "font", setFont, getFont, xmlElement, mode);
+        XMLPortParam(OverlayText, "caption", setCaption, getCaption, xmlElement, mode);
+        XMLPortParam(OverlayText, "textSize", setTextSize, getTextSize, xmlElement, mode);
+
+        if (mode == XMLPort::LoadObject)
+        {
+            this->text_->setCaption(this->caption_);
+        }
     }
-  }
 
-  void HUDText::setCaption(const std::string& caption)
-  {
-    this->caption_ = caption;
-  }
+    void OverlayText::setFont(const std::string& font)
+    {
+        if (this->text_ && font != "")
+            this->text_->setFontName(font);
+    }
 
-  const std::string& HUDText::getCaption() const
-  {
-    return this->caption_;
-  }
+    const std::string& OverlayText::getFont() const
+    {
+        if (this->text_)
+            return this->text_->getFontName();
+        else
+            return blankString;
+    }
 
-  void HUDText::setFont(const std::string& font)
-  {
-    if (this->text_ && font != "")
-      this->text_->setFontName(font);
-  }
-
-  std::string HUDText::getFont() const
-  {
-    if (this->text_)
-      return this->text_->getFontName();
-    else
-      return "";
-  }
+    void OverlayText::sizeChanged()
+    {
+        this->overlay_->setScale(getSize().y, getSize().y);
+        positionChanged();
+    }
 }
