Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 11704 was 11704, checked in by landauf, 8 years ago

[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
File size: 3.9 KB
RevLine 
[11263]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
[11277]29#include <vector>
30#include <string>
31
[11702]32#include <OgreOverlayManager.h>
33#include <OgrePanelOverlayElement.h>
34
[11263]35#include "core/CoreIncludes.h"
36#include "core/class/Super.h"
[11702]37#include "util/StringUtils.h"
[11277]38#include "HUDPickupSystem.h"
[11702]39#include "HUDPickupItem.h"
[11305]40#include "pickup/PickupManager.h"
[11263]41
42namespace orxonox
43{
44    RegisterClass(HUDPickupSystem);
45
46    HUDPickupSystem::HUDPickupSystem(Context* context) : OrxonoxOverlay(context)
47    {
48        RegisterObject(HUDPickupSystem);
49
[11277]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_);
[11263]55    }
56
57    HUDPickupSystem::~HUDPickupSystem()
58    {
59    }
60
[11354]61    void HUDPickupSystem::sizeChanged()
62    {
63        OrxonoxOverlay::sizeChanged();
64
65    }
66   
[11704]67    void HUDPickupSystem::tick(float dt)
[11700]68    {
[11704]69        SUPER(HUDPickupSystem, tick, dt);
70
[11700]71        //hide all pickup symbols in HUD and delete from local map
[11702]72        for(HUDPickupItem* item : items_)
[11700]73        {
[11702]74            item->hideMe();
[11700]75        }
76
[11702]77        items_.clear();
78        assert(items_.empty()); //items_ must be empty now
[11700]79
80        //add to local map and place on screen
[11336]81        const float offsetX = 0.345f;
[11703]82        const float offsetY = 0.82f;
[11336]83        const float x = 0.102f;
[11703]84        const float y = 0.075f;
[11314]85
[11704]86        int numPickups = PickupManager::getInstance().getNumPickups();
87        for (int index = 0; index < numPickups; ++index)
[11277]88        {
[11703]89            int row = index / 5;
90            int column = index % 5;
[11336]91
[11704]92            const PickupInventoryContainer* container = PickupManager::getInstance().popPickup();
93
[11700]94            HUDPickupItem* item = new HUDPickupItem(this->getContext());
[11704]95            item->initializeMaterial(this->getIcon(container->representationName), offsetX+column*x, offsetY+row*y);
[11700]96            item->setOverlayGroup(this->getOverlayGroup());
[11702]97            items_.push_back(item);
[11277]98        }
[11263]99    }
100
[11325]101    std::string HUDPickupSystem::getIcon(std::string repName)
102    {
103        if(repName.find("invisible", 0)!=std::string::npos) return "Eye";
[11336]104        else if(repName.find("tri", 0)!=std::string::npos) return "Asterisk";
[11325]105        else if(repName.find("health", 0)!=std::string::npos || repName.find("Health", 0)!=std::string::npos) return "Cross";
106        else if(repName.find("shield", 0)!=std::string::npos) return "Shield";
107        else if(repName.find("munition", 0)!=std::string::npos) return "Munition";
108        else if(repName.find("shrink", 0)!=std::string::npos) return "Shrink";
109        else if(repName.find("boost", 0)!=std::string::npos) return "Flash";
110        else if(repName.find("speed", 0)!=std::string::npos) return "3arrowsup";
111        else if(repName.find("drone", 0)!=std::string::npos) return "Damage";
112        else return "Unknown";
113    }
[11263]114}
Note: See TracBrowser for help on using the repository browser.