Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 11314


Ignore:
Timestamp:
Nov 28, 2016, 7:21:35 PM (7 years ago)
Author:
patricwi
Message:

linker problem solved, visuals work as long as only 1 item is picked up.

Location:
code/branches/HUD_HS16/src/modules
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • code/branches/HUD_HS16/src/modules/overlays/hud/HUDPickupItem.cc

    r11305 r11314  
    5252        overlayElement_ = static_cast<Ogre::PanelOverlayElement* >(Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", "HUDPickupItem" + getUniqueNumberString()));
    5353       
    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       
    5756    }
    5857
     
    6564    }
    6665
    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;
    6969        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;
    7581    }
    7682
  • code/branches/HUD_HS16/src/modules/overlays/hud/HUDPickupItem.h

    r11305 r11314  
    3636
    3737        // 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();
    4040
    4141    private:
  • code/branches/HUD_HS16/src/modules/overlays/hud/HUDPickupSystem.cc

    r11305 r11314  
    5353        orxout() << "hello here is the HUDPickupSystem" << endl;
    5454        this->background_->addChild(overlayElement_);
    55 
    56         PickupManager::getInstance().setPickupSystem(this);
    5755    }
    5856
     
    6967    void HUDPickupSystem::updatePickupList(std::vector<Pickupable*> picks)
    7068    {
    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)
    7277        {
    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            }
    7697        }
    7798    }
     
    79100    void HUDPickupSystem::createPickupList()
    80101    {
    81      
    82102    }     
     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    }
    83113
    84114    void HUDPickupSystem::destroyAll()
    85115    {
    86        
     116        this->background_->removeChild(overlayElement_->getName());
    87117    }
    88118}
  • code/branches/HUD_HS16/src/modules/overlays/hud/HUDPickupSystem.h

    r11305 r11314  
    6363        // virtual void positionChanged() override;
    6464        // 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);
    6668    private:
    67         void createPickupList();
     69       
    6870        void destroyAll();
     71
     72        std::map<Pickupable*, HUDPickupItem*> picks;
    6973
    7074        Ogre::PanelOverlayElement* overlayElement_;
  • code/branches/HUD_HS16/src/modules/pickup/CMakeLists.txt

    r9348 r11314  
    1919    PickupPrecompiledHeaders.h
    2020  LINK_LIBRARIES
     21    overlays
    2122    orxonox
    2223  SOURCE_FILES ${PICKUP_SRC_FILES}
  • code/branches/HUD_HS16/src/modules/pickup/PickupManager.cc

    r11305 r11314  
    8383    }
    8484
    85     void PickupManager::setPickupSystem(HUDPickupSystem* system)
    86     {
    87         pickupSystem=system;
    88     }
    89 
    9085    /**
    9186    @brief
     
    271266        assert(pickup);
    272267
     268        if(!pickupSystem)
     269        {
     270            for (HUDPickupSystem* hud : ObjectList<HUDPickupSystem>())
     271                pickupSystem = hud;
     272        }
     273        assert(pickupSystem); //pickupSystem HAS to be there!
     274
    273275        if(!GameMode::isMaster()) // If this is neither standalone nor the server.
    274276            return;
     
    299301            this->pickups_[index] = pickup;
    300302
    301             //TODO
    302             std::vector<Pickupable*> picks;
    303 
    304             PickupManager& manager = PickupManager::getInstance();
    305            
    306             Pickupable* pickup = nullptr;
    307 
    308             for(uint32_t i = 0; i!=10; i++)
    309             {
    310                 pickup=manager.pickups_.find(i)->second;
    311                 picks.push_back(pickup);
    312             }
    313             // pickupSystem->updatePickupList(picks);
     303            orxout() << "the pickup is: " << pickup << endl;
     304
     305            this->picks.push_back(pickup);
     306
     307            pickupSystem->updatePickupList(picks);
    314308           
    315309        }
     
    320314            index = it->second;
    321315
    322            
    323316            this->indexes_.erase(pickup);
    324317            this->pickups_.find(index)->second=nullptr; //set to null, so that can be identified as free slot by getPickupIndex()
     318
     319
     320            this->picks.erase(std::remove(this->picks.begin(), this->picks.end(), pickup), this->picks.end()); //remove pickup from vector
     321
     322            pickupSystem->removePickup(pickup);
     323            pickupSystem->updatePickupList(picks);
    325324        }
    326325
  • code/branches/HUD_HS16/src/modules/pickup/PickupManager.h

    r11305 r11314  
    4242
    4343#include "PickupRepresentation.h"
    44 
     44#include "interfaces/Pickupable.h"
    4545#include "util/Singleton.h"
    4646#include "interfaces/PickupListener.h"
     
    153153        private:
    154154            HUDPickupSystem* pickupSystem;
     155            std::vector<Pickupable*> picks;
     156
    155157            static PickupManager* singletonPtr_s;
    156158            static const std::string guiName_s; //!< The name of the PickupInventory
Note: See TracChangeset for help on using the changeset viewer.