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