Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/HUD_HS16/src/modules/overlays/hud/HUDPickupSystem.cc @ 11314

Last change on this file since 11314 was 11314, checked in by patricwi, 7 years ago

linker problem solved, visuals work as long as only 1 item is picked up.

File size: 3.6 KB
Line 
1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
23 *      Patrick Wintermeyer
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29#include <vector>
30#include <string>
31
32#include "core/CoreIncludes.h"
33#include "core/XMLPort.h"
34#include "util/Convert.h"
35#include "core/class/Super.h"
36#include "HUDPickupSystem.h"
37#include "pickup/Pickup.h"
38#include "HUDPickupItem.h"
39#include "pickup/PickupManager.h"
40
41namespace orxonox
42{
43    RegisterClass(HUDPickupSystem);
44
45    HUDPickupSystem::HUDPickupSystem(Context* context) : OrxonoxOverlay(context)
46    {
47        RegisterObject(HUDPickupSystem);
48
49        overlayElement_ = static_cast<Ogre::PanelOverlayElement* >(Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", "HUDPickupSystem" + getUniqueNumberString()));
50        overlayElement_->setMaterialName("PickupBar");
51        overlayElement_->setPosition(0.0f,0.0f);
52        overlayElement_->setDimensions(0.70f,0.15f);
53        orxout() << "hello here is the HUDPickupSystem" << endl;
54        this->background_->addChild(overlayElement_);
55    }
56
57    HUDPickupSystem::~HUDPickupSystem()
58    {
59        if (this->isInitialized())
60        {
61            //TODO: Destroy me
62        }
63    }
64
65   //TODO: XMLPort
66
67    void HUDPickupSystem::updatePickupList(std::vector<Pickupable*> picks)
68    {
69        int i=0;
70        const float offsetX = 0.32f;
71        float offsetY = 0.77f;
72        const float x = 0.1f;
73
74        orxout() << "size: " << picks.size() << endl;
75
76        if(picks.size()>0)
77        {
78
79            for(Pickupable* p : picks)
80            {
81                // orxout() << "actual pick is: " << p << endl;
82                if(i%4==0)
83                {
84                    offsetY+=0.04f;
85                    i=0;
86                }   
87                HUDPickupItem* item = new HUDPickupItem(this->getContext());
88                // item->initializeMaterial(((Pickup*)p)->getRepresentationName(), offsetX+i*x, offsetY);
89                if(i%2==0)
90                    item->initializeMaterial("Shield", offsetX+i*x, offsetY);
91                else
92                    item->initializeMaterial("ArrowUp", offsetX+i*x, offsetY);
93                item->setOverlayGroup(this->getOverlayGroup());
94                this->picks[p] = item;
95                ++i;
96            }
97        }
98    }
99
100    void HUDPickupSystem::createPickupList()
101    {
102    }     
103
104    void HUDPickupSystem::removePickup(Pickupable* pickup)
105    {
106        HUDPickupItem* item = this->picks.find(pickup)->second;
107        orxout() << "removePickup: pickup= " << pickup << " item= " << item << endl;
108        assert(item);
109        item->setOverlayGroup(nullptr); 
110        item->hideMe();
111        overlayElement_->_update();
112    }
113
114    void HUDPickupSystem::destroyAll()
115    {
116        this->background_->removeChild(overlayElement_->getName());
117    }
118}
Note: See TracBrowser for help on using the repository browser.