Changeset 6349 for code/branches
- Timestamp:
- Dec 14, 2009, 12:51:34 AM (15 years ago)
- Location:
- code/branches/presentation2/src/orxonox
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation2/src/orxonox/gamestates/GSMainMenu.cc
r6313 r6349 73 73 { 74 74 if (GameMode::playsSound()) 75 delete this->ambient_;75 this->ambient_->destroy(); 76 76 77 77 InputManager::getInstance().destroyState("mainMenu"); -
code/branches/presentation2/src/orxonox/sound/AmbientSound.cc
r6326 r6349 53 53 AmbientSound::~AmbientSound() 54 54 { 55 } 56 57 void AmbientSound::preDestroy() 58 { 59 if (GameMode::playsSound()) 60 { 61 // Smoothly fade out by keeping a SmartPtr 62 SoundManager::getInstance().unregisterAmbientSound(this); 63 } 55 64 } 56 65 -
code/branches/presentation2/src/orxonox/sound/AmbientSound.h
r6322 r6349 67 67 68 68 private: 69 virtual void preDestroy(); 69 70 void doPlay(); 70 71 void doStop(); -
code/branches/presentation2/src/orxonox/sound/SoundManager.cc
r6332 r6349 314 314 { 315 315 if (oldAmbient == NULL || ambientSounds_.empty()) 316 {317 316 return; 318 } 317 319 318 if (this->ambientSounds_.front().first == oldAmbient) 320 319 { … … 468 467 469 468 470 void SoundManager::fadeIn( AmbientSound*sound)469 void SoundManager::fadeIn(const SmartPtr<AmbientSound>& sound) 471 470 { 472 471 // If we're already fading out --> remove that 473 for (std::list< AmbientSound*>::iterator it = this->fadeOutList_.begin(); it != this->fadeOutList_.end(); it++)472 for (std::list<SmartPtr<AmbientSound> >::iterator it = this->fadeOutList_.begin(); it != this->fadeOutList_.end(); it++) 474 473 { 475 474 if (*it == sound) … … 484 483 } 485 484 486 void SoundManager::fadeOut( AmbientSound*sound)485 void SoundManager::fadeOut(const SmartPtr<AmbientSound>& sound) 487 486 { 488 487 // If we're already fading in --> remove that 489 for (std::list< AmbientSound*>::iterator it = this->fadeInList_.begin(); it != this->fadeInList_.end(); it++)488 for (std::list<SmartPtr<AmbientSound> >::iterator it = this->fadeInList_.begin(); it != this->fadeInList_.end(); it++) 490 489 { 491 490 if (*it == sound) … … 510 509 511 510 // FADE IN 512 for (std::list< AmbientSound*>::iterator it= this->fadeInList_.begin(); it != this->fadeInList_.end(); )511 for (std::list<SmartPtr<AmbientSound> >::iterator it= this->fadeInList_.begin(); it != this->fadeInList_.end(); ) 513 512 { 514 513 if ((*it)->getVolume() + this->crossFadeStep_*dt > 1.0f) … … 525 524 526 525 // FADE OUT 527 for (std::list< AmbientSound*>::iterator it = this->fadeOutList_.begin(); it != this->fadeOutList_.end(); )526 for (std::list<SmartPtr<AmbientSound> >::iterator it = this->fadeOutList_.begin(); it != this->fadeOutList_.end(); ) 528 527 { 529 528 if ((*it)->getVolume() - this->crossFadeStep_*dt < 0.0f) -
code/branches/presentation2/src/orxonox/sound/SoundManager.h
r6332 r6349 40 40 #include "util/Singleton.h" 41 41 #include "core/OrxonoxClass.h" 42 #include "core/SmartPtr.h" 42 43 43 44 // forward declaration … … 109 110 private: 110 111 void processCrossFading(float dt); 111 void fadeIn( AmbientSound*sound);112 void fadeOut( AmbientSound*sound);112 void fadeIn(const SmartPtr<AmbientSound>& sound); 113 void fadeOut(const SmartPtr<AmbientSound>& sound); 113 114 114 115 void checkFadeStepValidity(); … … 133 134 134 135 float crossFadeStep_; //!< Absolute change per second (0.1 means 10% of the nominal volume) for cross fading 135 std::list< AmbientSound*> fadeInList_;136 std::list< AmbientSound*> fadeOutList_;136 std::list<SmartPtr<AmbientSound> > fadeInList_; 137 std::list<SmartPtr<AmbientSound> > fadeOutList_; 137 138 138 139 float soundVolume_;
Note: See TracChangeset
for help on using the changeset viewer.