Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/gamestates2/src/orxonox/MoodManager.cc @ 6987

Last change on this file since 6987 was 6417, checked in by rgrieder, 15 years ago

Merged presentation2 branch back to trunk.
Major new features:

  • Actual GUI with settings, etc.
  • Improved space ship steering (human interaction)
  • Rocket fire and more particle effects
  • Advanced sound framework
  • Property svn:eol-style set to native
File size: 2.4 KB
Line 
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
52    /** Sets the mood
53    @note
54        TODO: Inform dependent classes of mood change
55    */
56    void MoodManager::setMood(const std::string& mood)
57    {
58        ModifyConfigValue(mood_, set, mood);
59    }
60
61    void MoodManager::checkMoodValidity()
62    {
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        }
73    }
74
75
76    std::string MoodListener::mood_s;
77
78    MoodListener::MoodListener()
79    {
80        RegisterRootObject(MoodListener);
81    }
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    }
89}
Note: See TracBrowser for help on using the repository browser.