1 | #include "HUD.h" |
---|
2 | // #include <Ogre.h> |
---|
3 | // #include <OIS/OIS.h> |
---|
4 | //#include <CEGUI/CEGUI.h> |
---|
5 | //#include <CEGUIRenderer.h> |
---|
6 | |
---|
7 | |
---|
8 | using namespace Ogre; |
---|
9 | |
---|
10 | namespace hud { |
---|
11 | HUD::HUD( void ) { |
---|
12 | |
---|
13 | init(); |
---|
14 | |
---|
15 | setTime(99,55); |
---|
16 | |
---|
17 | setTargetWindowName("HURRA"); |
---|
18 | setTargetWindowDistance(12); |
---|
19 | setTargetWindowStatus("Dead"); |
---|
20 | setTargetWindowDistance(30); |
---|
21 | |
---|
22 | setEnergyValue(60.0); |
---|
23 | |
---|
24 | setShieldLeftTopValue(true); |
---|
25 | setShieldRightTopValue(false); |
---|
26 | setShieldLeftBottomValue(false); |
---|
27 | setShieldRightBottomValue(true); |
---|
28 | |
---|
29 | setRocket1(11); |
---|
30 | setRocket2(22); |
---|
31 | setRocket3(33); |
---|
32 | setRocket4(44); |
---|
33 | |
---|
34 | setEnergyDistr(33,33,34); |
---|
35 | |
---|
36 | setPrimar(3); |
---|
37 | |
---|
38 | |
---|
39 | |
---|
40 | energyDistrPixelX_ = 100; |
---|
41 | energyDistrPixelY_ = 86; |
---|
42 | |
---|
43 | } |
---|
44 | |
---|
45 | |
---|
46 | HUD::~HUD( void ){ |
---|
47 | |
---|
48 | } |
---|
49 | |
---|
50 | void HUD::setTime(int i, int j){ |
---|
51 | timeMin_=i; |
---|
52 | timeSec_=j; |
---|
53 | timeText_->setCaption(StringConverter::toString(timeMin_) + ":" + StringConverter::toString(timeSec_)); |
---|
54 | |
---|
55 | } |
---|
56 | void HUD::setTargetWindowName(String i){ |
---|
57 | targetWindowName_=i; |
---|
58 | targetWindowNameText_->setCaption( targetWindowName_ ); |
---|
59 | |
---|
60 | } |
---|
61 | void HUD::setTargetWindowStatus(String i){ |
---|
62 | targetWindowStatus_=i; |
---|
63 | targetWindowStatusText_->setCaption( targetWindowStatus_ ); |
---|
64 | |
---|
65 | } |
---|
66 | void HUD::setTargetWindowDistance(int i){ |
---|
67 | targetWindowDistance_=i; |
---|
68 | targetWindowDistanceText_->setCaption(StringConverter::toString(targetWindowDistance_) + "km" ); |
---|
69 | |
---|
70 | } |
---|
71 | void HUD::setTargetWindowHitRating(int i){ |
---|
72 | targetWindowHitRating_=i; |
---|
73 | targetWindowHitRatingText_->setCaption(StringConverter::toString(targetWindowHitRating_) + "%" ); |
---|
74 | |
---|
75 | } |
---|
76 | void HUD::setEnergyValue(int i){ |
---|
77 | energyValue_=i; |
---|
78 | energyLength_->setWidth((int)((double)energyValue_/(double)100*200)); |
---|
79 | } |
---|
80 | void HUD::setShieldLeftTopValue(bool i){ |
---|
81 | shieldLeftTopValue_=i; |
---|
82 | if (shieldLeftTopValue_) shieldLeftTop_->show(); |
---|
83 | else shieldLeftTop_->hide(); |
---|
84 | } |
---|
85 | void HUD::setShieldRightTopValue(bool i){ |
---|
86 | shieldRightTopValue_=i; |
---|
87 | if (shieldRightTopValue_) shieldRightTop_->show(); |
---|
88 | else shieldRightTop_->hide(); |
---|
89 | } |
---|
90 | void HUD::setShieldLeftBottomValue(bool i){ |
---|
91 | shieldLeftBottomValue_=i; |
---|
92 | if (shieldLeftBottomValue_) shieldLeftBottom_->show(); |
---|
93 | else shieldLeftBottom_->hide(); |
---|
94 | } |
---|
95 | void HUD::setShieldRightBottomValue(bool i){ |
---|
96 | shieldRightBottomValue_=i; |
---|
97 | if (shieldRightBottomValue_) shieldRightBottom_->show(); |
---|
98 | else shieldRightBottom_->hide(); |
---|
99 | } |
---|
100 | void HUD::setRocket1(int i){ |
---|
101 | rocket1_=i; |
---|
102 | rocketNum1_->setCaption(StringConverter::toString(rocket1_)); |
---|
103 | } |
---|
104 | void HUD::setRocket2(int i){ |
---|
105 | rocket2_=i; |
---|
106 | rocketNum2_->setCaption(StringConverter::toString(rocket2_)); |
---|
107 | } |
---|
108 | void HUD::setRocket3(int i){ |
---|
109 | rocket3_=i; |
---|
110 | rocketNum3_->setCaption(StringConverter::toString(rocket3_)); |
---|
111 | } |
---|
112 | void HUD::setRocket4(int i){ |
---|
113 | rocket4_=i; |
---|
114 | rocketNum4_->setCaption(StringConverter::toString(rocket4_)); |
---|
115 | } |
---|
116 | void HUD::setEnergyDistr(double s, double e, double l){ |
---|
117 | energyDistrShield_=s; |
---|
118 | energyDistrEngine_=e; |
---|
119 | energyDistrLaser_=l; |
---|
120 | |
---|
121 | double energyDistrShieldInv_ = 100 - energyDistrShield_; |
---|
122 | double energyDistrEngineInv_ = 100 - energyDistrEngine_; |
---|
123 | double energyDistrLaserInv_ = 100 - energyDistrLaser_; |
---|
124 | |
---|
125 | double energyDistrT_ = -energyDistrPixelX_/((energyDistrPixelX_-energyDistrPixelX_/2*energyDistrShieldInv_/(energyDistrShieldInv_+energyDistrEngineInv_))*energyDistrLaserInv_*(energyDistrShieldInv_+energyDistrEngineInv_)/energyDistrShieldInv_/(energyDistrLaserInv_+energyDistrEngineInv_)+energyDistrPixelX_/2+energyDistrPixelX_/2*energyDistrEngineInv_/(energyDistrEngineInv_+energyDistrLaserInv_)); |
---|
126 | double energyDistrX_ = (-energyDistrPixelX_/2-energyDistrPixelX_/2*energyDistrEngineInv_/(energyDistrEngineInv_+energyDistrLaserInv_))*energyDistrT_; |
---|
127 | double energyDistrY_ = energyDistrPixelY_+energyDistrPixelY_*energyDistrLaserInv_/(energyDistrLaserInv_+energyDistrEngineInv_)*energyDistrT_; |
---|
128 | |
---|
129 | energyDistrPoint_->setLeft((int)energyDistrX_-3); |
---|
130 | energyDistrPoint_->setTop((int)energyDistrY_-3); |
---|
131 | |
---|
132 | } |
---|
133 | |
---|
134 | void HUD::setPrimar(int i){ |
---|
135 | primarValue_=i; |
---|
136 | if(i==1){ |
---|
137 | primarChoice_->setLeft(2); |
---|
138 | primarChoice_->setWidth(48); |
---|
139 | } |
---|
140 | if(i==2){ |
---|
141 | primarChoice_->setLeft(51); |
---|
142 | primarChoice_->setWidth(49); |
---|
143 | } |
---|
144 | else{ |
---|
145 | primarChoice_->setLeft(101); |
---|
146 | primarChoice_->setWidth(48); |
---|
147 | } |
---|
148 | } |
---|
149 | |
---|
150 | |
---|
151 | |
---|
152 | void HUD::init(void) |
---|
153 | { |
---|
154 | timeText_ = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/Time/Text"); |
---|
155 | |
---|
156 | targetWindowNameText_ = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/TargetWindow/Name"); |
---|
157 | targetWindowDistanceText_ = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/TargetWindow/DistanceText"); |
---|
158 | targetWindowStatusText_ = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/TargetWindow/StatusText"); |
---|
159 | targetWindowHitRatingText_ = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/TargetWindow/HitRatingText"); |
---|
160 | |
---|
161 | energyLength_ = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/EnergyBackground"); |
---|
162 | |
---|
163 | shieldLeftTop_ = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/shieldLeftTop"); |
---|
164 | shieldRightTop_ = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/shieldRightTop"); |
---|
165 | shieldLeftBottom_ = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/shieldLeftBottom"); |
---|
166 | shieldRightBottom_ = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/shieldRightBottom"); |
---|
167 | |
---|
168 | rocketNum1_ = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/RocketNum1"); |
---|
169 | rocketNum2_ = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/RocketNum2"); |
---|
170 | rocketNum3_ = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/RocketNum3"); |
---|
171 | rocketNum4_ = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/RocketNum4"); |
---|
172 | |
---|
173 | double energyDistrPixelX_ = 100; |
---|
174 | double energyDistrPixelY_ = 86; |
---|
175 | energyDistrPoint_ = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/EnergyDistrPoint"); |
---|
176 | |
---|
177 | primarChoice_ = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/PrimarChoice"); |
---|
178 | |
---|
179 | |
---|
180 | } |
---|
181 | |
---|
182 | |
---|
183 | } |
---|