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