Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/HUD_HS16/src/modules/overlays/hud/HUDPickupItem.cc @ 11277

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

visualization of pickup system initiated. next steps: add pickup icons when picked up

File size: 6.3 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    Ogre::PanelOverlayElement* overlayElement_;
47
48    HUDPickupItem::HUDPickupItem(Context* context) : OrxonoxOverlay(context)
49    {
50        RegisterObject(HUDPickupItem);
51
52        overlayElement_ = static_cast<Ogre::PanelOverlayElement* >(Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", "HUDPickupItem" + getUniqueNumberString()));
53       
54        overlayElement_->setPosition(0.0f,0.0f);
55        overlayElement_->setDimensions(0.5f,0.5f);
56        this->background_->addChild(overlayElement_);
57    }
58
59    HUDPickupItem::~HUDPickupItem()
60    {
61        if (this->isInitialized())
62        {
63            overlayElement_=nullptr;
64        }
65    }
66
67    void initializeMaterial(std::string s)
68    {
69        overlayElement_->setMaterialName(s);
70    }
71
72    // void HUDWeapon::XMLPort(Element& xmlelement, XMLPort::Mode mode)
73    // {
74    //     SUPER(HUDWeapon, XMLPort, xmlelement, mode);
75
76    //     XMLPortParam(HUDWeapons, "sensitivity", setRadarSensitivity, getRadarSensitivity, xmlelement, mode);
77    //     XMLPortParam(HUDWeapons, "halfDotSizeDistance", setHalfDotSizeDistance, getHalfDotSizeDistance, xmlelement, mode);
78    // }
79
80    // void HUDWeapon::tick(float dt)
81    // {
82    //     SUPER(HUDWeapon, tick, dt);
83
84    //     if (!weapon_)
85    //     {
86    //         // TODO: destroy this HUD id the Weapon does no more exist. (Wehen the weak pointer is null)
87    //     }
88    // }   
89
90    // void HUDWeapon::positionChanged()
91    // {
92    //     OrxonoxOverlay::positionChanged();
93
94    //     positionHUDChilds();
95    // }
96
97    // void HUDWeapon::sizeChanged()
98    // {
99    //     OrxonoxOverlay::sizeChanged();
100
101    //     positionHUDChilds();
102    // }
103
104    // void HUDWeapon::changedOwner()
105    // {
106    //     SUPER(HUDWeapon, changedOwner);
107
108    //     this->owner_ = orxonox_cast<Pawn*>(this->getOwner());
109
110    //     updateWeaponModeList();
111    // }
112
113    // void HUDWeapon::changedOverlayGroup()
114    // {
115    //     SUPER(HUDWeapon, changedOverlayGroup);
116    // }   
117
118    // void HUDWeapon::changedVisibility()
119    // {
120    //     SUPER(HUDWeapon, changedVisibility);
121
122    //     bool visible = this->isVisible();
123
124    //     for (HUDWeaponMode* hudWeaponMode : hudWeaponModes_)
125    //     {
126    //         hudWeaponMode->changedVisibility(); //inform all Child Overlays that our visibility has changed
127    //         hudWeaponMode->setVisible(visible);
128    //     }
129    // }
130
131    // void HUDWeapon::changedName()
132    // {
133    //     SUPER(HUDWeapon, changedName);
134    // }
135
136    // void HUDWeapon::setWeapon(Weapon* weapon)
137    // {
138    //     weapon_ = weapon;
139
140    //     if (!weapon_)
141    //     {
142    //         return;
143    //     }
144
145    //     updateWeaponModeList();
146    // }
147
148    // void HUDWeapon::updateWeaponModeList()
149    // {
150    //     if (owner_ == nullptr || weapon_ == nullptr)
151    //     {
152    //         return;
153    //     }
154           
155    //     destroyHUDChilds();
156
157    //     updateSize();
158    //     createHUDChilds();
159    //     positionHUDChilds();
160    // } 
161
162    // void HUDWeapon::createHUDChilds()
163    // {
164    //     if (weapon_ == nullptr)
165    //     {
166    //         return;
167    //     }
168
169    //     int positionIndex = 0;
170
171    //     for (const auto& mapEntry : weapon_->getAllWeaponmodes())
172    //     {
173    //         HUDWeaponMode* hudWeaponMode = new HUDWeaponMode(this->getContext());
174    //         hudWeaponMode->setOwner(owner_);
175    //         hudWeaponMode->setOverlayGroup(this->getOverlayGroup());
176    //         hudWeaponMode->setVisible(this->isVisible());
177    //         hudWeaponMode->setWeaponMode(mapEntry.second);
178    //         hudWeaponMode->setWeaponIndex(this->weaponIndex_);                   
179    //         hudWeaponMode->setAspectCorrection(false);
180    //         hudWeaponMode->setPickPoint(Vector2(0.0f,0.0f));
181
182    //         hudWeaponModes_.push_back(hudWeaponMode);
183
184    //         ++ positionIndex;
185    //     }
186    // }     
187
188    // void HUDWeapon::positionHUDChilds()
189    // {
190    //     int positionIndex = 0;
191
192    //     for (HUDWeaponMode* hudWeaponMode : hudWeaponModes_)
193    //     {
194    //         hudWeaponMode->setPositionOffset(this->positionOffset_);
195    //         hudWeaponMode->setWeaponModeIndex(positionIndex);
196    //         hudWeaponMode->setWeaponIndex(this->weaponIndex_);
197    //         hudWeaponMode->setWeaponModeHUDActualSize(this->weaponModeHUDActualSize_);
198
199    //         ++ positionIndex;
200    //     }
201    // } 
202
203    // void HUDWeapon::destroyHUDChilds()
204    // {
205    //     for (HUDWeaponMode* hudWeaponMode : hudWeaponModes_)
206    //     {
207    //         hudWeaponMode->destroy();
208    //     }
209
210    //     hudWeaponModes_.clear();
211    // }
212
213    // void HUDWeapon::updateSize()
214    // {
215    //     if (weapon_ != nullptr)
216    //     {
217    //         this->setSize(Vector2(weaponModeHUDActualSize_.x,weaponModeHUDActualSize_.y*weapon_->getAllWeaponmodes().size()));
218    //         updatePosition();
219    //     }       
220    // }
221
222    // void HUDWeapon::updatePosition()
223    // {
224    //     if (weapon_ != nullptr)
225    //     {
226    //         this->setPosition(Vector2(weaponModeHUDActualSize_.x*weaponIndex_,0.0f) + this->positionOffset_);
227    //     }       
228    // }       
229}
Note: See TracBrowser for help on using the repository browser.