[Orxonox-commit 6919] r11540 - in code/branches/HUD_HS16/src/modules: overlays/hud pickup

patricwi at orxonox.net patricwi at orxonox.net
Mon Nov 6 16:05:15 CET 2017


Author: patricwi
Date: 2017-11-06 16:05:15 +0100 (Mon, 06 Nov 2017)
New Revision: 11540

Modified:
   code/branches/HUD_HS16/src/modules/overlays/hud/HUDPickupItem.cc
   code/branches/HUD_HS16/src/modules/overlays/hud/HUDPickupSystem.cc
   code/branches/HUD_HS16/src/modules/overlays/hud/HUDPickupSystem.h
   code/branches/HUD_HS16/src/modules/pickup/PickupManager.cc
Log:
sync function added without success, order of pickups in HUD is mixed up

Modified: code/branches/HUD_HS16/src/modules/overlays/hud/HUDPickupItem.cc
===================================================================
--- code/branches/HUD_HS16/src/modules/overlays/hud/HUDPickupItem.cc	2017-11-06 15:01:33 UTC (rev 11539)
+++ code/branches/HUD_HS16/src/modules/overlays/hud/HUDPickupItem.cc	2017-11-06 15:05:15 UTC (rev 11540)
@@ -49,7 +49,7 @@
         RegisterObject(HUDPickupItem);
 
         std::string name = "HUDPickupItem" + getUniqueNumberString();
-
+        orxout() << "name: "<< name<<endl;
         overlayElement_ = static_cast<Ogre::PanelOverlayElement* >(Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", name ));
 
         overlayElement_->setDimensions(0.075f,0.08f);
@@ -77,7 +77,9 @@
         if(!repaint) return;                     //dont do anything, if we are not allowed to repaint because the level is terminating
         assert(overlayElement_);
         assert(this->background_);
-        overlayElement_->hide();
-        //this->background_->removeChild(overlayElement_->getName());
+        orxout()<< overlayElement_->getName()<< endl;
+        //overlayElement_->hide();
+        this->background_->removeChild(overlayElement_->getName());
+        
     }
 }

Modified: code/branches/HUD_HS16/src/modules/overlays/hud/HUDPickupSystem.cc
===================================================================
--- code/branches/HUD_HS16/src/modules/overlays/hud/HUDPickupSystem.cc	2017-11-06 15:01:33 UTC (rev 11539)
+++ code/branches/HUD_HS16/src/modules/overlays/hud/HUDPickupSystem.cc	2017-11-06 15:05:15 UTC (rev 11540)
@@ -67,7 +67,40 @@
 
     }
     
+    void HUDPickupSystem::sync(std::vector<Pickupable*> p)
+    {
+        //hide all pickup symbols in HUD and delete from local map
 
+        for(const auto& sm_pair : picks)
+        {
+            sm_pair.second->hideMe(sm_pair.first, repaint);
+            picks.erase(sm_pair.first);
+        }
+
+        //add to local map and place on screen
+        int i = 0;
+        const float offsetX = 0.345f;
+        float offsetY = 0.82f;
+        const float x = 0.102f;
+        for(Pickupable* pickup:p)
+        {
+            //second row has offset
+            if(i==4)
+            {    
+                i=0;
+                offsetY+=0.075f;
+            }
+
+            HUDPickupItem* item = new HUDPickupItem(this->getContext());
+            item->initializeMaterial(this->getIcon(((Pickup*)pickup)->getRepresentationName()), offsetX+i*x, offsetY);
+            orxout() << "created new pickupHUDItem"<<endl;
+            item->setOverlayGroup(this->getOverlayGroup());
+            picks[pickup] = item;
+            i++;
+        }
+
+    }
+
     void HUDPickupSystem::updatePickupList(std::vector<Pickupable*> picks, std::map<Pickupable*, uint32_t> indexes_)
     {
         int i =0;
@@ -91,7 +124,7 @@
                 {
                     HUDPickupItem* item = new HUDPickupItem(this->getContext());
                     item->initializeMaterial(this->getIcon(((Pickup*)p)->getRepresentationName()), offsetX+i*x, offsetY);
-                
+                    orxout() << "created new pickupHUDItem"<<endl;
                     item->setOverlayGroup(this->getOverlayGroup());
                     this->picks[p] = item;
                 }
@@ -109,12 +142,12 @@
         orxout()<< "removePickup called with " << pickup << endl;
         HUDPickupItem* item = this->picks.find(pickup)->second;
         orxout() << "removePickup: pickup= " << pickup << " item= " << item << endl;
+        this->picks.erase(pickup);
         //assert(item);
         item->hideMe(pickup, repaint);
         orxout() << "i am hidden now" << endl;
         //assert(overlayElement_);
         //assert(this->background_);
-        //this->picks.erase(pickup);
         orxout()<< "end removePickup method" << endl;
     }
 

Modified: code/branches/HUD_HS16/src/modules/overlays/hud/HUDPickupSystem.h
===================================================================
--- code/branches/HUD_HS16/src/modules/overlays/hud/HUDPickupSystem.h	2017-11-06 15:01:33 UTC (rev 11539)
+++ code/branches/HUD_HS16/src/modules/overlays/hud/HUDPickupSystem.h	2017-11-06 15:05:15 UTC (rev 11540)
@@ -56,6 +56,7 @@
         virtual ~HUDPickupSystem();
 
         void sizeChanged();
+        void sync(std::vector<Pickupable*> p);
         void updatePickupList(std::vector<Pickupable*> picks, std::map<Pickupable*, uint32_t> indexes_);  
         void createPickupList();  
         void removePickup(Pickupable* pickup);

Modified: code/branches/HUD_HS16/src/modules/pickup/PickupManager.cc
===================================================================
--- code/branches/HUD_HS16/src/modules/pickup/PickupManager.cc	2017-11-06 15:01:33 UTC (rev 11539)
+++ code/branches/HUD_HS16/src/modules/pickup/PickupManager.cc	2017-11-06 15:05:15 UTC (rev 11540)
@@ -264,6 +264,7 @@
     {
         assert(pickup);
 
+        orxout() << "just got called"<<endl;
         for (HUDPickupSystem* hud : ObjectList<HUDPickupSystem>())
             pickupSystem = hud;
         
@@ -298,7 +299,7 @@
             this->picks.push_back(pickup);
 
             if(pickupSystem)
-                pickupSystem->updatePickupList(picks, indexes_);
+                pickupSystem->sync(picks);
             
         }
         else // If it was dropped, it is removed from the required lists.
@@ -314,7 +315,7 @@
             this->picks.erase(std::remove(this->picks.begin(), this->picks.end(), pickup), this->picks.end()); //remove pickup from vector
 
             if(pickupSystem)
-                pickupSystem->removePickup(pickup);
+                pickupSystem->sync(picks);
             orxout() << "end of pickupChangedPickedUp" << endl;
         }
 



More information about the Orxonox-commit mailing list