[Orxonox-commit 419] r3001 - in branches/pickups2/src/orxonox: . objects/controllers objects/pickup
danielh at orxonox.net
danielh at orxonox.net
Wed May 20 21:01:18 CEST 2009
Author: danielh
Date: 2009-05-20 21:01:17 +0200 (Wed, 20 May 2009)
New Revision: 3001
Modified:
branches/pickups2/src/orxonox/CMakeLists.txt
branches/pickups2/src/orxonox/objects/controllers/HumanController.h
branches/pickups2/src/orxonox/objects/pickup/BaseItem.cc
branches/pickups2/src/orxonox/objects/pickup/BaseItem.h
branches/pickups2/src/orxonox/objects/pickup/Jump.cc
branches/pickups2/src/orxonox/objects/pickup/Jump.h
branches/pickups2/src/orxonox/objects/pickup/PickupCollection.cc
branches/pickups2/src/orxonox/objects/pickup/PickupCollection.h
branches/pickups2/src/orxonox/objects/pickup/PickupInventory.cc
branches/pickups2/src/orxonox/objects/pickup/PickupInventory.h
Log:
- Added helper method to HumanController to get it's ControllableEntity as a Pawn
- Removed tooltip, added default (empty) values for text and image from BaseItem
- Fixed tolua in BaseItem.h
- Added object to PickupCollection for the current UsableItem
- Moved most inventory logic from Lua to PickupInventory (still slow)
TODO:
- Re-use of CEGUI item windows, destroying and creating them on each update is slow, very slow
Modified: branches/pickups2/src/orxonox/CMakeLists.txt
===================================================================
--- branches/pickups2/src/orxonox/CMakeLists.txt 2009-05-20 18:47:08 UTC (rev 3000)
+++ branches/pickups2/src/orxonox/CMakeLists.txt 2009-05-20 19:01:17 UTC (rev 3001)
@@ -34,7 +34,7 @@
SET(ORXONOX_FILES ${ORXONOX_SRC_FILES} ${ORXONOX_HDR_FILES})
GENERATE_SOURCE_GROUPS(${ORXONOX_FILES})
-GENERATE_TOLUA_BINDINGS(Orxonox ORXONOX_FILES INPUTFILES gui/GUIManager.h objects/pickup/PickupInventory.h objects/pickup/BaseItem.h objects/pickup/EquipmentItem.h objects/pickup/UsableItem.h objects/pickup/PassiveItem.h)
+GENERATE_TOLUA_BINDINGS(Orxonox ORXONOX_FILES INPUTFILES gui/GUIManager.h objects/pickup/PickupInventory.h objects/pickup/BaseItem.h)
# Not using precompiled header files: Avoid dependencies
INCLUDE_DIRECTORIES(pch/nopch)
Modified: branches/pickups2/src/orxonox/objects/controllers/HumanController.h
===================================================================
--- branches/pickups2/src/orxonox/objects/controllers/HumanController.h 2009-05-20 18:47:08 UTC (rev 3000)
+++ branches/pickups2/src/orxonox/objects/controllers/HumanController.h 2009-05-20 19:01:17 UTC (rev 3001)
@@ -33,6 +33,7 @@
#include "util/Math.h"
#include "Controller.h"
+#include "objects/worldentities/pawns/Pawn.h"
namespace orxonox
{
@@ -67,6 +68,14 @@
static inline HumanController* getLocalControllerSingleton()
{ return HumanController::localController_s; }
+ static inline Pawn* getLocalControllerEntityAsPawn()
+ {
+ if (HumanController::localController_s) {
+ return dynamic_cast<Pawn*>(HumanController::localController_s->getControllableEntity());
+ } else {
+ return NULL;
+ }
+ }
private:
static HumanController* localController_s;
Modified: branches/pickups2/src/orxonox/objects/pickup/BaseItem.cc
===================================================================
--- branches/pickups2/src/orxonox/objects/pickup/BaseItem.cc 2009-05-20 18:47:08 UTC (rev 3000)
+++ branches/pickups2/src/orxonox/objects/pickup/BaseItem.cc 2009-05-20 19:01:17 UTC (rev 3001)
@@ -51,6 +51,8 @@
this->setOwner(0);
this->setPickupIdentifier(this->getName());
+ this->setGUIImage("");
+ this->setGUIText("");
}
//! Deconstructor.
BaseItem::~BaseItem()
@@ -67,7 +69,6 @@
SUPER(BaseItem, XMLPort, xmlelement, mode);
XMLPortParam(BaseItem, "guiText", setGUIText, getGUIText, xmlelement, mode);
- XMLPortParam(BaseItem, "guiTooltip", setGUITooltip, getGUITooltip, xmlelement, mode);
XMLPortParam(BaseItem, "guiImage", setGUIImage, getGUIImage, xmlelement, mode);
}
@@ -102,4 +103,6 @@
return true;
}
+
+ const std::string& BaseItem::getGUIText() const { return this->guiText_; }
}
Modified: branches/pickups2/src/orxonox/objects/pickup/BaseItem.h
===================================================================
--- branches/pickups2/src/orxonox/objects/pickup/BaseItem.h 2009-05-20 18:47:08 UTC (rev 3000)
+++ branches/pickups2/src/orxonox/objects/pickup/BaseItem.h 2009-05-20 19:01:17 UTC (rev 3001)
@@ -49,7 +49,10 @@
@author
Daniel 'Huty' Haggenmueller
*/
- class _OrxonoxExport BaseItem : public BaseObject
+ class _OrxonoxExport BaseItem
+// tolua_end
+ : public BaseObject
+// tolua_begin
{
// tolua_end
public:
@@ -121,17 +124,11 @@
{ this->pickupIdentifier_ = identifier; }
// GUI stuff
- virtual const std::string& getGUIText()
- { return this->guiText_; }
+ virtual const std::string& getGUIText() const; // tolua_export
inline void setGUIText(const std::string& text)
{ this->guiText_ = text; }
- virtual const std::string& getGUITooltip()
- { return this->guiTooltip_; }
- inline void setGUITooltip(const std::string& tooltip)
- { this->guiTooltip_ = tooltip; }
-
- virtual const std::string& getGUIImage()
+ virtual const std::string& getGUIImage() const
{ return this->guiImage_; }
inline void setGUIImage(const std::string& image)
{ this->guiImage_ = image; }
@@ -148,9 +145,8 @@
std::string pickupIdentifier_;
std::string guiText_;
- std::string guiTooltip_;
std::string guiImage_;
- };
-}
+ }; // tolua_export
+} // tolua_export
#endif /* _BaseItem_H__ */
Modified: branches/pickups2/src/orxonox/objects/pickup/Jump.cc
===================================================================
--- branches/pickups2/src/orxonox/objects/pickup/Jump.cc 2009-05-20 18:47:08 UTC (rev 3000)
+++ branches/pickups2/src/orxonox/objects/pickup/Jump.cc 2009-05-20 19:01:17 UTC (rev 3001)
@@ -102,7 +102,7 @@
*/
bool Jump::dropped(Pawn* pawn)
{
- DroppedItem::createDefaultDrop(this, pawn, ColourValue(1.0f, 0.0f, 0.0f), 5.0f);
+ 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/Jump.h
===================================================================
--- branches/pickups2/src/orxonox/objects/pickup/Jump.h 2009-05-20 18:47:08 UTC (rev 3000)
+++ branches/pickups2/src/orxonox/objects/pickup/Jump.h 2009-05-20 19:01:17 UTC (rev 3001)
@@ -54,6 +54,9 @@
virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< XMLPort
+ virtual int getMaxCarryAmount() const
+ { return INT_MAX; }
+
virtual void used(Pawn* pawn); //!< Called when the item is used.
virtual bool pickedUp(Pawn* pawn); //!< Called when the item is picked up.
Modified: branches/pickups2/src/orxonox/objects/pickup/PickupCollection.cc
===================================================================
--- branches/pickups2/src/orxonox/objects/pickup/PickupCollection.cc 2009-05-20 18:47:08 UTC (rev 3000)
+++ branches/pickups2/src/orxonox/objects/pickup/PickupCollection.cc 2009-05-20 19:01:17 UTC (rev 3001)
@@ -48,6 +48,7 @@
PickupCollection::PickupCollection()
{
this->bBlockRemovals_ = false;
+ this->currentUsable_ = NULL;
}
/**
@@ -63,6 +64,10 @@
{
if (this->checkSlot(item))
{
+ Identifier* ident = Class(UsableItem);
+ if(this->currentUsable_ == NULL && item->isA(ident))
+ this->currentUsable_ = dynamic_cast<UsableItem*>(item);
+
this->items_.insert( std::pair<std::string, BaseItem*> (item->getPickupIdentifier(), item) );
return true;
}
@@ -98,6 +103,7 @@
if((*it).second && (*it).second->getOwner())
(*it).second->dropped((*it).second->getOwner());
}
+ this->currentUsable_ = NULL;
this->items_.clear();
this->bBlockRemovals_ = false;
}
@@ -129,16 +135,8 @@
//! Uses the first usable item in the collection on the owner.
void PickupCollection::useItem()
{
- Identifier* ident = Class(UsableItem);
- for (std::multimap<std::string, BaseItem*>::iterator it = this->items_.begin(); it != this->items_.end(); it++)
- {
- if ((*it).second->isA(ident))
- {
- UsableItem* asUsable = dynamic_cast<UsableItem*>((*it).second);
- asUsable->used(this->owner_);
- return;
- }
- }
+ if(this->currentUsable_)
+ this->currentUsable_->used(this->owner_);
}
/**
@brief Uses a usable item on the owner of the collection.
@@ -159,6 +157,15 @@
if (!item || !this->contains(item, removeAllOfType) || this->bBlockRemovals_)
return;
+ if (item == this->currentUsable_ || (this->currentUsable_ && removeAllOfType && this->currentUsable_->getPickupIdentifier() == item->getPickupIdentifier()))
+ {
+ std::deque<UsableItem*> usables = this->getUsableItems();
+
+ if(usables.size() > 0)
+ this->currentUsable_ = usables.at(0);
+ else
+ this->currentUsable_ = NULL;
+ }
if (removeAllOfType)
{
std::multimap<std::string, BaseItem*>::iterator it;
Modified: branches/pickups2/src/orxonox/objects/pickup/PickupCollection.h
===================================================================
--- branches/pickups2/src/orxonox/objects/pickup/PickupCollection.h 2009-05-20 18:47:08 UTC (rev 3000)
+++ branches/pickups2/src/orxonox/objects/pickup/PickupCollection.h 2009-05-20 19:01:17 UTC (rev 3001)
@@ -105,11 +105,17 @@
inline void setOwner(Pawn* owner)
{ this->owner_ = owner; }
+ inline UsableItem* getCurrentUsable()
+ { return this->currentUsable_; };
+ inline void setCurrentUsable(UsableItem* usable)
+ { this->currentUsable_ = usable; }
+
std::deque<EquipmentItem*> getEquipmentItems(); //!< Get a list of equipment-type items.
std::deque<PassiveItem*> getPassiveItems(); //!< Get a list of passive items.
std::deque<UsableItem*> getUsableItems(); //!< Get a list of usable items.
private:
Pawn* owner_; //!< The owner of the PickupCollection.
+ UsableItem* currentUsable_;
bool bBlockRemovals_; //!< Whether to block direct removals through remove().
Modified: branches/pickups2/src/orxonox/objects/pickup/PickupInventory.cc
===================================================================
--- branches/pickups2/src/orxonox/objects/pickup/PickupInventory.cc 2009-05-20 18:47:08 UTC (rev 3000)
+++ branches/pickups2/src/orxonox/objects/pickup/PickupInventory.cc 2009-05-20 19:01:17 UTC (rev 3001)
@@ -29,8 +29,8 @@
#include "PickupInventory.h"
#include "EquipmentItem.h"
+#include "PassiveItem.h"
#include "UsableItem.h"
-#include "PassiveItem.h"
#include "core/CoreIncludes.h"
#include "core/ConsoleCommand.h"
@@ -38,10 +38,13 @@
#include "gui/GUIManager.h"
#include "objects/controllers/HumanController.h"
-#include "objects/worldentities/pawns/SpaceShip.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
@@ -77,124 +80,219 @@
COUT(1) << "tabChanged() argument is no CEGUI::TabControl!" << std::endl;
}
}
- unsigned int PickupInventory::getEquipmentCount()
+
+ unsigned int PickupInventory::getCurrentUsableIndex()
{
- if (HumanController::getLocalControllerSingleton() && HumanController::getLocalControllerSingleton()->getControllableEntity())
+ Pawn* pawn = HumanController::getLocalControllerEntityAsPawn();
+ if(pawn && pawn->getPickups().getCurrentUsable())
{
- Pawn* pawn = dynamic_cast<Pawn*>(HumanController::getLocalControllerSingleton()->getControllableEntity());
- if(pawn)
- return pawn->getPickups().getEquipmentItems().size();
+ 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;
}
- unsigned int PickupInventory::getUsableCount()
+ bool PickupInventory::isCurrentUsable(const BaseItem* item)
{
- if (HumanController::getLocalControllerSingleton() && HumanController::getLocalControllerSingleton()->getControllableEntity())
+ 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)
{
- Pawn* pawn = dynamic_cast<Pawn*>(HumanController::getLocalControllerSingleton()->getControllableEntity());
- if(pawn)
- return pawn->getPickups().getUsableItems().size();
-
+ std::deque<UsableItem*> items = pawn->getPickups().getUsableItems();
+ if(i < items.size())
+ pawn->getPickups().setCurrentUsable(items.at(i));
}
- return 0;
}
+
+ 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()
{
- if (HumanController::getLocalControllerSingleton() && HumanController::getLocalControllerSingleton()->getControllableEntity())
- {
- Pawn* pawn = dynamic_cast<Pawn*>(HumanController::getLocalControllerSingleton()->getControllableEntity());
- if(pawn)
- return pawn->getPickups().getPassiveItems().size();
-
- }
- return 0;
+ Pawn* pawn = HumanController::getLocalControllerEntityAsPawn();
+ if(pawn)
+ return pawn->getPickups().getPassiveItems().size();
+ else
+ return 0;
}
- EquipmentItem* PickupInventory::getEquipmentItem(unsigned int i)
+ BaseItem* PickupInventory::getEquipmentItem(unsigned int i)
{
- if (HumanController::getLocalControllerSingleton() && HumanController::getLocalControllerSingleton()->getControllableEntity())
+ Pawn* pawn = HumanController::getLocalControllerEntityAsPawn();
+ if(pawn)
{
- Pawn* pawn = dynamic_cast<Pawn*>(HumanController::getLocalControllerSingleton()->getControllableEntity());
- if(pawn)
- {
- std::deque<EquipmentItem*> l = pawn->getPickups().getEquipmentItems();
- if (i >= l.size()) { return NULL; }
- return l.at(i);
- }
-
+ std::deque<EquipmentItem*> l = pawn->getPickups().getEquipmentItems();
+ if (i >= l.size()) { return NULL; }
+ return l.at(i);
}
- return NULL;
+ else
+ return NULL;
}
- UsableItem* PickupInventory::getUsableItem(unsigned int i)
+ BaseItem* PickupInventory::getUsableItem(unsigned int i)
{
- if (HumanController::getLocalControllerSingleton() && HumanController::getLocalControllerSingleton()->getControllableEntity())
+ Pawn* pawn = HumanController::getLocalControllerEntityAsPawn();
+ if(pawn)
{
- Pawn* pawn = dynamic_cast<Pawn*>(HumanController::getLocalControllerSingleton()->getControllableEntity());
- if(pawn)
- {
- std::deque<UsableItem*> l = pawn->getPickups().getUsableItems();
- if (i >= l.size()) { return NULL; }
- return l.at(i);
- }
-
+ std::deque<UsableItem*> l = pawn->getPickups().getUsableItems();
+ if (i >= l.size()) { return NULL; }
+ return l.at(i);
}
- return NULL;
+ else
+ return NULL;
}
- PassiveItem* PickupInventory::getPassiveItem(unsigned int i)
+ BaseItem* PickupInventory::getPassiveItem(unsigned int i)
{
- if (HumanController::getLocalControllerSingleton() && HumanController::getLocalControllerSingleton()->getControllableEntity())
+ Pawn* pawn = HumanController::getLocalControllerEntityAsPawn();
+ if(pawn)
{
- Pawn* pawn = dynamic_cast<Pawn*>(HumanController::getLocalControllerSingleton()->getControllableEntity());
- if(pawn)
- {
- std::deque<PassiveItem*> l = pawn->getPickups().getPassiveItems();
- if (i >= l.size()) { return NULL; }
- return l.at(i);
- }
-
+ std::deque<PassiveItem*> l = pawn->getPickups().getPassiveItems();
+ if (i >= l.size()) { return NULL; }
+ return l.at(i);
}
- return NULL;
+ else
+ return NULL;
}
- std::string PickupInventory::getImagesetForEquipment(unsigned int i)
+
+ std::string PickupInventory::getImageForItem(const BaseItem* item)
{
- EquipmentItem* item = PickupInventory::getEquipmentItem(i);
if(!item)
return "";
std::string name = "pickup_" + item->getGUIImage();
- if(!CEGUI::ImagesetManager::getSingletonPtr()->isImagesetPresent(name)) {
- CEGUI::ImagesetManager::getSingletonPtr()->createImagesetFromImageFile(name, item->getGUIImage(), "pickups");
+ if(!CEGUI::ImagesetManager::getSingletonPtr()->isImagesetPresent(name))
+ {
+ CEGUI::ImagesetManager::getSingletonPtr()->createImagesetFromImageFile(name, item->getGUIImage(), "");
}
- return name;
+ return "set:" + name + " image:full_image";
}
- std::string PickupInventory::getImagesetForUsable(unsigned int i)
+
+ void PickupInventory::clearInventory(CEGUI::WindowManager* winMgr, int equipCount, int usableCount)
{
- UsableItem* item = PickupInventory::getUsableItem(i);
- if(!item)
- return "";
+ for(int i = 0; i < equipCount; i++)
+ {
+ std::ostringstream id;
+ id << i;
- std::string name = "pickup_" + item->getGUIImage();
+ 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++)
+ {
+ std::ostringstream id;
+ id << i;
- if(!CEGUI::ImagesetManager::getSingletonPtr()->isImagesetPresent(name)) {
- CEGUI::ImagesetManager::getSingletonPtr()->createImagesetFromImageFile(name, item->getGUIImage(), "pickups");
+ 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());
}
+ }
+ void PickupInventory::updateTabs(CEGUI::WindowManager *winMgr, CEGUI::Window *equipWindow, CEGUI::Window *usableWindow)
+ {
+ PickupInventory::updateEquipment(winMgr, equipWindow);
+ PickupInventory::updateUsable(winMgr, usableWindow);
+ }
- return name;
+ 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);
+
+ PickupInventory::addItem(winMgr, target, id.str(), item, "FFFFFFFF", i % 5, i / 5);
+ }
+ }
}
- std::string PickupInventory::getImagesetForPassive(unsigned int i)
+ void PickupInventory::updateUsable(CEGUI::WindowManager* winMgr, CEGUI::Window* target)
{
- PassiveItem* item = PickupInventory::getPassiveItem(i);
- if(!item)
- return "";
+ 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;
- std::string name = "pickup_" + item->getGUIImage();
+ UsableItem* item = items.at(i);
+ std::string colour;
- if(!CEGUI::ImagesetManager::getSingletonPtr()->isImagesetPresent(name)) {
- CEGUI::ImagesetManager::getSingletonPtr()->createImagesetFromImageFile(name, item->getGUIImage(), "pickups");
+ if(PickupInventory::isCurrentUsable(item))
+ colour = "FFFF5555";
+ else
+ colour = "FFFFFFFF";
+
+ PickupInventory::addItem(winMgr, target, id.str(), item, colour, i % 5, i / 5);
+ }
}
+ }
- return name;
+ void PickupInventory::addItem(CEGUI::WindowManager* winMgr, CEGUI::Window* target, const std::string& id, BaseItem* item, const std::string& titleColour, int x, int y)
+ {
+ if(!winMgr || !target || !item) { return; }
+
+ std::string image = PickupInventory::getImageForItem(item);
+
+ 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("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 + "");
+
+ 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->setProperty("NormalImage", image);
+ btn->setProperty("HoverImage", image);
+ btn->setProperty("PushedImage", image);
+ btn->setProperty("DisabledImage", image);
+ btn->setProperty("Tooltip", item->getGUIText());
+ btn->subscribeScriptedEvent("Clicked", "itemClicked");
+
+ target->addChildWindow(text);
+ target->addChildWindow(frame);
+ target->addChildWindow(btn);
}
}
Modified: branches/pickups2/src/orxonox/objects/pickup/PickupInventory.h
===================================================================
--- branches/pickups2/src/orxonox/objects/pickup/PickupInventory.h 2009-05-20 18:47:08 UTC (rev 3000)
+++ branches/pickups2/src/orxonox/objects/pickup/PickupInventory.h 2009-05-20 19:01:17 UTC (rev 3001)
@@ -38,19 +38,19 @@
#include "core/BaseObject.h"
-namespace CEGUI { class Window; }
+namespace CEGUI { class Window; class WindowManager; class Image; }
// tolua_begin
namespace orxonox
{
- class EquipmentItem;
- class PassiveItem;
- class UsableItem;
+// tolua_end
+ class _OrxonoxExport BaseItem;
/**
@brief Static class for the inventory GUI window.
@author Daniel 'Huty' Haggenmueller
- */
+ */
+// tolua_begin
class _OrxonoxExport PickupInventory
{
// tolua_end
@@ -69,13 +69,23 @@
static unsigned int getUsableCount(); // tolua_export
static unsigned int getPassiveCount(); // tolua_export
- static EquipmentItem* getEquipmentItem(unsigned int i); // tolua_export
- static UsableItem* getUsableItem(unsigned int i); // tolua_export
- static PassiveItem* getPassiveItem(unsigned int i); // 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 std::string getImagesetForEquipment(unsigned int i); // tolua_export
- static std::string getImagesetForUsable(unsigned int i); // tolua_export
- static std::string getImagesetForPassive(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
+
+ 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
+
+ static void updateEquipment(CEGUI::WindowManager* winMgr, CEGUI::Window* target);
+ static 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
}; // tolua_export
} // tolua_export
More information about the Orxonox-commit
mailing list