Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/FICN/src/orxonox/hud/HUD.cc @ 772

Last change on this file since 772 was 715, checked in by rgrieder, 17 years ago
  • the master has spoken…
  • misc/String.h is not anymore..
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 <OgreOverlayManager.h>
29#include <OgreOverlayElement.h>
30#include <OgreStringConverter.h>
31
32#include "HUD.h"
33
34
35namespace orxonox
36{
37  using namespace Ogre;
38
39  HUD::HUD(void)
40  {
41    init();
42
43    setTime(99,55);
44
45    setTargetWindowName("HURRA");
46    setTargetWindowDistance(12);
47    setTargetWindowStatus("Dead");
48    setTargetWindowDistance(30);
49
50    setEnergyValue(60.0);
51
52    setShieldLeftTopValue(true);
53    setShieldRightTopValue(false);
54    setShieldLeftBottomValue(false);
55    setShieldRightBottomValue(true);
56
57    setRocket1(11);
58    setRocket2(22);
59    setRocket3(33);
60    setRocket4(44);
61
62    setEnergyDistr(33,33,34);
63
64    setPrimar(3);
65
66    energyDistrPixelX_ = 100;
67    energyDistrPixelY_ = 86;
68
69  }
70
71
72  HUD::~HUD( void ){
73
74  }
75
76  void HUD::setTime(int i, int j){
77    timeMin_=i;
78    timeSec_=j;
79    timeText_->setCaption(StringConverter::toString(timeMin_) + ":" + StringConverter::toString(timeSec_));
80  }
81
82  void HUD::setTargetWindowName(std::string i){
83    targetWindowName_=i;
84    targetWindowNameText_->setCaption( targetWindowName_ );
85  }
86
87  void HUD::setTargetWindowStatus(std::string i){
88    targetWindowStatus_=i;
89    targetWindowStatusText_->setCaption( targetWindowStatus_ );
90  }
91
92  void HUD::setTargetWindowDistance(int i){
93    targetWindowDistance_=i;
94    targetWindowDistanceText_->setCaption(StringConverter::toString(targetWindowDistance_) + "km" );
95  }
96
97  void HUD::setTargetWindowHitRating(int i){
98    targetWindowHitRating_=i;
99    targetWindowHitRatingText_->setCaption(StringConverter::toString(targetWindowHitRating_) + "%" );
100  }
101
102  void HUD::setEnergyValue(int i){
103    energyValue_=i;
104    energyLength_->setWidth((int)((float)energyValue_/(float)100*200));
105  }
106
107  void HUD::setShieldLeftTopValue(bool i){
108    shieldLeftTopValue_=i;
109    if (shieldLeftTopValue_) shieldLeftTop_->show();
110    else shieldLeftTop_->hide();
111  }
112
113  void HUD::setShieldRightTopValue(bool i){
114    shieldRightTopValue_=i;
115    if (shieldRightTopValue_) shieldRightTop_->show();
116    else shieldRightTop_->hide();
117  }
118
119  void HUD::setShieldLeftBottomValue(bool i){
120    shieldLeftBottomValue_=i;
121    if (shieldLeftBottomValue_) shieldLeftBottom_->show();
122    else shieldLeftBottom_->hide();
123  }
124
125  void HUD::setShieldRightBottomValue(bool i){
126    shieldRightBottomValue_=i;
127    if (shieldRightBottomValue_) shieldRightBottom_->show();
128    else shieldRightBottom_->hide();
129  }
130
131  void HUD::setRocket1(int i){
132    rocket1_=i;
133    rocketNum1_->setCaption(StringConverter::toString(rocket1_));
134  }
135
136  void HUD::setRocket2(int i){
137    rocket2_=i;
138    rocketNum2_->setCaption(StringConverter::toString(rocket2_));
139  }
140
141  void HUD::setRocket3(int i){
142    rocket3_=i;
143    rocketNum3_->setCaption(StringConverter::toString(rocket3_));
144  }
145
146  void HUD::setRocket4(int i){
147    rocket4_=i;
148    rocketNum4_->setCaption(StringConverter::toString(rocket4_));
149  }
150
151  void HUD::setEnergyDistr(float s, float e, float l){
152    energyDistrShield_=s;
153    energyDistrEngine_=e;
154    energyDistrLaser_=l;
155
156    float energyDistrShieldInv_ = 100 - energyDistrShield_;
157    float energyDistrEngineInv_ = 100 - energyDistrEngine_;
158    float energyDistrLaserInv_ = 100 - energyDistrLaser_;
159
160    float energyDistrT_ = -energyDistrPixelX_/((energyDistrPixelX_-energyDistrPixelX_/2*energyDistrShieldInv_/(energyDistrShieldInv_+energyDistrEngineInv_))*energyDistrLaserInv_*(energyDistrShieldInv_+energyDistrEngineInv_)/energyDistrShieldInv_/(energyDistrLaserInv_+energyDistrEngineInv_)+energyDistrPixelX_/2+energyDistrPixelX_/2*energyDistrEngineInv_/(energyDistrEngineInv_+energyDistrLaserInv_));
161    float energyDistrX_ = (-energyDistrPixelX_/2-energyDistrPixelX_/2*energyDistrEngineInv_/(energyDistrEngineInv_+energyDistrLaserInv_))*energyDistrT_;
162    float energyDistrY_ = energyDistrPixelY_+energyDistrPixelY_*energyDistrLaserInv_/(energyDistrLaserInv_+energyDistrEngineInv_)*energyDistrT_;
163
164    energyDistrPoint_->setLeft((int)energyDistrX_-3);
165    energyDistrPoint_->setTop((int)energyDistrY_-3);
166
167  }
168
169  void HUD::setPrimar(int i){
170    primarValue_=i;
171    if(i==1){
172      primarChoice_->setLeft(2);
173      primarChoice_->setWidth(48);
174    }
175    if(i==2){
176      primarChoice_->setLeft(51);
177      primarChoice_->setWidth(49);
178    }
179    else{
180      primarChoice_->setLeft(101);
181      primarChoice_->setWidth(48);
182    }
183  }
184
185
186
187  void HUD::init(void)
188  {
189    timeText_ = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/Time/Text");
190
191    targetWindowNameText_ = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/TargetWindow/Name");
192    targetWindowDistanceText_ = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/TargetWindow/DistanceText");
193    targetWindowStatusText_ = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/TargetWindow/StatusText");
194    targetWindowHitRatingText_ = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/TargetWindow/HitRatingText");
195
196    energyLength_ = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/EnergyBackground");
197
198    shieldLeftTop_ = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/shieldLeftTop");
199    shieldRightTop_ = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/shieldRightTop");
200    shieldLeftBottom_ = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/shieldLeftBottom");
201    shieldRightBottom_ = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/shieldRightBottom");
202
203    rocketNum1_ = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/RocketNum1");
204    rocketNum2_ = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/RocketNum2");
205    rocketNum3_ = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/RocketNum3");
206    rocketNum4_ = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/RocketNum4");
207
208    // FIXME: unused vars!
209    float energyDistrPixelX_ = 100;
210    float energyDistrPixelY_ = 86;
211    energyDistrPoint_ = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/EnergyDistrPoint");
212
213    primarChoice_ = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/PrimarChoice");
214  }
215
216}
Note: See TracBrowser for help on using the repository browser.