Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jan 6, 2018, 6:07:53 PM (6 years ago)
Author:
landauf
Message:

[HUD_HS16] fixed issue that the hud shows pickups of ALL players/bots instead of just the own spaceship. fixed this by comparing objectIDs
note: network calls currently support only 5 arguments, so I removed representationObjectId which doesn't seem to be used (neither in C++ nor in Lua)

Location:
code/trunk/src/modules/overlays/hud
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/modules/overlays/hud/HUDPickupSystem.cc

    r11705 r11708  
    3434#include <OgrePanelOverlayElement.h>
    3535
     36#include "HUDPickupSystem.h"
     37
    3638#include "core/CoreIncludes.h"
    3739#include "core/class/Super.h"
    3840#include "util/Convert.h"
    39 #include "HUDPickupSystem.h"
    4041#include "pickup/PickupManager.h"
     42#include "worldentities/pawns/Pawn.h"
    4143
    4244namespace orxonox
     
    7880
    7981    }
    80    
     82
     83    void HUDPickupSystem::changedOwner()
     84    {
     85        SUPER(HUDPickupSystem, changedOwner);
     86
     87        this->owner_ = orxonox_cast<Pawn*>(this->getOwner());
     88    }
     89
    8190    void HUDPickupSystem::tick(float dt)
    8291    {
    8392        SUPER(HUDPickupSystem, tick, dt);
    8493
    85         int numPickups = PickupManager::getInstance().getNumPickups();
     94        std::vector<const PickupInventoryContainer*> containers = this->getPickupsForOwner();
     95
    8696        for (size_t index = 0; index < this->items_.size(); ++index)
    8797        {
    8898            Ogre::OverlayElement* item = this->items_[index];
    8999
    90             if (static_cast<int>(index) < numPickups)
     100            if (index < containers.size())
    91101            {
    92                 const PickupInventoryContainer* container = PickupManager::getInstance().popPickup();
    93                 item->setMaterialName(this->getIcon(container->representationName));
     102                item->setMaterialName(this->getIcon(containers[index]->representationName));
    94103                if (!item->getParent())
    95104                    this->background_->addChild(item);
     
    103112    }
    104113
    105     std::string HUDPickupSystem::getIcon(std::string repName)
     114    std::vector<const PickupInventoryContainer*> HUDPickupSystem::getPickupsForOwner() const
     115    {
     116        std::vector<const PickupInventoryContainer*> containers;
     117
     118        int numPickups = PickupManager::getInstance().getNumPickups();
     119        for (int i = 0; i < numPickups; ++i)
     120        {
     121            const PickupInventoryContainer* container = PickupManager::getInstance().popPickup();
     122            if (this->owner_ && this->owner_->getObjectID() == container->carrierPawnId)
     123                containers.push_back(container);
     124        }
     125
     126        return containers;
     127    }
     128
     129    std::string HUDPickupSystem::getIcon(const std::string& repName) const
    106130    {
    107131        if(repName.find("invisible", 0)!=std::string::npos) return "Eye";
  • code/trunk/src/modules/overlays/hud/HUDPickupSystem.h

    r11705 r11708  
    3232
    3333#include "overlays/OverlaysPrereqs.h"
     34#include "pickup/PickupPrereqs.h"
    3435
    3536#include <vector>
     
    4849
    4950        virtual void tick(float dt) override;
     51
    5052        virtual void sizeChanged() override;
     53        virtual void changedOwner() override;
    5154
    5255    private:
    53         std::string getIcon(std::string repName);
     56        std::vector<const PickupInventoryContainer*> getPickupsForOwner() const;
     57        std::string getIcon(const std::string& repName) const;
    5458
    5559        std::vector<Ogre::OverlayElement*> items_;
     60        WeakPtr<Pawn> owner_;
    5661    };
    5762}
Note: See TracChangeset for help on using the changeset viewer.