/* * 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: * Patrick Wintermeyer * Co-authors: * ... * */ #include #include #include "core/CoreIncludes.h" #include "core/XMLPort.h" #include "util/Convert.h" #include "core/class/Super.h" #include "HUDPickupSystem.h" #include "pickup/Pickup.h" #include "HUDPickupItem.h" #include "pickup/PickupManager.h" namespace orxonox { RegisterClass(HUDPickupSystem); HUDPickupSystem::HUDPickupSystem(Context* context) : OrxonoxOverlay(context) { RegisterObject(HUDPickupSystem); overlayElement_ = static_cast(Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", "HUDPickupSystem" + getUniqueNumberString())); overlayElement_->setMaterialName("PickupBar"); overlayElement_->setPosition(0.0f,0.0f); overlayElement_->setDimensions(0.70f,0.15f); orxout() << "hello here is the HUDPickupSystem" << endl; this->background_->addChild(overlayElement_); } HUDPickupSystem::~HUDPickupSystem() { if (this->isInitialized()) { this->picks.clear(); } } //TODO: XMLPort void HUDPickupSystem::updatePickupList(std::vector picks) { int i=0; const float offsetX = 0.32f; float offsetY = 0.77f; const float x = 0.1f; orxout() << "size: " << picks.size() << endl; if(picks.size()>0) { for(Pickupable* p : picks) { // orxout() << "actual pick is: " << p << endl; if(i%5==0) { offsetY+=0.04f; i=0; } if(this->picks.count(p)==0) { HUDPickupItem* item = new HUDPickupItem(this->getContext()); // item->initializeMaterial(((Pickup*)p)->getRepresentationName(), offsetX+i*x, offsetY); if(i%2==0) item->initializeMaterial("Shield", offsetX+i*x, offsetY); else item->initializeMaterial("ArrowUp", offsetX+i*x, offsetY); item->setOverlayGroup(this->getOverlayGroup()); this->picks[p] = item; } ++i; } } } void HUDPickupSystem::createPickupList() { } void HUDPickupSystem::removePickup(Pickupable* pickup) { assert(pickup); HUDPickupItem* item = this->picks.find(pickup)->second; orxout() << "removePickup: pickup= " << pickup << " item= " << item << endl; assert(item); // item->setOverlayGroup(nullptr); item->hideMe(pickup); assert(overlayElement_); // overlayElement_->_update(); assert(this->background_); // this->background_->_update(); this->picks.erase(pickup); } void HUDPickupSystem::destroyAll() { this->background_->removeChild(overlayElement_->getName()); } }