- Timestamp:
- Dec 19, 2009, 12:18:41 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation2/src/orxonox/sound/AmbientSound.cc
r6370 r6382 42 42 43 43 AmbientSound::AmbientSound(BaseObject* creator) 44 : BaseObject(creator), Synchronisable(creator) 44 : BaseObject(creator) 45 , Synchronisable(creator) 46 , bPlayOnLoad_(false) 45 47 { 46 48 RegisterObject(AmbientSound); … … 49 51 this->setVolume(0); 50 52 this->registerVariables(); 51 }52 53 AmbientSound::~AmbientSound()54 {55 53 } 56 54 … … 67 65 { 68 66 registerVariable(ambientSource_, ObjectDirection::ToClient, new NetworkCallback<AmbientSound>(this, &AmbientSound::ambientSourceChanged)); 69 registerVariable(bLooping_, ObjectDirection::ToClient, new NetworkCallback<AmbientSound>(this, &AmbientSound::loopingChanged));70 registerVariable(pitch_, ObjectDirection::ToClient, new NetworkCallback<AmbientSound>(this, &AmbientSound::pitchChanged));71 registerVariable( (int&)(BaseSound::state_), ObjectDirection::ToClient, new NetworkCallback<AmbientSound>(this, &AmbientSound::stateChanged));67 registerVariable(bLooping_, ObjectDirection::ToClient, new NetworkCallback<AmbientSound>(this, &AmbientSound::loopingChanged)); 68 registerVariable(pitch_, ObjectDirection::ToClient, new NetworkCallback<AmbientSound>(this, &AmbientSound::pitchChanged)); 69 registerVariable(bPlayOnLoad_, ObjectDirection::ToClient, new NetworkCallback<AmbientSound>(this, &AmbientSound::playOnLoadChanged)); 72 70 } 73 71 … … 76 74 SUPER(AmbientSound, XMLPort, xmlelement, mode); 77 75 BaseSound::XMLPortExtern(xmlelement, mode); 78 XMLPortParam(AmbientSound, "ambientsource", setAmbientSource, getAmbientSource, xmlelement, mode); 76 XMLPortParam(AmbientSound, "ambientSource", setAmbientSource, getAmbientSource, xmlelement, mode); 77 XMLPortParam(AmbientSound, "playOnLoad", setPlayOnLoad, getPlayOnLoad, xmlelement, mode); 79 78 } 80 79 … … 88 87 { 89 88 if (GameMode::playsSound()) 90 {91 89 SoundManager::getInstance().registerAmbientSound(this); 92 }93 else94 BaseSound::play();95 }96 97 void AmbientSound::doPlay()98 {99 BaseSound::play();100 90 } 101 91 … … 103 93 { 104 94 if (GameMode::playsSound()) 105 {106 95 SoundManager::getInstance().unregisterAmbientSound(this); 107 }108 else109 BaseSound::stop();110 }111 112 void AmbientSound::doStop()113 {114 BaseSound::stop();115 96 } 116 97 … … 118 99 { 119 100 if (GameMode::playsSound()) 120 {121 101 SoundManager::getInstance().pauseAmbientSound(this); 122 }123 else124 BaseSound::pause();125 102 } 126 103 … … 129 106 assert(GameMode::playsSound()); 130 107 return SoundManager::getInstance().getRealVolume(SoundType::Music); 131 }132 133 void AmbientSound::doPause()134 {135 BaseSound::pause();136 108 } 137 109 … … 150 122 } 151 123 124 void AmbientSound::setPlayOnLoad(bool val) 125 { 126 this->bPlayOnLoad_ = val; 127 if (val) 128 this->play(); 129 } 130 152 131 void AmbientSound::changedActivity() 153 132 {
Note: See TracChangeset
for help on using the changeset viewer.