[Orxonox-commit 2406] r7121 - code/branches/presentation3/src/orxonox
youngk at orxonox.net
youngk at orxonox.net
Mon Jun 7 01:06:36 CEST 2010
Author: youngk
Date: 2010-06-07 01:06:35 +0200 (Mon, 07 Jun 2010)
New Revision: 7121
Modified:
code/branches/presentation3/src/orxonox/MoodManager.cc
code/branches/presentation3/src/orxonox/MoodManager.h
Log:
Updated the MoodManager validation process to be more generic, however I ran into a little trouble. Please review the changes and consult my notes.
Modified: code/branches/presentation3/src/orxonox/MoodManager.cc
===================================================================
--- code/branches/presentation3/src/orxonox/MoodManager.cc 2010-06-06 23:00:01 UTC (rev 7120)
+++ code/branches/presentation3/src/orxonox/MoodManager.cc 2010-06-06 23:06:35 UTC (rev 7121)
@@ -31,28 +31,41 @@
#include "core/ConfigValueIncludes.h"
#include "core/CoreIncludes.h"
#include "core/ScopedSingletonManager.h"
+#include "core/Resource.h"
namespace orxonox
{
ManageScopedSingleton(MoodManager, ScopeID::Root, false);
+ // Note: I'm (Kevin Young) not entirely sure whether that's good code style:
+ const std::string MoodManager::defaultMood_ = "default";
+
MoodManager::MoodManager()
{
RegisterRootObject(MoodManager);
this->setConfigValues();
+
+ // Checking for the existence of the folder for the default mood
+ /* Note: Currently Resource::exists(path) will always return false when the path field points to a folder.
+ MoodManager::checkMoodValidity() performs the same check. Please help.
+ */
+ const std::string& path = "ambient/" + MoodManager::defaultMood_ + '/';
+ if (!Resource::exists(path))
+ {
+ // TODO: Non-fatal error handling (non-critical resource missing)
+ COUT(2) << "Mood Warning: Folder for default mood (" << MoodManager::defaultMood_ << ") does not exist!" << std::endl;
+ }
}
void MoodManager::setConfigValues()
{
- SetConfigValue(mood_, "default")
+ SetConfigValue(mood_, MoodManager::defaultMood_)
.description("Sets the mood for the current level.")
.callback(this, &MoodManager::checkMoodValidity);
}
- /** Sets the mood
- @note
- TODO: Inform dependent classes of mood change
- */
+ /** Set a new mood
+ */
void MoodManager::setMood(const std::string& mood)
{
ModifyConfigValue(mood_, set, mood);
@@ -60,9 +73,11 @@
void MoodManager::checkMoodValidity()
{
- // TODO: Insert new moods here & make this generic
- if (mood_ != "default" && mood_ != "dnb")
+ // Generic mood validation
+ const std::string& path = "ambient/" + mood_ + '/';
+ if (!Resource::exists(path))
{
+ COUT(3) << "Mood " << mood_ << " does not exist. Will not change." << std::endl;
ResetConfigValue(mood_);
}
else
Modified: code/branches/presentation3/src/orxonox/MoodManager.h
===================================================================
--- code/branches/presentation3/src/orxonox/MoodManager.h 2010-06-06 23:00:01 UTC (rev 7120)
+++ code/branches/presentation3/src/orxonox/MoodManager.h 2010-06-06 23:06:35 UTC (rev 7121)
@@ -37,6 +37,10 @@
namespace orxonox
{
+ /*
+ @brief
+ The MoodListener class is aware of a change in themes and directs that info to dependent classes.
+ */
class _OrxonoxExport MoodListener : virtual public OrxonoxClass
{
friend class MoodManager;
@@ -54,6 +58,10 @@
static std::string mood_s;
};
+ /*
+ @brief
+ The MoodManager class serves to allow for different musical themes in the game.
+ */
class _OrxonoxExport MoodManager : public Singleton<MoodManager>, public OrxonoxClass
{
friend class Singleton<MoodManager>;
@@ -73,6 +81,7 @@
// config values
std::string mood_;
+ static const std::string defaultMood_;
static MoodManager* singletonPtr_s;
};
More information about the Orxonox-commit
mailing list