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