Changeset 10698 in orxonox.OLD for trunk/src/util/hud.cc
- Timestamp:
- Jun 14, 2007, 5:33:43 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/util/hud.cc
r10516 r10698 11 11 ### File Specific: 12 12 main-programmer: Benjamin Grauer 13 co-programmer: ...13 co-programmer: Benjamin Knecht 14 14 */ 15 15 … … 52 52 this->energyWidget = NULL; 53 53 this->shieldWidget = NULL; 54 this-> armorWidget = NULL;55 //this->leftRect = NULL;56 //this->rightRect = NULL;54 this->healthWidget = NULL; 55 this->leftRect = NULL; 56 this->rightRect = NULL; 57 57 this->resX = 1; 58 58 this->resY = 1; … … 62 62 this->rightRect = new OrxGui::GLGuiImage(); 63 63 this->leftRect = new OrxGui::GLGuiImage(); 64 this->topRect = new OrxGui::GLGuiImage(); 65 this->bottomRect = new OrxGui::GLGuiImage(); 66 this->middleRect = new OrxGui::GLGuiImage(); 64 67 65 68 this->inputLine = new OrxGui::GLGuiInputLine(); 66 this->inputLine->setParent2D(this);69 //this->inputLine->setParent2D(this); 67 70 this->notifier = new OrxGui::GLGuiNotifier(); 68 this->notifier->setParent2D(this); 69 notifier->setAbsCoor2D(100,100); 71 this->notifier->setParent2D(this->bottomRect); 72 notifier->setRelCoor2D(5,5); 73 74 this->barSocket = new OrxGui::GLGuiImage(); 75 this->barSocket->setParent2D(this->bottomRect); 70 76 71 77 this->_radar = new OrxGui::GLGuiRadar(); … … 88 94 89 95 delete this->_radar; 96 delete this->barSocket; 90 97 delete this->rightRect; 91 98 delete this->leftRect; 99 delete this->topRect; 100 delete this->bottomRect; 101 delete this->middleRect; 102 92 103 //if (this->shipValuesBox != NULL) 93 104 //delete this->shipValuesBox; … … 135 146 } 136 147 137 this->updateResolution(); 138 } 139 140 void Hud::setShi ledWidget(OrxGui::GLGuiWidget* widget)148 this->updateResolution(); 149 } 150 151 void Hud::setShieldWidget(OrxGui::GLGuiWidget* widget) 141 152 { 142 153 /* … … 169 180 } 170 181 171 void Hud::setArmorWidget(OrxGui::GLGuiWidget* widget) 172 { 173 /* 174 if (this->shipValuesBox == NULL) 175 this->createShipValuesBox(); 176 */ 177 178 // decopple old widget 179 if (this->armorWidget != NULL) 180 { 181 this->armorWidget->hide(); 182 } 183 184 this->armorWidget = widget; 185 if (this->armorWidget != NULL) 186 { 187 //this->armorWidget->shiftDir2D(270); 188 //this->shipValuesBox->pack(this->armorWidget); 189 //dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (this->armorWidget)->setStandardSettings(); 190 this->armorWidget->setParent2D(this->leftRect); 191 dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (this->armorWidget)->setDisplayedImage("textures/gui/gui_health_icon.png"); 192 this->armorWidget->show(); 193 /* this->armorWidget->frontMaterial().setDiffuseMap("hud_energy_bar.png"); 194 this->armorWidget->frontMaterial().setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);*/ 182 void Hud::setHealthWidget(OrxGui::GLGuiWidget* widget) 183 { 184 if( this->playmode == FirstPerson ) 185 { 186 this->healthWidget = new OrxGui::GLGuiBar(); 187 dynamic_cast<OrxGui::GLGuiBar*> (this->healthWidget)->setMaximum(dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (widget)->getBarWidget()->maximum()); 188 dynamic_cast<OrxGui::GLGuiBar*> (this->healthWidget)->setValue(dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (widget)->getBarWidget()->value()); 189 this->healthWidget->setParent2D(this->barSocket); 190 } 191 else 192 { 193 /* 194 if (this->shipValuesBox == NULL) 195 this->createShipValuesBox(); 196 */ 197 198 // decopple old widget 199 if (this->healthWidget != NULL) 200 { 201 this->healthWidget->hide(); 202 } 203 204 this->healthWidget = widget; 205 if (this->healthWidget != NULL) 206 { 207 //this->healthWidget->shiftDir2D(270); 208 //this->shipValuesBox->pack(this->healthWidget); 209 //dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (this->healthWidget)->setStandardSettings(); 210 this->healthWidget->setParent2D(this->leftRect); 211 //dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (this->healthWidget)->setDisplayedImage("textures/gui/gui_health_icon.png"); 212 this->healthWidget->show(); 213 /* this->healthWidget->frontMaterial().setDiffuseMap("hud_energy_bar.png"); 214 this->healthWidget->frontMaterial().setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);*/ 215 } 216 } 217 218 this->updateResolution(); 219 } 220 221 222 void Hud::setImplantWidget(OrxGui::GLGuiWidget* widget) 223 { 224 //if (this->shipValuesBox == NULL) 225 //this->createShipValuesBox(); 226 227 // decopple old widget 228 if (this->implantWidget != NULL) 229 { 230 this->implantWidget->hide(); 231 } 232 233 this->implantWidget = widget; 234 if (this->implantWidget != NULL) 235 { 236 //this->energyWidget->shiftDir2D(270); 237 //dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (this->energyWidget)->setDisplayedName("Electronics"); 238 //this->shipValuesBox->pack(this->energyWidget); 239 //dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (this->energyWidget)->setStandardSettings(); 240 this->implantWidget->setParent2D(this->leftRect); 241 dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (this->implantWidget)->setDisplayedImage("textures/gui/gui_electronics_icon.png"); 242 this->implantWidget->show(); 243 /* this->energyWidget->frontMaterial().setDiffuseMap("hud_energy_bar.png"); 244 this->energyWidget->frontMaterial().setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);*/ 195 245 } 196 246 … … 341 391 342 392 this->setSize2D(.2 * this->resX, this->resY); 343 this->notifier->setAbsCoor2D(0.7 * this->resX, 0.3 * this->resY); 344 this->notifier->setWidgetSize(0.25 * this->resX, 0.6 * this->resY); 393 if( this->playmode != FirstPerson ) 394 { 395 this->notifier->setAbsCoor2D(0.7 * this->resX, 0.3 * this->resY); 396 this->notifier->setWidgetSize(0.25 * this->resX, 0.6 * this->resY); 397 } 345 398 346 399 int overlayWidth = 0; … … 348 401 overlayWidth = this->resX * (overlayPercentage)/(200); 349 402 else 350 overlayWidth = this->resX * 0.1;403 overlayWidth = this->resX / 10; // fixed warning! 351 404 //if (overlayWidth < 100) 352 405 //overlayWidth = 100; … … 354 407 this->rightRect->hide(); 355 408 this->leftRect->hide(); 356 357 this->leftRect->setParent2D(this); 358 this->leftRect->setWidgetSize(float(overlayWidth), float(this->resY)); 359 this->leftRect->setAbsCoor2D(0,0); 360 this->leftRect->setBackgroundTexture(Texture()); 361 this->leftRect->setBackgroundColor(Color(0,0,0.7,0.2)); 362 this->leftRect->setForegroundTexture(Texture()); 363 this->leftRect->setForegroundColor(Color(0,0,0,0)); 364 365 this->rightRect->setParent2D(this); 366 this->rightRect->setWidgetSize(float(overlayWidth), float(this->resY)); 367 this->rightRect->setAbsCoor2D(this->resX - overlayWidth,0); 368 this->rightRect->setBackgroundTexture(Texture()); 369 this->rightRect->setBackgroundColor(Color(0,0,0.7,0.2)); 370 this->rightRect->setForegroundTexture(Texture()); 371 this->rightRect->setForegroundColor(Color(0,0,0,0)); 372 409 410 if( this->playmode != FirstPerson ) 411 { 412 this->leftRect->setParent2D(this); 413 this->leftRect->setWidgetSize(float(overlayWidth), float(this->resY)); 414 this->leftRect->setAbsCoor2D(0,0); 415 this->leftRect->setBackgroundTexture(Texture()); 416 this->leftRect->setBackgroundColor(Color(0,0,0.7,0.2)); 417 this->leftRect->setForegroundTexture(Texture()); 418 this->leftRect->setForegroundColor(Color(0,0,0,0)); 419 420 this->rightRect->setParent2D(this); 421 this->rightRect->setWidgetSize(float(overlayWidth), float(this->resY)); 422 this->rightRect->setAbsCoor2D(this->resX - overlayWidth,0); 423 this->rightRect->setBackgroundTexture(Texture()); 424 this->rightRect->setBackgroundColor(Color(0,0,0.7,0.2)); 425 this->rightRect->setForegroundTexture(Texture()); 426 this->rightRect->setForegroundColor(Color(0,0,0,0)); 427 } 428 else 429 { 430 this->bottomRect->setParent2D(this); 431 this->bottomRect->setWidgetSize(float(this->resX), float(overlayWidth)); 432 this->bottomRect->setAbsCoor2D(0, this->resY - overlayWidth); 433 this->topRect->setParent2D(this); 434 this->topRect->setWidgetSize(float(this->resX), float(overlayWidth)); 435 this->topRect->setAbsCoor2D(0, 0); 436 this->middleRect->setParent2D(this); 437 this->middleRect->setWidgetSize(float(this->resY)/2, float(this->resY)/2); 438 this->middleRect->setAbsCoor2D(float(this->resX - this->resY/2)/2, float(this->resY)/4); 439 } 373 440 374 441 if (this->overlayActive == true) … … 382 449 { 383 450 PRINTF(4)("UPDATING RADAR\n"); 384 this->_radar->setParent2D(this->leftRect); 451 if( this->playmode != FirstPerson ) 452 this->_radar->setParent2D(this->leftRect); 453 else 454 this->_radar->setParent2D(this->topRect); 385 455 if (radarCenterNode == NULL) 386 456 this->_radar->setCenterNode(State::getPlayer()->getPlayable()); … … 397 467 398 468 int statWidgetsNumber = 0; 399 float expected ArmorSizeX = 0;400 float expected ArmorSizeY = 0;469 float expectedHealthSizeX = 0; 470 float expectedHealthSizeY = 0; 401 471 float newSizeY = 0; float newSizeX = 0; 402 472 float moduloWidth = 0; 403 473 404 if (this->armorWidget != NULL) 405 { 406 expectedArmorSizeX = 150; 407 expectedArmorSizeY = 50; 408 statWidgetsNumber++; 409 } 410 474 if( this->playmode != FirstPerson ) 475 { 476 if (this->healthWidget != NULL) 477 { 478 expectedHealthSizeX = 150; 479 expectedHealthSizeY = 50; 480 statWidgetsNumber++; 481 } 482 483 if (this->shieldWidget != NULL) 484 statWidgetsNumber++; 485 486 if (this->energyWidget != NULL) 487 statWidgetsNumber++; 488 489 if (expectedHealthSizeY * statWidgetsNumber > overlayWidth) 490 { 491 newSizeY = overlayWidth / float(statWidgetsNumber); 492 newSizeX = expectedHealthSizeX; 493 PRINTF(0)("Statwidgets resized\n"); 494 } 495 else 496 { 497 newSizeY = expectedHealthSizeY; 498 newSizeX = expectedHealthSizeX; 499 moduloWidth = int(overlayWidth) % int(expectedHealthSizeY * statWidgetsNumber); 500 } 501 502 float posY = overlayWidth + newSizeX; 503 504 if (this->healthWidget != NULL) 505 { 506 this->healthWidget->setSize2D(newSizeX, newSizeY); 507 this->healthWidget->setRelCoor2D((statWidgetsNumber - 1) * newSizeY + 3 * moduloWidth / (statWidgetsNumber + 1),posY); 508 } 509 if (this->shieldWidget != NULL) 510 { 511 this->shieldWidget->setSize2D(newSizeX, newSizeY); 512 this->shieldWidget->setRelCoor2D((statWidgetsNumber - 2) * newSizeY + 2 *moduloWidth / (statWidgetsNumber + 1),posY); 513 } 514 if (this->energyWidget != NULL) 515 { 516 this->energyWidget->setSize2D(newSizeX, newSizeY); 517 this->energyWidget->setRelCoor2D(moduloWidth / (statWidgetsNumber + 1),posY); 518 } 519 } 520 else 521 { 522 this->barSocket->setParent2D(this->bottomRect); 523 this->barSocket->setWidgetSize( float(overlayWidth), float(overlayWidth)); 524 this->barSocket->setRelCoor2D(0,this->resX - float(overlayWidth)); 525 526 this->healthWidget->setRelCoor2D(10,-20); 527 } 528 529 530 /* 531 if (this->healthWidget != NULL) 532 this->healthWidget->setRelCoor2D(100,0.2*this->resY + this->healthWidget->getSizeX2D()); 411 533 if (this->shieldWidget != NULL) 412 statWidgetsNumber++; 413 534 this->shieldWidget->setRelCoor2D(60,0.2*this->resY + this->healthWidget->getSizeX2D()); 414 535 if (this->energyWidget != NULL) 415 statWidgetsNumber++; 416 417 if (expectedArmorSizeY * statWidgetsNumber > overlayWidth) 418 { 419 newSizeY = overlayWidth / float(statWidgetsNumber); 420 newSizeX = expectedArmorSizeX; 421 PRINTF(0)("Statwidgets resized\n"); 422 } 423 else 424 { 425 newSizeY = expectedArmorSizeY; 426 newSizeX = expectedArmorSizeX; 427 moduloWidth = int(overlayWidth) % int(expectedArmorSizeY * statWidgetsNumber); 428 } 429 430 float posY = overlayWidth + newSizeX; 431 432 if (this->armorWidget != NULL) 433 { 434 this->armorWidget->setSize2D(newSizeX, newSizeY); 435 this->armorWidget->setRelCoor2D((statWidgetsNumber - 1) * newSizeY + 3 * moduloWidth / (statWidgetsNumber + 1),posY); 436 } 437 if (this->shieldWidget != NULL) 438 { 439 this->shieldWidget->setSize2D(newSizeX, newSizeY); 440 this->shieldWidget->setRelCoor2D((statWidgetsNumber - 2) * newSizeY + 2 *moduloWidth / (statWidgetsNumber + 1),posY); 441 } 442 if (this->energyWidget != NULL) 443 { 444 this->energyWidget->setSize2D(newSizeX, newSizeY); 445 this->energyWidget->setRelCoor2D(moduloWidth / (statWidgetsNumber + 1),posY); 446 } 447 448 /* 449 if (this->armorWidget != NULL) 450 this->armorWidget->setRelCoor2D(100,0.2*this->resY + this->armorWidget->getSizeX2D()); 451 if (this->shieldWidget != NULL) 452 this->shieldWidget->setRelCoor2D(60,0.2*this->resY + this->armorWidget->getSizeX2D()); 453 if (this->energyWidget != NULL) 454 this->energyWidget->setRelCoor2D(20,0.2*this->resY + this->armorWidget->getSizeX2D()); 536 this->energyWidget->setRelCoor2D(20,0.2*this->resY + this->healthWidget->getSizeX2D()); 455 537 */ 456 //this->shieldWidget->setRelCoor2D(0.1*this->resX + this-> armorWidget->getSizeX2D(),0);457 //this->energyWidget->setRelCoor2D(0.1*this->resX + this-> armorWidget->getSizeX2D() + this->shieldWidget->getSizeX2D(),0);538 //this->shieldWidget->setRelCoor2D(0.1*this->resX + this->healthWidget->getSizeX2D(),0); 539 //this->energyWidget->setRelCoor2D(0.1*this->resX + this->healthWidget->getSizeX2D() + this->shieldWidget->getSizeX2D(),0); 458 540 } 459 541
Note: See TracChangeset
for help on using the changeset viewer.