Changeset 11708 for code/trunk/src/modules/overlays
- Timestamp:
- Jan 6, 2018, 6:07:53 PM (7 years ago)
- Location:
- code/trunk/src/modules/overlays/hud
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/modules/overlays/hud/HUDPickupSystem.cc
r11705 r11708 34 34 #include <OgrePanelOverlayElement.h> 35 35 36 #include "HUDPickupSystem.h" 37 36 38 #include "core/CoreIncludes.h" 37 39 #include "core/class/Super.h" 38 40 #include "util/Convert.h" 39 #include "HUDPickupSystem.h"40 41 #include "pickup/PickupManager.h" 42 #include "worldentities/pawns/Pawn.h" 41 43 42 44 namespace orxonox … … 78 80 79 81 } 80 82 83 void HUDPickupSystem::changedOwner() 84 { 85 SUPER(HUDPickupSystem, changedOwner); 86 87 this->owner_ = orxonox_cast<Pawn*>(this->getOwner()); 88 } 89 81 90 void HUDPickupSystem::tick(float dt) 82 91 { 83 92 SUPER(HUDPickupSystem, tick, dt); 84 93 85 int numPickups = PickupManager::getInstance().getNumPickups(); 94 std::vector<const PickupInventoryContainer*> containers = this->getPickupsForOwner(); 95 86 96 for (size_t index = 0; index < this->items_.size(); ++index) 87 97 { 88 98 Ogre::OverlayElement* item = this->items_[index]; 89 99 90 if ( static_cast<int>(index) < numPickups)100 if (index < containers.size()) 91 101 { 92 const PickupInventoryContainer* container = PickupManager::getInstance().popPickup(); 93 item->setMaterialName(this->getIcon(container->representationName)); 102 item->setMaterialName(this->getIcon(containers[index]->representationName)); 94 103 if (!item->getParent()) 95 104 this->background_->addChild(item); … … 103 112 } 104 113 105 std::string HUDPickupSystem::getIcon(std::string repName) 114 std::vector<const PickupInventoryContainer*> HUDPickupSystem::getPickupsForOwner() const 115 { 116 std::vector<const PickupInventoryContainer*> containers; 117 118 int numPickups = PickupManager::getInstance().getNumPickups(); 119 for (int i = 0; i < numPickups; ++i) 120 { 121 const PickupInventoryContainer* container = PickupManager::getInstance().popPickup(); 122 if (this->owner_ && this->owner_->getObjectID() == container->carrierPawnId) 123 containers.push_back(container); 124 } 125 126 return containers; 127 } 128 129 std::string HUDPickupSystem::getIcon(const std::string& repName) const 106 130 { 107 131 if(repName.find("invisible", 0)!=std::string::npos) return "Eye"; -
code/trunk/src/modules/overlays/hud/HUDPickupSystem.h
r11705 r11708 32 32 33 33 #include "overlays/OverlaysPrereqs.h" 34 #include "pickup/PickupPrereqs.h" 34 35 35 36 #include <vector> … … 48 49 49 50 virtual void tick(float dt) override; 51 50 52 virtual void sizeChanged() override; 53 virtual void changedOwner() override; 51 54 52 55 private: 53 std::string getIcon(std::string repName); 56 std::vector<const PickupInventoryContainer*> getPickupsForOwner() const; 57 std::string getIcon(const std::string& repName) const; 54 58 55 59 std::vector<Ogre::OverlayElement*> items_; 60 WeakPtr<Pawn> owner_; 56 61 }; 57 62 }
Note: See TracChangeset
for help on using the changeset viewer.