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 
26 
29 #include "src/engines/kotor/area.h"
31 
33 
34 namespace Engines {
35 
36 namespace KotOR {
37 
40  if (area)
41  area->playAmbientMusic();
42 }
43 
46  if (area)
47  area->stopAmbientMusic();
48 }
49 
52  if (area)
53  area->setMusicDayTrack(ctx.getParams()[1].getInt());
54 }
55 
58  if (area)
59  area->setMusicNightTrack(ctx.getParams()[1].getInt());
60 }
61 
64 
65  ctx.getReturn() = area ? (int32)area->getMusicDayTrack() : -1;
66 }
67 
70 
71  ctx.getReturn() = area ? (int32)area->getMusicNightTrack() : -1;
72 }
73 
76 
77  if (!sound)
78  throw Common::Exception("Function::soundObjectPlay(): object is not a sound");
79 
80  sound->play();
81 }
82 
85 
86  if (!sound)
87  throw Common::Exception("Function::soundObjectStop(): object is not a sound");
88 
89  sound->stop();
90 }
91 
92 } // End of namespace KotOR
93 
94 } // End of namespace Engines
void musicBackgroundGetDayTrack(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:180
Context of an NWScript function.
static SoundObject * toSoundObject(Aurora::NWScript::Object *object)
void musicBackgroundPlay(Aurora::NWScript::FunctionContext &ctx)
An ingame sound in kotor.
void setMusicDayTrack(uint32 track)
Set the music track ID playing by day.
Definition: area.cpp:135
void musicBackgroundGetNightTrack(Aurora::NWScript::FunctionContext &ctx)
A container of Star Wars: Knights of the Old Republic objects.
void stopAmbientMusic()
Stop the ambient music.
Definition: area.cpp:172
StackException Exception
Definition: error.h:59
An area in Star Wars: Knights of the Old Republic, holding all objects and rooms within, as well as general area properties like the current background music and ambient sounds.
Definition: area.h:65
Star Wars: Knights of the Old Republic engine functions.
void soundObjectPlay(Aurora::NWScript::FunctionContext &ctx)
The context holding a Star Wars: Knights of the Old Republic area.
uint32 getMusicDayTrack() const
Return the music track ID playing by day.
Definition: area.cpp:123
An object in a Star Wars: Knights of the Old Republic area.
static Aurora::NWScript::Object * getParamObject(const Aurora::NWScript::FunctionContext &ctx, size_t n)
Definition: functions.cpp:117
static Area * toArea(Aurora::NWScript::Object *object)
void musicBackgroundChangeNight(Aurora::NWScript::FunctionContext &ctx)
uint32 getMusicNightTrack() const
Return the music track ID playing by night.
Definition: area.cpp:127
void soundObjectStop(Aurora::NWScript::FunctionContext &ctx)
void musicBackgroundChangeDay(Aurora::NWScript::FunctionContext &ctx)
void setMusicNightTrack(uint32 track)
Set the music track ID playing by night.
Definition: area.cpp:140
int32_t int32
Definition: types.h:203
void musicBackgroundStop(Aurora::NWScript::FunctionContext &ctx)