Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 6441 was 6441, checked in by bensch, 18 years ago

orxonox/trunk: the Hud now scales the Widgets itself

File size: 1.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: ...
14*/
15
16//#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_
17
18#include "hud.h"
19
20#include "state.h"
21
22using namespace std;
23
24
25/**
26 * standard constructor
27 * @todo this constructor is not jet implemented - do it
28*/
29Hud::Hud ()
30{
31  this->setClassID(CL_HUD, "Hud");
32
33  //this->setSize2D(
34  this->energyWidget = NULL;
35  this->shieldWidget = NULL;
36  this->armorWidget = NULL;
37  this->resX = 1;
38  this->resY = 1;
39}
40
41
42/**
43 * standard deconstructor
44*/
45Hud::~Hud ()
46{
47  // delete what has to be deleted here
48}
49
50
51void Hud::loadParams(const TiXmlElement* root)
52{
53
54}
55
56void Hud::setBackGround()
57{
58
59}
60
61void Hud::setEnergyWidget(GLGuiWidget* widget)
62{
63  // decopple old widget
64  if (this->energyWidget != NULL)
65  {
66    this->energyWidget->hide();
67  }
68
69  this->energyWidget = widget;
70  if (this->energyWidget != NULL)
71  {
72    this->energyWidget->show();
73  }
74
75  this->updateResolution();
76}
77
78void Hud::setShiledWidget(GLGuiWidget* widget)
79{
80
81}
82
83void Hud::setArmorWidget(GLGuiWidget* widget)
84{
85
86}
87
88void Hud::addWeaponWidget(GLGuiWidget* widget)
89{
90
91}
92
93void Hud::removeWeaponWidget(GLGuiWidget* widget)
94{
95
96}
97
98void Hud::updateResolution()
99{
100  this->resX = State::resX();
101  this->resY = State::resY();
102  if (this->energyWidget != NULL)
103  {
104    this->energyWidget->setAbsCoor2D(.02 * this->resX, .4 * this->resY);
105    this->energyWidget->setSize2D(.05 * this->resX, .55 * this->resY);
106  }
107}
108
109
110void Hud::tick(float dt)
111{
112  if (this->resY != State::resY() || this->resX != State::resY())
113    this->updateResolution();
114}
115
116void Hud::draw() const
117{
118  GLGuiWidget::draw();
119}
120
121
Note: See TracBrowser for help on using the repository browser.