ScummVM API documentation
crab.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 CRAB_H
23 #define CRAB_H
24 
25 #include "common/random.h"
26 #include "common/serializer.h"
27 
28 #include "crab/detection.h"
29 
30 namespace Graphics {
31 class ManagedSurface;
32 struct PixelFormat;
33 class Screen;
34 } // End of namespace Graphics
35 
36 namespace Crab {
37 
38 class App;
39 struct CrabGameDescription;
40 
41 class LoadingScreen;
42 
43 struct FilePaths;
44 struct TempValue;
45 class StringPool;
46 class ScreenSettings;
47 
48 namespace pyrodactyl {
49 namespace event {
50 struct GameEventStore;
51 } // End of namespace event
52 
53 namespace ui {
54 class SlideShow;
55 class OptionMenu;
56 
57 template<typename FileType>
58 class FileMenu;
59 
60 class SaveFileData;
61 } // End of namespace ui
62 
63 namespace image {
64 class ImageManager;
65 } // End of namespace image
66 
67 namespace input {
68 class Cursor;
69 class InputManager;
70 } // End of namespace input
71 
72 namespace music {
73 class MusicManager;
74 } // End of namespace music
75 
76 namespace text {
77 class TextManager;
78 } // End of namespace text
79 
80 } // End of namespace pyrodactyl
81 
82 enum DebugDraw {
83  DRAW_TMX = 1 << 0,
84  DRAW_PROP_BOUNDS = 1 << 1,
85  DRAW_SPRITE_BOUNDS = 1 << 2,
86  DRAW_PATHING = 1 << 3,
87  DRAW_FPS = 1 << 4
88 };
89 
90 class CrabEngine : public Engine {
91 private:
92  const ADGameDescription *_gameDescription;
93  Common::RandomSource _randomSource;
94  App *_app;
95 
96 protected:
97  // Engine APIs
98  Common::Error run() override;
99 
100 public:
101  Graphics::Screen *_screen = nullptr;
102  Graphics::PixelFormat *_format = nullptr;
103 
104  pyrodactyl::image::ImageManager *_imageManager = nullptr;
105  pyrodactyl::text::TextManager *_textManager = nullptr;
106  pyrodactyl::input::InputManager *_inputManager = nullptr;
107  pyrodactyl::music::MusicManager *_musicManager = nullptr;
108 
109  pyrodactyl::input::Cursor *_mouse = nullptr;
110  pyrodactyl::event::GameEventStore *_eventStore = nullptr;
111 
112  // Should these really be inside the Engine class?
113  LoadingScreen *_loadingScreen = nullptr;
114  pyrodactyl::ui::SlideShow *_helpScreen = nullptr;
115  pyrodactyl::ui::OptionMenu *_optionMenu = nullptr;
117 
118  FilePaths *_filePath = nullptr;
119  TempValue *_tempData = nullptr;
120  StringPool *_stringPool = nullptr;
121  ScreenSettings *_screenSettings = nullptr;
122 
123  // Keeps a copy of latest screen for thumbnail
124  Graphics::ManagedSurface *_thumbnail;
125 
126  // What components to draw lines for (if any)
127  uint32 _debugDraw;
128 
129  Common::FSNode _gameDataDir;
130 
131  CrabEngine(OSystem *syst, const ADGameDescription *gameDesc);
132  ~CrabEngine() override;
133  void initializePath(const Common::FSNode &gamePath) override;
134 
135  uint32 getFeatures() const;
136 
140  Common::String getGameId() const;
141 
145  uint32 getRandomNumber(uint maxNum) {
146  return _randomSource.getRandomNumber(maxNum);
147  }
148 
149  bool hasFeature(EngineFeature f) const override {
150  return (f == kSupportsLoadingDuringRuntime) ||
151  (f == kSupportsSavingDuringRuntime) ||
152  (f == kSupportsReturnToLauncher);
153  };
154 
155  bool canLoadGameStateCurrently(Common::U32String *msg = nullptr) override {
156  return true;
157  }
158 
159  bool canSaveGameStateCurrently(Common::U32String *msg = nullptr) override;
160 
165  Common::Error syncGame(Common::Serializer &s);
166 
167  Common::Error saveGameState(int slot, const Common::String &desc, bool isAutosave) override;
168  Common::Error loadGameState(int slot) override;
169 
170  void syncSoundSettings() override;
171 
172 
173 };
174 
175 extern CrabEngine *g_engine;
176 
177 } // End of namespace Crab
178 
179 #endif // CRAB_H
Definition: managed_surface.h:51
Definition: str.h:59
EngineFeature
Definition: engine.h:253
Definition: error.h:84
Definition: crab.h:58
Definition: pixelformat.h:138
Definition: advancedDetector.h:163
Definition: random.h:44
Definition: GameParam.h:62
uint getRandomNumber(uint max)
Definition: atari-screen.h:60
Definition: ImageManager.h:63
Definition: screen.h:48
Engine * g_engine
Definition: serializer.h:79
Definition: app.h:39
Definition: LoadingScreen.h:41
Definition: TextManager.h:52
uint32 getRandomNumber(uint maxNum)
Definition: crab.h:145
Definition: eventstore.h:43
Definition: FileData.h:45
Definition: ustr.h:57
Definition: atari-cursor.h:38
Definition: crab.h:90
Definition: fs.h:69
Definition: formatinfo.h:28
Definition: moveeffect.h:37
Definition: cursor.h:46
bool canLoadGameStateCurrently(Common::U32String *msg=nullptr) override
Definition: crab.h:155
Definition: GameParam.h:153
Definition: system.h:161
Definition: SlideShow.h:42
Definition: musicplugin.h:131
Definition: MusicManager.h:42
Definition: engine.h:144
bool hasFeature(EngineFeature f) const override
Definition: crab.h:149
Definition: OptionMenu.h:47
Definition: GameParam.h:107
Definition: ScreenSettings.h:102