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/str.h"
28 #include "math/vector3d.h"
29 
30 namespace Common {
31 class SeekableReadStream;
32 }
33 
34 namespace Nancy {
35 
36 class NancyEngine;
37 
38 // The original engine used a large amount of #defines for numerical constants,
39 // which can be found listed inside the gameflow.h file shipping with many of
40 // the titles (the Russian variant of nancy1 has it as a separate file, while
41 // nancy2 and above embed it within the ciftree).
42 //
43 // Other, more specific constants are declared within their related classes,
44 // so as not to litter the namespace
45 
46 static const int8 kFlagNoLabel = -1;
47 static const int8 kEvNoEvent = -1;
48 static const int8 kFrNoFrame = -1;
49 static const uint16 kNoScene = 9999;
50 
51 // Inventory items use types
52 static const byte kInvItemUseThenLose = 0;
53 static const byte kInvItemKeepAlways = 1;
54 static const byte kInvItemReturn = 2;
55 static const byte kInvItemNewSceneView = 3;
56 
57 // Inventory item sound override commands
58 static const byte kInvSoundOverrideCommandNoSound = 0;
59 static const byte kInvSoundOverrideCommandTurnOff = 1;
60 static const byte kInvSoundOverrideCommandNewSound = 2;
61 static const byte kInvSoundOverrideCommandICant = 3;
62 
63 // Dependency types
64 static const byte kFlagEvent = 1;
65 static const byte kFlagInventory = 2;
66 static const byte kFlagCursor = 3;
67 
68 // Scene panning
69 static const byte kPanNone = 0;
70 static const byte kPan360 = 1;
71 static const byte kPanLeftRight = 2;
72 
73 // Scene sound flags
74 static const byte kContinueSceneSound = 1;
75 static const byte kLoadSceneSound = 0;
76 
77 // Scene rotation special values
78 static const uint16 kInvertedNode = 77;
79 static const uint16 kNoAutoScroll = 333;
80 
81 // Clock bump types
82 static const byte kAbsoluteClockBump = 1;
83 static const byte kRelativeClockBump = 2;
84 
85 // Time of day
86 static const byte kPlayerDay = 0;
87 static const byte kPlayerNight = 1;
88 static const byte kPlayerDuskDawn = 2;
89 
90 // Video
91 static const byte kSmallVideoFormat = 1;
92 static const byte kLargeVideoFormat = 2;
93 
94 static const byte kVideoPlaytypeAVF = 0;
95 static const byte kVideoPlaytypeBink = 1;
96 
97 // Overlay
98 static const byte kPlayOverlayPlain = 1;
99 static const byte kPlayOverlayTransparent = 2;
100 
101 static const byte kPlayOverlaySceneChange = 1;
102 static const byte kPlayOverlayNoSceneChange = 2;
103 
104 static const byte kPlayOverlayStatic = 1;
105 static const byte kPlayOverlayAnimated = 2;
106 
107 static const byte kPlayOverlayOnce = 1;
108 static const byte kPlayOverlayLoop = 2;
109 
110 static const byte kPlayOverlayForward = 1;
111 static const byte kPlayOverlayReverse = 2;
112 
113 static const byte kPlayOverlayWithHotspot = 1;
114 static const byte kPlayOverlayNoHotspot = 2;
115 
116 // Table access
117 static const byte kNoChangeTableValue = 0;
118 static const byte kIncrementTableValue = 1;
119 static const byte kDecrementTableValue = 2;
120 static const uint16 kNoTableIndex = 99;
121 static const int16 kNoTableValue = 9999;
122 
123 // Autotext ordering info
124 static const uint16 kListLIFO = 0;
125 static const uint16 kListFIFO = 1;
126 
127 // 3D sound rotation
128 static const byte kRotateAroundX = 0;
129 static const byte kRotateAroundY = 1;
130 static const byte kRotateAroundZ = 2;
131 
132 enum MovementDirection : byte { kUp = 1, kDown = 2, kLeft = 4, kRight = 8, kMoveFast = 16 };
133 
134 // Separate namespace to remove possible clashes
135 namespace NancyState {
136 enum NancyState {
137  // Original engine states
138  kBoot, kLogo, kCredits, kMap,
139  kMainMenu, kLoadSave, kSetup,
140  kHelp, kScene, kSaveDialog,
141 
142  // Not real states
143  kNone,
144  kQuit,
145  kPause, // only used when the GMM is on screen
146 };
147 }
148 
149 // Describes a scene transition
151  uint16 sceneID = kNoScene;
152  uint16 frameID = 0;
153  uint16 verticalOffset = 0;
154  uint16 continueSceneSound = kLoadSceneSound;
155 
156  int8 paletteID = -1; // TVD only
157 
158  Math::Vector3d listenerFrontVector = Math::Vector3d(0, 0, 1);
159  uint16 frontVectorFrameID = 0;
160 
161  void readData(Common::SeekableReadStream &stream, bool longFormat = false);
162 };
163 
164 // Describes a single flag change or comparison
166  int16 label = -1;
167  byte flag = 0;
168 };
169 
171  SceneChangeDescription _sceneChange;
172  FlagDescription _flag;
173 
174  void readData(Common::SeekableReadStream &stream, bool reverseFormat = false);
175  void execute();
176 };
177 
178 // Describes a hotspot
180  uint16 frameID = 0;
181  Common::Rect coords;
182 
183  void readData(Common::SeekableReadStream &stream);
184 };
185 
186 // Describes a blit operation, dependent on a background frame
188  uint16 frameID = 0; // Frame ID of the Scene background
189  uint16 staticRectID = 0; // Used in Overlay
190  uint hasHotspot = kPlayOverlayNoHotspot;
191  Common::Rect src;
192  Common::Rect dest;
193 
194  void readData(Common::SeekableReadStream &stream, bool longFormat = false);
195 };
196 
197 // Describes 10 event flag changes to be executed when an action is triggered
199  FlagDescription descs[10];
200 
201  void readData(Common::SeekableReadStream &stream);
202  void execute();
203 };
204 
206  int16 frameID = kFrNoFrame;
207  Common::Rect srcRect;
208  Common::Rect destRect;
209  // 2 unknown/empty rects
210 
211  void readData(Common::SeekableReadStream &stream);
212 };
213 
214 // Describes set of effects that can be applied to sounds.
215 // Defaults are set according to the values used by PlaySoundTerse
217  uint32 minTimeDelay = 500;
218  uint32 maxTimeDelay = 2000;
219 
220  int32 randomMoveMinX = 0;
221  int32 randomMoveMaxX = 0;
222  int32 randomMoveMinY = 0;
223  int32 randomMoveMaxY = 0;
224  int32 randomMoveMinZ = 0;
225  int32 randomMoveMaxZ = 0;
226 
227  int32 fixedPosX = 0;
228  int32 fixedPosY = 0;
229  int32 fixedPosZ = 0;
230 
231  uint32 moveStepTime = 1000;
232  int32 numMoveSteps = 10;
233 
234  int32 linearMoveStartX = 0;
235  int32 linearMoveEndX = 0;
236  int32 linearMoveStartY = 0;
237  int32 linearMoveEndY = 0;
238  int32 linearMoveStartZ = 0;
239  int32 linearMoveEndZ = 0;
240 
241  int32 rotateMoveStartX = 0;
242  int32 rotateMoveStartY = 0;
243  int32 rotateMoveStartZ = 0;
244  byte rotateMoveAxis = kRotateAroundY;
245 
246  uint32 minDistance = 0;
247  uint32 maxDistance = 0;
248 
249  void readData(Common::SeekableReadStream &stream);
250 };
251 
252 // Descrbes a single sound. Combines four different structs found in the data in one
254  Common::String name = "NO SOUND";
255  uint16 channelID = 0;
256  uint16 playCommands = 1;
257  uint16 numLoops = 1;
258  uint16 volume = 50;
259  uint16 panAnchorFrame = 0;
260  uint32 samplesPerSec = 0;
261  bool isPanning = false;
262 
263  void readNormal(Common::SeekableReadStream &stream);
264  void readDIGI(Common::SeekableReadStream &stream);
265  void readMenu(Common::SeekableReadStream &stream);
266  void readScene(Common::SeekableReadStream &stream);
267  void readTerse(Common::SeekableReadStream &stream);
268 };
269 
270 // Structs inside nancy.dat, which contains all the data that was
271 // originally stored inside the executable
272 
273 enum class StaticDataConditionType { kEvent = 0, kInventory = 1, kDifficulty = 2 };
274 struct StaticDataFlag { byte type; int16 label; byte flag; };
275 
277  byte textID;
278  uint16 sceneID;
279  Common::String soundID;
281 
282  void readData(Common::SeekableReadStream &stream);
283 };
284 
286  Common::Array<uint16> sceneIDs;
288  StaticDataFlag flagToSet;
289 
290  void readData(Common::SeekableReadStream &stream);
291 };
292 
293 struct Goodbye {
294  Common::String soundID;
296 
297  void readData(Common::SeekableReadStream &stream);
298 };
299 
300 struct Hint {
301  byte textID;
302  int16 hintWeight;
303  SceneChangeDescription sceneChange;
304  Common::String soundIDs[3];
306 
307  void readData(Common::SeekableReadStream &stream);
308 };
309 
311  byte numChannels;
312  byte numSceneSpecificChannels;
313  Common::Array<byte> speechChannels;
314  Common::Array<byte> musicChannels;
315  Common::Array<byte> sfxChannels;
316 
317  void readData(Common::SeekableReadStream &stream);
318 };
319 
320 struct StaticData {
321  // Default values are for nancy1, provided for debugging purposes
322  uint16 numItems = 11;
323  uint16 numEventFlags = 168;
324  Common::Array<uint16> mapAccessSceneIDs;
325  Common::Array<uint16> genericEventFlags;
326  uint16 numCursorTypes = 4;
327  uint32 logoEndAfter = 7000;
328  int16 wonGameFlagID = -1;
329 
330  // Data for sound channels
331  SoundChannelInfo soundChannelInfo;
332 
333  // In-game strings and related logic
335  Common::Array<Goodbye> goodbyes;
337 
338  Common::Array<Common::String> conditionalDialogueTexts;
339  Common::Array<Common::String> goodbyeTexts;
341  Common::String ringingText;
342  Common::String emptySaveText;
343 
344  // Debug strings
345  Common::Array<Common::String> eventFlagNames;
346 
347  void readData(Common::SeekableReadStream &stream, Common::Language language, uint32 endPos, int8 majorVersion, int8 minorVersion);
348 };
349 
350 } // End of namespace Nancy
351 
352 #endif // NANCY_COMMONYPES_H
Definition: commontypes.h:198
Definition: commontypes.h:320
Definition: str.h:59
Definition: commontypes.h:150
Definition: array.h:52
Definition: commontypes.h:274
Definition: commontypes.h:300
Definition: commontypes.h:276
Definition: rect.h:144
Definition: stream.h:745
Definition: commontypes.h:216
Definition: commontypes.h:187
Definition: commontypes.h:293
Definition: commontypes.h:170
Definition: commontypes.h:310
Definition: algorithm.h:29
Definition: commontypes.h:253
Definition: commontypes.h:165
Definition: commontypes.h:205
Definition: commontypes.h:179
Definition: commontypes.h:285
Definition: actionmanager.h:32
Language
Definition: language.h:45