[Orxonox-commit 6707] r11336 - in code/branches/HUD_HS16/src: modules/overlays/hud modules/pickup orxonox/gamestates

patricwi at orxonox.net patricwi at orxonox.net
Mon Dec 12 16:20:50 CET 2016


Author: patricwi
Date: 2016-12-12 16:20:50 +0100 (Mon, 12 Dec 2016)
New Revision: 11336

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/overlays/hud/HUDPickupSystem.h
   code/branches/HUD_HS16/src/modules/pickup/PickupManager.cc
   code/branches/HUD_HS16/src/modules/pickup/PickupManager.h
   code/branches/HUD_HS16/src/orxonox/gamestates/GSLevel.cc
   code/branches/HUD_HS16/src/orxonox/gamestates/GSLevel.h
Log:
finished version of HUD and PickupSystem. crash bug remaining

Modified: code/branches/HUD_HS16/src/modules/overlays/hud/HUDPickupItem.cc
===================================================================
--- code/branches/HUD_HS16/src/modules/overlays/hud/HUDPickupItem.cc	2016-12-12 15:05:08 UTC (rev 11335)
+++ code/branches/HUD_HS16/src/modules/overlays/hud/HUDPickupItem.cc	2016-12-12 15:20:50 UTC (rev 11336)
@@ -52,7 +52,7 @@
 
         overlayElement_ = static_cast<Ogre::PanelOverlayElement* >(Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", name ));
 
-        overlayElement_->setDimensions(0.075f,0.1f);
+        overlayElement_->setDimensions(0.075f,0.08f);
         
     }
 
@@ -66,7 +66,6 @@
 
     void HUDPickupItem::initializeMaterial(const std::string& s, float x, float y)
     {
-        orxout() << "material name is: " << s << endl;
         overlayElement_->setMaterialName(s);
         overlayElement_->setPosition(x, y);
         overlayElement_->show();
@@ -78,16 +77,7 @@
         if(!repaint) return;                     //dont do anything, if we are not allowed to repaint because the level is terminating
         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();
         this->background_->removeChild(overlayElement_->getName());
-        // this->background_->_update();
-        // orxout() << "after the call the element is visible: " << overlayElement_->isVisible() << endl;
     }
 }

Modified: code/branches/HUD_HS16/src/modules/overlays/hud/HUDPickupItem.h
===================================================================
--- code/branches/HUD_HS16/src/modules/overlays/hud/HUDPickupItem.h	2016-12-12 15:05:08 UTC (rev 11335)
+++ code/branches/HUD_HS16/src/modules/overlays/hud/HUDPickupItem.h	2016-12-12 15:20:50 UTC (rev 11336)
@@ -25,29 +25,11 @@
         HUDPickupItem(Context* context);
         Ogre::PanelOverlayElement* overlayElement_;
         virtual ~HUDPickupItem();
-
-        // virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
-        // virtual void tick(float dt) override;
-        // virtual void changedOwner() override;
-        // virtual void changedOverlayGroup() override;
-        // virtual void changedVisibility() override;
-        // virtual void changedName() override;
-        // virtual void positionChanged() override;
-        // virtual void sizeChanged() override;
-
-        // void setPickup(Pickup* pickup);  
+        
         void initializeMaterial(const std::string& s, float x, float y);  
         void hideMe(Pickupable* p, bool repaint); 
 
-    private:
-        // void createHUDChilds();
-        // void positionHUDChilds();
-        // void destroyHUDChilds();
-        // void updateWeaponModeList();
-        // void updateSize();
-        // void updatePosition();
-
-        
+    private:        
         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-12 15:05:08 UTC (rev 11335)
+++ code/branches/HUD_HS16/src/modules/overlays/hud/HUDPickupSystem.cc	2016-12-12 15:20:50 UTC (rev 11336)
@@ -61,37 +61,33 @@
         }
     }
 
-    void HUDPickupSystem::updatePickupList(std::vector<Pickupable*> picks)
+    void HUDPickupSystem::updatePickupList(std::vector<Pickupable*> picks, std::map<Pickupable*, uint32_t> indexes_)
     {
-        int i=0;
-        const float offsetX = 0.335f;
-        float offsetY = 0.77f;
-        const float x = 0.1f;
+        int i =0;
+        const float offsetX = 0.345f;
+        float offsetY = 0.82f;
+        const float x = 0.102f;
 
-        orxout() << "size: " << picks.size() << endl;
-
         if(picks.size()>0)
         {
-
             for(Pickupable* p : picks)
             {
-                // orxout() << "actual pick is: " << p << endl;
-                if(i%5==0)
+                i = indexes_.find(p)->second;
+                offsetY = 0.82f;
+
+                if(i>=5)
                 {
-                    offsetY+=0.04f;
-                    i=0;
+                    offsetY+=0.075f;
+                    i-=5;
                 }   
                 if(this->picks.count(p)==0)
                 {
                     HUDPickupItem* item = new HUDPickupItem(this->getContext());
                     item->initializeMaterial(this->getIcon(((Pickup*)p)->getRepresentationName()), offsetX+i*x, offsetY);
-                    orxout() << ((Pickup*)p)->getRepresentationName() << endl;
                 
                     item->setOverlayGroup(this->getOverlayGroup());
                     this->picks[p] = item;
                 }
-                
-                ++i;
             }
         }
     }
@@ -104,14 +100,11 @@
     {
         assert(pickup);
         HUDPickupItem* item = this->picks.find(pickup)->second;
-        orxout() << "removePickup: pickup= " << pickup << " item= " << item << endl;
+        orxout(internal_info, context::pickups) << "removePickup: pickup= " << pickup << " item= " << item << endl;
         assert(item);
-        // item->setOverlayGroup(nullptr);
         item->hideMe(pickup, repaint);
         assert(overlayElement_);
-        // overlayElement_->_update();
         assert(this->background_);
-        // this->background_->_update();
         this->picks.erase(pickup);
     }
 
@@ -123,7 +116,7 @@
     std::string HUDPickupSystem::getIcon(std::string repName)
     {
         if(repName.find("invisible", 0)!=std::string::npos) return "Eye";
-        else if(repName.find("tri", 0)!=std::string::npos) return "Asterix";
+        else if(repName.find("tri", 0)!=std::string::npos) return "Asterisk";
         else if(repName.find("health", 0)!=std::string::npos || repName.find("Health", 0)!=std::string::npos) return "Cross";
         else if(repName.find("shield", 0)!=std::string::npos) return "Shield";
         else if(repName.find("munition", 0)!=std::string::npos) return "Munition";
@@ -131,7 +124,6 @@
         else if(repName.find("boost", 0)!=std::string::npos) return "Flash";
         else if(repName.find("speed", 0)!=std::string::npos) return "3arrowsup";
         else if(repName.find("drone", 0)!=std::string::npos) return "Damage";
-        //        else if(repName.find("xxxxxxx", 0)!=std::string::npos) return "Splash";
         else return "Unknown";
     }
 }

Modified: code/branches/HUD_HS16/src/modules/overlays/hud/HUDPickupSystem.h
===================================================================
--- code/branches/HUD_HS16/src/modules/overlays/hud/HUDPickupSystem.h	2016-12-12 15:05:08 UTC (rev 11335)
+++ code/branches/HUD_HS16/src/modules/overlays/hud/HUDPickupSystem.h	2016-12-12 15:20:50 UTC (rev 11336)
@@ -55,18 +55,11 @@
         HUDPickupSystem(Context* context);
         virtual ~HUDPickupSystem();
 
-        // virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
-        // virtual void changedOwner() override;
-        // virtual void changedOverlayGroup() override;
-        // virtual void changedVisibility() override;
-        // virtual void changedName() override;
-        // virtual void positionChanged() override;
-        // virtual void sizeChanged() override;
-        void updatePickupList(std::vector<Pickupable*> picks);  
+        void updatePickupList(std::vector<Pickupable*> picks, std::map<Pickupable*, uint32_t> indexes_);  
         void createPickupList();  
         void removePickup(Pickupable* pickup);
 
-        bool repaint=true;
+        bool repaint=true; //if we shouldnt repaint, set this to false
 
     private:
         

Modified: code/branches/HUD_HS16/src/modules/pickup/PickupManager.cc
===================================================================
--- code/branches/HUD_HS16/src/modules/pickup/PickupManager.cc	2016-12-12 15:05:08 UTC (rev 11335)
+++ code/branches/HUD_HS16/src/modules/pickup/PickupManager.cc	2016-12-12 15:20:50 UTC (rev 11336)
@@ -265,12 +265,9 @@
     {
         assert(pickup);
 
-
         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.
             return;
 
@@ -299,11 +296,10 @@
             this->indexes_[pickup] = index;
             this->pickups_[index] = pickup;
 
-            orxout() << "the pickup is: " << pickup << endl;
-
             this->picks.push_back(pickup);
 
-            pickupSystem->updatePickupList(picks);
+            if(pickupSystem)
+                pickupSystem->updatePickupList(picks, indexes_);
             
         }
         else // If it was dropped, it is removed from the required lists.
@@ -318,7 +314,8 @@
 
             this->picks.erase(std::remove(this->picks.begin(), this->picks.end(), pickup), this->picks.end()); //remove pickup from vector
 
-            pickupSystem->removePickup(pickup);
+            if(pickupSystem)
+                pickupSystem->removePickup(pickup);
         }
 
         // If we're either in standalone mode or this is the host whom the change of the pickup's status concerns.
@@ -348,10 +345,9 @@
 
     //This function is called by the command line or by the key binding
     //it uses or unuses the pickup, depending on its current state
+    //or drops it (depends what you comment/uncomment)
     void PickupManager::useUnusePickup(uint32_t index) 
     {
-        orxout() << "Hello there I was here " << index << endl;
-
         PickupManager& manager = PickupManager::getInstance();
 
         if(!manager.pickups_.count(index)) return; //if pickup is no longer here, dont do anything
@@ -359,14 +355,14 @@
         Pickupable* pickup=manager.pickups_.find(index)->second;
         if(pickup==nullptr)
         {
-            orxout() << "The pickup does not exist." << endl;
             return;                       //pickup does not exist
         }
 
-        orxout() << "The pickup is being used: " << pickup->isUsed() << endl;
-
+        //if the pickup should be dropped upon key press
         manager.dropPickup(index);
 
+        //if the pickup should be used/unused upon key press
+
         // if(pickup->isUsed())
         //     manager.usePickup(index, false);
         // else
@@ -562,7 +558,7 @@
             if(!pickups_.count(i)) return i;
         }
         //all slots are full and we have to drop sth
-        orxout() << "everything was full and we have now dropped the first element" << endl;
+        orxout(internal_info, context::pickups) << "everything was full and we have now dropped the first element" << endl;
         this->dropPickup(0);
         return 0;
     }

Modified: code/branches/HUD_HS16/src/modules/pickup/PickupManager.h
===================================================================
--- code/branches/HUD_HS16/src/modules/pickup/PickupManager.h	2016-12-12 15:05:08 UTC (rev 11335)
+++ code/branches/HUD_HS16/src/modules/pickup/PickupManager.h	2016-12-12 15:20:50 UTC (rev 11336)
@@ -171,9 +171,6 @@
 
             void updateGUI(void); //!< Updates the PickupInventory GUI.
             uint32_t getPickupIndex(void); //!< Get a new index for a Pickupable.
-
-            void addKeyBindingForNewPickup(Pickupable* pickup, uint32_t index);
-            void removeKeyBindingForOldPickup(Pickupable* pickup, uint32_t index);
             
     }; // tolua_export
 

Modified: code/branches/HUD_HS16/src/orxonox/gamestates/GSLevel.cc
===================================================================
--- code/branches/HUD_HS16/src/orxonox/gamestates/GSLevel.cc	2016-12-12 15:05:08 UTC (rev 11335)
+++ code/branches/HUD_HS16/src/orxonox/gamestates/GSLevel.cc	2016-12-12 15:20:50 UTC (rev 11336)
@@ -49,6 +49,7 @@
 #include "Level.h"
 #include "PlayerManager.h"
 #include "GSRoot.h"
+// #include "overlays/hud/HUDPickupSystem.h"
 
 namespace orxonox
 {
@@ -125,6 +126,13 @@
         if (GameMode::showsGraphics())
             InputManager::getInstance().leaveState("game");
 
+        // HUDPickupSystem* pickupSystem;
+
+        // for (HUDPickupSystem* hud : ObjectList<HUDPickupSystem>())
+        //     pickupSystem = hud;
+
+        // pickupSystem->repaint=false;
+
         // disconnect all HumanPlayers
         PlayerManager::getInstance().disconnectAllClients();
 

Modified: code/branches/HUD_HS16/src/orxonox/gamestates/GSLevel.h
===================================================================
--- code/branches/HUD_HS16/src/orxonox/gamestates/GSLevel.h	2016-12-12 15:05:08 UTC (rev 11335)
+++ code/branches/HUD_HS16/src/orxonox/gamestates/GSLevel.h	2016-12-12 15:20:50 UTC (rev 11336)
@@ -30,6 +30,7 @@
 #define _GSLevel_H__
 
 #include "OrxonoxPrereqs.h"
+// #include "overlays/OverlaysPrereqs.h"
 
 #include <string>
 #include <set>




More information about the Orxonox-commit mailing list