Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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.

File:
1 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        }
Note: See TracChangeset for help on using the changeset viewer.