xoreos  0.0.5
functions_sound.cpp
Go to the documentation of this file.
1 /* xoreos - A reimplementation of BioWare's Aurora engine
2  *
3  * xoreos is the legal property of its developers, whose names
4  * can be found in the AUTHORS file distributed with this source
5  * distribution.
6  *
7  * xoreos is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 3
10  * of the License, or (at your option) any later version.
11  *
12  * xoreos is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with xoreos. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
25 #include "src/aurora/talkman.h"
26 #include "src/aurora/ssffile.h"
27 
29 
31 
33 #include "src/engines/nwn/object.h"
34 #include "src/engines/nwn/area.h"
35 
37 
38 namespace Engines {
39 
40 namespace NWN {
41 
44  if (!object)
45  return;
46 
47  const Aurora::SSFFile *ssf = object->getSSF();
48  if (!ssf)
49  return;
50 
51  object->playSound(ssf->getSoundFile(ctx.getParams()[0].getInt()), true);
52 }
53 
56 
57  const Common::UString sound = TalkMan.getSoundResRef((uint32) ctx.getParams()[0].getInt());
58 
59  // TODO: Run as action
60  // bool runAsAction = ctx.getParams()[1].getInt() != 0;
61 
62  if (object)
63  object->playSound(sound);
64  else
66 }
67 
70 
71  if (object)
72  object->playSound(ctx.getParams()[0].getString());
73  else
75 
77 }
78 
81  if (area)
82  area->playAmbientMusic();
83 }
84 
87  if (area)
88  area->stopAmbientMusic();
89 }
90 
93  if (area)
94  area->setMusicDayTrack(ctx.getParams()[1].getInt());
95 }
96 
99  if (area)
100  area->setMusicNightTrack(ctx.getParams()[1].getInt());
101 }
102 
105 
106  ctx.getReturn() = area ? (int32)area->getMusicDayTrack() : -1;
107 }
108 
111 
112  ctx.getReturn() = area ? (int32)area->getMusicNightTrack() : -1;
113 }
114 
115 } // End of namespace NWN
116 
117 } // End of namespace Engines
const Common::UString & getSoundFile(size_t index) const
Return the sound file to play for this sound.
Definition: ssffile.cpp:173
Handling BioWare&#39;s SSFs (sound set file).
void musicBackgroundStop(Aurora::NWScript::FunctionContext &ctx)
void setMusicDayTrack(uint32 track)
Set the music track ID playing by day.
Definition: area.cpp:150
#define TalkMan
Shortcut for accessing the talk manager.
Definition: talkman.h:111
A container of Neverwinter Nights objects.
A class holding an UTF-8 string.
Definition: ustring.h:48
void musicBackgroundGetNightTrack(Aurora::NWScript::FunctionContext &ctx)
void playVoiceChat(Aurora::NWScript::FunctionContext &ctx)
Class to hold a sound set.
Definition: ssffile.h:55
Context of an NWScript function.
void unimplementedFunction(Aurora::NWScript::FunctionContext &ctx)
Definition: functions.cpp:97
void musicBackgroundChangeNight(Aurora::NWScript::FunctionContext &ctx)
static NWN::Object * toObject(::Aurora::NWScript::Object *object)
An area in Neverwinter Nights, holding all objects and room tiles within, as well as general area pro...
Definition: area.h:63
uint32 getMusicNightTrack() const
Return the music track ID playing by night.
Definition: area.cpp:142
void playSound(Aurora::NWScript::FunctionContext &ctx)
void playAmbientMusic(Common::UString music="")
Play the specified music (or the area&#39;s default) as ambient music.
Definition: area.cpp:195
void musicBackgroundPlay(Aurora::NWScript::FunctionContext &ctx)
The context holding a Neverwinter Nights area.
static Aurora::NWScript::Object * getParamObject(const Aurora::NWScript::FunctionContext &ctx, size_t n)
Definition: functions.cpp:118
void setMusicNightTrack(uint32 track)
Set the music track ID playing by night.
Definition: area.cpp:155
uint32 getMusicDayTrack() const
Return the music track ID playing by day.
Definition: area.cpp:138
void playSound(const Common::UString &sound, bool pitchVariance=false)
Play an object sound.
Definition: object.cpp:248
Voice/Speech.
Definition: types.h:46
Sound::ChannelHandle playSound(const Common::UString &sound, Sound::SoundType soundType, bool loop, float volume, bool pitchVariance)
Play this sound resource.
Definition: util.cpp:81
An object in a Neverwinter Nights area.
void musicBackgroundChangeDay(Aurora::NWScript::FunctionContext &ctx)
static Area * toArea(Aurora::NWScript::Object *object)
uint32_t uint32
Definition: types.h:204
The global talk manager for Aurora strings.
void playSoundByStrRef(Aurora::NWScript::FunctionContext &ctx)
Sound effect.
Definition: types.h:45
Generic Aurora engines utility functions.
void stopAmbientMusic()
Stop the ambient music.
Definition: area.cpp:187
void musicBackgroundGetDayTrack(Aurora::NWScript::FunctionContext &ctx)
Neverwinter Nights engine functions.
int32_t int32
Definition: types.h:203