Changeset 7121 for code/branches/presentation3/src/orxonox
- Timestamp:
- Jun 7, 2010, 1:06:35 AM (14 years ago)
- Location:
- code/branches/presentation3/src/orxonox
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation3/src/orxonox/MoodManager.cc
r6417 r7121 32 32 #include "core/CoreIncludes.h" 33 33 #include "core/ScopedSingletonManager.h" 34 #include "core/Resource.h" 34 35 35 36 namespace orxonox … … 37 38 ManageScopedSingleton(MoodManager, ScopeID::Root, false); 38 39 40 // Note: I'm (Kevin Young) not entirely sure whether that's good code style: 41 const std::string MoodManager::defaultMood_ = "default"; 42 39 43 MoodManager::MoodManager() 40 44 { 41 45 RegisterRootObject(MoodManager); 42 46 this->setConfigValues(); 47 48 // Checking for the existence of the folder for the default mood 49 /* Note: Currently Resource::exists(path) will always return false when the path field points to a folder. 50 MoodManager::checkMoodValidity() performs the same check. Please help. 51 */ 52 const std::string& path = "ambient/" + MoodManager::defaultMood_ + '/'; 53 if (!Resource::exists(path)) 54 { 55 // TODO: Non-fatal error handling (non-critical resource missing) 56 COUT(2) << "Mood Warning: Folder for default mood (" << MoodManager::defaultMood_ << ") does not exist!" << std::endl; 57 } 43 58 } 44 59 45 60 void MoodManager::setConfigValues() 46 61 { 47 SetConfigValue(mood_, "default")62 SetConfigValue(mood_, MoodManager::defaultMood_) 48 63 .description("Sets the mood for the current level.") 49 64 .callback(this, &MoodManager::checkMoodValidity); 50 65 } 51 66 52 /** Sets the mood 53 @note 54 TODO: Inform dependent classes of mood change 55 */ 67 /** Set a new mood 68 */ 56 69 void MoodManager::setMood(const std::string& mood) 57 70 { … … 61 74 void MoodManager::checkMoodValidity() 62 75 { 63 // TODO: Insert new moods here & make this generic 64 if (mood_ != "default" && mood_ != "dnb") 76 // Generic mood validation 77 const std::string& path = "ambient/" + mood_ + '/'; 78 if (!Resource::exists(path)) 65 79 { 80 COUT(3) << "Mood " << mood_ << " does not exist. Will not change." << std::endl; 66 81 ResetConfigValue(mood_); 67 82 } -
code/branches/presentation3/src/orxonox/MoodManager.h
r6417 r7121 38 38 namespace orxonox 39 39 { 40 /* 41 @brief 42 The MoodListener class is aware of a change in themes and directs that info to dependent classes. 43 */ 40 44 class _OrxonoxExport MoodListener : virtual public OrxonoxClass 41 45 { … … 55 59 }; 56 60 61 /* 62 @brief 63 The MoodManager class serves to allow for different musical themes in the game. 64 */ 57 65 class _OrxonoxExport MoodManager : public Singleton<MoodManager>, public OrxonoxClass 58 66 { … … 74 82 // config values 75 83 std::string mood_; 84 static const std::string defaultMood_; 76 85 77 86 static MoodManager* singletonPtr_s;
Note: See TracChangeset
for help on using the changeset viewer.