Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10368 in orxonox.OLD for trunk/src/util


Ignore:
Timestamp:
Jan 25, 2007, 2:18:07 PM (17 years ago)
Author:
patrick
Message:

merged the branche playability into the trunk

Location:
trunk
Files:
9 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk

    • Property svn:ignore
      •  

        old new  
        1010autom4te.cache
        1111aclocal.m4
         12tags
         13test.bmp
         14config.sub
         15config.guess
         16OrxonoxPlayability.kdevses
         17OrxonoxPlayability.kdevelop.pcs
  • trunk/src/util/Makefile.am

    r9869 r10368  
    2626                        animation/animation_player.cc \
    2727                        \
    28                         track/pilot_node.cc
    29 
    30 #                       track/track_manager.cc \
     28                        track/pilot_node.cc \
     29                        track/track.cc \
     30                        track/track_manager.cc \
    3131                        track/track_node.cc
    3232
     
    5252                        animation/t_animation.h \
    5353                        \
    54                         track/pilot_node.h
     54                        track/pilot_node.h \
     55                        track/track.h \
     56                        track/track_manager.h \
     57                        track/track_node.h
    5558
    56 #                       track/track_manager.h \
    57                         track/track_node.h
  • trunk/src/util/hud.cc

    r9869 r10368  
    2323#include "world_entities/weapons/weapon_manager.h"
    2424#include "glgui_widget.h"
     25#include "glgui_box.h"
     26#include "glgui_bar.h"
     27#include "elements/glgui_energywidgetvertical.h"
    2528
    2629#include "glgui_inputline.h"
    2730#include "specials/glgui_notifier.h"
    2831#include "elements/glgui_radar.h"
     32#include "world_entities/space_ships/space_ship.h"
    2933
    3034
     
    4549  //this->setSize2D(
    4650  this->weaponManager = NULL;
     51  this->weaponManagerSecondary = NULL;
    4752  this->energyWidget = NULL;
    4853  this->shieldWidget = NULL;
    4954  this->armorWidget = NULL;
     55  //this->leftRect = NULL;
     56  //this->rightRect = NULL;
    5057  this->resX = 1;
    5158  this->resY = 1;
     59
     60  this->overlayPercentage = 40;
     61  this->overlayActive = false;
     62  this->rightRect = new OrxGui::GLGuiImage();
     63  this->leftRect = new OrxGui::GLGuiImage();
    5264
    5365  this->inputLine = new OrxGui::GLGuiInputLine();
     
    5870
    5971  this->_radar = new OrxGui::GLGuiRadar();
     72  this->radarCenterNode = NULL;
    6073
    6174  this->subscribeEvent(ES_ALL, EV_VIDEO_RESIZE);
    6275  this->subscribeEvent(ES_ALL, SDLK_TAB);
    6376
    64 
     77  //this->shipValuesBox = NULL;
    6578}
    6679
     
    7588
    7689  delete this->_radar;
     90  delete this->rightRect;
     91  delete this->leftRect;
     92  //if (this->shipValuesBox != NULL)
     93    //delete this->shipValuesBox;
     94
    7795  // delete what has to be deleted here
    7896}
     
    94112void Hud::setEnergyWidget(OrxGui::GLGuiWidget* widget)
    95113{
     114  //if (this->shipValuesBox == NULL)
     115    //this->createShipValuesBox();
     116
    96117  // decopple old widget
    97118  if (this->energyWidget != NULL)
     
    103124  if (this->energyWidget != NULL)
    104125  {
     126    //this->energyWidget->shiftDir2D(270);
     127    //dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (this->energyWidget)->setDisplayedName("Electronics");
     128    //this->shipValuesBox->pack(this->energyWidget);
     129    //dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (this->energyWidget)->setStandardSettings();
     130    this->energyWidget->setParent2D(this->leftRect);
    105131    this->energyWidget->show();
    106     this->energyWidget->setBackgroundTexture( "hud_energy_background.png");
    107132    /*    this->energyWidget->frontMaterial().setDiffuseMap("hud_energy_bar.png");
    108133        this->energyWidget->frontMaterial().setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);*/
     
    113138
    114139void Hud::setShiledWidget(OrxGui::GLGuiWidget* widget)
    115 {}
     140{
     141  /*
     142  if (this->shipValuesBox == NULL)
     143    this->createShipValuesBox();
     144  */
     145
     146  // decopple old widget
     147  if (this->shieldWidget != NULL)
     148  {
     149    this->shieldWidget->hide();
     150  }
     151
     152  this->shieldWidget = widget;
     153  if (this->shieldWidget != NULL)
     154  {
     155    //this->shieldWidget->shiftDir2D(270);
     156    //this->shipValuesBox->pack(this->shieldWidget);
     157    //dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (this->shieldWidget)->setStandardSettings();
     158    this->shieldWidget->setParent2D(this->leftRect);
     159    this->shieldWidget->show();
     160    /*    this->shieldWidget->frontMaterial().setDiffuseMap("hud_energy_bar.png");
     161        this->shieldWidget->frontMaterial().setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);*/
     162  }
     163  else
     164    printf("schild im hud nicht uebergeben!!!!!!!!!!!!!!!!!!!!!!!!!");
     165
     166  this->updateResolution();
     167}
    116168
    117169void Hud::setArmorWidget(OrxGui::GLGuiWidget* widget)
    118 {}
    119 
    120 void Hud::setWeaponManager(WeaponManager* weaponMan)
    121 {
     170{
     171  /*
     172  if (this->shipValuesBox == NULL)
     173    this->createShipValuesBox();
     174  */
     175
     176// decopple old widget
     177  if (this->armorWidget != NULL)
     178  {
     179    this->armorWidget->hide();
     180  }
     181
     182  this->armorWidget = widget;
     183  if (this->armorWidget != NULL)
     184  {
     185    //this->armorWidget->shiftDir2D(270);
     186    //this->shipValuesBox->pack(this->armorWidget);
     187    //dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (this->armorWidget)->setStandardSettings();
     188    this->armorWidget->setParent2D(this->leftRect);
     189    this->armorWidget->show();
     190    /*    this->armorWidget->frontMaterial().setDiffuseMap("hud_energy_bar.png");
     191        this->armorWidget->frontMaterial().setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);*/
     192  }
     193
     194  this->updateResolution();
     195}
     196
     197void Hud::setWeaponManager(WeaponManager* weaponMan, WeaponManager* weaponManSec)
     198{
     199  //clearWeaponManager();
     200
     201  //Hide all widgets
    122202  if (this->weaponManager != NULL)
    123203  {
     
    128208      {
    129209        weapon->getEnergyWidget()->hide();
    130         this->weaponsWidgets.remove(weapon->getEnergyWidget());
     210        //this->weaponsWidgetsPrim.remove(dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (weapon->getEnergyWidget()));
    131211      }
    132212    }
    133213  }
    134214
     215  if (this->weaponManagerSecondary != NULL)
     216  {
     217    for (unsigned int i = 0; i < this->weaponManagerSecondary->getSlotCount(); i++)
     218    {
     219      Weapon* weapon = this->weaponManagerSecondary->getWeapon(i);
     220      if (weapon != NULL)
     221      {
     222        weapon->getEnergyWidget()->hide();
     223        //this->weaponsWidgetsSec.remove(dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (weapon->getEnergyWidget()));
     224      }
     225    }
     226  }
     227
    135228  this->weaponManager = weaponMan;
     229  this->weaponManagerSecondary = weaponManSec;
    136230
    137231  this->updateWeaponManager();
     
    139233}
    140234
     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
    141270void Hud::updateWeaponManager()
    142271{
    143272  // hide all the Widgets
    144   std::list<OrxGui::GLGuiWidget*>::iterator weaponWidget;
    145   for (weaponWidget = this->weaponsWidgets.begin(); weaponWidget != this->weaponsWidgets.end(); weaponWidget++)
     273 
     274  std::list<OrxGui::GLGuiEnergyWidgetVertical*>::iterator weaponWidget;
     275  for (weaponWidget = this->weaponsWidgetsPrim.begin(); weaponWidget != this->weaponsWidgetsPrim.end(); weaponWidget++)
    146276  {
    147277    (*weaponWidget)->hide();
    148278  }
    149   this->weaponsWidgets.clear();
     279  this->weaponsWidgetsPrim.clear();
     280
     281  for (weaponWidget = this->weaponsWidgetsSec.begin(); weaponWidget != this->weaponsWidgetsSec.end(); weaponWidget++)
     282  {
     283    (*weaponWidget)->hide();
     284  }
     285  this->weaponsWidgetsSec.clear();
     286 
    150287
    151288  // add all that we need again.
     289
    152290  if (this->weaponManager != NULL)
    153291    for (unsigned int i = 0; i < this->weaponManager->getSlotCount(); i++)
     
    157295      {
    158296        //PRINTF(0)("WEAPON %s::%s in Slots\n", weapon->getClassCName(), weapon->getName());
     297        weapon->getEnergyWidget()->setParent2D(this->rightRect);
    159298        weapon->getEnergyWidget()->show();
    160299        weapon->getEnergyWidget()->setBackgroundColor(Color(.8,.2,.11, 0.1));
    161300        weapon->getEnergyWidget()->setFrontColor(Color( .2,.5,.7,.6));
    162         //      weapon->getEnergyWidget()->frontMaterial().setTransparency(.6);
    163         this->weaponsWidgets.push_back(weapon->getEnergyWidget());
     301        weapon->getEnergyWidget()->setWidgetSize(120,30);
     302        //weapon->getEnergyWidget()->frontMaterial().setTransparency(.6);
     303        this->weaponsWidgetsPrim.push_back(dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (weapon->getEnergyWidget()));
    164304      }
    165305    }
     306
     307  if (this->weaponManagerSecondary != NULL)
     308    for (unsigned int i = 0; i < this->weaponManagerSecondary->getSlotCount(); i++)
     309    {
     310      Weapon* weapon = this->weaponManagerSecondary->getWeapon(i);
     311      if (weapon != NULL)
     312      {
     313        //PRINTF(0)("WEAPON %s::%s in Slots\n", weapon->getClassCName(), weapon->getName());
     314        weapon->getEnergyWidget()->setParent2D(this->rightRect);
     315        weapon->getEnergyWidget()->show();
     316        weapon->getEnergyWidget()->setBackgroundColor(Color(.8,.2,.11, 0.1));
     317        weapon->getEnergyWidget()->setFrontColor(Color( .2,.5,.7,.6));
     318        weapon->getEnergyWidget()->setWidgetSize(150,50);
     319        //weapon->getEnergyWidget()->frontMaterial().setTransparency(.6);
     320        this->weaponsWidgetsSec.push_back(dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (weapon->getEnergyWidget()));
     321      }
     322    }
     323
    166324  this->updateResolution();
     325
    167326}
    168327
     
    182341  this->notifier->setWidgetSize(0.25 * this->resX, 0.6 * this->resY);
    183342
     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;
     350
     351  this->rightRect->hide();
     352  this->leftRect->hide();
     353
     354  this->leftRect->setParent2D(this);
     355  this->leftRect->setWidgetSize(float(overlayWidth), float(this->resY));
     356  this->leftRect->setAbsCoor2D(0,0);
     357  this->leftRect->setBackgroundTexture(Texture());
     358  this->leftRect->setBackgroundColor(Color(0,0,0.7,0.2));
     359  this->leftRect->setForegroundTexture(Texture());
     360  this->leftRect->setForegroundColor(Color(0,0,0,0));
     361
     362  this->rightRect->setParent2D(this);
     363  this->rightRect->setWidgetSize(float(overlayWidth), float(this->resY));
     364  this->rightRect->setAbsCoor2D(this->resX - overlayWidth,0);
     365  this->rightRect->setBackgroundTexture(Texture());
     366  this->rightRect->setBackgroundColor(Color(0,0,0.7,0.2));
     367  this->rightRect->setForegroundTexture(Texture());
     368  this->rightRect->setForegroundColor(Color(0,0,0,0));
     369
     370
     371  if (this->overlayActive == true)
     372  {
     373    this->rightRect->show();
     374    this->leftRect->show();
     375  }
     376
    184377
    185378  if (State::getPlayer() && State::getPlayer()->getPlayable() && State::getObjectManager())
    186379  {
    187380    PRINTF(4)("UPDATING RADAR\n");
    188     this->_radar->setCenterNode(State::getPlayer()->getPlayable());
    189     this->_radar->addEntityList(&State::getObjectManager()->getEntityList((OM_LIST)(State::getPlayer()->getPlayable()->getOMListNumber()+1)), Color(.4, .4, 1.0));
    190     this->_radar->addEntityList(&State::getObjectManager()->getEntityList(OM_GROUP_02), Color(1.0, .2, .2));
    191     this->_radar->setAbsCoor2D(0.8 * this->resX, 0.01 * this->resY);
    192     this->_radar->setWidgetSize(0.2 * this->resX, 0.2 * this->resY);
     381    this->_radar->setParent2D(this->leftRect);
     382    if (radarCenterNode == NULL)
     383      this->_radar->setCenterNode(State::getPlayer()->getPlayable());
     384    else
     385      this->_radar->setCenterNode(this->radarCenterNode);
     386
     387    //this->_radar->addEntityList(&State::getObjectManager()->getEntityList((OM_LIST)(State::getPlayer()->getPlayable()->getOMListNumber()+1)), Color(.4, .4, 1.0));
     388    this->_radar->addEntityList(&State::getObjectManager()->getEntityList(OM_GROUP_00), Color(1, 0, 0));
     389    this->_radar->addEntityList(&State::getObjectManager()->getEntityList(OM_GROUP_01), Color(0, 0, 1));
     390    this->_radar->setAbsCoor2D(0, 0.01 * this->resY);
     391    this->_radar->setWidgetSize(overlayWidth, overlayWidth);
    193392    this->_radar->setRange(300);
    194393    this->_radar->show();
    195   }
    196 
    197 
    198   if (this->energyWidget != NULL)
    199   {
    200     this->energyWidget->setAbsCoor2D(0.0 * this->resX, 0.85 * this->resY);
    201     this->energyWidget->setWidgetSize(.25 * this->resX, 0.1 * this->resY);
    202   }
    203 
    204 
    205   std::list<OrxGui::GLGuiWidget*>::iterator weaponWidget;
    206   Vector2D pos(0.3, .9);
    207   for (weaponWidget = this->weaponsWidgets.begin(); weaponWidget != this->weaponsWidgets.end(); weaponWidget++, pos.x+=.2)
    208   {
    209     if (pos.x > .8)
    210     {
    211       pos.x = 0.3;
    212       pos.y -= .1;
    213 
    214     }
    215     (*weaponWidget)->setAbsCoor2D(pos.x*this->resX, pos.y*this->resY);
    216     (*weaponWidget)->setWidgetSize(.02*this->resX, .1 *this->resY);
     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    /*
     446    if (this->armorWidget != NULL)
     447      this->armorWidget->setRelCoor2D(100,0.2*this->resY + this->armorWidget->getSizeX2D());
     448    if (this->shieldWidget != NULL)
     449      this->shieldWidget->setRelCoor2D(60,0.2*this->resY + this->armorWidget->getSizeX2D());
     450    if (this->energyWidget != NULL)
     451      this->energyWidget->setRelCoor2D(20,0.2*this->resY + this->armorWidget->getSizeX2D());
     452    */
     453    //this->shieldWidget->setRelCoor2D(0.1*this->resX + this->armorWidget->getSizeX2D(),0);
     454    //this->energyWidget->setRelCoor2D(0.1*this->resX + this->armorWidget->getSizeX2D() + this->shieldWidget->getSizeX2D(),0);
     455  }
     456
     457  /*
     458  if (this->shipValuesBox != NULL)
     459  {
     460    this->shipValuesBox->setAbsCoor2D(0.2 * this->resX, 0.4 * this->resY);
     461    this->shipValuesBox->setWidgetSize(.4 * this->resX, 0.1 * this->resY);
     462  }
     463  else
     464    createShipValuesBox();
     465  */
     466
     467  std::list<OrxGui::GLGuiEnergyWidgetVertical*>::iterator weaponWidget;
     468  Vector2D pos = Vector2D(overlayWidth, 0.4*this->resY);
     469  float largestWidgetSizeX = 0;
     470  //PRINTF(0)("Cur Pos: %f,%f\n",pos.x,pos.y);
     471  // out of reasons i can't get behind, this version is segfaulting when calling getSizeX2D or getSizeY2D. the other
     472  // element2D- related function works tough.. :s
     473
     474  for (weaponWidget = this->weaponsWidgetsPrim.begin(); weaponWidget != this->weaponsWidgetsPrim.end(); weaponWidget++)
     475  {
     476    float ySize = (*weaponWidget)->getSizeY2D();
     477    float xSize = (*weaponWidget)->getSizeX2D();
     478    if (xSize > largestWidgetSizeX)
     479      largestWidgetSizeX = xSize;
     480    if (pos.x < ySize)
     481    {
     482      pos.x = overlayWidth;
     483      pos.y += largestWidgetSizeX;
     484    }
     485    pos.x -= ySize;
     486    (*weaponWidget)->setAbsCoor2D(pos.x + this->rightRect->getAbsCoor2D().x, pos.y);
     487    //(*weaponWidget)->setAbsCoor2D(0,100);
    217488    (*weaponWidget)->show();
    218489    //printf("update thing %s::%s\n", (*weaponWidget)->getClassCName(), (*weaponWidget)->getName());
    219490  }
     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
     501  for (weaponWidget = this->weaponsWidgetsSec.begin(); weaponWidget != this->weaponsWidgetsSec.end(); weaponWidget++)
     502  {
     503    float ySize = (*weaponWidget)->getSizeY2D();
     504    float xSize = (*weaponWidget)->getSizeX2D();
     505    if (xSize > largestWidgetSizeX)
     506      largestWidgetSizeX = xSize;
     507    if (pos.x < ySize)
     508    {
     509      pos.x = overlayWidth;
     510      pos.y -= largestWidgetSizeX + expectedWidgetSizeY * 0.6;
     511    }
     512    pos.x -= ySize;
     513    //PRINTF(0)("secweaponwidget y-size: %f/n", (*weaponWidget)->getSizeY2D());
     514    (*weaponWidget)->setAbsCoor2D(pos.x + this->rightRect->getAbsCoor2D().x, pos.y);
     515    (*weaponWidget)->show();
     516    //printf("update thing %s::%s\n", (*weaponWidget)->getClassCName(), (*weaponWidget)->getName());
     517  }
     518
    220519}
    221520
     
    235534  //  this->inputLine->select();
    236535  }
    237 
    238 
    239 }
    240 
    241 
     536}
     537
     538/*
     539void Hud::createShipValuesBox()
     540{
     541  this->shipValuesBox = new OrxGui::GLGuiBox(OrxGui::Vertical);
     542  //this->shipValuesBox->setWidgetSize(1000,500);
     543  //this->shipValuesBox->setBackgroundTexture("maps/gui_container_background.png");
     544  this->shipValuesBox->setBackgroundTexture(Texture());
     545  this->shipValuesBox->setBackgroundColor(Color(0,0,1,0.5));
     546  this->shipValuesBox->setVisibility(true);
     547}
     548*/
     549
     550
  • trunk/src/util/hud.h

    r9869 r10368  
    99#include "element_2d.h"
    1010#include "event_listener.h"
     11#include "glgui_box.h"
     12#include "elements/glgui_energywidgetvertical.h"
    1113
    1214
     
    3941  void setShiledWidget(OrxGui::GLGuiWidget* widget);
    4042  void setArmorWidget(OrxGui::GLGuiWidget* widget);
    41   void setWeaponManager(WeaponManager* weaponMan);
     43  inline OrxGui::GLGuiWidget* getEnergyWidget() {return this->energyWidget;};
     44  inline OrxGui::GLGuiWidget* getShieldWidget() {return this->shieldWidget;};
     45  inline OrxGui::GLGuiWidget* getArmorWidget() {return this->armorWidget;};
     46
     47  void setWeaponManager(WeaponManager* weaponMan, WeaponManager* weaponManSec = NULL);
     48  inline void setRadarCenterNode(PNode* node) {this->radarCenterNode = node;};
    4249
    4350  void addWeaponWidget(OrxGui::GLGuiWidget* widget);
     
    4754
    4855  void updateWeaponManager();
     56  //void clearWeaponManager();
     57
     58  inline void setOverlayPercentage(int perc)
     59  {
     60    if (perc > 100) perc = 100;
     61    else if (perc < 0) perc = 0;
     62
     63    this->overlayPercentage = perc;
     64    updateResolution();
     65  };
     66
     67  inline void setOverlayActive(bool b)
     68  {
     69    overlayActive = b;
     70    updateResolution();
     71  };
    4972
    5073  void draw() const;
     
    5477  private:
    5578    void updateResolution();
     79    //void createShipValuesBox();
    5680
    5781private:
    5882  unsigned int             resX;
    5983  unsigned int             resY;
     84
     85  float                    travelZoneWidth; //the percentage of the screen, the player has got for his movements. should always be a value between 0 and 1;
    6086
    6187  OrxGui::GLGuiWidget*     energyWidget;
     
    6692  OrxGui::GLGuiInputLine*  inputLine;
    6793  OrxGui::GLGuiRadar*      _radar;
     94  PNode*                   radarCenterNode;
     95
     96  OrxGui::GLGuiWidget*     rightRect;
     97  OrxGui::GLGuiWidget*     leftRect;
     98  bool                     overlayActive;
     99  int                      overlayPercentage; //the percentage of the screen, the player has got for his movements. should always be a value between 0 and 1;
    68100
    69101  WeaponManager*           weaponManager;
     102  WeaponManager*           weaponManagerSecondary;
    70103
    71   std::list<OrxGui::GLGuiWidget*> weaponsWidgets; //!< WeaponWidgets will be displayed one after another
     104  std::list<OrxGui::GLGuiEnergyWidgetVertical*> weaponsWidgetsPrim; //!< WeaponWidgets will be displayed one after another
     105  std::list<OrxGui::GLGuiEnergyWidgetVertical*> weaponsWidgetsSec;
    72106};
    73107
  • trunk/src/util/state.h

    r8408 r10368  
    109109  static inline int getMenuID() { return State::menuID;}
    110110
     111  ////////////////////////
     112  /// Scroller-Control ///
     113  ////////////////////////
     114  /** sets the scroller-travelnode (center of the screen) */
     115  static void setTravelNode(PNode* travelNode) {State::travelNode = travelNode;}
     116  /** @returns the scroller-travelnode (center of the screen) */
     117  static PNode* getTravelNode() { return State::travelNode; }
    111118
    112119
     
    123130  static GameRules*             gameRules;          //!< A reference to the GameRules
    124131  static Player*                player;             //!< A reference to the Player
     132  static PNode*                 travelNode;         //!< A reference to the scroller-travelnode
    125133
    126134  static SkyBox*                skyBox;            //!< The SkyBox used in the current world.
  • trunk/src/util/track/track_manager.cc

    r10320 r10368  
    2626#include "t_animation.h"
    2727
     28#include <string.h>
     29
    2830
    2931#include "parser/tinyxml/tinyxml.h"
     
    3234#include <stdarg.h>
    3335
     36ObjectListDefinition(TrackElement);
    3437
    3538
     
    3942TrackElement::TrackElement()
    4043{
    41   this->setClassID(CL_TRACK_ELEMENT, "TrackElement");
     44  this->registerObject(this, TrackElement::_objectList);
     45
    4246
    4347  this->isFresh = true;
     
    126130{
    127131  // return if Found.
    128   if (this->getName() && !strcmp(this->getName(), trackName))
    129     return this;
     132//   if (this->getName() && !strcmp(this->getName(), trackName))
     133//     return this;
    130134  // search all children
    131135  if (this->childCount > 0)
     
    217221void TrackElement::debug() const
    218222{
    219   PRINT(0)("--== TrackElement:%i ==--", this->ID);
    220   if(this->getName())
    221     PRINT(0)("--++Name: %s++--", this->getName());
    222   if(this->isFresh)
    223     PRINT(0)("  -- has not jet eddited in any way --\n");
    224   PRINT(0)("\n   TimeTable: startingTime=%f; endTime=%f; duration=%f; jumpTime=%f\n", this->startingTime, this->endTime, this->duration, this->jumpTime);
    225   PRINT(0)("   consists of %d Points\n", this->nodeCount);
    226   if (this->childCount == 0)
    227     PRINT(0)("   has no child\n");
    228   else if (this->childCount == 1)
    229     PRINT(0)("   has 1 child: =%d=\n", this->getChild(0)->ID);
    230   else if (this->childCount > 1)
    231     {
    232       PRINT(0)("   has %d children: ", this->childCount);
    233       //TrackElement* enumElem = this->children->enumerate();
    234       tIterator<TrackElement>* iterator = this->children->getIterator();
    235       TrackElement* enumElem = iterator->firstElement();
    236       while (enumElem)
    237         {
    238           PRINT(0)("=%d= ", enumElem->ID);
    239           enumElem = iterator->nextElement();
    240         }
    241       delete iterator;
    242       PRINT(0)("\n");
    243     }
    244 
    245   if(this->isHotPoint)
    246     PRINT(0)("   is a special Point:\n");
    247   if(this->isSavePoint)
    248     PRINT(0)("    is a SavePoint\n");
    249   if(this->isFork)
    250     {
    251       PRINT(0)("    is A Fork with with %d children.\n", this->childCount);
    252     }
    253   if(this->isJoined)
    254     PRINT(0)("   is Joined at the End\n");
    255 
    256   if(!this->backLoopCheck()) /* this should not happen */
    257     PRINT(2)(" THERE IS A BACKLOOP TO THIS ELEMENT\n");
     223//   PRINT(0)("--== TrackElement:%i ==--", this->ID);
     224//   if(this->getName())
     225//     PRINT(0)("--++Name: %s++--", this->getName());
     226//   if(this->isFresh)
     227//     PRINT(0)("  -- has not jet eddited in any way --\n");
     228//   PRINT(0)("\n   TimeTable: startingTime=%f; endTime=%f; duration=%f; jumpTime=%f\n", this->startingTime, this->endTime, this->duration, this->jumpTime);
     229//   PRINT(0)("   consists of %d Points\n", this->nodeCount);
     230//   if (this->childCount == 0)
     231//     PRINT(0)("   has no child\n");
     232//   else if (this->childCount == 1)
     233//     PRINT(0)("   has 1 child: =%d=\n", this->getChild(0)->ID);
     234//   else if (this->childCount > 1)
     235//     {
     236//       PRINT(0)("   has %d children: ", this->childCount);
     237//       //TrackElement* enumElem = this->children->enumerate();
     238//       tIterator<TrackElement>* iterator = this->children->getIterator();
     239//       TrackElement* enumElem = iterator->firstElement();
     240//       while (enumElem)
     241//         {
     242//           PRINT(0)("=%d= ", enumElem->ID);
     243//           enumElem = iterator->nextElement();
     244//         }
     245//       delete iterator;
     246//       PRINT(0)("\n");
     247//     }
     248//
     249//   if(this->isHotPoint)
     250//     PRINT(0)("   is a special Point:\n");
     251//   if(this->isSavePoint)
     252//     PRINT(0)("    is a SavePoint\n");
     253//   if(this->isFork)
     254//     {
     255//       PRINT(0)("    is A Fork with with %d children.\n", this->childCount);
     256//     }
     257//   if(this->isJoined)
     258//     PRINT(0)("   is Joined at the End\n");
     259//
     260//   if(!this->backLoopCheck()) /* this should not happen */
     261//     PRINT(2)(" THERE IS A BACKLOOP TO THIS ELEMENT\n");
    258262}
    259263
     
    358362TrackManager::TrackManager()
    359363{
    360   this->setClassID(CL_TRACK_MANAGER, "TrackManager");
    361   this->setName("TrackManager");
    362 
    363364  TrackManager::singletonRef = this; // do this because otherwise the TrackNode cannot get The instance of the TrackManager
    364365
     
    395396void TrackManager::loadParams(const TiXmlElement* root)
    396397{
    397   double x, y, z, d;
    398 
    399   LOAD_PARAM_START_CYCLE(root, element);
    400   {
    401 
    402     LoadParam_CYCLE(element, "WorkOn", this, TrackManager, workOnS)
    403         .describe("Selects a TrackElement (by name) to work on");
    404 
    405     LoadParam_CYCLE(element, "Point", this, TrackManager, addPoint)
    406         .describe("Adds a new Point to the currently selected TrackElement");
    407 
    408     LoadParam_CYCLE(element, "Duration", this, TrackManager, setDuration)
    409         .describe("Sets the Duration of the currently selected TrackElement");
    410 
    411     LoadParam_CYCLE(element, "HotPoint", this, TrackManager, addHotPoint)
    412         .describe("Sets a new Point that acts as a hot point. meaning, the curve will flow through this Point");
    413 
    414     LoadParam_CYCLE(element, "SavePoint", this, TrackManager, setSavePointS)
    415         .describe("Sets the current selected Point to a Savepoint, meaning that the curve will be ended and a new one starts, and that one starts again from this point on");
    416 
    417     LoadParam_CYCLE(element, "Fork", this, TrackManager, forkS)
    418         .describe("Forks the Path into multiple forked Path names seperated by ','");
    419 
    420     LoadParam_CYCLE(element, "Join", this, TrackManager, joinS)
    421         .describe("Joins multiple joining Path names seperated by ','");
     398//   double x, y, z, d;
     399//
     400//   LOAD_PARAM_START_CYCLE(root, element);
     401//   {
     402//
     403//     LoadParam_CYCLE(element, "WorkOn", this, TrackManager, workOnS)
     404//         .describe("Selects a TrackElement (by name) to work on");
     405//
     406//     LoadParam_CYCLE(element, "Point", this, TrackManager, addPoint)
     407//         .describe("Adds a new Point to the currently selected TrackElement");
     408//
     409//     LoadParam_CYCLE(element, "Duration", this, TrackManager, setDuration)
     410//         .describe("Sets the Duration of the currently selected TrackElement");
     411//
     412//     LoadParam_CYCLE(element, "HotPoint", this, TrackManager, addHotPoint)
     413//         .describe("Sets a new Point that acts as a hot point. meaning, the curve will flow through this Point");
     414//
     415//     LoadParam_CYCLE(element, "SavePoint", this, TrackManager, setSavePointS)
     416//         .describe("Sets the current selected Point to a Savepoint, meaning that the curve will be ended and a new one starts, and that one starts again from this point on");
     417//
     418//     LoadParam_CYCLE(element, "Fork", this, TrackManager, forkS)
     419//         .describe("Forks the Path into multiple forked Path names seperated by ','");
     420//
     421//     LoadParam_CYCLE(element, "Join", this, TrackManager, joinS)
     422//         .describe("Joins multiple joining Path names seperated by ','");
    422423
    423424      /*
     
    445446        }
    446447      */
    447   }
    448   LOAD_PARAM_END_CYCLE(element);
     448
     449//   }
     450//   LOAD_PARAM_END_CYCLE(element);
    449451}
    450452
     
    477479void TrackManager::initChildren(unsigned int childCount, TrackElement* trackElem)
    478480{
    479   if (!trackElem)
    480     trackElem = this->currentTrackElem;
    481 
    482   trackElem->childCount = childCount;
    483   trackElem->mainJoin = true;  // this tells join, that this one is the Main Join, if it tries to join multiple Tracks
    484   trackElem->children =  new tList<TrackElement>();
    485   for (int i = 0; i < childCount; i++)
    486     {
    487       // create a new Element
    488       TrackElement* newElem = new TrackElement();
    489       // setting up the new ID
    490       newElem->ID = ++trackElemCount;
    491       // setting up the Time
    492       newElem->startingTime = trackElem->endTime + trackElem->jumpTime;
    493       // adds the conection Point
    494       this->addPointV(trackElem->curve->getNode(trackElem->curve->getNodeCount()),
    495                      newElem);
    496       // add the new child to the childList.
    497       trackElem->children->add(newElem);
    498     }
    499 
    500   // setting the Name of the new TrackElement to the name of the last one + _childI
    501 
    502   if (trackElem->getName())
    503     {
    504       for (int i = 0; i < trackElem->childCount; i++)
    505       {
    506         char* childName = new char[strlen(trackElem->getName())+10];
    507         sprintf(childName, "%s_child%d", trackElem->getName(), i);
    508         trackElem->getChild(i)->setName(childName);
    509       }
    510     }
    511   // select the first Child to work on.
    512   this->currentTrackElem = trackElem->getChild(0);
     481//   if (!trackElem)
     482//     trackElem = this->currentTrackElem;
     483//
     484//   trackElem->childCount = childCount;
     485//   trackElem->mainJoin = true;  // this tells join, that this one is the Main Join, if it tries to join multiple Tracks
     486//   trackElem->children =  new tList<TrackElement>();
     487//   for (int i = 0; i < childCount; i++)
     488//     {
     489//       // create a new Element
     490//       TrackElement* newElem = new TrackElement();
     491//       // setting up the new ID
     492//       newElem->ID = ++trackElemCount;
     493//       // setting up the Time
     494//       newElem->startingTime = trackElem->endTime + trackElem->jumpTime;
     495//       // adds the conection Point
     496//       this->addPointV(trackElem->curve->getNode(trackElem->curve->getNodeCount()),
     497//                      newElem);
     498//       // add the new child to the childList.
     499//       trackElem->children->add(newElem);
     500//     }
     501//
     502//   // setting the Name of the new TrackElement to the name of the last one + _childI
     503//
     504//   if (trackElem->getName())
     505//     {
     506//       for (int i = 0; i < trackElem->childCount; i++)
     507//       {
     508//         char* childName = new char[strlen(trackElem->getName())+10];
     509//         sprintf(childName, "%s_child%d", trackElem->getName(), i);
     510//         trackElem->getChild(i)->setName(childName);
     511//       }
     512//     }
     513//   // select the first Child to work on.
     514//   this->currentTrackElem = trackElem->getChild(0);
    513515}
    514516
     
    659661void TrackManager::setSavePointS(const std::string& nextElementName)
    660662{
    661   this->setSavePoint(NULL);
    662   if (strcmp(nextElementName, ""))
    663     this->firstTrackElem->findByID(this->trackElemCount)->setName(nextElementName);
     663//   this->setSavePoint(NULL);
     664//   if (strcmp(nextElementName, ""))
     665//     this->firstTrackElem->findByID(this->trackElemCount)->setName(nextElementName);
    664666}
    665667
     
    736738void TrackManager::forkS(const std::string& forkString)
    737739{
    738   SubString strings(forkString, ',');
    739 
    740   int* trackIDs = new int[strings.getCount()];
    741   this->forkV(strings.getCount(), trackIDs, NULL);
    742 
    743   for(int i = 0; i < strings.getCount(); i++)
    744     {
    745       this->firstTrackElem->findByID(trackIDs[i])->setName(strings.getString(i));
    746     }
    747   delete []trackIDs;
     740//   SubString strings(forkString, ',');
     741//
     742//   int* trackIDs = new int[strings.getCount()];
     743//   this->forkV(strings.getCount(), trackIDs, NULL);
     744//
     745//   for(int i = 0; i < strings.getCount(); i++)
     746//     {
     747//       this->firstTrackElem->findByID(trackIDs[i])->setName(strings.getString(i));
     748//     }
     749//   delete []trackIDs;
    748750}
    749751
     
    877879void TrackManager::joinS(const std::string& joinString)
    878880{
    879   SubString strings(joinString, ',');
    880 
    881   int* trackIDs = new int[strings.getCount()];
    882   this->joinV(strings.getCount(), trackIDs);
    883 
    884   for(unsigned int i = 0; i < strings.getCount(); i++)
    885     {
    886       TrackElement* tmpElem = this->firstTrackElem->findByName(strings.getString(i).c_str());
    887       if (tmpElem != NULL)
    888         trackIDs[i] = tmpElem->ID;
    889       else
    890       {
    891         PRINTF(1)("Trying to join a Track, of which the name does not exist: %s\n", strings.getString(i).c_str());
    892         trackIDs[i] = -1;
    893       }
    894     }
    895   this->joinV(strings.getCount(), trackIDs);
    896   delete []trackIDs;
     881//   SubString strings(joinString, ',');
     882//
     883//   int* trackIDs = new int[strings.getCount()];
     884//   this->joinV(strings.getCount(), trackIDs);
     885//
     886//   for(unsigned int i = 0; i < strings.getCount(); i++)
     887//     {
     888//       TrackElement* tmpElem = this->firstTrackElem->findByName(strings.getString(i).c_str());
     889//       if (tmpElem != NULL)
     890//         trackIDs[i] = tmpElem->ID;
     891//       else
     892//       {
     893//         PRINTF(1)("Trying to join a Track, of which the name does not exist: %s\n", strings.getString(i).c_str());
     894//         trackIDs[i] = -1;
     895//       }
     896//     }
     897//   this->joinV(strings.getCount(), trackIDs);
     898//   delete []trackIDs;
    897899}
    898900
     
    10731075void TrackManager::tick(float dt)
    10741076{
    1075   PRINTF(4)("CurrentTrackID: %d, LocalTime is: %f, timestep is: %f\n", this->currentTrackElem->ID, this->localTime, dt);
    1076   if (this->localTime <= this->firstTrackElem->duration)
    1077     this->jumpTo(this->localTime);
    1078   if (this->localTime <= this->maxTime)
    1079     this->localTime += dt;
    1080   if (this->localTime > this->currentTrackElem->endTime
    1081       && this->currentTrackElem->children)
    1082     {
    1083       if (this->currentTrackElem->jumpTime != 0.0)
    1084         this->jumpTo(this->localTime + this->currentTrackElem->jumpTime);
    1085       // jump to the next TrackElement and also set the history of the new Element to the old one.
    1086       TrackElement* tmpHistoryElem = this->currentTrackElem;
    1087       this->currentTrackElem = this->currentTrackElem->getChild(this->choosePath(this->currentTrackElem));
    1088       this->currentTrackElem->history = tmpHistoryElem;
    1089       if (this->currentTrackElem->getName())
    1090         {
    1091           this->trackText->setText(this->currentTrackElem->getName());
    1092           this->textAnimation->replay();
    1093         }
    1094     }
    1095   if (this->bindSlave)
    1096     {
    1097       Vector tmp = this->calcPos();
    1098       Quaternion quat = Quaternion(this->calcDir(), Vector(this->currentTrackElem->curve->calcAcc((localTime-this->currentTrackElem->startingTime)/this->currentTrackElem->duration).x,1,this->currentTrackElem->curve->calcAcc((localTime-this->currentTrackElem->startingTime)/this->currentTrackElem->duration).z));
    1099 
    1100       Vector v(0.0, 1.0, 0.0);
    1101       Quaternion q(-PI/2, v);
    1102       quat = quat * q;
    1103 
    1104       this->bindSlave->setAbsCoor(tmp);
    1105       this->bindSlave->setAbsDir(quat);
    1106     }
     1077//   PRINTF(4)("CurrentTrackID: %d, LocalTime is: %f, timestep is: %f\n", this->currentTrackElem->ID, this->localTime, dt);
     1078//   if (this->localTime <= this->firstTrackElem->duration)
     1079//     this->jumpTo(this->localTime);
     1080//   if (this->localTime <= this->maxTime)
     1081//     this->localTime += dt;
     1082//   if (this->localTime > this->currentTrackElem->endTime
     1083//       && this->currentTrackElem->children)
     1084//     {
     1085//       if (this->currentTrackElem->jumpTime != 0.0)
     1086//         this->jumpTo(this->localTime + this->currentTrackElem->jumpTime);
     1087//       // jump to the next TrackElement and also set the history of the new Element to the old one.
     1088//       TrackElement* tmpHistoryElem = this->currentTrackElem;
     1089//       this->currentTrackElem = this->currentTrackElem->getChild(this->choosePath(this->currentTrackElem));
     1090//       this->currentTrackElem->history = tmpHistoryElem;
     1091//       if (this->currentTrackElem->getName())
     1092//         {
     1093//           this->trackText->setText(this->currentTrackElem->getName());
     1094//           this->textAnimation->replay();
     1095//         }
     1096//     }
     1097//   if (this->bindSlave)
     1098//     {
     1099//       Vector tmp = this->calcPos();
     1100//       Quaternion quat = Quaternion(this->calcDir(), Vector(this->currentTrackElem->curve->calcAcc((localTime-this->currentTrackElem->startingTime)/this->currentTrackElem->duration).x,1,this->currentTrackElem->curve->calcAcc((localTime-this->currentTrackElem->startingTime)/this->currentTrackElem->duration).z));
     1101//
     1102//       Vector v(0.0, 1.0, 0.0);
     1103//       Quaternion q(-PI/2, v);
     1104//       quat = quat * q;
     1105//
     1106//       this->bindSlave->setAbsCoor(tmp);
     1107//       this->bindSlave->setAbsDir(quat);
     1108//     }
    11071109}
    11081110
     
    11161118void TrackManager::jumpTo(float time)
    11171119{
    1118   if (time == 0)
    1119     {
    1120       this->currentTrackElem = this->firstTrackElem;
    1121       if (this->currentTrackElem->getName())
    1122         {
    1123           this->trackText->setText(this->currentTrackElem->getName());
    1124           this->textAnimation->play();
    1125         }
    1126     }
    1127   this->localTime = time;
     1120//   if (time == 0)
     1121//     {
     1122//       this->currentTrackElem = this->firstTrackElem;
     1123//       if (this->currentTrackElem->getName())
     1124//         {
     1125//           this->trackText->setText(this->currentTrackElem->getName());
     1126//           this->textAnimation->play();
     1127//         }
     1128//     }
     1129//   this->localTime = time;
    11281130}
    11291131
  • trunk/src/util/track/track_manager.h

    r7221 r10368  
    4141class TrackElement : public BaseObject
    4242{
     43  ObjectListDeclaration(TrackElement);
     44
    4345 public:
    4446  TrackElement();
     
    131133    \li TrackElement: A Part of A whole Track
    132134*/
    133 class TrackManager : public BaseObject
     135class TrackManager
    134136{
    135137 public:
  • trunk/src/util/track/track_node.cc

    r9869 r10368  
    1717
    1818
    19 #include "track_node.h"
     19#include "track/track_node.h"
    2020
    21 #include "track_manager.h"
     21#include "track/track_manager.h"
    2222
    2323
    24 ObjectListDefinition(TracNode);
     24ObjectListDefinition(TrackNode);
     25
    2526/**
    2627 *  standard constructor
     
    2829TrackNode::TrackNode ()
    2930{
    30   this->registerObject(this, TracNode::_objectList);
    31   this->setName("TrackNode");
     31  this->registerObject(this, TrackNode::_objectList);
    3232
    3333  PNode::getNullParent()->addChild(this);
  • trunk/src/util/track/track_node.h

    r9869 r10368  
    1414#include "p_node.h"
    1515
     16
    1617/* FORWARD DECLARATION */
    1718class TrackManager;
     
    2021class TrackNode : public PNode
    2122{
    22   ObjectListDeclaratrion(TracNode);
     23  ObjectListDeclaration(TrackNode);
    2324 public:
    2425  TrackNode ();
Note: See TracChangeset for help on using the changeset viewer.