Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/hud3/src/orxonox/hud/HUDV2.cc @ 1292

Last change on this file since 1292 was 1283, checked in by chaiy, 17 years ago

new hud branch, since hud2 doesnt work on tardis

File size: 7.1 KB
Line 
1/*
2*   ORXONOX - the hottest 3D action shooter ever to exist
3*
4*
5*   License notice:
6*
7*   This program is free software; you can redistribute it and/or
8*   modify it under the terms of the GNU General Public License
9*   as published by the Free Software Foundation; either version 2
10*   of the License, or (at your option) any later version.
11*
12*   This program is distributed in the hope that it will be useful,
13*   but WITHOUT ANY WARRANTY; without even the implied warranty of
14*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15*   GNU General Public License for more details.
16*
17*   You should have received a copy of the GNU General Public License
18*   along with this program; if not, write to the Free Software
19*   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20*
21*   Author:
22*      Yuning Chai
23*   Co-authors:
24*      ...
25*
26*/
27
28#include "OrxonoxStableHeaders.h"
29
30#include <OgreOverlayManager.h>
31#include <OgreOverlayElement.h>
32#include <OgreStringConverter.h>
33
34#include "HUD.h"
35#include "Bar.h"
36
37
38namespace orxonox
39{
40  using namespace Ogre;
41
42  HUD::HUD(void)
43  {
44    init();
45
46    setTime(99,55);
47
48    setTargetWindowName("HURRA");
49    setTargetWindowDistance(12);
50    setTargetWindowStatus("Dead");
51    setTargetWindowDistance(30);
52
53    setEnergyValue(60);
54
55    setShieldLeftTopValue(true);
56    setShieldRightTopValue(false);
57    setShieldLeftBottomValue(false);
58    setShieldRightBottomValue(true);
59
60    setRocket1(11);
61    setRocket2(22);
62    setRocket3(33);
63    setRocket4(44);
64
65    setEnergyDistr(33,33,34);
66
67    setPrimar(3);
68
69    energyDistrPixelX_ = 100;
70    energyDistrPixelY_ = 86;
71
72
73  }
74
75
76  HUD::~HUD( void ){
77
78  }
79
80  void HUD::setTime(int i, int j){
81    timeMin_=i;
82    timeSec_=j;
83    timeText_->setCaption(StringConverter::toString(timeMin_) + ":" + StringConverter::toString(timeSec_));
84  }
85
86  void HUD::setTargetWindowName(std::string i){
87    targetWindowName_=i;
88    targetWindowNameText_->setCaption( targetWindowName_ );
89  }
90
91  void HUD::setTargetWindowStatus(std::string i){
92    targetWindowStatus_=i;
93    targetWindowStatusText_->setCaption( targetWindowStatus_ );
94  }
95
96  void HUD::setTargetWindowDistance(int i){
97    targetWindowDistance_=i;
98    targetWindowDistanceText_->setCaption(StringConverter::toString(targetWindowDistance_) + "km" );
99  }
100
101  void HUD::setTargetWindowHitRating(int i){
102    targetWindowHitRating_=i;
103    targetWindowHitRatingText_->setCaption(StringConverter::toString(targetWindowHitRating_) + "%" );
104  }
105
106  void HUD::setEnergyValue(int i){
107    energyValue_=i;
108    energyLength_->setWidth((int)((float)energyValue_/(float)100*200));
109  }
110
111  void HUD::setShieldLeftTopValue(bool i){
112    shieldLeftTopValue_=i;
113    if (shieldLeftTopValue_) shieldLeftTop_->show();
114    else shieldLeftTop_->hide();
115  }
116
117  void HUD::setShieldRightTopValue(bool i){
118    shieldRightTopValue_=i;
119    if (shieldRightTopValue_) shieldRightTop_->show();
120    else shieldRightTop_->hide();
121  }
122
123  void HUD::setShieldLeftBottomValue(bool i){
124    shieldLeftBottomValue_=i;
125    if (shieldLeftBottomValue_) shieldLeftBottom_->show();
126    else shieldLeftBottom_->hide();
127  }
128
129  void HUD::setShieldRightBottomValue(bool i){
130    shieldRightBottomValue_=i;
131    if (shieldRightBottomValue_) shieldRightBottom_->show();
132    else shieldRightBottom_->hide();
133  }
134
135  void HUD::setRocket1(int i){
136    rocket1_=i;
137    rocketNum1_->setCaption(StringConverter::toString(rocket1_));
138  }
139
140  void HUD::setRocket2(int i){
141    rocket2_=i;
142    rocketNum2_->setCaption(StringConverter::toString(rocket2_));
143  }
144
145  void HUD::setRocket3(int i){
146    rocket3_=i;
147    rocketNum3_->setCaption(StringConverter::toString(rocket3_));
148  }
149
150  void HUD::setRocket4(int i){
151    rocket4_=i;
152    rocketNum4_->setCaption(StringConverter::toString(rocket4_));
153  }
154
155  void HUD::setEnergyDistr(float s, float e, float l){
156    energyDistrShield_=s;
157    energyDistrEngine_=e;
158    energyDistrLaser_=l;
159
160    float energyDistrShieldInv_ = 100 - energyDistrShield_;
161    float energyDistrEngineInv_ = 100 - energyDistrEngine_;
162    float energyDistrLaserInv_ = 100 - energyDistrLaser_;
163
164    float energyDistrT_ = -energyDistrPixelX_/((energyDistrPixelX_-energyDistrPixelX_/2*energyDistrShieldInv_/(energyDistrShieldInv_+energyDistrEngineInv_))*energyDistrLaserInv_*(energyDistrShieldInv_+energyDistrEngineInv_)/energyDistrShieldInv_/(energyDistrLaserInv_+energyDistrEngineInv_)+energyDistrPixelX_/2+energyDistrPixelX_/2*energyDistrEngineInv_/(energyDistrEngineInv_+energyDistrLaserInv_));
165    float energyDistrX_ = (-energyDistrPixelX_/2-energyDistrPixelX_/2*energyDistrEngineInv_/(energyDistrEngineInv_+energyDistrLaserInv_))*energyDistrT_;
166    float energyDistrY_ = energyDistrPixelY_+energyDistrPixelY_*energyDistrLaserInv_/(energyDistrLaserInv_+energyDistrEngineInv_)*energyDistrT_;
167
168    energyDistrPoint_->setLeft((int)energyDistrX_-3);
169    energyDistrPoint_->setTop((int)energyDistrY_-3);
170
171  }
172
173  void HUD::setPrimar(int i){
174    primarValue_=i;
175    if(i==1){
176      primarChoice_->setLeft(2);
177      primarChoice_->setWidth(48);
178    }
179    if(i==2){
180      primarChoice_->setLeft(51);
181      primarChoice_->setWidth(49);
182    }
183    else{
184      primarChoice_->setLeft(101);
185      primarChoice_->setWidth(48);
186    }
187  }
188
189
190
191  void HUD::init(void)
192  {
193    timeText_ = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/Time/Text");
194
195    targetWindowNameText_ = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/TargetWindow/Name");
196    targetWindowDistanceText_ = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/TargetWindow/DistanceText");
197    targetWindowStatusText_ = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/TargetWindow/StatusText");
198    targetWindowHitRatingText_ = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/TargetWindow/HitRatingText");
199
200    energyLength_ = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/EnergyBackground");
201
202    shieldLeftTop_ = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/shieldLeftTop");
203    shieldRightTop_ = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/shieldRightTop");
204    shieldLeftBottom_ = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/shieldLeftBottom");
205    shieldRightBottom_ = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/shieldRightBottom");
206
207    rocketNum1_ = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/RocketNum1");
208    rocketNum2_ = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/RocketNum2");
209    rocketNum3_ = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/RocketNum3");
210    rocketNum4_ = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/RocketNum4");
211
212    // FIXME: unused vars!
213    float energyDistrPixelX_ = 100;
214    float energyDistrPixelY_ = 86;
215    energyDistrPoint_ = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/EnergyDistrPoint");
216
217    primarChoice_ = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/PrimarChoice");
218  }
219
220}
Note: See TracBrowser for help on using the repository browser.