Index: code/trunk/src/orxonox/Orxonox.cc
===================================================================
--- code/trunk/src/orxonox/Orxonox.cc	(revision 1576)
+++ code/trunk/src/orxonox/Orxonox.cc	(revision 1577)
@@ -70,4 +70,5 @@
 // objects and tools
 #include "hud/HUD.h"
+#include "console/InGameConsole.h"
 #include "objects/Tickable.h"
 #include "tools/ParticleInterface.h"
@@ -76,8 +77,7 @@
 #include "Settings.h"
 
-// FIXME: is this really file scope?
 // globals for the server or client
-network::Client *client_g = 0;
-network::Server *server_g = 0;
+static network::Client *client_g = 0;
+static network::Server *server_g = 0;
 
 namespace orxonox
@@ -121,4 +121,5 @@
     //if (this->auMan_)
     //  delete this->auMan_;
+    InGameConsole::getInstance().destroy();
     if (this->timer_)
       delete this->timer_;
@@ -263,4 +264,11 @@
         return false;
 
+      // TODO: Spread this so that this call only initialises things needed for the Console
+      if (!ogre_->initialiseResources())
+        return false;
+
+      // Load the InGameConsole
+      InGameConsole::getInstance().initialise();
+
       // Calls the InputManager which sets up the input devices.
       // The render window width and height are used to set up the mouse movement.
@@ -269,8 +277,4 @@
         return false;
 
-      // TODO: Spread this so that this call only initialises things needed for the GUI
-      if (!ogre_->initialiseResources())
-        return false;
-
       // TOOD: load the GUI here
       // set InputManager to GUI mode
@@ -315,5 +319,5 @@
   /**
    * Loads everything in the scene except for the actual objects.
-   * This includes HUD, Console..
+   * This includes HUD, audio..
    */
   bool Orxonox::loadPlayground()
@@ -331,4 +335,5 @@
     orxonoxHUD_ = &HUD::getSingleton();
     orxonoxHUD_->initialise();
+
     return true;
   }
@@ -339,5 +344,5 @@
   bool Orxonox::serverLoad()
   {
-    COUT(2) << "Loading level in server mode" << std::endl;
+    COUT(0) << "Loading level in server mode" << std::endl;
 
     //server_g = new network::Server(serverPort_);
@@ -357,5 +362,5 @@
   bool Orxonox::clientLoad()
   {
-    COUT(2) << "Loading level in client mode" << std::endl;\
+    COUT(0) << "Loading level in client mode" << std::endl;\
 
     if (serverIp_.compare("") == 0)
@@ -377,5 +382,5 @@
   bool Orxonox::standaloneLoad()
   {
-    COUT(2) << "Loading level in standalone mode" << std::endl;
+    COUT(0) << "Loading level in standalone mode" << std::endl;
 
     if (!loadScene())
@@ -500,5 +505,5 @@
       // again, just to be sure ogre works fine
       ogreRoot._fireFrameEnded(evt);
-      //msleep(200);
+      //msleep(500);
     }
 
Index: code/trunk/src/orxonox/console/InGameConsole.cc
===================================================================
--- code/trunk/src/orxonox/console/InGameConsole.cc	(revision 1576)
+++ code/trunk/src/orxonox/console/InGameConsole.cc	(revision 1577)
@@ -47,7 +47,5 @@
 
 #define LINES 30
-#define CHAR_WIDTH1 7.45 //78 //34 // fix this please - determine the char-width dynamically
-#define CHAR_WIDTH2 CHAR_WIDTH1 //28 // fix this please - determine the char-width dynamically
-#define CHAR_WIDTH3 CHAR_WIDTH1 //80 //78 // fix this please - determine the char-width dynamically
+#define CHAR_WIDTH 7.45 // fix this please - determine the char-width dynamically
 
 namespace orxonox
@@ -58,27 +56,23 @@
     using namespace Ogre;
 
-    float InGameConsole::REL_WIDTH = 0.8;
-    float InGameConsole::REL_HEIGHT = 0.4;
-    float InGameConsole::BLINK = 0.5;
-
     /**
         @brief Constructor: Creates and initializes the InGameConsole.
     */
     InGameConsole::InGameConsole() :
-        om_(0), consoleOverlay_(0), consoleOverlayContainer_(0),
-        consoleOverlayNoise_(0), consoleOverlayBorder_(0), consoleOverlayTextAreas_(0)
+        consoleOverlay_(0), consoleOverlayContainer_(0),
+        consoleOverlayNoise_(0), consoleOverlayCursor_(0), consoleOverlayBorder_(0),
+        consoleOverlayTextAreas_(0)
     {
         RegisterObject(InGameConsole);
 
         this->bActive_ = false;
-        this->cursor_ = 0.0;
+        this->cursor_ = 0.0f;
         this->cursorSymbol_ = '|';
         this->inputWindowStart_ = 0;
         this->numLinesShifted_ = LINES - 1;
-
-        this->init();
+        // for the beginning, don't scroll
+        this->scroll_ = 0;
+
         this->setConfigValues();
-
-        Shell::getInstance().addOutputLevel(true);
     }
 
@@ -88,10 +82,5 @@
     InGameConsole::~InGameConsole(void)
     {
-        /*for (int i = 0; i < LINES; i++)
-            if (this->consoleOverlayTextAreas_[i])
-                om_->destroyOverlayElement(this->consoleOverlayTextAreas_[i]);
-
-        if (this->consoleOverlayTextAreas_)
-            delete[] this->consoleOverlayTextAreas_;*/
+        this->destroy();
     }
 
@@ -110,111 +99,33 @@
     void InGameConsole::setConfigValues()
     {
-        SetConfigValue(REL_WIDTH, 0.8);
-        SetConfigValue(REL_HEIGHT, 0.4);
-        SetConfigValue(BLINK, 0.5);
-    }
-
-    /**
-        @brief Called if all output-lines have to be redrawn.
-    */
-    void InGameConsole::linesChanged()
-    {
-        std::list<std::string>::const_iterator it = Shell::getInstance().getNewestLineIterator();
-        int max = 0;
-        for (int i = 1; i < LINES; ++i)
-        {
-            if (it != Shell::getInstance().getEndIterator())
-            {
-                ++it;
-                max = i;
-            }
-            else
-                break;
-        }
-
-        for (int i = LINES - 1; i > max; --i)
-            this->print("", i, true);
-
-        for (int i = max; i >= 1; --i)
-        {
-            --it;
-            this->print(*it, i, true);
-        }
-    }
-
-    /**
-        @brief Called if only the last output-line has changed.
-    */
-    void InGameConsole::onlyLastLineChanged()
-    {
-        if (LINES > 1)
-            this->print(*Shell::getInstance().getNewestLineIterator(), 1);
-    }
-
-    /**
-        @brief Called if a new output-line was added.
-    */
-    void InGameConsole::lineAdded()
-    {
-        this->numLinesShifted_ = 0;
-        this->shiftLines();
-        this->onlyLastLineChanged();
-    }
-
-    /**
-        @brief Called if the text in the input-line has changed.
-    */
-    void InGameConsole::inputChanged()
-    {
-        if (LINES > 0)
-            this->print(Shell::getInstance().getInput(), 0);
-
-        if (Shell::getInstance().getInput() == "" || Shell::getInstance().getInput().size() == 0)
-            this->inputWindowStart_ = 0;
-    }
-
-    /**
-        @brief Called if the position of the cursor in the input-line has changed.
-    */
-    void InGameConsole::cursorChanged()
-    {
-        /*std::string input = Shell::getInstance().getInput();
-        input.insert(Shell::getInstance().getCursorPosition(), 1, this->cursorSymbol_);
-        if (LINES > 0)
-            this->print(input, 0);*/
-        this->setCursorPosition(Shell::getInstance().getCursorPosition() - inputWindowStart_);
-    }
-
-    /**
-        @brief Called if the console gets closed.
-    */
-    void InGameConsole::exit()
-    {
-        this->deactivate();
-    }
-
-    /**
-        @brief Called once by constructor, initializes the InGameConsole.
-    */
-    void InGameConsole::init()
-    {
-        // for the beginning, don't scroll
-        this->scroll_ = 0;
-        this->cursor_ = 0;
-
+        SetConfigValue(relativeWidth, 0.8);
+        SetConfigValue(relativeHeight, 0.4);
+        SetConfigValue(blinkTime, 0.5);
+        SetConfigValue(scrollSpeed_, 3.0f);
+        SetConfigValue(noiseSize_, 1.0f);
+    }
+
+    /**
+        @brief Initializes the InGameConsole.
+    */
+    void InGameConsole::initialise()
+    {
         // create overlay and elements
-        this->om_ = &Ogre::OverlayManager::getSingleton();
+        Ogre::OverlayManager* ovMan = Ogre::OverlayManager::getSingletonPtr();
+
+        // create actual overlay
+        this->consoleOverlay_ = ovMan->create("InGameConsoleConsole");
 
         // create a container
-        this->consoleOverlayContainer_ = static_cast<OverlayContainer*>(this->om_->createOverlayElement("Panel", "InGameConsoleContainer"));
+        this->consoleOverlayContainer_ = static_cast<OverlayContainer*>(ovMan->createOverlayElement("Panel", "InGameConsoleContainer"));
         this->consoleOverlayContainer_->setMetricsMode(Ogre::GMM_RELATIVE);
-        this->consoleOverlayContainer_->setPosition((1 - InGameConsole::REL_WIDTH) / 2, 0);
-        this->consoleOverlayContainer_->setDimensions(InGameConsole::REL_WIDTH, InGameConsole::REL_HEIGHT);
+        this->consoleOverlayContainer_->setPosition((1 - this->relativeWidth) / 2, 0);
+        this->consoleOverlayContainer_->setDimensions(this->relativeWidth, this->relativeHeight);
+        this->consoleOverlay_->add2D(this->consoleOverlayContainer_);
 
         // create BorderPanel
-        this->consoleOverlayBorder_ = static_cast<BorderPanelOverlayElement*>(this->om_->createOverlayElement("BorderPanel", "InGameConsoleBorderPanel"));
+        this->consoleOverlayBorder_ = static_cast<BorderPanelOverlayElement*>(ovMan->createOverlayElement("BorderPanel", "InGameConsoleBorderPanel"));
         this->consoleOverlayBorder_->setMetricsMode(Ogre::GMM_PIXELS);
         this->consoleOverlayBorder_->setMaterialName("ConsoleCenter");
-        // set parameters for border
         this->consoleOverlayBorder_->setBorderSize(16, 16, 0, 16);
         this->consoleOverlayBorder_->setBorderMaterialName("ConsoleBorder");
@@ -224,4 +135,5 @@
         this->consoleOverlayBorder_->setBottomLeftBorderUV(0.0, 0.5, 0.5, 1.0);
         this->consoleOverlayBorder_->setBottomRightBorderUV(0.5, 0.5, 1.0, 1.0);
+        this->consoleOverlayContainer_->addChild(this->consoleOverlayBorder_);
 
         // create the text lines
@@ -229,5 +141,5 @@
         for (int i = 0; i < LINES; i++)
         {
-            this->consoleOverlayTextAreas_[i] = static_cast<TextAreaOverlayElement*>(this->om_->createOverlayElement("TextArea", "InGameConsoleTextArea" + Ogre::StringConverter::toString(i)));
+            this->consoleOverlayTextAreas_[i] = static_cast<TextAreaOverlayElement*>(ovMan->createOverlayElement("TextArea", "InGameConsoleTextArea" + Ogre::StringConverter::toString(i)));
             this->consoleOverlayTextAreas_[i]->setMetricsMode(Ogre::GMM_PIXELS);
             this->consoleOverlayTextAreas_[i]->setFontName("Monofur");
@@ -236,35 +148,32 @@
             this->consoleOverlayTextAreas_[i]->setLeft(8);
             this->consoleOverlayTextAreas_[i]->setCaption("");
-        }
+            this->consoleOverlayContainer_->addChild(this->consoleOverlayTextAreas_[i]);
+        }
+
+        // create cursor (also a text area overlay element)
+        this->consoleOverlayCursor_ = static_cast<TextAreaOverlayElement*>(ovMan->createOverlayElement("TextArea", "InGameConsoleTextArea" + Ogre::StringConverter::toString(i)));
+        this->consoleOverlayCursor_->setMetricsMode(Ogre::GMM_PIXELS);
+        this->consoleOverlayCursor_->setFontName("Monofur");
+        this->consoleOverlayCursor_->setCharHeight(18);
+        this->consoleOverlayCursor_->setParameter("colour_top", "0.21 0.69 0.21");
+        this->consoleOverlayCursor_->setLeft(7);
+        this->consoleOverlayCursor_->setCaption("|");
+        this->consoleOverlayContainer_->addChild(this->consoleOverlayCursor_);
 
         // create noise
-        this->consoleOverlayNoise_ = static_cast<PanelOverlayElement*>(this->om_->createOverlayElement("Panel", "InGameConsoleNoise"));
+        this->consoleOverlayNoise_ = static_cast<PanelOverlayElement*>(ovMan->createOverlayElement("Panel", "InGameConsoleNoise"));
         this->consoleOverlayNoise_->setMetricsMode(Ogre::GMM_PIXELS);
         this->consoleOverlayNoise_->setPosition(5,0);
-        this->consoleOverlayNoise_->setMaterialName("ConsoleNoise");
-
-        // create cursor
-        this->consoleOverlayCursor_ = static_cast<PanelOverlayElement*>(this->om_->createOverlayElement("Panel", "InGameConsoleCursor"));
-        this->consoleOverlayCursor_->setMetricsMode(Ogre::GMM_PIXELS);
-        this->consoleOverlayCursor_->setPosition(5,219);
-        this->consoleOverlayCursor_->setDimensions(1, 14);
-        this->consoleOverlayCursor_->setMaterialName("Orxonox/GreenDot");
-
-        this->consoleOverlay_ = this->om_->create("InGameConsoleConsole");
-        this->consoleOverlay_->add2D(this->consoleOverlayContainer_);
-        this->consoleOverlayContainer_->addChild(this->consoleOverlayBorder_);
-        this->consoleOverlayContainer_->addChild(this->consoleOverlayCursor_);
-        //comment following line to disable noise
+        this->consoleOverlayNoise_->setMaterialName("ConsoleNoiseSmall");
+        // comment following line to disable noise
         this->consoleOverlayContainer_->addChild(this->consoleOverlayNoise_);
-        for (int i = 0; i < LINES; i++)
-            this->consoleOverlayContainer_->addChild(this->consoleOverlayTextAreas_[i]);
 
         this->resize();
 
         // move overlay "above" the top edge of the screen
-        // we take -1.2 because the border mkes the panel bigger
-        this->consoleOverlayContainer_->setTop(-1.2 * InGameConsole::REL_HEIGHT);
-        // show overlay
-        this->consoleOverlay_->show();
+        // we take -1.2 because the border makes the panel bigger
+        this->consoleOverlayContainer_->setTop(-1.2 * this->relativeHeight);
+
+        Shell::getInstance().addOutputLevel(true);
 
         COUT(4) << "Info: InGameConsole initialized" << std::endl;
@@ -272,32 +181,126 @@
 
     /**
-        @brief Resizes the console elements. Call if window size changes.
-    */
-    void InGameConsole::resize()
-    {
-        this->windowW_ = GraphicsEngine::getSingleton().getWindowWidth();
-        this->windowH_ = GraphicsEngine::getSingleton().getWindowHeight();
-        this->consoleOverlayBorder_->setWidth((int) this->windowW_* InGameConsole::REL_WIDTH);
-        this->consoleOverlayBorder_->setHeight((int) this->windowH_ * InGameConsole::REL_HEIGHT);
-        this->consoleOverlayNoise_->setWidth((int) this->windowW_ * InGameConsole::REL_WIDTH - 10);
-        this->consoleOverlayNoise_->setHeight((int) this->windowH_ * InGameConsole::REL_HEIGHT - 5);
-
-        // now adjust the text lines...
-        this->desiredTextWidth_ = (int) (this->windowW_ * InGameConsole::REL_WIDTH) - 12;
-
+        @brief Destroys all the elements if necessary.
+    */
+    void InGameConsole::destroy()
+    {
+        Ogre::OverlayManager* ovMan = Ogre::OverlayManager::getSingletonPtr();
+        if (ovMan)
+        {
+            if (this->consoleOverlayNoise_)
+                Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->consoleOverlayNoise_);
+            if (this->consoleOverlayCursor_)
+                Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->consoleOverlayCursor_);
+            if (this->consoleOverlayBorder_)
+                Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->consoleOverlayBorder_);
+            if (this->consoleOverlayTextAreas_)
+            {
+                for (int i = 0; i < LINES; i++)
+                {
+                    if (this->consoleOverlayTextAreas_[i])
+                      Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->consoleOverlayTextAreas_[i]);
+                    this->consoleOverlayTextAreas_[i] = 0;
+                }
+
+            }
+            if (this->consoleOverlayContainer_)
+                Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->consoleOverlayContainer_);
+        }
+        if (this->consoleOverlayTextAreas_)
+        {
+            delete[] this->consoleOverlayTextAreas_;
+            this->consoleOverlayTextAreas_ = 0;
+        }
+    }
+
+    // ###############################
+    // ###  ShellListener methods  ###
+    // ###############################
+
+    /**
+        @brief Called if all output-lines have to be redrawn.
+    */
+    void InGameConsole::linesChanged()
+    {
+        std::list<std::string>::const_iterator it = Shell::getInstance().getNewestLineIterator();
+        int max = 0;
+        for (int i = 1; i < LINES; ++i)
+        {
+            if (it != Shell::getInstance().getEndIterator())
+            {
+                ++it;
+                max = i;
+            }
+            else
+                break;
+        }
+
+        for (int i = LINES - 1; i > max; --i)
+            this->print("", i, true);
+
+        for (int i = max; i >= 1; --i)
+        {
+            --it;
+            this->print(*it, i, true);
+        }
+    }
+
+    /**
+        @brief Called if only the last output-line has changed.
+    */
+    void InGameConsole::onlyLastLineChanged()
+    {
+        if (LINES > 1)
+            this->print(*Shell::getInstance().getNewestLineIterator(), 1);
+    }
+
+    /**
+        @brief Called if a new output-line was added.
+    */
+    void InGameConsole::lineAdded()
+    {
+        this->numLinesShifted_ = 0;
+        this->shiftLines();
+        this->onlyLastLineChanged();
+    }
+
+    /**
+        @brief Called if the text in the input-line has changed.
+    */
+    void InGameConsole::inputChanged()
+    {
         if (LINES > 0)
-            this->maxCharsPerLine_ = max((unsigned int)10, (unsigned int) ((float)this->desiredTextWidth_ / CHAR_WIDTH3));
-        else
-            this->maxCharsPerLine_ = 10;
-
-        for (int i = 0; i < LINES; i++)
-        {
-            this->consoleOverlayTextAreas_[i]->setWidth(this->desiredTextWidth_);
-            this->consoleOverlayTextAreas_[i]->setTop((int) this->windowH_ * InGameConsole::REL_HEIGHT - 24 - 14*i);
-        }
-
-        this->linesChanged();
-        this->cursorChanged();
-    }
+            this->print(Shell::getInstance().getInput(), 0);
+
+        if (Shell::getInstance().getInput() == "" || Shell::getInstance().getInput().size() == 0)
+            this->inputWindowStart_ = 0;
+    }
+
+    /**
+        @brief Called if the position of the cursor in the input-line has changed.
+    */
+    void InGameConsole::cursorChanged()
+    {
+        unsigned int pos = Shell::getInstance().getCursorPosition() - inputWindowStart_;
+        if (pos > maxCharsPerLine_)
+            pos = maxCharsPerLine_;
+        else if (pos < 0)
+            pos = 0;
+
+        this->consoleOverlayCursor_->setCaption(std::string(pos,' ') + cursorSymbol_);
+        this->consoleOverlayCursor_->setTop((int) this->windowH_ * this->relativeHeight - 24);
+    }
+
+    /**
+        @brief Called if the console gets closed.
+    */
+    void InGameConsole::exit()
+    {
+        this->deactivate();
+    }
+
+    // ###############################
+    // ###  other external calls   ###
+    // ###############################
 
     /**
@@ -308,19 +311,36 @@
         if (this->scroll_ != 0)
         {
-            float top = this->consoleOverlayContainer_->getTop() + dt * this->scroll_;
-            this->consoleOverlayContainer_->setTop(top);
-
-            if (this->scroll_ < 0 && top <= -1.2 * InGameConsole::REL_HEIGHT)
-            {
-                // window has completely scrolled up
-                this->scroll_ = 0;
-                this->consoleOverlay_->hide();
-            }
-
-            if (this->scroll_ > 0 && top >= 0)
-            {
-                // window has completely scrolled down
-                this->scroll_ = 0;
-                this->consoleOverlayContainer_->setTop(0);
+            float oldTop = this->consoleOverlayContainer_->getTop();
+
+            if (this->scroll_ > 0)
+            {
+                // scrolling down
+                // enlarge oldTop a little bit so that this exponential function
+                // reaches 0 before infinite time has passed...
+                float deltaScroll = (oldTop - 0.01) * dt * this->scrollSpeed_;
+                if (oldTop - deltaScroll >= 0)
+                {
+                    // window has completely scrolled down
+                    this->consoleOverlayContainer_->setTop(0);
+                    this->scroll_ = 0;
+                }
+                else
+                    this->consoleOverlayContainer_->setTop(oldTop - deltaScroll);
+            }
+
+            else
+            {
+                // scrolling up
+                // note: +0.01 for the same reason as when scrolling down
+                float deltaScroll = (1.2 * this->relativeHeight + 0.01 + oldTop) * dt * this->scrollSpeed_;
+                if (oldTop - deltaScroll <= -1.2 * this->relativeHeight)
+                {
+                    // window has completely scrolled up
+                    this->consoleOverlayContainer_->setTop(-1.2 * this->relativeHeight);
+                    this->scroll_ = 0;
+                    this->consoleOverlay_->hide();
+                }
+                else
+                    this->consoleOverlayContainer_->setTop(oldTop - deltaScroll);
             }
         }
@@ -329,162 +349,55 @@
         {
             this->cursor_ += dt;
-            if (this->cursor_ >= InGameConsole::BLINK)
+            if (this->cursor_ >= this->blinkTime)
             {
                 this->cursor_ = 0;
                 bShowCursor_ = !bShowCursor_;
                 if (bShowCursor_)
-                  this->consoleOverlayCursor_->show();
+                    this->consoleOverlayCursor_->show();
                 else
-                  this->consoleOverlayCursor_->hide();
-            }
-
-            /*if (this->cursor_ >= 2 * InGameConsole::BLINK)
-              this->cursor_ = 0;
-
-            if (this->cursor_ >= InGameConsole::BLINK && this->cursorSymbol_ == '|')
-            {
-                this->cursorSymbol_ = ' ';
-                this->cursorChanged();
-            }
-            else if (this->cursor_ < InGameConsole::BLINK && this->cursorSymbol_ == ' ')
-            {
-                this->cursorSymbol_ = '|';
-                this->cursorChanged();
-            }*/
-
-            // this creates a flickering effect
-            this->consoleOverlayNoise_->setTiling(1, rand() % 5 + 1);
-        }
-    }
-
-    /**
-        @brief Shows the InGameConsole.
-    */
-    void InGameConsole::activate()
-    {
-        if (!this->bActive_)
-        {
-            this->bActive_ = true;
-            InputManager::setInputState(InputManager::IS_CONSOLE);
-            Shell::getInstance().registerListener(this);
-
-            this->resize();
-            this->linesChanged();
-            this->cursorChanged();
-            this->consoleOverlay_->show();
-
-            // scroll down
-            this->scroll_ = 1;
-            // the rest is done by tick
-        }
-    }
-
-    /**
-    @brief Hides the InGameConsole.
-    */
-    void InGameConsole::deactivate()
-    {
-        if (this->bActive_)
-        {
-            this->bActive_ = false;
-            InputManager::setInputState(InputManager::IS_NORMAL);
-            Shell::getInstance().unregisterListener(this);
-
-            // scroll up
-            this->scroll_ = -1;
-            // the rest is done by tick
-        }
-    }
-
-    /**
-        @brief Activates the console.
-    */
-    void InGameConsole::openConsole()
-    {
-        InGameConsole::getInstance().activate();
-    }
-
-    /**
-        @brief Deactivates the console.
-    */
-    void InGameConsole::closeConsole()
-    {
-        InGameConsole::getInstance().deactivate();
-    }
-
-    /**
-        @brief Shifts all output lines one line up
-    */
-    void InGameConsole::shiftLines()
-    {
-        for (unsigned int i = LINES - 1; i > 1; --i)
-        {
-            this->consoleOverlayTextAreas_[i]->setCaption(this->consoleOverlayTextAreas_[i - 1]->getCaption());
-            this->consoleOverlayTextAreas_[i]->setColourTop(this->consoleOverlayTextAreas_[i - 1]->getColourTop());
-            this->consoleOverlayTextAreas_[i]->setColourBottom(this->consoleOverlayTextAreas_[i - 1]->getColourBottom());
-        }
-    }
-
-    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));
-        }
+                    this->consoleOverlayCursor_->hide();
+            }
+
+            // this creates a flickering effect (extracts exactly 80% of the texture at a random location)
+            float uRand = (rand() & 1023) / 1023.0f * 0.2f;
+            float vRand = (rand() & 1023) / 1023.0f * 0.2f;
+            this->consoleOverlayNoise_->setUV(uRand, vRand, 0.8f + uRand, 0.8f + vRand);
+        }
+    }
+
+    /**
+        @brief Resizes the console elements. Call if window size changes.
+    */
+    void InGameConsole::resize()
+    {
+        this->windowW_ = GraphicsEngine::getSingleton().getWindowWidth();
+        this->windowH_ = GraphicsEngine::getSingleton().getWindowHeight();
+        this->consoleOverlayBorder_->setWidth((int) this->windowW_* this->relativeWidth);
+        this->consoleOverlayBorder_->setHeight((int) this->windowH_ * this->relativeHeight);
+        this->consoleOverlayNoise_->setWidth((int) this->windowW_ * this->relativeWidth - 10);
+        this->consoleOverlayNoise_->setHeight((int) this->windowH_ * this->relativeHeight - 5);
+        this->consoleOverlayNoise_->setTiling(consoleOverlayNoise_->getWidth() / 80.0f * this->noiseSize_, consoleOverlayNoise_->getHeight() / 80.0f * this->noiseSize_);
+
+        // now adjust the text lines...
+        this->desiredTextWidth_ = (int) (this->windowW_ * this->relativeWidth) - 12;
+
+        if (LINES > 0)
+            this->maxCharsPerLine_ = max((unsigned int)10, (unsigned int) ((float)this->desiredTextWidth_ / CHAR_WIDTH));
         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));
-        }
-    }
-
-    void InGameConsole::setCursorPosition(unsigned int pos)
-    {
-        static std::string char1 = "bdefgilpqtzCEGIJKNOPQT5[}äü";
-        static std::string char2 = "Z4";
-
-        if (pos > maxCharsPerLine_)
-          pos = maxCharsPerLine_;
-        else if (pos < 0)
-          pos = 0;
-
-        float width = 0;
-        for (unsigned int i = 0; i < pos && i < displayedText_.size(); ++i)
-        {
-            if (char1.find(displayedText_[i]) != std::string::npos)
-                width += CHAR_WIDTH1;
-            else if (char2.find(displayedText_[i]) != std::string::npos)
-                width += CHAR_WIDTH2;
-            else
-                width += CHAR_WIDTH3;
-        }
-        this->consoleOverlayCursor_->setPosition(width + 8, this->windowH_ * InGameConsole::REL_HEIGHT - 20);
-    }
+            this->maxCharsPerLine_ = 10;
+
+        for (int i = 0; i < LINES; i++)
+        {
+            this->consoleOverlayTextAreas_[i]->setWidth(this->desiredTextWidth_);
+            this->consoleOverlayTextAreas_[i]->setTop((int) this->windowH_ * this->relativeHeight - 24 - 14*i);
+        }
+
+        this->linesChanged();
+        this->cursorChanged();
+    }
+
+    // ###############################
+    // ###    internal methods     ###
+    // ###############################
 
     /**
@@ -544,9 +457,120 @@
 
     /**
+        @brief Shows the InGameConsole.
+    */
+    void InGameConsole::activate()
+    {
+        if (!this->bActive_)
+        {
+            this->bActive_ = true;
+            InputManager::setInputState(InputManager::IS_CONSOLE);
+            Shell::getInstance().registerListener(this);
+
+            this->resize();
+            this->linesChanged();
+            this->cursorChanged();
+            this->consoleOverlay_->show();
+
+            // scroll down
+            this->scroll_ = 1;
+            // the rest is done by tick
+        }
+    }
+
+    /**
+    @brief Hides the InGameConsole.
+    */
+    void InGameConsole::deactivate()
+    {
+        if (this->bActive_)
+        {
+            this->bActive_ = false;
+            InputManager::setInputState(InputManager::IS_NORMAL);
+            Shell::getInstance().unregisterListener(this);
+
+            // scroll up
+            this->scroll_ = -1;
+            // the rest is done by tick
+        }
+    }
+
+    /**
+        @brief Shifts all output lines one line up
+    */
+    void InGameConsole::shiftLines()
+    {
+        for (unsigned int i = LINES - 1; i > 1; --i)
+        {
+            this->consoleOverlayTextAreas_[i]->setCaption(this->consoleOverlayTextAreas_[i - 1]->getCaption());
+            this->consoleOverlayTextAreas_[i]->setColourTop(this->consoleOverlayTextAreas_[i - 1]->getColourTop());
+            this->consoleOverlayTextAreas_[i]->setColourBottom(this->consoleOverlayTextAreas_[i - 1]->getColourBottom());
+        }
+    }
+
+    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      ###
+    // ###############################
+
+    /**
+        @brief Activates the console.
+    */
+    /*static*/ void InGameConsole::openConsole()
+    {
+        InGameConsole::getInstance().activate();
+    }
+
+    /**
+        @brief Deactivates the console.
+    */
+    /*static*/ void InGameConsole::closeConsole()
+    {
+        InGameConsole::getInstance().deactivate();
+    }
+
+    /**
         @brief Converts a string into an Ogre::UTFString.
         @param s The string to convert
         @return The converted string
     */
-    Ogre::UTFString InGameConsole::convert2UTF(std::string s)
+    /*static*/ Ogre::UTFString InGameConsole::convert2UTF(std::string s)
     {
         Ogre::UTFString utf;
Index: code/trunk/src/orxonox/console/InGameConsole.h
===================================================================
--- code/trunk/src/orxonox/console/InGameConsole.h	(revision 1576)
+++ code/trunk/src/orxonox/console/InGameConsole.h	(revision 1577)
@@ -44,17 +44,20 @@
     class _OrxonoxExport InGameConsole : public TickableReal, public ShellListener
     {
-        public:
+        public: // functions
+            void initialise();
+            void destroy();
+            void setConfigValues();
+
+            void tick(float dt);
+            void resize();
+
             static InGameConsole& getInstance();
 
-            void setConfigValues();
-            void tick(float dt);
-
-            void resize();
             static void openConsole();
             static void closeConsole();
 
-        private:
+        private: // functions
             InGameConsole();
-            InGameConsole(const InGameConsole& other);
+            InGameConsole(const InGameConsole& other) {}
             ~InGameConsole();
 
@@ -62,22 +65,19 @@
             void deactivate();
 
-            virtual void linesChanged();
-            virtual void onlyLastLineChanged();
-            virtual void lineAdded();
-            virtual void inputChanged();
-            virtual void cursorChanged();
-            virtual void exit();
+            void linesChanged();
+            void onlyLastLineChanged();
+            void lineAdded();
+            void inputChanged();
+            void cursorChanged();
+            void exit();
 
-            void init();
             void shiftLines();
             void colourLine(int colourcode, int index);
             void setCursorPosition(unsigned int pos);
             void print(const std::string& text, int index, bool alwaysShift = false);
+
             static Ogre::UTFString convert2UTF(std::string s);
 
-            static float REL_WIDTH;
-            static float REL_HEIGHT;
-            static float BLINK;
-
+        private: // variables
             bool bActive_;
             int windowW_;
@@ -92,11 +92,17 @@
             bool bShowCursor_;
             std::string displayedText_;
-            Ogre::OverlayManager* om_;
             Ogre::Overlay* consoleOverlay_;
             Ogre::OverlayContainer* consoleOverlayContainer_;
             Ogre::PanelOverlayElement* consoleOverlayNoise_;
-            Ogre::PanelOverlayElement* consoleOverlayCursor_;
+            Ogre::TextAreaOverlayElement* consoleOverlayCursor_;
             Ogre::BorderPanelOverlayElement* consoleOverlayBorder_;
             Ogre::TextAreaOverlayElement** consoleOverlayTextAreas_;
+
+            // config values
+            float relativeWidth;
+            float relativeHeight;
+            float blinkTime;
+            float scrollSpeed_;
+            float noiseSize_;
     };
 }
