ScummVM API documentation
commontypes.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_COMMONYPES_H
23#define NANCY_COMMONYPES_H
24
25#include "common/rect.h"
26#include "common/array.h"
27#include "common/language.h"
28#include "common/path.h"
29#include "common/str.h"
30#include "math/vector3d.h"
31
32namespace Common {
33class SeekableReadStream;
34}
35
36namespace Nancy {
37
38class NancyEngine;
39
40// The original engine used a large amount of #defines for numerical constants,
41// which can be found listed inside the gameflow.h file shipping with many of
42// the titles (the Russian variant of nancy1 has it as a separate file, while
43// nancy2 and above embed it within the ciftree).
44//
45// Other, more specific constants are declared within their related classes,
46// so as not to litter the namespace
47
48static const int8 kFlagNoLabel = -1;
49static const int8 kEvNoEvent = -1;
50static const int8 kFrNoFrame = -1;
51static const uint16 kNoScene = 9999;
52static const uint16 kNoSceneNancy17 = 0x7fff; // what the Nancy17 data has in its place
53
54// Nancy15 alternates between three protagonists (Nancy and the Hardy boys
55// Frank and Joe), each of whom keeps their own UI and journal. The two
56// brothers share their progress: whichever is played second inherits it
57// from the other.
58static const uint kMaxPlayerCharacters = 3;
59static const uint kPlayerCharacterFrank = 1;
60static const uint kPlayerCharacterJoe = 2;
61
62// Inventory action records name the character whose inventory they change.
63// This value stands for whoever is being played at the time.
64static const byte kPlayerCharacterActive = 9;
65
66// Taskbar popup UI types. Shared by ControlUIItems (AR 29), UIPopupPrepScene
67// (AR 32) and the Scene UI-prep-scene machinery.
68enum UIType {
69 kUITypeInventory = 1,
70 kUITypeNotebook = 2,
71 kUITypeCellphone = 3
72};
73
74// Inventory items use types
75static const byte kInvItemUseThenLose = 0;
76static const byte kInvItemKeepAlways = 1;
77static const byte kInvItemReturn = 2;
78static const byte kInvItemNewSceneView = 3;
79
80// Nancy15 EnableDisableInventory records can name a whole group of items
81// instead of a single one
82static const uint16 kInvItemGroupAll = 100;
83static const uint16 kInvItemGroupViewable = 101;
84static const uint16 kInvItemGroupPortable = 102;
85
86// Inventory item sound override commands
87static const byte kInvSoundOverrideCommandNoSound = 0;
88static const byte kInvSoundOverrideCommandTurnOff = 1;
89static const byte kInvSoundOverrideCommandNewSound = 2;
90static const byte kInvSoundOverrideCommandICant = 3;
91
92// Dependency types
93static const byte kFlagEvent = 1;
94static const byte kFlagInventory = 2;
95static const byte kFlagCursor = 3;
96
97// Scene panning
98static const byte kPanNone = 0;
99static const byte kPan360 = 1;
100static const byte kPanLeftRight = 2;
101
102// Scene sound flags
103static const byte kContinueSceneSound = 1;
104static const byte kLoadSceneSound = 0;
105
106// Scene rotation special values
107static const uint16 kInvertedNode = 77;
108static const uint16 kNoAutoScroll = 333;
109
110// Clock bump types
111static const byte kAbsoluteClockBump = 1;
112static const byte kRelativeClockBump = 2;
113
114// Time of day
115static const byte kPlayerDay = 0;
116static const byte kPlayerNight = 1;
117static const byte kPlayerDuskDawn = 2;
118
119// Video
120static const byte kSmallVideoFormat = 1;
121static const byte kLargeVideoFormat = 2;
122
123// Video container. Auto picks per game type.
124static const byte kVideoPlaytypeAVF = 0;
125static const byte kVideoPlaytypeBink = 1;
126static const byte kVideoPlaytypeAuto = 2;
127
128// Overlay transparency mode. 1 = opaque, anything >= kPlayOverlayTransparent is
129// drawn transparent (the original engine is 16bpp color-key, with no alpha/blend
130// path, so every transparent mode - Nancy12 also uses 3 - is a plain color key).
131static const byte kPlayOverlayPlain = 1;
132static const byte kPlayOverlayTransparent = 2;
133static const byte kPlayOverlayTransparent2 = 3;
134
135static const byte kPlayOverlaySceneChange = 1;
136static const byte kPlayOverlayNoSceneChange = 2;
137
138static const byte kPlayOverlayStatic = 1;
139static const byte kPlayOverlayAnimated = 2;
140
141static const byte kPlayOverlayOnce = 1;
142static const byte kPlayOverlayLoop = 2;
143
144static const byte kPlayOverlayForward = 1;
145static const byte kPlayOverlayReverse = 2;
146
147static const byte kPlayOverlayWithHotspot = 1;
148static const byte kPlayOverlayNoHotspot = 2;
149
150// Table access
151static const byte kNoChangeTableValue = 0;
152static const byte kIncrementTableValue = 1;
153static const byte kDecrementTableValue = 2;
154static const uint16 kNoTableIndex = 99;
155static const int16 kNoTableValue = 9999;
156static const int16 kTimerDurationIndexBase = 5000;
157
158// Autotext ordering info
159static const uint16 kListLIFO = 0;
160static const uint16 kListFIFO = 1;
161
162// 3D sound rotation
163static const byte kRotateAroundX = 0;
164static const byte kRotateAroundY = 1;
165static const byte kRotateAroundZ = 2;
166
167enum MovementDirection : byte { kUp = 1, kDown = 2, kLeft = 4, kRight = 8, kMoveFast = 16 };
168
169// Separate namespace to remove possible clashes
170namespace NancyState {
171enum NancyState {
172 // Original engine states
173 kBoot, kLogo, kCredits, kMap,
174 kMainMenu, kLoadSave, kSetup,
175 kHelp, kScene, kSaveDialog,
176 kDesignSelect, // Nancy15 only
177
178 // Not real states
179 kNone,
180 kQuit,
181 kPause, // only used when the GMM is on screen
182};
183}
184
185// Describes a scene transition
187 uint16 sceneID = kNoScene;
188 uint16 frameID = 0;
189 uint16 verticalOffset = 0;
190 uint16 continueSceneSound = kLoadSceneSound;
191
192 int8 paletteID = -1; // TVD only
193
194 Math::Vector3d listenerFrontVector = Math::Vector3d(0, 0, 1);
195 uint16 frontVectorFrameID = 0;
196
197 void readData(Common::SeekableReadStream &stream, bool longFormat = false);
198};
199
200// Describes a single flag change or comparison
202 int16 label = -1;
203 byte flag = 0;
204};
205
207 SceneChangeDescription _sceneChange;
208 FlagDescription _flag;
209
210 void readData(Common::SeekableReadStream &stream, bool reverseFormat = false, bool terse = false);
211 void execute();
212};
213
214// Describes a hotspot
216 uint16 frameID = 0;
217 Common::Rect coords;
218
219 void readData(Common::SeekableReadStream &stream);
220};
221
222// Describes a blit operation, dependent on a background frame
224 uint16 frameID = 0; // Frame ID of the Scene background
225 uint16 staticRectID = 0; // Used in Overlay
226 uint hasHotspot = kPlayOverlayNoHotspot;
227 Common::Rect src;
228 Common::Rect dest;
229
230 void readData(Common::SeekableReadStream &stream, bool longFormat = false);
231};
232
233// Describes event flag changes to be executed when an action is triggered.
234// There are always 10, except in Nancy15+ event flag records, which list any number.
236 MultiEventFlagDescription() : descs(10) {}
237
239
240 void readData(Common::SeekableReadStream &stream);
241 void execute();
242};
243
244// A Nancy 10+ cellphone list entry: an email message (mode 0) or a web-search
245// link (mode 1). Added at runtime by AR 131 (AddSearchLink); the first entry of
246// each list may instead be embedded in the UICL chunk. Which fields are used
247// depends on the mode (see CellPhonePopup). The byte layout differs per source,
248// so each site fills the fields itself rather than sharing a readData.
250 Common::String key; // CVTX key whose looked-up text is the list row
251 Common::String value; // body CVTX key (email); unused for search
252 int16 extra = 0; // page index (search); unused for email
253 int16 flag = 0; // stored by the original but unused; reserved
254 int16 eventFlag = -1; // event-flag index set when the entry is opened
255 bool read = false; // email only: set once the message is opened
256};
257
259 int16 frameID = kFrNoFrame;
260 Common::Rect srcRect;
261 Common::Rect destRect;
262 // 2 unknown/empty rects
263
264 void readData(Common::SeekableReadStream &stream, bool hasTrailingRects = false);
265};
266
267// Describes set of effects that can be applied to sounds.
268// Defaults are set according to the values used by PlaySoundTerse
270 uint32 minTimeDelay = 500;
271 uint32 maxTimeDelay = 2000;
272
273 int32 randomMoveMinX = 0;
274 int32 randomMoveMaxX = 0;
275 int32 randomMoveMinY = 0;
276 int32 randomMoveMaxY = 0;
277 int32 randomMoveMinZ = 0;
278 int32 randomMoveMaxZ = 0;
279
280 int32 fixedPosX = 0;
281 int32 fixedPosY = 0;
282 int32 fixedPosZ = 0;
283
284 uint32 moveStepTime = 1000;
285 int32 numMoveSteps = 10;
286
287 int32 linearMoveStartX = 0;
288 int32 linearMoveEndX = 0;
289 int32 linearMoveStartY = 0;
290 int32 linearMoveEndY = 0;
291 int32 linearMoveStartZ = 0;
292 int32 linearMoveEndZ = 0;
293
294 int32 rotateMoveStartX = 0;
295 int32 rotateMoveStartY = 0;
296 int32 rotateMoveStartZ = 0;
297 byte rotateMoveAxis = kRotateAroundY;
298
299 uint32 minDistance = 0;
300 uint32 maxDistance = 0;
301
302 void readData(Common::SeekableReadStream &stream);
303};
304
305// Descrbes a single sound. Combines four different structs found in the data in one
307 Common::String name = "NO SOUND";
308 uint16 channelID = 0;
309 uint16 playCommands = 1;
310 uint16 numLoops = 1;
311 uint16 volume = 50;
312 uint16 panAnchorFrame = 0;
313 uint32 samplesPerSec = 0;
314 bool isPanning = false;
315
316 void readNormal(Common::SeekableReadStream &stream);
317 void readDIGI(Common::SeekableReadStream &stream);
318 void readMenu(Common::SeekableReadStream &stream);
319 void readScene(Common::SeekableReadStream &stream);
320 void readTerse(Common::SeekableReadStream &stream);
321};
322
323// The "random sound" block shared by some Nancy 12 puzzles
326 int16 channel = 0;
327 int32 numLoops = 0;
328 int16 volume = 0;
329
330 void readData(Common::SeekableReadStream &stream);
331
332 // Plays one of the sounds, picked at random, and shows its caption, looked up by the
333 // sound's name, first in AUTOTEXT, then in CONVO. Returns the sound's description,
334 // which is left as "NO SOUND" when there is nothing to play.
335 SoundDescription play() const;
336};
337
338// Structs inside nancy.dat, which contains all the data that was
339// originally stored inside the executable
340
341enum class StaticDataConditionType { kEvent = 0, kInventory = 1, kDifficulty = 2 };
342struct StaticDataFlag { byte type; int16 label; byte flag; };
343
345 byte textID;
346 uint16 sceneID;
347 Common::String soundID;
349
350 void readData(Common::SeekableReadStream &stream);
351};
352
354 Common::Array<uint16> sceneIDs;
356 StaticDataFlag flagToSet;
357
358 void readData(Common::SeekableReadStream &stream);
359};
360
361struct Goodbye {
362 Common::String soundID;
364
365 void readData(Common::SeekableReadStream &stream);
366};
367
368struct Hint {
369 byte textID;
370 int16 hintWeight;
371 SceneChangeDescription sceneChange;
372 Common::String soundIDs[3];
374
375 void readData(Common::SeekableReadStream &stream);
376};
377
379 byte numChannels;
380 byte numSceneSpecificChannels;
381 Common::Array<byte> speechChannels;
382 Common::Array<byte> musicChannels;
383 Common::Array<byte> sfxChannels;
384
385 void readData(Common::SeekableReadStream &stream);
386};
387
389 // Default values are for nancy1, provided for debugging purposes
390 uint16 numItems = 11;
391 uint16 numEventFlags = 168;
392 Common::Array<uint16> mapAccessSceneIDs;
393 Common::Array<uint16> genericEventFlags;
394 uint16 numCursorTypes = 4;
395 uint32 logoEndAfter = 7000;
396 int16 wonGameFlagID = -1;
397
398 // Data for sound channels
399 SoundChannelInfo soundChannelInfo;
400
401 // In-game strings and related logic
403 Common::Array<Goodbye> goodbyes;
405
406 Common::Array<Common::String> conditionalDialogueTexts;
409 Common::String ringingText;
410 Common::String emptySaveText;
411
412 // Debug strings
413 Common::Array<Common::String> eventFlagNames;
414
415 void readData(Common::SeekableReadStream &stream, Common::Language language, uint32 endPos, int8 majorVersion, int8 minorVersion);
416};
417
418// Source-rect order shared by the close button and slider widgets in the
419// Nancy 10+ popup header. The tab/filter strips use a different order, with
420// the active entry at index 0.
421enum UIButtonState {
422 kUIButtonIdle = 0,
423 kUIButtonHover = 1,
424 kUIButtonPressed = 2, // dragging, for sliders
425 kUIButtonDisabled = 3
426};
427
428// Reusable button widget embedded in Nancy 10+ popup UIs.
430 static const uint kRecordSize = 239;
431 Common::Path primaryImageName;
432 Common::Path secondaryImageName;
433 uint32 id = 0;
434 Common::Rect sourceRects[4];
435 Common::Rect srcBackgroundRestore;
436 Common::Rect destRect;
437 uint32 destUsesGameFrameOffset = 0; // translate dest by game-frame origin when non-zero
438 uint32 hoverEnableFlag = 0;
439 uint32 hoverCursorFlag = 0; // swap cursor sprite on hover when set
440 uint32 secondaryStateField = 0;
441 uint32 initialState = 0; // 0=idle, 1=hover, 2=pressed, 3/4=disabled
442 uint32 pressedDuration = 0; // milliseconds the pressed sprite stays up after a click
443 SoundDescription clickSound;
444};
445
446// A UIButton slot. Used for the notebook tab strip (UINB) and the
447// inventory category-filter strip (UIIV).
449 static const uint kRecordSize = 247;
450 uint32 enabled = 0;
451 uint32 id = 0; // slot identifier (filter category / tab)
452 UIButtonRecord button;
453};
454
455// Reusable slider widget embedded in Nancy 10+ popup UIs.
457 static const uint kRecordSize = 198;
458 Common::Path primaryImageName;
459 Common::Path secondaryImageName;
460 uint32 id = 0;
461 Common::Rect sourceRects[4];
462 Common::Rect srcBackgroundRestore;
463 Common::Rect destRect;
464 uint32 destUsesGameFrameOffset = 0; // translate dest by game-frame origin when non-zero
465 uint32 unknownA = 0;
466 uint32 isDraggable = 0; // when zero, the slider stays at its current value on click
467 uint32 unknownC = 0;
468 uint32 orientation = 0; // 0 = horizontal, 1 = vertical
469 uint32 positionHint = 0; // 0/1 left/right for horiz, 2/3 top/bottom for vert
470 uint32 secondaryStateField = 0;
471 uint32 initialState = 0; // 0=idle, 1=hover, 2=dragging
472};
473
474// Common header shared by all Nancy 10 popup-UI chunks
475// (UIIV, UICO, UICL, UINB).
477 Common::Path imageName; // background image
478 uint32 unknownHeaderField = 0; // chunk version
479 int16 linkbackScene = 9999; // return scene; 9999 = none
480 Common::Rect normalSrcRect; // SRC rect on the popup overlay image when in state 2 (normal size)
481 Common::Rect maximizedSrcRect; // SRC rect on the popup overlay image when in state 3 (maximized size)
482 Common::Rect normalDestRect; // DEST rect on screen for state 2 (normal size)
483 Common::Rect maximizedDestRect; // DEST rect on screen for state 3 (maximized size)
484 uint32 overlayInGameFrame = 0; // if non-zero, both dest rects are translated during initialization
485 SoundDescription sounds[4]; // open/close/button-click sound slots
486
487 uint32 secondaryButtonEnabled = 0;
488 UIButtonRecord secondaryButton;
489 uint32 sliderEnabled = 0;
490 UISliderRecord slider;
491};
492
493} // End of namespace Nancy
494
495#endif // NANCY_COMMONYPES_H
Definition: array.h:52
Definition: path.h:52
Definition: stream.h:745
Definition: str.h:59
Language
Definition: language.h:45
Definition: algorithm.h:29
Definition: actionmanager.h:32
Definition: rect.h:536
Definition: commontypes.h:344
Definition: commontypes.h:201
Definition: commontypes.h:223
Definition: commontypes.h:361
Definition: commontypes.h:353
Definition: commontypes.h:368
Definition: commontypes.h:215
Definition: commontypes.h:235
Definition: commontypes.h:324
Definition: commontypes.h:186
Definition: commontypes.h:206
Definition: commontypes.h:258
Definition: commontypes.h:378
Definition: commontypes.h:306
Definition: commontypes.h:269
Definition: commontypes.h:342
Definition: commontypes.h:388
Definition: commontypes.h:429
Definition: commontypes.h:448
Definition: commontypes.h:476
Definition: commontypes.h:456