[Orxonox-commit 465] r3040 - branches/pickups2/src/orxonox/objects/pickup

landauf at orxonox.net landauf at orxonox.net
Sun May 24 21:43:45 CEST 2009


Author: landauf
Date: 2009-05-24 21:43:45 +0200 (Sun, 24 May 2009)
New Revision: 3040

Modified:
   branches/pickups2/src/orxonox/objects/pickup/Jump.cc
   branches/pickups2/src/orxonox/objects/pickup/PickupCollection.cc
   branches/pickups2/src/orxonox/objects/pickup/PickupInventory.cc
   branches/pickups2/src/orxonox/objects/pickup/PickupInventory.h
Log:
added 2 typedefs in PickupCollection.cc to replace _Pairii which isn't supported by gcc.

Modified: branches/pickups2/src/orxonox/objects/pickup/Jump.cc
===================================================================
--- branches/pickups2/src/orxonox/objects/pickup/Jump.cc	2009-05-24 16:09:23 UTC (rev 3039)
+++ branches/pickups2/src/orxonox/objects/pickup/Jump.cc	2009-05-24 19:43:45 UTC (rev 3040)
@@ -105,4 +105,4 @@
         DroppedItem::createDefaultDrop(this, pawn, ColourValue(1.0f, 0.0f, 0.0f), 30.0f);
         return this->removeFrom(pawn);
     }
-}
\ No newline at end of file
+}

Modified: branches/pickups2/src/orxonox/objects/pickup/PickupCollection.cc
===================================================================
--- branches/pickups2/src/orxonox/objects/pickup/PickupCollection.cc	2009-05-24 16:09:23 UTC (rev 3039)
+++ branches/pickups2/src/orxonox/objects/pickup/PickupCollection.cc	2009-05-24 19:43:45 UTC (rev 3040)
@@ -44,6 +44,9 @@
 
 namespace orxonox
 {
+    typedef std::pair<std::multimap<std::string, BaseItem*>::iterator, std::multimap<std::string, BaseItem*>::iterator> item_range;
+    typedef std::pair<std::multimap<ModifierType::Enum, float>::iterator, std::multimap<ModifierType::Enum, float>::iterator> modifier_range;
+
     //! Constructor
     PickupCollection::PickupCollection()
     {
@@ -54,7 +57,7 @@
     /**
         @brief
             Add an item to the collection.
-            
+
             Only adds the item if there's a free slot for it.
 
         @param item Item to add to the collection.
@@ -121,7 +124,7 @@
         }
         else
         {
-            std::multimap<std::string, BaseItem*>::_Pairii bounds = this->items_.equal_range(item->getPickupIdentifier());
+            item_range 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)
@@ -173,7 +176,7 @@
         }
         else
         {
-            std::multimap<std::string, BaseItem*>::_Pairii bounds = this->items_.equal_range(item->getPickupIdentifier());
+            item_range 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)
@@ -192,7 +195,7 @@
                 this->currentUsable_ = usables.at(0);
             else
                 this->currentUsable_ = NULL;
-            
+
         }
     }
     /**
@@ -213,7 +216,7 @@
     {
         float v = 0.0f;
 
-        std::multimap<ModifierType::Enum, float>::_Pairii range = this->additiveModifiers_.equal_range(type);
+        modifier_range range = this->additiveModifiers_.equal_range(type);
 
         for (std::multimap<ModifierType::Enum, float>::iterator it = range.first; it != range.second && it != this->additiveModifiers_.end(); it++)
         {
@@ -229,7 +232,7 @@
     */
     void PickupCollection::removeAdditiveModifier(ModifierType::Enum type, float value)
     {
-        std::multimap<ModifierType::Enum, float>::_Pairii range = this->additiveModifiers_.equal_range(type);
+        modifier_range range = this->additiveModifiers_.equal_range(type);
         for (std::multimap<ModifierType::Enum, float>::iterator it = range.first; it != range.second && it != this->additiveModifiers_.end(); it++)
         {
             if ((*it).second == value)
@@ -257,7 +260,7 @@
     {
         float v = 1.0f;
 
-        std::multimap<ModifierType::Enum, float>::_Pairii range = this->multiplicativeModifiers_.equal_range(type);
+        modifier_range range = this->multiplicativeModifiers_.equal_range(type);
         for (std::multimap<ModifierType::Enum, float>::iterator it = range.first; it != range.second && it != this->multiplicativeModifiers_.end(); it++)
         {
             v *= (*it).second;
@@ -272,7 +275,7 @@
     */
     void PickupCollection::removeMultiplicativeModifier(ModifierType::Enum type, float value)
     {
-        std::multimap<ModifierType::Enum, float>::_Pairii range = this->multiplicativeModifiers_.equal_range(type);
+        modifier_range range = this->multiplicativeModifiers_.equal_range(type);
         for (std::multimap<ModifierType::Enum, float>::iterator it = range.first; it != range.second && it != this->multiplicativeModifiers_.end(); it++)
         {
             if ((*it).second == value)

Modified: branches/pickups2/src/orxonox/objects/pickup/PickupInventory.cc
===================================================================
--- branches/pickups2/src/orxonox/objects/pickup/PickupInventory.cc	2009-05-24 16:09:23 UTC (rev 3039)
+++ branches/pickups2/src/orxonox/objects/pickup/PickupInventory.cc	2009-05-24 19:43:45 UTC (rev 3040)
@@ -1,339 +1,339 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   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
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Daniel 'Huty' Haggenmueller
- *   Co-authors:
- *      ...
- *
- */
-
-#include "PickupInventory.h"
-
-#include "EquipmentItem.h"
-#include "PassiveItem.h"
-#include "UsableItem.h"
-
-#include "core/CoreIncludes.h"
-#include "core/ConsoleCommand.h"
-#include "core/input/InputManager.h"
-
-#include "gui/GUIManager.h"
-#include "objects/controllers/HumanController.h"
-#include "objects/worldentities/pawns/Pawn.h"
-
-#include <CEGUIImage.h>
-#include <CEGUIImageset.h>
-#include <CEGUIImagesetManager.h>
-#include <CEGUIWindow.h>
-#include <CEGUIWindowManager.h>
-#include <elements/CEGUITabControl.h>
-
-namespace orxonox
-{
-    orxonox::ConsoleCommand& function_PickupInventory_ToggleInventory_0 =
-        orxonox::CommandExecutor::addConsoleCommandShortcut(orxonox::createConsoleCommand(orxonox::createFunctor(&PickupInventory::toggleInventory), "toggleInventory"), true);
-
-    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(PickupInventory::getSingleton()->isVisible()) {
-            GUIManager::getInstancePtr()->executeCode("hideGUI(\"PickupInventory\")");
-            GUIManager::getInstancePtr()->executeCode("hideCursor()");
-            InputManager::getInstance().requestLeaveState("guiMouseOnly");
-        }
-        else
-        {
-            GUIManager::getInstancePtr()->showGUI("PickupInventory");
-            GUIManager::getInstancePtr()->executeCode("showCursor()");
-            InputManager::getInstance().requestEnterState("guiMouseOnly");
-        }
-        PickupInventory::getSingleton()->setVisible(!PickupInventory::getSingleton()->isVisible());
-    }
-
-    unsigned int PickupInventory::getCurrentUsableIndex()
-    {
-        Pawn* pawn = HumanController::getLocalControllerEntityAsPawn();
-        if(pawn && pawn->getPickups().getCurrentUsable())
-        {
-            UsableItem* use = pawn->getPickups().getCurrentUsable();
-            std::deque<UsableItem*> items = pawn->getPickups().getUsableItems();
-            for(unsigned int i = 0; i < items.size(); i++)
-            {
-                if(items.at(i) == use)
-                    return i;
-            }
-        }
-
-        return 0;
-    }
-    bool PickupInventory::isCurrentUsable(const BaseItem* item)
-    {
-        Pawn* pawn = HumanController::getLocalControllerEntityAsPawn();
-        if(pawn)
-            return (pawn->getPickups().getCurrentUsable() == item);
-        else
-            return false;
-    }
-    void PickupInventory::selectUsable(unsigned int i)
-    {
-        Pawn* pawn = HumanController::getLocalControllerEntityAsPawn();
-        if(pawn)
-        {
-            std::deque<UsableItem*> items = pawn->getPickups().getUsableItems();
-            if(i < items.size())
-                pawn->getPickups().setCurrentUsable(items.at(i));
-        }
-    }
-
-    unsigned int PickupInventory::getEquipmentCount()
-    {
-        Pawn* pawn = HumanController::getLocalControllerEntityAsPawn();
-        if(pawn)
-            return pawn->getPickups().getEquipmentItems().size();
-        else
-            return 0;
-    }
-    unsigned int PickupInventory::getUsableCount()
-    {
-        Pawn* pawn = HumanController::getLocalControllerEntityAsPawn();
-        if(pawn)
-            return pawn->getPickups().getUsableItems().size();
-        else
-            return 0;
-    }
-    unsigned int PickupInventory::getPassiveCount()
-    {
-        Pawn* pawn = HumanController::getLocalControllerEntityAsPawn();
-        if(pawn)
-            return pawn->getPickups().getPassiveItems().size();
-        else
-            return 0;
-    }
-    BaseItem* PickupInventory::getEquipmentItem(unsigned int i)
-    {
-        Pawn* pawn = HumanController::getLocalControllerEntityAsPawn();
-        if(pawn)
-        {
-            std::deque<EquipmentItem*> l = pawn->getPickups().getEquipmentItems();
-            if (i >= l.size()) { return NULL; }
-            return l.at(i);
-        }
-        else
-            return NULL;
-    }
-    BaseItem* PickupInventory::getUsableItem(unsigned int i)
-    {
-        Pawn* pawn = HumanController::getLocalControllerEntityAsPawn();
-        if(pawn)
-        {
-            std::deque<UsableItem*> l = pawn->getPickups().getUsableItems();
-            if (i >= l.size()) { return NULL; }
-            return l.at(i);
-        }
-        else
-            return NULL;
-    }
-    BaseItem* PickupInventory::getPassiveItem(unsigned int i)
-    {
-        Pawn* pawn = HumanController::getLocalControllerEntityAsPawn();
-        if(pawn)
-        {
-            std::deque<PassiveItem*> l = pawn->getPickups().getPassiveItems();
-            if (i >= l.size()) { return NULL; }
-            return l.at(i);
-        }
-        else
-            return NULL;
-    }
-
-    std::string PickupInventory::getImageForItem(const BaseItem* item)
-    {
-        if(!item)
-            return "";
-
-        std::string name = "pickup_" + item->getGUIImage();
-
-        if(!CEGUI::ImagesetManager::getSingletonPtr()->isImagesetPresent(name))
-        {
-            CEGUI::ImagesetManager::getSingletonPtr()->createImagesetFromImageFile(name, item->getGUIImage(), "");
-        }
-
-        return "set:" + name + " image:full_image";
-    }
-
-    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->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;
-
-            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)
-    {
-        this->updateEquipment(winMgr, equipWindow);
-        this->updateUsable(winMgr, usableWindow);
-    }
-
-    void PickupInventory::updateEquipment(CEGUI::WindowManager* winMgr, CEGUI::Window* target)
-    {
-        Pawn* pawn;
-        if(pawn = HumanController::getLocalControllerEntityAsPawn())
-        {
-            std::deque<EquipmentItem*> items = pawn->getPickups().getEquipmentItems();
-            for(unsigned int i = 0; i < items.size(); i++)
-            {
-                std::ostringstream id;
-                id << "equ/" << i;
-
-                EquipmentItem* item = items.at(i);
-
-                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();
-        }
-    }
-    void PickupInventory::updateUsable(CEGUI::WindowManager* winMgr, CEGUI::Window* target)
-    {
-        Pawn* pawn;
-        if(pawn = HumanController::getLocalControllerEntityAsPawn())
-        {
-            std::deque<UsableItem*> items = pawn->getPickups().getUsableItems();
-            for(unsigned int i = 0; i < items.size(); i++)
-            {
-                std::ostringstream id;
-                id << "use/" << i;
-
-                UsableItem* item = items.at(i);
-                std::string colour;
-
-                if(PickupInventory::isCurrentUsable(item))
-                    colour = "FFFF5555";
-                else
-                    colour = "FFFFFFFF";
-
-                if(this->createdUsableWindows_ <= i)
-                {
-                    PickupInventory::createItemWindows(winMgr, id.str(), i % 5, i / 5);
-                    this->createdUsableWindows_++;
-                }
-
-                PickupInventory::setWindowProperties(winMgr, target, id.str(), item, colour);
-            }
-            this->visibleUsableWIndows_ = items.size();
-        }
-    }
-
-    void PickupInventory::createItemWindows(CEGUI::WindowManager* winMgr, const std::string& id, int x, int y)
-    { 
-        if(!winMgr) { return; }
-
-        CEGUI::Window* frame = winMgr->createWindow("TaharezLook/StaticImage", "orxonox/Inventory/Frame/" + id);
-        frame->setPosition(CEGUI::UVector2(CEGUI::UDim(0, 5 + x * 70), CEGUI::UDim(0, 5 + y * 90)));
-        frame->setSize(CEGUI::UVector2(CEGUI::UDim(0, 65), CEGUI::UDim(0, 65)));
-
-        CEGUI::Window* text = winMgr->createWindow("TaharezLook/StaticText", "orxonox/Inventory/Title/" + id);
-        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("FrameEnabled", "False");
-        text->setProperty("BackgroundEnabled", "False");
-        text->setProperty("HorzFormatting", "HorzCentred");
-        text->setProperty("VertFormatting", "VertCentred");
-        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);
-        btn->setProperty("PushedImage", image);
-        btn->setProperty("DisabledImage", image);
-        btn->setProperty("Tooltip", item->getGUIText());
-
-        target->addChildWindow(frm);
-        target->addChildWindow(txt);
-        target->addChildWindow(btn);
-    }
-}
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   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
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Daniel 'Huty' Haggenmueller
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "PickupInventory.h"
+
+#include "EquipmentItem.h"
+#include "PassiveItem.h"
+#include "UsableItem.h"
+
+#include "core/CoreIncludes.h"
+#include "core/ConsoleCommand.h"
+#include "core/input/InputManager.h"
+
+#include "gui/GUIManager.h"
+#include "objects/controllers/HumanController.h"
+#include "objects/worldentities/pawns/Pawn.h"
+
+#include <CEGUIImage.h>
+#include <CEGUIImageset.h>
+#include <CEGUIImagesetManager.h>
+#include <CEGUIWindow.h>
+#include <CEGUIWindowManager.h>
+#include <elements/CEGUITabControl.h>
+
+namespace orxonox
+{
+    orxonox::ConsoleCommand& function_PickupInventory_ToggleInventory_0 =
+        orxonox::CommandExecutor::addConsoleCommandShortcut(orxonox::createConsoleCommand(orxonox::createFunctor(&PickupInventory::toggleInventory), "toggleInventory"), true);
+
+    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(PickupInventory::getSingleton()->isVisible()) {
+            GUIManager::getInstancePtr()->executeCode("hideGUI(\"PickupInventory\")");
+            GUIManager::getInstancePtr()->executeCode("hideCursor()");
+            InputManager::getInstance().requestLeaveState("guiMouseOnly");
+        }
+        else
+        {
+            GUIManager::getInstancePtr()->showGUI("PickupInventory");
+            GUIManager::getInstancePtr()->executeCode("showCursor()");
+            InputManager::getInstance().requestEnterState("guiMouseOnly");
+        }
+        PickupInventory::getSingleton()->setVisible(!PickupInventory::getSingleton()->isVisible());
+    }
+
+    unsigned int PickupInventory::getCurrentUsableIndex()
+    {
+        Pawn* pawn = HumanController::getLocalControllerEntityAsPawn();
+        if(pawn && pawn->getPickups().getCurrentUsable())
+        {
+            UsableItem* use = pawn->getPickups().getCurrentUsable();
+            std::deque<UsableItem*> items = pawn->getPickups().getUsableItems();
+            for(unsigned int i = 0; i < items.size(); i++)
+            {
+                if(items.at(i) == use)
+                    return i;
+            }
+        }
+
+        return 0;
+    }
+    bool PickupInventory::isCurrentUsable(const BaseItem* item)
+    {
+        Pawn* pawn = HumanController::getLocalControllerEntityAsPawn();
+        if(pawn)
+            return (pawn->getPickups().getCurrentUsable() == item);
+        else
+            return false;
+    }
+    void PickupInventory::selectUsable(unsigned int i)
+    {
+        Pawn* pawn = HumanController::getLocalControllerEntityAsPawn();
+        if(pawn)
+        {
+            std::deque<UsableItem*> items = pawn->getPickups().getUsableItems();
+            if(i < items.size())
+                pawn->getPickups().setCurrentUsable(items.at(i));
+        }
+    }
+
+    unsigned int PickupInventory::getEquipmentCount()
+    {
+        Pawn* pawn = HumanController::getLocalControllerEntityAsPawn();
+        if(pawn)
+            return pawn->getPickups().getEquipmentItems().size();
+        else
+            return 0;
+    }
+    unsigned int PickupInventory::getUsableCount()
+    {
+        Pawn* pawn = HumanController::getLocalControllerEntityAsPawn();
+        if(pawn)
+            return pawn->getPickups().getUsableItems().size();
+        else
+            return 0;
+    }
+    unsigned int PickupInventory::getPassiveCount()
+    {
+        Pawn* pawn = HumanController::getLocalControllerEntityAsPawn();
+        if(pawn)
+            return pawn->getPickups().getPassiveItems().size();
+        else
+            return 0;
+    }
+    BaseItem* PickupInventory::getEquipmentItem(unsigned int i)
+    {
+        Pawn* pawn = HumanController::getLocalControllerEntityAsPawn();
+        if(pawn)
+        {
+            std::deque<EquipmentItem*> l = pawn->getPickups().getEquipmentItems();
+            if (i >= l.size()) { return NULL; }
+            return l.at(i);
+        }
+        else
+            return NULL;
+    }
+    BaseItem* PickupInventory::getUsableItem(unsigned int i)
+    {
+        Pawn* pawn = HumanController::getLocalControllerEntityAsPawn();
+        if(pawn)
+        {
+            std::deque<UsableItem*> l = pawn->getPickups().getUsableItems();
+            if (i >= l.size()) { return NULL; }
+            return l.at(i);
+        }
+        else
+            return NULL;
+    }
+    BaseItem* PickupInventory::getPassiveItem(unsigned int i)
+    {
+        Pawn* pawn = HumanController::getLocalControllerEntityAsPawn();
+        if(pawn)
+        {
+            std::deque<PassiveItem*> l = pawn->getPickups().getPassiveItems();
+            if (i >= l.size()) { return NULL; }
+            return l.at(i);
+        }
+        else
+            return NULL;
+    }
+
+    std::string PickupInventory::getImageForItem(const BaseItem* item)
+    {
+        if(!item)
+            return "";
+
+        std::string name = "pickup_" + item->getGUIImage();
+
+        if(!CEGUI::ImagesetManager::getSingletonPtr()->isImagesetPresent(name))
+        {
+            CEGUI::ImagesetManager::getSingletonPtr()->createImagesetFromImageFile(name, item->getGUIImage(), "");
+        }
+
+        return "set:" + name + " image:full_image";
+    }
+
+    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->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;
+
+            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)
+    {
+        this->updateEquipment(winMgr, equipWindow);
+        this->updateUsable(winMgr, usableWindow);
+    }
+
+    void PickupInventory::updateEquipment(CEGUI::WindowManager* winMgr, CEGUI::Window* target)
+    {
+        Pawn* pawn;
+        if(pawn = HumanController::getLocalControllerEntityAsPawn())
+        {
+            std::deque<EquipmentItem*> items = pawn->getPickups().getEquipmentItems();
+            for(unsigned int i = 0; i < items.size(); i++)
+            {
+                std::ostringstream id;
+                id << "equ/" << i;
+
+                EquipmentItem* item = items.at(i);
+
+                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();
+        }
+    }
+    void PickupInventory::updateUsable(CEGUI::WindowManager* winMgr, CEGUI::Window* target)
+    {
+        Pawn* pawn;
+        if(pawn = HumanController::getLocalControllerEntityAsPawn())
+        {
+            std::deque<UsableItem*> items = pawn->getPickups().getUsableItems();
+            for(unsigned int i = 0; i < items.size(); i++)
+            {
+                std::ostringstream id;
+                id << "use/" << i;
+
+                UsableItem* item = items.at(i);
+                std::string colour;
+
+                if(PickupInventory::isCurrentUsable(item))
+                    colour = "FFFF5555";
+                else
+                    colour = "FFFFFFFF";
+
+                if(this->createdUsableWindows_ <= i)
+                {
+                    PickupInventory::createItemWindows(winMgr, id.str(), i % 5, i / 5);
+                    this->createdUsableWindows_++;
+                }
+
+                PickupInventory::setWindowProperties(winMgr, target, id.str(), item, colour);
+            }
+            this->visibleUsableWIndows_ = items.size();
+        }
+    }
+
+    void PickupInventory::createItemWindows(CEGUI::WindowManager* winMgr, const std::string& id, int x, int y)
+    { 
+        if(!winMgr) { return; }
+
+        CEGUI::Window* frame = winMgr->createWindow("TaharezLook/StaticImage", "orxonox/Inventory/Frame/" + id);
+        frame->setPosition(CEGUI::UVector2(CEGUI::UDim(0, 5 + x * 70), CEGUI::UDim(0, 5 + y * 90)));
+        frame->setSize(CEGUI::UVector2(CEGUI::UDim(0, 65), CEGUI::UDim(0, 65)));
+
+        CEGUI::Window* text = winMgr->createWindow("TaharezLook/StaticText", "orxonox/Inventory/Title/" + id);
+        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("FrameEnabled", "False");
+        text->setProperty("BackgroundEnabled", "False");
+        text->setProperty("HorzFormatting", "HorzCentred");
+        text->setProperty("VertFormatting", "VertCentred");
+        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);
+        btn->setProperty("PushedImage", image);
+        btn->setProperty("DisabledImage", image);
+        btn->setProperty("Tooltip", item->getGUIText());
+
+        target->addChildWindow(frm);
+        target->addChildWindow(txt);
+        target->addChildWindow(btn);
+    }
+}


Property changes on: branches/pickups2/src/orxonox/objects/pickup/PickupInventory.cc
___________________________________________________________________
Added: svn:eol-style
   + native

Modified: branches/pickups2/src/orxonox/objects/pickup/PickupInventory.h
===================================================================
--- branches/pickups2/src/orxonox/objects/pickup/PickupInventory.h	2009-05-24 16:09:23 UTC (rev 3039)
+++ branches/pickups2/src/orxonox/objects/pickup/PickupInventory.h	2009-05-24 19:43:45 UTC (rev 3040)
@@ -1,103 +1,103 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   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
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Daniel 'Huty' Haggenmueller
- *   Co-authors:
- *      ...
- *
- */
-
-/**
-    @file
-    @brief Declaration of static class for the inventory GUI window.
-*/
-
-#ifndef _PickupInventory_H__
-#define _PickupInventory_H__
-
-#include "OrxonoxPrereqs.h"
-
-#include "core/BaseObject.h"
-
-namespace CEGUI { class Window; class WindowManager; class Image; }
-
-// tolua_begin
-namespace orxonox
-{
-// tolua_end
-    class _OrxonoxExport BaseItem;
-
-    /**
-        @brief Static class for the inventory GUI window.
-        @author Daniel 'Huty' Haggenmueller
-    */ 
-// tolua_begin
-    class _OrxonoxExport PickupInventory
-    {
-// tolua_end
-    public:
-        PickupInventory();
-        virtual ~PickupInventory();
-
-        static PickupInventory* getSingleton(); // tolua_export
-
-        static void toggleInventory(); // tolua_export
-
-        static unsigned int getEquipmentCount(); // tolua_export
-        static unsigned int getUsableCount(); // tolua_export
-        static unsigned int getPassiveCount(); // tolua_export
-
-        static unsigned int getCurrentUsableIndex(); // tolua_export
-        static bool isCurrentUsable(const BaseItem* item); // tolua_export
-        static void selectUsable(unsigned int i); // tolua_export
-
-        static BaseItem* getEquipmentItem(unsigned int i); // tolua_export
-        static BaseItem* getUsableItem(unsigned int i); // tolua_export
-        static BaseItem* getPassiveItem(unsigned int i); // tolua_export
-
-        static std::string getImageForItem(const BaseItem* item); // 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
-
-        void updateEquipment(CEGUI::WindowManager* winMgr, CEGUI::Window* target);
-        void updateUsable(CEGUI::WindowManager* winMgr, CEGUI::Window* target);
-
-        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
-
-#endif /* _PickupInventory_H__ */
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   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
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Daniel 'Huty' Haggenmueller
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file
+    @brief Declaration of static class for the inventory GUI window.
+*/
+
+#ifndef _PickupInventory_H__
+#define _PickupInventory_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "core/BaseObject.h"
+
+namespace CEGUI { class Window; class WindowManager; class Image; }
+
+// tolua_begin
+namespace orxonox
+{
+// tolua_end
+    class _OrxonoxExport BaseItem;
+
+    /**
+        @brief Static class for the inventory GUI window.
+        @author Daniel 'Huty' Haggenmueller
+    */ 
+// tolua_begin
+    class _OrxonoxExport PickupInventory
+    {
+// tolua_end
+    public:
+        PickupInventory();
+        virtual ~PickupInventory();
+
+        static PickupInventory* getSingleton(); // tolua_export
+
+        static void toggleInventory(); // tolua_export
+
+        static unsigned int getEquipmentCount(); // tolua_export
+        static unsigned int getUsableCount(); // tolua_export
+        static unsigned int getPassiveCount(); // tolua_export
+
+        static unsigned int getCurrentUsableIndex(); // tolua_export
+        static bool isCurrentUsable(const BaseItem* item); // tolua_export
+        static void selectUsable(unsigned int i); // tolua_export
+
+        static BaseItem* getEquipmentItem(unsigned int i); // tolua_export
+        static BaseItem* getUsableItem(unsigned int i); // tolua_export
+        static BaseItem* getPassiveItem(unsigned int i); // tolua_export
+
+        static std::string getImageForItem(const BaseItem* item); // 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
+
+        void updateEquipment(CEGUI::WindowManager* winMgr, CEGUI::Window* target);
+        void updateUsable(CEGUI::WindowManager* winMgr, CEGUI::Window* target);
+
+        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
+
+#endif /* _PickupInventory_H__ */


Property changes on: branches/pickups2/src/orxonox/objects/pickup/PickupInventory.h
___________________________________________________________________
Added: svn:eol-style
   + native




More information about the Orxonox-commit mailing list