Index: /code/branches/pickups2/src/orxonox/objects/pickup/PickupCollection.cc
===================================================================
--- /code/branches/pickups2/src/orxonox/objects/pickup/PickupCollection.cc	(revision 3015)
+++ /code/branches/pickups2/src/orxonox/objects/pickup/PickupCollection.cc	(revision 3016)
@@ -158,5 +158,32 @@
             return;
 
+        bool getNewUsable = false;
         if (item == this->currentUsable_ || (this->currentUsable_ && removeAllOfType && this->currentUsable_->getPickupIdentifier() == item->getPickupIdentifier()))
+        {
+            getNewUsable = true;
+        }
+
+        if (removeAllOfType)
+        {
+            std::multimap<std::string, BaseItem*>::iterator it;
+            while ((it = this->items_.find(item->getPickupIdentifier())) != this->items_.end())
+            {
+                this->items_.erase(it);
+            }
+        }
+        else
+        {
+            std::multimap<std::string, BaseItem*>::_Pairii bounds = this->items_.equal_range(item->getPickupIdentifier());
+            for (std::multimap<std::string, BaseItem*>::iterator it = bounds.first; it != bounds.second && it != this->items_.end(); it++)
+            {
+                if ((*it).second == item)
+                {
+                    this->items_.erase(it);
+                    break;
+                }
+            }
+        }
+
+        if (getNewUsable)
         {
             std::deque<UsableItem*> usables = this->getUsableItems();
@@ -166,24 +193,5 @@
             else
                 this->currentUsable_ = NULL;
-        }
-        if (removeAllOfType)
-        {
-            std::multimap<std::string, BaseItem*>::iterator it;
-            while ((it = this->items_.find(item->getPickupIdentifier())) != this->items_.end())
-            {
-                this->items_.erase(it);
-            }
-        }
-        else
-        {
-            std::multimap<std::string, BaseItem*>::_Pairii bounds = this->items_.equal_range(item->getPickupIdentifier());
-            for (std::multimap<std::string, BaseItem*>::iterator it = bounds.first; it != bounds.second && it != this->items_.end(); it++)
-            {
-                if ((*it).second == item)
-                {
-                    this->items_.erase(it);
-                    return;
-                }
-            }
+            
         }
     }
Index: /code/branches/pickups2/src/orxonox/objects/pickup/PickupInventory.cc
===================================================================
--- /code/branches/pickups2/src/orxonox/objects/pickup/PickupInventory.cc	(revision 3015)
+++ /code/branches/pickups2/src/orxonox/objects/pickup/PickupInventory.cc	(revision 3016)
@@ -53,8 +53,28 @@
         orxonox::CommandExecutor::addConsoleCommandShortcut(orxonox::createConsoleCommand(orxonox::createFunctor(&PickupInventory::toggleInventory), "toggleInventory"), true);
 
-    static bool bInventoryVisible_ = false;
+    PickupInventory* PickupInventory::pickupInventory_s = NULL;
+    PickupInventory* PickupInventory::getSingleton()
+    {
+        if(!PickupInventory::pickupInventory_s)
+            PickupInventory::pickupInventory_s = new PickupInventory();
+
+        return PickupInventory::pickupInventory_s;
+    }
+
+    PickupInventory::PickupInventory()
+    {
+        this->bInventoryVisible_ = false;
+        this->createdEquipmentWindows_ = this->createdUsableWindows_ = 0;
+        this->visibleEquipmentWindows_ = this->visibleUsableWIndows_ = 0;
+    }
+    PickupInventory::~PickupInventory()
+    {
+    }
+
+    
+
     void PickupInventory::toggleInventory()
     {
-        if(bInventoryVisible_) {
+        if(PickupInventory::getSingleton()->isVisible()) {
             GUIManager::getInstancePtr()->executeCode("hideGUI(\"PickupInventory\")");
             GUIManager::getInstancePtr()->executeCode("hideCursor()");
@@ -67,17 +87,5 @@
             InputManager::getInstance().requestEnterState("guiMouseOnly");
         }
-        bInventoryVisible_ = !bInventoryVisible_;
-    }
-    void PickupInventory::tabChanged(CEGUI::Window *tab)
-    {
-        CEGUI::TabControl* tabCtrl = dynamic_cast<CEGUI::TabControl*>(tab);
-        if(tabCtrl != NULL)
-        {
-            COUT(1) << "tabChanged() tab index: " << tabCtrl->getSelectedTabIndex() << std::endl;
-        }
-        else
-        {
-            COUT(1) << "tabChanged() argument is no CEGUI::TabControl!" << std::endl;
-        }
+        PickupInventory::getSingleton()->setVisible(!PickupInventory::getSingleton()->isVisible());
     }
 
@@ -193,30 +201,37 @@
     }
 
-    void PickupInventory::clearInventory(CEGUI::WindowManager* winMgr, int equipCount, int usableCount)
-    {
-        for(int i = 0; i < equipCount; i++)
+    void PickupInventory::clearInventory(CEGUI::WindowManager* winMgr, CEGUI::Window* equipPane, CEGUI::Window* usablePane)
+    {
+        for(unsigned int i = 0; i < this->visibleEquipmentWindows_; i++)
         {
             std::ostringstream id;
             id << i;
 
-            winMgr->destroyWindow("orxonox/Inventory/Frame/equ/" + id.str());
-            winMgr->destroyWindow("orxonox/Inventory/Title/equ/" + id.str());
-            winMgr->destroyWindow("orxonox/Inventory/Items/equ/" + id.str());
-        }
-        for(int i = 0; i < usableCount; i++)
+            winMgr->getWindow("orxonox/Inventory/Frame/equ/" + id.str())->setVisible(false);
+            winMgr->getWindow("orxonox/Inventory/Title/equ/" + id.str())->setVisible(false);
+            winMgr->getWindow("orxonox/Inventory/Items/equ/" + id.str())->setVisible(false);
+
+            /*equipPane->removeChildWindow("orxonox/Inventory/Frame/equ/" + id.str());
+            equipPane->removeChildWindow("orxonox/Inventory/Title/equ/" + id.str());
+            equipPane->removeChildWindow("orxonox/Inventory/Items/equ/" + id.str());*/
+        }
+        for(unsigned int i = 0; i < this->visibleUsableWIndows_; i++)
         {
             std::ostringstream id;
             id << i;
 
-            std::string s = id.str();
-            winMgr->destroyWindow("orxonox/Inventory/Frame/use/" + id.str());
-            winMgr->destroyWindow("orxonox/Inventory/Title/use/" + id.str());
-            winMgr->destroyWindow("orxonox/Inventory/Items/use/" + id.str());
+            winMgr->getWindow("orxonox/Inventory/Frame/use/" + id.str())->setVisible(false);
+            winMgr->getWindow("orxonox/Inventory/Title/use/" + id.str())->setVisible(false);
+            winMgr->getWindow("orxonox/Inventory/Items/use/" + id.str())->setVisible(false);
+
+            /*usablePane->removeChildWindow("orxonox/Inventory/Frame/use/" + id.str());
+            usablePane->removeChildWindow("orxonox/Inventory/Title/use/" + id.str());
+            usablePane->removeChildWindow("orxonox/Inventory/Items/use/" + id.str());*/
         }
     }
     void PickupInventory::updateTabs(CEGUI::WindowManager *winMgr, CEGUI::Window *equipWindow, CEGUI::Window *usableWindow)
     {
-        PickupInventory::updateEquipment(winMgr, equipWindow);
-        PickupInventory::updateUsable(winMgr, usableWindow);
+        this->updateEquipment(winMgr, equipWindow);
+        this->updateUsable(winMgr, usableWindow);
     }
 
@@ -234,6 +249,13 @@
                 EquipmentItem* item = items.at(i);
 
-                PickupInventory::addItem(winMgr, target, id.str(), item, "FFFFFFFF", i % 5, i / 5);
+                if(this->createdEquipmentWindows_ <= i)
+                {
+                    PickupInventory::createItemWindows(winMgr, id.str(), i % 5, i / 5);
+                    this->createdEquipmentWindows_++;
+                }
+
+                PickupInventory::setWindowProperties(winMgr, target, id.str(), item, "FFFFFFFF");
             }
+            this->visibleEquipmentWindows_ = items.size();
         }
     }
@@ -257,14 +279,19 @@
                     colour = "FFFFFFFF";
 
-                PickupInventory::addItem(winMgr, target, id.str(), item, colour, i % 5, i / 5);
+                if(this->createdUsableWindows_ <= i)
+                {
+                    PickupInventory::createItemWindows(winMgr, id.str(), i % 5, i / 5);
+                    this->createdUsableWindows_++;
+                }
+
+                PickupInventory::setWindowProperties(winMgr, target, id.str(), item, colour);
             }
-        }
-    }
-
-    void PickupInventory::addItem(CEGUI::WindowManager* winMgr, CEGUI::Window* target, const std::string& id, BaseItem* item, const std::string& titleColour, int x, int y)
+            this->visibleUsableWIndows_ = items.size();
+        }
+    }
+
+    void PickupInventory::createItemWindows(CEGUI::WindowManager* winMgr, const std::string& id, int x, int y)
     { 
-        if(!winMgr || !target || !item) { return; }
-
-        std::string image = PickupInventory::getImageForItem(item);
+        if(!winMgr) { return; }
 
         CEGUI::Window* frame = winMgr->createWindow("TaharezLook/StaticImage", "orxonox/Inventory/Frame/" + id);
@@ -275,14 +302,29 @@
         text->setPosition(CEGUI::UVector2(CEGUI::UDim(0, 5 + x * 70), CEGUI::UDim(0, 70 + y * 90)));
         text->setSize(CEGUI::UVector2(CEGUI::UDim(0, 65), CEGUI::UDim(0, 20)));
-        text->setProperty("Text", item->getGUIText());
         text->setProperty("FrameEnabled", "False");
         text->setProperty("BackgroundEnabled", "False");
         text->setProperty("HorzFormatting", "HorzCentred");
         text->setProperty("VertFormatting", "VertCentred");
-        text->setProperty("TextColours", "tl:" + titleColour + " tr:" + titleColour + " bl:" + titleColour + " br:" + titleColour + "");
+        text->setProperty("TextColours", "tl:FFFFFFFF tr:FFFFFFFF bl:FFFFFFFF br:FFFFFFFF");
 
         CEGUI::Window* btn = winMgr->createWindow("TaharezLook/Button", "orxonox/Inventory/Items/" + id);
         btn->setPosition(CEGUI::UVector2(CEGUI::UDim(0, 8 + x * 70), CEGUI::UDim(0, 8 + y * 90)));
         btn->setSize(CEGUI::UVector2(CEGUI::UDim(0, 59), CEGUI::UDim(0, 59)));
+        btn->subscribeScriptedEvent("Clicked", "itemClicked");
+    }
+    void PickupInventory::setWindowProperties(CEGUI::WindowManager* winMgr, CEGUI::Window* target, const std::string& id, const BaseItem* item, const std::string& textColour)
+    {
+        CEGUI::Window* txt = winMgr->getWindow("orxonox/Inventory/Title/" + id);
+        CEGUI::Window* btn = winMgr->getWindow("orxonox/Inventory/Items/" + id);
+        CEGUI::Window* frm = winMgr->getWindow("orxonox/Inventory/Frame/" + id);
+
+        frm->setVisible(true);
+
+        txt->setVisible(true);
+        txt->setProperty("Text", item->getGUIText());
+        txt->setProperty("TextColours", "tl:" + textColour + " tr:" + textColour + " bl:" + textColour + " br:" + textColour + "");
+
+        std::string image = PickupInventory::getImageForItem(item);
+        btn->setVisible(true);
         btn->setProperty("NormalImage", image);
         btn->setProperty("HoverImage", image);
@@ -290,8 +332,7 @@
         btn->setProperty("DisabledImage", image);
         btn->setProperty("Tooltip", item->getGUIText());
-        btn->subscribeScriptedEvent("Clicked", "itemClicked");
-
-        target->addChildWindow(text);
-        target->addChildWindow(frame);
+
+        target->addChildWindow(frm);
+        target->addChildWindow(txt);
         target->addChildWindow(btn);
     }
Index: /code/branches/pickups2/src/orxonox/objects/pickup/PickupInventory.h
===================================================================
--- /code/branches/pickups2/src/orxonox/objects/pickup/PickupInventory.h	(revision 3015)
+++ /code/branches/pickups2/src/orxonox/objects/pickup/PickupInventory.h	(revision 3016)
@@ -56,13 +56,10 @@
 // tolua_end
     public:
-        //PickupInventory(BaseObject* creator);
-        //virtual ~PickupInventory();
+        PickupInventory();
+        virtual ~PickupInventory();
 
-        /**
-            @brief Toggle visiblity of inventory.
-        */
+        static PickupInventory* getSingleton(); // tolua_export
+
         static void toggleInventory(); // tolua_export
-
-        static void tabChanged(CEGUI::Window* tab); // tolua_export
 
         static unsigned int getEquipmentCount(); // tolua_export
@@ -80,11 +77,25 @@
         static std::string getImageForItem(const BaseItem* item); // tolua_export
 
-        static void clearInventory(CEGUI::WindowManager* winMgr, int equipCount, int usableCount); // tolua_export
-        static void updateTabs(CEGUI::WindowManager* winMgr, CEGUI::Window* equipWindow, CEGUI::Window* usableWindow); // tolua_export
+        void clearInventory(CEGUI::WindowManager* winMgr, CEGUI::Window* equipPane, CEGUI::Window* usablePane); // tolua_export
+        void updateTabs(CEGUI::WindowManager* winMgr, CEGUI::Window* equipWindow, CEGUI::Window* usableWindow); // tolua_export
 
-        static void updateEquipment(CEGUI::WindowManager* winMgr, CEGUI::Window* target);
-        static void updateUsable(CEGUI::WindowManager* winMgr, CEGUI::Window* target);
+        void updateEquipment(CEGUI::WindowManager* winMgr, CEGUI::Window* target);
+        void updateUsable(CEGUI::WindowManager* winMgr, CEGUI::Window* target);
 
-        static void addItem(CEGUI::WindowManager* winMgr, CEGUI::Window* target, const std::string& id, BaseItem* item, const std::string& titleColour, int x, int y); // tolua_export
+        static void createItemWindows(CEGUI::WindowManager* winMgr, const std::string& id, int x, int y);
+        static void setWindowProperties(CEGUI::WindowManager* winMgr, CEGUI::Window* target, const std::string& id, const BaseItem* item, const std::string& textColour);
+
+        const bool isVisible() const
+            { return this->bInventoryVisible_; }
+        void setVisible(bool visible)
+            { this->bInventoryVisible_ = visible; }
+    private:
+        bool bInventoryVisible_;
+        unsigned int createdEquipmentWindows_;
+        unsigned int createdUsableWindows_;
+        unsigned int visibleEquipmentWindows_;
+        unsigned int visibleUsableWIndows_;
+
+        static PickupInventory* pickupInventory_s;
     }; // tolua_export
 } // tolua_export
