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
Files:
5 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
  • code/branches/HUD_HS16/src/modules/pickup/PickupManager.cc

    r11314 r11323  
    266266        assert(pickup);
    267267
    268         if(!pickupSystem)
    269         {
    270             for (HUDPickupSystem* hud : ObjectList<HUDPickupSystem>())
    271                 pickupSystem = hud;
    272         }
     268
     269        for (HUDPickupSystem* hud : ObjectList<HUDPickupSystem>())
     270            pickupSystem = hud;
     271       
    273272        assert(pickupSystem); //pickupSystem HAS to be there!
    274273
     
    321320
    322321            pickupSystem->removePickup(pickup);
    323             pickupSystem->updatePickupList(picks);
    324322        }
    325323
     
    366364        orxout() << "The pickup is being used: " << pickup->isUsed() << endl;
    367365
    368         if(pickup->isUsed())
    369             manager.usePickup(index, false);
    370         else
    371             manager.usePickup(index, true);
     366        pickup->drop(true);
     367        // if(pickup->isUsed())
     368        //     manager.usePickup(index, false);
     369        // else
     370        //     manager.usePickup(index, true);
    372371    }
    373372
  • code/branches/HUD_HS16/src/orxonox/interfaces/Pickupable.h

    r11071 r11323  
    9696
    9797            /**
     98            @brief Check whether the Pickupable is in the process of being destroyed.
     99            @return Returns true if so.
     100            */
     101            inline bool isBeingDestroyed(void)
     102                { return this->beingDestroyed_; }
     103               
     104            /**
    98105            @brief Returns whether the Pickupable is currently picked up.
    99106            @return Returns true if the Pickupable is currently picked up, false if not.
     
    155162
    156163            /**
    157             @brief Check whether the Pickupable is in the process of being destroyed.
    158             @return Returns true if so.
    159             */
    160             inline bool isBeingDestroyed(void)
    161                 { return this->beingDestroyed_; }
    162 
    163             /**
    164164            @brief Facilitates the creation of a PickupSpawner upon dropping of the Pickupable.
    165165                   This method must be implemented by any class directly inheriting from Pickupable.
Note: See TracChangeset for help on using the changeset viewer.