Changeset 11052 for code/trunk/src/modules/overlays
- Timestamp:
- Jan 9, 2016, 6:26:20 PM (9 years ago)
- Location:
- code/trunk
- Files:
-
- 9 edited
- 12 copied
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/modules/overlays/OverlaysPrereqs.h
r9939 r11052 90 90 class HUDRadar; 91 91 class HUDSpeedBar; 92 class HUDShieldBar; 92 93 class HUDBoostBar; 94 class HUDRocketFuelBar; 95 class HUDEnemyHealthBar; 96 class HUDEnemyShieldBar; 97 class HUDWeaponSystem; 98 class HUDWeapon; 99 class HUDWeaponMode; 93 100 class HUDTimer; 94 101 class HUDAimAssistant; -
code/trunk/src/modules/overlays/hud/CMakeLists.txt
r9939 r11052 5 5 HUDSpeedBar.cc 6 6 HUDBoostBar.cc 7 HUDShieldBar.cc 7 8 HUDHealthBar.cc 9 HUDRocketFuelBar.cc 8 10 HUDTimer.cc 9 11 HUDEnemyHealthBar.cc 12 HUDEnemyShieldBar.cc 13 HUDWeaponMode.cc 14 HUDWeapon.cc 15 HUDWeaponSystem.cc 10 16 ChatOverlay.cc 11 17 AnnounceMessage.cc -
code/trunk/src/modules/overlays/hud/HUDBar.cc
r9667 r11052 47 47 RegisterClass(BarColour); 48 48 49 BarColour::BarColour(Context* context) 50 : BaseObject(context) 49 BarColour::BarColour(Context* context) : BaseObject(context) 51 50 { 52 51 RegisterObject(BarColour); 53 52 54 53 this->setColour(ColourValue(1.0, 1.0, 1.0, 1.0)); 55 54 this->setPosition(0.0); … … 69 68 RegisterClass(HUDBar); 70 69 71 HUDBar::HUDBar(Context* context) 72 : OrxonoxOverlay(context), right2Left_(false), autoColour_(false) 70 HUDBar::HUDBar(Context* context) : OrxonoxOverlay(context), right2Left_(false), autoColour_(false) 73 71 { 74 72 RegisterObject(HUDBar); … … 88 86 this->bar_->setMaterialName(materialname); 89 87 88 this->bar_->setPosition(0.0f,0.0f); 89 this->bar_->setDimensions(1.0f,1.0f); 90 91 this->bUseIcon_ = false; 90 92 this->value_ = 1.0f; // initialize with 1.0f to trigger a change when calling setValue(0.0f) on the line below 91 93 this->setAutoColour(true); … … 95 97 96 98 this->background_->addChild(bar_); 99 100 this->icon_ = static_cast<Ogre::PanelOverlayElement* >(Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", "HUDBar_icon_" + getUniqueNumberString())); 101 this->icon_->setPosition(0.06f,0.0f); 102 this->icon_->setDimensions(0.1f,1.0f); 103 this->background_->addChild(this->icon_); 97 104 } 98 105 … … 115 122 XMLPortParam(HUDBar, "autocolour", setAutoColour, getAutoColour, xmlelement, mode); 116 123 XMLPortParam(HUDBar, "bartexture", setBarTexture, getBarTexture, xmlelement, mode); 124 XMLPortParam(HUDBar, "iconmaterial", setIconMaterial, getIconMaterial, xmlelement, mode); 117 125 XMLPortObject(HUDBar, BarColour, "", addColour, getColour, xmlelement, mode); 118 126 } … … 161 169 } 162 170 171 float height = this->bar_->getHeight(); 172 float top = this->bar_->getTop(); 173 163 174 // set value 164 175 if (this->right2Left_) 165 176 { 166 177 // backward case 167 this->bar_->setPosition(0.06f + 0.88f * (1 - this->value_), 0.0f); 168 this->bar_->setDimensions(0.88f * this->value_, 1.0f); 178 if (this->bUseIcon_) 179 { 180 this->bar_->setPosition(0.16f + 0.78f * (1 - this->value_), top); 181 this->bar_->setDimensions(0.78f * this->value_, height); 182 } 183 else 184 { 185 this->bar_->setPosition(0.06f + 0.88f * (1 - this->value_), top); 186 this->bar_->setDimensions(0.88f * this->value_, height); 187 } 169 188 } 170 189 else 171 190 { 172 191 // default case 173 this->bar_->setPosition(0.06f, 0.0f); 174 this->bar_->setDimensions(0.88f * this->value_, 1.0f); 175 } 192 if (this->bUseIcon_) 193 { 194 this->bar_->setPosition(0.16f, top); 195 this->bar_->setDimensions(0.78f * this->value_, height); 196 } 197 else 198 { 199 this->bar_->setPosition(0.06f, top); 200 this->bar_->setDimensions(0.88f * this->value_, height); 201 } 202 } 203 176 204 if (this->value_ != 0) 177 205 this->bar_->setTiling(this->value_, 1.0); … … 208 236 return this->textureUnitState_->getTextureName(); 209 237 } 238 239 void HUDBar::setIconMaterial(const std::string& iconMaterial) 240 { 241 this->bUseIcon_ = true; 242 this->icon_->setMaterialName(iconMaterial); 243 valueChanged(); 244 } 245 246 const std::string& HUDBar::getIconMaterial() const 247 { 248 return this->icon_->getMaterialName(); 249 } 210 250 } -
code/trunk/src/modules/overlays/hud/HUDBar.h
r9667 r11052 37 37 #include <map> 38 38 #include <vector> 39 #include <OgrePanelOverlayElement.h> 39 40 40 41 #include "util/Math.h" … … 51 52 virtual ~BarColour() { } 52 53 53 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 54 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 54 55 55 56 void setColour(const ColourValue& colour) { this->colour_ = colour; } … … 115 116 const std::string& getBarTexture() const; 116 117 118 void setIconMaterial(const std::string& iconMaterial); 119 const std::string& getIconMaterial() const; 120 117 121 inline const ColourValue& getCurrentBarColour() const 118 122 { return this->currentColour_; } 119 123 124 inline void setIconPosition(Vector2 position) 125 { this->icon_->setPosition(position.x, position.y); } 126 inline void setIconDimensions(Vector2 dimensions) 127 { this->icon_->setDimensions(dimensions.x, dimensions.y); } 128 120 129 protected: 121 130 virtual void valueChanged(); 122 123 131 private: 124 132 void addColour(BarColour* colour); … … 129 137 float value_; //!< progress of bar 130 138 ColourValue currentColour_; 139 bool bUseIcon_; 131 140 132 141 Ogre::PanelOverlayElement* bar_; 133 142 Ogre::TextureUnitState* textureUnitState_; 143 Ogre::PanelOverlayElement* icon_; 134 144 std::map<float, ColourValue> colours_; 135 145 std::vector<BarColour*> barColours_; -
code/trunk/src/modules/overlays/hud/HUDBoostBar.cc
r9667 r11052 59 59 if (this->owner_->isBoostCoolingDown()) 60 60 { 61 this->setBackgroundColour(ColourValue(0.7f, 0.2f, 0.2f));61 //this->setBackgroundColour(ColourValue(0.7f, 0.2f, 0.2f)); 62 62 if (this->flashDt_ <= 0.0f) 63 63 { … … 72 72 this->flashDt_ = 0.0f; 73 73 this->show(); 74 this->setBackgroundColour(ColourValue(0.2f, 0.7f, 0.2f));74 //this->setBackgroundColour(ColourValue(0.2f, 0.7f, 0.2f)); 75 75 } 76 76 -
code/trunk/src/modules/overlays/hud/HUDHealthBar.cc
r9667 r11052 45 45 this->owner_ = 0; 46 46 this->bUseBarColour_ = false; 47 this->textOffset_ = Vector2(0.0f, 0.0f); 48 this->textScale_ = 1.0f; 49 50 this->setIconPosition(Vector2(0.05f,0.5f)); 51 this->setIconDimensions(Vector2(0.1f,0.5f)); 47 52 48 53 this->textoverlay_ = new OverlayText(this->getContext()); … … 51 56 52 57 this->textoverlay_->setCaption(""); 58 this->textoverlay_->setAspectCorrection(false); 59 60 positionText(); 53 61 } 54 62 … … 58 66 { 59 67 this->textoverlay_->destroy(); 60 this->textoverlay_ = 0;68 this->textoverlay_ = NULL; 61 69 } 62 70 } … … 70 78 XMLPortParam(HUDHealthBar, "textusebarcolour", setTextUseBarColour, getTextUseBarColour, xmlelement, mode).defaultValues(false); 71 79 XMLPortParam(HUDHealthBar, "textcolour", setTextColour, getTextColour, xmlelement, mode).defaultValues(ColourValue(1.0, 1.0, 1.0, 1.0)); 72 XMLPortParam(HUDHealthBar, "textsize", setTextSize, getTextSize, xmlelement, mode).defaultValues(1.0f);73 80 XMLPortParam(HUDHealthBar, "textalign", setTextAlignmentString, getTextAlignmentString, xmlelement, mode).defaultValues("left"); 74 81 XMLPortParam(HUDHealthBar, "textoffset", setTextOffset, getTextOffset, xmlelement, mode).defaultValues(Vector2::ZERO); 82 XMLPortParam(HUDHealthBar, "textscale", setTextScale, getTextScale, xmlelement, mode).defaultValues(1.0f); 75 83 XMLPortParam(HUDHealthBar, "textpickpoint", setTextPickPoint, getTextPickPoint, xmlelement, mode).defaultValues(Vector2::ZERO); 76 84 XMLPortParam(HUDHealthBar, "textrotation", setTextRotation, getTextRotation, xmlelement, mode).defaultValues(0.0f); 77 XMLPortParam(HUDHealthBar, "textcorrectaspect", setTextAspectCorrection, getTextAspectCorrection, xmlelement, mode).defaultValues(true);78 85 XMLPortParam(HUDHealthBar, "textspacewidth", setTextSpaceWidth, getTextSpaceWidth, xmlelement, mode).defaultValues(true); 79 86 } … … 139 146 this->textoverlay_->setColour(this->textColour_); 140 147 } 148 149 void HUDHealthBar::positionText() 150 { 151 this->textoverlay_->setPosition(this->getPosition() + this->textOffset_*this->getActualSize()); 152 this->textoverlay_->setTextSize(this->getActualSize().y*this->textScale_); 153 } 154 155 void HUDHealthBar::positionChanged() 156 { 157 HUDBar::positionChanged(); 158 positionText(); 159 } 160 161 void HUDHealthBar::sizeChanged() 162 { 163 HUDBar::sizeChanged(); 164 positionText(); 165 } 141 166 } -
code/trunk/src/modules/overlays/hud/HUDHealthBar.h
r10624 r11052 75 75 { return this->textoverlay_->getAlignmentString(); } 76 76 77 inline void setTextSize(float size)78 { this->textoverlay_->setTextSize(size); }79 inline float getTextSize() const80 { return this->textoverlay_->getTextSize(); }81 82 77 inline void setTextVisible(bool bVisible) 83 78 { this->textoverlay_->setVisible(bVisible); } 84 79 inline bool getTextVisible() const 85 80 { return this->textoverlay_->isVisible(); } 81 82 inline void setTextScale(float scale) 83 { this->textScale_ = scale; 84 positionText(); 85 } 86 inline float getTextScale() const 87 { return this->textScale_; } 86 88 87 89 inline void setTextPickPoint(const Vector2& pickpoint) … … 91 93 92 94 inline void setTextOffset(const Vector2& position) 93 { this->textoverlay_->setPosition(this->getPosition() + (position - this->getPickPoint()) * this->getSize()); } 95 { this->textOffset_ = position; 96 this->positionText(); 97 } 94 98 inline Vector2 getTextOffset() const 95 { return (this->textoverlay_->getPosition() - this->getPosition()) / this->getSize() + this->getPickPoint(); } 96 97 inline void setTextAspectCorrection(bool correct) 98 { this->textoverlay_->setAspectCorrection(correct); } 99 inline bool getTextAspectCorrection() const 100 { return this->textoverlay_->getAspectCorrection(); } 99 { return this->textOffset_; } 101 100 102 101 inline void setTextRotation(const Degree& angle) … … 112 111 inline void setHealthBarOwner(Pawn* owner) 113 112 { this->owner_ = owner; } 114 113 protected: 114 virtual void positionChanged(); 115 virtual void sizeChanged(); 115 116 private: 117 virtual void positionText(); 116 118 WeakPtr<Pawn> owner_; 117 119 StrongPtr<OverlayText> textoverlay_; 118 120 bool bUseBarColour_; 119 121 ColourValue textColour_; 122 Vector2 textOffset_; 123 float textScale_; 120 124 }; 121 125 } -
code/trunk/src/modules/overlays/hud/HUDRadar.cc
r9945 r11052 240 240 } 241 241 else 242 coord = get2DView coordinates(this->owner_->getPosition(), this->owner_->getOrientation() * WorldEntity::FRONT, this->owner_->getOrientation() * WorldEntity::UP, wePointer->getWorldPosition());242 coord = get2DViewCoordinates(this->owner_->getPosition(), this->owner_->getOrientation() * WorldEntity::FRONT, this->owner_->getOrientation() * WorldEntity::UP, wePointer->getWorldPosition()); 243 243 244 244 coord *= math::pi / 3.5f; // small adjustment to make it fit the texture
Note: See TracChangeset
for help on using the changeset viewer.