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 
28 
30 
34 
36 
37 namespace Engines {
38 
39 namespace Witcher {
40 
43 
44  const Common::UString sound = TalkMan.getSoundResRef((uint32) ctx.getParams()[0].getInt());
45 
46  // TODO: Run as action
47  // bool runAsAction = ctx.getParams()[1].getInt() != 0;
48 
49  if (object)
50  object->playSound(sound);
51  else
53 }
54 
57 
58  if (object)
59  object->playSound(ctx.getParams()[0].getString());
60  else
62 
64 }
65 
68  if (area)
69  area->playAmbientMusic();
70 }
71 
74  if (area)
75  area->stopAmbientMusic();
76 }
77 
80  if (area)
81  area->setMusicDayTrack(ctx.getParams()[1].getInt());
82 }
83 
86  if (area)
87  area->setMusicNightTrack(ctx.getParams()[1].getInt());
88 }
89 
92 
93  ctx.getReturn() = area ? (int32)area->getMusicDayTrack() : -1;
94 }
95 
98 
99  ctx.getReturn() = area ? (int32)area->getMusicNightTrack() : -1;
100 }
101 
102 } // End of namespace Witcher
103 
104 } // End of namespace Engines
void musicBackgroundGetNightTrack(Aurora::NWScript::FunctionContext &ctx)
A container of The Witcher objects.
void playSound(Aurora::NWScript::FunctionContext &ctx)
An area in The Witcher, holding all objects and area geometry within, as well as general area propert...
Definition: area.h:63
#define TalkMan
Shortcut for accessing the talk manager.
Definition: talkman.h:111
A class holding an UTF-8 string.
Definition: ustring.h:48
void playSound(const Common::UString &sound, bool pitchVariance=false)
Play an object sound.
Definition: object.cpp:207
An object within a Witcher area.
Definition: object.h:51
void playAmbientMusic(Common::UString music="")
Play the specified music (or the area&#39;s default) as ambient music.
Definition: area.cpp:155
Context of an NWScript function.
static Area * toArea(Aurora::NWScript::Object *object)
uint32 getMusicNightTrack() const
Return the music track ID playing by night.
Definition: area.cpp:128
uint32 getMusicDayTrack() const
Return the music track ID playing by day.
Definition: area.cpp:124
static Aurora::NWScript::Object * getParamObject(const Aurora::NWScript::FunctionContext &ctx, size_t n)
Definition: functions.cpp:124
void musicBackgroundPlay(Aurora::NWScript::FunctionContext &ctx)
void musicBackgroundChangeNight(Aurora::NWScript::FunctionContext &ctx)
void musicBackgroundGetDayTrack(Aurora::NWScript::FunctionContext &ctx)
An object in a The Witcher area.
void unimplementedFunction(Aurora::NWScript::FunctionContext &ctx)
Definition: functions.cpp:98
void stopAmbientMusic()
Stop the ambient music.
Definition: area.cpp:151
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
void playSoundByStrRef(Aurora::NWScript::FunctionContext &ctx)
uint32_t uint32
Definition: types.h:204
The global talk manager for Aurora strings.
The Witcher engine functions.
The context holding a The Witcher area.
Sound effect.
Definition: types.h:45
Generic Aurora engines utility functions.
void musicBackgroundChangeDay(Aurora::NWScript::FunctionContext &ctx)
void setMusicDayTrack(uint32 track)
Set the music track ID playing by day.
Definition: area.cpp:136
void setMusicNightTrack(uint32 track)
Set the music track ID playing by night.
Definition: area.cpp:141
static Witcher::Object * toObject(::Aurora::NWScript::Object *object)
void musicBackgroundStop(Aurora::NWScript::FunctionContext &ctx)
int32_t int32
Definition: types.h:203