Changeset 6412 for code/branches/pickup2/src/modules/overlays
- Timestamp:
- Dec 25, 2009, 1:18:03 PM (15 years ago)
- Location:
- code/branches/pickup2
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/pickup2
- Property svn:mergeinfo changed
-
code/branches/pickup2/src/modules/overlays/GUIOverlay.cc
r5781 r6412 64 64 65 65 //Setting player now. 66 GUIManager::getInstance().setPlayer(this->guiName_, (orxonox_cast<ControllableEntity*>(this->getOwner()))->getPlayer()); 66 if( this->getOwner() ) 67 GUIManager::getInstance().setPlayer(this->guiName_, (orxonox_cast<ControllableEntity*>(this->getOwner()))->getPlayer()); 67 68 68 69 if (this->isVisible()) 69 70 { 70 std::string str; 71 std::stringstream out; 71 std::ostringstream out; 72 72 out << reinterpret_cast<long>(this); 73 str = out.str(); 74 GUIManager::getInstance().executeCode("showCursor()"); 75 InputManager::getInstance().enterState("guiMouseOnly"); 76 GUIManager::getInstance().executeCode("showGUI(\"" + this->guiName_ + "\", " + str + ")"); 73 const std::string& str = out.str(); 74 COUT(1) << "GUIManager ptr: " << str << std::endl; 75 GUIManager::getInstance().showGUIExtra(this->guiName_, str); 76 77 COUT(3) << "Showing GUI " << this->guiName_ << std::endl; 77 78 } 78 79 else 79 80 { 80 GUIManager::getInstance().executeCode("hideGUI(\"" + this->guiName_ + "\")"); 81 GUIManager::getInstance().executeCode("hideCursor()"); 82 InputManager::getInstance().leaveState("guiMouseOnly"); 81 GUIManager::hideGUI(this->guiName_); 82 COUT(3) << "Hiding GUI " << this->guiName_ << std::endl; 83 83 } 84 84 } -
code/branches/pickup2/src/modules/overlays/OverlayText.cc
r5781 r6412 134 134 void OverlayText::setFont(const std::string& font) 135 135 { 136 if ( font != "")136 if (!font.empty()) 137 137 this->text_->setFontName(font); 138 138 } -
code/branches/pickup2/src/modules/overlays/hud/ChatOverlay.cc
r5929 r6412 33 33 34 34 #include "util/Convert.h" 35 #include "util/ UTFStringConversions.h"35 #include "util/DisplayStringConversions.h" 36 36 #include "core/CoreIncludes.h" 37 37 #include "core/ConfigValueIncludes.h" … … 86 86 } 87 87 88 this->messages_.push_back(multi_cast<Ogre:: UTFString>(text));88 this->messages_.push_back(multi_cast<Ogre::DisplayString>(text)); 89 89 COUT(0) << "Chat: " << text << std::endl; 90 90 … … 110 110 this->text_->setCaption(""); 111 111 112 for (std::list<Ogre:: UTFString>::reverse_iterator it = this->messages_.rbegin(); it != this->messages_.rend(); ++it)112 for (std::list<Ogre::DisplayString>::reverse_iterator it = this->messages_.rbegin(); it != this->messages_.rend(); ++it) 113 113 { 114 114 this->text_->setCaption(this->text_->getCaption() + "\n" + (*it)); -
code/branches/pickup2/src/modules/overlays/hud/ChatOverlay.h
r5929 r6412 33 33 34 34 #include <list> 35 #include <Ogre UTFString.h>35 #include <OgreOverlayElement.h> 36 36 37 37 #include "network/ChatListener.h" … … 51 51 virtual void incomingChat(const std::string& message, unsigned int senderID); 52 52 53 std::list<Ogre:: UTFString> messages_;53 std::list<Ogre::DisplayString> messages_; 54 54 55 55 private: -
code/branches/pickup2/src/modules/overlays/hud/HUDBar.cc
r5929 r6412 67 67 68 68 HUDBar::HUDBar(BaseObject* creator) 69 : OrxonoxOverlay(creator) 69 : OrxonoxOverlay(creator), right2Left_(false), autoColour_(false) 70 70 { 71 71 RegisterObject(HUDBar); 72 72 73 73 // create new material 74 std::stringmaterialname = "barmaterial" + multi_cast<std::string>(materialcount_s++);74 const std::string& materialname = "barmaterial" + multi_cast<std::string>(materialcount_s++); 75 75 Ogre::MaterialPtr material = static_cast<Ogre::MaterialPtr>(Ogre::MaterialManager::getSingleton().create(materialname, "General")); 76 76 material->getTechnique(0)->getPass(0)->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA); … … 85 85 86 86 this->value_ = 1.0f; // initielize with 1.0f to trigger a change when calling setValue(0.0f) on the line below 87 this->setAutoColour(true); 87 88 this->setValue(0.0f); // <-- 88 89 this->setRightToLeft(false); 89 this->setAutoColour(true);90 90 this->currentColour_ = ColourValue::White; 91 91 … … 122 122 { 123 123 ColourValue colour1(0, 0, 0, 1); 124 ColourValue colour2 = (*this->colours_.rbegin()).second;124 ColourValue colour2 = this->colours_.rbegin()->second; 125 125 float value1(0); 126 float value2 = (*this->colours_.rbegin()).first;126 float value2 = this->colours_.rbegin()->first; 127 127 for (std::map<float, ColourValue>::reverse_iterator it = this->colours_.rbegin(); it != this->colours_.rend(); ++it) 128 128 { 129 129 colour1 = colour2; 130 130 value1 = value2; 131 colour2 = (*it).second;132 value2 = (*it).first;131 colour2 = it->second; 132 value2 = it->first; 133 133 134 134 if (value2 < this->value_) -
code/branches/pickup2/src/modules/overlays/hud/HUDHealthBar.cc
r5929 r6412 48 48 this->textoverlay_ = new OverlayText(this); 49 49 50 assert(this->textoverlay_ );50 assert(this->textoverlay_.get()); 51 51 52 52 this->textoverlay_->setCaption(""); … … 56 56 { 57 57 if (this->isInitialized()) 58 { 58 59 this->textoverlay_->destroy(); 60 this->textoverlay_ = 0; 61 } 59 62 } 60 63 … … 106 109 SUPER(HUDHealthBar, changedOverlayGroup); 107 110 108 this->getOverlayGroup()->addElement(this->textoverlay_ );111 this->getOverlayGroup()->addElement(this->textoverlay_.get()); 109 112 } 110 113 -
code/branches/pickup2/src/modules/overlays/hud/HUDHealthBar.h
r5929 r6412 53 53 54 54 inline void setTextFont(const std::string& font) 55 { if ( font != "") { this->textoverlay_->setFont(font); } }55 { if (!font.empty()) { this->textoverlay_->setFont(font); } } 56 56 inline const std::string& getTextFont() const 57 57 { return this->textoverlay_->getFont(); } … … 112 112 private: 113 113 WeakPtr<Pawn> owner_; 114 OverlayText*textoverlay_;114 SmartPtr<OverlayText> textoverlay_; 115 115 bool bUseBarColour_; 116 116 ColourValue textColour_; -
code/branches/pickup2/src/modules/overlays/hud/HUDNavigation.cc
r5929 r6412 30 30 31 31 #include <string> 32 #include <OgreCamera.h> 32 33 #include <OgreOverlayManager.h> 33 34 #include <OgreTextAreaOverlayElement.h> … … 35 36 36 37 #include "util/Math.h" 37 #include "util/StringUtils.h"38 38 #include "util/Convert.h" 39 39 #include "core/CoreIncludes.h" 40 40 #include "core/XMLPort.h" 41 #include "CameraManager.h" 41 42 #include "Scene.h" 42 43 #include "Radar.h" 44 #include "graphics/Camera.h" 45 #include "controllers/HumanController.h" 46 #include "worldentities/pawns/Pawn.h" 43 47 44 48 namespace orxonox … … 60 64 navMarker_->setMaterialName("Orxonox/NavArrows"); 61 65 66 /* 62 67 // create aim marker 63 68 aimMarker_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton() … … 70 75 setNavMarkerSize(0.05f); 71 76 setAimMarkerSize(0.04f); 77 */ 72 78 73 79 background_->addChild(navMarker_); 74 background_->addChild(aimMarker_);80 // background_->addChild(aimMarker_); 75 81 background_->addChild(navText_); 76 82 … … 85 91 Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->navMarker_); 86 92 Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->navText_); 87 Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->aimMarker_);93 // Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->aimMarker_); 88 94 } 89 95 } … … 96 102 XMLPortParam(HUDNavigation, "textSize", setTextSize, getTextSize, xmlElement, mode); 97 103 XMLPortParam(HUDNavigation, "navMarkerSize", setNavMarkerSize, getNavMarkerSize, xmlElement, mode); 98 XMLPortParam(HUDNavigation, "aimMarkerSize", setAimMarkerSize, getAimMarkerSize, xmlElement, mode);104 // XMLPortParam(HUDNavigation, "aimMarkerSize", setAimMarkerSize, getAimMarkerSize, xmlElement, mode); 99 105 } 100 106 101 107 void HUDNavigation::setFont(const std::string& font) 102 108 { 103 if (this->navText_ && font != "")109 if (this->navText_ && !font.empty()) 104 110 this->navText_->setFontName(font); 105 111 } … … 149 155 float textLength = multi_cast<std::string>(dist).size() * navText_->getCharHeight() * 0.3; 150 156 151 /* 152 Ogre::Camera* navCam = SpaceShip::getLocalShip()->getCamera()->cam_;153 Matrix4 transformationMatrix = navCam->getProjectionMatrix() * navCam->getViewMatrix();154 */ 157 orxonox::Camera* cam = CameraManager::getInstance().getActiveCamera(); 158 if (!cam) 159 return; 160 const Matrix4& transform = cam->getOgreCamera()->getProjectionMatrix() * cam->getOgreCamera()->getViewMatrix(); 155 161 // transform to screen coordinates 156 Vector3 pos = /*transformationMatrix * */radar->getFocus()->getRVWorldPosition();162 Vector3 pos = transform * radar->getFocus()->getRVWorldPosition(); 157 163 158 164 bool outOfView; … … 172 178 { 173 179 // object is not in view 174 aimMarker_->hide();180 // aimMarker_->hide(); 175 181 176 182 if (!wasOutOfView_) … … 227 233 // object is in view 228 234 /* 229 Vector3 aimpos = transform ationMatrix* getPredictedPosition(SpaceShip::getLocalShip()->getPosition(),235 Vector3 aimpos = transform * getPredictedPosition(SpaceShip::getLocalShip()->getPosition(), 230 236 Projectile::getSpeed(), Radar::getInstance().getFocus()->getRVWorldPosition(), Radar::getInstance().getFocus()->getRVOrientedVelocity()); 231 237 */ … … 241 247 navMarker_->setTop((-pos.y + 1.0 - navMarker_->getHeight()) * 0.5); 242 248 249 /* 243 250 aimMarker_->show(); 244 /*245 251 aimMarker_->setLeft((aimpos.x + 1.0 - aimMarker_->getWidth()) * 0.5); 246 252 aimMarker_->setTop((-aimpos.y + 1.0 - aimMarker_->getHeight()) * 0.5); … … 253 259 float HUDNavigation::getDist2Focus() const 254 260 { 255 /* 256 if (Radar::getInstance().getFocus()) 257 return (Radar::getInstance().getFocus()->getRVWorldPosition() - SpaceShip::getLocalShip()->getPosition()).length(); 258 else 259 */ 261 Radar* radar = this->getOwner()->getScene()->getRadar(); 262 if (radar->getFocus() && HumanController::getLocalControllerEntityAsPawn()) 263 return (radar->getFocus()->getRVWorldPosition() - HumanController::getLocalControllerEntityAsPawn()->getWorldPosition()).length(); 264 else 260 265 return 0; 261 266 } … … 267 272 void HUDNavigation::sizeChanged() 268 273 { 269 // use size to compensate for a pspect ratio if enabled.274 // use size to compensate for aspect ratio if enabled. 270 275 float xScale = this->getActualSize().x; 271 276 float yScale = this->getActualSize().y; 272 277 if (this->navMarker_) 273 278 navMarker_->setDimensions(navMarkerSize_ * xScale, navMarkerSize_ * yScale); 279 /* 274 280 if (this->aimMarker_) 275 281 aimMarker_->setDimensions(aimMarkerSize_ * xScale, aimMarkerSize_ * yScale); 282 */ 276 283 if (this->navText_) 277 284 navText_->setCharHeight(navText_->getCharHeight() * yScale); -
code/branches/pickup2/src/modules/overlays/hud/HUDNavigation.h
r5781 r6412 56 56 float getNavMarkerSize() const { return this->navMarkerSize_; } 57 57 58 /* 58 59 void setAimMarkerSize(float size) { this->aimMarkerSize_ = size; this->sizeChanged(); } 59 60 float getAimMarkerSize() const { return this->aimMarkerSize_; } 61 */ 60 62 61 63 void setTextSize(float size); … … 71 73 Ogre::PanelOverlayElement* navMarker_; //!< the panel used to show the arrow and the target marker 72 74 float navMarkerSize_; //!< One paramter size of the navigation marker 75 /* 73 76 Ogre::PanelOverlayElement* aimMarker_; //!< Panel used to show the aim Marker 74 77 float aimMarkerSize_; //!< One paramter size of the aim marker 78 */ 75 79 Ogre::TextAreaOverlayElement* navText_; //!< Text overlay to display the target distance 76 80 bool wasOutOfView_; //!< Performance booster variable: setMaterial is not cheap -
code/branches/pickup2/src/modules/overlays/hud/HUDRadar.cc
r5781 r6412 126 126 panel = *itRadarDots_; 127 127 ++itRadarDots_; 128 std::stringmaterialName = TextureGenerator::getMaterialName(128 const std::string& materialName = TextureGenerator::getMaterialName( 129 129 shapeMaterials_[object->getRadarObjectShape()], object->getRadarObjectColour()); 130 130 if (materialName != panel->getMaterialName()) -
code/branches/pickup2/src/modules/overlays/hud/TeamBaseMatchScore.cc
r5929 r6412 71 71 if (this->owner_) 72 72 { 73 std::string bases1 = "(" + multi_cast<std::string>(this->owner_->getTeamBases(0)) + ")";74 std::string bases2 = "(" + multi_cast<std::string>(this->owner_->getTeamBases(1)) + ")";73 const std::string& bases1 = '(' + multi_cast<std::string>(this->owner_->getTeamBases(0)) + ')'; 74 const std::string& bases2 = '(' + multi_cast<std::string>(this->owner_->getTeamBases(1)) + ')'; 75 75 76 std::stringscore1 = multi_cast<std::string>(this->owner_->getTeamPoints(0));77 std::stringscore2 = multi_cast<std::string>(this->owner_->getTeamPoints(1));76 const std::string& score1 = multi_cast<std::string>(this->owner_->getTeamPoints(0)); 77 const std::string& score2 = multi_cast<std::string>(this->owner_->getTeamPoints(1)); 78 78 79 79 std::string output1; … … 99 99 } 100 100 101 std::string output = "";101 std::string output; 102 102 if (this->bShowBases_ || this->bShowScore_) 103 103 { 104 104 if (this->bShowLeftTeam_ && this->bShowRightTeam_) 105 output = output1 + ":"+ output2;105 output = output1 + ':' + output2; 106 106 else if (this->bShowLeftTeam_ || this->bShowRightTeam_) 107 107 output = output1 + output2; -
code/branches/pickup2/src/modules/overlays/hud/UnderAttackHealthBar.cc
r5929 r6412 34 34 #include "gametypes/UnderAttack.h" 35 35 #include "worldentities/pawns/Destroyer.h" 36 #include "overlays/OverlayGroup.h" 36 37 37 38 namespace orxonox … … 58 59 { 59 60 if (this->isInitialized()) 61 { 60 62 this->text_->destroy(); 63 this->text_ = 0; 64 } 61 65 } 62 66 … … 91 95 } 92 96 97 void UnderAttackHealthBar::changedOverlayGroup() 98 { 99 SUPER(UnderAttackHealthBar, changedOverlayGroup); 100 101 this->getOverlayGroup()->addElement(this->text_.get()); 102 } 103 93 104 void UnderAttackHealthBar::init() 94 105 { -
code/branches/pickup2/src/modules/overlays/hud/UnderAttackHealthBar.h
r5929 r6412 46 46 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 47 47 virtual void changedOwner(); 48 virtual void changedOverlayGroup(); 48 49 49 50 inline void setDescriptionPickPoint(const Vector2& pickpoint) … … 61 62 62 63 PlayerInfo* owner_; 63 OverlayText*text_;64 SmartPtr<OverlayText> text_; 64 65 Timer inittimer_; 65 66 }; -
code/branches/pickup2/src/modules/overlays/stats/CreateLines.cc
r5929 r6412 87 87 this->background_->setVisible(visible); 88 88 } 89 void CreateLines::changedVisibility() 90 { 91 this->scoreText_->changedVisibility(); 92 this->deathsText_->changedVisibility(); 93 this->playerNameText_->changedVisibility(); 94 this->background_->changedVisibility(); 95 } 96 97 void CreateLines::setOverlayGroup( OverlayGroup* group ) 98 { 99 this->scoreText_->setOverlayGroup( group ); 100 this->deathsText_->setOverlayGroup( group ); 101 this->playerNameText_->setOverlayGroup( group ); 102 this->background_->setOverlayGroup( group ); 103 } 89 104 90 105 /** -
code/branches/pickup2/src/modules/overlays/stats/CreateLines.h
r5781 r6412 44 44 45 45 void setVisibility(bool); 46 void changedVisibility(); 47 void setOverlayGroup( OverlayGroup* group ); 46 48 47 49 //void setNumberOfColumns(unsigned int numberOfColumns, unsigned int lineIndex); -
code/branches/pickup2/src/modules/overlays/stats/Scoreboard.cc
r5929 r6412 69 69 70 70 for (unsigned int i = 0; i < this->lines_.size(); ++i) 71 this->lines_[i]-> setVisibility(this->isVisible());71 this->lines_[i]->changedVisibility(); 72 72 } 73 73 … … 89 89 CreateLines* lines = new CreateLines(leftOffset, topOffset + (distance + height) * lines_.size(), width, height); 90 90 lines->setVisibility(this->isVisible()); 91 lines->setOverlayGroup( this->getOverlayGroup() ); 91 92 this->lines_.push_back(lines); 92 93 }
Note: See TracChangeset
for help on using the changeset viewer.