[4744] | 1 | /* |
---|
[1853] | 2 | orxonox - the future of 3D-vertical-scrollers |
---|
| 3 | |
---|
| 4 | Copyright (C) 2004 orx |
---|
| 5 | |
---|
| 6 | This program is free software; you can redistribute it and/or modify |
---|
| 7 | it under the terms of the GNU General Public License as published by |
---|
| 8 | the Free Software Foundation; either version 2, or (at your option) |
---|
| 9 | any later version. |
---|
[1855] | 10 | |
---|
| 11 | ### File Specific: |
---|
[6437] | 12 | main-programmer: Benjamin Grauer |
---|
[1855] | 13 | co-programmer: ... |
---|
[1853] | 14 | */ |
---|
| 15 | |
---|
[3955] | 16 | //#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_ |
---|
[1853] | 17 | |
---|
[6437] | 18 | #include "hud.h" |
---|
[1853] | 19 | |
---|
[6441] | 20 | #include "state.h" |
---|
[8976] | 21 | #include "debug.h" |
---|
[6441] | 22 | |
---|
[6442] | 23 | #include "world_entities/weapons/weapon_manager.h" |
---|
[8448] | 24 | #include "glgui_widget.h" |
---|
[10111] | 25 | #include "glgui_box.h" |
---|
[10230] | 26 | #include "glgui_bar.h" |
---|
[10120] | 27 | #include "elements/glgui_energywidgetvertical.h" |
---|
[6442] | 28 | |
---|
[8518] | 29 | #include "glgui_inputline.h" |
---|
| 30 | #include "specials/glgui_notifier.h" |
---|
[8994] | 31 | #include "elements/glgui_radar.h" |
---|
[10270] | 32 | #include "world_entities/space_ships/space_ship.h" |
---|
[8518] | 33 | |
---|
[8996] | 34 | |
---|
| 35 | |
---|
| 36 | /// HACK |
---|
| 37 | #include "player.h" |
---|
| 38 | #include "playable.h" |
---|
| 39 | |
---|
[9869] | 40 | ObjectListDefinition(Hud); |
---|
[3245] | 41 | /** |
---|
[4838] | 42 | * standard constructor |
---|
| 43 | * @todo this constructor is not jet implemented - do it |
---|
[3245] | 44 | */ |
---|
[6437] | 45 | Hud::Hud () |
---|
[3365] | 46 | { |
---|
[9869] | 47 | this->registerObject(this, Hud::_objectList); |
---|
[4320] | 48 | |
---|
[6441] | 49 | //this->setSize2D( |
---|
[6442] | 50 | this->weaponManager = NULL; |
---|
[9965] | 51 | this->weaponManagerSecondary = NULL; |
---|
[6440] | 52 | this->energyWidget = NULL; |
---|
| 53 | this->shieldWidget = NULL; |
---|
| 54 | this->armorWidget = NULL; |
---|
[10230] | 55 | //this->leftRect = NULL; |
---|
| 56 | //this->rightRect = NULL; |
---|
[6441] | 57 | this->resX = 1; |
---|
| 58 | this->resY = 1; |
---|
[6442] | 59 | |
---|
[10234] | 60 | this->overlayPercentage = 40; |
---|
[10233] | 61 | this->overlayActive = false; |
---|
[10234] | 62 | this->rightRect = new OrxGui::GLGuiImage(); |
---|
| 63 | this->leftRect = new OrxGui::GLGuiImage(); |
---|
[10230] | 64 | |
---|
[8518] | 65 | this->inputLine = new OrxGui::GLGuiInputLine(); |
---|
| 66 | this->inputLine->setParent2D(this); |
---|
| 67 | this->notifier = new OrxGui::GLGuiNotifier(); |
---|
| 68 | this->notifier->setParent2D(this); |
---|
| 69 | notifier->setAbsCoor2D(100,100); |
---|
| 70 | |
---|
[8995] | 71 | this->_radar = new OrxGui::GLGuiRadar(); |
---|
[10270] | 72 | this->radarCenterNode = NULL; |
---|
[8994] | 73 | |
---|
[8990] | 74 | this->subscribeEvent(ES_ALL, EV_VIDEO_RESIZE); |
---|
[9003] | 75 | this->subscribeEvent(ES_ALL, SDLK_TAB); |
---|
[8518] | 76 | |
---|
[10194] | 77 | //this->shipValuesBox = NULL; |
---|
[3365] | 78 | } |
---|
[1853] | 79 | |
---|
| 80 | |
---|
[3245] | 81 | /** |
---|
[4838] | 82 | * standard deconstructor |
---|
[3245] | 83 | */ |
---|
[6437] | 84 | Hud::~Hud () |
---|
[3543] | 85 | { |
---|
[8518] | 86 | delete this->inputLine; |
---|
| 87 | delete this->notifier; |
---|
[8994] | 88 | |
---|
[8995] | 89 | delete this->_radar; |
---|
[10233] | 90 | delete this->rightRect; |
---|
| 91 | delete this->leftRect; |
---|
[10194] | 92 | //if (this->shipValuesBox != NULL) |
---|
| 93 | //delete this->shipValuesBox; |
---|
[10139] | 94 | |
---|
[3543] | 95 | // delete what has to be deleted here |
---|
| 96 | } |
---|
[6438] | 97 | |
---|
| 98 | |
---|
| 99 | void Hud::loadParams(const TiXmlElement* root) |
---|
| 100 | { |
---|
[6512] | 101 | Element2D::loadParams(root); |
---|
[6438] | 102 | } |
---|
| 103 | |
---|
[8518] | 104 | void Hud::notifyUser(const std::string& message) |
---|
[6438] | 105 | { |
---|
[8518] | 106 | this->notifier->pushNotifyMessage(message); |
---|
[6438] | 107 | } |
---|
| 108 | |
---|
[8518] | 109 | void Hud::setBackGround() |
---|
| 110 | {} |
---|
| 111 | |
---|
[8145] | 112 | void Hud::setEnergyWidget(OrxGui::GLGuiWidget* widget) |
---|
[6438] | 113 | { |
---|
[10194] | 114 | //if (this->shipValuesBox == NULL) |
---|
| 115 | //this->createShipValuesBox(); |
---|
| 116 | |
---|
[6440] | 117 | // decopple old widget |
---|
| 118 | if (this->energyWidget != NULL) |
---|
| 119 | { |
---|
| 120 | this->energyWidget->hide(); |
---|
| 121 | } |
---|
[6438] | 122 | |
---|
[6440] | 123 | this->energyWidget = widget; |
---|
| 124 | if (this->energyWidget != NULL) |
---|
| 125 | { |
---|
[10139] | 126 | //this->energyWidget->shiftDir2D(270); |
---|
[10194] | 127 | //dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (this->energyWidget)->setDisplayedName("Electronics"); |
---|
| 128 | //this->shipValuesBox->pack(this->energyWidget); |
---|
[10230] | 129 | //dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (this->energyWidget)->setStandardSettings(); |
---|
[10234] | 130 | this->energyWidget->setParent2D(this->leftRect); |
---|
[10139] | 131 | this->energyWidget->show(); |
---|
[8518] | 132 | /* this->energyWidget->frontMaterial().setDiffuseMap("hud_energy_bar.png"); |
---|
| 133 | this->energyWidget->frontMaterial().setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);*/ |
---|
[6440] | 134 | } |
---|
| 135 | |
---|
[6441] | 136 | this->updateResolution(); |
---|
[6438] | 137 | } |
---|
| 138 | |
---|
[8145] | 139 | void Hud::setShiledWidget(OrxGui::GLGuiWidget* widget) |
---|
[10120] | 140 | { |
---|
[10194] | 141 | /* |
---|
[10139] | 142 | if (this->shipValuesBox == NULL) |
---|
| 143 | this->createShipValuesBox(); |
---|
[10194] | 144 | */ |
---|
| 145 | |
---|
[10120] | 146 | // decopple old widget |
---|
| 147 | if (this->shieldWidget != NULL) |
---|
| 148 | { |
---|
| 149 | this->shieldWidget->hide(); |
---|
| 150 | } |
---|
[6438] | 151 | |
---|
[10120] | 152 | this->shieldWidget = widget; |
---|
| 153 | if (this->shieldWidget != NULL) |
---|
| 154 | { |
---|
[10139] | 155 | //this->shieldWidget->shiftDir2D(270); |
---|
[10194] | 156 | //this->shipValuesBox->pack(this->shieldWidget); |
---|
[10230] | 157 | //dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (this->shieldWidget)->setStandardSettings(); |
---|
[10234] | 158 | this->shieldWidget->setParent2D(this->leftRect); |
---|
[10120] | 159 | this->shieldWidget->show(); |
---|
| 160 | /* this->shieldWidget->frontMaterial().setDiffuseMap("hud_energy_bar.png"); |
---|
| 161 | this->shieldWidget->frontMaterial().setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);*/ |
---|
| 162 | } |
---|
[10139] | 163 | else |
---|
| 164 | printf("schild im hud nicht uebergeben!!!!!!!!!!!!!!!!!!!!!!!!!"); |
---|
[10120] | 165 | |
---|
| 166 | this->updateResolution(); |
---|
| 167 | } |
---|
| 168 | |
---|
[8145] | 169 | void Hud::setArmorWidget(OrxGui::GLGuiWidget* widget) |
---|
[10120] | 170 | { |
---|
[10194] | 171 | /* |
---|
[10139] | 172 | if (this->shipValuesBox == NULL) |
---|
| 173 | this->createShipValuesBox(); |
---|
[10194] | 174 | */ |
---|
[10139] | 175 | |
---|
[10120] | 176 | // decopple old widget |
---|
| 177 | if (this->armorWidget != NULL) |
---|
| 178 | { |
---|
| 179 | this->armorWidget->hide(); |
---|
| 180 | } |
---|
[6438] | 181 | |
---|
[10120] | 182 | this->armorWidget = widget; |
---|
| 183 | if (this->armorWidget != NULL) |
---|
| 184 | { |
---|
[10139] | 185 | //this->armorWidget->shiftDir2D(270); |
---|
[10194] | 186 | //this->shipValuesBox->pack(this->armorWidget); |
---|
[10230] | 187 | //dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (this->armorWidget)->setStandardSettings(); |
---|
[10234] | 188 | this->armorWidget->setParent2D(this->leftRect); |
---|
[10120] | 189 | this->armorWidget->show(); |
---|
| 190 | /* this->armorWidget->frontMaterial().setDiffuseMap("hud_energy_bar.png"); |
---|
| 191 | this->armorWidget->frontMaterial().setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);*/ |
---|
| 192 | } |
---|
| 193 | |
---|
| 194 | this->updateResolution(); |
---|
| 195 | } |
---|
| 196 | |
---|
[9965] | 197 | void Hud::setWeaponManager(WeaponManager* weaponMan, WeaponManager* weaponManSec) |
---|
[6442] | 198 | { |
---|
[10278] | 199 | //clearWeaponManager(); |
---|
| 200 | |
---|
| 201 | //Hide all widgets |
---|
[6442] | 202 | if (this->weaponManager != NULL) |
---|
| 203 | { |
---|
| 204 | for (unsigned int i = 0; i < this->weaponManager->getSlotCount(); i++) |
---|
| 205 | { |
---|
| 206 | Weapon* weapon = this->weaponManager->getWeapon(i); |
---|
| 207 | if (weapon != NULL) |
---|
| 208 | { |
---|
| 209 | weapon->getEnergyWidget()->hide(); |
---|
[10278] | 210 | //this->weaponsWidgetsPrim.remove(dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (weapon->getEnergyWidget())); |
---|
[6442] | 211 | } |
---|
| 212 | } |
---|
| 213 | } |
---|
| 214 | |
---|
[9965] | 215 | if (this->weaponManagerSecondary != NULL) |
---|
| 216 | { |
---|
| 217 | for (unsigned int i = 0; i < this->weaponManagerSecondary->getSlotCount(); i++) |
---|
| 218 | { |
---|
| 219 | Weapon* weapon = this->weaponManagerSecondary->getWeapon(i); |
---|
| 220 | if (weapon != NULL) |
---|
| 221 | { |
---|
| 222 | weapon->getEnergyWidget()->hide(); |
---|
[10278] | 223 | //this->weaponsWidgetsSec.remove(dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (weapon->getEnergyWidget())); |
---|
[9965] | 224 | } |
---|
| 225 | } |
---|
| 226 | } |
---|
| 227 | |
---|
[6442] | 228 | this->weaponManager = weaponMan; |
---|
[10278] | 229 | this->weaponManagerSecondary = weaponManSec; |
---|
[6442] | 230 | |
---|
[6445] | 231 | this->updateWeaponManager(); |
---|
[8996] | 232 | // this->updateResolution(); |
---|
[6438] | 233 | } |
---|
| 234 | |
---|
[10278] | 235 | /* |
---|
| 236 | void Hud::clearWeaponManager() |
---|
| 237 | { |
---|
| 238 | //Hide all widgets |
---|
| 239 | if (this->weaponManager != NULL) |
---|
| 240 | { |
---|
| 241 | for (unsigned int i = 0; i < this->weaponManager->getSlotCount(); i++) |
---|
| 242 | { |
---|
| 243 | Weapon* weapon = this->weaponManager->getWeapon(i); |
---|
| 244 | if (weapon != NULL) |
---|
| 245 | { |
---|
| 246 | weapon->getEnergyWidget()->hide(); |
---|
| 247 | //this->weaponsWidgetsPrim.remove(dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (weapon->getEnergyWidget())); |
---|
| 248 | } |
---|
| 249 | } |
---|
| 250 | } |
---|
| 251 | |
---|
| 252 | if (this->weaponManagerSecondary != NULL) |
---|
| 253 | { |
---|
| 254 | for (unsigned int i = 0; i < this->weaponManagerSecondary->getSlotCount(); i++) |
---|
| 255 | { |
---|
| 256 | Weapon* weapon = this->weaponManagerSecondary->getWeapon(i); |
---|
| 257 | if (weapon != NULL) |
---|
| 258 | { |
---|
| 259 | weapon->getEnergyWidget()->hide(); |
---|
| 260 | //this->weaponsWidgetsSec.remove(dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (weapon->getEnergyWidget())); |
---|
| 261 | } |
---|
| 262 | } |
---|
| 263 | } |
---|
| 264 | |
---|
| 265 | //this->weaponsWidgetsPrim.clear(); |
---|
| 266 | //this->weaponsWidgetsSec.clear(); |
---|
| 267 | } |
---|
| 268 | */ |
---|
| 269 | |
---|
[6443] | 270 | void Hud::updateWeaponManager() |
---|
| 271 | { |
---|
| 272 | // hide all the Widgets |
---|
[10278] | 273 | |
---|
[10230] | 274 | std::list<OrxGui::GLGuiEnergyWidgetVertical*>::iterator weaponWidget; |
---|
| 275 | for (weaponWidget = this->weaponsWidgetsPrim.begin(); weaponWidget != this->weaponsWidgetsPrim.end(); weaponWidget++) |
---|
[6443] | 276 | { |
---|
| 277 | (*weaponWidget)->hide(); |
---|
| 278 | } |
---|
[10230] | 279 | this->weaponsWidgetsPrim.clear(); |
---|
[6442] | 280 | |
---|
[10230] | 281 | for (weaponWidget = this->weaponsWidgetsSec.begin(); weaponWidget != this->weaponsWidgetsSec.end(); weaponWidget++) |
---|
| 282 | { |
---|
| 283 | (*weaponWidget)->hide(); |
---|
| 284 | } |
---|
| 285 | this->weaponsWidgetsSec.clear(); |
---|
[10278] | 286 | |
---|
[10230] | 287 | |
---|
[6443] | 288 | // add all that we need again. |
---|
[10278] | 289 | |
---|
[6443] | 290 | if (this->weaponManager != NULL) |
---|
| 291 | for (unsigned int i = 0; i < this->weaponManager->getSlotCount(); i++) |
---|
| 292 | { |
---|
[8518] | 293 | Weapon* weapon = this->weaponManager->getWeapon(i); |
---|
| 294 | if (weapon != NULL) |
---|
| 295 | { |
---|
[9406] | 296 | //PRINTF(0)("WEAPON %s::%s in Slots\n", weapon->getClassCName(), weapon->getName()); |
---|
[10234] | 297 | weapon->getEnergyWidget()->setParent2D(this->rightRect); |
---|
[8518] | 298 | weapon->getEnergyWidget()->show(); |
---|
[8619] | 299 | weapon->getEnergyWidget()->setBackgroundColor(Color(.8,.2,.11, 0.1)); |
---|
[8518] | 300 | weapon->getEnergyWidget()->setFrontColor(Color( .2,.5,.7,.6)); |
---|
[10234] | 301 | weapon->getEnergyWidget()->setWidgetSize(120,30); |
---|
[10023] | 302 | //weapon->getEnergyWidget()->frontMaterial().setTransparency(.6); |
---|
[10230] | 303 | this->weaponsWidgetsPrim.push_back(dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (weapon->getEnergyWidget())); |
---|
[8518] | 304 | } |
---|
[6443] | 305 | } |
---|
[9965] | 306 | |
---|
| 307 | if (this->weaponManagerSecondary != NULL) |
---|
| 308 | for (unsigned int i = 0; i < this->weaponManagerSecondary->getSlotCount(); i++) |
---|
| 309 | { |
---|
| 310 | Weapon* weapon = this->weaponManagerSecondary->getWeapon(i); |
---|
| 311 | if (weapon != NULL) |
---|
| 312 | { |
---|
| 313 | //PRINTF(0)("WEAPON %s::%s in Slots\n", weapon->getClassCName(), weapon->getName()); |
---|
[10234] | 314 | weapon->getEnergyWidget()->setParent2D(this->rightRect); |
---|
[9965] | 315 | weapon->getEnergyWidget()->show(); |
---|
| 316 | weapon->getEnergyWidget()->setBackgroundColor(Color(.8,.2,.11, 0.1)); |
---|
| 317 | weapon->getEnergyWidget()->setFrontColor(Color( .2,.5,.7,.6)); |
---|
[10023] | 318 | //weapon->getEnergyWidget()->frontMaterial().setTransparency(.6); |
---|
[10230] | 319 | this->weaponsWidgetsSec.push_back(dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (weapon->getEnergyWidget())); |
---|
[9965] | 320 | } |
---|
| 321 | } |
---|
| 322 | |
---|
[6443] | 323 | this->updateResolution(); |
---|
[9965] | 324 | |
---|
[6443] | 325 | } |
---|
| 326 | |
---|
[8145] | 327 | void Hud::addWeaponWidget(OrxGui::GLGuiWidget* widget) |
---|
[8518] | 328 | {} |
---|
[6438] | 329 | |
---|
[8145] | 330 | void Hud::removeWeaponWidget(OrxGui::GLGuiWidget* widget) |
---|
[8518] | 331 | {} |
---|
[6438] | 332 | |
---|
[6441] | 333 | void Hud::updateResolution() |
---|
| 334 | { |
---|
[6498] | 335 | this->resX = State::getResX(); |
---|
| 336 | this->resY = State::getResY(); |
---|
[8976] | 337 | |
---|
| 338 | this->setSize2D(.2 * this->resX, this->resY); |
---|
[8989] | 339 | this->notifier->setAbsCoor2D(0.7 * this->resX, 0.3 * this->resY); |
---|
| 340 | this->notifier->setWidgetSize(0.25 * this->resX, 0.6 * this->resY); |
---|
[8976] | 341 | |
---|
[10234] | 342 | int overlayWidth = this->resX * (overlayPercentage)/(200); |
---|
| 343 | this->rightRect->hide(); |
---|
| 344 | this->leftRect->hide(); |
---|
| 345 | |
---|
| 346 | this->leftRect->setParent2D(this); |
---|
| 347 | this->leftRect->setWidgetSize(float(overlayWidth), float(this->resY)); |
---|
| 348 | this->leftRect->setAbsCoor2D(0,0); |
---|
| 349 | this->leftRect->setBackgroundTexture(Texture()); |
---|
| 350 | this->leftRect->setBackgroundColor(Color(0,0,0.7,0.2)); |
---|
| 351 | this->leftRect->setForegroundTexture(Texture()); |
---|
| 352 | this->leftRect->setForegroundColor(Color(0,0,0,0)); |
---|
| 353 | |
---|
| 354 | this->rightRect->setParent2D(this); |
---|
| 355 | this->rightRect->setWidgetSize(float(overlayWidth), float(this->resY)); |
---|
| 356 | this->rightRect->setAbsCoor2D(this->resX - overlayWidth,0); |
---|
| 357 | this->rightRect->setBackgroundTexture(Texture()); |
---|
| 358 | this->rightRect->setBackgroundColor(Color(0,0,0.7,0.2)); |
---|
| 359 | this->rightRect->setForegroundTexture(Texture()); |
---|
| 360 | this->rightRect->setForegroundColor(Color(0,0,0,0)); |
---|
| 361 | |
---|
| 362 | |
---|
[10233] | 363 | if (this->overlayActive == true) |
---|
| 364 | { |
---|
[10234] | 365 | this->rightRect->show(); |
---|
[10233] | 366 | this->leftRect->show(); |
---|
| 367 | } |
---|
[8995] | 368 | |
---|
[10233] | 369 | |
---|
[8996] | 370 | if (State::getPlayer() && State::getPlayer()->getPlayable() && State::getObjectManager()) |
---|
| 371 | { |
---|
[9869] | 372 | PRINTF(4)("UPDATING RADAR\n"); |
---|
[10234] | 373 | this->_radar->setParent2D(this->leftRect); |
---|
[10270] | 374 | if (radarCenterNode == NULL) |
---|
| 375 | this->_radar->setCenterNode(State::getPlayer()->getPlayable()); |
---|
| 376 | else |
---|
| 377 | this->_radar->setCenterNode(this->radarCenterNode); |
---|
| 378 | |
---|
[10092] | 379 | //this->_radar->addEntityList(&State::getObjectManager()->getEntityList((OM_LIST)(State::getPlayer()->getPlayable()->getOMListNumber()+1)), Color(.4, .4, 1.0)); |
---|
| 380 | this->_radar->addEntityList(&State::getObjectManager()->getEntityList(OM_GROUP_00), Color(1, 0, 0)); |
---|
| 381 | this->_radar->addEntityList(&State::getObjectManager()->getEntityList(OM_GROUP_01), Color(0, 0, 1)); |
---|
[10230] | 382 | this->_radar->setAbsCoor2D(0, 0.01 * this->resY); |
---|
| 383 | this->_radar->setWidgetSize(0.18 * this->resX, 0.2 * this->resY); |
---|
[9014] | 384 | this->_radar->setRange(300); |
---|
[8996] | 385 | this->_radar->show(); |
---|
[10194] | 386 | |
---|
| 387 | if (this->armorWidget != NULL) |
---|
[10230] | 388 | this->armorWidget->setRelCoor2D(100,0.2*this->resY + this->armorWidget->getSizeX2D()); |
---|
[10194] | 389 | if (this->shieldWidget != NULL) |
---|
[10230] | 390 | this->shieldWidget->setRelCoor2D(60,0.2*this->resY + this->armorWidget->getSizeX2D()); |
---|
[10194] | 391 | if (this->energyWidget != NULL) |
---|
[10230] | 392 | this->energyWidget->setRelCoor2D(20,0.2*this->resY + this->armorWidget->getSizeX2D()); |
---|
[10194] | 393 | //this->shieldWidget->setRelCoor2D(0.1*this->resX + this->armorWidget->getSizeX2D(),0); |
---|
| 394 | //this->energyWidget->setRelCoor2D(0.1*this->resX + this->armorWidget->getSizeX2D() + this->shieldWidget->getSizeX2D(),0); |
---|
[8996] | 395 | } |
---|
| 396 | |
---|
[10194] | 397 | /* |
---|
[10111] | 398 | if (this->shipValuesBox != NULL) |
---|
[6441] | 399 | { |
---|
[10139] | 400 | this->shipValuesBox->setAbsCoor2D(0.2 * this->resX, 0.4 * this->resY); |
---|
[10111] | 401 | this->shipValuesBox->setWidgetSize(.4 * this->resX, 0.1 * this->resY); |
---|
[6441] | 402 | } |
---|
[10139] | 403 | else |
---|
| 404 | createShipValuesBox(); |
---|
[10194] | 405 | */ |
---|
[6442] | 406 | |
---|
[10230] | 407 | std::list<OrxGui::GLGuiEnergyWidgetVertical*>::iterator weaponWidget; |
---|
[10278] | 408 | Vector2D pos = Vector2D(overlayWidth + this->rightRect->getAbsCoor2D().x, 0.5*this->resY); |
---|
| 409 | PRINTF(0)("Cur Pos: %f,%f\n",pos.x,pos.y); |
---|
[10234] | 410 | // out of reasons i can't get behind, this version is segfaulting when calling getSizeX2D or getSizeY2D. the other |
---|
| 411 | // element2D- related function works tough.. :s |
---|
| 412 | |
---|
[10230] | 413 | for (weaponWidget = this->weaponsWidgetsPrim.begin(); weaponWidget != this->weaponsWidgetsPrim.end(); weaponWidget++) |
---|
[6442] | 414 | { |
---|
[10234] | 415 | if (pos.x < overlayWidth*0.2) |
---|
[8987] | 416 | { |
---|
[10278] | 417 | pos.x = overlayWidth + this->rightRect->getAbsCoor2D().x; |
---|
[10234] | 418 | pos.y += (*weaponWidget)->getSizeX2D(); |
---|
[10230] | 419 | } |
---|
[10234] | 420 | pos.x -= (*weaponWidget)->getSizeY2D(); |
---|
[10230] | 421 | (*weaponWidget)->setAbsCoor2D(pos.x, pos.y); |
---|
[10234] | 422 | //(*weaponWidget)->setAbsCoor2D(0,100); |
---|
[10230] | 423 | (*weaponWidget)->show(); |
---|
| 424 | //printf("update thing %s::%s\n", (*weaponWidget)->getClassCName(), (*weaponWidget)->getName()); |
---|
| 425 | } |
---|
[8987] | 426 | |
---|
[10234] | 427 | pos.y += 160; |
---|
[10278] | 428 | pos.x = overlayWidth + this->rightRect->getAbsCoor2D().x; |
---|
[10230] | 429 | for (weaponWidget = this->weaponsWidgetsSec.begin(); weaponWidget != this->weaponsWidgetsSec.end(); weaponWidget++) |
---|
| 430 | { |
---|
[10234] | 431 | if (pos.x < overlayWidth*0.2) |
---|
[10230] | 432 | { |
---|
[10278] | 433 | pos.x = overlayWidth + this->rightRect->getAbsCoor2D().x; |
---|
[10234] | 434 | pos.y += (*weaponWidget)->getSizeX2D(); |
---|
[8987] | 435 | } |
---|
[10234] | 436 | pos.x -= (*weaponWidget)->getSizeY2D(); |
---|
[10230] | 437 | (*weaponWidget)->setAbsCoor2D(pos.x, pos.y); |
---|
[8976] | 438 | (*weaponWidget)->show(); |
---|
[9406] | 439 | //printf("update thing %s::%s\n", (*weaponWidget)->getClassCName(), (*weaponWidget)->getName()); |
---|
[6442] | 440 | } |
---|
[10230] | 441 | |
---|
[6441] | 442 | } |
---|
| 443 | |
---|
[8990] | 444 | void Hud::draw() const |
---|
[6441] | 445 | { |
---|
[8990] | 446 | // GLGuiWidget::draw(); |
---|
[6441] | 447 | } |
---|
| 448 | |
---|
[8990] | 449 | |
---|
| 450 | void Hud::process(const Event &event) |
---|
[6441] | 451 | { |
---|
[8990] | 452 | if (event.type == EV_VIDEO_RESIZE) |
---|
| 453 | this->updateResolution(); |
---|
[9003] | 454 | else if (event.type == SDLK_TAB) |
---|
| 455 | { |
---|
| 456 | /// TODO SHOW THE INPUT-LINE |
---|
| 457 | // this->inputLine->select(); |
---|
| 458 | } |
---|
[10139] | 459 | } |
---|
[9003] | 460 | |
---|
[10194] | 461 | /* |
---|
[10139] | 462 | void Hud::createShipValuesBox() |
---|
| 463 | { |
---|
[10194] | 464 | this->shipValuesBox = new OrxGui::GLGuiBox(OrxGui::Vertical); |
---|
[10139] | 465 | //this->shipValuesBox->setWidgetSize(1000,500); |
---|
| 466 | //this->shipValuesBox->setBackgroundTexture("maps/gui_container_background.png"); |
---|
| 467 | this->shipValuesBox->setBackgroundTexture(Texture()); |
---|
| 468 | this->shipValuesBox->setBackgroundColor(Color(0,0,1,0.5)); |
---|
| 469 | this->shipValuesBox->setVisibility(true); |
---|
[6441] | 470 | } |
---|
[10194] | 471 | */ |
---|
[6441] | 472 | |
---|
| 473 | |
---|