Index: trunk/src/lib/event/event_def.h
===================================================================
--- trunk/src/lib/event/event_def.h	(revision 5387)
+++ trunk/src/lib/event/event_def.h	(revision 5388)
@@ -40,12 +40,13 @@
 typedef enum elState
   {
-    ES_GAME,           //!< the state during the game plays
-    ES_GAME_MENU,      //!< state when the menu is called during game
-    ES_MENU,           //!< orxonox menu state
-    ES_SHELL,          //!< if we are in shell Modus
+    ES_NULL         = -1,
+    ES_GAME         = 0,       //!< the state during the game plays
+    ES_GAME_MENU    = 1,       //!< state when the menu is called during game
+    ES_MENU         = 2,       //!< orxonox menu state
+    ES_SHELL        = 3,       //!< if we are in shell Modus
 
-    ES_ALL,            //!< you want to register events for all states
+    ES_ALL          = 4,       //!< you want to register events for all states
 
-    ES_NUMBER,         //!< the number of states
+    ES_NUMBER       = 5,       //!< the number of states
   };
 
Index: trunk/src/lib/event/event_handler.cc
===================================================================
--- trunk/src/lib/event/event_handler.cc	(revision 5387)
+++ trunk/src/lib/event/event_handler.cc	(revision 5388)
@@ -26,4 +26,6 @@
 #include "class_list.h"
 
+#include "t_stack.h"
+
 using namespace std;
 
@@ -47,4 +49,5 @@
   this->state = ES_GAME;
   this->keyMapper = NULL;
+  this->stateStack = NULL;
 }
 
@@ -72,4 +75,5 @@
     }
   }
+  delete this->stateStack;
   delete this->keyMapper;
 
@@ -87,7 +91,51 @@
 void EventHandler::init(IniParser* iniParser)
 {
-  this->keyMapper = new KeyMapper();
-  this->keyMapper->loadKeyBindings(iniParser);
-}
+  if (this->keyMapper == NULL)
+  {
+    this->keyMapper = new KeyMapper();
+    this->keyMapper->loadKeyBindings(iniParser);
+  }
+  if (this->stateStack == NULL)
+    this->stateStack = new tStack<short>;
+}
+
+/**
+ * pushes the current State in the State-stack, and selects state
+ * @param state the new State to set
+ */
+void EventHandler::pushState(elState state)
+{
+  if (likely(state != ES_NULL && state != ES_ALL && this->stateStack != NULL))
+  {
+    this->stateStack->push(this->state);
+    this->setState(state);
+  }
+  else
+  {
+    PRINTF(2)("unable to push State\n");
+  }
+}
+
+/**
+ * this removes the topmost stack-entry and select the underlying one
+ * @returns the next stack-entry
+ */
+elState EventHandler::popState()
+{
+  if (unlikely(this->stateStack == NULL))
+    return ES_NULL;
+  elState state = (elState)this->stateStack->pop();
+  if (state == ES_NULL)
+  {
+    PRINTF(2)("No more states availiable. (unable to pop state)\n");
+    return ES_NULL;
+  }
+  else
+  {
+    this->setState(state);
+    return state;
+  }
+}
+
 
 /**
Index: trunk/src/lib/event/event_handler.h
===================================================================
--- trunk/src/lib/event/event_handler.h	(revision 5387)
+++ trunk/src/lib/event/event_handler.h	(revision 5388)
@@ -14,5 +14,6 @@
 // FORWARD DECLARATION
 class EventListener;
-template <class T> class tList;
+template<class T> class tList;
+template<class T> class tStack;
 class IniParser;
 
@@ -30,4 +31,7 @@
   /** @returns the current state */
   inline elState getState() const { return this->state; };
+
+  void pushState(elState state);
+  elState popState();
 
   void subscribe(EventListener* el, elState state, int eventType);
@@ -50,7 +54,9 @@
   static EventHandler*       singletonRef;                    //!< the singleton reference
 
-  EventListener*             listeners[ES_NUMBER][EV_NUMBER]; //!< a list of registered listeners
-  elState                    state;                           //!< the state of the event handlder
-  KeyMapper*                 keyMapper;                       //!< reference to the key mapper
+  EventListener*             listeners[ES_NUMBER][EV_NUMBER]; //!< a list of registered listeners.
+  elState                    state;                           //!< the state of the event handlder.
+  tStack<short>*             stateStack;                      //!< a stack for the States we are in.
+  KeyMapper*                 keyMapper;                       //!< reference to the key mapper.
+
 };
 
Index: trunk/src/lib/gui/gl_gui/glgui_handler.cc
===================================================================
--- trunk/src/lib/gui/gl_gui/glgui_handler.cc	(revision 5387)
+++ trunk/src/lib/gui/gl_gui/glgui_handler.cc	(revision 5388)
@@ -17,4 +17,5 @@
 
 #include "glgui_handler.h"
+#include "event_handler.h"
 
 using namespace std;
@@ -28,16 +29,4 @@
    this->setName("GLGuiHandler");
 
-   /* If you make a new class, what is most probably the case when you write this file
-      don't forget to:
-       1. Add the new file new_class.cc to the ./src/Makefile.am
-       2. Add the class identifier to ./src/class_id.h eg. CL_NEW_CLASS
-   !!!!!!!!!! IMPORTANT FOR SINGLETON !!!!!!!!!!!!!!!!
-        3. SingleTon MUST be CL_NEW_CLASS = 0x00000fxx
-
-      Advanced Topics:
-      - if you want to let your object be managed via the ObjectManager make sure to read
-        the object_manager.h header comments. You will use this most certanly only if you
-        make many objects of your class, like a weapon bullet.
-   */
 }
 
@@ -54,2 +43,21 @@
   GLGuiHandler::singletonRef = NULL;
 }
+
+void GLGuiHandler::activate()
+{
+//  EventHandler::getInstance()->setState(ES_MENU);
+
+}
+
+void GLGuiHandler::deactivate()
+{
+
+}
+
+
+void GLGuiHandler::process(const Event &event)
+{
+
+
+
+}
Index: trunk/src/lib/gui/gl_gui/glgui_handler.h
===================================================================
--- trunk/src/lib/gui/gl_gui/glgui_handler.h	(revision 5387)
+++ trunk/src/lib/gui/gl_gui/glgui_handler.h	(revision 5388)
@@ -7,10 +7,10 @@
 #define _GLGUI_HANDLER_H
 
-#include "base_object.h"
+#include "event_listener.h"
 
 // FORWARD DEFINITION
 
 //! A default singleton class.
-class GLGuiHandler : public BaseObject {
+class GLGuiHandler : public EventListener {
 
  public:
@@ -19,7 +19,16 @@
   inline static GLGuiHandler* getInstance(void) { if (!singletonRef) singletonRef = new GLGuiHandler();  return singletonRef; };
 
+  void activate();
+  void deactivate();
+
+
+  virtual void process(const Event &event);
+
  private:
   GLGuiHandler(void);
   static GLGuiHandler* singletonRef;
+
+
+  bool                 isActive;
 };
 
Index: trunk/src/lib/shell/shell.cc
===================================================================
--- trunk/src/lib/shell/shell.cc	(revision 5387)
+++ trunk/src/lib/shell/shell.cc	(revision 5388)
@@ -125,7 +125,9 @@
   if (this->bActive == true)
     PRINTF(3)("The shell is already active\n");
+
+  printf("ACT\n");
   this->bActive = true;
 
-  EventHandler::getInstance()->setState(ES_SHELL);
+  EventHandler::getInstance()->pushState(ES_SHELL);
   this->setRelCoorSoft2D(0, 0, 1, 5);
 
@@ -149,5 +151,6 @@
   this->bActive = false;
 
-  EventHandler::getInstance()->setState(ES_GAME);
+  EventHandler::getInstance()->popState();
+
   this->setRelCoorSoft2D(0, -(int)this->shellHeight, 1, 5);
 
@@ -445,5 +448,5 @@
     if (event.type == SDLK_BACKQUOTE)
     {
-      if (EventHandler::getInstance()->getState() == ES_GAME)
+      if (this->bActive == false)
         this->activate();
       else
Index: trunk/src/lib/util/array.h
===================================================================
--- trunk/src/lib/util/array.h	(revision 5387)
+++ trunk/src/lib/util/array.h	(revision 5388)
@@ -24,4 +24,6 @@
 #define _ARRAY_H
 #include "debug.h"
+
+using namespace std;
 
 //! Array Class that handles dynamic-type arrays.
Index: trunk/src/lib/util/t_stack.h
===================================================================
--- trunk/src/lib/util/t_stack.h	(revision 5388)
+++ trunk/src/lib/util/t_stack.h	(revision 5388)
@@ -0,0 +1,130 @@
+/*
+   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: ...
+*/
+
+/*!
+  @file t_stack.h
+  @brief Contains the tStack Class that handles stacks of classes.
+  this class creates a Array of a semi-Dynamic length.
+  beware, that after finalizing the array may not be resized again.
+*/
+
+#ifndef _T_STACK_H
+#define _T_STACK_H
+
+using namespace std;
+
+//! Stack Class that handles dynamic-type Stacks.
+template<class T>
+     class tStack
+{
+  public:
+    tStack();
+    ~tStack();
+
+    void push(T entry);
+    T pop();
+    T getTop();
+    /** @returns the Size of the Stack (0 if empty) */
+    unsigned int getSize() { return this->entryCount; };
+
+    void debug() const ;
+
+  private:
+    //! One entry of the Stack
+    struct tStackEntry
+    {
+      T              value;          //!< The value of this Entry.
+      tStackEntry*   next;           //!< Pointer to the Next entry.
+    };
+
+
+    unsigned int     entryCount;      //!< The count of Entries in this Array.
+    tStackEntry*     topEntry;      //!< Pointer to the first Entry of this Array
+};
+
+/**
+ * creates and initializes a Stack
+ */
+template<class T>
+    tStack<T>::tStack()
+{
+  this->topEntry = NULL;
+  this->entryCount = 0;
+}
+
+/**
+ * delocates alocated memory from a Stack.
+ * This does not delete the entries of the Stack
+ */
+template<class T>
+    tStack<T>::~tStack()
+{
+  tStackEntry* delEntry;
+  while (this->topEntry != NULL)
+  {
+    delEntry = this->topEntry;
+    this->topEntry = topEntry->next;
+    delete delEntry;
+  }
+}
+
+
+/**
+ * pushes one Entry into the Stack.
+ * @param entry the Entry to push into the Stack
+ */
+template<class T>
+    void tStack<T>::push(T entry)
+{
+  tStackEntry* newEntry = new tStackEntry;
+  newEntry->value = entry;
+  newEntry->next = this->topEntry;
+  this->topEntry = newEntry;
+
+  this->entryCount++;
+}
+
+
+/**
+ * pops up the topmost enrty of the Stack, and moves the pointer to the next Stack-entry.
+ * @returns the top-most enrty.
+ */
+template<class T>
+    T tStack<T>::pop()
+{
+  if (this->topEntry == NULL)
+    return 0;
+
+  tStackEntry* retEntry = this->topEntry;
+  T retVal = retEntry->value;
+  this->topEntry = this->topEntry->next;
+  delete retEntry;
+  this->entryCount--;
+  return retVal;
+}
+
+/**
+ * @returns the topMost entry of the Stack
+ */
+template<class T>
+    T tStack<T>::getTop()
+{
+  if (this->topEntry != NULL)
+    return this->topEntry->value;
+  else
+    return NULL;
+}
+
+#endif /* _T_STACK_H */
