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 
34 #include "src/engines/nwn2/area.h"
35 
37 
38 namespace Engines {
39 
40 namespace NWN2 {
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 NWN2
116 
117 } // End of namespace Engines
void playSound(Aurora::NWScript::FunctionContext &ctx)
void musicBackgroundStop(Aurora::NWScript::FunctionContext &ctx)
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 unimplementedFunction(Aurora::NWScript::FunctionContext &ctx)
Definition: functions.cpp:97
#define TalkMan
Shortcut for accessing the talk manager.
Definition: talkman.h:111
static NWN2::Object * toObject(::Aurora::NWScript::Object *object)
void musicBackgroundChangeNight(Aurora::NWScript::FunctionContext &ctx)
A class holding an UTF-8 string.
Definition: ustring.h:48
void playAmbientMusic(Common::UString music="")
Play the specified music (or the area&#39;s default) as ambient music.
Definition: area.cpp:190
An area in Neverwinter Nights 2, holding all objects, room tiles and terrain within, as well as general area properties like the current background music and ambient sounds.
Definition: area.h:65
Class to hold a sound set.
Definition: ssffile.h:55
Context of an NWScript function.
The context holding a Neverwinter Nights 2 area.
void playSoundByStrRef(Aurora::NWScript::FunctionContext &ctx)
An object within a NWN2 area.
Definition: object.h:58
void musicBackgroundChangeDay(Aurora::NWScript::FunctionContext &ctx)
void setMusicNightTrack(uint32 track)
Set the music track ID playing by night.
Definition: area.cpp:151
void musicBackgroundPlay(Aurora::NWScript::FunctionContext &ctx)
Neverwinter Nights 2 engine functions.
A container of Neverwinter Nights 2 objects.
uint32 getMusicNightTrack() const
Return the music track ID playing by night.
Definition: area.cpp:138
Voice/Speech.
Definition: types.h:46
void playVoiceChat(Aurora::NWScript::FunctionContext &ctx)
Sound::ChannelHandle playSound(const Common::UString &sound, Sound::SoundType soundType, bool loop, float volume, bool pitchVariance)
Play this sound resource.
Definition: util.cpp:81
void playSound(const Common::UString &sound, bool pitchVariance=false)
Play an object sound.
Definition: object.cpp:284
uint32_t uint32
Definition: types.h:204
The global talk manager for Aurora strings.
uint32 getMusicDayTrack() const
Return the music track ID playing by day.
Definition: area.cpp:134
static Aurora::NWScript::Object * getParamObject(const Aurora::NWScript::FunctionContext &ctx, size_t n)
Definition: functions.cpp:118
An object in a Neverwinter Nights 2 area.
Sound effect.
Definition: types.h:45
Generic Aurora engines utility functions.
void musicBackgroundGetNightTrack(Aurora::NWScript::FunctionContext &ctx)
static Area * toArea(Aurora::NWScript::Object *object)
void setMusicDayTrack(uint32 track)
Set the music track ID playing by day.
Definition: area.cpp:146
void musicBackgroundGetDayTrack(Aurora::NWScript::FunctionContext &ctx)
int32_t int32
Definition: types.h:203
void stopAmbientMusic()
Stop the ambient music.
Definition: area.cpp:182