- Timestamp:
- Dec 25, 2009, 1:18:03 PM (15 years ago)
- Location:
- code/branches/pickup2
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/pickup2
- Property svn:mergeinfo changed
-
code/branches/pickup2/src/orxonox/overlays/OrxonoxOverlay.cc
r5781 r6412 39 39 #include <OgrePanelOverlayElement.h> 40 40 #include <OgreRenderWindow.h> 41 #include <OgreMaterialManager.h> 42 #include <OgreTechnique.h> 43 #include <OgrePass.h> 41 44 42 45 #include "util/Convert.h" 43 46 #include "util/Exception.h" 44 #include "util/StringUtils.h"45 47 #include "core/GameMode.h" 46 48 #include "core/CoreIncludes.h" 47 49 #include "core/XMLPort.h" 48 50 #include "core/ConsoleCommand.h" 51 52 #include "OverlayGroup.h" 49 53 50 54 namespace orxonox … … 81 85 // Get aspect ratio from the render window. Later on, we get informed automatically 82 86 this->windowAspectRatio_ = static_cast<float>(this->getWindowWidth()) / this->getWindowHeight(); 83 this->sizeCorrectionChanged(); 84 85 this-> changedVisibility();86 87 setSize(Vector2(1.0f, 1.0f));88 setPickPoint(Vector2(0.0f, 0.0f));89 setPosition(Vector2(0.0f, 0.0f));90 setRotation(Degree(0.0));91 setAspectCorrection(false); 87 88 this->size_ = Vector2(1.0f, 1.0f); 89 this->pickPoint_= Vector2(0.0f, 0.0f); 90 this->position_ = Vector2(0.0f, 0.0f); 91 this->angle_ = Degree(0.0); 92 this->bCorrectAspect_ = false; 93 this->rotState_ = Horizontal; 94 this->angleChanged(); // updates all other values as well 95 92 96 setBackgroundMaterial(""); 93 97 } … … 141 145 142 146 if (OrxonoxOverlay::overlays_s.find(this->getName()) != OrxonoxOverlay::overlays_s.end()) 143 COUT(1) << "Overlay names should be unique or you cannnot access them via console. Name: \"" << this->getName() << "\""<< std::endl;147 COUT(1) << "Overlay names should be unique or you cannnot access them via console. Name: \"" << this->getName() << '"' << std::endl; 144 148 145 149 OrxonoxOverlay::overlays_s[this->getName()] = this; … … 149 153 void OrxonoxOverlay::setBackgroundMaterial(const std::string& material) 150 154 { 151 if (this->background_ && material != "")155 if (this->background_ && !material.empty()) 152 156 this->background_->setMaterialName(material); 153 157 } … … 165 169 void OrxonoxOverlay::changedVisibility() 166 170 { 171 SUPER( OrxonoxOverlay, changedVisibility ); 172 167 173 if (!this->overlay_) 168 174 return; 169 175 170 if (this->isVisible()) 176 // only set to visible if corresponding OverlayGroup is also visible 177 if (this->isVisible() && (!this->getOverlayGroup() || this->getOverlayGroup()->isVisible()) ) 171 178 this->overlay_->show(); 172 179 else … … 304 311 std::map<std::string, OrxonoxOverlay*>::const_iterator it = overlays_s.find(name); 305 312 if (it != overlays_s.end()) 306 (*it).second->scale(Vector2(scale, scale));313 it->second->scale(Vector2(scale, scale)); 307 314 } 308 315 … … 319 326 if (it != overlays_s.end()) 320 327 { 321 OrxonoxOverlay* overlay= (*it).second;328 OrxonoxOverlay* overlay= it->second; 322 329 if(overlay->isVisible()) 323 330 overlay->hide(); … … 338 345 std::map<std::string, OrxonoxOverlay*>::const_iterator it = overlays_s.find(name); 339 346 if (it != overlays_s.end()) 340 (*it).second->scroll(scroll);347 it->second->scroll(scroll); 341 348 } 342 349 … … 352 359 std::map<std::string, OrxonoxOverlay*>::const_iterator it = overlays_s.find(name); 353 360 if (it != overlays_s.end()) 354 (*it).second->rotate(angle); 361 it->second->rotate(angle); 362 } 363 364 void OrxonoxOverlay::setOverlayGroup(OverlayGroup* group) 365 { 366 if (group != this->group_) 367 { 368 if (this->group_) 369 this->group_->removeElement(this); 370 this->group_ = group; 371 this->changedOverlayGroup(); 372 } 373 } 374 375 void OrxonoxOverlay::setBackgroundAlpha(float alpha) { 376 Ogre::MaterialPtr ptr = this->background_->getMaterial(); 377 Ogre::TextureUnitState* tempTx = ptr->getTechnique(0)->getPass(0)->getTextureUnitState(0); 378 tempTx->setAlphaOperation(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, alpha); 355 379 } 356 380 }
Note: See TracChangeset
for help on using the changeset viewer.