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