ScummVM API documentation
soundrecords.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11 
12  * This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef NANCY_ACTION_SOUNDRECORDS_H
23 #define NANCY_ACTION_SOUNDRECORDS_H
24 
25 #include "engines/nancy/action/actionrecord.h"
26 
27 namespace Nancy {
28 namespace Action {
29 
30 // Sets the volume for a particular channel.
31 class SetVolume : public ActionRecord {
32 public:
33  void readData(Common::SeekableReadStream &stream) override;
34  void execute() override;
35 
36  uint16 channel = 0;
37  byte volume = 0;
38 
39 protected:
40  Common::String getRecordTypeName() const override { return "SetVolume"; }
41 };
42 
43 // Used for sound effects. From nancy3 up it includes 3D sound data, which lets
44 // the sound move in 3D space as the player rotates/changes scenes. Also supports
45 // changing the scene and/or setting a flag
46 class PlaySound : public ActionRecord {
47 public:
48  PlaySound() {}
49  ~PlaySound() { delete _soundEffect; }
50 
51  void readData(Common::SeekableReadStream &stream) override;
52  void execute() override;
53 
54  SoundDescription _sound;
55  SoundEffectDescription *_soundEffect = nullptr;
56  bool _changeSceneImmediately = false;
57  SceneChangeDescription _sceneChange;
58  FlagDescription _flag;
59 
60 protected:
61  Common::String getRecordTypeName() const override;
62 };
63 
64 // The same as PlaySound, but with the addition of captioning text,
65 // which gets displayed inside the Textbox.
66 class PlaySoundCC : public PlaySound {
67 public:
68  void readData(Common::SeekableReadStream &stream) override;
69  void execute() override;
70 
71  void readCCText(Common::SeekableReadStream &stream, Common::String &out);
72 
73  Common::String _ccText;
74 
75 protected:
76  Common::String getRecordTypeName() const override;
77 };
78 
79 // Short version of PlaySoundCC, no event flag
80 class PlaySoundTerse : public PlaySoundCC {
81 public:
82  void readData(Common::SeekableReadStream &stream) override;
83 
84 protected:
85  Common::String getRecordTypeName() const override { return "PlaySoundTerse"; }
86 };
87 
88 // Short version of PlaySoundCC, with event flag
90 public:
91  void readData(Common::SeekableReadStream &stream) override;
92 
93 protected:
94  Common::String getRecordTypeName() const override { return "PlaySoundEventFlagTerse"; }
95 };
96 
97 // Used for sounds that pan left-right depending on the scene background frame.
98 // Only used in The Vampire Diaries; later games use PlaySound's 3D sound capabilities instead
100 public:
101  void readData(Common::SeekableReadStream &stream) override;
102  void execute() override;
103 
104  SoundDescription _sound;
105 
106 protected:
107  Common::String getRecordTypeName() const override;
108 };
109 
110 // Plays a sound effect; has multiple hotspots, one per scene background frame.
111 // Used in exactly two places; one scene in tvd, and one in nancy1
113 public:
114  void readData(Common::SeekableReadStream &stream) override;
115  void execute() override;
116 
117  SoundDescription _sound; // 0x0
118  SceneChangeDescription _sceneChange; // 0x22
119  FlagDescription _flag; // 0x2A
120  Common::Array<HotspotDescription> _hotspots; // 0x31
121 
122 protected:
123  bool canHaveHotspot() const override { return true; }
124  Common::String getRecordTypeName() const override { return "PlaySoundMultiHS"; }
125 };
126 
127 // Stops a sound if it's loaded and playing. Used very rarely, as sounds (usually)
128 // get auto-stopped on a scene change
129 class StopSound : public ActionRecord {
130 public:
131  void readData(Common::SeekableReadStream &stream) override;
132  void execute() override;
133 
134  uint _channelID;
135  SceneChangeWithFlag _sceneChange;
136 
137 protected:
138  Common::String getRecordTypeName() const override { return "StopSound"; }
139 };
140 
141 // Same as PlaySound, except it randomly picks between one of several
142 // provided sound files; all other settings for the sound are shared.
143 class PlayRandomSound : public PlaySound {
144 public:
145  void readData(Common::SeekableReadStream &stream) override;
146  void execute() override;
147 
148  Common::Array<Common::String> _soundNames;
149 
150  uint _selectedSound = 0;
151 
152 protected:
153  Common::String getRecordTypeName() const override { return "PlayRandomSound"; }
154 };
155 
156 // Short version of PlayRandomSound, but ALSO supports closed captioning text
158 public:
159  void readData(Common::SeekableReadStream &stream) override;
160  void execute() override;
161 
162  Common::Array<Common::String> _soundNames;
164 
165  uint _selectedSound = 0;
166 
167 protected:
168  Common::String getRecordTypeName() const override { return "PlayRandomSoundTerse"; }
169 };
170 
171 // Same as PlaySound, except it discards the filename provided in the data.
172 // Instead, it takes the current value of an item in TableData, and appends that
173 // value to the end of the base filename provided in the TABL chunk. Does not contain
174 // any CC text inside the record data; instead, that also gets copied over from TABL.
176 public:
177  void readData(Common::SeekableReadStream &stream) override;
178  void execute() override;
179 
180 protected:
181  Common::String getRecordTypeName() const override { return "TableIndexPlaySound"; }
182 
183  uint16 _tableIndex = 0;
184  int16 _lastIndexVal = -1;
185 };
186 
187 } // End of namespace Action
188 } // End of namespace Nancy
189 
190 #endif // NANCY_ACTION_NAVIGATIONRECORDS_H
Definition: str.h:59
Definition: soundrecords.h:80
Definition: soundrecords.h:31
Definition: commontypes.h:151
Definition: array.h:52
Definition: soundrecords.h:129
Definition: soundrecords.h:99
Definition: stream.h:745
Definition: commontypes.h:217
Definition: soundrecords.h:46
Definition: commontypes.h:171
Definition: soundrecords.h:66
Definition: actionrecord.h:97
Definition: soundrecords.h:89
Definition: soundrecords.h:175
Definition: soundrecords.h:112
Definition: soundrecords.h:157
Definition: commontypes.h:254
Definition: commontypes.h:166
Definition: actionmanager.h:32
Definition: soundrecords.h:143