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/surface.h"
32 #include "graphics/managed_surface.h"
33 
34 #include "engines/advancedDetector.h"
35 #include "engines/engine.h"
36 
37 #include "gui/debugger.h"
38 
39 #include "dgds/resource.h"
40 #include "dgds/clock.h"
41 #include "dgds/menu.h"
42 
43 
44 namespace Dgds {
45 
46 class Console;
47 class ResourceManager;
48 class Decompressor;
49 class Image;
50 class GamePalettes;
51 class FontManager;
52 class Inventory;
53 class SDSScene;
54 class GDSScene;
55 class Sound;
56 class REQFileData;
57 class Menu;
58 struct DgdsADS;
59 class ADSInterpreter;
60 class Globals;
61 class ShellGame;
62 
63 const float MS_PER_FRAME = 16.6667f;
64 
65 enum DgdsGameId {
66  GID_DRAGON,
67  GID_HOC,
68  GID_WILLY,
69  GID_SQ5DEMO,
70  GID_COMINGATTRACTIONS,
71  GID_QUARKY
72 };
73 
74 enum DgdsDetailLevel {
75  kDgdsDetailLow = 0,
76  kDgdsDetailHigh = 1
77 };
78 
79 enum DgdsKeyEvent {
80  kDgdsKeyLoad,
81  kDgdsKeySave,
82  kDgdsKeyToggleMenu,
83  kDgdsKeyToggleClock,
84  kDgdsKeyNextChoice,
85  kDgdsKeyPrevChoice,
86  kDgdsKeyNextItem,
87  kDgdsKeyPrevItem,
88  kDgdsKeyPickUp,
89  kDgdsKeyLook,
90  kDgdsKeyActivate,
91 };
92 
93 class DgdsEngine : public Engine {
94 public:
95  Common::Platform _platform;
96  Sound *_soundPlayer;
97  Graphics::ManagedSurface _compositionBuffer;
98 
99  static const byte HOC_CHAR_SWAP_ICONS[];
100 
101 private:
102  Console *_console;
103 
104  ResourceManager *_resource;
105  Decompressor *_decompressor;
106 
107  DgdsGameId _gameId;
108  Graphics::ManagedSurface _backgroundBuffer;
109  Common::String _backgroundFile; // Record the background file name for save games.
110  Graphics::ManagedSurface _storedAreaBuffer;
111  SDSScene *_scene;
112  GDSScene *_gdsScene;
113  Menu *_menu;
114 
115  ADSInterpreter *_adsInterp;
116  GamePalettes *_gamePals;
117  Globals *_gameGlobals;
118  Inventory *_inventory;
119 
120  // HoC only
121  ShellGame *_shellGame;
122 
123  FontManager *_fontManager;
124  Common::SharedPtr<Image> _corners;
126 
127  // Settings which we should integrate with ScummVM settings UI
128  DgdsDetailLevel _detailLevel;
129  int _textSpeed;
130  int _difficulty;
131 
132  bool _justChangedScene1;
133  bool _justChangedScene2;
134 
135  Common::RandomSource _random;
136  Common::Point _lastMouse; // originals start mouse at 0,0.
137  int _currentCursor;
138  Common::Point _currentCursorHot;
139 
140  Clock _clock;
141 
142  MenuId _menuToTrigger;
143 
144  bool _isLoading;
145  const char *_rstFileName;
146 
147  bool _isDemo;
148  bool _flipMode;
149 
150 public:
151  DgdsEngine(OSystem *syst, const ADGameDescription *gameDesc);
152  virtual ~DgdsEngine();
153 
154  virtual Common::Error run() override;
155 
156  void restartGame();
157 
158  DgdsGameId getGameId() { return _gameId; }
159 
160  Graphics::ManagedSurface &getBackgroundBuffer() { return _backgroundBuffer; }
161  Graphics::ManagedSurface &getStoredAreaBuffer() { return _storedAreaBuffer; }
162 
163  // Various game engine singletons
164  Common::SeekableReadStream *getResource(const Common::String &name, bool ignorePatches);
165  ResourceManager *getResourceManager() { return _resource; }
166  Decompressor *getDecompressor() { return _decompressor; }
167  const SDSScene *getScene() const { return _scene; }
168  SDSScene *getScene() { return _scene; }
169  GDSScene *getGDSScene() { return _gdsScene; }
170  const FontManager *getFontMan() const { return _fontManager; }
171  const Common::SharedPtr<Image> &getUICorners() { return _corners; }
172  const Common::SharedPtr<Image> &getIcons() { return _icons; }
173  GamePalettes *getGamePals() { return _gamePals; }
174  Globals *getGameGlobals() { return _gameGlobals; }
175  Inventory *getInventory() { return _inventory; }
176  Clock &getClock() { return _clock; }
177  ADSInterpreter *adsInterpreter() { return _adsInterp; }
178  Common::RandomSource &getRandom() { return _random; }
179 
180  bool changeScene(int sceneNum);
181  void setMouseCursor(uint num);
182 
183  int getTextSpeed() const { return _textSpeed; }
184  void setTextSpeed(int16 speed) { _textSpeed = speed; }
185  int16 getDifficulty() const { return _difficulty; }
186  void setDifficulty(int16 difficulty) { _difficulty = difficulty; }
187  DgdsDetailLevel getDetailLevel() const { return _detailLevel; }
188  void setDetailLevel(DgdsDetailLevel level) { _detailLevel = level; }
189 
190  void setShowClock(bool val);
191  bool justChangedScene1() const { return _justChangedScene1; }
192  bool justChangedScene2() const { return _justChangedScene2; }
193  Common::Point getLastMouse() const { return _lastMouse; }
194  Common::Point getLastMouseMinusHot() const;
195 
196  bool canLoadGameStateCurrently(Common::U32String *msg = nullptr) override;
197  bool canSaveGameStateCurrently(Common::U32String *msg = nullptr) override;
198  bool canSaveAutosaveCurrently() override;
199 
200  Common::Error saveGameStream(Common::WriteStream *stream, bool isAutosave = false) override {
201  Common::Serializer s(nullptr, stream);
202  return syncGame(s);
203  }
204 
206  Common::Serializer s(stream, nullptr);
207  return syncGame(s);
208  }
209 
210  bool hasFeature(EngineFeature f) const override {
211  return
214  };
215 
216  void setBackgroundFile(const Common::String &name) { _backgroundFile = name; }
217  const Common::String &getBackgroundFile() const { return _backgroundFile; }
218  void setMenuToTrigger(MenuId menu) { _menuToTrigger = menu; }
219  bool isInvButtonVisible() const;
220  ShellGame *getShellGame() { return _shellGame; }
221 
222  static DgdsEngine *getInstance() { return static_cast<DgdsEngine *>(g_engine); }
223  void setFlipMode(bool mode) { _flipMode = mode; }
224 
225 private:
226  Common::Error syncGame(Common::Serializer &s);
227 
228  void loadCorners(const Common::String &filename);
229  void loadIcons();
230  void checkDrawInventoryButton();
231 
232  void init(bool restarting);
233  void loadGameFiles();
234  void loadRestartFile();
235 };
236 
237 } // End of namespace Dgds
238 
239 #endif // DGDS_DGDS_H
Definition: managed_surface.h:51
Definition: str.h:59
EngineFeature
Definition: engine.h:250
Definition: game_palettes.h:45
Definition: stream.h:77
Definition: error.h:84
Definition: advancedDetector.h:163
Definition: globals.h:81
Definition: inventory.h:37
Definition: random.h:44
Definition: ads.h:28
Definition: sound.h:41
Definition: stream.h:745
Engine * g_engine
Definition: serializer.h:79
Definition: console.h:31
Definition: ads.h:63
Common::Error saveGameStream(Common::WriteStream *stream, bool isAutosave=false) override
Definition: dgds.h:200
bool canSaveAutosaveCurrently() override
bool hasFeature(EngineFeature f) const override
Definition: dgds.h:210
virtual Common::Error run() override
bool canLoadGameStateCurrently(Common::U32String *msg=nullptr) override
Definition: menu.h:72
Definition: clock.h:39
Definition: ustr.h:57
Definition: scene.h:408
bool canSaveGameStateCurrently(Common::U32String *msg=nullptr) override
Definition: rect.h:45
Common::Error loadGameStream(Common::SeekableReadStream *stream) override
Definition: dgds.h:205
Definition: dgds.h:93
Definition: system.h:161
Definition: ptr.h:159
Definition: scene.h:353
Definition: movie_decoder.h:32
Definition: font.h:99
Definition: engine.h:282
Definition: engine.h:143
Definition: decompress.h:67
Platform
Definition: platform.h:46
Definition: shell_game.h:30
Definition: resource.h:49