Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

merged HUD branch to trunk

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