Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 11704 for code


Ignore:
Timestamp:
Jan 6, 2018, 3:16:00 AM (7 years ago)
Author:
landauf
Message:

[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
Location:
code/trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/data/defaultConfig/keybindings.ini

    r11353 r11704  
    7070KeyNoConvert=
    7171KeyNumLock=
    72 KeyNumRow0="useUnusePickup 0"
    73 KeyNumRow1="useUnusePickup 1"
    74 KeyNumRow2="useUnusePickup 2"
    75 KeyNumRow3="useUnusePickup 3"
    76 KeyNumRow4="useUnusePickup 4"
    77 KeyNumRow5="useUnusePickup 5"
    78 KeyNumRow6="useUnusePickup 6"
    79 KeyNumRow7="useUnusePickup 7"
    80 KeyNumRow8="useUnusePickup 8"
    81 KeyNumRow9="useUnusePickup 9"
    82 KeyNumpad0="useUnusePickup 0"
    83 KeyNumpad1="useUnusePickup 1"
    84 KeyNumpad2="useUnusePickup 2"
    85 KeyNumpad3="useUnusePickup 3"
    86 KeyNumpad4="useUnusePickup 4"
    87 KeyNumpad5="useUnusePickup 5"
    88 KeyNumpad6="useUnusePickup 6"
    89 KeyNumpad7="useUnusePickup 7"
    90 KeyNumpad8="useUnusePickup 8"
    91 KeyNumpad9="useUnusePickup 9"
     72KeyNumRow0=
     73KeyNumRow1="toggleFormationFlight"
     74KeyNumRow2="FFChangeMode"
     75KeyNumRow3=
     76KeyNumRow4=
     77KeyNumRow5=
     78KeyNumRow6=
     79KeyNumRow7=
     80KeyNumRow8=
     81KeyNumRow9=
     82KeyNumpad0=
     83KeyNumpad1=
     84KeyNumpad2=
     85KeyNumpad3=
     86KeyNumpad4=
     87KeyNumpad5=
     88KeyNumpad6=
     89KeyNumpad7=
     90KeyNumpad8=
     91KeyNumpad9=
    9292KeyNumpadAdd=
    9393KeyNumpadComma=
     
    9696KeyNumpadPeriod=
    9797KeyNumpadSubtract=
    98 KeyO="toggleFormationFlight"
    99 KeyP="FFChangeMode"
     98KeyO=
     99KeyP=
    100100KeyPageDown="scale -1 rotateRoll"
    101101KeyPageUp=
  • code/trunk/data/gui/scripts/KeyBindMenu.lua

    r11353 r11704  
    3636    table.insert(commandList, "pause")
    3737    table.insert(commandList, "printScreen")
    38     table.insert(commandList, "useUnusePickup")
    3938    if orxonox.GUIManager:inDevMode() then
    4039        table.insert(commandList, "printScreenHD")
     
    7271    table.insert(nameList, "Pause")
    7372    table.insert(nameList, "Screenshot")
    74     table.insert(nameList, "Pickup 0")
    7573    if orxonox.GUIManager:inDevMode() then
    7674        table.insert(nameList, "HD screenshot")
  • code/trunk/src/modules/overlays/CMakeLists.txt

    r11056 r11704  
    1616  LINK_LIBRARIES
    1717    orxonox
     18    pickup
    1819    weapons
    1920  SOURCE_FILES ${OVERLAYS_SRC_FILES}
  • code/trunk/src/modules/overlays/hud/HUDPickupSystem.cc

    r11703 r11704  
    3838#include "HUDPickupSystem.h"
    3939#include "HUDPickupItem.h"
    40 #include "pickup/Pickup.h"
    4140#include "pickup/PickupManager.h"
    4241
     
    6665    }
    6766   
    68     void HUDPickupSystem::sync(std::vector<Pickupable*> p, std::map<Pickupable*, uint32_t> indexes_)
     67    void HUDPickupSystem::tick(float dt)
    6968    {
     69        SUPER(HUDPickupSystem, tick, dt);
     70
    7071        //hide all pickup symbols in HUD and delete from local map
    71        
    7272        for(HUDPickupItem* item : items_)
    7373        {
     
    8484        const float y = 0.075f;
    8585
    86         for(Pickupable* pickup:p)
     86        int numPickups = PickupManager::getInstance().getNumPickups();
     87        for (int index = 0; index < numPickups; ++index)
    8788        {
    88             int index = indexes_.find(pickup)->second;
    8989            int row = index / 5;
    9090            int column = index % 5;
    9191
     92            const PickupInventoryContainer* container = PickupManager::getInstance().popPickup();
     93
    9294            HUDPickupItem* item = new HUDPickupItem(this->getContext());
    93             item->initializeMaterial(this->getIcon(((Pickup*)pickup)->getRepresentationName()), offsetX+column*x, offsetY+row*y);
     95            item->initializeMaterial(this->getIcon(container->representationName), offsetX+column*x, offsetY+row*y);
    9496            item->setOverlayGroup(this->getOverlayGroup());
    9597            items_.push_back(item);
  • code/trunk/src/modules/overlays/hud/HUDPickupSystem.h

    r11702 r11704  
    3737#include "util/OgreForwardRefs.h"
    3838#include "overlays/OrxonoxOverlay.h"
     39#include "tools/interfaces/Tickable.h"
    3940
    4041namespace orxonox
    4142{
    42     class _OverlaysExport HUDPickupSystem : public OrxonoxOverlay
     43    class _OverlaysExport HUDPickupSystem : public OrxonoxOverlay, public Tickable
    4344    {
    4445    public:
     
    4647        virtual ~HUDPickupSystem();
    4748
    48         void sizeChanged();
    49         void sync(std::vector<Pickupable*> p, std::map<Pickupable*, uint32_t> indexes_);
     49        virtual void tick(float dt) override;
     50        virtual void sizeChanged() override;
    5051
    5152    private:
  • code/trunk/src/modules/pickup/CMakeLists.txt

    r11353 r11704  
    1919    PickupPrecompiledHeaders.h
    2020  LINK_LIBRARIES
    21     overlays
    2221    orxonox
    2322  SOURCE_FILES ${PICKUP_SRC_FILES}
  • code/trunk/src/modules/pickup/PickupManager.cc

    r11701 r11704  
    4141#include "network/Host.h"
    4242#include "network/NetworkFunctionIncludes.h"
    43 #include "core/input/KeyBinderManager.h"    //for keybinding
    44 #include "core/input/KeyBinder.h"           //for keybinding
    45 #include "core/command/ConsoleCommandIncludes.h"
    4643
    4744#include "infos/PlayerInfo.h"
     
    5148#include "CollectiblePickup.h"
    5249#include "PickupRepresentation.h"
    53 #include "overlays/hud/HUDPickupSystem.h"
    5450
    5551namespace orxonox
     
    6763
    6864    RegisterAbstractClass(PickupManager).inheritsFrom<PickupListener>();
    69 
    70     SetConsoleCommand("useUnusePickup", &PickupManager::useUnusePickup).addShortcut().setActive(true);
    7165
    7266    /**
     
    265259        assert(pickup);
    266260
    267         for (HUDPickupSystem* hud : ObjectList<HUDPickupSystem>())
    268             pickupSystem = hud;
    269        
    270261        if(!GameMode::isMaster()) // If this is neither standalone nor the server.
    271262            return;
     
    295286            this->indexes_[pickup] = index;
    296287            this->pickups_[index] = pickup;
    297 
    298             this->picks.push_back(pickup);
    299 
    300             if(pickupSystem)
    301                 pickupSystem->sync(picks, indexes_);
    302            
    303288        }
    304289        else // If it was dropped, it is removed from the required lists.
     
    308293            index = it->second;
    309294
    310             this->indexes_.erase(pickup);
    311             this->pickups_.erase(index); //set to null, so that can be identified as free slot by getPickupIndex()
    312 
    313 
    314             this->picks.erase(std::remove(this->picks.begin(), this->picks.end(), pickup), this->picks.end()); //remove pickup from vector
    315 
    316             if(pickupSystem)
    317                 pickupSystem->sync(picks, indexes_);
     295            // Remove the Pickupable from the indexes_ and pickups_ list.
     296            this->indexes_.erase(it);
     297            this->pickups_.erase(index);
    318298        }
    319299
     
    342322
    343323    }
    344 
    345     //This function is called by the command line or by the key binding
    346     //it uses or unuses the pickup, depending on its current state
    347     //or drops it (depends what you comment/uncomment)
    348     void PickupManager::useUnusePickup(uint32_t index)
    349     {
    350         PickupManager& manager = PickupManager::getInstance();
    351 
    352         if(!manager.pickups_.count(index)) return; //if pickup is no longer here, dont do anything
    353 
    354         Pickupable* pickup=manager.pickups_.find(index)->second;
    355         if(pickup==nullptr)
    356         {
    357             return;                       //pickup does not exist
    358         }
    359 
    360         //if the pickup should be dropped upon key press
    361         manager.dropPickup(index);
    362 
    363         //if the pickup should be used/unused upon key press
    364 
    365         // if(pickup->isUsed())
    366         //     manager.usePickup(index, false);
    367         // else
    368         //     manager.usePickup(index, true);
    369     }
    370 
    371324
    372325    /**
     
    448401            Pickupable* pickupable = this->pickups_.find(pickup)->second;
    449402            if(pickupable != nullptr)
    450             {
    451403                pickupable->drop();
    452 
    453             }
    454404        }
    455405        // If we're neither server nor standalone we drop the pickup by calling dropPickupNetworked() of the PickupManager on the server.
     
    544494    /**
    545495    @brief
    546         Get a new index between 0 and 9 for a Pickupable.
    547         If all slots are occupied, the Pickupable in the first slot will be dropped.
     496        Get a new index for a Pickupable.
     497        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.
    548498    @return
    549499        Returns the new index.
     
    551501    uint32_t PickupManager::getPickupIndex(void)
    552502    {
    553         //check if there are free slots available
    554 
    555         for(uint32_t i=0; i<10; i++)
    556         {
    557             if(!pickups_.count(i)) return i;
    558         }
    559         //all slots are full and we have to drop sth
    560         orxout(internal_info, context::pickups) << "everything was full and we have now dropped the first element" << endl;
    561         this->dropPickup(0);
    562         return 0;
     503        if(this->pickupHighestIndex_ == uint32_t(~0x0)-1) // If we've reached the highest possible number, we wrap around.
     504            this->pickupHighestIndex_ = 0;
     505        return this->pickupHighestIndex_++;
    563506    }
    564507
  • code/trunk/src/modules/pickup/PickupManager.h

    r11353 r11704  
    4242
    4343#include "PickupRepresentation.h"
    44 #include "interfaces/Pickupable.h"
     44
    4545#include "util/Singleton.h"
    4646#include "interfaces/PickupListener.h"
    47 #include "overlays/hud/HUDPickupSystem.h"
    4847
    4948namespace orxonox // tolua_export
     
    136135
    137136            void dropPickup(uint32_t pickup); //!< Drop the input Pickupable.
    138             static void useUnusePickup(uint32_t index); //tolua_export
    139137            void usePickup(uint32_t pickup, bool use); //!< Use (or unuse) the input Pickupable.
    140138             /**
     
    149147            static void dropPickupNetworked(uint32_t pickup); //!< Helper method to drop the input pickup on the server.
    150148            static void usePickupNetworked(uint32_t pickup, bool use); //!< Helper method to use (or unuse) the input Pickupable on the server.
    151             void setPickupSystem(HUDPickupSystem* system);
    152149
    153150        private:
    154             HUDPickupSystem* pickupSystem;
    155             std::vector<Pickupable*> picks;
    156 
    157151            static PickupManager* singletonPtr_s;
    158152            static const std::string guiName_s; //!< The name of the PickupInventory
     
    172166            void updateGUI(void); //!< Updates the PickupInventory GUI.
    173167            uint32_t getPickupIndex(void); //!< Get a new index for a Pickupable.
    174            
     168
    175169    }; // tolua_export
    176170
  • code/trunk/src/orxonox/CMakeLists.txt

    r11356 r11704  
    2020INCLUDE_DIRECTORIES(
    2121  ${CMAKE_SOURCE_DIR}/src/libraries
    22   ${CMAKE_SOURCE_DIR}/src/modules
    2322  ${CMAKE_CURRENT_SOURCE_DIR}
    2423)
  • code/trunk/src/orxonox/interfaces/Pickupable.h

    r11353 r11704  
    9696
    9797            /**
    98             @brief Check whether the Pickupable is in the process of being destroyed.
    99             @return Returns true if so.
    100             */
    101             inline bool isBeingDestroyed(void)
    102                 { return this->beingDestroyed_; }
    103                
    104             /**
    10598            @brief Returns whether the Pickupable is currently picked up.
    10699            @return Returns true if the Pickupable is currently picked up, false if not.
     
    162155
    163156            /**
     157            @brief Check whether the Pickupable is in the process of being destroyed.
     158            @return Returns true if so.
     159            */
     160            inline bool isBeingDestroyed(void)
     161                { return this->beingDestroyed_; }
     162
     163            /**
    164164            @brief Facilitates the creation of a PickupSpawner upon dropping of the Pickupable.
    165165                   This method must be implemented by any class directly inheriting from Pickupable.
Note: See TracChangeset for help on using the changeset viewer.