Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7121


Ignore:
Timestamp:
Jun 7, 2010, 1:06:35 AM (14 years ago)
Author:
youngk
Message:

Updated the MoodManager validation process to be more generic, however I ran into a little trouble. Please review the changes and consult my notes.

Location:
code/branches/presentation3/src/orxonox
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation3/src/orxonox/MoodManager.cc

    r6417 r7121  
    3232#include "core/CoreIncludes.h"
    3333#include "core/ScopedSingletonManager.h"
     34#include "core/Resource.h"
    3435
    3536namespace orxonox
     
    3738    ManageScopedSingleton(MoodManager, ScopeID::Root, false);
    3839
     40    // Note: I'm (Kevin Young) not entirely sure whether that's good code style:
     41    const std::string MoodManager::defaultMood_ = "default";
     42
    3943    MoodManager::MoodManager()
    4044    {
    4145        RegisterRootObject(MoodManager);
    4246        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        }
    4358    }
    4459
    4560    void MoodManager::setConfigValues()
    4661    {
    47         SetConfigValue(mood_, "default")
     62        SetConfigValue(mood_, MoodManager::defaultMood_)
    4863            .description("Sets the mood for the current level.")
    4964            .callback(this, &MoodManager::checkMoodValidity);
    5065    }
    5166
    52     /** Sets the mood
    53     @note
    54         TODO: Inform dependent classes of mood change
    55     */
     67    /** Set a new mood
     68     */
    5669    void MoodManager::setMood(const std::string& mood)
    5770    {
     
    6174    void MoodManager::checkMoodValidity()
    6275    {
    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))
    6579        {
     80            COUT(3) << "Mood " << mood_ << " does not exist. Will not change." << std::endl;
    6681            ResetConfigValue(mood_);
    6782        }
  • code/branches/presentation3/src/orxonox/MoodManager.h

    r6417 r7121  
    3838namespace orxonox
    3939{
     40    /*
     41    @brief
     42        The MoodListener class is aware of a change in themes and directs that info to dependent classes.
     43    */
    4044    class _OrxonoxExport MoodListener : virtual public OrxonoxClass
    4145    {
     
    5559    };
    5660
     61    /*
     62    @brief
     63        The MoodManager class serves to allow for different musical themes in the game.
     64    */
    5765    class _OrxonoxExport MoodManager : public Singleton<MoodManager>, public OrxonoxClass
    5866    {
     
    7482            // config values
    7583            std::string mood_;
     84            static const std::string defaultMood_;
    7685
    7786            static MoodManager* singletonPtr_s;
Note: See TracChangeset for help on using the changeset viewer.