Index: code/branches/pickup2/src/orxonox/overlays/InGameConsole.cc
===================================================================
--- code/branches/pickup2/src/orxonox/overlays/InGameConsole.cc	(revision 5942)
+++ code/branches/pickup2/src/orxonox/overlays/InGameConsole.cc	(revision 6412)
@@ -44,5 +44,5 @@
 #include "util/Convert.h"
 #include "util/Math.h"
-#include "util/UTFStringConversions.h"
+#include "util/DisplayStringConversions.h"
 #include "core/CoreIncludes.h"
 #include "core/ConfigValueIncludes.h"
@@ -61,5 +61,4 @@
     SetConsoleCommand(InGameConsole, closeConsole, true);
 
-    InGameConsole* InGameConsole::singletonPtr_s = 0;
     ManageScopedSingleton(InGameConsole, ScopeID::Graphics, false);
 
@@ -68,5 +67,7 @@
     */
     InGameConsole::InGameConsole()
-        : consoleOverlay_(0)
+        : shell_(new Shell("InGameConsole", true))
+        , bShowCursor_(false)
+        , consoleOverlay_(0)
         , consoleOverlayContainer_(0)
         , consoleOverlayNoise_(0)
@@ -99,4 +100,7 @@
         // destroy the input state previously created (InputBuffer gets destroyed by the Shell)
         InputManager::getInstance().destroyState("console");
+
+        // destroy the underlaying shell
+        this->shell_->destroy();
 
         Ogre::OverlayManager* ovMan = Ogre::OverlayManager::getSingletonPtr();
@@ -174,5 +178,5 @@
         // create the corresponding input state
         inputState_ = InputManager::getInstance().createInputState("console", false, false, InputStatePriority::Console);
-        inputState_->setKeyHandler(Shell::getInstance().getInputBuffer());
+        inputState_->setKeyHandler(this->shell_->getInputBuffer());
         bHidesAllInputChanged();
 
@@ -214,4 +218,12 @@
         font->addCodePointRange(Ogre::Font::CodePointRange(161, 255));
 
+        // create noise
+        this->consoleOverlayNoise_ = static_cast<Ogre::PanelOverlayElement*>(ovMan->createOverlayElement("Panel", "InGameConsoleNoise"));
+        this->consoleOverlayNoise_->setMetricsMode(Ogre::GMM_PIXELS);
+        this->consoleOverlayNoise_->setPosition(5,0);
+        this->consoleOverlayNoise_->setMaterialName("ConsoleNoiseSmall");
+        // comment following line to disable noise
+        this->consoleOverlayBorder_->addChild(this->consoleOverlayNoise_);
+
         // create the text lines
         this->consoleOverlayTextAreas_ = new Ogre::TextAreaOverlayElement*[LINES];
@@ -225,5 +237,5 @@
             this->consoleOverlayTextAreas_[i]->setLeft(8);
             this->consoleOverlayTextAreas_[i]->setCaption("");
-            this->consoleOverlayContainer_->addChild(this->consoleOverlayTextAreas_[i]);
+            this->consoleOverlayNoise_->addChild(this->consoleOverlayTextAreas_[i]);
         }
 
@@ -236,21 +248,11 @@
         this->consoleOverlayCursor_->setLeft(7);
         this->consoleOverlayCursor_->setCaption(std::string(this->cursorSymbol_, 1));
-        this->consoleOverlayContainer_->addChild(this->consoleOverlayCursor_);
-
-        // create noise
-        this->consoleOverlayNoise_ = static_cast<Ogre::PanelOverlayElement*>(ovMan->createOverlayElement("Panel", "InGameConsoleNoise"));
-        this->consoleOverlayNoise_->setMetricsMode(Ogre::GMM_PIXELS);
-        this->consoleOverlayNoise_->setPosition(5,0);
-        this->consoleOverlayNoise_->setMaterialName("ConsoleNoiseSmall");
-        // comment following line to disable noise
-        this->consoleOverlayContainer_->addChild(this->consoleOverlayNoise_);
+        this->consoleOverlayNoise_->addChild(this->consoleOverlayCursor_);
 
         this->windowResized(this->getWindowWidth(), this->getWindowWidth());
 
         // move overlay "above" the top edge of the screen
-        // we take -1.2 because the border makes the panel bigger
-        this->consoleOverlayContainer_->setTop(-1.2 * this->relativeHeight);
-
-        Shell::getInstance().addOutputLevel(true);
+        // we take -1.3 because the border makes the panel bigger
+        this->consoleOverlayContainer_->setTop(-1.3 * this->relativeHeight);
 
         COUT(4) << "Info: InGameConsole initialized" << std::endl;
@@ -266,9 +268,9 @@
     void InGameConsole::linesChanged()
     {
-        std::list<std::string>::const_iterator it = Shell::getInstance().getNewestLineIterator();
+        Shell::LineList::const_iterator it = this->shell_->getNewestLineIterator();
         int max = 0;
         for (int i = 1; i < LINES; ++i)
         {
-            if (it != Shell::getInstance().getEndIterator())
+            if (it != this->shell_->getEndIterator())
             {
                 ++it;
@@ -280,10 +282,10 @@
 
         for (int i = LINES - 1; i > max; --i)
-            this->print("", i, true);
+            this->print("", Shell::None, i, true);
 
         for (int i = max; i >= 1; --i)
         {
             --it;
-            this->print(*it, i, true);
+            this->print(it->first, it->second, i, true);
         }
     }
@@ -295,5 +297,5 @@
     {
         if (LINES > 1)
-            this->print(*Shell::getInstance().getNewestLineIterator(), 1);
+            this->print(this->shell_->getNewestLineIterator()->first, this->shell_->getNewestLineIterator()->second, 1);
     }
 
@@ -314,7 +316,7 @@
     {
         if (LINES > 0)
-            this->print(Shell::getInstance().getInput(), 0);
-
-        if (Shell::getInstance().getInput() == "" || Shell::getInstance().getInput().size() == 0)
+            this->print(this->shell_->getInput(), Shell::Input, 0);
+
+        if (this->shell_->getInput().empty())
             this->inputWindowStart_ = 0;
     }
@@ -325,5 +327,5 @@
     void InGameConsole::cursorChanged()
     {
-        unsigned int pos = Shell::getInstance().getCursorPosition() - inputWindowStart_;
+        unsigned int pos = this->shell_->getCursorPosition() - inputWindowStart_;
         if (pos > maxCharsPerLine_)
             pos = maxCharsPerLine_;
@@ -331,4 +333,12 @@
         this->consoleOverlayCursor_->setCaption(std::string(pos,' ') + cursorSymbol_);
         this->consoleOverlayCursor_->setTop(static_cast<int>(this->windowH_ * this->relativeHeight) - 24);
+    }
+
+    /**
+        @brief Called if a command is about to be executed
+    */
+    void InGameConsole::executed()
+    {
+        this->shell_->addOutput(this->shell_->getInput() + '\n', Shell::Command);
     }
 
@@ -348,5 +358,5 @@
         @brief Used to control the actual scrolling and the cursor.
     */
-    void InGameConsole::update(const Clock& time)
+    void InGameConsole::preUpdate(const Clock& time)
     {
         if (this->scroll_ != 0)
@@ -374,9 +384,9 @@
                 // scrolling up
                 // note: +0.01 for the same reason as when scrolling down
-                float deltaScroll = (1.2 * this->relativeHeight + 0.01 + oldTop) * time.getDeltaTime() * this->scrollSpeed_;
-                if (oldTop - deltaScroll <= -1.2 * this->relativeHeight)
+                float deltaScroll = (1.3 * this->relativeHeight + 0.01 + oldTop) * time.getDeltaTime() * this->scrollSpeed_;
+                if (oldTop - deltaScroll <= -1.3 * this->relativeHeight)
                 {
                     // window has completely scrolled up
-                    this->consoleOverlayContainer_->setTop(-1.2 * this->relativeHeight);
+                    this->consoleOverlayContainer_->setTop(-1.3 * this->relativeHeight);
                     this->scroll_ = 0;
                     this->consoleOverlay_->hide();
@@ -446,18 +456,10 @@
         @param s String to be printed
     */
-    void InGameConsole::print(const std::string& text, int index, bool alwaysShift)
-    {
-        char level = 0;
-        if (text.size() > 0)
-            level = text[0];
-
+    void InGameConsole::print(const std::string& text, Shell::LineType type, int index, bool alwaysShift)
+    {
         std::string output = text;
-
-        if (level >= -1 && level <= 5)
-            output.erase(0, 1);
-
         if (LINES > index)
         {
-            this->colourLine(level, index);
+            this->colourLine(type, index);
 
             if (index > 0)
@@ -467,12 +469,12 @@
                 {
                     ++linesUsed;
-                    this->consoleOverlayTextAreas_[index]->setCaption(multi_cast<Ogre::UTFString>(output.substr(0, this->maxCharsPerLine_)));
+                    this->consoleOverlayTextAreas_[index]->setCaption(multi_cast<Ogre::DisplayString>(output.substr(0, this->maxCharsPerLine_)));
                     output.erase(0, this->maxCharsPerLine_);
                     output.insert(0, 1, ' ');
                     if (linesUsed > numLinesShifted_ || alwaysShift)
                         this->shiftLines();
-                    this->colourLine(level, index);
+                    this->colourLine(type, index);
                 }
-                this->consoleOverlayTextAreas_[index]->setCaption(multi_cast<Ogre::UTFString>(output));
+                this->consoleOverlayTextAreas_[index]->setCaption(multi_cast<Ogre::DisplayString>(output));
                 this->displayedText_ = output;
                 this->numLinesShifted_ = linesUsed;
@@ -482,8 +484,8 @@
                 if (output.size() > this->maxCharsPerLine_)
                 {
-                    if (Shell::getInstance().getInputBuffer()->getCursorPosition() < this->inputWindowStart_)
-                        this->inputWindowStart_ = Shell::getInstance().getInputBuffer()->getCursorPosition();
-                    else if (Shell::getInstance().getInputBuffer()->getCursorPosition() >= (this->inputWindowStart_ + this->maxCharsPerLine_ - 1))
-                        this->inputWindowStart_ = Shell::getInstance().getInputBuffer()->getCursorPosition() - this->maxCharsPerLine_ + 1;
+                    if (this->shell_->getInputBuffer()->getCursorPosition() < this->inputWindowStart_)
+                        this->inputWindowStart_ = this->shell_->getInputBuffer()->getCursorPosition();
+                    else if (this->shell_->getInputBuffer()->getCursorPosition() >= (this->inputWindowStart_ + this->maxCharsPerLine_ - 1))
+                        this->inputWindowStart_ = this->shell_->getInputBuffer()->getCursorPosition() - this->maxCharsPerLine_ + 1;
 
                     output = output.substr(this->inputWindowStart_, this->maxCharsPerLine_);
@@ -492,5 +494,5 @@
                   this->inputWindowStart_ = 0;
                 this->displayedText_ = output;
-                this->consoleOverlayTextAreas_[index]->setCaption(multi_cast<Ogre::UTFString>(output));
+                this->consoleOverlayTextAreas_[index]->setCaption(multi_cast<Ogre::DisplayString>(output));
             }
         }
@@ -506,5 +508,5 @@
             this->bActive_ = true;
             InputManager::getInstance().enterState("console");
-            Shell::getInstance().registerListener(this);
+            this->shell_->registerListener(this);
 
             this->windowResized(this->windowW_, this->windowH_);
@@ -528,5 +530,5 @@
             this->bActive_ = false;
             InputManager::getInstance().leaveState("console");
-            Shell::getInstance().unregisterListener(this);
+            this->shell_->unregisterListener(this);
 
             // scroll up
@@ -549,46 +551,44 @@
     }
 
-    void InGameConsole::colourLine(int colourcode, int index)
-    {
-        if (colourcode == -1)
-        {
-            this->consoleOverlayTextAreas_[index]->setColourTop   (ColourValue(0.90, 0.90, 0.90, 1.00));
-            this->consoleOverlayTextAreas_[index]->setColourBottom(ColourValue(1.00, 1.00, 1.00, 1.00));
-        }
-        else if (colourcode == 1)
-        {
-            this->consoleOverlayTextAreas_[index]->setColourTop   (ColourValue(0.95, 0.25, 0.25, 1.00));
-            this->consoleOverlayTextAreas_[index]->setColourBottom(ColourValue(1.00, 0.50, 0.50, 1.00));
-        }
-        else if (colourcode == 2)
-        {
-            this->consoleOverlayTextAreas_[index]->setColourTop   (ColourValue(0.95, 0.50, 0.20, 1.00));
-            this->consoleOverlayTextAreas_[index]->setColourBottom(ColourValue(1.00, 0.70, 0.50, 1.00));
-        }
-        else if (colourcode == 3)
-        {
-            this->consoleOverlayTextAreas_[index]->setColourTop   (ColourValue(0.50, 0.50, 0.95, 1.00));
-            this->consoleOverlayTextAreas_[index]->setColourBottom(ColourValue(0.80, 0.80, 1.00, 1.00));
-        }
-        else if (colourcode == 4)
-        {
-            this->consoleOverlayTextAreas_[index]->setColourTop   (ColourValue(0.65, 0.48, 0.44, 1.00));
-            this->consoleOverlayTextAreas_[index]->setColourBottom(ColourValue(1.00, 0.90, 0.90, 1.00));
-        }
-        else if (colourcode == 5)
-        {
-            this->consoleOverlayTextAreas_[index]->setColourTop   (ColourValue(0.40, 0.20, 0.40, 1.00));
-            this->consoleOverlayTextAreas_[index]->setColourBottom(ColourValue(0.80, 0.60, 0.80, 1.00));
-        }
-        else
-        {
-            this->consoleOverlayTextAreas_[index]->setColourTop   (ColourValue(0.21, 0.69, 0.21, 1.00));
-            this->consoleOverlayTextAreas_[index]->setColourBottom(ColourValue(0.80, 1.00, 0.80, 1.00));
-        }
-    }
-
-    // ###############################
-    // ###      satic methods      ###
-    // ###############################
+    void InGameConsole::colourLine(Shell::LineType type, int index)
+    {
+        ColourValue colourTop, colourBottom;
+        switch (type)
+        {
+        case Shell::Error:   colourTop = ColourValue(0.95, 0.25, 0.25, 1.00);
+                          colourBottom = ColourValue(1.00, 0.50, 0.50, 1.00); break;
+
+        case Shell::Warning: colourTop = ColourValue(0.95, 0.50, 0.20, 1.00);
+                          colourBottom = ColourValue(1.00, 0.70, 0.50, 1.00); break;
+
+        case Shell::Info:    colourTop = ColourValue(0.50, 0.50, 0.95, 1.00);
+                          colourBottom = ColourValue(0.80, 0.80, 1.00, 1.00); break;
+
+        case Shell::Debug:   colourTop = ColourValue(0.65, 0.48, 0.44, 1.00);
+                          colourBottom = ColourValue(1.00, 0.90, 0.90, 1.00); break;
+
+        case Shell::Verbose: colourTop = ColourValue(0.40, 0.20, 0.40, 1.00);
+                          colourBottom = ColourValue(0.80, 0.60, 0.80, 1.00); break;
+
+        case Shell::Ultra:   colourTop = ColourValue(0.21, 0.69, 0.21, 1.00);
+                          colourBottom = ColourValue(0.80, 1.00, 0.80, 1.00); break;
+
+        case Shell::Command: colourTop = ColourValue(0.80, 0.80, 0.80, 1.00);
+                          colourBottom = ColourValue(0.90, 0.90, 0.90, 0.90); break;
+
+        case Shell::Hint:    colourTop = ColourValue(0.80, 0.80, 0.80, 1.00);
+                          colourBottom = ColourValue(0.90, 0.90, 0.90, 1.00); break;
+
+        default:             colourTop = ColourValue(0.90, 0.90, 0.90, 1.00);
+                          colourBottom = ColourValue(1.00, 1.00, 1.00, 1.00); break;
+        }
+
+        this->consoleOverlayTextAreas_[index]->setColourTop   (colourTop);
+        this->consoleOverlayTextAreas_[index]->setColourBottom(colourBottom);
+    }
+
+    // ################################
+    // ###      static methods      ###
+    // ################################
 
     /**
Index: code/branches/pickup2/src/orxonox/overlays/InGameConsole.h
===================================================================
--- code/branches/pickup2/src/orxonox/overlays/InGameConsole.h	(revision 5942)
+++ code/branches/pickup2/src/orxonox/overlays/InGameConsole.h	(revision 6412)
@@ -52,5 +52,5 @@
         void setConfigValues();
 
-        void update(const Clock& time);
+        void preUpdate(const Clock& time);
 
         static void openConsole();
@@ -68,10 +68,11 @@
         void inputChanged();
         void cursorChanged();
+        void executed();
         void exit();
 
         void shiftLines();
-        void colourLine(int colourcode, int index);
+        void colourLine(Shell::LineType type, int index);
         void setCursorPosition(unsigned int pos);
-        void print(const std::string& text, int index, bool alwaysShift = false);
+        void print(const std::string& text, Shell::LineType type, int index, bool alwaysShift = false);
 
         void windowResized(unsigned int newWidth, unsigned int newHeight);
@@ -81,4 +82,5 @@
 
     private: // variables
+        Shell* shell_;
         bool bActive_;
         int windowW_;
Index: code/branches/pickup2/src/orxonox/overlays/Map.cc
===================================================================
--- code/branches/pickup2/src/orxonox/overlays/Map.cc	(revision 5942)
+++ code/branches/pickup2/src/orxonox/overlays/Map.cc	(revision 6412)
@@ -49,4 +49,5 @@
 #include <OgreViewport.h>
 
+#include "util/StringUtils.h"
 #include "core/ConsoleCommand.h"
 #include "core/CoreIncludes.h"
@@ -94,9 +95,6 @@
 
         //Getting Scene Manager (Hack)
-        if( !sManager_ )
-        {
-            ObjectList<Scene>::iterator it = ObjectList<Scene>::begin();
-            this->sManager_ = it->getSceneManager();
-        }
+        ObjectList<Scene>::iterator it = ObjectList<Scene>::begin();
+        this->sManager_ = it->getSceneManager();
         if( !Map::getMapSceneManager() )
         {
Index: code/branches/pickup2/src/orxonox/overlays/OrxonoxOverlay.cc
===================================================================
--- code/branches/pickup2/src/orxonox/overlays/OrxonoxOverlay.cc	(revision 5942)
+++ code/branches/pickup2/src/orxonox/overlays/OrxonoxOverlay.cc	(revision 6412)
@@ -39,12 +39,16 @@
 #include <OgrePanelOverlayElement.h>
 #include <OgreRenderWindow.h>
+#include <OgreMaterialManager.h>
+#include <OgreTechnique.h>
+#include <OgrePass.h>
 
 #include "util/Convert.h"
 #include "util/Exception.h"
-#include "util/StringUtils.h"
 #include "core/GameMode.h"
 #include "core/CoreIncludes.h"
 #include "core/XMLPort.h"
 #include "core/ConsoleCommand.h"
+
+#include "OverlayGroup.h"
 
 namespace orxonox
@@ -81,13 +85,13 @@
         // Get aspect ratio from the render window. Later on, we get informed automatically
         this->windowAspectRatio_ = static_cast<float>(this->getWindowWidth()) / this->getWindowHeight();
-        this->sizeCorrectionChanged();
-
-        this->changedVisibility();
-
-        setSize(Vector2(1.0f, 1.0f));
-        setPickPoint(Vector2(0.0f, 0.0f));
-        setPosition(Vector2(0.0f, 0.0f));
-        setRotation(Degree(0.0));
-        setAspectCorrection(false);
+
+        this->size_ = Vector2(1.0f, 1.0f);
+        this->pickPoint_= Vector2(0.0f, 0.0f);
+        this->position_ = Vector2(0.0f, 0.0f);
+        this->angle_ = Degree(0.0);
+        this->bCorrectAspect_ = false;
+        this->rotState_ = Horizontal;
+        this->angleChanged(); // updates all other values as well
+
         setBackgroundMaterial("");
     }
@@ -141,5 +145,5 @@
 
         if (OrxonoxOverlay::overlays_s.find(this->getName()) != OrxonoxOverlay::overlays_s.end())
-            COUT(1) << "Overlay names should be unique or you cannnot access them via console. Name: \"" << this->getName() << "\"" << std::endl;
+            COUT(1) << "Overlay names should be unique or you cannnot access them via console. Name: \"" << this->getName() << '"' << std::endl;
 
         OrxonoxOverlay::overlays_s[this->getName()] = this;
@@ -149,5 +153,5 @@
     void OrxonoxOverlay::setBackgroundMaterial(const std::string& material)
     {
-        if (this->background_ && material != "")
+        if (this->background_ && !material.empty())
             this->background_->setMaterialName(material);
     }
@@ -165,8 +169,11 @@
     void OrxonoxOverlay::changedVisibility()
     {
+        SUPER( OrxonoxOverlay, changedVisibility );
+
         if (!this->overlay_)
             return;
 
-        if (this->isVisible())
+        // only set to visible if corresponding OverlayGroup is also visible
+        if (this->isVisible() && (!this->getOverlayGroup() || this->getOverlayGroup()->isVisible()) )
             this->overlay_->show();
         else
@@ -304,5 +311,5 @@
         std::map<std::string, OrxonoxOverlay*>::const_iterator it = overlays_s.find(name);
         if (it != overlays_s.end())
-            (*it).second->scale(Vector2(scale, scale));
+            it->second->scale(Vector2(scale, scale));
     }
 
@@ -319,5 +326,5 @@
         if (it != overlays_s.end())
         {
-            OrxonoxOverlay* overlay= (*it).second;
+            OrxonoxOverlay* overlay= it->second;
             if(overlay->isVisible())
                 overlay->hide();
@@ -338,5 +345,5 @@
         std::map<std::string, OrxonoxOverlay*>::const_iterator it = overlays_s.find(name);
         if (it != overlays_s.end())
-            (*it).second->scroll(scroll);
+            it->second->scroll(scroll);
     }
 
@@ -352,5 +359,22 @@
         std::map<std::string, OrxonoxOverlay*>::const_iterator it = overlays_s.find(name);
         if (it != overlays_s.end())
-            (*it).second->rotate(angle);
+            it->second->rotate(angle);
+    }
+
+    void OrxonoxOverlay::setOverlayGroup(OverlayGroup* group)
+    {
+        if (group != this->group_)
+        {
+            if (this->group_)
+                this->group_->removeElement(this);
+            this->group_ = group;
+            this->changedOverlayGroup();
+        }
+    }
+
+    void OrxonoxOverlay::setBackgroundAlpha(float alpha) {
+        Ogre::MaterialPtr ptr = this->background_->getMaterial();
+        Ogre::TextureUnitState* tempTx = ptr->getTechnique(0)->getPass(0)->getTextureUnitState(0);
+        tempTx->setAlphaOperation(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, alpha);
     }
 }
Index: code/branches/pickup2/src/orxonox/overlays/OrxonoxOverlay.h
===================================================================
--- code/branches/pickup2/src/orxonox/overlays/OrxonoxOverlay.h	(revision 5942)
+++ code/branches/pickup2/src/orxonox/overlays/OrxonoxOverlay.h	(revision 6412)
@@ -155,4 +155,9 @@
         static void rotateOverlay(const std::string& name, const Degree& angle);
 
+        void setBackgroundMaterial(const std::string& material);
+        const std::string& getBackgroundMaterial() const;
+
+        void setBackgroundAlpha(float alpha);
+
         virtual void changedVisibility();
 
@@ -169,15 +174,9 @@
         virtual void changedOwner() {}
 
-        inline void setOverlayGroup(OverlayGroup* group)
-        {
-            if (group != this->group_)
-            {
-                this->group_ = group;
-                this->changedOverlayGroup();
-            }
-        }
+        void setOverlayGroup(OverlayGroup* group);
         inline OverlayGroup* getOverlayGroup() const
             { return this->group_; }
-        virtual void changedOverlayGroup() {}
+        virtual void changedOverlayGroup()
+            { this->changedVisibility(); }
 
     protected:
@@ -186,7 +185,4 @@
         virtual void sizeChanged();
         virtual void positionChanged();
-
-        void setBackgroundMaterial(const std::string& material);
-        const std::string& getBackgroundMaterial() const;
 
         Ogre::Overlay* overlay_;                   //!< The overlay the entire class is about.
@@ -211,4 +207,5 @@
         BaseObject* owner_;
         OverlayGroup* group_;
+        Ogre::Pass* backgroundAlphaPass_;
   };
 
Index: code/branches/pickup2/src/orxonox/overlays/OverlayGroup.cc
===================================================================
--- code/branches/pickup2/src/orxonox/overlays/OverlayGroup.cc	(revision 5942)
+++ code/branches/pickup2/src/orxonox/overlays/OverlayGroup.cc	(revision 6412)
@@ -60,6 +60,7 @@
     OverlayGroup::~OverlayGroup()
     {
-        for (std::set<OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
+        for (std::set< SmartPtr<OrxonoxOverlay> >::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
             (*it)->destroy();
+        this->hudElements_.clear();
     }
 
@@ -83,5 +84,5 @@
     void OverlayGroup::setScale(const Vector2& scale)
     {
-        for (std::set<OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
+        for (std::set< SmartPtr<OrxonoxOverlay> >::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
             (*it)->scale(scale / this->scale_);
         this->scale_ = scale;
@@ -91,5 +92,5 @@
     void OverlayGroup::setScroll(const Vector2& scroll)
     {
-        for (std::set<OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
+        for (std::set< SmartPtr<OrxonoxOverlay> >::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
             (*it)->scroll(scroll - this->scroll_);
         this->scroll_ = scroll;
@@ -104,6 +105,6 @@
     void OverlayGroup::addElement(OrxonoxOverlay* element)
     {
-        hudElements_.insert(element);
-        element->setVisible(this->isVisible());
+        hudElements_.insert(SmartPtr<OrxonoxOverlay>(element));
+        element->setOverlayGroup( this );
         if (this->owner_)
             element->setOwner(this->owner_);
@@ -120,5 +121,5 @@
     bool OverlayGroup::removeElement(OrxonoxOverlay* element)
     {
-        if(this->hudElements_.erase(element) == 0)
+        if(this->hudElements_.erase(SmartPtr<OrxonoxOverlay>(element)) == 0)
             return false;
         return true;
@@ -130,8 +131,8 @@
         if (index < this->hudElements_.size())
         {
-            std::set<OrxonoxOverlay*>::const_iterator it = hudElements_.begin();
+            std::set< SmartPtr<OrxonoxOverlay> >::const_iterator it = hudElements_.begin();
             for (unsigned int i = 0; i != index; ++it, ++i)
                 ;
-            return (*it);
+            return it->get();
         }
         else
@@ -142,6 +143,8 @@
     void OverlayGroup::changedVisibility()
     {
-        for (std::set<OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
-            (*it)->setVisible(this->isVisible());
+        SUPER( OverlayGroup, changedVisibility );
+
+        for (std::set< SmartPtr<OrxonoxOverlay> >::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
+            (*it)->changedVisibility(); //inform all Child Overlays that our visibility has changed
     }
 
@@ -150,5 +153,5 @@
         this->owner_ = owner;
 
-        for (std::set<OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
+        for (std::set< SmartPtr<OrxonoxOverlay> >::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
             (*it)->setOwner(owner);
     }
Index: code/branches/pickup2/src/orxonox/overlays/OverlayGroup.h
===================================================================
--- code/branches/pickup2/src/orxonox/overlays/OverlayGroup.h	(revision 5942)
+++ code/branches/pickup2/src/orxonox/overlays/OverlayGroup.h	(revision 6412)
@@ -64,5 +64,5 @@
         static void scrollGroup(const std::string& name, const Vector2& scroll);
 
-        inline const std::set<OrxonoxOverlay*>& getOverlays() const
+        inline const std::set< SmartPtr<OrxonoxOverlay> >& getOverlays() const
             { return this->hudElements_; }
 
@@ -90,5 +90,5 @@
 
     private:
-        std::set<OrxonoxOverlay*> hudElements_;    //!< Contains all the OrxonoxOverlays of the this group.
+        std::set< SmartPtr<OrxonoxOverlay> > hudElements_;    //!< Contains all the OrxonoxOverlays of the this group.
         Vector2 scale_;                            //!< Current scale (independent of the elements).
         Vector2 scroll_;                           //!< Current scrolling offset.
