ScummVM API documentation
hypno.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 HYPNO_H
23 #define HYPNO_H
24 
25 #include "common/array.h"
26 #include "common/compression/installshieldv3_archive.h"
27 #include "common/random.h"
28 #include "common/serializer.h"
29 #include "common/str-array.h"
30 #include "common/stream.h"
31 #include "engines/engine.h"
32 #include "graphics/font.h"
33 #include "graphics/fontman.h"
34 #include "graphics/surface.h"
35 #include "video/subtitles.h"
36 
37 #include "hypno/grammar.h"
38 #include "hypno/libfile.h"
39 
40 namespace Audio {
41 class SeekableAudioStream;
42 }
43 
44 namespace Image {
45 class ImageDecoder;
46 }
47 
48 struct ADGameDescription;
49 
50 namespace Hypno {
51 
52 // debug channels
53 enum {
54  kHypnoDebugMedia = 1,
55  kHypnoDebugParser,
56  kHypnoDebugArcade,
57  kHypnoDebugScene,
58 };
59 
60 // Player positions
61 
62 enum PlayerPosition {
63  kPlayerTop = 'T',
64  kPlayerBottom = 'B',
65  kPlayerLeft = 'L',
66  kPlayerRight = 'R'
67 };
68 
69 // Common colors
70 enum HypnoColors {
71  kHypnoNoColor = -1,
72  kHypnoColorRed = 250,
73  kHypnoColorGreen = 251,
74  kHypnoColorWhiteOrBlue = 252,
75  kHypnoColorYellow = 253,
76  kHypnoColorBlack = 254,
77  kHypnoColorCyan = 255
78 };
79 
80 // Spider colors
81 enum SpiderColors {
82  kSpiderColorWhite = 248,
83  kSpiderColorBlue = 252,
84 };
85 
86 enum HYPNOActions {
87  kActionNone,
88  kActionSkipIntro,
89  kActionSkipCutscene,
90  kActionPrimaryShoot,
91  kActionSkipLevel,
92  kActionKillPlayer,
93  kActionPause,
94  kActionLeft,
95  kActionDown,
96  kActionRight,
97  kActionUp,
98  kActionYes,
99  kActionNo,
100  kActionDifficultyChump,
101  kActionDifficultyPunk,
102  kActionDifficultyBadass,
103  kActionDifficultExit,
104  kActionRetry,
105  kActionRestart,
106  kActionNewMission,
107  kActionQuit,
108  kActionCredits,
109  kActionSelect,
110  kActionSecondaryShoot,
111  kActionAimLeft,
112  kActionAimDown,
113  kActionAimRight,
114  kActionAimUp,
115 };
116 
117 class HypnoEngine;
118 
119 class CursorCache {
120 private:
121  HypnoEngine *_vm;
122  Common::String _filename;
123  uint32 _frame;
124  byte *_palette;
125  Graphics::Surface *_surface;
126 
127 public:
128  CursorCache(HypnoEngine *vm) : _vm(vm), _filename(""), _frame(0), _palette(nullptr), _surface(nullptr) {}
129 
130  ~CursorCache() {
131  if (_surface) {
132  _surface->free();
133  delete _surface;
134  }
135  free(_palette);
136  }
137 
138  Graphics::Surface *getCursor(const Common::String &cursor, uint32 n, byte **palette);
139 };
140 
141 class HypnoEngine : public Engine {
142 private:
143  Image::ImageDecoder *_image;
144 
145 public:
146  HypnoEngine(OSystem *syst, const ADGameDescription *gd);
147  ~HypnoEngine();
148 
149  const ADGameDescription *_gameDescription;
150  bool isDemo() const;
151  Common::Language _language;
152  Common::Platform _platform;
153  Common::String _variant;
154  bool _cheatsEnabled;
155  bool _infiniteHealthCheat;
156  bool _infiniteAmmoCheat;
157  bool _unlockAllLevels;
158  bool _restoredContentEnabled;
159 
160  Audio::SoundHandle _soundHandle, _musicHandle;
161  Common::InstallShieldV3 _installerArchive;
162  Common::List<LibFile*> _archive;
163 
164  Common::Error run() override;
165  Levels _levels;
167  virtual void resetSceneState();
168  bool checkSceneCompleted();
169  bool checkLevelWon();
170  void runLevel(Common::String &name);
171  void runScene(Scene *scene);
172  virtual void runBeforeArcade(ArcadeShooting *arc);
173  virtual void runAfterArcade(ArcadeShooting *arc);
174  void runArcade(ArcadeShooting *arc);
175  // For some menus and hardcoded puzzles
176  virtual void runCode(Code *code);
177  // Level transitions
178  void runTransition(Transition *trans);
179 
180  void restartGame();
181  void clearAreas();
182  void initializePath(const Common::FSNode &gamePath) override;
183  virtual void loadAssets();
184 
185  // Parsing
186  void splitArcadeFile(const Common::String &filename, Common::String &arc, Common::String &list);
187  void parseArcadeShooting(const Common::String &prefix, const Common::String &name, const Common::String &data);
188  SegmentShootsSequence parseShootList(const Common::String &name, const Common::String &data);
189  void loadArcadeLevel(const Common::String &current, const Common::String &nextWin, const Common::String &nextLose, const Common::String &prefix);
190  void loadSceneLevel(const Common::String &current, const Common::String &next, const Common::String &prefix);
191  void loadSceneLevel(const char *buf, const Common::String &name, const Common::String &next, const Common::String &prefix);
192 
193  LibFile *loadLib(const Common::Path &prefix, const Common::Path &filename, bool encrypted);
194 
195  // User input
196  void clickedHotspot(Common::Point);
197  virtual bool hoverHotspot(Common::Point);
198 
199  // Cursors
200  bool cursorPauseMovie(Common::Point);
201  bool cursorExit(Common::Point);
202  bool cursorMask(Common::Point);
203 
204  virtual void loadGame(const Common::String &nextLevel, int score, int puzzleDifficulty, int combatDifficulty);
205  bool canLoadGameStateCurrently(Common::U32String *msg = nullptr) override { return (isDemo() ? false : true); }
206  bool canSaveAutosaveCurrently() override { return false; }
207  bool canSaveGameStateCurrently(Common::U32String *msg = nullptr) override { return (isDemo() ? false : true); }
208  Common::String _checkpoint;
209 
210  bool _useSubtitles;
211  Video::Subtitles *_subtitles;
212  void adjustSubtitleSize();
213  void loadSubtitles(const Common::Path &path);
214 
215  Common::Path _prefixDir;
216  Common::Path convertPath(const Common::String &);
217  void playVideo(MVideo &video);
218  void skipVideo(MVideo &video);
219 
220  Graphics::Surface *decodeFrame(const Common::String &name, int frame, byte **palette = nullptr);
221  Frames decodeFrames(const Common::String &name);
222  void loadImage(const Common::String &file, int x, int y, bool transparent, bool palette = false, int frameNumber = 0);
223  void drawImage(Graphics::Surface &image, int x, int y, bool transparent);
224  void loadPalette(const Common::String &fname);
225  void loadPalette(const byte *palette, uint32 offset, uint32 size);
226  byte *getPalette(uint32 idx);
227 
228  // Cursors
229  Common::String _defaultCursor;
230  uint32 _defaultCursorIdx;
231  CursorCache *_cursorCache;
232  void disableCursor();
233  void defaultCursor();
234  virtual void changeCursor(const Common::String &cursor, uint32 n, bool centerCursor = false);
235  virtual void changeCursor(const Common::String &cursor);
236  virtual void changeCursor(const Graphics::Surface &entry, byte *palette, bool centerCursor = false);
237 
238  // Actions
239  virtual void runMenu(Hotspots *hs, bool only_menu = false);
240  void runBackground(Background *a);
241  void runOverlay(Overlay *a);
242  void runMice(Mice *a);
243  void runEscape();
244  void runSave(Save *a);
245  void runLoad(Load *a);
246  void runLoadCheckpoint(LoadCheckpoint *a);
247  void runTimer(Timer *a);
248  void runQuit(Quit *a);
249  void runCutscene(Cutscene *a);
250  void runIntro(Intro *a);
251  void runPlay(Play *a);
252  void runSound(Sound *a);
253  void runPalette(Palette *a);
254  void runAmbient(Ambient *a);
255  void runWalN(WalN *a);
256  bool runGlobal(Global *a);
257  void runTalk(Talk *a);
258  void runSwapPointer(SwapPointer *a);
259  void runChangeLevel(ChangeLevel *a);
260  virtual void drawBackToMenu(Hotspot *h);
261 
262  // Screen
263  int _screenW, _screenH;
264  Graphics::PixelFormat _pixelFormat;
265  void changeScreenMode(const Common::String &mode);
266  Graphics::Surface *_compositeSurface;
267  uint32 _transparentColor;
268  Common::Rect screenRect;
269  void updateScreen(MVideo &video);
270  void updateVideo(MVideo &video);
271  void drawScreen();
272 
273  // intros
274  void runIntro(MVideo &video);
275  void runIntros(Videos &videos);
276  void runIntrosWithSubtitles(Videos &videos);
278 
279  // levels
280  Common::String _nextLevel;
281  Common::String _currentLevel;
282  virtual Common::String findNextLevel(const Common::String &level);
283  virtual Common::String findNextLevel(const Transition *trans);
284  uint32 _levelId;
285 
286  // hotspots
287  Hotspots *_nextHotsToAdd;
288  Hotspots *_nextHotsToRemove;
289  HotspotsStack stack;
290 
291  // Movies
292  Videos _nextSequentialVideoToPlay;
293  Videos _nextParallelVideoToPlay;
294  Videos _escapeSequentialVideoToPlay;
295  Videos _videosPlaying;
296  Videos _videosLooping;
297  MVideo *_masks;
298  MVideo *_additionalVideo;
299  const Graphics::Surface *_mask;
300 
301  // Sounds
302  Filename _soundPath;
303  Audio::SeekableAudioStream *loadAudioStream(const Filename &filename, uint32 sampleRate = 22050, bool stereo = false);
304  void playSound(const Filename &filename, uint32 loops, uint32 sampleRate = 22050, bool stereo = false);
305  void playMusic(const Filename &filename, uint32 sampleRate = 22050, bool stereo = false);
306  void stopSound();
307  void stopMusic();
308  bool isMusicActive();
309 
310  // Arcade
311  Common::String _arcadeMode;
312  MVideo *_background;
313  Filename _currentPalette;
314  virtual bool availableObjectives();
315  virtual bool checkArcadeObjectives();
316  ArcadeTransitions _transitions;
317  virtual bool checkTransition(ArcadeTransitions &transitions, ArcadeShooting *arc);
318  virtual Common::Point getPlayerPosition(bool needsUpdate);
319  virtual Common::Point computeTargetPosition(const Common::Point &mousePos);
320  virtual int detectTarget(const Common::Point &mousePos);
321  virtual void pressedKey(const int keycode);
322  virtual bool clickedPrimaryShoot(const Common::Point &mousePos);
323  virtual bool clickedSecondaryShoot(const Common::Point &mousePos);
324  void resetGamepadAim(const Common::Rect &mouseBox);
325  void setGamepadAimActive(bool active);
326  bool isGamepadAimActive() const;
327  bool handleGamepadAimAction(const int action, bool pressed);
328  bool handleGamepadAxisAction(const int action, int16 position);
329  bool updateGamepadAim(const Common::Rect &mouseBox);
330  virtual void drawShoot(const Common::Point &mousePos);
331  virtual bool shoot(const Common::Point &mousePos, ArcadeShooting *arc, bool secondary);
332  virtual void hitPlayer();
333  virtual void missedTarget(Shoot *s, ArcadeShooting *arc);
334  virtual void missNoTarget(ArcadeShooting *arc);
335  virtual byte *getTargetColor(Common::String name, int levelId);
336  virtual bool checkRButtonUp();
337  virtual void setRButtonUp(const bool val);
338  virtual void disableGameKeymaps();
339  virtual void enableGameKeymaps();
340 
341  // Segments
342  Segments _segments;
343  uint32 _segmentIdx;
344  uint32 _segmentOffset;
345  uint32 _segmentRepetition;
346  uint32 _segmentRepetitionMax;
347  uint32 _segmentShootSequenceOffset;
348  uint32 _segmentShootSequenceMax;
349  ShootSequence _shootSequence;
350  virtual void findNextSegment(ArcadeShooting *arc);
351  virtual void initSegment(ArcadeShooting *arc);
352 
353  ArcadeStats _stats;
354  void resetStatistics();
355  void incLivesUsed();
356  void incShotsFired();
357  void incEnemyHits();
358  void incEnemyTargets();
359  void incTargetsDestroyed();
360  void incTargetsMissed();
361  void incFriendliesEncountered();
362  void incInfoReceived();
363 
364  void incScore(int inc);
365  void incBonus(int inc);
366 
367  uint32 killRatio();
368  uint32 accuracyRatio();
369 
370  Common::String _difficulty;
371  bool _skipLevel;
372  bool _loseLevel;
373  bool _skipDefeatVideo;
374  bool _skipNextVideo;
375  Common::Point _gamepadAimPosition;
376  int16 _gamepadAxisX;
377  int16 _gamepadAxisY;
378  bool _gamepadAimActive;
379  bool _gamepadAimLeft;
380  bool _gamepadAimDown;
381  bool _gamepadAimRight;
382  bool _gamepadAimUp;
383 
384  virtual void drawCursorArcade(const Common::Point &mousePos);
385  virtual void drawPlayer();
386  virtual void drawHealth();
387  virtual void drawAmmo();
388  int _health;
389  int _maxHealth;
390 
391  int _ammo;
392  int _maxAmmo;
393 
394  int _score;
395  int _bonus;
396  int _lives;
397 
398  Common::String _healthString;
399  Common::String _scoreString;
400  Common::String _objString;
401  Common::String _targetString;
402  Common::String _directionString;
403  Common::String _enterNameString;
404 
405  Filename _shootSound;
406  Filename _hitSound;
407  Filename _additionalSound;
408  Shoots _shoots;
409  Frames _playerFrames;
410  int _playerFrameIdx;
411  Common::List<int> _playerFrameSeps;
412  int _playerFrameStart;
413  int _playerFrameSep;
414  int _playerFrameEnd;
415 
416  // Objectives
417  uint32 _objIdx;
418  uint32 _objKillsCount[2];
419  uint32 _objMissesCount[2];
420  uint32 _objKillsRequired[2];
421  uint32 _objMissesAllowed[2];
422 
423  // Fonts
424  Common::BitArray _font05;
425  Common::BitArray _font08;
426  virtual void loadFonts(const Common::String &prefix = "");
427  virtual void drawString(const Filename &name, const Common::String &str, int x, int y, int w, uint32 c);
428 
429  // Conversation
430  Actions _conversation;
431  bool _refreshConversation;
432  virtual void showConversation();
433  virtual void endConversation();
434  virtual void rightClickedConversation(const Common::Point &mousePos);
435  virtual void leftClickedConversation(const Common::Point &mousePos);
436  virtual bool hoverConversation(const Common::Point &mousePos);
437  // Credits
438  virtual void showCredits();
439 
440  // Timers
441  int32 _countdown;
442  bool _timerStarted;
443  bool _keepTimerDuringScenes;
444  bool startAlarm(uint32, Common::String *);
445  bool startCountdown(uint32);
446  void removeTimers();
447 
448  // Random
449  Common::RandomSource *_rnd;
450 };
451 
452 struct chapterEntry {
453  int id;
454  int energyPos[2];
455  int scorePos[2];
456  int objectivesPos[2];
457  int ammoPos[2];
458  int ammoOffset;
459  int targetColor;
460 };
461 
462 class WetEngine : public HypnoEngine {
463 public:
464  WetEngine(OSystem *syst, const ADGameDescription *gd);
465  ~WetEngine();
467  Common::Array<int> _ids;
468  int _lastLevel;
469  Common::String _name;
470 
471  void loadAssets() override;
472  void loadAssetsDemoDisc();
473  void loadAssetsEarlyDemo();
474  void loadAssetsGen4();
475  void loadAssetsPCW();
476  void loadAssetsPCG();
477  void loadAssetsFullGame();
478  void loadAssetsNI();
479 
480  void loadFonts(const Common::String &prefix = "") override;
481  void drawString(const Filename &name, const Common::String &str, int x, int y, int w, uint32 c) override;
482  void changeCursor(const Common::String &cursor) override;
483 
484  void showCredits() override;
485  bool clickedSecondaryShoot(const Common::Point &mousePos) override;
486  void drawShoot(const Common::Point &target) override;
487  void drawPlayer() override;
488  void drawHealth() override;
489  void drawAmmo() override;
490  void hitPlayer() override;
491  void drawCursorArcade(const Common::Point &mousePos) override;
492  Common::Point computeTargetPosition(const Common::Point &mousePos) override;
493  void missedTarget(Shoot *s, ArcadeShooting *arc) override;
494  void missNoTarget(ArcadeShooting *arc) override;
495 
496  void runCode(Code *code) override;
497  Common::String findNextLevel(const Common::String &level) override;
498  Common::String findNextLevel(const Transition *trans) override;
499 
500  // Saves
501  Common::Error saveGameStream(Common::WriteStream *stream, bool isAutosave = false) override;
502  Common::Error loadGameStream(Common::SeekableReadStream *stream) override;
503  bool loadProfile(const Common::String &name);
504  void saveProfile(const Common::String &name, int levelId);
505 
506  // Arcade
507  Common::Point getPlayerPosition(bool needsUpdate) override;
508  bool checkTransition(ArcadeTransitions &transitions, ArcadeShooting *arc) override;
509  void pressedKey(const int keycode) override;
510  void runBeforeArcade(ArcadeShooting *arc) override;
511  void runAfterArcade(ArcadeShooting *arc) override;
512  void findNextSegment(ArcadeShooting *arc) override;
513  void initSegment(ArcadeShooting *arc) override;
514  byte *getTargetColor(Common::String name, int levelId) override;
515  bool checkRButtonUp() override;
516  void setRButtonUp(const bool val) override;
517  void disableGameKeymaps() override;
518  void enableGameKeymaps() override;
519 
520 
521  bool hasFeature(EngineFeature f) const override {
522  return (f == kSupportsReturnToLauncher);
523  }
524 
525 private:
526  Common::String getLocalizedString(const Common::String &name);
527  uint16 getNextChar(const Common::String &str, uint32 &c);
528  void drawGlyph(const Common::BitArray &font, int x, int y, int bitoffset, int width, int height, int pitch, uint32 color, bool invert);
529  void drawKoreanChar(uint16 chr, int &curx, int y, uint32 color);
530  void drawStatLine(const Common::String &name, const Common::String &value, int y, uint32 color);
531  void runMainMenu(Code *code);
532  void runLevelMenu(Code *code);
533  void runCheckLives(Code *code);
534  void endCredits(Code *code);
535  void showDemoScore();
536  uint32 findPaletteIndexZones(uint32 id);
537 
538  Common::List<int> _scoreMilestones;
539  void restoreScoreMilestones(int score);
540  bool checkScoreMilestones(int score);
541 
542 
543  Frames _c33PlayerCursor;
544  Common::Point _c33PlayerPosition;
545  Common::List<PlayerPosition> _c33PlayerDirection;
546  bool _c33UseMouse;
547  void generateStaticEffect();
548 
549  Common::BitArray _fontg9a;
550  Common::Array<uint32> _c40SegmentPath;
551  Common::Array<uint32> _c40SegmentNext;
552  int _c40SegmentIdx;
553  int _c40lastTurn;
554  int _c50LeftTurns;
555  int _c50RigthTurns;
556 
557  bool _rButtonUp;
558 };
559 
560 class SpiderEngine : public HypnoEngine {
561 public:
562  SpiderEngine(OSystem *syst, const ADGameDescription *gd);
563  ~SpiderEngine();
564  void loadAssets() override;
565  void loadAssetsDemo();
566  void loadAssetsFullGame();
567  void showCredits() override;
568 
569  void drawCursorArcade(const Common::Point &mousePos) override;
570  void drawShoot(const Common::Point &target) override;
571  void drawPlayer() override;
572  void drawHealth() override;
573  void missedTarget(Shoot *s, ArcadeShooting *arc) override;
574  void hitPlayer() override;
575 
576  // Arcade
577  void pressedKey(const int keycode) override;
578  void runBeforeArcade(ArcadeShooting *arc) override;
579  void runAfterArcade(ArcadeShooting *arc) override;
580  void findNextSegment(ArcadeShooting *arc) override;
581  void initSegment(ArcadeShooting *arc) override;
582  byte *getTargetColor(Common::String name, int levelId) override;
583 
584  void drawBackToMenu(Hotspot *h) override;
585  void runCode(Code *code) override;
586  Common::String findNextLevel(const Common::String &level) override;
587  Common::String findNextLevel(const Transition *trans) override;
588 
589  void loadFonts(const Common::String &prefix = "") override;
590  void drawString(const Filename &name, const Common::String &str, int x, int y, int w, uint32 c) override;
591 
592  void showConversation() override;
593  void endConversation() override;
594  void rightClickedConversation(const Common::Point &mousePos) override;
595  void leftClickedConversation(const Common::Point &mousePos) override;
596  bool hoverConversation(const Common::Point &mousePos) override;
597 
598  void loadGame(const Common::String &nextLevel, int score, int puzzleDifficulty, int combatDifficulty) override;
599  Common::Error loadGameStream(Common::SeekableReadStream *stream) override;
600  Common::Error saveGameStream(Common::WriteStream *stream, bool isAutosave = false) override;
601  bool canSaveAutosaveCurrently() override {
602  return false; // No hypno engine should perform autosave using the default implementation
603  }
604 
605  bool hasFeature(EngineFeature f) const override {
606  return (f == kSupportsSavingDuringRuntime || f == kSupportsLoadingDuringRuntime || f == kSupportsReturnToLauncher);
607  }
608 
609 private:
610  void runMatrix(Code *code);
611  void addIngredient(Code *code);
612  void checkMixture(Code *code);
613  void runNote(Code *code);
614  void runFusePanel(Code *code);
615  void runRecept(Code *code);
616  void runOffice(Code *code);
617  void runFileCabinet(Code *code);
618  void runLock(Code *code);
619  void runFuseBox(Code *code);
620  void runGiveUp();
621  void showScore(const Common::String &prefix);
622 
623  uint32 _currentPlayerPosition;
624  uint32 _lastPlayerPosition;
625 
626  bool _fuseState[2][10] = {};
627  bool _isFuseRust = true;
628  bool _isFuseUnreadable = false;
629  bool ingredients[7] = {};
630 
631  Common::Rect _h1Area;
632  Common::Rect _h2Area;
633  Common::Rect _h3Area;
634 
635  const Graphics::Font *_font;
636 };
637 
638 // SOUND.LIB ships four music tracks that no level script references: the menus
639 // and the territory approach videos use them. m_choice/m_hilite are the menu
640 // click and highlight sounds (as in Wetlands).
641 static const char *const kMenuChoiceSound = "sound/m_choice.raw";
642 static const char *const kMenuHiliteSound = "sound/m_hilite.raw";
643 static const char *const kMenuMusic = "sound/46-g.raw";
644 static const char *const kTransitionMusic = "sound/45.raw";
645 static const char *const kCreditsMusic = "sound/42.raw";
646 
647 class BoyzEngine : public HypnoEngine {
648 public:
649  BoyzEngine(OSystem *syst, const ADGameDescription *gd);
650  ~BoyzEngine();
651  Common::String _name;
652  Common::Array<int> _ids;
653  int _lastLevel;
654  bool _flashbackMode;
655  void loadAssets() override;
656  void runCode(Code *code) override;
657  Common::String findNextLevel(const Common::String &level) override;
658  Common::String findNextLevel(const Transition *trans) override;
659 
660  // Scenes
661  void resetSceneState() override;
662  void runMenu(Hotspots *hs, bool only_menu = false) override;
663  bool hoverHotspot(Common::Point) override;
664 
665  // Arcade
666  void runBeforeArcade(ArcadeShooting *arc) override;
667  void runAfterArcade(ArcadeShooting *arc) override;
668  void pressedKey(const int keycode) override;
669  int detectTarget(const Common::Point &mousePos) override;
670  void drawCursorArcade(const Common::Point &mousePos) override;
671  bool shoot(const Common::Point &mousePos, ArcadeShooting *arc, bool secondary) override;
672  bool clickedSecondaryShoot(const Common::Point &mousePos) override;
673  void showCredits() override;
674  // Stats
675  void showArcadeStats(int territory, const ArcadeStats &data);
676  ArcadeStats _lastStats;
677  ArcadeStats _globalStats;
678 
679  void missedTarget(Shoot *s, ArcadeShooting *arc) override;
680  void drawHealth() override;
681  void drawAmmo() override;
682  void drawShoot(const Common::Point &target) override;
683  void hitPlayer() override;
684  void drawPlayer() override;
685  void findNextSegment(ArcadeShooting *arc) override;
686  void initSegment(ArcadeShooting *arc) override;
687  bool checkTransition(ArcadeTransitions &transitions, ArcadeShooting *arc) override;
688 
689  void drawString(const Filename &name, const Common::String &str, int x, int y, int w, uint32 c) override;
690 
691  // Saves
692  Common::Error saveGameStream(Common::WriteStream *stream, bool isAutosave = false) override;
693  Common::Error loadGameStream(Common::SeekableReadStream *stream) override;
694  Common::StringArray listProfiles();
695  bool loadProfile(const Common::String &name);
696  void saveProfile(const Common::String &name, int levelId);
697 
698  private:
699  Common::Rect _lastHighlighted;
700  void renderHighlights(Hotspots *hs);
701  void waitForUserClick(uint32 timeout);
702  int pickABox();
703  int _selectedCorrectBox;
704  char selectDirection();
705 
706  void runMainMenu(Code *code);
707  bool runExitMenu();
708  void runRetryMenu(Code *code);
709  void runCheckC3(Code *code);
710  void runCheckHo(Code *code);
711  void runCheckC5(Code *code);
712  void runAlarmC5(Code *code);
713  void runDifficultyMenu(Code *code);
714  void endCredits(Code *code);
715  int getTerritory(const Common::String &level);
716  Common::String lastLevelTerritory(const Common::String &level);
717  Common::String firstLevelTerritory(const Common::String &level);
718 
719  void loadSceneState(Common::SeekableReadStream *stream);
720  void saveSceneState(Common::WriteStream *stream);
721  void unlockAllLevels();
722 
723  int _previousHealth;
724  Graphics::Surface _healthBar[7];
725  Graphics::Surface _ammoBar[7];
726  Graphics::Surface _portrait[7];
727  Filename _deathDay[7];
728  Filename _deathNight[7];
729 
730  Filename _weaponShootSound[8];
731  Filename _weaponReloadSound[8];
732  Filename _heySound[7];
733  int _weaponMaxAmmo[8];
734 
735  byte *_crosshairsPalette;
736  Graphics::Surface _crosshairsInactive[8];
737  Graphics::Surface _crosshairsActive[8];
738  Graphics::Surface _crosshairsTarget[8];
739  Graphics::Surface _leftArrowPointer;
740  Graphics::Surface _rightArrowPointer;
741  Graphics::Surface _crossPointer;
742 
743  void updateFromScript();
744  bool checkCup(const Common::String &name);
745 
746  Script _currentScript;
747  ScriptMode _currentMode;
748  uint32 _currentActor;
749  uint32 _currentWeapon;
750  Common::Array<Filename> _warningVideosDay;
751  Common::Array<Filename> _warningVideosNight;
752  Common::Array<Filename> _warningAlarmVideos;
753  Filename _warningHostage;
754 
755  Common::Array<Filename> _deathVideo;
756  Common::HashMap<Common::String, bool> _shootsDestroyed;
757 
758  bool hasFeature(EngineFeature f) const override {
759  return (f == kSupportsReturnToLauncher);
760  }
761 };
762 
763 } // End of namespace Hypno
764 
765 #endif
bool canSaveAutosaveCurrently() override
Definition: hypno.h:601
Definition: grammar.h:732
Definition: image_decoder.h:53
Definition: grammar.h:333
Definition: str.h:59
Definition: installshieldv3_archive.h:35
Definition: font.h:83
Definition: hypno.h:647
Definition: surface.h:67
Definition: grammar.h:359
EngineFeature
Definition: engine.h:282
Definition: grammar.h:121
Definition: libfile.h:39
Definition: stream.h:77
Definition: error.h:81
Definition: grammar.h:221
Definition: grammar.h:244
Definition: grammar.h:440
Definition: pixelformat.h:138
Definition: grammar.h:152
Definition: advancedDetector.h:164
Definition: random.h:44
Definition: hypno.h:452
Definition: grammar.h:214
Definition: grammar.h:235
Definition: hypno.h:560
Definition: list.h:44
Definition: rect.h:536
Definition: path.h:52
Definition: grammar.h:707
Definition: stream.h:745
Definition: audiostream.h:212
Definition: subtitles.h:78
Definition: grammar.h:228
Definition: mixer.h:49
bool canLoadGameStateCurrently(Common::U32String *msg=nullptr) override
Definition: hypno.h:205
Definition: hypno.h:462
Definition: grammar.h:187
Definition: grammar.h:48
Definition: hypno.h:141
Definition: grammar.h:262
Definition: hashmap.h:85
Definition: ustr.h:57
Definition: grammar.h:311
Definition: fs.h:69
Definition: bitarray.h:29
Definition: rect.h:144
Definition: grammar.h:35
Definition: grammar.h:253
bool canSaveGameStateCurrently(Common::U32String *msg=nullptr) override
Definition: hypno.h:207
Definition: grammar.h:132
bool hasFeature(EngineFeature f) const override
Definition: hypno.h:521
Definition: grammar.h:600
Definition: grammar.h:745
Definition: grammar.h:141
Definition: grammar.h:277
Definition: grammar.h:207
Definition: grammar.h:104
bool hasFeature(EngineFeature f) const override
Definition: hypno.h:605
Definition: system.h:166
Definition: hypno.h:119
bool canSaveAutosaveCurrently() override
Definition: hypno.h:206
Definition: movie_decoder.h:32
Definition: engine.h:149
Definition: grammar.h:395
Definition: system.h:39
Definition: grammar.h:170
Platform
Definition: platform.h:93
Definition: grammar.h:294
Language
Definition: language.h:45