Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10347 in orxonox.OLD for branches/playability/src/util/hud.cc


Ignore:
Timestamp:
Jan 24, 2007, 6:50:33 PM (18 years ago)
Author:
muellmic
Message:

hud scales now according to actionWidth and res

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/playability/src/util/hud.cc

    r10332 r10347  
    341341  this->notifier->setWidgetSize(0.25 * this->resX, 0.6 * this->resY);
    342342
    343   int overlayWidth = this->resX * (overlayPercentage)/(200);
    344   if (overlayWidth < 100)
    345     overlayWidth = 100;
     343  int overlayWidth = 0;
     344  if (overlayPercentage >= 20)
     345    overlayWidth = this->resX * (overlayPercentage)/(200);
     346  else
     347    overlayWidth = this->resX * 0.1;
     348  //if (overlayWidth < 100)
     349    //overlayWidth = 100;
    346350
    347351  this->rightRect->hide();
     
    385389    this->_radar->addEntityList(&State::getObjectManager()->getEntityList(OM_GROUP_01), Color(0, 0, 1));
    386390    this->_radar->setAbsCoor2D(0, 0.01 * this->resY);
    387     this->_radar->setWidgetSize(0.18 * this->resX, 0.2 * this->resY);
     391    this->_radar->setWidgetSize(overlayWidth, overlayWidth);
    388392    this->_radar->setRange(300);
    389393    this->_radar->show();
    390 
     394   
     395    int statWidgetsNumber = 0;
     396    float expectedArmorSizeX = 0;
     397    float expectedArmorSizeY = 0;
     398    float newSizeY = 0; float newSizeX = 0;
     399    float moduloWidth = 0;
     400
     401    if (this->armorWidget != NULL)
     402    {
     403      expectedArmorSizeX = 150;
     404      expectedArmorSizeY = 50;
     405      statWidgetsNumber++;
     406    }
     407
     408    if (this->shieldWidget != NULL)
     409      statWidgetsNumber++;
     410   
     411    if (this->energyWidget != NULL)
     412      statWidgetsNumber++;
     413
     414    if (expectedArmorSizeY * statWidgetsNumber > overlayWidth)
     415    {
     416      newSizeY = overlayWidth / float(statWidgetsNumber);
     417      newSizeX = expectedArmorSizeX;
     418      PRINTF(0)("Statwidgets resized\n");
     419    }
     420    else
     421    {
     422      newSizeY = expectedArmorSizeY;
     423      newSizeX = expectedArmorSizeX;
     424      moduloWidth = int(overlayWidth) % int(expectedArmorSizeY * statWidgetsNumber);
     425    }
     426
     427    float posY = overlayWidth + newSizeX;
     428
     429    if (this->armorWidget != NULL)
     430    {
     431      this->armorWidget->setSize2D(newSizeX, newSizeY);
     432      this->armorWidget->setRelCoor2D((statWidgetsNumber - 1) * newSizeY + 3 * moduloWidth / (statWidgetsNumber + 1),posY);
     433    }
     434    if (this->shieldWidget != NULL)
     435    {
     436      this->shieldWidget->setSize2D(newSizeX, newSizeY);
     437      this->shieldWidget->setRelCoor2D((statWidgetsNumber - 2) * newSizeY + 2 *moduloWidth / (statWidgetsNumber + 1),posY);
     438    }
     439    if (this->energyWidget != NULL)
     440    {
     441      this->energyWidget->setSize2D(newSizeX, newSizeY);
     442      this->energyWidget->setRelCoor2D(moduloWidth / (statWidgetsNumber + 1),posY);
     443    }
     444
     445    /*
    391446    if (this->armorWidget != NULL)
    392447      this->armorWidget->setRelCoor2D(100,0.2*this->resY + this->armorWidget->getSizeX2D());
     
    395450    if (this->energyWidget != NULL)
    396451      this->energyWidget->setRelCoor2D(20,0.2*this->resY + this->armorWidget->getSizeX2D());
     452    */
    397453    //this->shieldWidget->setRelCoor2D(0.1*this->resX + this->armorWidget->getSizeX2D(),0);
    398454    //this->energyWidget->setRelCoor2D(0.1*this->resX + this->armorWidget->getSizeX2D() + this->shieldWidget->getSizeX2D(),0);
     
    411467  std::list<OrxGui::GLGuiEnergyWidgetVertical*>::iterator weaponWidget;
    412468  Vector2D pos = Vector2D(overlayWidth, 0.4*this->resY);
     469  float largestWidgetSizeX = 0;
    413470  //PRINTF(0)("Cur Pos: %f,%f\n",pos.x,pos.y);
    414471  // out of reasons i can't get behind, this version is segfaulting when calling getSizeX2D or getSizeY2D. the other
     
    418475  {
    419476    float ySize = (*weaponWidget)->getSizeY2D();
     477    float xSize = (*weaponWidget)->getSizeX2D();
     478    if (xSize > largestWidgetSizeX)
     479      largestWidgetSizeX = xSize;
    420480    if (pos.x < ySize)
    421481    {
    422482      pos.x = overlayWidth;
    423       pos.y += (*weaponWidget)->getSizeX2D();
     483      pos.y += largestWidgetSizeX;
    424484    }
    425485    pos.x -= ySize;
     
    429489    //printf("update thing %s::%s\n", (*weaponWidget)->getClassCName(), (*weaponWidget)->getName());
    430490  }
    431 
    432   pos.y += 160;
    433   pos.x = 0; //overlayWidth + this->rightRect->getAbsCoor2D().x;
     491 
     492  weaponWidget = this->weaponsWidgetsSec.begin();
     493  float expectedWidgetSizeY = 0;
     494  if (weaponWidget != this->weaponsWidgetsSec.end())
     495  {
     496    expectedWidgetSizeY = (*weaponWidget)->getSizeY2D();
     497  }
     498  pos.y = resY - expectedWidgetSizeY * 0.6;
     499  pos.x = overlayWidth + this->rightRect->getAbsCoor2D().x;
     500
    434501  for (weaponWidget = this->weaponsWidgetsSec.begin(); weaponWidget != this->weaponsWidgetsSec.end(); weaponWidget++)
    435502  {
    436503    float ySize = (*weaponWidget)->getSizeY2D();
     504    float xSize = (*weaponWidget)->getSizeX2D();
     505    if (xSize > largestWidgetSizeX)
     506      largestWidgetSizeX = xSize;
    437507    if (pos.x < ySize)
    438508    {
    439509      pos.x = overlayWidth;
    440       pos.y += (*weaponWidget)->getSizeX2D();
     510      pos.y -= largestWidgetSizeX + expectedWidgetSizeY * 0.6;
    441511    }
    442512    pos.x -= ySize;
    443     PRINTF(0)("secweaponwidget y-size: %f/n", (*weaponWidget)->getSizeY2D());
     513    //PRINTF(0)("secweaponwidget y-size: %f/n", (*weaponWidget)->getSizeY2D());
    444514    (*weaponWidget)->setAbsCoor2D(pos.x + this->rightRect->getAbsCoor2D().x, pos.y);
    445515    (*weaponWidget)->show();
Note: See TracChangeset for help on using the changeset viewer.