Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/modules/overlays/hud/HUDPickupSystem.cc @ 11702

Last change on this file since 11702 was 11702, checked in by landauf, 6 years ago

[HUD_HS16] removed a lot of unused stuff

File size: 3.8 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 <OgreOverlayManager.h>
33#include <OgrePanelOverlayElement.h>
34
35#include "core/CoreIncludes.h"
36#include "core/class/Super.h"
37#include "util/StringUtils.h"
38#include "HUDPickupSystem.h"
39#include "HUDPickupItem.h"
40#include "pickup/Pickup.h"
41#include "pickup/PickupManager.h"
42
43namespace orxonox
44{
45    RegisterClass(HUDPickupSystem);
46
47    HUDPickupSystem::HUDPickupSystem(Context* context) : OrxonoxOverlay(context)
48    {
49        RegisterObject(HUDPickupSystem);
50
51        overlayElement_ = static_cast<Ogre::PanelOverlayElement* >(Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", "HUDPickupSystem" + getUniqueNumberString()));
52        overlayElement_->setMaterialName("PickupBar");
53        overlayElement_->setPosition(0.0f,0.0f);
54        overlayElement_->setDimensions(0.70f,0.15f);
55        this->background_->addChild(overlayElement_);
56    }
57
58    HUDPickupSystem::~HUDPickupSystem()
59    {
60    }
61
62    void HUDPickupSystem::sizeChanged()
63    {
64        OrxonoxOverlay::sizeChanged();
65
66    }
67   
68    void HUDPickupSystem::sync(std::vector<Pickupable*> p, std::map<Pickupable*, uint32_t> indexes_)
69    {
70        //hide all pickup symbols in HUD and delete from local map
71       
72        for(HUDPickupItem* item : items_)
73        {
74            item->hideMe();
75        }
76
77        items_.clear();
78        assert(items_.empty()); //items_ must be empty now
79
80        //add to local map and place on screen
81        int i = 0;
82        const float offsetX = 0.345f;
83        float offsetY = 0.82f;
84        const float x = 0.102f;
85
86        for(Pickupable* pickup:p)
87        {
88            i=indexes_.find(pickup)->second;
89            //second row has offset
90            if(i==5)
91            {   
92                i=0;
93                offsetY+=0.075f;
94            }
95
96            HUDPickupItem* item = new HUDPickupItem(this->getContext());
97            item->initializeMaterial(this->getIcon(((Pickup*)pickup)->getRepresentationName()), offsetX+i*x, offsetY);
98            item->setOverlayGroup(this->getOverlayGroup());
99            items_.push_back(item);
100        }
101    }
102
103    std::string HUDPickupSystem::getIcon(std::string repName)
104    {
105        if(repName.find("invisible", 0)!=std::string::npos) return "Eye";
106        else if(repName.find("tri", 0)!=std::string::npos) return "Asterisk";
107        else if(repName.find("health", 0)!=std::string::npos || repName.find("Health", 0)!=std::string::npos) return "Cross";
108        else if(repName.find("shield", 0)!=std::string::npos) return "Shield";
109        else if(repName.find("munition", 0)!=std::string::npos) return "Munition";
110        else if(repName.find("shrink", 0)!=std::string::npos) return "Shrink";
111        else if(repName.find("boost", 0)!=std::string::npos) return "Flash";
112        else if(repName.find("speed", 0)!=std::string::npos) return "3arrowsup";
113        else if(repName.find("drone", 0)!=std::string::npos) return "Damage";
114        else return "Unknown";
115    }
116}
Note: See TracBrowser for help on using the repository browser.