[Orxonox-commit 6693] r11323 - in code/branches/HUD_HS16/src: modules/overlays/hud modules/pickup orxonox/interfaces

patricwi at orxonox.net patricwi at orxonox.net
Mon Dec 5 18:01:02 CET 2016


Author: patricwi
Date: 2016-12-05 18:01:02 +0100 (Mon, 05 Dec 2016)
New Revision: 11323

Modified:
   code/branches/HUD_HS16/src/modules/overlays/hud/HUDPickupItem.cc
   code/branches/HUD_HS16/src/modules/overlays/hud/HUDPickupItem.h
   code/branches/HUD_HS16/src/modules/overlays/hud/HUDPickupSystem.cc
   code/branches/HUD_HS16/src/modules/pickup/PickupManager.cc
   code/branches/HUD_HS16/src/orxonox/interfaces/Pickupable.h
Log:
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

Modified: code/branches/HUD_HS16/src/modules/overlays/hud/HUDPickupItem.cc
===================================================================
--- code/branches/HUD_HS16/src/modules/overlays/hud/HUDPickupItem.cc	2016-12-05 15:15:27 UTC (rev 11322)
+++ code/branches/HUD_HS16/src/modules/overlays/hud/HUDPickupItem.cc	2016-12-05 17:01:02 UTC (rev 11323)
@@ -43,14 +43,16 @@
 namespace orxonox
 {
     RegisterClass(HUDPickupItem);
-    Ogre::PanelOverlayElement* overlayElement_;
 
     HUDPickupItem::HUDPickupItem(Context* context) : OrxonoxOverlay(context)
     {
         RegisterObject(HUDPickupItem);
 
-        overlayElement_ = static_cast<Ogre::PanelOverlayElement* >(Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", "HUDPickupItem" + getUniqueNumberString()));
-        
+        std::string name = "HUDPickupItem" + getUniqueNumberString();
+
+        overlayElement_ = static_cast<Ogre::PanelOverlayElement* >(Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", name ));
+        // overlayElement_->setName(name);
+
         overlayElement_->setDimensions(0.1f,0.1f);
         
     }
@@ -72,12 +74,21 @@
         this->background_->addChild(overlayElement_);
     }
 
-    void HUDPickupItem::hideMe()
+    void HUDPickupItem::hideMe(Pickupable* p)
     {
-        orxout() << this << " has called hide" << endl;
+        assert(overlayElement_);
+        assert(this->background_);
+        // if(p->isBeingDestroyed()) //if the pickup is being destroyed, we do nothing
+        // {
+        //     orxout() << "now i didnt repaint" << endl;
+        //     return;
+        // } 
+        orxout() << "name overlay element: " << overlayElement_->getName() << endl;
+        // orxout() << this << " has called hide" << endl;
         overlayElement_->hide();
-        overlayElement_->_update();
-        orxout() << "after the call the element is visible: " << overlayElement_->isVisible() << endl;
+        this->background_->removeChild(overlayElement_->getName());
+        // this->background_->_update();
+        // orxout() << "after the call the element is visible: " << overlayElement_->isVisible() << endl;
     }
 
     // void HUDWeapon::XMLPort(Element& xmlelement, XMLPort::Mode mode)

Modified: code/branches/HUD_HS16/src/modules/overlays/hud/HUDPickupItem.h
===================================================================
--- code/branches/HUD_HS16/src/modules/overlays/hud/HUDPickupItem.h	2016-12-05 15:15:27 UTC (rev 11322)
+++ code/branches/HUD_HS16/src/modules/overlays/hud/HUDPickupItem.h	2016-12-05 17:01:02 UTC (rev 11323)
@@ -23,6 +23,7 @@
     {
     public:
         HUDPickupItem(Context* context);
+        Ogre::PanelOverlayElement* overlayElement_;
         virtual ~HUDPickupItem();
 
         // virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
@@ -36,7 +37,7 @@
 
         // void setPickup(Pickup* pickup);  
         void initializeMaterial(const std::string& s, float x, float y);  
-        void hideMe(); 
+        void hideMe(Pickupable* p); 
 
     private:
         // void createHUDChilds();
@@ -46,6 +47,7 @@
         // void updateSize();
         // void updatePosition();
 
+        
         WeakPtr<Pawn> owner_;
         WeakPtr<Pickup> pickup_;
 

Modified: code/branches/HUD_HS16/src/modules/overlays/hud/HUDPickupSystem.cc
===================================================================
--- code/branches/HUD_HS16/src/modules/overlays/hud/HUDPickupSystem.cc	2016-12-05 15:15:27 UTC (rev 11322)
+++ code/branches/HUD_HS16/src/modules/overlays/hud/HUDPickupSystem.cc	2016-12-05 17:01:02 UTC (rev 11323)
@@ -58,7 +58,7 @@
     {
         if (this->isInitialized())
         {
-            //TODO: Destroy me
+            this->picks.clear();
         }
     }
 
@@ -79,19 +79,23 @@
             for(Pickupable* p : picks)
             {
                 // orxout() << "actual pick is: " << p << endl;
-                if(i%4==0)
+                if(i%5==0)
                 {
                     offsetY+=0.04f;
                     i=0;
                 }   
-                HUDPickupItem* item = new HUDPickupItem(this->getContext());
-                // item->initializeMaterial(((Pickup*)p)->getRepresentationName(), offsetX+i*x, offsetY);
+                if(this->picks.count(p)==0)
+                {
+                    HUDPickupItem* item = new HUDPickupItem(this->getContext());
+                    // item->initializeMaterial(((Pickup*)p)->getRepresentationName(), offsetX+i*x, offsetY);
                 if(i%2==0)
                     item->initializeMaterial("Shield", offsetX+i*x, offsetY);
                 else
                     item->initializeMaterial("ArrowUp", offsetX+i*x, offsetY);
                 item->setOverlayGroup(this->getOverlayGroup());
                 this->picks[p] = item;
+                }
+                
                 ++i;
             }
         }
@@ -103,12 +107,17 @@
 
     void HUDPickupSystem::removePickup(Pickupable* pickup)
     {
+        assert(pickup);
         HUDPickupItem* item = this->picks.find(pickup)->second;
         orxout() << "removePickup: pickup= " << pickup << " item= " << item << endl;
         assert(item);
-        item->setOverlayGroup(nullptr); 
-        item->hideMe();
-        overlayElement_->_update();
+        // item->setOverlayGroup(nullptr);
+        item->hideMe(pickup);
+        assert(overlayElement_);
+        // overlayElement_->_update();
+        assert(this->background_);
+        // this->background_->_update();
+        this->picks.erase(pickup);
     }
 
     void HUDPickupSystem::destroyAll()

Modified: code/branches/HUD_HS16/src/modules/pickup/PickupManager.cc
===================================================================
--- code/branches/HUD_HS16/src/modules/pickup/PickupManager.cc	2016-12-05 15:15:27 UTC (rev 11322)
+++ code/branches/HUD_HS16/src/modules/pickup/PickupManager.cc	2016-12-05 17:01:02 UTC (rev 11323)
@@ -265,11 +265,10 @@
     {
         assert(pickup);
 
-        if(!pickupSystem)
-        {
-            for (HUDPickupSystem* hud : ObjectList<HUDPickupSystem>())
-                pickupSystem = hud;
-        }
+
+        for (HUDPickupSystem* hud : ObjectList<HUDPickupSystem>())
+            pickupSystem = hud;
+        
         assert(pickupSystem); //pickupSystem HAS to be there!
 
         if(!GameMode::isMaster()) // If this is neither standalone nor the server.
@@ -320,7 +319,6 @@
             this->picks.erase(std::remove(this->picks.begin(), this->picks.end(), pickup), this->picks.end()); //remove pickup from vector
 
             pickupSystem->removePickup(pickup);
-            pickupSystem->updatePickupList(picks);
         }
 
         // If we're either in standalone mode or this is the host whom the change of the pickup's status concerns.
@@ -365,10 +363,11 @@
 
         orxout() << "The pickup is being used: " << pickup->isUsed() << endl;
 
-        if(pickup->isUsed())
-            manager.usePickup(index, false);
-        else
-            manager.usePickup(index, true);
+        pickup->drop(true);
+        // if(pickup->isUsed())
+        //     manager.usePickup(index, false);
+        // else
+        //     manager.usePickup(index, true);
     }
 
 

Modified: code/branches/HUD_HS16/src/orxonox/interfaces/Pickupable.h
===================================================================
--- code/branches/HUD_HS16/src/orxonox/interfaces/Pickupable.h	2016-12-05 15:15:27 UTC (rev 11322)
+++ code/branches/HUD_HS16/src/orxonox/interfaces/Pickupable.h	2016-12-05 17:01:02 UTC (rev 11323)
@@ -95,6 +95,13 @@
             virtual void changedCarrier(void) {}
 
             /**
+            @brief Check whether the Pickupable is in the process of being destroyed.
+            @return Returns true if so.
+            */
+            inline bool isBeingDestroyed(void)
+                { return this->beingDestroyed_; }
+                
+            /**
             @brief Returns whether the Pickupable is currently picked up.
             @return Returns true if the Pickupable is currently picked up, false if not.
             */
@@ -154,13 +161,6 @@
                 { this->enabled_ = false; }
 
             /**
-            @brief Check whether the Pickupable is in the process of being destroyed.
-            @return Returns true if so.
-            */
-            inline bool isBeingDestroyed(void)
-                { return this->beingDestroyed_; }
-
-            /**
             @brief Facilitates the creation of a PickupSpawner upon dropping of the Pickupable.
                    This method must be implemented by any class directly inheriting from Pickupable.
             @return Returns true if a spawner was created, false if not.




More information about the Orxonox-commit mailing list