Changeset 6412 for code/branches/pickup2/src/orxonox/overlays
- Timestamp:
- Dec 25, 2009, 1:18:03 PM (15 years ago)
- Location:
- code/branches/pickup2
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/pickup2
- Property svn:mergeinfo changed
-
code/branches/pickup2/src/orxonox/overlays/InGameConsole.cc
r5929 r6412 44 44 #include "util/Convert.h" 45 45 #include "util/Math.h" 46 #include "util/ UTFStringConversions.h"46 #include "util/DisplayStringConversions.h" 47 47 #include "core/CoreIncludes.h" 48 48 #include "core/ConfigValueIncludes.h" … … 61 61 SetConsoleCommand(InGameConsole, closeConsole, true); 62 62 63 InGameConsole* InGameConsole::singletonPtr_s = 0;64 63 ManageScopedSingleton(InGameConsole, ScopeID::Graphics, false); 65 64 … … 68 67 */ 69 68 InGameConsole::InGameConsole() 70 : consoleOverlay_(0) 69 : shell_(new Shell("InGameConsole", true)) 70 , bShowCursor_(false) 71 , consoleOverlay_(0) 71 72 , consoleOverlayContainer_(0) 72 73 , consoleOverlayNoise_(0) … … 99 100 // destroy the input state previously created (InputBuffer gets destroyed by the Shell) 100 101 InputManager::getInstance().destroyState("console"); 102 103 // destroy the underlaying shell 104 this->shell_->destroy(); 101 105 102 106 Ogre::OverlayManager* ovMan = Ogre::OverlayManager::getSingletonPtr(); … … 174 178 // create the corresponding input state 175 179 inputState_ = InputManager::getInstance().createInputState("console", false, false, InputStatePriority::Console); 176 inputState_->setKeyHandler( Shell::getInstance().getInputBuffer());180 inputState_->setKeyHandler(this->shell_->getInputBuffer()); 177 181 bHidesAllInputChanged(); 178 182 … … 214 218 font->addCodePointRange(Ogre::Font::CodePointRange(161, 255)); 215 219 220 // create noise 221 this->consoleOverlayNoise_ = static_cast<Ogre::PanelOverlayElement*>(ovMan->createOverlayElement("Panel", "InGameConsoleNoise")); 222 this->consoleOverlayNoise_->setMetricsMode(Ogre::GMM_PIXELS); 223 this->consoleOverlayNoise_->setPosition(5,0); 224 this->consoleOverlayNoise_->setMaterialName("ConsoleNoiseSmall"); 225 // comment following line to disable noise 226 this->consoleOverlayBorder_->addChild(this->consoleOverlayNoise_); 227 216 228 // create the text lines 217 229 this->consoleOverlayTextAreas_ = new Ogre::TextAreaOverlayElement*[LINES]; … … 225 237 this->consoleOverlayTextAreas_[i]->setLeft(8); 226 238 this->consoleOverlayTextAreas_[i]->setCaption(""); 227 this->consoleOverlay Container_->addChild(this->consoleOverlayTextAreas_[i]);239 this->consoleOverlayNoise_->addChild(this->consoleOverlayTextAreas_[i]); 228 240 } 229 241 … … 236 248 this->consoleOverlayCursor_->setLeft(7); 237 249 this->consoleOverlayCursor_->setCaption(std::string(this->cursorSymbol_, 1)); 238 this->consoleOverlayContainer_->addChild(this->consoleOverlayCursor_); 239 240 // create noise 241 this->consoleOverlayNoise_ = static_cast<Ogre::PanelOverlayElement*>(ovMan->createOverlayElement("Panel", "InGameConsoleNoise")); 242 this->consoleOverlayNoise_->setMetricsMode(Ogre::GMM_PIXELS); 243 this->consoleOverlayNoise_->setPosition(5,0); 244 this->consoleOverlayNoise_->setMaterialName("ConsoleNoiseSmall"); 245 // comment following line to disable noise 246 this->consoleOverlayContainer_->addChild(this->consoleOverlayNoise_); 250 this->consoleOverlayNoise_->addChild(this->consoleOverlayCursor_); 247 251 248 252 this->windowResized(this->getWindowWidth(), this->getWindowWidth()); 249 253 250 254 // move overlay "above" the top edge of the screen 251 // we take -1.2 because the border makes the panel bigger 252 this->consoleOverlayContainer_->setTop(-1.2 * this->relativeHeight); 253 254 Shell::getInstance().addOutputLevel(true); 255 // we take -1.3 because the border makes the panel bigger 256 this->consoleOverlayContainer_->setTop(-1.3 * this->relativeHeight); 255 257 256 258 COUT(4) << "Info: InGameConsole initialized" << std::endl; … … 266 268 void InGameConsole::linesChanged() 267 269 { 268 std::list<std::string>::const_iterator it = Shell::getInstance().getNewestLineIterator();270 Shell::LineList::const_iterator it = this->shell_->getNewestLineIterator(); 269 271 int max = 0; 270 272 for (int i = 1; i < LINES; ++i) 271 273 { 272 if (it != Shell::getInstance().getEndIterator())274 if (it != this->shell_->getEndIterator()) 273 275 { 274 276 ++it; … … 280 282 281 283 for (int i = LINES - 1; i > max; --i) 282 this->print("", i, true);284 this->print("", Shell::None, i, true); 283 285 284 286 for (int i = max; i >= 1; --i) 285 287 { 286 288 --it; 287 this->print( *it, i, true);289 this->print(it->first, it->second, i, true); 288 290 } 289 291 } … … 295 297 { 296 298 if (LINES > 1) 297 this->print( *Shell::getInstance().getNewestLineIterator(), 1);299 this->print(this->shell_->getNewestLineIterator()->first, this->shell_->getNewestLineIterator()->second, 1); 298 300 } 299 301 … … 314 316 { 315 317 if (LINES > 0) 316 this->print( Shell::getInstance().getInput(), 0);317 318 if ( Shell::getInstance().getInput() == "" || Shell::getInstance().getInput().size() == 0)318 this->print(this->shell_->getInput(), Shell::Input, 0); 319 320 if (this->shell_->getInput().empty()) 319 321 this->inputWindowStart_ = 0; 320 322 } … … 325 327 void InGameConsole::cursorChanged() 326 328 { 327 unsigned int pos = Shell::getInstance().getCursorPosition() - inputWindowStart_;329 unsigned int pos = this->shell_->getCursorPosition() - inputWindowStart_; 328 330 if (pos > maxCharsPerLine_) 329 331 pos = maxCharsPerLine_; … … 331 333 this->consoleOverlayCursor_->setCaption(std::string(pos,' ') + cursorSymbol_); 332 334 this->consoleOverlayCursor_->setTop(static_cast<int>(this->windowH_ * this->relativeHeight) - 24); 335 } 336 337 /** 338 @brief Called if a command is about to be executed 339 */ 340 void InGameConsole::executed() 341 { 342 this->shell_->addOutput(this->shell_->getInput() + '\n', Shell::Command); 333 343 } 334 344 … … 348 358 @brief Used to control the actual scrolling and the cursor. 349 359 */ 350 void InGameConsole:: update(const Clock& time)360 void InGameConsole::preUpdate(const Clock& time) 351 361 { 352 362 if (this->scroll_ != 0) … … 374 384 // scrolling up 375 385 // note: +0.01 for the same reason as when scrolling down 376 float deltaScroll = (1. 2* this->relativeHeight + 0.01 + oldTop) * time.getDeltaTime() * this->scrollSpeed_;377 if (oldTop - deltaScroll <= -1. 2* this->relativeHeight)386 float deltaScroll = (1.3 * this->relativeHeight + 0.01 + oldTop) * time.getDeltaTime() * this->scrollSpeed_; 387 if (oldTop - deltaScroll <= -1.3 * this->relativeHeight) 378 388 { 379 389 // window has completely scrolled up 380 this->consoleOverlayContainer_->setTop(-1. 2* this->relativeHeight);390 this->consoleOverlayContainer_->setTop(-1.3 * this->relativeHeight); 381 391 this->scroll_ = 0; 382 392 this->consoleOverlay_->hide(); … … 446 456 @param s String to be printed 447 457 */ 448 void InGameConsole::print(const std::string& text, int index, bool alwaysShift) 449 { 450 char level = 0; 451 if (text.size() > 0) 452 level = text[0]; 453 458 void InGameConsole::print(const std::string& text, Shell::LineType type, int index, bool alwaysShift) 459 { 454 460 std::string output = text; 455 456 if (level >= -1 && level <= 5)457 output.erase(0, 1);458 459 461 if (LINES > index) 460 462 { 461 this->colourLine( level, index);463 this->colourLine(type, index); 462 464 463 465 if (index > 0) … … 467 469 { 468 470 ++linesUsed; 469 this->consoleOverlayTextAreas_[index]->setCaption(multi_cast<Ogre:: UTFString>(output.substr(0, this->maxCharsPerLine_)));471 this->consoleOverlayTextAreas_[index]->setCaption(multi_cast<Ogre::DisplayString>(output.substr(0, this->maxCharsPerLine_))); 470 472 output.erase(0, this->maxCharsPerLine_); 471 473 output.insert(0, 1, ' '); 472 474 if (linesUsed > numLinesShifted_ || alwaysShift) 473 475 this->shiftLines(); 474 this->colourLine( level, index);476 this->colourLine(type, index); 475 477 } 476 this->consoleOverlayTextAreas_[index]->setCaption(multi_cast<Ogre:: UTFString>(output));478 this->consoleOverlayTextAreas_[index]->setCaption(multi_cast<Ogre::DisplayString>(output)); 477 479 this->displayedText_ = output; 478 480 this->numLinesShifted_ = linesUsed; … … 482 484 if (output.size() > this->maxCharsPerLine_) 483 485 { 484 if ( Shell::getInstance().getInputBuffer()->getCursorPosition() < this->inputWindowStart_)485 this->inputWindowStart_ = Shell::getInstance().getInputBuffer()->getCursorPosition();486 else if ( Shell::getInstance().getInputBuffer()->getCursorPosition() >= (this->inputWindowStart_ + this->maxCharsPerLine_ - 1))487 this->inputWindowStart_ = Shell::getInstance().getInputBuffer()->getCursorPosition() - this->maxCharsPerLine_ + 1;486 if (this->shell_->getInputBuffer()->getCursorPosition() < this->inputWindowStart_) 487 this->inputWindowStart_ = this->shell_->getInputBuffer()->getCursorPosition(); 488 else if (this->shell_->getInputBuffer()->getCursorPosition() >= (this->inputWindowStart_ + this->maxCharsPerLine_ - 1)) 489 this->inputWindowStart_ = this->shell_->getInputBuffer()->getCursorPosition() - this->maxCharsPerLine_ + 1; 488 490 489 491 output = output.substr(this->inputWindowStart_, this->maxCharsPerLine_); … … 492 494 this->inputWindowStart_ = 0; 493 495 this->displayedText_ = output; 494 this->consoleOverlayTextAreas_[index]->setCaption(multi_cast<Ogre:: UTFString>(output));496 this->consoleOverlayTextAreas_[index]->setCaption(multi_cast<Ogre::DisplayString>(output)); 495 497 } 496 498 } … … 506 508 this->bActive_ = true; 507 509 InputManager::getInstance().enterState("console"); 508 Shell::getInstance().registerListener(this);510 this->shell_->registerListener(this); 509 511 510 512 this->windowResized(this->windowW_, this->windowH_); … … 528 530 this->bActive_ = false; 529 531 InputManager::getInstance().leaveState("console"); 530 Shell::getInstance().unregisterListener(this);532 this->shell_->unregisterListener(this); 531 533 532 534 // scroll up … … 549 551 } 550 552 551 void InGameConsole::colourLine(int colourcode, int index) 552 { 553 if (colourcode == -1) 554 { 555 this->consoleOverlayTextAreas_[index]->setColourTop (ColourValue(0.90, 0.90, 0.90, 1.00)); 556 this->consoleOverlayTextAreas_[index]->setColourBottom(ColourValue(1.00, 1.00, 1.00, 1.00)); 557 } 558 else if (colourcode == 1) 559 { 560 this->consoleOverlayTextAreas_[index]->setColourTop (ColourValue(0.95, 0.25, 0.25, 1.00)); 561 this->consoleOverlayTextAreas_[index]->setColourBottom(ColourValue(1.00, 0.50, 0.50, 1.00)); 562 } 563 else if (colourcode == 2) 564 { 565 this->consoleOverlayTextAreas_[index]->setColourTop (ColourValue(0.95, 0.50, 0.20, 1.00)); 566 this->consoleOverlayTextAreas_[index]->setColourBottom(ColourValue(1.00, 0.70, 0.50, 1.00)); 567 } 568 else if (colourcode == 3) 569 { 570 this->consoleOverlayTextAreas_[index]->setColourTop (ColourValue(0.50, 0.50, 0.95, 1.00)); 571 this->consoleOverlayTextAreas_[index]->setColourBottom(ColourValue(0.80, 0.80, 1.00, 1.00)); 572 } 573 else if (colourcode == 4) 574 { 575 this->consoleOverlayTextAreas_[index]->setColourTop (ColourValue(0.65, 0.48, 0.44, 1.00)); 576 this->consoleOverlayTextAreas_[index]->setColourBottom(ColourValue(1.00, 0.90, 0.90, 1.00)); 577 } 578 else if (colourcode == 5) 579 { 580 this->consoleOverlayTextAreas_[index]->setColourTop (ColourValue(0.40, 0.20, 0.40, 1.00)); 581 this->consoleOverlayTextAreas_[index]->setColourBottom(ColourValue(0.80, 0.60, 0.80, 1.00)); 582 } 583 else 584 { 585 this->consoleOverlayTextAreas_[index]->setColourTop (ColourValue(0.21, 0.69, 0.21, 1.00)); 586 this->consoleOverlayTextAreas_[index]->setColourBottom(ColourValue(0.80, 1.00, 0.80, 1.00)); 587 } 588 } 589 590 // ############################### 591 // ### satic methods ### 592 // ############################### 553 void InGameConsole::colourLine(Shell::LineType type, int index) 554 { 555 ColourValue colourTop, colourBottom; 556 switch (type) 557 { 558 case Shell::Error: colourTop = ColourValue(0.95, 0.25, 0.25, 1.00); 559 colourBottom = ColourValue(1.00, 0.50, 0.50, 1.00); break; 560 561 case Shell::Warning: colourTop = ColourValue(0.95, 0.50, 0.20, 1.00); 562 colourBottom = ColourValue(1.00, 0.70, 0.50, 1.00); break; 563 564 case Shell::Info: colourTop = ColourValue(0.50, 0.50, 0.95, 1.00); 565 colourBottom = ColourValue(0.80, 0.80, 1.00, 1.00); break; 566 567 case Shell::Debug: colourTop = ColourValue(0.65, 0.48, 0.44, 1.00); 568 colourBottom = ColourValue(1.00, 0.90, 0.90, 1.00); break; 569 570 case Shell::Verbose: colourTop = ColourValue(0.40, 0.20, 0.40, 1.00); 571 colourBottom = ColourValue(0.80, 0.60, 0.80, 1.00); break; 572 573 case Shell::Ultra: colourTop = ColourValue(0.21, 0.69, 0.21, 1.00); 574 colourBottom = ColourValue(0.80, 1.00, 0.80, 1.00); break; 575 576 case Shell::Command: colourTop = ColourValue(0.80, 0.80, 0.80, 1.00); 577 colourBottom = ColourValue(0.90, 0.90, 0.90, 0.90); break; 578 579 case Shell::Hint: colourTop = ColourValue(0.80, 0.80, 0.80, 1.00); 580 colourBottom = ColourValue(0.90, 0.90, 0.90, 1.00); break; 581 582 default: colourTop = ColourValue(0.90, 0.90, 0.90, 1.00); 583 colourBottom = ColourValue(1.00, 1.00, 1.00, 1.00); break; 584 } 585 586 this->consoleOverlayTextAreas_[index]->setColourTop (colourTop); 587 this->consoleOverlayTextAreas_[index]->setColourBottom(colourBottom); 588 } 589 590 // ################################ 591 // ### static methods ### 592 // ################################ 593 593 594 594 /** -
code/branches/pickup2/src/orxonox/overlays/InGameConsole.h
r5929 r6412 52 52 void setConfigValues(); 53 53 54 void update(const Clock& time);54 void preUpdate(const Clock& time); 55 55 56 56 static void openConsole(); … … 68 68 void inputChanged(); 69 69 void cursorChanged(); 70 void executed(); 70 71 void exit(); 71 72 72 73 void shiftLines(); 73 void colourLine( int colourcode, int index);74 void colourLine(Shell::LineType type, int index); 74 75 void setCursorPosition(unsigned int pos); 75 void print(const std::string& text, int index, bool alwaysShift = false);76 void print(const std::string& text, Shell::LineType type, int index, bool alwaysShift = false); 76 77 77 78 void windowResized(unsigned int newWidth, unsigned int newHeight); … … 81 82 82 83 private: // variables 84 Shell* shell_; 83 85 bool bActive_; 84 86 int windowW_; -
code/branches/pickup2/src/orxonox/overlays/Map.cc
r5929 r6412 49 49 #include <OgreViewport.h> 50 50 51 #include "util/StringUtils.h" 51 52 #include "core/ConsoleCommand.h" 52 53 #include "core/CoreIncludes.h" … … 94 95 95 96 //Getting Scene Manager (Hack) 96 if( !sManager_ ) 97 { 98 ObjectList<Scene>::iterator it = ObjectList<Scene>::begin(); 99 this->sManager_ = it->getSceneManager(); 100 } 97 ObjectList<Scene>::iterator it = ObjectList<Scene>::begin(); 98 this->sManager_ = it->getSceneManager(); 101 99 if( !Map::getMapSceneManager() ) 102 100 { -
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 } -
code/branches/pickup2/src/orxonox/overlays/OrxonoxOverlay.h
r5929 r6412 155 155 static void rotateOverlay(const std::string& name, const Degree& angle); 156 156 157 void setBackgroundMaterial(const std::string& material); 158 const std::string& getBackgroundMaterial() const; 159 160 void setBackgroundAlpha(float alpha); 161 157 162 virtual void changedVisibility(); 158 163 … … 169 174 virtual void changedOwner() {} 170 175 171 inline void setOverlayGroup(OverlayGroup* group) 172 { 173 if (group != this->group_) 174 { 175 this->group_ = group; 176 this->changedOverlayGroup(); 177 } 178 } 176 void setOverlayGroup(OverlayGroup* group); 179 177 inline OverlayGroup* getOverlayGroup() const 180 178 { return this->group_; } 181 virtual void changedOverlayGroup() {} 179 virtual void changedOverlayGroup() 180 { this->changedVisibility(); } 182 181 183 182 protected: … … 186 185 virtual void sizeChanged(); 187 186 virtual void positionChanged(); 188 189 void setBackgroundMaterial(const std::string& material);190 const std::string& getBackgroundMaterial() const;191 187 192 188 Ogre::Overlay* overlay_; //!< The overlay the entire class is about. … … 211 207 BaseObject* owner_; 212 208 OverlayGroup* group_; 209 Ogre::Pass* backgroundAlphaPass_; 213 210 }; 214 211 -
code/branches/pickup2/src/orxonox/overlays/OverlayGroup.cc
r5929 r6412 60 60 OverlayGroup::~OverlayGroup() 61 61 { 62 for (std::set< OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)62 for (std::set< SmartPtr<OrxonoxOverlay> >::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it) 63 63 (*it)->destroy(); 64 this->hudElements_.clear(); 64 65 } 65 66 … … 83 84 void OverlayGroup::setScale(const Vector2& scale) 84 85 { 85 for (std::set< OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)86 for (std::set< SmartPtr<OrxonoxOverlay> >::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it) 86 87 (*it)->scale(scale / this->scale_); 87 88 this->scale_ = scale; … … 91 92 void OverlayGroup::setScroll(const Vector2& scroll) 92 93 { 93 for (std::set< OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)94 for (std::set< SmartPtr<OrxonoxOverlay> >::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it) 94 95 (*it)->scroll(scroll - this->scroll_); 95 96 this->scroll_ = scroll; … … 104 105 void OverlayGroup::addElement(OrxonoxOverlay* element) 105 106 { 106 hudElements_.insert( element);107 element->set Visible(this->isVisible());107 hudElements_.insert(SmartPtr<OrxonoxOverlay>(element)); 108 element->setOverlayGroup( this ); 108 109 if (this->owner_) 109 110 element->setOwner(this->owner_); … … 120 121 bool OverlayGroup::removeElement(OrxonoxOverlay* element) 121 122 { 122 if(this->hudElements_.erase( element) == 0)123 if(this->hudElements_.erase(SmartPtr<OrxonoxOverlay>(element)) == 0) 123 124 return false; 124 125 return true; … … 130 131 if (index < this->hudElements_.size()) 131 132 { 132 std::set< OrxonoxOverlay*>::const_iterator it = hudElements_.begin();133 std::set< SmartPtr<OrxonoxOverlay> >::const_iterator it = hudElements_.begin(); 133 134 for (unsigned int i = 0; i != index; ++it, ++i) 134 135 ; 135 return (*it);136 return it->get(); 136 137 } 137 138 else … … 142 143 void OverlayGroup::changedVisibility() 143 144 { 144 for (std::set<OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it) 145 (*it)->setVisible(this->isVisible()); 145 SUPER( OverlayGroup, changedVisibility ); 146 147 for (std::set< SmartPtr<OrxonoxOverlay> >::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it) 148 (*it)->changedVisibility(); //inform all Child Overlays that our visibility has changed 146 149 } 147 150 … … 150 153 this->owner_ = owner; 151 154 152 for (std::set< OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)155 for (std::set< SmartPtr<OrxonoxOverlay> >::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it) 153 156 (*it)->setOwner(owner); 154 157 } -
code/branches/pickup2/src/orxonox/overlays/OverlayGroup.h
r5781 r6412 64 64 static void scrollGroup(const std::string& name, const Vector2& scroll); 65 65 66 inline const std::set< OrxonoxOverlay*>& getOverlays() const66 inline const std::set< SmartPtr<OrxonoxOverlay> >& getOverlays() const 67 67 { return this->hudElements_; } 68 68 … … 90 90 91 91 private: 92 std::set< OrxonoxOverlay*> hudElements_; //!< Contains all the OrxonoxOverlays of the this group.92 std::set< SmartPtr<OrxonoxOverlay> > hudElements_; //!< Contains all the OrxonoxOverlays of the this group. 93 93 Vector2 scale_; //!< Current scale (independent of the elements). 94 94 Vector2 scroll_; //!< Current scrolling offset.
Note: See TracChangeset
for help on using the changeset viewer.