[Orxonox-commit 7087] r11704 - in code/trunk: data/defaultConfig data/gui/scripts src/modules/overlays src/modules/overlays/hud src/modules/pickup src/orxonox src/orxonox/interfaces

landauf at orxonox.net landauf at orxonox.net
Sat Jan 6 03:16:00 CET 2018


Author: landauf
Date: 2018-01-06 03:16:00 +0100 (Sat, 06 Jan 2018)
New Revision: 11704

Modified:
   code/trunk/data/defaultConfig/keybindings.ini
   code/trunk/data/gui/scripts/KeyBindMenu.lua
   code/trunk/src/modules/overlays/CMakeLists.txt
   code/trunk/src/modules/overlays/hud/HUDPickupSystem.cc
   code/trunk/src/modules/overlays/hud/HUDPickupSystem.h
   code/trunk/src/modules/pickup/CMakeLists.txt
   code/trunk/src/modules/pickup/PickupManager.cc
   code/trunk/src/modules/pickup/PickupManager.h
   code/trunk/src/orxonox/CMakeLists.txt
   code/trunk/src/orxonox/interfaces/Pickupable.h
Log:
[HUD_HS16] fixed wrong dependency between overlays and pickup module: pickup should NOT depend on overlays; instead overlays should use pickup.

also reverted all changes from HUD_HS16 in PickupManager for several reasons:
 - calling HUDPickupSystem is not necessary anymore due to the fixed dependencies
 - adding a console command is not necessary because there is already a full GUI for this purpose (press F4)
 - limiting the number of pickups to 10 is a bad idea because PickupManager manages pickups for ALL players in the game

Modified: code/trunk/data/defaultConfig/keybindings.ini
===================================================================
--- code/trunk/data/defaultConfig/keybindings.ini	2018-01-06 01:11:17 UTC (rev 11703)
+++ code/trunk/data/defaultConfig/keybindings.ini	2018-01-06 02:16:00 UTC (rev 11704)
@@ -69,26 +69,26 @@
 KeyNextTrack=
 KeyNoConvert=
 KeyNumLock=
-KeyNumRow0="useUnusePickup 0"
-KeyNumRow1="useUnusePickup 1"
-KeyNumRow2="useUnusePickup 2"
-KeyNumRow3="useUnusePickup 3"
-KeyNumRow4="useUnusePickup 4"
-KeyNumRow5="useUnusePickup 5"
-KeyNumRow6="useUnusePickup 6"
-KeyNumRow7="useUnusePickup 7"
-KeyNumRow8="useUnusePickup 8"
-KeyNumRow9="useUnusePickup 9"
-KeyNumpad0="useUnusePickup 0"
-KeyNumpad1="useUnusePickup 1"
-KeyNumpad2="useUnusePickup 2"
-KeyNumpad3="useUnusePickup 3"
-KeyNumpad4="useUnusePickup 4"
-KeyNumpad5="useUnusePickup 5"
-KeyNumpad6="useUnusePickup 6"
-KeyNumpad7="useUnusePickup 7"
-KeyNumpad8="useUnusePickup 8"
-KeyNumpad9="useUnusePickup 9"
+KeyNumRow0=
+KeyNumRow1="toggleFormationFlight"
+KeyNumRow2="FFChangeMode"
+KeyNumRow3=
+KeyNumRow4=
+KeyNumRow5=
+KeyNumRow6=
+KeyNumRow7=
+KeyNumRow8=
+KeyNumRow9=
+KeyNumpad0=
+KeyNumpad1=
+KeyNumpad2=
+KeyNumpad3=
+KeyNumpad4=
+KeyNumpad5=
+KeyNumpad6=
+KeyNumpad7=
+KeyNumpad8=
+KeyNumpad9=
 KeyNumpadAdd=
 KeyNumpadComma=
 KeyNumpadEnter=
@@ -95,8 +95,8 @@
 KeyNumpadEquals=
 KeyNumpadPeriod=
 KeyNumpadSubtract=
-KeyO="toggleFormationFlight"
-KeyP="FFChangeMode"
+KeyO=
+KeyP=
 KeyPageDown="scale -1 rotateRoll"
 KeyPageUp=
 KeyPause=pause

Modified: code/trunk/data/gui/scripts/KeyBindMenu.lua
===================================================================
--- code/trunk/data/gui/scripts/KeyBindMenu.lua	2018-01-06 01:11:17 UTC (rev 11703)
+++ code/trunk/data/gui/scripts/KeyBindMenu.lua	2018-01-06 02:16:00 UTC (rev 11704)
@@ -35,7 +35,6 @@
     table.insert(commandList, "mouseLook")
     table.insert(commandList, "pause")
     table.insert(commandList, "printScreen")
-    table.insert(commandList, "useUnusePickup")
     if orxonox.GUIManager:inDevMode() then
         table.insert(commandList, "printScreenHD")
         table.insert(commandList, "createSkybox")
@@ -71,7 +70,6 @@
     table.insert(nameList, "Look Around")
     table.insert(nameList, "Pause")
     table.insert(nameList, "Screenshot")
-    table.insert(nameList, "Pickup 0")
     if orxonox.GUIManager:inDevMode() then
         table.insert(nameList, "HD screenshot")
         table.insert(nameList, "Create Skybox")

Modified: code/trunk/src/modules/overlays/CMakeLists.txt
===================================================================
--- code/trunk/src/modules/overlays/CMakeLists.txt	2018-01-06 01:11:17 UTC (rev 11703)
+++ code/trunk/src/modules/overlays/CMakeLists.txt	2018-01-06 02:16:00 UTC (rev 11704)
@@ -15,6 +15,7 @@
     OverlaysPrecompiledHeaders.h
   LINK_LIBRARIES
     orxonox
+    pickup
     weapons
   SOURCE_FILES ${OVERLAYS_SRC_FILES}
 )

Modified: code/trunk/src/modules/overlays/hud/HUDPickupSystem.cc
===================================================================
--- code/trunk/src/modules/overlays/hud/HUDPickupSystem.cc	2018-01-06 01:11:17 UTC (rev 11703)
+++ code/trunk/src/modules/overlays/hud/HUDPickupSystem.cc	2018-01-06 02:16:00 UTC (rev 11704)
@@ -37,7 +37,6 @@
 #include "util/StringUtils.h"
 #include "HUDPickupSystem.h"
 #include "HUDPickupItem.h"
-#include "pickup/Pickup.h"
 #include "pickup/PickupManager.h"
 
 namespace orxonox
@@ -65,10 +64,11 @@
 
     }
     
-    void HUDPickupSystem::sync(std::vector<Pickupable*> p, std::map<Pickupable*, uint32_t> indexes_)
+    void HUDPickupSystem::tick(float dt)
     {
+        SUPER(HUDPickupSystem, tick, dt);
+
         //hide all pickup symbols in HUD and delete from local map
-        
         for(HUDPickupItem* item : items_)
         {
             item->hideMe();
@@ -83,14 +83,16 @@
         const float x = 0.102f;
         const float y = 0.075f;
 
-        for(Pickupable* pickup:p)
+        int numPickups = PickupManager::getInstance().getNumPickups();
+        for (int index = 0; index < numPickups; ++index)
         {
-            int index = indexes_.find(pickup)->second;
             int row = index / 5;
             int column = index % 5;
 
+            const PickupInventoryContainer* container = PickupManager::getInstance().popPickup();
+
             HUDPickupItem* item = new HUDPickupItem(this->getContext());
-            item->initializeMaterial(this->getIcon(((Pickup*)pickup)->getRepresentationName()), offsetX+column*x, offsetY+row*y);
+            item->initializeMaterial(this->getIcon(container->representationName), offsetX+column*x, offsetY+row*y);
             item->setOverlayGroup(this->getOverlayGroup());
             items_.push_back(item);
         }

Modified: code/trunk/src/modules/overlays/hud/HUDPickupSystem.h
===================================================================
--- code/trunk/src/modules/overlays/hud/HUDPickupSystem.h	2018-01-06 01:11:17 UTC (rev 11703)
+++ code/trunk/src/modules/overlays/hud/HUDPickupSystem.h	2018-01-06 02:16:00 UTC (rev 11704)
@@ -36,17 +36,18 @@
 
 #include "util/OgreForwardRefs.h"
 #include "overlays/OrxonoxOverlay.h"
+#include "tools/interfaces/Tickable.h"
 
 namespace orxonox
 {
-    class _OverlaysExport HUDPickupSystem : public OrxonoxOverlay
+    class _OverlaysExport HUDPickupSystem : public OrxonoxOverlay, public Tickable
     {
     public:
         HUDPickupSystem(Context* context);
         virtual ~HUDPickupSystem();
 
-        void sizeChanged();
-        void sync(std::vector<Pickupable*> p, std::map<Pickupable*, uint32_t> indexes_);
+        virtual void tick(float dt) override;
+        virtual void sizeChanged() override;
 
     private:
         

Modified: code/trunk/src/modules/pickup/CMakeLists.txt
===================================================================
--- code/trunk/src/modules/pickup/CMakeLists.txt	2018-01-06 01:11:17 UTC (rev 11703)
+++ code/trunk/src/modules/pickup/CMakeLists.txt	2018-01-06 02:16:00 UTC (rev 11704)
@@ -18,7 +18,6 @@
   PCH_FILE
     PickupPrecompiledHeaders.h
   LINK_LIBRARIES
-    overlays
     orxonox
   SOURCE_FILES ${PICKUP_SRC_FILES}
 )

Modified: code/trunk/src/modules/pickup/PickupManager.cc
===================================================================
--- code/trunk/src/modules/pickup/PickupManager.cc	2018-01-06 01:11:17 UTC (rev 11703)
+++ code/trunk/src/modules/pickup/PickupManager.cc	2018-01-06 02:16:00 UTC (rev 11704)
@@ -40,9 +40,6 @@
 #include "core/singleton/ScopedSingletonIncludes.h"
 #include "network/Host.h"
 #include "network/NetworkFunctionIncludes.h"
-#include "core/input/KeyBinderManager.h"    //for keybinding
-#include "core/input/KeyBinder.h"           //for keybinding
-#include "core/command/ConsoleCommandIncludes.h"
 
 #include "infos/PlayerInfo.h"
 #include "interfaces/PickupCarrier.h"
@@ -50,7 +47,6 @@
 
 #include "CollectiblePickup.h"
 #include "PickupRepresentation.h"
-#include "overlays/hud/HUDPickupSystem.h"
 
 namespace orxonox
 {
@@ -67,8 +63,6 @@
 
     RegisterAbstractClass(PickupManager).inheritsFrom<PickupListener>();
 
-    SetConsoleCommand("useUnusePickup", &PickupManager::useUnusePickup).addShortcut().setActive(true);
-
     /**
     @brief
         Constructor. Registers the PickupManager and creates the default PickupRepresentation.
@@ -264,9 +258,6 @@
     {
         assert(pickup);
 
-        for (HUDPickupSystem* hud : ObjectList<HUDPickupSystem>())
-            pickupSystem = hud;
-        
         if(!GameMode::isMaster()) // If this is neither standalone nor the server.
             return;
 
@@ -294,12 +285,6 @@
             // Add the Pickupable to the indexes_ and pickups_ lists.
             this->indexes_[pickup] = index;
             this->pickups_[index] = pickup;
-
-            this->picks.push_back(pickup);
-
-            if(pickupSystem)
-                pickupSystem->sync(picks, indexes_);
-            
         }
         else // If it was dropped, it is removed from the required lists.
         {
@@ -307,14 +292,9 @@
             std::map<Pickupable*, uint32_t>::iterator it = this->indexes_.find(pickup);
             index = it->second;
 
-            this->indexes_.erase(pickup);
-            this->pickups_.erase(index); //set to null, so that can be identified as free slot by getPickupIndex()
-
-
-            this->picks.erase(std::remove(this->picks.begin(), this->picks.end(), pickup), this->picks.end()); //remove pickup from vector
-
-            if(pickupSystem)
-                pickupSystem->sync(picks, indexes_);
+            // Remove the Pickupable from the indexes_ and pickups_ list.
+            this->indexes_.erase(it);
+            this->pickups_.erase(index);
         }
 
         // If we're either in standalone mode or this is the host whom the change of the pickup's status concerns.
@@ -342,33 +322,6 @@
 
     }
 
-    //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) 
-    {
-        PickupManager& manager = PickupManager::getInstance();
-
-        if(!manager.pickups_.count(index)) return; //if pickup is no longer here, dont do anything
-
-        Pickupable* pickup=manager.pickups_.find(index)->second;
-        if(pickup==nullptr)
-        {
-            return;                       //pickup does not exist
-        }
-
-        //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
-        //     manager.usePickup(index, true);
-    }
-
-
     /**
     @brief
         Helper method to react to the change in the pickedUp status of a Pickupable.
@@ -447,10 +400,7 @@
                 return;
             Pickupable* pickupable = this->pickups_.find(pickup)->second;
             if(pickupable != nullptr)
-            {
                 pickupable->drop();
-
-            }
         }
         // If we're neither server nor standalone we drop the pickup by calling dropPickupNetworked() of the PickupManager on the server.
         else
@@ -543,23 +493,16 @@
 
     /**
     @brief
-        Get a new index between 0 and 9 for a Pickupable.
-        If all slots are occupied, the Pickupable in the first slot will be dropped.
+        Get a new index for a Pickupable.
+        This will work as long as the number of Pickupables that are picked up is sufficiently small and as long as they don't exist forever.
     @return
         Returns the new index.
     */
     uint32_t PickupManager::getPickupIndex(void)
     {
-        //check if there are free slots available
-
-        for(uint32_t i=0; i<10; i++)
-        {
-            if(!pickups_.count(i)) return i;
-        }
-        //all slots are full and we have to drop sth
-        orxout(internal_info, context::pickups) << "everything was full and we have now dropped the first element" << endl;
-        this->dropPickup(0);
-        return 0;
+        if(this->pickupHighestIndex_ == uint32_t(~0x0)-1) // If we've reached the highest possible number, we wrap around.
+            this->pickupHighestIndex_ = 0;
+        return this->pickupHighestIndex_++;
     }
 
 }

Modified: code/trunk/src/modules/pickup/PickupManager.h
===================================================================
--- code/trunk/src/modules/pickup/PickupManager.h	2018-01-06 01:11:17 UTC (rev 11703)
+++ code/trunk/src/modules/pickup/PickupManager.h	2018-01-06 02:16:00 UTC (rev 11704)
@@ -41,10 +41,9 @@
 #include "core/object/WeakPtr.h"
 
 #include "PickupRepresentation.h"
-#include "interfaces/Pickupable.h"
+
 #include "util/Singleton.h"
 #include "interfaces/PickupListener.h"
-#include "overlays/hud/HUDPickupSystem.h"
 
 namespace orxonox // tolua_export
 { // tolua_export
@@ -135,7 +134,6 @@
                 { return (this->pickupsIterator_++)->second; }
 
             void dropPickup(uint32_t pickup); //!< Drop the input Pickupable.
-            static void useUnusePickup(uint32_t index); //tolua_export
             void usePickup(uint32_t pickup, bool use); //!< Use (or unuse) the input Pickupable.
              /**
             @brief Check whether the input Pickupable is valid, meaning that it is in the PickupManager's list and still exists.
@@ -148,12 +146,8 @@
 
             static void dropPickupNetworked(uint32_t pickup); //!< Helper method to drop the input pickup on the server.
             static void usePickupNetworked(uint32_t pickup, bool use); //!< Helper method to use (or unuse) the input Pickupable on the server.
-            void setPickupSystem(HUDPickupSystem* system);
 
         private:
-            HUDPickupSystem* pickupSystem;
-            std::vector<Pickupable*> picks;
-
             static PickupManager* singletonPtr_s;
             static const std::string guiName_s; //!< The name of the PickupInventory
             bool guiLoaded_; //!< Whether the PickupInventory GUI has been loaded, yet.
@@ -171,7 +165,7 @@
 
             void updateGUI(void); //!< Updates the PickupInventory GUI.
             uint32_t getPickupIndex(void); //!< Get a new index for a Pickupable.
-            
+
     }; // tolua_export
 
 } // tolua_export

Modified: code/trunk/src/orxonox/CMakeLists.txt
===================================================================
--- code/trunk/src/orxonox/CMakeLists.txt	2018-01-06 01:11:17 UTC (rev 11703)
+++ code/trunk/src/orxonox/CMakeLists.txt	2018-01-06 02:16:00 UTC (rev 11704)
@@ -19,7 +19,6 @@
 
 INCLUDE_DIRECTORIES(
   ${CMAKE_SOURCE_DIR}/src/libraries
-  ${CMAKE_SOURCE_DIR}/src/modules
   ${CMAKE_CURRENT_SOURCE_DIR}
 )
 

Modified: code/trunk/src/orxonox/interfaces/Pickupable.h
===================================================================
--- code/trunk/src/orxonox/interfaces/Pickupable.h	2018-01-06 01:11:17 UTC (rev 11703)
+++ code/trunk/src/orxonox/interfaces/Pickupable.h	2018-01-06 02:16:00 UTC (rev 11704)
@@ -95,13 +95,6 @@
             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.
             */
@@ -161,6 +154,13 @@
                 { 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