Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 6, 2017, 4:05:15 PM (7 years ago)
Author:
patricwi
Message:

sync function added without success, order of pickups in HUD is mixed up

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

Legend:

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

    r11510 r11540  
    5050
    5151        std::string name = "HUDPickupItem" + getUniqueNumberString();
    52 
     52        orxout() << "name: "<< name<<endl;
    5353        overlayElement_ = static_cast<Ogre::PanelOverlayElement* >(Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", name ));
    5454
     
    7878        assert(overlayElement_);
    7979        assert(this->background_);
    80         overlayElement_->hide();
    81         //this->background_->removeChild(overlayElement_->getName());
     80        orxout()<< overlayElement_->getName()<< endl;
     81        //overlayElement_->hide();
     82        this->background_->removeChild(overlayElement_->getName());
     83       
    8284    }
    8385}
  • code/branches/HUD_HS16/src/modules/overlays/hud/HUDPickupSystem.cc

    r11510 r11540  
    6868    }
    6969   
     70    void HUDPickupSystem::sync(std::vector<Pickupable*> p)
     71    {
     72        //hide all pickup symbols in HUD and delete from local map
     73
     74        for(const auto& sm_pair : picks)
     75        {
     76            sm_pair.second->hideMe(sm_pair.first, repaint);
     77            picks.erase(sm_pair.first);
     78        }
     79
     80        //add to local map and place on screen
     81        int i = 0;
     82        const float offsetX = 0.345f;
     83        float offsetY = 0.82f;
     84        const float x = 0.102f;
     85        for(Pickupable* pickup:p)
     86        {
     87            //second row has offset
     88            if(i==4)
     89            {   
     90                i=0;
     91                offsetY+=0.075f;
     92            }
     93
     94            HUDPickupItem* item = new HUDPickupItem(this->getContext());
     95            item->initializeMaterial(this->getIcon(((Pickup*)pickup)->getRepresentationName()), offsetX+i*x, offsetY);
     96            orxout() << "created new pickupHUDItem"<<endl;
     97            item->setOverlayGroup(this->getOverlayGroup());
     98            picks[pickup] = item;
     99            i++;
     100        }
     101
     102    }
    70103
    71104    void HUDPickupSystem::updatePickupList(std::vector<Pickupable*> picks, std::map<Pickupable*, uint32_t> indexes_)
     
    92125                    HUDPickupItem* item = new HUDPickupItem(this->getContext());
    93126                    item->initializeMaterial(this->getIcon(((Pickup*)p)->getRepresentationName()), offsetX+i*x, offsetY);
    94                
     127                    orxout() << "created new pickupHUDItem"<<endl;
    95128                    item->setOverlayGroup(this->getOverlayGroup());
    96129                    this->picks[p] = item;
     
    110143        HUDPickupItem* item = this->picks.find(pickup)->second;
    111144        orxout() << "removePickup: pickup= " << pickup << " item= " << item << endl;
     145        this->picks.erase(pickup);
    112146        //assert(item);
    113147        item->hideMe(pickup, repaint);
     
    115149        //assert(overlayElement_);
    116150        //assert(this->background_);
    117         //this->picks.erase(pickup);
    118151        orxout()<< "end removePickup method" << endl;
    119152    }
  • code/branches/HUD_HS16/src/modules/overlays/hud/HUDPickupSystem.h

    r11351 r11540  
    5757
    5858        void sizeChanged();
     59        void sync(std::vector<Pickupable*> p);
    5960        void updatePickupList(std::vector<Pickupable*> picks, std::map<Pickupable*, uint32_t> indexes_); 
    6061        void createPickupList(); 
  • code/branches/HUD_HS16/src/modules/pickup/PickupManager.cc

    r11510 r11540  
    265265        assert(pickup);
    266266
     267        orxout() << "just got called"<<endl;
    267268        for (HUDPickupSystem* hud : ObjectList<HUDPickupSystem>())
    268269            pickupSystem = hud;
     
    299300
    300301            if(pickupSystem)
    301                 pickupSystem->updatePickupList(picks, indexes_);
     302                pickupSystem->sync(picks);
    302303           
    303304        }
     
    315316
    316317            if(pickupSystem)
    317                 pickupSystem->removePickup(pickup);
     318                pickupSystem->sync(picks);
    318319            orxout() << "end of pickupChangedPickedUp" << endl;
    319320        }
Note: See TracChangeset for help on using the changeset viewer.