Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/presentation2/src/orxonox/MoodManager.cc @ 6791

Last change on this file since 6791 was 6406, checked in by rgrieder, 15 years ago

Mood changes should now be working and with immediate (but delayed because of loading) effect.

  • Property svn:eol-style set to native
File size: 2.4 KB
RevLine 
[6119]1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
23 *      Kevin 'youngk' Young
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29#include "MoodManager.h"
30
31#include "core/ConfigValueIncludes.h"
32#include "core/CoreIncludes.h"
33#include "core/ScopedSingletonManager.h"
34
35namespace orxonox
36{
37    ManageScopedSingleton(MoodManager, ScopeID::Root, false);
38
39    MoodManager::MoodManager()
40    {
41        RegisterRootObject(MoodManager);
42        this->setConfigValues();
43    }
44
45    void MoodManager::setConfigValues()
46    {
47        SetConfigValue(mood_, "default")
48            .description("Sets the mood for the current level.")
49            .callback(this, &MoodManager::checkMoodValidity);
50    }
51
[6370]52    /** Sets the mood
53    @note
54        TODO: Inform dependent classes of mood change
55    */
[6119]56    void MoodManager::setMood(const std::string& mood)
57    {
58        ModifyConfigValue(mood_, set, mood);
59    }
[6387]60
[6406]61    void MoodManager::checkMoodValidity()
[6119]62    {
[6406]63        // TODO: Insert new moods here & make this generic
64        if (mood_ != "default" && mood_ != "dnb")
65        {
66            ResetConfigValue(mood_);
67        }
68        else
69        {
70            COUT(3) << "Mood changed to " << mood_ << std::endl;
71            MoodListener::changedMood(mood_);
72        }
[6119]73    }
74
[6406]75
76    std::string MoodListener::mood_s;
77
78    MoodListener::MoodListener()
[6119]79    {
[6406]80        RegisterRootObject(MoodListener);
[6119]81    }
[6406]82
83    /*static*/ void MoodListener::changedMood(const std::string& mood)
84    {
85        mood_s = mood;
86        for (ObjectList<MoodListener>::iterator it = ObjectList<MoodListener>::begin(); it; ++it)
87            it->moodChanged(mood_s);
88    }
[6119]89}
Note: See TracBrowser for help on using the repository browser.