ScummVM API documentation
miscrecords.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_RECORDTYPES_H
23 #define NANCY_ACTION_RECORDTYPES_H
24 
25 #include "engines/nancy/action/actionrecord.h"
26 #include "engines/nancy/enginedata.h"
27 
28 namespace Nancy {
29 
30 class NancyEngine;
31 
32 namespace Action {
33 
34 // Changes the palette for the current scene's background. TVD only.
36 public:
37  void readData(Common::SeekableReadStream &stream) override;
38  void execute() override;
39 
40  byte _paletteID;
41  byte _unknownEnum; // enum w values 1-3
42  uint16 _paletteStart;
43  uint16 _paletteSize;
44 
45 protected:
46  Common::String getRecordTypeName() const override { return "PaletteThisScene"; }
47 };
48 
49 // Changes the palette for the next scene's background. TVD only.
51 public:
52  void readData(Common::SeekableReadStream &stream) override;
53  void execute() override;
54 
55  byte _paletteID;
56 
57 protected:
58  Common::String getRecordTypeName() const override { return "PaletteNextScene"; }
59 };
60 
61 // Turns on (temporary) lightning effect. TVD Only.
62 class LightningOn : public ActionRecord {
63 public:
64  void readData(Common::SeekableReadStream &stream) override;
65  void execute() override;
66 
67  int16 _distance;
68  uint16 _pulseTime;
69  int16 _rgbPercent;
70 
71 protected:
72  Common::String getRecordTypeName() const override { return "LightningOn"; }
73 };
74 
75 // Requests either a fade between two scenes, or a fade to black; fade executes when scene is changed. Nancy2 and up.
76 class SpecialEffect : public ActionRecord {
77 public:
78  void readData(Common::SeekableReadStream &stream) override;
79  void execute() override;
80 
81  byte _type = 1;
82  uint16 _fadeToBlackTime = 0;
83  uint16 _frameTime = 0;
84  uint16 _totalTime = 0;
85  Common::Rect _rect;
86 
87 protected:
88  Common::String getRecordTypeName() const override { return "SpecialEffect"; }
89 };
90 
91 // Adds a caption to the textbox. The Nancy 11+ "autotext" variant (AR 81),
92 // carries an extra header that makes the record wait for a sound to finish
93 // or a timer to elapse before it completes; in both variants the body is
94 // either inline text or resolved from an AUTOTEXT key.
95 class TextBoxWrite : public ActionRecord {
96 public:
97  enum WaitMode { kWaitNone = 0, kWaitForSound = 1, kWaitForTimer = 2 };
98 
99  TextBoxWrite(bool isAutotext = false) : _isAutotext(isAutotext) {}
100 
101  void readData(Common::SeekableReadStream &stream) override;
102  void execute() override;
103 
104  Common::String _text;
105 
106  // Nancy 11+ AR 81 only
107  bool _isAutotext;
108  int16 _waitMode = 0;
109  uint16 _soundChannel = 0;
110  uint32 _waitTimeMs = 0;
111 
112 protected:
113  Common::String getRecordTypeName() const override { return _isAutotext ? "AutotextTextBoxWrite" : "TextBoxWrite"; }
114 
115 private:
116  uint32 _endTime = 0;
117 };
118 
119 // Clears the textbox. Used very rarely.
120 class TextboxClear : public ActionRecord {
121 public:
122  void readData(Common::SeekableReadStream &stream) override;
123  void execute() override;
124 
125 protected:
126  Common::String getRecordTypeName() const override { return "TextboxClear"; }
127 };
128 
129 // Nancy 10+ replacement for TextBoxWrite. Pushes a line of conversation
130 // text into the new (UICO-driven) textbox
131 class FrameTextBox : public ActionRecord {
132 public:
133  enum Variant {
134  kVariant74 = 74,
135  kVariant75 = 75
136  };
137 
138  FrameTextBox(Variant variant) : _variant(variant), _flags(0), _slot(0) {}
139 
140  void readData(Common::SeekableReadStream &stream) override;
141  void execute() override;
142 
143  Variant _variant;
144  Common::String _text;
145  int16 _flags;
146  int16 _slot;
147 
148 protected:
149  Common::String getRecordTypeName() const override { return "FrameTextBox"; }
150 };
151 
152 // Nancy 10+ opcode 29. Toggles whether one of the taskbar popups
153 // (inventory / notebook / cellphone) is enabled.
154 class ControlUIItems : public ActionRecord {
155 public:
156  enum UIType {
157  kUITypeInventory = 1,
158  kUITypeNotebook = 2,
159  kUITypeCellphone = 3
160  };
161 
162  void readData(Common::SeekableReadStream &stream) override;
163  void execute() override;
164 
165  uint16 _uiButton = 0;
166  byte _autoOpenOrBadgeSound = 0; // 1 = auto-open popup; 0/10 = notification-badge click-sound selector
167  byte _flagB = 0; // 0 = clear, 1 = enable+remember scene
168  int16 _startScene = 0; // start scene id (9999 = none); also the auto-open cell phone's call target
169  int16 _endScene = 0; // end scene id (9999 = none)
170 
171 protected:
172  Common::String getRecordTypeName() const override { return "ControlUIItems"; }
173 };
174 
175 // Nancy 10+ opcode 32. Prepares a UI popup
177 public:
178  void readData(Common::SeekableReadStream &stream) override;
179  void execute() override;
180 
181  int32 _uiType = 0;
182  int32 _signalValue = 0;
183 
184 protected:
185  Common::String getRecordTypeName() const override { return "UIPopupPrepScene"; }
186 };
187 
188 // Nancy 10+ opcode 131. Pushes a new entry into either the cellphone
189 // search-results list (mode 0) or the URL link list (mode 1).
190 class AddSearchLink : public ActionRecord {
191 public:
192  void readData(Common::SeekableReadStream &stream) override;
193  void execute() override;
194 
195  int16 _mode = 0;
196  Common::String _key; // CVTX key for the list row text (both modes)
197  Common::String _value; // body CVTX key (mode 0/email); unused for mode 1
198  int16 _extra = 0; // page index (mode 1); unused for mode 0
199  int16 _flag = 0; // stored but unused by the original; reserved
200  int16 _eventFlag = 0; // event-flag index set when the entry is opened
201 
202 protected:
203  Common::String getRecordTypeName() const override { return "AddSearchLink"; }
204 };
205 
206 // Sets the cellphone's battery/signal indicators. Modes 0/1 toggle the
207 // battery (normal / low) and 2/3 toggle the signal (normal / no signal).
209 public:
210  void readData(Common::SeekableReadStream &stream) override;
211  void execute() override;
212 
213  uint16 _mode = 0;
214 
215 protected:
216  Common::String getRecordTypeName() const override { return "SetCellPhoneBatteryAndSignal"; }
217 };
218 
219 // Adds a new entry to the cellphone directory, or overwrites an existing
220 // one matched by dial pattern. Used to unlock contacts as the player
221 // progresses (Nancy 10+).
223 public:
224  void readData(Common::SeekableReadStream &stream) override;
225  void execute() override;
226 
227  UICL::Contact _contact;
228 
229 protected:
230  Common::String getRecordTypeName() const override { return "ChangeCellPhoneInfo"; }
231 };
232 
233 // Returns from a cellphone-driven conversation scene to the pre-call scene.
234 // sceneID == kNoScene pops the saved scene; any other sceneID overrides it.
236 public:
237  void readData(Common::SeekableReadStream &stream) override;
238  void execute() override;
239 
240  SceneChangeDescription _sceneChange;
241 
242 protected:
243  Common::String getRecordTypeName() const override { return "CellPhonePopCellSceneFromStack"; }
244 };
245 
246 // Changes the in-game time. Used prior to the introduction of SetPlayerClock.
248 public:
249  void readData(Common::SeekableReadStream &stream) override;
250  void execute() override;
251 
252  byte _relative;
253  uint16 _hours;
254  uint16 _minutes;
255 
256 protected:
257  Common::String getRecordTypeName() const override { return "BumpPlayerClock"; }
258 };
259 
260 // Creates a Second Chance save.
262 public:
263  void readData(Common::SeekableReadStream &stream) override;
264  void execute() override;
265 
266 protected:
267  Common::String getRecordTypeName() const override { return "SaveContinueGame"; }
268 };
269 
270 // Stops the screen from rendering. Our rendering system is different from the original engine's,
271 // so we have no use for this.
273 public:
274  void readData(Common::SeekableReadStream &stream) override;
275 
276 protected:
277  Common::String getRecordTypeName() const override { return "TurnOffMainRendering"; }
278 };
279 
280 // Restarts screen rendering. Our rendering system is different from the original engine's,
281 // so we have no use for this.
283 public:
284  void readData(Common::SeekableReadStream &stream) override;
285 
286 protected:
287  Common::String getRecordTypeName() const override { return "TurnOnMainRendering"; }
288 };
289 
290 // Starts the timer. Used in combination with Dependency types that check for
291 // how much time has passed since the timer was started. From Nancy 11 onwards
292 // the record also carries a software-timer slot index (see TimerControl).
294 public:
295  void readData(Common::SeekableReadStream &stream) override;
296  void execute() override;
297 
298  byte _timerIndex = 0; // Nancy 11+ software-timer slot
299 
300 protected:
301  Common::String getRecordTypeName() const override { return "ResetAndStartTimer"; }
302 };
303 
304 // Stops the timer.
305 class StopTimer : public ActionRecord {
306 public:
307  void readData(Common::SeekableReadStream &stream) override;
308  void execute() override;
309 
310  byte _timerIndex = 0; // Nancy 11+ software-timer slot
311 
312 protected:
313  Common::String getRecordTypeName() const override { return "StopTimer"; }
314 };
315 
316 // Nancy 11+ AR 69 (AT_TIMER_CONTROL). Issues a command to one of the 10
317 // software-timer slots (see TimerData::Timer). The fixed-size chunk
318 // (0xc4 header + count*4 flag entries) carries a slot index, a command, a
319 // target duration, an optional sound + caption, and the event flags to fire
320 // when the timer expires.
321 class TimerControl : public ActionRecord {
322 public:
323  enum Command {
324  kReset = 0, // Clear the slot back to idle
325  kStart = 1, // Begin counting, with no target
326  kPause = 2, // Suspend counting
327  kAddTime = 3, // Add the duration to the elapsed time
328  kSubtractTime = 4, // Subtract the duration from the elapsed time
329  kConfigOneShot = 5, // Set target/payload; fire once, then reset
330  kConfigRepeating = 6 // Set target/payload; fire once, then keep running
331  };
332 
333  void readData(Common::SeekableReadStream &stream) override;
334  void execute() override;
335 
336  int16 _timerIndex = 0;
337  int16 _command = 0;
338  int16 _hours = 0;
339  int16 _minutes = 0;
340  int16 _seconds = 0;
341 
342  SoundDescription _sound;
343  Common::String _autotextKey;
344  Common::String _caption;
346 
347 protected:
348  Common::String getRecordTypeName() const override { return "TimerControl"; }
349 };
350 
351 // Nancy 11+ AR 30. Disables the player's ability to scroll/pan the viewport
352 // (both mouse-edge and keyboard movement). State persists across scene changes.
354 public:
355  void readData(Common::SeekableReadStream &stream) override;
356  void execute() override;
357 
358 protected:
359  Common::String getRecordTypeName() const override { return "StopPlayerScrolling"; }
360 };
361 
362 // Nancy 11+ AR 31. Re-enables the player's ability to scroll/pan the viewport.
364 public:
365  void readData(Common::SeekableReadStream &stream) override;
366  void execute() override;
367 
368 protected:
369  Common::String getRecordTypeName() const override { return "StartPlayerScrolling"; }
370 };
371 
372 // Returns the player back to the main menu
373 class GotoMenu : public ActionRecord {
374 public:
375  void readData(Common::SeekableReadStream &stream) override;
376  void execute() override;
377 
378 protected:
379  Common::String getRecordTypeName() const override { return "GotoMenu"; }
380 };
381 
382 // Stops the game and boots the player back to the Menu screen, while also making sure
383 // they can't Continue. The devs took care to add Second Chance saves before every one
384 // of these, to make sure the player can return to a state just before the dangerous part.
385 class LoseGame : public ActionRecord {
386 public:
387  void readData(Common::SeekableReadStream &stream) override;
388  void execute() override;
389 
390 protected:
391  Common::String getRecordTypeName() const override { return "LoseGame"; }
392 };
393 
394 // Adds a scene to the "stack" (which is just a single value). Used in combination with PopScene.
395 class PushScene : public ActionRecord {
396 public:
397  void readData(Common::SeekableReadStream &stream) override;
398  void execute() override;
399 
400 protected:
401  Common::String getRecordTypeName() const override { return "PushScene"; }
402 };
403 
404 // Changes to the scene pushed onto the "stack". Scenes can be pushed via PushScene, or Conversation types.
405 class PopScene : public ActionRecord {
406 public:
407  void readData(Common::SeekableReadStream &stream) override;
408  void execute() override;
409 
410 protected:
411  Common::String getRecordTypeName() const override { return "PopScene"; }
412 };
413 
414 // Ends the game and boots the player to the Credits screen.
415 // TODO: The original engine also sets a config option called PlayerWonTheGame,
416 // which in turn is used to trigger whichever event flag marks that the player
417 // has beat the game at least once, which in turn allows easter eggs to be shown.
418 // We currently support none of this.
419 class WinGame : public ActionRecord {
420 public:
421  void readData(Common::SeekableReadStream &stream) override;
422  void execute() override;
423 
424 protected:
425  Common::String getRecordTypeName() const override { return "WinGame"; }
426 };
427 
428 // Checks how many hints the player is allowed to get. If they are still allowed hints,
429 // it selects an appropriate one and plays its sound/displays its caption in the Textbox.
430 // The hint system was _only_ used in nancy1, since it's pretty limited and overly punishing.
431 class HintSystem : public ActionRecord {
432 public:
433  void readData(Common::SeekableReadStream &stream) override;
434  void execute() override;
435 
436  byte _characterID; // 0x00
437  SoundDescription _genericSound; // 0x01
438 
439  const Hint *selectedHint;
440  int16 _hintID;
441 
442  void selectHint();
443 
444 protected:
445  Common::String getRecordTypeName() const override { return "HintSystem"; }
446 };
447 
448 } // End of namespace Action
449 } // End of namespace Nancy
450 
451 #endif // NANCY_ACTION_MISCRECORDS_H
Definition: miscrecords.h:62
Definition: miscrecords.h:154
Definition: str.h:59
Definition: miscrecords.h:385
Definition: commontypes.h:152
Definition: array.h:52
Definition: miscrecords.h:353
Definition: enginedata.h:590
Definition: commontypes.h:302
Definition: miscrecords.h:395
Definition: miscrecords.h:419
Definition: miscrecords.h:282
Definition: rect.h:524
Definition: actionrecord.h:165
Definition: miscrecords.h:95
Definition: stream.h:745
Definition: miscrecords.h:76
Definition: miscrecords.h:120
Definition: miscrecords.h:305
Definition: miscrecords.h:35
Definition: miscrecords.h:373
Definition: miscrecords.h:363
Definition: miscrecords.h:272
Definition: actionrecord.h:97
Definition: miscrecords.h:208
Definition: miscrecords.h:176
Definition: miscrecords.h:405
Definition: miscrecords.h:131
Definition: miscrecords.h:261
Definition: miscrecords.h:321
Definition: commontypes.h:255
Definition: miscrecords.h:293
Definition: miscrecords.h:50
Definition: miscrecords.h:247
Definition: miscrecords.h:222
Definition: miscrecords.h:431
Definition: actionmanager.h:32