ScummVM API documentation
dgds.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 DGDS_DGDS_H
23#define DGDS_DGDS_H
24
25#include "common/error.h"
26#include "common/events.h"
27#include "common/platform.h"
28#include "common/random.h"
29#include "common/serializer.h"
30
31#include "graphics/managed_surface.h"
32
33#include "engines/advancedDetector.h"
34#include "engines/engine.h"
35
36#include "dgds/resource.h"
37#include "dgds/clock.h"
38#include "dgds/menu.h"
39
40
41namespace Dgds {
42
43class Console;
44class ResourceManager;
45class Decompressor;
46class Image;
47class GamePalettes;
48class FontManager;
49class Inventory;
50class SDSScene;
51class GDSScene;
52class Sound;
53class REQFileData;
54class Menu;
55struct DgdsADS;
56class ADSInterpreter;
57class Globals;
58class ShellGame;
59class DragonArcade;
60class HocIntro;
61class ChinaTank;
62class ChinaTrain;
63
64// This is not actually MS per frame - it's MS per timer tick that is used for delays.
65const float MS_PER_FRAME = 16.6667f;
66
67enum DgdsGameId {
68 GID_DRAGON,
69 GID_HOC,
70 GID_WILLY,
71 GID_SQ5DEMO,
72 GID_COMINGATTRACTIONS,
73 GID_QUARKY,
74 GID_CASTAWAY,
75 GID_INVALID,
76};
77
78enum DgdsDetailLevel {
79 kDgdsDetailLow = 0,
80 kDgdsDetailHigh = 1
81};
82
83enum DgdsKeyEvent {
84 kDgdsKeyLoad,
85 kDgdsKeySave,
86 kDgdsKeyToggleMenu,
87 kDgdsKeyToggleClock,
88 kDgdsKeyNextChoice,
89 kDgdsKeyPrevChoice,
90 kDgdsKeyNextItem,
91 kDgdsKeyPrevItem,
92 kDgdsKeyPickUp,
93 kDgdsKeyLook,
94 kDgdsKeyActivate,
95};
96
97enum DgdsMouseCursor {
98 kDgdsMouseGameDefault = -1,
99 kDgdsMouseWait = -2,
100 kDgdsMouseLook = -3,
101};
102
103// TODO: Enable keymapper for dragon arcade sequences
104/*
105enum DragonArcadeKeyEvent {
106 kDragonArcadeKeyLeft,
107 kDragonArcadeKeyRight,
108 kDragonArcadeKeyUp,
109 kDragonArcadeKeyDown,
110 kDragonArcadeKeyLeftUp,
111 kDragonArcadeKeyRightUp,
112 kDragonArcadeKeyLeftDown,
113 kDragonArcadeKeyRightDown,
114 kDragonArcadeKeyJumpMode,
115 kDragonArcadeKeyFire,
116};
117*/
118
119
120class DgdsEngine : public Engine {
121public:
122 Sound *_soundPlayer;
123 Graphics::ManagedSurface _compositionBuffer;
124
125 static const byte HOC_CHAR_SWAP_ICONS[];
126
127private:
128 Common::Platform _platform;
129 Common::Language _gameLang;
130
131 Console *_console;
132
133 ResourceManager *_resource;
134 Decompressor *_decompressor;
135
136 DgdsGameId _gameId;
137 Graphics::ManagedSurface _backgroundBuffer;
138 Common::String _backgroundFile; // Record the background file name for save games.
139 Graphics::ManagedSurface _storedAreaBuffer;
140 SDSScene *_scene;
141 GDSScene *_gdsScene;
142 Menu *_menu;
143
144 ADSInterpreter *_adsInterp;
145 GamePalettes *_gamePals;
146 Globals *_gameGlobals;
147 Inventory *_inventory;
148
149 // Dragon only
150 DragonArcade *_dragonArcade;
151
152 // HoC only
153 ShellGame *_shellGame;
154 HocIntro *_hocIntro;
155 ChinaTank *_chinaTank;
156 ChinaTrain *_chinaTrain;
157
158 FontManager *_fontManager;
161
162 // Settings which we should integrate with ScummVM settings UI
163 DgdsDetailLevel _detailLevel;
164 int _textSpeed;
165 int _difficulty;
166
167 bool _justChangedScene1;
168 // There is another flag in Rise of the Dragon, but it seems to never be used for anything?
169 //bool _justChangedScene2;
170
171 Common::RandomSource _random;
172 Common::Point _lastMouse; // originals start mouse at 0,0.
173 Common::EventType _lastMouseEvent; // a pending mouse event to process.
174 int _currentCursor;
175 Common::Point _currentCursorHot;
176
177 Clock _clock;
178
179 MenuId _menuToTrigger;
180
181 bool _isLoading;
182 const char *_rstFileName;
183
184 bool _isDemo;
185 bool _isEGA;
186 bool _isAltDlgColors;
187 bool _flipMode;
188 uint32 _thisFrameMs;
189 int16 _lastGlobalFade; // Only used in Willy Beamish
190 uint _lastGlobalFadedPal; // Only used in Willy Beamish
191
192 bool _debugShowHotAreas;
193
194public:
195 DgdsEngine(OSystem *syst, const ADGameDescription *gameDesc);
196 virtual ~DgdsEngine();
197
198 virtual Common::Error run() override;
199
200 void restartGame();
201
202 DgdsGameId getGameId() const { return _gameId; }
203 Common::Language getGameLang() const { return _gameLang; }
204 Common::Platform getPlatform() const { return _platform; }
205
206 Graphics::ManagedSurface &getBackgroundBuffer() { return _backgroundBuffer; }
207 Graphics::ManagedSurface &getStoredAreaBuffer() { return _storedAreaBuffer; }
208
209 // Various game engine singletons
210 Common::SeekableReadStream *getResource(const Common::String &name, bool ignorePatches);
211 ResourceManager *getResourceManager() { return _resource; }
212 Decompressor *getDecompressor() { return _decompressor; }
213 const SDSScene *getScene() const { return _scene; }
214 SDSScene *getScene() { return _scene; }
215 GDSScene *getGDSScene() { return _gdsScene; }
216 const FontManager *getFontMan() const { return _fontManager; }
217 const Common::SharedPtr<Image> &getUICorners() { return _corners; }
218 const Common::SharedPtr<Image> &getIcons() { return _icons; }
219 GamePalettes *getGamePals() { return _gamePals; }
220 Globals *getGameGlobals() { return _gameGlobals; }
221 Inventory *getInventory() { return _inventory; }
222 Clock &getClock() { return _clock; }
223 ADSInterpreter *adsInterpreter() { return _adsInterp; }
224 Common::RandomSource &getRandom() { return _random; }
225
226 bool changeScene(int sceneNum);
227 void setMouseCursor(int num);
228
229 int getTextSpeed() const { return _textSpeed; }
230 void setTextSpeed(int16 speed) { _textSpeed = speed; }
231 int16 getDifficulty() const { return _difficulty; }
232 void setDifficulty(int16 difficulty) { _difficulty = difficulty; }
233 DgdsDetailLevel getDetailLevel() const { return _detailLevel; }
234 void setDetailLevel(DgdsDetailLevel level) { _detailLevel = level; }
235
236 void setShowClock(bool val);
237 bool justChangedScene1() const { return _justChangedScene1; }
238 Common::Point getLastMouse() const { return _lastMouse; }
239 Common::Point getLastMouseMinusHot() const;
240
241 bool canLoadGameStateCurrently(Common::U32String *msg = nullptr) override;
242 bool canSaveGameStateCurrently(Common::U32String *msg = nullptr) override;
244
245 Common::Error saveGameStream(Common::WriteStream *stream, bool isAutosave = false) override {
246 Common::Serializer s(nullptr, stream);
247 return syncGame(s);
248 }
249
251
252 bool hasFeature(EngineFeature f) const override {
253 return
257 };
258
259 void setBackgroundFile(const Common::String &name) { _backgroundFile = name; }
260 const Common::String &getBackgroundFile() const { return _backgroundFile; }
261 void setMenuToTrigger(MenuId menu) { _menuToTrigger = menu; }
262 bool isInvButtonVisible() const;
263 ShellGame *getShellGame() { return _shellGame; }
264 HocIntro *getHocIntro() { return _hocIntro; }
265 ChinaTrain *getChinaTrain() { return _chinaTrain; }
266 ChinaTank *getChinaTank() { return _chinaTank; }
267 DragonArcade *getDragonArcade() { return _dragonArcade; }
268 uint32 getThisFrameMs() const { return _thisFrameMs; }
269 void updateThisFrameMillis();
270
271 static DgdsEngine *getInstance() { return static_cast<DgdsEngine *>(g_engine); }
272 void setFlipMode(bool mode) { _flipMode = mode; }
273
274 bool isEGA() const { return _isEGA; }
275 bool isDemo() const { return _isDemo; }
276 bool isAltDlgColors() const { return _isAltDlgColors; }
277
278 void enableKeymapper();
279 void disableKeymapper();
280
281 void setDebugShowHotAreas(bool enable) { _debugShowHotAreas = enable; }
282 bool getDebugShowHotAreas() const { return _debugShowHotAreas; }
283
284 static void dumpFrame(const Graphics::Surface &surf, const char *name);
285
286 void dimPalForWillyDialog(bool force);
287
288private:
290
291 void loadCorners(const Common::String &filename);
292 void loadIcons();
293 void checkDrawInventoryButton();
294
295 void init(bool restarting);
296 void loadGameFiles();
297 void loadRestartFile();
298 void pumpMessages();
299};
300
301} // End of namespace Dgds
302
303#endif // DGDS_DGDS_H
Definition: error.h:81
Definition: random.h:44
Definition: stream.h:745
Definition: serializer.h:80
Definition: ptr.h:159
Definition: str.h:59
Definition: ustr.h:57
Definition: stream.h:77
Definition: ads.h:63
Definition: china_tank.h:28
Definition: china_train.h:159
Definition: clock.h:38
Definition: console.h:31
Definition: decompress.h:67
Definition: dgds.h:120
virtual Common::Error run() override
Common::Error loadGameStream(Common::SeekableReadStream *stream) override
Common::Error saveGameStream(Common::WriteStream *stream, bool isAutosave=false) override
Definition: dgds.h:245
bool canSaveAutosaveCurrently() override
bool canSaveGameStateCurrently(Common::U32String *msg=nullptr) override
bool canLoadGameStateCurrently(Common::U32String *msg=nullptr) override
bool hasFeature(EngineFeature f) const override
Definition: dgds.h:252
Definition: dragon_arcade.h:85
Definition: font.h:99
Definition: scene.h:213
Definition: game_palettes.h:45
Definition: globals.h:81
Definition: hoc_intro.h:33
Definition: inventory.h:37
Definition: menu.h:63
Definition: resource.h:48
Definition: scene.h:271
Definition: shell_game.h:30
Definition: sound.h:51
Definition: engine.h:149
EngineFeature
Definition: engine.h:282
@ kSupportsReturnToLauncher
Definition: engine.h:296
@ kSupportsSavingDuringRuntime
Definition: engine.h:314
@ kSupportsLoadingDuringRuntime
Definition: engine.h:305
Definition: managed_surface.h:51
Definition: system.h:166
EventType
Definition: events.h:49
Language
Definition: language.h:45
Platform
Definition: platform.h:93
Engine * g_engine
Definition: advancedDetector.h:164
Definition: rect.h:144
Definition: surface.h:67