Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
Jan 17, 2007, 7:23:47 PM (18 years ago)
Author:
muellmic
Message:

fixed bug, that set false Coor2Ds for the weapon-widgets when changing the weapon configuration. lots of thanks 2 marc!

File:
1 edited

Legend:

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

    r10270 r10278  
    197197void Hud::setWeaponManager(WeaponManager* weaponMan, WeaponManager* weaponManSec)
    198198{
     199  //clearWeaponManager();
     200
     201  //Hide all widgets
    199202  if (this->weaponManager != NULL)
    200203  {
     
    205208      {
    206209        weapon->getEnergyWidget()->hide();
    207         this->weaponsWidgetsPrim.remove(dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (weapon->getEnergyWidget()));
     210        //this->weaponsWidgetsPrim.remove(dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (weapon->getEnergyWidget()));
    208211      }
    209212    }
     
    218221      {
    219222        weapon->getEnergyWidget()->hide();
    220         this->weaponsWidgetsSec.remove(dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (weapon->getEnergyWidget()));
     223        //this->weaponsWidgetsSec.remove(dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (weapon->getEnergyWidget()));
    221224      }
    222225    }
     
    224227
    225228  this->weaponManager = weaponMan;
    226   this->weaponManagerSecondary = weaponManSec;
     229  this->weaponManagerSecondary = weaponManSec; 
    227230
    228231  this->updateWeaponManager();
     
    230233}
    231234
     235/*
     236void 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
    232270void Hud::updateWeaponManager()
    233271{
    234272  // hide all the Widgets
     273 
    235274  std::list<OrxGui::GLGuiEnergyWidgetVertical*>::iterator weaponWidget;
    236275  for (weaponWidget = this->weaponsWidgetsPrim.begin(); weaponWidget != this->weaponsWidgetsPrim.end(); weaponWidget++)
     
    245284  }
    246285  this->weaponsWidgetsSec.clear();
     286 
    247287
    248288  // add all that we need again.
     289
    249290  if (this->weaponManager != NULL)
    250291    for (unsigned int i = 0; i < this->weaponManager->getSlotCount(); i++)
     
    365406
    366407  std::list<OrxGui::GLGuiEnergyWidgetVertical*>::iterator weaponWidget;
    367   Vector2D pos(overlayWidth, 0.5*this->resY);
    368 
     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);
    369410  // out of reasons i can't get behind, this version is segfaulting when calling getSizeX2D or getSizeY2D. the other
    370411  // element2D- related function works tough.. :s
     
    374415    if (pos.x < overlayWidth*0.2)
    375416    {
    376       pos.x = overlayWidth;
     417      pos.x = overlayWidth + this->rightRect->getAbsCoor2D().x;
    377418      pos.y += (*weaponWidget)->getSizeX2D();
    378419    }
     
    385426
    386427  pos.y += 160;
    387   pos.x = overlayWidth;
     428  pos.x = overlayWidth + this->rightRect->getAbsCoor2D().x;
    388429  for (weaponWidget = this->weaponsWidgetsSec.begin(); weaponWidget != this->weaponsWidgetsSec.end(); weaponWidget++)
    389430  {
    390431    if (pos.x < overlayWidth*0.2)
    391432    {
    392       pos.x = overlayWidth;
     433      pos.x = overlayWidth + this->rightRect->getAbsCoor2D().x;
    393434      pos.y += (*weaponWidget)->getSizeX2D();
    394435    }
Note: See TracChangeset for help on using the changeset viewer.