Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/orxonox/sound/WorldAmbientSound.cc @ 9811

Last change on this file since 9811 was 9667, checked in by landauf, 11 years ago

merged core6 back to trunk

  • Property svn:eol-style set to native
File size: 3.6 KB
RevLine 
[7854]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 *      Fabian 'x3n' Landau
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29#include "WorldAmbientSound.h"
30
31#include "core/CoreIncludes.h"
32#include "core/EventIncludes.h"
33#include "core/XMLPort.h"
34#include "AmbientSound.h"
35
36namespace orxonox
37{
[9667]38    RegisterClass(WorldAmbientSound);
[7854]39
[9667]40    WorldAmbientSound::WorldAmbientSound(Context* context) : BaseObject(context), Synchronisable(context)
[7854]41    {
42        RegisterObject(WorldAmbientSound);
43
44        this->ambientSound_ = new AmbientSound();
45        this->registerVariables();
46    }
47
48    WorldAmbientSound::~WorldAmbientSound()
49    {
50        if (this->isInitialized())
51        {
52            this->ambientSound_->destroy();
53        }
54    }
55
56    void WorldAmbientSound::registerVariables()
57    {
58        registerVariable(this->ambientSound_->ambientSource_, ObjectDirection::ToClient, new NetworkCallback<AmbientSound>(this->ambientSound_, &AmbientSound::ambientSourceChanged));
59        registerVariable(this->ambientSound_->bLooping_,      ObjectDirection::ToClient, new NetworkCallback<AmbientSound>(this->ambientSound_, &AmbientSound::loopingChanged));
60        registerVariable(this->ambientSound_->pitch_,         ObjectDirection::ToClient, new NetworkCallback<AmbientSound>(this->ambientSound_, &AmbientSound::pitchChanged));
61        registerVariable(this->ambientSound_->bPlayOnLoad_,   ObjectDirection::ToClient, new NetworkCallback<AmbientSound>(this->ambientSound_, &AmbientSound::playOnLoadChanged));
62    }
63
64    void WorldAmbientSound::XMLPort(Element& xmlelement, XMLPort::Mode mode)
65    {
66        SUPER(WorldAmbientSound, XMLPort, xmlelement, mode);
67
68        XMLPortParamExtern(WorldAmbientSound, BaseSound, static_cast<BaseSound*>(this->ambientSound_), "looping", setLooping, getLooping, xmlelement, mode);
69        XMLPortParamExtern(WorldAmbientSound, BaseSound, static_cast<BaseSound*>(this->ambientSound_), "pitch",   setPitch,   getPitch,   xmlelement, mode);
70
71        XMLPortParamExtern(WorldAmbientSound, AmbientSound, this->ambientSound_, "source",     setAmbientSource, getAmbientSource, xmlelement, mode);
72        XMLPortParamExtern(WorldAmbientSound, AmbientSound, this->ambientSound_, "playOnLoad", setPlayOnLoad,    getPlayOnLoad,    xmlelement, mode);
73    }
74
75    void WorldAmbientSound::XMLEventPort(Element& xmlelement, XMLPort::Mode mode)
76    {
77        SUPER(WorldAmbientSound, XMLEventPort, xmlelement, mode);
78
79        XMLPortEventState(WorldAmbientSound, BaseObject, "play", play, xmlelement, mode);
80    }
81
82    void WorldAmbientSound::play()
83    {
84        this->ambientSound_->play();
85    }
86
87    void WorldAmbientSound::changedActivity()
88    {
89        SUPER(WorldAmbientSound, changedActivity);
90
91        if (this->isActive())
92            this->ambientSound_->play();
93        else
94            this->ambientSound_->stop();
95    }
96}
Note: See TracBrowser for help on using the repository browser.