Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/presentation/src/util/hud.cc @ 10716

Last change on this file since 10716 was 10716, checked in by bknecht, 17 years ago

hud update

File size: 21.0 KB
Line 
1/*
2   orxonox - the future of 3D-vertical-scrollers
3
4   Copyright (C) 2004 orx
5
6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; either version 2, or (at your option)
9   any later version.
10
11   ### File Specific:
12   main-programmer: Benjamin Grauer
13   co-programmer: Benjamin Knecht
14*/
15
16//#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_
17
18#include "hud.h"
19
20#include "state.h"
21#include "debug.h"
22
23#include "world_entities/weapons/weapon_manager.h"
24#include "glgui_widget.h"
25#include "glgui_box.h"
26#include "glgui_bar.h"
27#include "elements/glgui_energywidgetvertical.h"
28
29#include "glgui_inputline.h"
30#include "specials/glgui_notifier.h"
31#include "elements/glgui_radar.h"
32#include "world_entities/space_ships/space_ship.h"
33
34
35
36/// HACK
37#include "player.h"
38#include "playable.h"
39
40ObjectListDefinition(Hud);
41/**
42 * standard constructor
43 * @todo this constructor is not jet implemented - do it
44*/
45Hud::Hud ()
46{
47  this->registerObject(this, Hud::_objectList);
48
49  //this->setSize2D(
50  this->weaponManager = NULL;
51  this->weaponManagerSecondary = NULL;
52  this->energyWidget = NULL;
53  this->shieldWidget = NULL;
54  this->healthWidget = NULL;
55  this->leftRect = NULL;
56  this->rightRect = NULL;
57  this->resX = 1;
58  this->resY = 1;
59
60        this->init();
61 
62}
63
64
65/**
66 * standard deconstructor
67*/
68Hud::~Hud ()
69{
70  delete this->inputLine;
71  delete this->notifier;
72
73  delete this->_radar;
74  delete this->barSocket;
75  delete this->rightRect;
76  delete this->leftRect;
77  delete this->topRect;
78  delete this->bottomRect;
79  delete this->middleRect;
80 
81
82  //if (this->shipValuesBox != NULL)
83    //delete this->shipValuesBox;
84
85  // delete what has to be deleted here
86}
87
88void Hud::init()
89{
90        this->overlayPercentage = 40;
91        this->overlayActive = false;
92        this->rightRect = new OrxGui::GLGuiImage();
93        this->leftRect = new OrxGui::GLGuiImage();
94        this->topRect = new OrxGui::GLGuiImage();
95        this->bottomRect = new OrxGui::GLGuiImage();
96        this->middleRect = new OrxGui::GLGuiImage();
97
98        this->inputLine = new OrxGui::GLGuiInputLine();
99        this->inputLine->setParent2D(this);
100        this->notifier = new OrxGui::GLGuiNotifier();
101        this->notifier->setParent2D(this);
102        notifier->setAbsCoor2D(100,100);
103       
104        this->barSocket = new OrxGui::GLGuiImage();
105        this->barSocket->setParent2D(this->bottomRect);
106       
107        this->_radar = new OrxGui::GLGuiRadar();
108        this->radarCenterNode = NULL;
109       
110        this->subscribeEvent(ES_ALL, EV_VIDEO_RESIZE);
111        this->subscribeEvent(ES_ALL, SDLK_TAB);
112 
113        if (this->playmode == FirstPerson)
114        {
115                this->topHit = new OrxGui::GLGuiImage();
116                this->topHit->loadImageFromFile("textures/gui/gui_hitbar.png");
117                this->topHit->setParent2D(this->middleRect);
118                this->topHit->setRelDir2D(-1.5708);
119               
120                this->bottomHit = new OrxGui::GLGuiImage();
121                this->bottomHit->loadImageFromFile("textures/gui/gui_hitbar.png");
122                this->bottomHit->setParent2D(this->middleRect);
123                this->bottomHit->setRelDir2D(1.5708);
124               
125                this->leftHit = new OrxGui::GLGuiImage();
126                this->leftHit->loadImageFromFile("textures/gui/gui_hitbar.png");
127                this->leftHit->setParent2D(this->middleRect);
128               
129                this->rightHit = new OrxGui::GLGuiImage();
130                this->rightHit->loadImageFromFile("textures/gui/gui_hitbar.png");
131                this->rightHit->setParent2D(this->middleRect);
132                this->rightHit->setRelDir2D(3.1416);
133               
134                this->leftRect->setParent2D(this);
135                this->rightRect->setParent2D(this);
136        }
137
138  //this->shipValuesBox = NULL;
139}
140
141
142void Hud::loadParams(const TiXmlElement* root)
143{
144  Element2D::loadParams(root);
145}
146
147void Hud::notifyUser(const std::string& message)
148{
149  this->notifier->pushNotifyMessage(message);
150}
151
152void Hud::setBackGround()
153{}
154
155void Hud::setEnergyWidget(OrxGui::GLGuiWidget* widget)
156{
157  //if (this->shipValuesBox == NULL)
158    //this->createShipValuesBox();
159
160  // decopple old widget
161  if (this->energyWidget != NULL)
162  {
163    this->energyWidget->hide();
164  }
165
166  this->energyWidget = widget;
167  if (this->energyWidget != NULL)
168  {
169    //this->energyWidget->shiftDir2D(270);
170    //dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (this->energyWidget)->setDisplayedName("Electronics");
171    //this->shipValuesBox->pack(this->energyWidget);
172    //dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (this->energyWidget)->setStandardSettings();
173    this->energyWidget->setParent2D(this->leftRect);
174    dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (this->energyWidget)->setDisplayedImage("textures/gui/gui_electronics_icon.png");
175    this->energyWidget->show();
176    /*    this->energyWidget->frontMaterial().setDiffuseMap("hud_energy_bar.png");
177        this->energyWidget->frontMaterial().setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);*/
178  }
179
180  this->updateResolution(); 
181}
182
183void Hud::setShieldWidget(OrxGui::GLGuiWidget* widget)
184{
185  /*
186  if (this->shipValuesBox == NULL)
187    this->createShipValuesBox();
188  */
189
190  // decopple old widget
191  if (this->shieldWidget != NULL)
192  {
193    this->shieldWidget->hide();
194  }
195
196  this->shieldWidget = widget;
197  if (this->shieldWidget != NULL)
198  {
199    //this->shieldWidget->shiftDir2D(270);
200    //this->shipValuesBox->pack(this->shieldWidget);
201    //dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (this->shieldWidget)->setStandardSettings();
202    this->shieldWidget->setParent2D(this->leftRect);
203    dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (this->shieldWidget)->setDisplayedImage("textures/gui/gui_shield_icon.png");
204    this->shieldWidget->show();
205    /*    this->shieldWidget->frontMaterial().setDiffuseMap("hud_energy_bar.png");
206        this->shieldWidget->frontMaterial().setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);*/
207  }
208  else
209    printf("schild im hud nicht uebergeben!!!!!!!!!!!!!!!!!!!!!!!!!");
210
211  this->updateResolution();
212}
213
214void Hud::setHealthWidget(OrxGui::GLGuiWidget* widget)
215{
216        if( this->playmode == FirstPerson )
217        {
218                this->healthWidget = new OrxGui::GLGuiBar();
219                dynamic_cast<OrxGui::GLGuiBar*> (this->healthWidget)->setMaximum(dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (widget)->getBarWidget()->maximum());
220                dynamic_cast<OrxGui::GLGuiBar*> (this->healthWidget)->setValue(dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (widget)->getBarWidget()->value());
221                this->healthWidget->setParent2D(this->barSocket);
222        }
223        else
224        {
225          /*
226          if (this->shipValuesBox == NULL)
227            this->createShipValuesBox();
228          */
229       
230        // decopple old widget
231          if (this->healthWidget != NULL)
232          {
233            this->healthWidget->hide();
234          }
235       
236          this->healthWidget = widget;
237          if (this->healthWidget != NULL)
238          {
239            //this->healthWidget->shiftDir2D(270);
240            //this->shipValuesBox->pack(this->healthWidget);
241            //dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (this->healthWidget)->setStandardSettings();
242            this->healthWidget->setParent2D(this->leftRect);
243            //dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (this->healthWidget)->setDisplayedImage("textures/gui/gui_health_icon.png");
244            this->healthWidget->show();
245            /*    this->healthWidget->frontMaterial().setDiffuseMap("hud_energy_bar.png");
246                this->healthWidget->frontMaterial().setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);*/
247          }
248        }
249
250  this->updateResolution();
251}
252
253
254void Hud::setImplantWidget(OrxGui::GLGuiWidget* widget)
255{
256  //if (this->shipValuesBox == NULL)
257    //this->createShipValuesBox();
258
259  // decopple old widget
260  if (this->implantWidget != NULL)
261  {
262    this->implantWidget->hide();
263  }
264
265  this->implantWidget = widget;
266  if (this->implantWidget != NULL)
267  {
268    //this->energyWidget->shiftDir2D(270);
269    //dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (this->energyWidget)->setDisplayedName("Electronics");
270    //this->shipValuesBox->pack(this->energyWidget);
271    //dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (this->energyWidget)->setStandardSettings();
272    this->implantWidget->setParent2D(this->leftRect);
273    dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (this->implantWidget)->setDisplayedImage("textures/gui/gui_electronics_icon.png");
274    this->implantWidget->show();
275    /*    this->energyWidget->frontMaterial().setDiffuseMap("hud_energy_bar.png");
276        this->energyWidget->frontMaterial().setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);*/
277  }
278
279  this->updateResolution();
280}
281
282void Hud::setWeaponManager(WeaponManager* weaponMan, WeaponManager* weaponManSec)
283{
284  //clearWeaponManager();
285
286  //Hide all widgets
287  if (this->weaponManager != NULL)
288  {
289    for (unsigned int i = 0; i < this->weaponManager->getSlotCount(); i++)
290    {
291      Weapon* weapon = this->weaponManager->getWeapon(i);
292      if (weapon != NULL)
293      {
294        weapon->getEnergyWidget()->hide();
295        //this->weaponsWidgetsPrim.remove(dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (weapon->getEnergyWidget()));
296      }
297    }
298  }
299
300  if (this->weaponManagerSecondary != NULL)
301  {
302    for (unsigned int i = 0; i < this->weaponManagerSecondary->getSlotCount(); i++)
303    {
304      Weapon* weapon = this->weaponManagerSecondary->getWeapon(i);
305      if (weapon != NULL)
306      {
307        weapon->getEnergyWidget()->hide();
308        //this->weaponsWidgetsSec.remove(dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (weapon->getEnergyWidget()));
309      }
310    }
311  }
312
313  this->weaponManager = weaponMan;
314  this->weaponManagerSecondary = weaponManSec; 
315
316  this->updateWeaponManager();
317  //  this->updateResolution();
318}
319
320/*
321void Hud::clearWeaponManager()
322{
323  //Hide all widgets
324  if (this->weaponManager != NULL)
325  {
326    for (unsigned int i = 0; i < this->weaponManager->getSlotCount(); i++)
327    {
328      Weapon* weapon = this->weaponManager->getWeapon(i);
329      if (weapon != NULL)
330      {
331        weapon->getEnergyWidget()->hide();
332        //this->weaponsWidgetsPrim.remove(dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (weapon->getEnergyWidget()));
333      }
334    }
335  }
336
337  if (this->weaponManagerSecondary != NULL)
338  {
339    for (unsigned int i = 0; i < this->weaponManagerSecondary->getSlotCount(); i++)
340    {
341      Weapon* weapon = this->weaponManagerSecondary->getWeapon(i);
342      if (weapon != NULL)
343      {
344        weapon->getEnergyWidget()->hide();
345        //this->weaponsWidgetsSec.remove(dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (weapon->getEnergyWidget()));
346      }
347    }
348  }
349
350  //this->weaponsWidgetsPrim.clear();
351  //this->weaponsWidgetsSec.clear();
352}
353*/
354
355void Hud::setMode(Hud::Playmode playmode)
356{
357        this->playmode = playmode;
358        this->init();
359}
360
361void Hud::updateWeaponManager()
362{
363  // hide all the Widgets
364 
365  std::list<OrxGui::GLGuiEnergyWidgetVertical*>::iterator weaponWidget;
366  for (weaponWidget = this->weaponsWidgetsPrim.begin(); weaponWidget != this->weaponsWidgetsPrim.end(); weaponWidget++)
367  {
368    (*weaponWidget)->hide();
369  }
370  this->weaponsWidgetsPrim.clear();
371
372  for (weaponWidget = this->weaponsWidgetsSec.begin(); weaponWidget != this->weaponsWidgetsSec.end(); weaponWidget++)
373  {
374    (*weaponWidget)->hide();
375  }
376  this->weaponsWidgetsSec.clear();
377 
378
379  // add all that we need again.
380
381  if (this->weaponManager != NULL)
382    for (unsigned int i = 0; i < this->weaponManager->getSlotCount(); i++)
383    {
384      Weapon* weapon = this->weaponManager->getWeapon(i);
385      if (weapon != NULL)
386      {
387        //PRINTF(0)("WEAPON %s::%s in Slots\n", weapon->getClassCName(), weapon->getName());
388        weapon->getEnergyWidget()->setParent2D(this->rightRect);
389        weapon->getEnergyWidget()->show();
390        weapon->getEnergyWidget()->setBackgroundColor(Color(.8,.2,.11, 0.1));
391        weapon->getEnergyWidget()->setFrontColor(Color( .2,.5,.7,.6));
392        weapon->getEnergyWidget()->setWidgetSize(120,30);
393        //weapon->getEnergyWidget()->frontMaterial().setTransparency(.6);
394        this->weaponsWidgetsPrim.push_back(dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (weapon->getEnergyWidget()));
395      }
396    }
397
398  if (this->weaponManagerSecondary != NULL)
399    for (unsigned int i = 0; i < this->weaponManagerSecondary->getSlotCount(); i++)
400    {
401      Weapon* weapon = this->weaponManagerSecondary->getWeapon(i);
402      if (weapon != NULL)
403      {
404        //PRINTF(0)("WEAPON %s::%s in Slots\n", weapon->getClassCName(), weapon->getName());
405        weapon->getEnergyWidget()->setParent2D(this->rightRect);
406        weapon->getEnergyWidget()->show();
407        weapon->getEnergyWidget()->setBackgroundColor(Color(.8,.2,.11, 0.1));
408        weapon->getEnergyWidget()->setFrontColor(Color( .2,.5,.7,.6));
409        weapon->getEnergyWidget()->setWidgetSize(150,50);
410        //weapon->getEnergyWidget()->frontMaterial().setTransparency(.6);
411        this->weaponsWidgetsSec.push_back(dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (weapon->getEnergyWidget()));
412      }
413    }
414
415  this->updateResolution();
416
417}
418
419void Hud::addWeaponWidget(OrxGui::GLGuiWidget* widget)
420{}
421
422void Hud::removeWeaponWidget(OrxGui::GLGuiWidget* widget)
423{}
424
425void Hud::updateResolution()
426{
427  this->resX = State::getResX();
428  this->resY = State::getResY();
429
430  this->setSize2D(this->resX, this->resY);
431  if( this->playmode != FirstPerson )
432  {
433          this->notifier->setAbsCoor2D(0.7 * this->resX, 0.3 * this->resY);
434          this->notifier->setWidgetSize(0.25 * this->resX, 0.6 * this->resY);
435  }
436
437  int overlayWidth = 0;
438  if (overlayPercentage >= 20)
439    overlayWidth = this->resX * (overlayPercentage)/(200);
440  else
441    overlayWidth = this->resX / 10; // fixed warning!
442  //if (overlayWidth < 100)
443    //overlayWidth = 100;
444
445  this->rightRect->hide();
446  this->leftRect->hide();
447 
448  if( this->playmode != FirstPerson )
449  {
450         
451          this->leftRect->setWidgetSize(float(overlayWidth), float(this->resY));
452          this->leftRect->setAbsCoor2D(0,0);
453          /*this->leftRect->setBackgroundTexture(Texture());
454          this->leftRect->setBackgroundColor(Color(0,0,0.7,0.2));
455          this->leftRect->setForegroundTexture(Texture());
456          this->leftRect->setForegroundColor(Color(0,0,0,0));*/
457         
458          this->rightRect->setWidgetSize(float(overlayWidth), float(this->resY));
459          this->rightRect->setAbsCoor2D(this->resX - overlayWidth,0);
460          /*this->rightRect->setBackgroundTexture(Texture());
461          this->rightRect->setBackgroundColor(Color(0,0,0.7,0.2));
462          this->rightRect->setForegroundTexture(Texture());
463          this->rightRect->setForegroundColor(Color(0,0,0,0));*/
464  }
465  else
466  {
467          this->bottomRect->setParent2D(this);
468          this->bottomRect->setWidgetSize(float(this->resX), float(overlayWidth));
469          this->bottomRect->setAbsCoor2D(0, this->resY - overlayWidth);
470         
471          this->topRect->setParent2D(this);
472          this->topRect->setWidgetSize(float(this->resX), float(overlayWidth));
473          this->topRect->setAbsCoor2D(0, 0);
474         
475          this->middleRect->setParent2D(this);
476          //this->middleRect->setWidgetSize(float(this->resY)/2, float(this->resY)/2);
477          this->middleRect->setAbsCoor2D(/*float(this->resX - this->resY/2)/2, float(this->resY)/4*/float(this->resX/2), float(this->resY/2));
478         
479          this->bottomHit->setRelCoor2D(0, this->resY/4);
480          this->topHit->setRelCoor2D(0, -this->resY/4);
481          this->leftHit->setRelCoor2D(-this->resX/4, 0);
482          this->rightHit->setRelCoor2D(this->resX/4, 0);
483  }
484
485  if (this->overlayActive == true)
486  {
487    this->rightRect->show();
488    this->leftRect->show();
489  }
490
491
492  if (State::getPlayer() && State::getPlayer()->getPlayable() && State::getObjectManager())
493  {
494    PRINTF(4)("UPDATING RADAR\n");
495    if( this->playmode != FirstPerson )
496        this->_radar->setParent2D(this->leftRect);
497    else
498        this->_radar->setParent2D(this->topRect);
499    if (radarCenterNode == NULL)
500      this->_radar->setCenterNode(State::getPlayer()->getPlayable());
501    else
502      this->_radar->setCenterNode(this->radarCenterNode);
503
504    //this->_radar->addEntityList(&State::getObjectManager()->getEntityList((OM_LIST)(State::getPlayer()->getPlayable()->getOMListNumber()+1)), Color(.4, .4, 1.0));
505    this->_radar->addEntityList(&State::getObjectManager()->getEntityList(OM_GROUP_00), Color(1, 0, 0));
506    this->_radar->addEntityList(&State::getObjectManager()->getEntityList(OM_GROUP_01), Color(0, 0, 1));
507    this->_radar->setAbsCoor2D(0, 0.01 * this->resY);
508    this->_radar->setWidgetSize(overlayWidth, overlayWidth);
509    this->_radar->setRange(300);
510    this->_radar->show();
511   
512    int statWidgetsNumber = 0;
513    float expectedHealthSizeX = 0;
514    float expectedHealthSizeY = 0;
515    float newSizeY = 0; float newSizeX = 0;
516    float moduloWidth = 0;
517
518        if( this->playmode != FirstPerson )
519        {
520            if (this->healthWidget != NULL)
521            {
522              expectedHealthSizeX = 150;
523              expectedHealthSizeY = 50;
524              statWidgetsNumber++;
525            }
526
527            if (this->shieldWidget != NULL)
528              statWidgetsNumber++;
529           
530            if (this->energyWidget != NULL)
531              statWidgetsNumber++;
532       
533            if (expectedHealthSizeY * statWidgetsNumber > overlayWidth)
534            {
535              newSizeY = overlayWidth / float(statWidgetsNumber);
536              newSizeX = expectedHealthSizeX;
537              PRINTF(0)("Statwidgets resized\n");
538            }
539            else
540            {
541              newSizeY = expectedHealthSizeY;
542              newSizeX = expectedHealthSizeX;
543              moduloWidth = int(overlayWidth) % int(expectedHealthSizeY * statWidgetsNumber);
544            }
545       
546            float posY = overlayWidth + newSizeX;
547       
548            if (this->healthWidget != NULL)
549            {
550              this->healthWidget->setSize2D(newSizeX, newSizeY);
551              this->healthWidget->setRelCoor2D((statWidgetsNumber - 1) * newSizeY + 3 * moduloWidth / (statWidgetsNumber + 1),posY);
552            }
553            if (this->shieldWidget != NULL)
554            {
555              this->shieldWidget->setSize2D(newSizeX, newSizeY);
556              this->shieldWidget->setRelCoor2D((statWidgetsNumber - 2) * newSizeY + 2 *moduloWidth / (statWidgetsNumber + 1),posY);
557            }
558            if (this->energyWidget != NULL)
559            {
560              this->energyWidget->setSize2D(newSizeX, newSizeY);
561              this->energyWidget->setRelCoor2D(moduloWidth / (statWidgetsNumber + 1),posY);
562            }
563        }
564        else
565        {
566                this->barSocket->setParent2D(this->bottomRect);
567                this->barSocket->setWidgetSize( float(overlayWidth), float(overlayWidth));
568                this->barSocket->setRelCoor2D(0,this->resX - float(overlayWidth));
569               
570                this->healthWidget->setRelCoor2D(10,-20);
571        }
572       
573
574    /*
575    if (this->healthWidget != NULL)
576      this->healthWidget->setRelCoor2D(100,0.2*this->resY + this->healthWidget->getSizeX2D());
577    if (this->shieldWidget != NULL)
578      this->shieldWidget->setRelCoor2D(60,0.2*this->resY + this->healthWidget->getSizeX2D());
579    if (this->energyWidget != NULL)
580      this->energyWidget->setRelCoor2D(20,0.2*this->resY + this->healthWidget->getSizeX2D());
581    */
582    //this->shieldWidget->setRelCoor2D(0.1*this->resX + this->healthWidget->getSizeX2D(),0);
583    //this->energyWidget->setRelCoor2D(0.1*this->resX + this->healthWidget->getSizeX2D() + this->shieldWidget->getSizeX2D(),0);
584  }
585
586  /*
587  if (this->shipValuesBox != NULL)
588  {
589    this->shipValuesBox->setAbsCoor2D(0.2 * this->resX, 0.4 * this->resY);
590    this->shipValuesBox->setWidgetSize(.4 * this->resX, 0.1 * this->resY);
591  }
592  else
593    createShipValuesBox();
594  */
595
596  std::list<OrxGui::GLGuiEnergyWidgetVertical*>::iterator weaponWidget;
597  Vector2D pos = Vector2D(overlayWidth, 0.4*this->resY);
598  float largestWidgetSizeX = 0;
599  //PRINTF(0)("Cur Pos: %f,%f\n",pos.x,pos.y);
600  // out of reasons i can't get behind, this version is segfaulting when calling getSizeX2D or getSizeY2D. the other
601  // element2D- related function works tough.. :s
602
603  for (weaponWidget = this->weaponsWidgetsPrim.begin(); weaponWidget != this->weaponsWidgetsPrim.end(); weaponWidget++)
604  {
605    float ySize = (*weaponWidget)->getSizeY2D();
606    float xSize = (*weaponWidget)->getSizeX2D();
607    if (xSize > largestWidgetSizeX)
608      largestWidgetSizeX = xSize;
609    if (pos.x < ySize)
610    {
611      pos.x = overlayWidth;
612      pos.y += largestWidgetSizeX;
613    }
614    pos.x -= ySize;
615    (*weaponWidget)->setAbsCoor2D(pos.x + this->rightRect->getAbsCoor2D().x, pos.y);
616    //(*weaponWidget)->setAbsCoor2D(0,100);
617    (*weaponWidget)->show();
618    //printf("update thing %s::%s\n", (*weaponWidget)->getClassCName(), (*weaponWidget)->getName());
619  }
620 
621  weaponWidget = this->weaponsWidgetsSec.begin();
622  float expectedWidgetSizeY = 0;
623  if (weaponWidget != this->weaponsWidgetsSec.end())
624  {
625    expectedWidgetSizeY = (*weaponWidget)->getSizeY2D();
626  }
627  pos.y = resY - expectedWidgetSizeY * 0.6;
628  pos.x = overlayWidth + this->rightRect->getAbsCoor2D().x;
629
630  for (weaponWidget = this->weaponsWidgetsSec.begin(); weaponWidget != this->weaponsWidgetsSec.end(); weaponWidget++)
631  {
632    float ySize = (*weaponWidget)->getSizeY2D();
633    float xSize = (*weaponWidget)->getSizeX2D();
634    if (xSize > largestWidgetSizeX)
635      largestWidgetSizeX = xSize;
636    if (pos.x < ySize)
637    {
638      pos.x = overlayWidth;
639      pos.y -= largestWidgetSizeX + expectedWidgetSizeY * 0.6;
640    }
641    pos.x -= ySize;
642    //PRINTF(0)("secweaponwidget y-size: %f/n", (*weaponWidget)->getSizeY2D());
643    (*weaponWidget)->setAbsCoor2D(pos.x, pos.y);//+this->rightRect->getAbsCoor2D().x, pos.y);
644    (*weaponWidget)->show();
645    //printf("update thing %s::%s\n", (*weaponWidget)->getClassCName(), (*weaponWidget)->getName());
646  }
647
648}
649
650void Hud::draw() const
651{
652  //  GLGuiWidget::draw();
653}
654
655
656void Hud::process(const Event &event)
657{
658  if (event.type == EV_VIDEO_RESIZE)
659    this->updateResolution();
660  else if (event.type == SDLK_TAB)
661  {
662    /// TODO SHOW THE INPUT-LINE
663  //  this->inputLine->select();
664  }
665}
666
667/*
668void Hud::createShipValuesBox()
669{
670  this->shipValuesBox = new OrxGui::GLGuiBox(OrxGui::Vertical);
671  //this->shipValuesBox->setWidgetSize(1000,500);
672  //this->shipValuesBox->setBackgroundTexture("textures/gui_container_background.png");
673  this->shipValuesBox->setBackgroundTexture(Texture());
674  this->shipValuesBox->setBackgroundColor(Color(0,0,1,0.5));
675  this->shipValuesBox->setVisibility(true);
676}
677*/
678
679
Note: See TracBrowser for help on using the repository browser.