Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/orxonox/hud/HUD.cc @ 840

Last change on this file since 840 was 790, checked in by nicolasc, 17 years ago

merged FICN back into trunk
awaiting release.

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