[Orxonox-commit 1915] r6632 - in code/branches/pickup4: data/gui/layouts data/gui/scripts data/overlays src/modules/pickup src/orxonox src/orxonox/interfaces src/orxonox/overlays src/orxonox/worldentities/pawns
dafrick at orxonox.net
dafrick at orxonox.net
Mon Mar 29 12:30:32 CEST 2010
Author: dafrick
Date: 2010-03-29 12:30:32 +0200 (Mon, 29 Mar 2010)
New Revision: 6632
Modified:
code/branches/pickup4/data/gui/layouts/PickupInventory.layout
code/branches/pickup4/data/gui/scripts/PickupInventory.lua
code/branches/pickup4/data/gui/scripts/QuestGUI.lua
code/branches/pickup4/data/overlays/hudtemplates3.oxo
code/branches/pickup4/src/modules/pickup/CMakeLists.txt
code/branches/pickup4/src/modules/pickup/PickupManager.cc
code/branches/pickup4/src/modules/pickup/PickupManager.h
code/branches/pickup4/src/modules/pickup/PickupPrereqs.h
code/branches/pickup4/src/modules/pickup/PickupRepresentation.cc
code/branches/pickup4/src/modules/pickup/PickupRepresentation.h
code/branches/pickup4/src/orxonox/CMakeLists.txt
code/branches/pickup4/src/orxonox/interfaces/InterfaceCompilation.cc
code/branches/pickup4/src/orxonox/interfaces/PickupCarrier.h
code/branches/pickup4/src/orxonox/overlays/OrxonoxOverlay.cc
code/branches/pickup4/src/orxonox/worldentities/pawns/Pawn.h
Log:
Working towards a functioning PickupInventory.
Modified: code/branches/pickup4/data/gui/layouts/PickupInventory.layout
===================================================================
--- code/branches/pickup4/data/gui/layouts/PickupInventory.layout 2010-03-29 09:28:59 UTC (rev 6631)
+++ code/branches/pickup4/data/gui/layouts/PickupInventory.layout 2010-03-29 10:30:32 UTC (rev 6632)
@@ -1,32 +1,43 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<GUILayout>
- <Window Type="TaharezLook/FrameWindow" Name="orxonox/Inventory">
- <Property Name="UnifiedMinSize" Value="{{0.0,385},{0.0,200}}" />
- <Property Name="UnifiedMaxSize" Value="{{0.0,385},{0.0,200}}" />
- <Property Name="UnifiedPosition" Value="{{0.5,-100},{0.5,-85}}" />
- <Property Name="UnifiedSize" Value="{{0.0,385},{0.0,200}}" />
- <Property Name="Text" Value="Inventory" />
- <Property Name="CloseButtonEnabled" Value="False" />
+<?xml version="1.0" encoding="UTF-8"?>
- <Window Type="TaharezLook/TabControl" Name="orxonox/Inventory/TabControl" >
- <Property Name="Tooltip" Value="Inventory" />
- <Property Name="TabHeight" Value="{0,-1}" />
+<GUILayout >
+ <Window Type="DefaultWindow" Name="orxonox/PickupInventory/Background" >
+ <Property Name="InheritsAlpha" Value="False" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0,0},{0,0},{1,0},{1,0}}" />
+ <Window Type="TaharezLook/StaticText" Name="orxonox/PickupInventory/PickupInventory" >
+ <Property Name="Text" Value="Pickup Inventory" />
+ <Property Name="Alpha" Value="0.8" />
+ <Property Name="InheritsAlpha" Value="False" />
+ <Property Name="HorzFormatting" Value="HorzCentred" />
<Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
- <Property Name="TabPanePosition" Value="Bottom" />
- <Property Name="UnifiedAreaRect" Value="{{0,10},{0,30},{1,-10},{1,-10}}" />
-
- <Window Type="TaharezLook/ScrollablePane" Name="orxonox/Inventory/TabControl/TabEquipment">
- <Property Name="Text" Value="Equipment" />
- <Property Name="UnifiedPosition" Value="{{0.0,3},{0.0,3}}"/>
- <Property Name="UnifiedSize" Value="{{1.0,-6},{1.0,-6}}"/>
+ <Property Name="VertFormatting" Value="TopAligned" />
+ <Property Name="UnifiedAreaRect" Value="{{0.15,0},{0.15,0},{0.85,0},{0.8,0}}" />
+ <Window Type="TaharezLook/StaticText" Name="orxonox/PickupInventory/Wrapper" >
+ <Property Name="TextColours" Value="FF4444FF" />
+ <Property Name="InheritsAlpha" Value="False" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="HorzFormatting" Value="HorzCentred" />
+ <Property Name="VertFormatting" Value="TopAligned" />
+ <Property Name="UnifiedAreaRect" Value="{{0.05,0},{0.15,0},{0.95,0},{0.92,0}}" />
+ <Window Type="TaharezLook/ScrollablePane" Name="orxonox/PickupInventory/Inventory" >
+ <Property Name="ContentArea" Value="l:0 t:0 r:0 b:0" />
+ <Property Name="HorzStepSize" Value="0.005" />
+ <Property Name="VertStepSize" Value="0.005" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="HorzOverlapSize" Value="0.01" />
+ <Property Name="UnifiedAreaRect" Value="{{0.005,0},{0.01,0},{0.995,0},{0.99,0}}" />
+ <Property Name="VertOverlapSize" Value="0.01" />
+ <Property Name="HorzScrollPosition" Value="0" />
+ <Property Name="VertScrollPosition" Value="0" />
+ </Window>
</Window>
- <Window Type="TaharezLook/ScrollablePane" Name="orxonox/Inventory/TabControl/TabUsable">
- <Property Name="Text" Value="Usable" />
- <Property Name="UnifiedPosition" Value="{{0.0,3},{0.0,3}}"/>
- <Property Name="UnifiedSize" Value="{{1.0,-6},{1.0,-6}}"/>
- </Window>
</Window>
-
- <Event Name="WindowUpdate" Function="PickupInventory.update" />
+ <Window Type="TaharezLook/Button" Name="orxonox/PickupInventory/InventoryBackButton" >
+ <Property Name="Text" Value="Back" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.4,0},{0.8350,0},{0.6,0},{0.8800,0}}" />
+ <Event Name="Clicked" Function="PickupInventory.InventoryBackButton_clicked"/>
+ </Window>
</Window>
</GUILayout>
Modified: code/branches/pickup4/data/gui/scripts/PickupInventory.lua
===================================================================
--- code/branches/pickup4/data/gui/scripts/PickupInventory.lua 2010-03-29 09:28:59 UTC (rev 6631)
+++ code/branches/pickup4/data/gui/scripts/PickupInventory.lua 2010-03-29 10:30:32 UTC (rev 6632)
@@ -2,6 +2,7 @@
BasicGUI = require("BasicGUI")
local P = BasicGUI:new() --inherit everything from the gui package
+
if _REQUIREDNAME == nil then
PickupInventory = P
else
@@ -11,58 +12,87 @@
P.filename = "PickupInventory"
P.layoutString = "PickupInventory.layout"
-P.lastEquipmentCount_ = 0
-P.lastUsableCount_ = 0
-P.currentUsableID_ = 0
+function P:init()
+
+end
--- events
-function P:frmUpdate(e)
- local equipCount = orxonox.PickupInventory:getEquipmentCount()
- local usableCount = orxonox.PickupInventory:getUsableCount()
-
- if equipCount ~= self.lastEquipmentCount_ or usableCount ~= self.lastUsableCount_ then
- self:updateTabs()
+function P:show()
+ self.window:show() -- TODO: Do this through parent...
+ self.visible = true
+
+ carrierList = {}
+
+ -- TODO: Nicer?
+ local pickupManager = orxonox.PickupManager:getInstance()
+ local carrier = pickupManager:getPawn()
+ P.getCarrierList(carrier)
+
+ for k,v in pairs(carrierList) do
+ local args = {}
+ table.insert(args, v)
+ table.insert(args, k)
+ local window = P.createCarrierBox(args)
end
end
-function P.update(e)
- loadedGUIs["PickupInventory"]:frmUpdate(e)
+function P.getCarrierList(carrier)
+
+ -- TODO: Test for nil or 0?
+ if carrier == nil then
+ return
+ end
+
+ table.insert(carrierList, carrier)
+
+ local numCarriers = orxonox.PickupManager.getInstance():getNumCarrierChildren(carrier)
+ if numCarriers == 0 then
+ return
+ end
+
+ for i=0,numCarriers-1,1 do
+ local child = orxonox.PickupManager.getInstance():getCarrierChild(i, carrier)
+ if child ~= nil then
+ P.getCarrierList(child)
+ end
+ end
end
-function P.itemClicked(e)
- loadedGUIs["PickupInventory"]:mItemClicked(e)
+function P.createCarrierBox(args)
+ local carrier = args[1]
+ local index = args[2]
+
+ local name = "orxonox/PickupInventory/Carrier" .. index
+ local window = winMgr:createWindow("TaharezLook/StaticText", name .. "/Title")
+ window:setText(carrier:getCarrierName())
+ -- TODO: Does this exist?
+ local height = window:getHeight()
+
+ local box = winMgr:createWindow("TaharezLook/ScrollablePane", name .. "/Box")
+ box:setPosition(CEGUI.UVector2(CEGUI.UDim(0.05, 0), CEGUI.UDim(0, height)))
+ box:setWidth(CEGUI.UDim(0.9, 0))
+
+ local numPickups = orxonox.PickupManager.getInstance():getNumPickups(carrier)
+ for i=0,numPickups-1,1 do
+
+ end
+
+ return window
end
-function P:mItemClicked(e)
- local w = CEGUI.toWindowEventArgs(e).window
- local name = w:getName()
- local t = name:sub(25, 27)
- local i = name:sub(29)
+function P.InventoryUseButton_clicked(e)
- if t == "equ" then
+end
- end
+function P.InventoryDropButton_clicked(e)
- if t == "use" then
- if self.currentUsableID_ >= 0 then
- winMgr:getWindow("orxonox/Inventory/Title/use/" .. self.currentUsableID_):setProperty("TextColours", "tl:FFFFFFFF tr:FFFFFFFF bl:FFFFFFFF br:FFFFFFFF")
- end
- orxonox.PickupInventory:selectUsable(tonumber(i))
- self.currentUsableID_ = tonumber(i)
- winMgr:getWindow("orxonox/Inventory/Title/use/" .. i):setProperty("TextColours", "tl:FFFF4444 tr:FFFF4444 bl:FFFF4444 br:FFFF4444")
- end
end
--- methods
-function P:updateTabs()
- local eqWin = winMgr:getWindow("orxonox/Inventory/TabControl/TabEquipment")
- local usWin = winMgr:getWindow("orxonox/Inventory/TabControl/TabUsable")
- orxonox.PickupInventory:getSingleton():clearInventory(winMgr, eqWin, usWin)
- orxonox.PickupInventory:getSingleton():updateTabs(winMgr, eqWin, usWin)
+function P.InventoryShowDetails_clicked(e)
- self.currentUsableID_ = orxonox.PickupInventory:getCurrentUsableIndex()
- self.lastEquipmentCount_ = orxonox.PickupInventory:getEquipmentCount()
- self.lastUsableCount_ = orxonox.PickupInventory:getUsableCount()
end
+function P.InventoryBackButton_clicked(e)
+ hideGUI("PickupInventory")
+end
+
return P
Modified: code/branches/pickup4/data/gui/scripts/QuestGUI.lua
===================================================================
--- code/branches/pickup4/data/gui/scripts/QuestGUI.lua 2010-03-29 09:28:59 UTC (rev 6631)
+++ code/branches/pickup4/data/gui/scripts/QuestGUI.lua 2010-03-29 10:30:32 UTC (rev 6632)
@@ -10,7 +10,7 @@
P.layoutString = "QuestGUI.layout"
function P:show()
- self.window:show() -- TDO: Do this through parent...
+ self.window:show() -- TODO: Do this through parent...
self.visible = true
local questManager = orxonox.QuestManager:getInstance()
Modified: code/branches/pickup4/data/overlays/hudtemplates3.oxo
===================================================================
--- code/branches/pickup4/data/overlays/hudtemplates3.oxo 2010-03-29 09:28:59 UTC (rev 6631)
+++ code/branches/pickup4/data/overlays/hudtemplates3.oxo 2010-03-29 10:30:32 UTC (rev 6632)
@@ -100,6 +100,12 @@
guiname = "QuestGUI"
visible = "false"
/>
+
+ <GUIOverlay
+ name = "PickupInventory"
+ guiname = "PickupInventory"
+ visible = "false"
+ />
</OverlayGroup>
</Template>
Modified: code/branches/pickup4/src/modules/pickup/CMakeLists.txt
===================================================================
--- code/branches/pickup4/src/modules/pickup/CMakeLists.txt 2010-03-29 09:28:59 UTC (rev 6631)
+++ code/branches/pickup4/src/modules/pickup/CMakeLists.txt 2010-03-29 10:30:32 UTC (rev 6632)
@@ -14,6 +14,8 @@
MODULE
FIND_HEADER_FILES
TOLUA_FILES
+ PickupManager.h
+ PickupRepresentation.h
DEFINE_SYMBOL
"PICKUP_SHARED_BUILD"
PCH_FILE
Modified: code/branches/pickup4/src/modules/pickup/PickupManager.cc
===================================================================
--- code/branches/pickup4/src/modules/pickup/PickupManager.cc 2010-03-29 09:28:59 UTC (rev 6631)
+++ code/branches/pickup4/src/modules/pickup/PickupManager.cc 2010-03-29 10:30:32 UTC (rev 6632)
@@ -34,17 +34,26 @@
#include "PickupManager.h"
#include "core/CoreIncludes.h"
+#include "core/LuaState.h"
+#include "core/GUIManager.h"
#include "core/ScopedSingletonManager.h"
#include "core/Identifier.h"
#include "interfaces/PickupCarrier.h"
+#include "infos/PlayerInfo.h"
#include "worldentities/pawns/Pawn.h"
#include "PickupRepresentation.h"
+#include "ToluaBindPickup.h"
+
namespace orxonox
{
-
+ // Register tolua_open function when loading the library
+ DeclareToluaInterface(Pickup);
+
ManageScopedSingleton(PickupManager, ScopeID::Root, false);
+ /*static*/ const std::string PickupManager::guiName_s = "PickupInventory";
+
/**
@brief
Constructor. Registers the PickupManager and creates the default PickupRepresentation.
@@ -109,4 +118,49 @@
return it->second;
}
+ PickupCarrier* PickupManager::getPawn(void)
+ {
+ Pawn* pawn = dynamic_cast<Pawn*>(GUIManager::getInstancePtr()->getPlayer(PickupManager::guiName_s)->getControllableEntity());
+ if(pawn == NULL)
+ return NULL;
+ return dynamic_cast<PickupCarrier*>(pawn);
+ }
+
+ unsigned int PickupManager::getNumCarrierChildren(PickupCarrier* carrier)
+ {
+ return carrier->getNumCarrierChildren();
+ }
+
+ PickupCarrier* PickupManager::getCarrierChild(unsigned int index, PickupCarrier* carrier)
+ {
+ return carrier->getCarrierChild(index);
+ }
+
+ PickupRepresentation* PickupManager::getPickupRepresentation(unsigned int index, PickupCarrier* carrier)
+ {
+ Pickupable* pickup = carrier->getPickup(index);
+ if(pickup == NULL)
+ return NULL;
+
+ return this->getRepresentation(pickup->getPickupIdentifier());
+ }
+
+
+ unsigned int PickupManager::getNumPickups(PickupCarrier* carrier)
+ {
+ return carrier->getNumPickups();
+ }
+
+ void PickupManager::dropPickup(unsigned int index, PickupCarrier* carrier)
+ {
+ Pickupable* pickup = carrier->getPickup(index);
+ carrier->drop(pickup);
+ }
+
+ void PickupManager::usePickup(unsigned int index, PickupCarrier* carrier, bool use)
+ {
+ Pickupable* pickup = carrier->getPickup(index);
+ pickup->setUsed(use);
+ }
+
}
Modified: code/branches/pickup4/src/modules/pickup/PickupManager.h
===================================================================
--- code/branches/pickup4/src/modules/pickup/PickupManager.h 2010-03-29 09:28:59 UTC (rev 6631)
+++ code/branches/pickup4/src/modules/pickup/PickupManager.h 2010-03-29 10:30:32 UTC (rev 6632)
@@ -43,38 +43,55 @@
#include "core/OrxonoxClass.h"
-namespace orxonox
-{
+namespace orxonox // tolua_export
+{ // tolua_export
+ //TODO: Remove after transfer to orxonox/pickup
+ class PickupCarrier; // tolua_export
+
/**
@brief
Manages Pickupables.
- In essence has two tasks to fulfill. Firstly it must link Pickupables (through their PickupIdentifiers) and their PickupRepresentations. Secondly it manages the Pickup GUI.
+ In essence has two tasks to fulfill. Firstly it must link Pickupables (through their PickupIdentifiers) and their PickupRepresentations. Secondly it manages the PickupInventory.
//TODO: Manage Pickup GUI.
@author
Damian 'Mozork' Frick
*/
- class _PickupExport PickupManager : public Singleton<PickupManager>, public OrxonoxClass
- {
+ class _PickupExport PickupManager // tolua_export
+ : public Singleton<PickupManager>, public OrxonoxClass
+ { // tolua_export
friend class Singleton<PickupManager>;
public:
PickupManager();
virtual ~PickupManager();
- static PickupManager& getInstance() { return Singleton<PickupManager>::getInstance(); }
+ static PickupManager& getInstance() { return Singleton<PickupManager>::getInstance(); } // tolua_export
bool registerRepresentation(const PickupIdentifier* identifier, PickupRepresentation* representation); //!< Registers a PickupRepresentation together with the PickupIdentifier of the Pickupable the PickupRepresentation represents.
PickupRepresentation* getRepresentation(const PickupIdentifier* identifier); //!< Get the PickupRepresentation representing the Pickupable with the input PickupIdentifier.
+ // tolua_begin
+ PickupCarrier* getPawn(void);
+
+ unsigned int getNumCarrierChildren(PickupCarrier* carrier);
+ PickupCarrier* getCarrierChild(unsigned int index, PickupCarrier* carrier);
+
+ unsigned int getNumPickups(PickupCarrier* carrier);
+ PickupRepresentation* getPickupRepresentation(unsigned int index, PickupCarrier* carrier);
+ void dropPickup(unsigned int index, PickupCarrier* carrier);
+ void usePickup(unsigned int index, PickupCarrier* carrier, bool use);
+ // tolua_end
+
private:
static PickupManager* singletonPtr_s;
+ static const std::string guiName_s;
PickupRepresentation* defaultRepresentation_; //!< The default PickupRepresentation.
std::map<const PickupIdentifier*, PickupRepresentation*, PickupIdentifierCompare> representations_; //!< Map linking PickupIdentifiers (representing types if Pickupables) and PickupRepresentations.
- };
+ }; // tolua_export
-}
+} // tolua_export
#endif // _PickupManager_H__
Modified: code/branches/pickup4/src/modules/pickup/PickupPrereqs.h
===================================================================
--- code/branches/pickup4/src/modules/pickup/PickupPrereqs.h 2010-03-29 09:28:59 UTC (rev 6631)
+++ code/branches/pickup4/src/modules/pickup/PickupPrereqs.h 2010-03-29 10:30:32 UTC (rev 6632)
@@ -64,7 +64,7 @@
namespace orxonox
{
-
+
class DroppedPickup;
class Pickup;
class PickupCollection;
Modified: code/branches/pickup4/src/modules/pickup/PickupRepresentation.cc
===================================================================
--- code/branches/pickup4/src/modules/pickup/PickupRepresentation.cc 2010-03-29 09:28:59 UTC (rev 6631)
+++ code/branches/pickup4/src/modules/pickup/PickupRepresentation.cc 2010-03-29 10:30:32 UTC (rev 6632)
@@ -85,6 +85,7 @@
this->description_ = "This is a pickup.";
this->name_ = "Pickup";
this->spawnerTemplate_ = "";
+ this->inventoryRepresentation_ = "";
this->pickup_ = NULL;
}
@@ -99,6 +100,7 @@
XMLPortParam(PickupRepresentation, "name", setName, getName, xmlelement, mode);
XMLPortParam(PickupRepresentation, "description", setDescription, getDescription, xmlelement, mode);
XMLPortParam(PickupRepresentation, "spawnerTemplate", setSpawnerTemplate, getSpawnerTemplate, xmlelement, mode);
+ XMLPortParam(PickupRepresentation, "inventoryRepresentation", setInventoryRepresentation, getInventoryRepresentation, xmlelement, mode);
XMLPortObject(PickupRepresentation, Pickupable, "pickup", setPickup, getPickup, xmlelement, mode);
XMLPortObject(PickupRepresentation, StaticEntity, "spawner-representation", setSpawnerRepresentation, getSpawnerRepresentationIndex, xmlelement, mode);
Modified: code/branches/pickup4/src/modules/pickup/PickupRepresentation.h
===================================================================
--- code/branches/pickup4/src/modules/pickup/PickupRepresentation.h 2010-03-29 09:28:59 UTC (rev 6631)
+++ code/branches/pickup4/src/modules/pickup/PickupRepresentation.h 2010-03-29 10:30:32 UTC (rev 6632)
@@ -44,16 +44,17 @@
#include "core/BaseObject.h"
-namespace orxonox
-{
+namespace orxonox // tolua_export
+{ // tolua_export
/**
@brief
The PickupRepresentation class represents a specific pickup type (identified by its PickupIdentifier). It defines the information displayed in the GUI and how PickupSpawners that spawn the pickup type look like.
They are created through XML and are registered with the PickupManager.
*/
- class _PickupExport PickupRepresentation : public BaseObject
- {
+ class _PickupExport PickupRepresentation // tolua_export
+ : public BaseObject
+ { // tolua_export
public:
PickupRepresentation(); //!< Constructor
@@ -89,6 +90,12 @@
inline void setSpawnerRepresentation(StaticEntity* representation)
{ this->spawnerRepresentation_ = representation; }
/**
+ @brief Set the image representing the pickup in the PickupInventory.
+ @param image A string with the name of the image representing the pickup.
+ */
+ inline void setInventoryRepresentation(const std::string& image)
+ { this->inventoryRepresentation_ = image; }
+ /**
@brief Set the Pickupable that is represented by this PickupRepresentation.
@param pickup A pointer to the Pickupable.
*/
@@ -99,14 +106,12 @@
@brief Get the name of the Pickupable represented by this PickupRepresentation.
@return Returns the name.
*/
- inline const std::string& getName(void)
- { return this->name_; }
+ inline const std::string& getName(void) { return this->name_; } // tolua_export
/**
@brief Get the description of the Pickupable represented by this PickupRepresentation.
@return Returns the description.
*/
- inline const std::string& getDescription(void)
- { return this->description_; }
+ inline const std::string& getDescription(void) { return this->description_; } // tolua_export
/**
@brief Get the name of spawnerTemplate the Pickupable represented by this PickupRepresentation.
@return Returns the name of the spawnerTemplate.
@@ -121,6 +126,11 @@
inline const StaticEntity* getSpawnerRepresentationIndex(unsigned int index)
{ if(index == 0) return this->spawnerRepresentation_; return NULL; }
/**
+ @brief Get the name of the image representing the pickup in the PickupInventory.
+ @return Returns the name of the image as a string.
+ */
+ inline const std::string& getInventoryRepresentation(void) { return this->inventoryRepresentation_; } // tolua_export
+ /**
@brief Get the Pickupable represented by this PickupRepresentation.
@param index The index.
@return Returns (for index = 0) a pointer to the Pickupable. For index > 0 it returns NULL.
@@ -138,11 +148,12 @@
std::string description_; //!< The description of the Pickupable represented by this PickupRepresentation.
std::string spawnerTemplate_; //!< The name of the template of this PickupRepresentation.
StaticEntity* spawnerRepresentation_; //!< The spawnerRepresentation of this PickupRepresentation.
+ std::string inventoryRepresentation_; //!< The name of an image representing the pickup in the PickupInventory. TODO: Exact format and placement of image?
Pickupable* pickup_; //!< The Pickupable that is represented by this PickupRepresentation.
- };
+ }; // tolua_export
-}
+} // tolua_export
#endif // _PickupRepresentation_H__
Modified: code/branches/pickup4/src/orxonox/CMakeLists.txt
===================================================================
--- code/branches/pickup4/src/orxonox/CMakeLists.txt 2010-03-29 09:28:59 UTC (rev 6631)
+++ code/branches/pickup4/src/orxonox/CMakeLists.txt 2010-03-29 10:30:32 UTC (rev 6632)
@@ -57,6 +57,7 @@
LevelManager.h
MoodManager.h
controllers/HumanController.h
+ interfaces/PickupCarrier.h
sound/SoundManager.h
DEFINE_SYMBOL
"ORXONOX_SHARED_BUILD"
Modified: code/branches/pickup4/src/orxonox/interfaces/InterfaceCompilation.cc
===================================================================
--- code/branches/pickup4/src/orxonox/interfaces/InterfaceCompilation.cc 2010-03-29 09:28:59 UTC (rev 6631)
+++ code/branches/pickup4/src/orxonox/interfaces/InterfaceCompilation.cc 2010-03-29 10:30:32 UTC (rev 6632)
@@ -59,6 +59,7 @@
{
RegisterRootObject(PickupCarrier);
+ this->setCarrierName("PickupCarrier");
}
PickupCarrier::~PickupCarrier()
Modified: code/branches/pickup4/src/orxonox/interfaces/PickupCarrier.h
===================================================================
--- code/branches/pickup4/src/orxonox/interfaces/PickupCarrier.h 2010-03-29 09:28:59 UTC (rev 6631)
+++ code/branches/pickup4/src/orxonox/interfaces/PickupCarrier.h 2010-03-29 10:30:32 UTC (rev 6632)
@@ -44,10 +44,11 @@
#include "core/OrxonoxClass.h"
-namespace orxonox
-{
+namespace orxonox // tolua_export
+{ // tolua_export
- //! Pre-declarations.
+ //! Forward-declarations.
+ class PickupManager;
class Pickup;
class HealthPickup;
class MetaPickup;
@@ -58,11 +59,13 @@
@author
Damian 'Mozork' Frick
*/
- class _OrxonoxExport PickupCarrier : virtual public OrxonoxClass
- {
+ class _OrxonoxExport PickupCarrier // tolua_export
+ : virtual public OrxonoxClass
+ { // tolua_export
//! So that the different Pickupables have full access to their PickupCarrier.
+ friend class Pickupable;
+ friend class PickupManager;
//! Friends.
- friend class Pickupable;
friend class Pickup;
friend class HealthPickup;
friend class MetaPickup;
@@ -115,8 +118,8 @@
return true;
//! Go recursively through all children to check whether they are a target.
- std::list<PickupCarrier*>* children = this->getCarrierChildren();
- for(std::list<PickupCarrier*>::const_iterator it = children->begin(); it != children->end(); it++)
+ std::vector<PickupCarrier*>* children = this->getCarrierChildren();
+ for(std::vector<PickupCarrier*>::const_iterator it = children->begin(); it != children->end(); it++)
{
if((*it)->isTarget(pickup))
return true;
@@ -142,8 +145,8 @@
return this;
//! Go recursively through all children to check whether they are the target.
- std::list<PickupCarrier*>* children = this->getCarrierChildren();
- for(std::list<PickupCarrier*>::iterator it = children->begin(); it != children->end(); it++)
+ std::vector<PickupCarrier*>* children = this->getCarrierChildren();
+ for(std::vector<PickupCarrier*>::iterator it = children->begin(); it != children->end(); it++)
{
if(pickup->isTarget(*it))
return *it;
@@ -162,6 +165,8 @@
*/
virtual const Vector3& getCarrierPosition(void) = 0;
+ const std::string& getCarrierName(void) { return this->carrierName_; } // tolua_export
+
protected:
/**
@brief Get all direct children of this PickupSpawner.
@@ -169,7 +174,7 @@
The returned list will be deleted by the methods calling this function.
@return Returns a pointer to a list of all direct children.
*/
- virtual std::list<PickupCarrier*>* getCarrierChildren(void) = 0;
+ virtual std::vector<PickupCarrier*>* getCarrierChildren(void) = 0;
/**
@brief Get the parent of this PickupSpawner
This method needs to be implemented by any direct derivative class of PickupCarrier.
@@ -183,11 +188,47 @@
*/
std::set<Pickupable*>& getPickups(void)
{ return this->pickups_; }
+
+ void setCarrierName(const std::string& name)
+ { this->carrierName_ = name; }
private:
std::set<Pickupable*> pickups_; //!< The list of Pickupables carried by this PickupCarrier.
+ std::string carrierName_;
- };
-}
+ unsigned int getNumCarrierChildren(void)
+ {
+ std::vector<PickupCarrier*>* list = this->getCarrierChildren();
+ unsigned int size = list->size();
+ delete list;
+ return size;
+ }
+
+ PickupCarrier* getCarrierChild(unsigned int index)
+ {
+ std::vector<PickupCarrier*>* list = this->getCarrierChildren();
+ if(list->size() < index)
+ return NULL;
+ PickupCarrier* carrier = (*list)[index];
+ delete list;
+ return carrier;
+ }
+
+ Pickupable* getPickup(unsigned int index)
+ {
+ std::set<Pickupable*>::iterator it;
+ for(it = this->pickups_.begin(); index != 0 && it != this->pickups_.end(); it++)
+ index--;
+ if(it == this->pickups_.end())
+ return NULL;
+ return *it;
+ }
+
+ unsigned int getNumPickups(void)
+ { return this->pickups_.size(); }
+
+
+ }; // tolua_export
+} // tolua_export
#endif /* _PickupCarrier_H__ */
Modified: code/branches/pickup4/src/orxonox/overlays/OrxonoxOverlay.cc
===================================================================
--- code/branches/pickup4/src/orxonox/overlays/OrxonoxOverlay.cc 2010-03-29 09:28:59 UTC (rev 6631)
+++ code/branches/pickup4/src/orxonox/overlays/OrxonoxOverlay.cc 2010-03-29 10:30:32 UTC (rev 6632)
@@ -326,10 +326,17 @@
if (it != overlays_s.end())
{
OrxonoxOverlay* overlay= it->second;
+ COUT(1) << "MUP" << std::endl;
if(overlay->isVisible())
+ {
overlay->hide();
+ COUT(1) << "HIDE " << name << std::endl;
+ }
else
+ {
overlay->show();
+ COUT(1) << "SHOW " << name << std::endl;
+ }
}
}
Modified: code/branches/pickup4/src/orxonox/worldentities/pawns/Pawn.h
===================================================================
--- code/branches/pickup4/src/orxonox/worldentities/pawns/Pawn.h 2010-03-29 09:28:59 UTC (rev 6631)
+++ code/branches/pickup4/src/orxonox/worldentities/pawns/Pawn.h 2010-03-29 10:30:32 UTC (rev 6632)
@@ -36,10 +36,11 @@
#include "interfaces/RadarViewable.h"
#include "worldentities/ControllableEntity.h"
-namespace orxonox
-{
- class _OrxonoxExport Pawn : public ControllableEntity, public RadarViewable, public PickupCarrier
- {
+namespace orxonox // tolua_export
+{ // tolua_export
+ class _OrxonoxExport Pawn // tolua_export
+ : public ControllableEntity, public RadarViewable, public PickupCarrier
+ { // tolua_export
friend class WeaponSystem;
public:
@@ -131,8 +132,8 @@
bool bAlive_;
- virtual std::list<PickupCarrier*>* getCarrierChildren(void)
- { return new std::list<PickupCarrier*>(); }
+ virtual std::vector<PickupCarrier*>* getCarrierChildren(void)
+ { return new std::vector<PickupCarrier*>(); }
virtual PickupCarrier* getCarrierParent(void)
{ return NULL; }
@@ -154,7 +155,7 @@
{ this->weaponSystem_ = weaponsystem; }
Vector3 aimPosition_;
- };
-}
+ }; // tolua_export
+} // tolua_export
#endif /* _Pawn_H__ */
More information about the Orxonox-commit
mailing list