ScummVM API documentation
mortimer.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#ifndef SCUMM_INSANE_MORTIMER_MORTIMER_H
22#define SCUMM_INSANE_MORTIMER_MORTIMER_H
23
24#include "engines/engine.h"
25#include "backends/keymapper/keymap.h"
26#include "audio/mixer.h"
27#include "common/random.h"
28#include "graphics/surface.h"
29#include "scumm/insane/mortimer/flight.h"
30#include "scumm/insane/mortimer/interview.h"
31#include "scumm/insane/mortimer/campaign.h"
32#include "scumm/insane/mortimer/castle.h"
33#include "scumm/insane/mortimer/scores.h"
34#include "scumm/smush/saud_stream.h"
35
36namespace Scumm {
37
38// Registered by the SCUMM plugin, but deliberately independent of ScummEngine
39// and both Rebel Assault engines.
40class MortimerEngine : public Engine {
41public:
42 MortimerEngine(OSystem *system, bool isDemo);
43 ~MortimerEngine() override;
44 Common::Error run() override;
45 bool hasFeature(EngineFeature feature) const override;
46 Common::String getSaveStateName(int slot) const override;
47 Common::Error loadGameState(int slot) override;
48 bool canLoadGameStateCurrently(Common::U32String *msg = nullptr) override;
49 bool canSaveGameStateCurrently(Common::U32String *msg = nullptr) override;
50 static Common::KeymapArray initKeymaps();
51
52protected:
53 void pauseEngineIntern(bool pause) override;
54
55private:
56 enum CrashStage { kNoCrash, kCrashMovie, kRepairMovie };
57
58 bool loadResources();
59 bool selectDifficulty();
60 void setDifficulty(uint flight, uint riddle);
61 bool selectPilot();
62 bool startPilot();
63 Common::Error savePilot();
64 void saveCheckpoint(uint checkpoint);
65 void setScoreNameInput(bool enabled);
66 bool finishHighScores();
67 uint introCount() const;
68 bool loadIntro(uint index);
69 bool loadFlight(uint segment);
70 bool enterCampaignScene();
71 bool loadRegion(uint region);
72 bool loadRetailFlight(const Common::String &name, bool cached = false);
73 bool followFlightBranch();
74 bool loadSubtitles(const char *name);
75 void updateMovieContext();
76 bool startMovie(bool preserveScreen = false);
77 bool startFlight();
78 bool startCrash();
79 bool loadCrashMovie(bool repair);
80 bool finishCrash();
81 void creditRescues();
82 bool processInterview();
83 bool processCastle();
84 bool updateCastle();
85 bool updateScene();
86 bool nextScene(bool skip = false);
87 bool restart(bool all = false);
88 MortimerMovie &currentMovie();
89 const MortimerMovie &currentMovie() const;
90 MortimerFlight &currentFlight() { return _castleActive ? _castle : _flight; }
91 bool interactive() const { return _castleActive ? _castle.courseView() :
92 _crashStage == kNoCrash && !_interviewActive && _introIndex < 0 && _flight.interactive(); }
93 bool canFire() const { return interactive() && (!_castleActive || _castle.acceptsShots()); }
94 bool gameplay() const { return _interviewActive || _castleActive || _crashStage != kNoCrash ||
95 (_introIndex < 0 && (!_isDemo || _flight.interactive())); }
96 bool canPause() const;
97 void setMouse(const Common::Point &position);
98 void updateSteering(bool centerView = false);
99 void updateView(int x, int y);
100 void updateInterface();
101 void fire();
102 bool updateAutofire();
103 Common::Point moviePoint(const Common::Point &point) const;
104 Common::Point screenPoint(const Common::Point &point) const;
105 void draw(bool paused = false);
106 void drawSprite(const MortimerSprite &sprite, int x, int y, bool centered = false, const Common::Rect *clip = nullptr);
107 void drawProjectile();
108 void drawTargets();
109 void drawDashboard();
110 bool speechPlaying() const;
111 void playSound(const MortimerSound &sound, Audio::SoundHandle &handle, Audio::Mixer::SoundType type, uint64 skipFrames = 0);
112 void playMovieSounds(bool seek = false);
113 void playCollisionSound();
114 void stopSounds();
115 bool handleCheatKey(const Common::KeyState &key);
116 bool skipRegion();
117 bool addShellShock();
118 void clearShellShock();
119
120 const bool _isDemo, _restoredContent;
121 uint _flightDifficulty, _riddleDifficulty;
122 Common::String _pilotName;
123 int _pilotSlot;
124 uint _checkpoint;
125 uint32 _score, _checkpointScore;
126 bool _girl, _pilotLoadRequested;
127 bool _highScoresActive, _highScoreEligible, _viewingHighScores;
128 MortimerHighScores _highScores;
129 Common::RandomSource _random;
130 MortimerCutscene _intro;
131 MortimerFlight _flight;
132 MortimerInterview _interview;
133 MortimerCastle _castle;
134 MortimerSubtitles _subtitles;
135 MortimerCampaign _campaign;
136 Graphics::Surface _screen;
137 Common::Array<MortimerSprite> _cockpit, _dashboard, _reticles, _icons, _head;
138 Common::Array<MortimerSprite> _scopeHit, _slimeHit, _scopeBeam, _slimeBall, _numbers, _corners;
139 MortimerSound _scopeSound, _rescueSound, _collisionSound, _slimeSound, _slimeHitSound, _glowSound, _balloonSound;
140 MortimerSound _buttonSound, _payoutSound;
141 SaudStreamState _soundState;
143 Common::Array<Audio::SoundHandle> _collisionHandles;
144 Audio::SoundHandle _scopeHandle, _rescueHandle, _glowHandle, _castleHandle;
145 Common::String _loadError;
146 Common::String _flightName, _pendingFlight, _subtitleName;
147 Common::Rect _viewport;
148 Common::Point _mouse, _view, _aim, _shot;
149 Common::Point _steeringHistory[10];
150 int _steering[4];
151 MortimerFlight::Weapon _shotWeapon;
152 CrashStage _crashStage;
153 uint32 _nextFrameTime, _pauseTime;
154 int _introIndex;
155 int _loadedRegion;
156 uint _creditedRescues;
157 uint _segment, _carriedStones, _completedSpecies, _shellShocks, _shockFrame, _crashCount;
158 uint _uiFrame, _shotFrame, _glowFrame, _glowStones, _pendingGlowStones;
159 uint _fireButtons, _fireCountdown;
160 uint _iconFlash[7];
161 bool _finished, _controllerMode, _interviewActive, _castleActive;
162 bool _resourcesLoaded, _playingCached;
163 bool _needsRepair, _hitJolt;
164 bool _cheats, _programmer, _invulnerable;
165};
166
167} // End of namespace Scumm
168
169#endif
SoundType
Definition: mixer.h:73
Definition: mixer.h:49
Definition: error.h:81
Definition: random.h:44
Definition: str.h:59
Definition: ustr.h:57
Definition: engine.h:149
EngineFeature
Definition: engine.h:282
Definition: system.h:166
Definition: mortimer.h:40
Common::Error loadGameState(int slot) override
Common::Error run() override
bool canLoadGameStateCurrently(Common::U32String *msg=nullptr) override
bool hasFeature(EngineFeature feature) const override
Common::String getSaveStateName(int slot) const override
void pauseEngineIntern(bool pause) override
bool canSaveGameStateCurrently(Common::U32String *msg=nullptr) override
Definition: flight.h:28
Definition: movie.h:72
Definition: actor.h:30
Definition: keyboard.h:294
Definition: rect.h:144
Definition: rect.h:536
Definition: surface.h:67