ScummVM API documentation
private.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 PRIVATE_H
23 #define PRIVATE_H
24 
25 #include "common/compression/installshieldv3_archive.h"
26 #include "common/random.h"
27 #include "common/serializer.h"
28 #include "engines/engine.h"
29 #include "graphics/managed_surface.h"
30 #include "graphics/wincursor.h"
31 #include "video/smk_decoder.h"
32 #include "video/subtitles.h"
33 
34 #include "private/grammar.h"
35 
36 namespace Image {
37 class ImageDecoder;
38 }
39 
40 namespace Graphics {
41 class ManagedSurface;
42 }
43 
44 struct ADGameDescription;
45 
46 namespace Private {
47 
48 enum PRIVATEActions {
49  kActionSkip,
50 };
51 
52 // debug channels
53 enum {
54  kPrivateDebugFunction = 1,
55  kPrivateDebugCode,
56  kPrivateDebugScript,
57 };
58 
59 // sounds
60 
61 const int kPaperShuffleSound[7] = {32, 33, 34, 35, 36, 37, 39};
62 
63 // police
64 
65 const int kPoliceBustVideos[6] = {1, 2, 4, 5, 7, 8};
66 
67 // points
68 
69 const int kOriginZero[2] = {0, 0};
70 const int kOriginOne[2] = {64, 48};
71 
72 // vm
73 
74 extern Gen::VM *Gen::g_vm;
75 
76 // structs
77 
78 typedef struct ExitInfo {
79  Common::String nextSetting;
80  Common::Rect rect;
81  Common::String cursor;
82 } ExitInfo;
83 
84 typedef struct MaskInfo {
85  Graphics::Surface *surf;
86  Common::String nextSetting;
87  Common::Point point;
88  Symbol *flag1;
89  Symbol *flag2;
90  Common::String cursor;
91 
92  void clear() {
93  surf = nullptr;
94  flag1 = nullptr;
95  flag2 = nullptr;
96  nextSetting.clear();
97  cursor.clear();
98  point = Common::Point();
99  }
100 } MaskInfo;
101 
102 typedef struct PhoneInfo {
103  Common::String sound;
104  Symbol *flag;
105  int val;
106 } PhoneInfo;
107 
108 typedef struct DossierInfo {
109  Common::String page1;
110  Common::String page2;
111 } DossierInfo;
112 
113 typedef struct CursorInfo {
114  Common::String name;
115  Common::String aname;
116  Graphics::Cursor *cursor;
117  Graphics::WinCursorGroup *winCursorGroup;
118 } CursorInfo;
119 
120 typedef struct MemoryInfo {
121  Common::String image;
122  Common::String movie;
123 } MemoryInfo;
124 
125 typedef struct DiaryPage {
126  Common::String locationName;
127  Common::Array<MemoryInfo> memories;
128  uint locationID;
129 } DiaryPage;
130 
131 // funcs
132 
133 typedef struct FuncTable {
134  void (*func)(Private::ArgArray);
135  const char *name;
136 } FunctTable;
137 
139 extern const FuncTable funcTable[];
140 
141 // lists
142 
148 
149 // arrays
150 
153 
154 // hash tables
155 
157 
158 
159 class PrivateEngine : public Engine {
160 private:
161  Common::RandomSource *_rnd;
162  Graphics::PixelFormat _pixelFormat;
163  Image::ImageDecoder *_image;
164  int _screenW, _screenH;
165 
166 public:
167  PrivateEngine(OSystem *syst, const ADGameDescription *gd);
168  ~PrivateEngine();
169 
170  const ADGameDescription *_gameDescription;
171  bool isDemo() const;
172  Common::Language _language;
173  Common::Platform _platform;
174 
175  SymbolMaps maps;
176 
177  Audio::SoundHandle _fgSoundHandle;
178  Audio::SoundHandle _bgSoundHandle;
179  Video::SmackerDecoder *_videoDecoder;
180  Video::SmackerDecoder *_pausedVideo;
181  Common::InstallShieldV3 _installerArchive;
182 
183  Common::Error run() override;
184  void restartGame();
185  void clearAreas();
186  void initializePath(const Common::FSNode &gamePath) override;
187  Common::SeekableReadStream *loadAssets();
188 
189  // Functions
190 
191  NameToPtr _functions;
192  void initFuncs();
193 
194  // User input
195  void selectPauseGame(Common::Point);
196  void selectMask(Common::Point);
197  void selectExit(Common::Point);
198  void selectLoadGame(Common::Point);
199  void selectSaveGame(Common::Point);
200  void resumeGame();
201 
202  // Cursors
203  bool cursorPauseMovie(Common::Point);
204  bool cursorExit(Common::Point);
205  bool cursorMask(Common::Point);
206 
207  bool hasFeature(EngineFeature f) const override;
208  bool canLoadGameStateCurrently(Common::U32String *msg = nullptr) override {
209  return true;
210  }
211  bool canSaveAutosaveCurrently() override {
212  return false;
213  }
214  bool canSaveGameStateCurrently(Common::U32String *msg = nullptr) override {
215  return true;
216  }
217 
218  void ignoreEvents();
219  Common::Error loadGameStream(Common::SeekableReadStream *stream) override;
220  Common::Error saveGameStream(Common::WriteStream *stream, bool isAutosave = false) override;
221 
222  Common::Path convertPath(const Common::String &);
223  void playVideo(const Common::String &);
224  void skipVideo();
225 
226  void loadSubtitles(const Common::Path &path);
227  void adjustSubtitleSize();
228  Video::Subtitles *_subtitles;
229  bool _sfxSubtitles;
230 
231  Graphics::Surface *decodeImage(const Common::String &file, byte **palette);
232  //byte *decodePalette(const Common::String &name);
233  void remapImage(uint16 ncolors, const Graphics::Surface *oldImage, const byte *oldPalette, Graphics::Surface *newImage, const byte *currentPalette);
234  void loadImage(const Common::String &file, int x, int y);
235  void drawScreenFrame(const byte *videoPalette);
236 
237  // Cursors
238  Common::Array<CursorInfo> _cursors;
239  Common::String _currentCursor;
240  void changeCursor(const Common::String &);
241  Common::String getInventoryCursor();
242  Common::String getExitCursor();
243  void loadCursors();
244 
245  // Rendering
246  Graphics::ManagedSurface *_compositeSurface;
247  Graphics::Surface *loadMask(const Common::String &, int, int, bool);
248  void drawMask(Graphics::Surface *);
249  void fillRect(uint32, Common::Rect);
250  bool inMask(Graphics::Surface *, Common::Point);
251  uint32 _transparentColor;
252  Common::Rect _screenRect;
253  Common::String _framePath;
254  Graphics::Surface *_frameImage;
255  Graphics::Surface *_mframeImage;
256  byte *_framePalette;
257  Common::String _nextVS;
258  Common::String _currentVS;
259  Common::Point _origin;
260  void drawScreen();
261  bool _needToDrawScreenFrame;
262 
263  // settings
264  Common::String _nextSetting;
265  Common::String _pausedSetting;
266  Common::String _currentSetting;
267  Common::String getPauseMovieSetting();
268  Common::String getGoIntroSetting();
269  Common::String getMainDesktopSetting();
270  Common::String getPOGoBustMovieSetting();
271  Common::String getPoliceBustFromMOSetting();
272  Common::String getAlternateGameVariable();
273  Common::String getPoliceIndexVariable();
274  Common::String getWallSafeValueVariable();
275 
276  // movies
277  Common::String _nextMovie;
278  Common::String _currentMovie;
279 
280  // Dossiers
281  DossierArray _dossiers;
282  uint _dossierSuspect;
283  uint _dossierPage;
284  MaskInfo _dossierNextSuspectMask;
285  MaskInfo _dossierPrevSuspectMask;
286  MaskInfo _dossierNextSheetMask;
287  MaskInfo _dossierPrevSheetMask;
288  bool selectDossierNextSuspect(Common::Point);
289  bool selectDossierPrevSuspect(Common::Point);
290  bool selectDossierNextSheet(Common::Point);
291  bool selectDossierPrevSheet(Common::Point);
292  void loadDossier();
293 
294  // Police Bust
295  bool _policeBustEnabled;
296  void startPoliceBust();
297  void checkPoliceBust();
298  int _numberClicks;
299  int _maxNumberClicks;
300  int _sirenWarning;
301  Common::String _policeBustSetting;
302 
303  // Diary
304  InvList inventory;
305  Common::String _diaryLocPrefix;
306  void loadLocations(const Common::Rect &);
307  void loadInventory(uint32, const Common::Rect &, const Common::Rect &);
308  bool _toTake;
309  DiaryPages _diaryPages;
310  int _currentDiaryPage;
311  ExitInfo _diaryNextPageExit;
312  ExitInfo _diaryPrevPageExit;
313  bool selectDiaryNextPage(Common::Point mousePos);
314  bool selectDiaryPrevPage(Common::Point mousePos);
315  void addMemory(const Common::String &path);
316  void loadMemories(const Common::Rect &rect, uint rightPageOffset, uint verticalOffset);
317  bool selectLocation(const Common::Point &mousePos);
318  Common::Array<MaskInfo> _locationMasks;
319  Common::Array<MaskInfo> _memoryMasks;
320  bool selectMemory(const Common::Point &mousePos);
321 
322  // Save/Load games
323  MaskInfo _saveGameMask;
324  MaskInfo _loadGameMask;
325 
326  int _mode;
327  bool _modified;
328 
329  PlayedMediaTable _playedMovies;
330  PlayedMediaTable _playedPhoneClips;
331  Common::String _repeatedMovieExit;
332 
333  // Masks/Exits
334  ExitList _exits;
335  MaskList _masks;
336 
337  // Sounds
338  void playSound(const Common::String &, uint, bool, bool);
339  void stopSound(bool);
340  bool isSoundActive();
341  bool _noStopSounds;
342 
343  Common::String getPaperShuffleSound();
344  Common::String _globalAudioPath;
345 
346  Common::String getTakeSound();
347  Common::String getTakeLeaveSound();
348  Common::String getLeaveSound();
349  Common::String _sirenSound;
350 
351  // Radios
352  Common::String _infaceRadioPath;
353  MaskInfo _AMRadioArea;
354  MaskInfo _policeRadioArea;
355  MaskInfo _phoneArea;
356  Common::String _phonePrefix;
357  Common::String _phoneCallSound;
358  SoundList _AMRadio;
359  SoundList _policeRadio;
360  PhoneList _phone;
361 
362  Common::String getRandomPhoneClip(const char *, int, int);
363  void selectAMRadioArea(Common::Point);
364  void selectPoliceRadioArea(Common::Point);
365  void selectPhoneArea(Common::Point);
366  void checkPhoneCall();
367 
368  // Safe
369  uint32 _safeColor;
370  Common::String _safeNumberPath;
371  MaskInfo _safeDigitArea[3];
372  Common::Rect _safeDigitRect[3];
373  uint32 _safeDigit[3];
374 
375  bool selectSafeDigit(Common::Point);
376  void addSafeDigit(uint32, Common::Rect*);
377  void renderSafeDigit(uint32);
378 
379  // Random values
380  bool getRandomBool(uint);
381 
382  // Timers
383  bool installTimer(uint32, Common::String *);
384  void removeTimer();
385 };
386 
387 extern PrivateEngine *g_private;
388 
389 } // End of namespace Private
390 
391 #endif
Definition: managed_surface.h:51
Definition: image_decoder.h:53
Definition: wincursor.h:54
Definition: str.h:59
Definition: installshieldv3_archive.h:35
Definition: surface.h:67
EngineFeature
Definition: engine.h:260
Definition: stream.h:77
Definition: error.h:81
Definition: array.h:52
Definition: pixelformat.h:138
Definition: advancedDetector.h:164
Definition: random.h:44
Definition: symbol.h:56
Definition: rect.h:524
Definition: path.h:52
Definition: private.h:102
Definition: stream.h:745
Definition: smk_decoder.h:77
Definition: private.h:78
Definition: symbol.h:35
bool canSaveAutosaveCurrently() override
Definition: private.h:211
Definition: private.h:84
bool canLoadGameStateCurrently(Common::U32String *msg=nullptr) override
Definition: private.h:208
Definition: subtitles.h:77
Definition: mixer.h:49
Definition: ustr.h:57
Definition: private.h:159
Definition: cursor.h:42
Definition: fs.h:69
Definition: formatinfo.h:28
Definition: rect.h:144
Definition: decompiler.h:30
Definition: private.h:113
bool canSaveGameStateCurrently(Common::U32String *msg=nullptr) override
Definition: private.h:214
Definition: private.h:120
Definition: system.h:163
Definition: private.h:108
Definition: private.h:125
Definition: movie_decoder.h:32
Definition: private.h:133
Definition: engine.h:146
Platform
Definition: platform.h:46
Language
Definition: language.h:45