Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/util/hud.cc @ 10757

Last change on this file since 10757 was 10698, checked in by snellen, 17 years ago

merged adm, hud, vs-enhancements : beni's responsible for this commit. blame him!

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