Changeset 6031 for code/branches/sound3
- Timestamp:
- Nov 4, 2009, 4:03:03 PM (15 years ago)
- Location:
- code/branches/sound3
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/sound3/data/levels/sound.oxw
r5982 r6031 17 17 skybox = "Orxonox/Starbox" 18 18 > 19 <AmbientSound source=" ambient/mainmenu.wav" loop="true" playOnLoad="true" />20 <AmbientSound source=" ambient/CoreWave.wav" loop="true" playOnLoad="false">19 <AmbientSound source="mainmenu.wav" loop="true" playOnLoad="true" /> 20 <AmbientSound source="CoreWave.wav" loop="true" playOnLoad="false"> 21 21 <events> 22 22 <activity> -
code/branches/sound3/src/orxonox/MoodManager.cc
r5956 r6031 42 42 { 43 43 RegisterRootObject(MoodManager); 44 moodOld_ = "default"; 44 45 this->setConfigValues(); 45 46 CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&MoodManager::setMood, this), "setMood")); … … 53 54 { 54 55 SetConfigValue(mood_, "default") 55 .description("Sets the mood for the current level."); 56 .description("Sets the mood for the current level.") 57 .callback(this, &MoodManager::checkMoodValidity); 56 58 } 57 59 58 // sets a new mood 60 /** 61 * Sets the mood 62 * @note TODO: Inform dependent classes of mood change 63 */ 59 64 void MoodManager::setMood(const std::string& mood) { 60 65 ModifyConfigValue(mood_, set, mood); … … 65 70 return mood_; 66 71 } 72 73 void MoodManager::checkMoodValidity() 74 { 75 if(mood_ != "default" && mood_ != "dnb") // Insert new moods here 76 { 77 ResetConfigValue(mood_); 78 } 79 COUT(0) << "MoodManager: Mood now set to " << mood_ << std::endl; 80 return; 81 } 67 82 } -
code/branches/sound3/src/orxonox/MoodManager.h
r5956 r6031 62 62 // config values 63 63 std::string mood_; 64 std::string moodOld_; 65 66 void checkMoodValidity(); 64 67 65 68 static MoodManager* singletonPtr_s; -
code/branches/sound3/src/orxonox/gamestates/GSMainMenu.cc
r5956 r6031 128 128 void GSMainMenu::setConfigValues() 129 129 { 130 SetConfigValue(soundPathMain_, " ambient/mainmenu.wav")130 SetConfigValue(soundPathMain_, "mainmenu.wav") 131 131 .description("Contains the path to the main menu sound file.") 132 132 .callback(this, &GSMainMenu::reloadSound); -
code/branches/sound3/src/orxonox/sound/AmbientSound.cc
r5982 r6031 85 85 } 86 86 87 void AmbientSound::setSource(const std::string& source) 88 { 89 if(source.find('/') == std::string.npos) 90 { 91 std::string filePath = SoundManager::getInstance().getAmbientPath(source); 92 if(!(filePath.empty())) 93 { 94 BaseSound::setSource(filePath); 95 return; 96 } 97 } 98 COUT(3) << source << ": Not a valid name! Ambient sound will not change." << std::endl; 99 } 100 87 101 void AmbientSound::changedActivity() 88 102 { -
code/branches/sound3/src/orxonox/sound/AmbientSound.h
r5982 r6031 52 52 virtual void pause(); 53 53 54 virtual void setSource(const std::string& source); 55 54 56 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 55 57 virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode); -
code/branches/sound3/src/orxonox/sound/BaseSound.h
r5982 r6031 58 58 bool isStopped(); 59 59 60 v oid setSource(const std::string& source);60 virtual void setSource(const std::string& source); 61 61 const std::string& getSource() { return this->source_; } 62 62 -
code/branches/sound3/src/orxonox/sound/SoundManager.cc
r5982 r6031 34 34 #include "util/Math.h" 35 35 #include "util/ScopeGuard.h" 36 #include "util/StringUtils.h" 36 37 #include "core/GameMode.h" 37 38 #include "core/ScopedSingletonManager.h" 39 #include "core/Resource.h" 38 40 #include "BaseSound.h" 41 #include "MoodManager.h" 39 42 40 43 namespace orxonox … … 127 130 void SoundManager::unregisterAmbientSound(BaseSound* currentAmbient) 128 131 { 132 if(currentAmbient == NULL || ambientSounds_.empty()) 133 { 134 return; 135 } 129 136 if(this->ambientSounds_.front() == currentAmbient) 130 137 { 131 138 this->ambientSounds_.pop_front(); 132 this->ambientSounds_.front()->replay(); 139 if(!(this->ambientSounds_.empty())) 140 { 141 this->ambientSounds_.front()->replay(); 142 } 133 143 } 134 144 else … … 144 154 } 145 155 } 156 157 // Get the current mood and return the full path string to the requested sound. 158 const std::string& SoundManager::getAmbientPath(const std::string& source) 159 { 160 lastReqPath = "ambient/" + MoodManager::getInstance().getMood() + "/" + source; 161 shared_ptr<ResourceInfo> fileInfo = Resource::getInfo(lastReqPath); 162 if(fileInfo == NULL) 163 { 164 return BLANKSTRING; 165 } 166 return lastReqPath; 167 } 146 168 } -
code/branches/sound3/src/orxonox/sound/SoundManager.h
r5982 r6031 53 53 void registerAmbientSound(BaseSound* newAmbient); 54 54 void unregisterAmbientSound(BaseSound* currentAmbient); 55 const std::string& getAmbientPath(const std::string& source); 55 56 56 57 private: … … 58 59 ALCcontext* context_; 59 60 std::list<BaseSound*> ambientSounds_; 61 std::string lastReqPath; 60 62 61 63 static SoundManager* singletonPtr_s;
Note: See TracChangeset
for help on using the changeset viewer.