- Timestamp:
- Dec 22, 2006, 12:21:38 AM (18 years ago)
- Location:
- branches/playability/src
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/playability/src/lib/gui/gl/glgui_bar.cc
r9869 r10139 71 71 72 72 this->_value = value; 73 this->_frontRect.setSize((this->getSizeX2D() - borderLeft() - borderRight()) * (_value - _minimum)/ (_minimum + _maximum)73 this->_frontRect.setSize((this->getSizeX2D() - borderLeft() - borderRight()) * (_value - _minimum) / (_maximum -_minimum) 74 74 ,this->getSizeY2D() - borderTop() - borderBottom()); 75 75 } … … 99 99 100 100 this->_frontRect.setTopLeft(borderLeft(), borderTop()); 101 this->_frontRect.setSize((this->getSizeX2D() - borderLeft() - borderRight()) * (_value - _minimum)/ (_minimum + _maximum)102 101 this->_frontRect.setSize((this->getSizeX2D() - borderLeft() - borderRight()) * (_value - _minimum) / (_maximum -_minimum) 102 ,this->getSizeY2D() - borderTop() - borderBottom()); 103 103 104 104 } -
branches/playability/src/lib/gui/gl/glgui_box.cc
r9869 r10139 18 18 #include "glgui_box.h" 19 19 #include <cassert> 20 #include <iostream> 20 21 #include "debug.h" 22 #include "network_log.h" 21 23 22 24 namespace OrxGui … … 177 179 void GLGuiBox::resize() 178 180 { 179 if ( orientation() == OrxGui::Vertical)181 if (this->orientation() == OrxGui::Vertical) 180 182 { 181 183 float height = borderTop(); … … 186 188 for (widget = this->_children.begin(); widget != this->_children.end(); ++widget) 187 189 { 188 (*widget)->setRelCoor2D(borderLeft(), height); 189 height += (*widget)->getSizeY2D(); 190 width = fmax(width, (*widget)->getSizeX2D()); 190 float radDir = (*widget)->getAbsDir2D() * 2 * M_PI / 360; 191 float realSizeX = fabsf((*widget)->getSizeX2D() * cosf(radDir)) + fabsf((*widget)->getSizeY2D() * sinf(radDir)); 192 float realSizeY = fabsf((*widget)->getSizeX2D() * sinf(radDir)) + fabsf((*widget)->getSizeY2D() * cosf(radDir)); 193 194 (*widget)->setRelCoor2D(borderLeft(), height + borderTop()); 195 height += realSizeY; 196 width = fmax(width, realSizeX); 191 197 } 192 198 … … 205 211 for (widget = this->_children.begin(); widget != this->_children.end(); ++widget) 206 212 { 213 float radDir = (*widget)->getAbsDir2D() * 2 * M_PI / 360; 214 //std::cout << "size X: " << (*widget)->getSizeX2D() << "size Y: " << (*widget)->getSizeY2D() << '\n'; 215 float realSizeX = fabsf((*widget)->getSizeX2D() * cosf(radDir)) + fabsf((*widget)->getSizeY2D() * sinf(radDir)); 216 float realSizeY = fabsf((*widget)->getSizeX2D() * sinf(radDir)) + fabsf((*widget)->getSizeY2D() * cosf(radDir)); 217 207 218 (*widget)->setRelCoor2D(width, borderTop()); 208 height = fmax(height, (*widget)->getSizeY2D());209 width += (*widget)->getSizeX2D();219 height = fmax(height, realSizeY); 220 width += realSizeX; 210 221 } 211 222 -
branches/playability/src/util/hud.cc
r10120 r10139 65 65 this->subscribeEvent(ES_ALL, SDLK_TAB); 66 66 67 this->shipValuesBox = new OrxGui::GLGuiBox(OrxGui::Vertical); 68 this->shipValuesBox->setBackgroundTexture("maps/gui_container_background.png"); 67 this->shipValuesBox = NULL; 69 68 } 70 69 … … 79 78 80 79 delete this->_radar; 80 delete this->shipValuesBox; 81 81 82 // delete what has to be deleted here 82 83 } … … 98 99 void Hud::setEnergyWidget(OrxGui::GLGuiWidget* widget) 99 100 { 101 if (this->shipValuesBox == NULL) 102 this->createShipValuesBox(); 100 103 // decopple old widget 101 104 if (this->energyWidget != NULL) … … 107 110 if (this->energyWidget != NULL) 108 111 { 109 this->energyWidget->show(); 110 this->energyWidget->shiftDir2D(270); 112 //this->energyWidget->shiftDir2D(270); 111 113 dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (this->energyWidget)->setDisplayedName("Electronics"); 112 114 this->shipValuesBox->pack(this->energyWidget); 115 this->energyWidget->show(); 113 116 /* this->energyWidget->frontMaterial().setDiffuseMap("hud_energy_bar.png"); 114 117 this->energyWidget->frontMaterial().setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);*/ … … 120 123 void Hud::setShiledWidget(OrxGui::GLGuiWidget* widget) 121 124 { 125 if (this->shipValuesBox == NULL) 126 this->createShipValuesBox(); 122 127 // decopple old widget 123 128 if (this->shieldWidget != NULL) … … 129 134 if (this->shieldWidget != NULL) 130 135 { 136 //this->shieldWidget->shiftDir2D(270); 137 this->shipValuesBox->pack(this->shieldWidget); 131 138 this->shieldWidget->show(); 132 this->shieldWidget->shiftDir2D(270);133 this->shipValuesBox->pack(this->shieldWidget);134 139 /* this->shieldWidget->frontMaterial().setDiffuseMap("hud_energy_bar.png"); 135 140 this->shieldWidget->frontMaterial().setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);*/ 136 141 } 142 else 143 printf("schild im hud nicht uebergeben!!!!!!!!!!!!!!!!!!!!!!!!!"); 137 144 138 145 this->updateResolution(); … … 141 148 void Hud::setArmorWidget(OrxGui::GLGuiWidget* widget) 142 149 { 150 if (this->shipValuesBox == NULL) 151 this->createShipValuesBox(); 152 143 153 // decopple old widget 144 154 if (this->armorWidget != NULL) … … 150 160 if (this->armorWidget != NULL) 151 161 { 162 //this->armorWidget->shiftDir2D(270); 163 this->shipValuesBox->pack(this->armorWidget); 152 164 this->armorWidget->show(); 153 this->armorWidget->shiftDir2D(270);154 //this->shipValuesBox->pack(this->armorWidget);155 165 /* this->armorWidget->frontMaterial().setDiffuseMap("hud_energy_bar.png"); 156 166 this->armorWidget->frontMaterial().setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);*/ … … 272 282 if (this->shipValuesBox != NULL) 273 283 { 274 this->shipValuesBox->setAbsCoor2D(0. 8 * this->resX, 0.85* this->resY);284 this->shipValuesBox->setAbsCoor2D(0.2 * this->resX, 0.4 * this->resY); 275 285 this->shipValuesBox->setWidgetSize(.4 * this->resX, 0.1 * this->resY); 276 286 } 287 else 288 createShipValuesBox(); 277 289 278 290 … … 309 321 // this->inputLine->select(); 310 322 } 311 312 313 } 314 315 323 } 324 325 void Hud::createShipValuesBox() 326 { 327 this->shipValuesBox = new OrxGui::GLGuiBox(OrxGui::Horizontal); 328 //this->shipValuesBox->setWidgetSize(1000,500); 329 //this->shipValuesBox->setBackgroundTexture("maps/gui_container_background.png"); 330 this->shipValuesBox->setBackgroundTexture(Texture()); 331 this->shipValuesBox->setBackgroundColor(Color(0,0,1,0.5)); 332 this->shipValuesBox->setVisibility(true); 333 } 334 335 -
branches/playability/src/util/hud.h
r10111 r10139 40 40 void setShiledWidget(OrxGui::GLGuiWidget* widget); 41 41 void setArmorWidget(OrxGui::GLGuiWidget* widget); 42 inline OrxGui::GLGuiWidget* getEnergyWidget() {return this->energyWidget;}; 43 inline OrxGui::GLGuiWidget* getShieldWidget() {return this->shieldWidget;}; 44 inline OrxGui::GLGuiWidget* getArmorWidget() {return this->armorWidget;}; 45 42 46 void setWeaponManager(WeaponManager* weaponMan, WeaponManager* weaponManSec = NULL); 43 47 … … 55 59 private: 56 60 void updateResolution(); 61 void createShipValuesBox(); 57 62 58 63 private: -
branches/playability/src/world_entities/elements/glgui_energywidgetvertical.cc
r10120 r10139 29 29 // this->setClassID(CL_PROTO_ID, "GLGuiEnergyWidget"); 30 30 31 32 33 this->_bar.setSize2D(100, 30);34 this->_name.setRelCoor2D(200,0);35 this-> _valueText.setRelCoor2D(22,0);36 31 //this->_bar.setSize2D(100, 30); 32 //this->_bar.setRelCoor2D(-10,0); 33 //this->_name.setRelCoor2D(20,0); 34 //this->_valueText.setRelCoor2D(,0); 35 this->shiftDir2D(270); 36 this->setOrientation(OrxGui::Horizontal); 37 37 this->pack(&this->_name); 38 38 this->pack(&this->_valueText); … … 44 44 45 45 this->setBackgroundTexture(Texture()); 46 this->setBackgroundColor(Color(.5,.5,.5,0 ));46 this->setBackgroundColor(Color(.5,.5,.5,0.5)); 47 47 48 48 //this->_name.setBackgroundTexture(Texture()); -
branches/playability/src/world_entities/space_ships/space_ship.cc
r10133 r10139 232 232 233 233 // widget handling 234 /* 234 235 this->electronicWidget = new OrxGui::GLGuiEnergyWidgetVertical(); 235 236 this->electronicWidget->setDisplayedName(std::string(this->getClassName()) + " Electronics:"); … … 249 250 State::getPlayer()->hud().setEnergyWidget(this->electronicWidget); 250 251 } 252 */ 253 this->electronicWidget = NULL; 254 this->shieldWidget = NULL; 251 255 252 256 //add events to the eventlist … … 392 396 this->secWeaponMan.showCrosshair(); 393 397 this->toList( OM_GROUP_01 ); 398 dynamic_cast <OrxGui::GLGuiEnergyWidgetVertical*> (State::getPlayer()->hud().getArmorWidget())->setDisplayedName("Armor"); 394 399 //dynamic_cast<Element2D*>(this->secWeaponMan.getFixedTarget())->setVisibility( true); 395 400 //this->attachCamera(); … … 1014 1019 void SpaceShip::updateElectronicWidget() 1015 1020 { 1016 this->electronicWidget->setMaximum(this->electronicMax); 1017 this->electronicWidget->setValue(this->electronicCur); 1018 if (this->hasPlayer()) 1019 this->electronicWidget->show(); 1021 if (this->electronicWidget != NULL) 1022 { //if it exists already: update it 1023 this->electronicWidget->setMaximum(this->electronicMax); 1024 this->electronicWidget->setValue(this->electronicCur); 1025 } 1026 else 1027 { //create the widget 1028 this->electronicWidget = new OrxGui::GLGuiEnergyWidgetVertical(); 1029 this->electronicWidget->setDisplayedName("Electronics:"); 1030 //this->electronicWidget->setSize2D(100,20); 1031 //this->electronicWidget->setAbsCoor2D(150,200); 1032 this->updateElectronicWidget(); 1033 if (this->hasPlayer()) 1034 State::getPlayer()->hud().setEnergyWidget(this->electronicWidget); 1035 } 1020 1036 } 1021 1037 1022 1038 void SpaceShip::updateShieldWidget() 1023 1039 { 1024 this->shieldWidget->setMaximum(this->shieldMax); 1025 this->shieldWidget->setValue(this->shieldCur); 1026 if (this->hasPlayer()) 1027 this->shieldWidget->show(); 1028 } 1040 if (this->shieldWidget != NULL) 1041 { 1042 this->shieldWidget->setMaximum(this->shieldMax); 1043 this->shieldWidget->setValue(this->shieldCur);; 1044 } 1045 else 1046 { 1047 this->shieldWidget = new OrxGui::GLGuiEnergyWidgetVertical(); 1048 this->shieldWidget->setDisplayedName("Shield:"); 1049 //his->shieldWidget->setSize2D(100,20); 1050 //this->shieldWidget->setAbsCoor2D(200,200); 1051 this->updateShieldWidget(); 1052 if (this->hasPlayer()) 1053 State::getPlayer()->hud().setShiledWidget(this->shieldWidget); 1054 } 1055 } -
branches/playability/src/world_entities/world_entity.cc
r10120 r10139 752 752 { 753 753 this->healthWidget = new OrxGui::GLGuiEnergyWidgetVertical(); 754 this->healthWidget->setDisplayedName(" Electronics");755 this->healthWidget->setSize2D(30,400);756 this->healthWidget->setAbsCoor2D(100,200);754 this->healthWidget->setDisplayedName("Health"); 755 //this->healthWidget->setSize2D(100,20); 756 //this->healthWidget->setAbsCoor2D(100,200); 757 757 758 758 this->updateHealthWidget();
Note: See TracChangeset
for help on using the changeset viewer.