Changeset 11314 for code/branches/HUD_HS16/src/modules/overlays
- Timestamp:
- Nov 28, 2016, 7:21:35 PM (8 years ago)
- Location:
- code/branches/HUD_HS16/src/modules/overlays/hud
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/HUD_HS16/src/modules/overlays/hud/HUDPickupItem.cc
r11305 r11314 52 52 overlayElement_ = static_cast<Ogre::PanelOverlayElement* >(Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", "HUDPickupItem" + getUniqueNumberString())); 53 53 54 overlayElement_->setPosition(0.0f,0.0f); 55 overlayElement_->setDimensions(0.5f,0.5f); 56 this->background_->addChild(overlayElement_); 54 overlayElement_->setDimensions(0.1f,0.1f); 55 57 56 } 58 57 … … 65 64 } 66 65 67 void HUDPickupItem::initializeMaterial(const std::string& s) 68 { 66 void HUDPickupItem::initializeMaterial(const std::string& s, float x, float y) 67 { 68 orxout() << "material name is: " << s << endl; 69 69 overlayElement_->setMaterialName(s); 70 } 71 72 void HUDPickupItem::printHello() 73 { 74 orxout() << "lets say hello" << endl; 70 overlayElement_->setPosition(x, y); 71 overlayElement_->show(); 72 this->background_->addChild(overlayElement_); 73 } 74 75 void HUDPickupItem::hideMe() 76 { 77 orxout() << this << " has called hide" << endl; 78 overlayElement_->hide(); 79 overlayElement_->_update(); 80 orxout() << "after the call the element is visible: " << overlayElement_->isVisible() << endl; 75 81 } 76 82 -
code/branches/HUD_HS16/src/modules/overlays/hud/HUDPickupItem.h
r11305 r11314 36 36 37 37 // void setPickup(Pickup* pickup); 38 void initializeMaterial(const std::string& s );39 void printHello();38 void initializeMaterial(const std::string& s, float x, float y); 39 void hideMe(); 40 40 41 41 private: -
code/branches/HUD_HS16/src/modules/overlays/hud/HUDPickupSystem.cc
r11305 r11314 53 53 orxout() << "hello here is the HUDPickupSystem" << endl; 54 54 this->background_->addChild(overlayElement_); 55 56 PickupManager::getInstance().setPickupSystem(this);57 55 } 58 56 … … 69 67 void HUDPickupSystem::updatePickupList(std::vector<Pickupable*> picks) 70 68 { 71 for(Pickupable* p : picks) 69 int i=0; 70 const float offsetX = 0.32f; 71 float offsetY = 0.77f; 72 const float x = 0.1f; 73 74 orxout() << "size: " << picks.size() << endl; 75 76 if(picks.size()>0) 72 77 { 73 HUDPickupItem* item = new HUDPickupItem(this->getContext()); 74 item->initializeMaterial(((Pickup*)p)->getRepresentationName()); 75 item->printHello(); 78 79 for(Pickupable* p : picks) 80 { 81 // orxout() << "actual pick is: " << p << endl; 82 if(i%4==0) 83 { 84 offsetY+=0.04f; 85 i=0; 86 } 87 HUDPickupItem* item = new HUDPickupItem(this->getContext()); 88 // item->initializeMaterial(((Pickup*)p)->getRepresentationName(), offsetX+i*x, offsetY); 89 if(i%2==0) 90 item->initializeMaterial("Shield", offsetX+i*x, offsetY); 91 else 92 item->initializeMaterial("ArrowUp", offsetX+i*x, offsetY); 93 item->setOverlayGroup(this->getOverlayGroup()); 94 this->picks[p] = item; 95 ++i; 96 } 76 97 } 77 98 } … … 79 100 void HUDPickupSystem::createPickupList() 80 101 { 81 82 102 } 103 104 void HUDPickupSystem::removePickup(Pickupable* pickup) 105 { 106 HUDPickupItem* item = this->picks.find(pickup)->second; 107 orxout() << "removePickup: pickup= " << pickup << " item= " << item << endl; 108 assert(item); 109 item->setOverlayGroup(nullptr); 110 item->hideMe(); 111 overlayElement_->_update(); 112 } 83 113 84 114 void HUDPickupSystem::destroyAll() 85 115 { 86 116 this->background_->removeChild(overlayElement_->getName()); 87 117 } 88 118 } -
code/branches/HUD_HS16/src/modules/overlays/hud/HUDPickupSystem.h
r11305 r11314 63 63 // virtual void positionChanged() override; 64 64 // virtual void sizeChanged() override; 65 void updatePickupList(std::vector<Pickupable*> picks); 65 void updatePickupList(std::vector<Pickupable*> picks); 66 void createPickupList(); 67 void removePickup(Pickupable* pickup); 66 68 private: 67 void createPickupList();69 68 70 void destroyAll(); 71 72 std::map<Pickupable*, HUDPickupItem*> picks; 69 73 70 74 Ogre::PanelOverlayElement* overlayElement_;
Note: See TracChangeset
for help on using the changeset viewer.