Changeset 10685 in orxonox.OLD for branches/hud
- Timestamp:
- Jun 11, 2007, 4:40:33 PM (18 years ago)
- Location:
- branches/hud/src
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/hud/src/util/hud.cc
r10516 r10685 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;54 this->healthWidget = NULL; 55 55 //this->leftRect = NULL; 56 56 //this->rightRect = NULL; … … 60 60 this->overlayPercentage = 40; 61 61 this->overlayActive = false; 62 this->rightRect = new OrxGui::GLGuiImage(); 63 this->leftRect = new OrxGui::GLGuiImage(); 64 65 this->inputLine = new OrxGui::GLGuiInputLine(); 66 this->inputLine->setParent2D(this); 62 //this->rightRect = new OrxGui::GLGuiImage(); 63 //this->leftRect = new OrxGui::GLGuiImage(); 64 this->topRect = new OrxGui::GLGuiImage(); 65 this->bottomRect = new OrxGui::GLGuiImage(); 66 this->middleRect = new OrxGui::GLGuiImage(); 67 68 //this->inputLine = new OrxGui::GLGuiInputLine(); 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(); … … 90 96 delete this->rightRect; 91 97 delete this->leftRect; 98 delete this->topRect; 99 delete this->bottomRect; 100 delete this->middleRect; 92 101 //if (this->shipValuesBox != NULL) 93 102 //delete this->shipValuesBox; … … 135 144 } 136 145 137 this->updateResolution(); 138 } 139 140 void Hud::setShi ledWidget(OrxGui::GLGuiWidget* widget)146 this->updateResolution(); 147 } 148 149 void Hud::setShieldWidget(OrxGui::GLGuiWidget* widget) 141 150 { 142 151 /* … … 169 178 } 170 179 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);*/ 180 void Hud::setHealthWidget(OrxGui::GLGuiWidget* widget) 181 { 182 if( this->playmode == FirstPerson ) 183 { 184 this->healthWidget = new OrxGui::GLGuiBar(); 185 this->healthWidget->setMaximum(widget->getBarWidget()->maximum()); 186 this->healthWidget->setValue(widget->getBarWidget()->value()); 187 this->healthWidget->setParent2D(this->barSocket); 188 } 189 else 190 { 191 /* 192 if (this->shipValuesBox == NULL) 193 this->createShipValuesBox(); 194 */ 195 196 // decopple old widget 197 if (this->healthWidget != NULL) 198 { 199 this->healthWidget->hide(); 200 } 201 202 this->healthWidget = widget; 203 if (this->healthWidget != NULL) 204 { 205 //this->healthWidget->shiftDir2D(270); 206 //this->shipValuesBox->pack(this->healthWidget); 207 //dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (this->healthWidget)->setStandardSettings(); 208 this->healthWidget->setParent2D(this->leftRect); 209 //dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (this->healthWidget)->setDisplayedImage("textures/gui/gui_health_icon.png"); 210 this->healthWidget->show(); 211 /* this->healthWidget->frontMaterial().setDiffuseMap("hud_energy_bar.png"); 212 this->healthWidget->frontMaterial().setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);*/ 213 } 214 } 215 216 this->updateResolution(); 217 } 218 219 220 void Hud::setImplantWidget(OrxGui::GLGuiWidget* widget) 221 { 222 //if (this->shipValuesBox == NULL) 223 //this->createShipValuesBox(); 224 225 // decopple old widget 226 if (this->implantWidget != NULL) 227 { 228 this->implantWidget->hide(); 229 } 230 231 this->implantWidget = widget; 232 if (this->implantWidget != NULL) 233 { 234 //this->energyWidget->shiftDir2D(270); 235 //dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (this->energyWidget)->setDisplayedName("Electronics"); 236 //this->shipValuesBox->pack(this->energyWidget); 237 //dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (this->energyWidget)->setStandardSettings(); 238 this->implantWidget->setParent2D(this->leftRect); 239 dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (this->implantWidget)->setDisplayedImage("textures/gui/gui_electronics_icon.png"); 240 this->implantWidget->show(); 241 /* this->energyWidget->frontMaterial().setDiffuseMap("hud_energy_bar.png"); 242 this->energyWidget->frontMaterial().setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);*/ 195 243 } 196 244 … … 341 389 342 390 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); 391 if( this->playmode != FirstPerson ) 392 { 393 this->notifier->setAbsCoor2D(0.7 * this->resX, 0.3 * this->resY); 394 this->notifier->setWidgetSize(0.25 * this->resX, 0.6 * this->resY); 395 } 345 396 346 397 int overlayWidth = 0; … … 354 405 this->rightRect->hide(); 355 406 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 407 408 if( this->playmode != FirstPerson ) 409 { 410 this->leftRect->setParent2D(this); 411 this->leftRect->setWidgetSize(float(overlayWidth), float(this->resY)); 412 this->leftRect->setAbsCoor2D(0,0); 413 this->leftRect->setBackgroundTexture(Texture()); 414 this->leftRect->setBackgroundColor(Color(0,0,0.7,0.2)); 415 this->leftRect->setForegroundTexture(Texture()); 416 this->leftRect->setForegroundColor(Color(0,0,0,0)); 417 418 this->rightRect->setParent2D(this); 419 this->rightRect->setWidgetSize(float(overlayWidth), float(this->resY)); 420 this->rightRect->setAbsCoor2D(this->resX - overlayWidth,0); 421 this->rightRect->setBackgroundTexture(Texture()); 422 this->rightRect->setBackgroundColor(Color(0,0,0.7,0.2)); 423 this->rightRect->setForegroundTexture(Texture()); 424 this->rightRect->setForegroundColor(Color(0,0,0,0)); 425 } 426 else 427 { 428 this->bottomRect->setParent2D(this); 429 this->bottomRect->setWidgetSize(float(this->resX), float(overlayWidth)); 430 this->bottomRect->setAbsCoor2D(0, this->resY - overlayWidth); 431 this->topRect->setParent2D(this); 432 this->topRect->setWidgetSize(float(this->resX), float(overlayWidth)); 433 this->topRect->setAbsCoor2D(0, 0); 434 this->middleRect->setParent2D(this); 435 this->middleRect->setWidgetSize(float(this->resY)/2, float(this->resY)/2); 436 this->middleRect->setAbsCoor2D(float(this->resX - this->resY/2)/2, float(this->resY)/4); 437 } 373 438 374 439 if (this->overlayActive == true) … … 382 447 { 383 448 PRINTF(4)("UPDATING RADAR\n"); 384 this->_radar->setParent2D(this->leftRect); 449 if( this->playmode != FirstPerson ) 450 this->_radar->setParent2D(this->leftRect); 451 else 452 this->_radar->setParent2D(this->topRect); 385 453 if (radarCenterNode == NULL) 386 454 this->_radar->setCenterNode(State::getPlayer()->getPlayable()); … … 397 465 398 466 int statWidgetsNumber = 0; 399 float expected ArmorSizeX = 0;400 float expected ArmorSizeY = 0;467 float expectedHealthSizeX = 0; 468 float expectedHealthSizeY = 0; 401 469 float newSizeY = 0; float newSizeX = 0; 402 470 float moduloWidth = 0; 403 471 404 if (this->armorWidget != NULL) 405 { 406 expectedArmorSizeX = 150; 407 expectedArmorSizeY = 50; 408 statWidgetsNumber++; 409 } 410 472 if( this->playmode != FirstPerson ) 473 { 474 if (this->healthWidget != NULL) 475 { 476 expectedHealthSizeX = 150; 477 expectedHealthSizeY = 50; 478 statWidgetsNumber++; 479 } 480 481 if (this->shieldWidget != NULL) 482 statWidgetsNumber++; 483 484 if (this->energyWidget != NULL) 485 statWidgetsNumber++; 486 487 if (expectedHealthSizeY * statWidgetsNumber > overlayWidth) 488 { 489 newSizeY = overlayWidth / float(statWidgetsNumber); 490 newSizeX = expectedHealthSizeX; 491 PRINTF(0)("Statwidgets resized\n"); 492 } 493 else 494 { 495 newSizeY = expectedHealthSizeY; 496 newSizeX = expectedHealthSizeX; 497 moduloWidth = int(overlayWidth) % int(expectedHealthSizeY * statWidgetsNumber); 498 } 499 500 float posY = overlayWidth + newSizeX; 501 502 if (this->healthWidget != NULL) 503 { 504 this->healthWidget->setSize2D(newSizeX, newSizeY); 505 this->healthWidget->setRelCoor2D((statWidgetsNumber - 1) * newSizeY + 3 * moduloWidth / (statWidgetsNumber + 1),posY); 506 } 507 if (this->shieldWidget != NULL) 508 { 509 this->shieldWidget->setSize2D(newSizeX, newSizeY); 510 this->shieldWidget->setRelCoor2D((statWidgetsNumber - 2) * newSizeY + 2 *moduloWidth / (statWidgetsNumber + 1),posY); 511 } 512 if (this->energyWidget != NULL) 513 { 514 this->energyWidget->setSize2D(newSizeX, newSizeY); 515 this->energyWidget->setRelCoor2D(moduloWidth / (statWidgetsNumber + 1),posY); 516 } 517 } 518 else 519 { 520 this->barSocket->setParent2D(this->bottomRect); 521 this->barSocket->setWidgetSize( float(overlayWidth), float(overlayWidth)); 522 this->barSocket->setRelCoor2D(0,this->resX - float(overlayWidth)); 523 524 this->healthWidget->setRelCoor2D(10,-20); 525 } 526 527 528 /* 529 if (this->healthWidget != NULL) 530 this->healthWidget->setRelCoor2D(100,0.2*this->resY + this->healthWidget->getSizeX2D()); 411 531 if (this->shieldWidget != NULL) 412 statWidgetsNumber++; 413 532 this->shieldWidget->setRelCoor2D(60,0.2*this->resY + this->healthWidget->getSizeX2D()); 414 533 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()); 534 this->energyWidget->setRelCoor2D(20,0.2*this->resY + this->healthWidget->getSizeX2D()); 455 535 */ 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);536 //this->shieldWidget->setRelCoor2D(0.1*this->resX + this->healthWidget->getSizeX2D(),0); 537 //this->energyWidget->setRelCoor2D(0.1*this->resX + this->healthWidget->getSizeX2D() + this->shieldWidget->getSizeX2D(),0); 458 538 } 459 539 -
branches/hud/src/util/hud.h
r10368 r10685 28 28 29 29 public: 30 31 typedef enum { 32 Vertical = 1, //!< Vertical (seen from left or right/move in x-z) 33 Horizontal = 2, //!< Horizontal (seet from the top/move in x-y) 34 FromBehind = 4, //!< Seen from behind (move in z-y) 35 Full3D = 8, //!< Full featured 3D-mode. (move in all directions x-y-z) 36 FirstPerson = 16, 37 38 PlaymodeCount = 5, 39 } Playmode; 40 30 41 Hud(); 31 42 virtual ~Hud(); … … 36 47 void notifyUser(const std::string& message); 37 48 49 inline void setMode(Hud::Playmode playmode) {this->playmode = playmode;}; 50 inline Hud::Playmode getMode() {return this->playmode;}; 38 51 39 52 void setBackGround(); 40 53 void setEnergyWidget(OrxGui::GLGuiWidget* widget); 41 void setShiledWidget(OrxGui::GLGuiWidget* widget); 42 void setArmorWidget(OrxGui::GLGuiWidget* widget); 54 void setShieldWidget(OrxGui::GLGuiWidget* widget); 55 void setHealthWidget(OrxGui::GLGuiWidget* widget); 56 void setImplantWidget(OrxGui::GLGuiWidget* widget); 43 57 inline OrxGui::GLGuiWidget* getEnergyWidget() {return this->energyWidget;}; 44 58 inline OrxGui::GLGuiWidget* getShieldWidget() {return this->shieldWidget;}; 45 inline OrxGui::GLGuiWidget* getArmorWidget() {return this->armorWidget;}; 59 inline OrxGui::GLGuiWidget* getHealthWidget() {return this->healthWidget;}; 60 inline OrxGui::GLGuiWidget* getImplantWidget() {return this->implantWidget;}; 46 61 47 62 void setWeaponManager(WeaponManager* weaponMan, WeaponManager* weaponManSec = NULL); … … 82 97 unsigned int resX; 83 98 unsigned int resY; 99 100 Hud::Playmode playmode; 84 101 85 102 float travelZoneWidth; //the percentage of the screen, the player has got for his movements. should always be a value between 0 and 1; … … 87 104 OrxGui::GLGuiWidget* energyWidget; 88 105 OrxGui::GLGuiWidget* shieldWidget; 89 OrxGui::GLGuiWidget* armorWidget; 106 OrxGui::GLGuiWidget* healthWidget; 107 OrxGui::GLGuiWidget* implantWidget; 90 108 91 109 OrxGui::GLGuiNotifier* notifier; … … 96 114 OrxGui::GLGuiWidget* rightRect; 97 115 OrxGui::GLGuiWidget* leftRect; 116 OrxGui::GLGuiWidget* topRect; 117 OrxGui::GLGuiWidget* bottomRect; 118 OrxGui::GLGuiWidget* middleRect; 119 OrxGui::GLGuiWidget* barSocket; 98 120 bool overlayActive; 99 121 int overlayPercentage; //the percentage of the screen, the player has got for his movements. should always be a value between 0 and 1; -
branches/hud/src/world_entities/creatures/fps_player.cc
r10654 r10685 20 20 #include "state.h" 21 21 #include "tools/camera.h" 22 #include "player.h" 22 23 23 24 #include "src/lib/util/loading/factory.h" … … 52 53 ->addMethod("getAbsCoorY", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorY)) 53 54 ->addMethod("getAbsCoorZ", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorZ)) 55 ->addMethod("displayHUDText", Executor1<FPSPlayer, lua_State*, const std::string&>(&FPSPlayer::displayHUDText)) 54 56 ); 55 57 … … 352 354 { 353 355 this->getWeaponManager().fire(); 354 PRINTF(0)("Crosshair at position: %f, %f, %f\n", this->getWeaponManager().getFixedTarget()->getAbsCoor().x, this->getWeaponManager().getFixedTarget()->getAbsCoor().y, this->getWeaponManager().getFixedTarget()->getAbsCoor().z);355 356 } 356 357 … … 604 605 } 605 606 607 void FPSPlayer::displayHUDText( const std::string& message ) 608 { 609 State::getPlayer()->hud().notifyUser(message); 610 } -
branches/hud/src/world_entities/creatures/fps_player.h
r10654 r10685 36 36 virtual void tick(float time); 37 37 virtual void draw() const; 38 39 void displayHUDText( const std::string& message ); 38 40 39 41 -
branches/hud/src/world_entities/player.cc
r10516 r10685 19 19 20 20 #include "event_handler.h" 21 #include "fps_player.h" 21 22 22 23 #include "state.h" … … 74 75 PRINTF(4)("Enter new Playable\n"); 75 76 this->playable = playable; 76 this->_hud.setArmorWidget(this->playable->getHealthWidget()); 77 if (dynamic_cast<SpaceShip*>(this->playable) != 0) 77 78 if( playable->isA(FpsPlayer::staticClassID()) ) 79 { 80 this->_hud.setMod(Hud::Playmode FirstPerson); 81 this->_hud.setHealthWidget(this->playable->getHealthWidget()); 82 } 83 else 84 { 85 this->_hud.setMode(Hud::Playmode Full3D); 86 this->_hud.setHealthWidget(this->playable->getHealthWidget()); 87 } 88 /*if (dynamic_cast<SpaceShip*>(this->playable) != 0) 78 89 this->_hud.setWeaponManager(&this->playable->getWeaponManager(), &dynamic_cast<SpaceShip*>(this->playable)->getWeaponManagerSecondary()); 79 90 else 80 this->_hud.setWeaponManager(&this->playable->getWeaponManager()); 91 this->_hud.setWeaponManager(&this->playable->getWeaponManager());*/ 81 92 82 93 this->playable->setPlayer(this); -
branches/hud/src/world_entities/world_entity.cc
r10618 r10685 813 813 } 814 814 815 /** 816 * @brief creates the ImplantWidget 817 * 818 * since not all entities need an ImpantWidget, it is only created on request. 819 */ 820 void WorldEntity::createImplantWidget() 821 { 822 if (this->implantWidget == NULL) 823 { 824 this->implantWidget = new OrxGui::GLGuiEnergyWidgetVertical(); 825 //this->impantWidget->setDisplayedName("Implant"); 826 //this->impantWidget->setSize2D(100,20); 827 //this->impantWidget->setAbsCoor2D(100,200); 828 829 //this->updateImplantWidget(); 830 } 831 else 832 PRINTF(3)("Allready created the ImlpantWidget for %s::%s\n", this->getClassCName(), this->getCName()); 833 } 834 815 835 void WorldEntity::increaseHealthMax(float increaseHealth) 816 836 { … … 824 844 this->createHealthWidget(); 825 845 return this->healthWidget; 846 } 847 848 849 OrxGui::GLGuiWidget* WorldEntity::getImplantWidget() 850 { 851 this->createImplantWidget(); 852 return this->implantWidget; 826 853 } 827 854 -
branches/hud/src/world_entities/world_entity.h
r10540 r10685 161 161 void increaseHealthMax(float increaseHealth); 162 162 OrxGui::GLGuiWidget* getHealthWidget(); 163 OrxGui::GLGuiWidget* getImplantWidget(); 163 164 bool hasHealthWidget() const { return this->healthWidget != NULL; }; 164 165 … … 187 188 void setHealthMax(float healthMax); 188 189 void createHealthWidget(); 190 void createImplantWidget(); 189 191 // CharacterAttributes* charAttr; //!< the character attributes of a world_entity 190 192 … … 206 208 207 209 private: 208 /// TODO maybe we will move the following threeentries and the corresponding functions to Playable AND NPC210 /// TODO maybe we will move the following eight entries and the corresponding functions to Playable AND NPC 209 211 float damage; //!< the damage dealt to other objects by colliding. 210 212 float health; //!< The Energy of this Entity, if the Entity has any energy at all. 211 float healthMax; //!< The Maximal energy this entity can take. 213 float healthMax; //!< The Maximal energy this entity can take. 214 float implantEnergy; //!< energy of implants 212 215 OrxGui::GLGuiEnergyWidgetVertical* healthWidget; //!< The Slider (if wanted). 216 OrxGui::GLGuiEnergyWidgetVertical* implantWidget; 213 217 214 218 std::vector<Model*> models; //!< The model that should be loaded for this entity. … … 247 251 float healthMax_write; 248 252 int healthMax_handle; 253 254 249 255 250 256
Note: See TracChangeset
for help on using the changeset viewer.