Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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