ScummVM API documentation
navigationrecords.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_NAVIGATIONRECORDS_H
23 #define NANCY_ACTION_NAVIGATIONRECORDS_H
24 
25 #include "engines/nancy/action/actionrecord.h"
26 
27 #include "engines/nancy/state/scenestream.h"
28 
29 namespace Nancy {
30 namespace Action {
31 
32 // Simply changes the scene
33 class SceneChange : public ActionRecord {
34 public:
35  // Nancy16: whether the record also names the frame to open the scene at
36  enum FrameType {
37  kWithFrame,
38  kWithoutFrame
39  };
40 
41  SceneChange(FrameType frameType = kWithFrame) : _frameType(frameType) {}
42 
43  void readData(Common::SeekableReadStream &stream) override;
44  void execute() override;
45 
46  SceneChangeDescription _sceneChange;
47 
48  Common::String getRecordExtraInfo() const override { return Common::String::format("Scene %d", _sceneChange.sceneID); }
49 
50 protected:
51  Common::String getRecordTypeName() const override { return "SceneChange"; }
52 
53  void readDataNancy16(Common::SeekableReadStream &stream);
54 
55  FrameType _frameType;
56 };
57 
58 // Changes the scene when clicked
60 public:
62  _hasHotspot = false;
63  _hoverCursor = CursorManager::kNormal;
64  }
65  virtual ~HotSingleFrameSceneChange() {}
66 
67  void readData(Common::SeekableReadStream &stream) override;
68  void execute() override;
69 
70  CursorManager::CursorType getHoverCursor() const override { return _hoverCursor; }
71  bool cursorSetFromScript() const override { return false; }
72 
73  HotspotDescription _sceneHotspot;
74 
75  bool canHaveHotspot() const override { return true; }
76 
77 protected:
78  CursorManager::CursorType _hoverCursor;
79 
80  Common::String getRecordTypeName() const override { return "HotSingleFrameSceneChange"; }
81 };
82 
83 // Changes the scene when clicked. Hotspot can move along with scene background frame.
84 // Nancy4 introduced several sub-types with a specific mouse cursor to show when
85 // hovering; all of them are handled in this class as well.
87 public:
88  HotMultiframeSceneChange(CursorManager::CursorType hoverCursor, bool isTerse = false) :
89  _hoverCursor(hoverCursor), _isTerse(isTerse) {}
90  virtual ~HotMultiframeSceneChange() {}
91 
92  void readData(Common::SeekableReadStream &stream) override;
93  void execute() override;
94 
95  CursorManager::CursorType getHoverCursor() const override { return _hoverCursor; }
96  bool cursorSetFromScript() const override { return _isTerse; }
97 
99  bool _isTerse = false;
100 
101  bool canHaveHotspot() const override { return true; }
102 
103 protected:
104  Common::String getRecordTypeName() const override {
105  if (_isTerse)
106  return "HotMultiframeSceneChangeTerse";
107 
108  switch (_hoverCursor) {
109  case CursorManager::kMoveForward:
110  return "HotMultiframeForwardSceneChange";
111  case CursorManager::kMoveUp:
112  return "HotMultiframeUpSceneChange";
113  case CursorManager::kMoveDown:
114  return "HotMultiframeDownSceneChange";
115  default:
116  return "HotMultiframeSceneChange";
117  }
118  }
119 
120  CursorManager::CursorType _hoverCursor;
121 };
122 
123 // Changes the scene when clicked; does _not_ move with scene background.
124 // Nancy4 introduced several sub-types with a specific mouse cursor to show when
125 // hovering; all of them are handled in this class as well.
127 public:
128  Hot1FrSceneChange(CursorManager::CursorType hoverCursor, bool dynamicCursor = false, bool isTerse = false) :
129  _hoverCursor(hoverCursor), _dynamicCursor(dynamicCursor), _isTerse(isTerse) {}
130  virtual ~Hot1FrSceneChange() {}
131 
132  void readData(Common::SeekableReadStream &stream) override;
133  void execute() override;
134 
135  CursorManager::CursorType getHoverCursor() const override { return _hoverCursor; }
136  bool cursorSetFromScript() const override { return _dynamicCursor; }
137 
138  HotspotDescription _hotspotDesc;
139  bool _isTerse = false;
140  bool _dynamicCursor = false;
141 
142  bool canHaveHotspot() const override { return true; }
143 
144 protected:
145  Common::String getRecordTypeName() const override {
146  if (_isTerse)
147  return "HotSceneChangeTerse";
148 
149  switch (_hoverCursor) {
150  case CursorManager::kExit:
151  return "Hot1FrExitSceneChange";
152  case CursorManager::kMoveForward:
153  return "Hot1FrForwardSceneChange";
154  case CursorManager::kMoveBackward:
155  return "Hot1FrBackSceneChange";
156  case CursorManager::kMoveUp:
157  return "Hot1FrUpSceneChange";
158  case CursorManager::kMoveDown:
159  return "Hot1FrDownSceneChange";
160  case CursorManager::kMoveLeft:
161  return "Hot1FrLeftSceneChange";
162  case CursorManager::kMoveRight:
163  return "Hot1FrRightSceneChange";
164  default:
165  return "Hot1FrSceneChange";
166  }
167  }
168 
169  CursorManager::CursorType _hoverCursor;
170 };
171 
172 // Changes the scene when clicked. Hotspot can move along with scene background frame.
173 // However, the scene it changes to can be one of two options, picked based on
174 // a provided condition.
176 public:
177  void readData(Common::SeekableReadStream &stream) override;
178  void execute() override;
179 
180  SceneChangeWithFlag _onTrue;
181  SceneChangeWithFlag _onFalse;
182  byte _condType;
183  uint16 _conditionID;
184  byte _conditionPayload;
186 
187  bool canHaveHotspot() const override { return true; }
188 
189 protected:
190  Common::String getRecordTypeName() const override { return "HotMultiframeMultisceneChange"; }
191 };
192 
193 // Changes the scene when clicked. Hotspot can move along with scene background frame.
194 // However, the scene it changes to can be one of several options, picked based on
195 // the item the player is currently holding.
197 public:
198  void readData(Common::SeekableReadStream &stream) override;
199  void execute() override;
200 
202  Common::Array<uint16> _cursorTypes;
203 
204  SceneChangeDescription _defaultScene;
206 
207  Common::String getRecordExtraInfo() const override { return Common::String::format("Default scene %d", _defaultScene.sceneID); }
208 
209 protected:
210  Common::String getRecordTypeName() const override { return "HotMultiframeMultisceneCursorTypeSceneChange"; }
211 };
212 
213 // Nancy13 replacement for the record above (AR 27 in both). Also picks what happens
214 // from the item the player is holding, but every accepted item now comes with its own
215 // sound and event flags, and says whether it is returned to the inventory or used up.
216 // The scene only changes once the sound has finished playing.
218 public:
219  // One branch of the record. The same block, minus the item fields, describes
220  // what happens when the held item matches nothing.
221  struct ItemUse {
222  void readData(Common::SeekableReadStream &stream);
223 
224  int16 itemID = -1;
225  bool loseItem = false;
226  SoundDescription sound;
227  Common::String ccText;
228  uint16 sceneID = kNoScene;
230  };
231 
232  void readData(Common::SeekableReadStream &stream) override;
233  void execute() override;
234 
235  Common::Array<ItemUse> _itemUses;
236  ItemUse _defaultItemUse;
238 
239  bool canHaveHotspot() const override { return true; }
240 
241  Common::String getRecordExtraInfo() const override { return Common::String::format("Default scene %d", _defaultItemUse.sceneID); }
242 
243 protected:
244  Common::String getRecordTypeName() const override { return "HotMultiframeInvTypeSceneChange"; }
245 
246  // The branch the record is currently waiting on; also marks that it has triggered
247  const ItemUse *_activeUse = nullptr;
248 };
249 
250 // Simply switches to the Map state. TVD/nancy1 only.
251 class MapCall : public ActionRecord {
252 public:
253  void readData(Common::SeekableReadStream &stream) override;
254  void execute() override;
255 
256  CursorManager::CursorType getHoverCursor() const override { return CursorManager::kExit; }
257 
258 protected:
259  Common::String getRecordTypeName() const override { return "MapCall"; }
260 };
261 
262 // Switches to the Map state when clicked; does _not_ move with background frame. TVD/nancy1 only.
263 class MapCallHot1Fr : public MapCall {
264 public:
265  void readData(Common::SeekableReadStream &stream) override;
266  void execute() override;
267 
268  HotspotDescription _hotspotDesc;
269 
270  bool canHaveHotspot() const override { return true; }
271 
272 protected:
273  Common::String getRecordTypeName() const override { return "MapCallHot1Fr"; }
274 };
275 
276 // Switches to the Map state when clicked. Hotspot can move along with scene background frame. TVD/nancy1 only.
278 public:
279  void readData(Common::SeekableReadStream &stream) override;
280  void execute() override;
281 
283 
284  bool canHaveHotspot() const override { return true; }
285 
286 protected:
287  Common::String getRecordTypeName() const override { return "MapCallHotMultiframe"; }
288 };
289 
290 // Nancy16+ scene change which can also set event flags, wait for a click on a
291 // hotspot, and (Nancy17) change the scene of another stream
293 public:
294  enum Extras {
295  kStreamName = 1 << 0,
296  kSingleFlag = 1 << 1,
297  kFlagList = 1 << 2,
298  kHotspots = 1 << 3
299  };
300 
301  SceneChangeWithExtras(uint extras) : _extras(extras) { _flags.descs.clear(); }
302 
303  void readData(Common::SeekableReadStream &stream) override;
304  void execute() override;
305 
306  CursorManager::CursorType getHoverCursor() const override { return _hoverCursor; }
307  bool canHaveHotspot() const override { return (_extras & kHotspots) != 0; }
308 
309 protected:
310  Common::String getRecordTypeName() const override { return "SceneChangeWithExtras"; }
311 
312  uint _extras;
313  Common::String _streamName;
315  CursorManager::CursorType _hoverCursor = CursorManager::kHotspot;
317 };
318 
319 // Nancy17. Starts a scene in a stream of its own, next to the scene that asks for it
320 class BeginStream : public ActionRecord {
321 public:
322  void readData(Common::SeekableReadStream &stream) override;
323  void execute() override;
324 
325 protected:
326  Common::String getRecordTypeName() const override { return "BeginStream"; }
327 
328  Common::String _sceneName; // e.g. "s4409"
329  uint32 _frameID = 0;
330  Common::String _streamName; // e.g. "BRU_Random_sfx"
331  State::StreamFlags _flags;
332 };
333 
334 // Nancy17. Ends a stream; without a name, the one the record runs in
335 class EndStream : public ActionRecord {
336 public:
337  void readData(Common::SeekableReadStream &stream) override;
338  void execute() override;
339 
340 protected:
341  Common::String getRecordTypeName() const override { return "EndStream"; }
342 
343  Common::String _streamName;
344 };
345 
346 // Nancy17. Sets a flag once a stream has moved on to another scene
347 class OnSceneChange : public ActionRecord {
348 public:
349  void readData(Common::SeekableReadStream &stream) override;
350  void execute() override;
351 
352 protected:
353  Common::String getRecordTypeName() const override { return "OnSceneChange"; }
354 
355  Common::String _streamName;
356  FlagDescription _flag;
357  Common::String _sceneName;
358 };
359 
360 } // End of namespace Action
361 } // End of namespace Nancy
362 
363 #endif // NANCY_ACTION_NAVIGATIONRECORDS_H
Definition: navigationrecords.h:251
Definition: commontypes.h:235
Definition: navigationrecords.h:175
Definition: str.h:59
static String format(MSVC_PRINTF const char *fmt,...) GCC_PRINTF(1
Definition: navigationrecords.h:347
Definition: commontypes.h:186
Definition: array.h:52
Definition: navigationrecords.h:33
Definition: stream.h:745
Definition: commontypes.h:206
Definition: scenestream.h:53
Definition: navigationrecords.h:292
Definition: navigationrecords.h:86
Definition: navigationrecords.h:59
Definition: actionrecord.h:107
Definition: navigationrecords.h:217
Definition: navigationrecords.h:277
Definition: commontypes.h:306
Definition: navigationrecords.h:335
Definition: navigationrecords.h:263
Definition: commontypes.h:201
Definition: navigationrecords.h:126
Definition: commontypes.h:215
Definition: navigationrecords.h:320
Definition: actionmanager.h:32