Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/modules/overlays/hud/HUDPickupItem.cc @ 11600

Last change on this file since 11600 was 11353, checked in by patricwi, 8 years ago

merged HUD branch to trunk

File size: 2.4 KB
RevLine 
[11264]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 "HUDPickupItem.h"
30
[11277]31#include <string>
32
33
34#include <OgreOverlayManager.h>
35#include <OgrePanelOverlayElement.h> 
36
[11264]37#include "core/CoreIncludes.h"
38#include "core/XMLPort.h"
39#include "util/Convert.h"
40#include "core/class/Super.h"
[11277]41#include "HUDPickupItem.h"
[11264]42
43namespace orxonox
44{
45    RegisterClass(HUDPickupItem);
46
47    HUDPickupItem::HUDPickupItem(Context* context) : OrxonoxOverlay(context)
48    {
49        RegisterObject(HUDPickupItem);
50
[11323]51        std::string name = "HUDPickupItem" + getUniqueNumberString();
52
53        overlayElement_ = static_cast<Ogre::PanelOverlayElement* >(Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", name ));
54
[11336]55        overlayElement_->setDimensions(0.075f,0.08f);
[11314]56       
[11264]57    }
58
59    HUDPickupItem::~HUDPickupItem()
60    {
61        if (this->isInitialized())
62        {
[11277]63            overlayElement_=nullptr;
[11264]64        }
65    }
66
[11314]67    void HUDPickupItem::initializeMaterial(const std::string& s, float x, float y)
[11277]68    {
69        overlayElement_->setMaterialName(s);
[11314]70        overlayElement_->setPosition(x, y);
71        overlayElement_->show();
72        this->background_->addChild(overlayElement_);
[11277]73    }
74
[11325]75    void HUDPickupItem::hideMe(Pickupable* p, bool repaint)
[11295]76    {
[11325]77        if(!repaint) return;                     //dont do anything, if we are not allowed to repaint because the level is terminating
[11323]78        assert(overlayElement_);
79        assert(this->background_);
[11314]80        overlayElement_->hide();
[11323]81        this->background_->removeChild(overlayElement_->getName());
[11295]82    }
[11264]83}
Note: See TracBrowser for help on using the repository browser.