Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 5, 2016, 6:01:02 PM (7 years ago)
Author:
patricwi
Message:

bug when ending or restarting a game with non-empty inventory and size and address of pickups still has to be specified so that the item corresponds to the right pickup symbol

Location:
code/branches/HUD_HS16/src/modules/overlays/hud
Files:
3 edited

Legend:

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

    r11314 r11323  
    4444{
    4545    RegisterClass(HUDPickupItem);
    46     Ogre::PanelOverlayElement* overlayElement_;
    4746
    4847    HUDPickupItem::HUDPickupItem(Context* context) : OrxonoxOverlay(context)
     
    5049        RegisterObject(HUDPickupItem);
    5150
    52         overlayElement_ = static_cast<Ogre::PanelOverlayElement* >(Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", "HUDPickupItem" + getUniqueNumberString()));
    53        
     51        std::string name = "HUDPickupItem" + getUniqueNumberString();
     52
     53        overlayElement_ = static_cast<Ogre::PanelOverlayElement* >(Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", name ));
     54        // overlayElement_->setName(name);
     55
    5456        overlayElement_->setDimensions(0.1f,0.1f);
    5557       
     
    7375    }
    7476
    75     void HUDPickupItem::hideMe()
    76     {
    77         orxout() << this << " has called hide" << endl;
     77    void HUDPickupItem::hideMe(Pickupable* p)
     78    {
     79        assert(overlayElement_);
     80        assert(this->background_);
     81        // if(p->isBeingDestroyed()) //if the pickup is being destroyed, we do nothing
     82        // {
     83        //     orxout() << "now i didnt repaint" << endl;
     84        //     return;
     85        // }
     86        orxout() << "name overlay element: " << overlayElement_->getName() << endl;
     87        // orxout() << this << " has called hide" << endl;
    7888        overlayElement_->hide();
    79         overlayElement_->_update();
    80         orxout() << "after the call the element is visible: " << overlayElement_->isVisible() << endl;
     89        this->background_->removeChild(overlayElement_->getName());
     90        // this->background_->_update();
     91        // orxout() << "after the call the element is visible: " << overlayElement_->isVisible() << endl;
    8192    }
    8293
  • code/branches/HUD_HS16/src/modules/overlays/hud/HUDPickupItem.h

    r11314 r11323  
    2424    public:
    2525        HUDPickupItem(Context* context);
     26        Ogre::PanelOverlayElement* overlayElement_;
    2627        virtual ~HUDPickupItem();
    2728
     
    3738        // void setPickup(Pickup* pickup); 
    3839        void initializeMaterial(const std::string& s, float x, float y); 
    39         void hideMe();
     40        void hideMe(Pickupable* p);
    4041
    4142    private:
     
    4748        // void updatePosition();
    4849
     50       
    4951        WeakPtr<Pawn> owner_;
    5052        WeakPtr<Pickup> pickup_;
  • code/branches/HUD_HS16/src/modules/overlays/hud/HUDPickupSystem.cc

    r11314 r11323  
    5959        if (this->isInitialized())
    6060        {
    61             //TODO: Destroy me
     61            this->picks.clear();
    6262        }
    6363    }
     
    8080            {
    8181                // orxout() << "actual pick is: " << p << endl;
    82                 if(i%4==0)
     82                if(i%5==0)
    8383                {
    8484                    offsetY+=0.04f;
    8585                    i=0;
    8686                }   
    87                 HUDPickupItem* item = new HUDPickupItem(this->getContext());
    88                 // item->initializeMaterial(((Pickup*)p)->getRepresentationName(), offsetX+i*x, offsetY);
     87                if(this->picks.count(p)==0)
     88                {
     89                    HUDPickupItem* item = new HUDPickupItem(this->getContext());
     90                    // item->initializeMaterial(((Pickup*)p)->getRepresentationName(), offsetX+i*x, offsetY);
    8991                if(i%2==0)
    9092                    item->initializeMaterial("Shield", offsetX+i*x, offsetY);
     
    9395                item->setOverlayGroup(this->getOverlayGroup());
    9496                this->picks[p] = item;
     97                }
     98               
    9599                ++i;
    96100            }
     
    104108    void HUDPickupSystem::removePickup(Pickupable* pickup)
    105109    {
     110        assert(pickup);
    106111        HUDPickupItem* item = this->picks.find(pickup)->second;
    107112        orxout() << "removePickup: pickup= " << pickup << " item= " << item << endl;
    108113        assert(item);
    109         item->setOverlayGroup(nullptr);
    110         item->hideMe();
    111         overlayElement_->_update();
     114        // item->setOverlayGroup(nullptr);
     115        item->hideMe(pickup);
     116        assert(overlayElement_);
     117        // overlayElement_->_update();
     118        assert(this->background_);
     119        // this->background_->_update();
     120        this->picks.erase(pickup);
    112121    }
    113122
Note: See TracChangeset for help on using the changeset viewer.