Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jan 6, 2018, 3:13:26 PM (7 years ago)
Author:
landauf
Message:

[HUD_HS16] removed HUDPickupItem as it is not really necessary (it's just an ogre overlay). also fixed several memory-leaks and some issues with positioning and visibility of the pickup items

Location:
code/trunk/src/modules/overlays
Files:
2 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/modules/overlays/OverlaysPrereqs.h

    r11353 r11705  
    105105    class TeamBaseMatchScore;
    106106    class HUDPickupSystem;
    107     class HUDPickupItem;
    108107
    109108    // stats
  • code/trunk/src/modules/overlays/hud/CMakeLists.txt

    r11353 r11705  
    1414  HUDWeapon.cc
    1515  HUDWeaponSystem.cc
    16   HUDPickupItem.cc
    1716  HUDPickupSystem.cc
    1817  ChatOverlay.cc
  • code/trunk/src/modules/overlays/hud/HUDPickupSystem.cc

    r11704 r11705  
    3131
    3232#include <OgreOverlayManager.h>
     33#include <OgreOverlayElement.h>
    3334#include <OgrePanelOverlayElement.h>
    3435
    3536#include "core/CoreIncludes.h"
    3637#include "core/class/Super.h"
    37 #include "util/StringUtils.h"
     38#include "util/Convert.h"
    3839#include "HUDPickupSystem.h"
    39 #include "HUDPickupItem.h"
    4040#include "pickup/PickupManager.h"
    4141
     
    4848        RegisterObject(HUDPickupSystem);
    4949
    50         overlayElement_ = static_cast<Ogre::PanelOverlayElement* >(Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", "HUDPickupSystem" + getUniqueNumberString()));
    51         overlayElement_->setMaterialName("PickupBar");
    52         overlayElement_->setPosition(0.0f,0.0f);
    53         overlayElement_->setDimensions(0.70f,0.15f);
    54         this->background_->addChild(overlayElement_);
     50        const float offsetX = 0.02f;
     51        const float offsetY = 0.05f;
     52        const float x = 0.2;
     53        const float y = 0.5f;
     54
     55        for (int index = 0; index < 10; ++index)
     56        {
     57            int row = index / 5;
     58            int column = index % 5;
     59
     60            std::string name = "HUDPickupItem" + multi_cast<std::string>(index);
     61            Ogre::OverlayElement* item = Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", name);
     62
     63            item->setDimensions(0.16, 0.4);
     64            item->setPosition(offsetX + column*x, offsetY + row*y);
     65            this->items_.push_back(item);
     66        }
    5567    }
    5668
    5769    HUDPickupSystem::~HUDPickupSystem()
    5870    {
     71        for (Ogre::OverlayElement* item : items_)
     72            Ogre::OverlayManager::getSingleton().destroyOverlayElement(item);
    5973    }
    6074
     
    6983        SUPER(HUDPickupSystem, tick, dt);
    7084
    71         //hide all pickup symbols in HUD and delete from local map
    72         for(HUDPickupItem* item : items_)
     85        int numPickups = PickupManager::getInstance().getNumPickups();
     86        for (size_t index = 0; index < this->items_.size(); ++index)
    7387        {
    74             item->hideMe();
    75         }
     88            Ogre::OverlayElement* item = this->items_[index];
    7689
    77         items_.clear();
    78         assert(items_.empty()); //items_ must be empty now
    79 
    80         //add to local map and place on screen
    81         const float offsetX = 0.345f;
    82         const float offsetY = 0.82f;
    83         const float x = 0.102f;
    84         const float y = 0.075f;
    85 
    86         int numPickups = PickupManager::getInstance().getNumPickups();
    87         for (int index = 0; index < numPickups; ++index)
    88         {
    89             int row = index / 5;
    90             int column = index % 5;
    91 
    92             const PickupInventoryContainer* container = PickupManager::getInstance().popPickup();
    93 
    94             HUDPickupItem* item = new HUDPickupItem(this->getContext());
    95             item->initializeMaterial(this->getIcon(container->representationName), offsetX+column*x, offsetY+row*y);
    96             item->setOverlayGroup(this->getOverlayGroup());
    97             items_.push_back(item);
     90            if (static_cast<int>(index) < numPickups)
     91            {
     92                const PickupInventoryContainer* container = PickupManager::getInstance().popPickup();
     93                item->setMaterialName(this->getIcon(container->representationName));
     94                if (!item->getParent())
     95                    this->background_->addChild(item);
     96            }
     97            else
     98            {
     99                if (item->getParent())
     100                    this->background_->removeChild(item->getName());
     101            }
    98102        }
    99103    }
  • code/trunk/src/modules/overlays/hud/HUDPickupSystem.h

    r11704 r11705  
    5151
    5252    private:
    53        
    5453        std::string getIcon(std::string repName);
    5554
    56         std::vector<HUDPickupItem*> items_;
    57         Ogre::PanelOverlayElement* overlayElement_;
     55        std::vector<Ogre::OverlayElement*> items_;
    5856    };
    5957}
Note: See TracChangeset for help on using the changeset viewer.