ScummVM API documentation
m4.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 M4_H
23#define M4_H
24
25#include "common/scummsys.h"
26#include "common/system.h"
27#include "common/error.h"
28#include "common/fs.h"
29#include "common/random.h"
30#include "common/serializer.h"
31#include "common/util.h"
32#include "engines/engine.h"
33#include "engines/savestate.h"
34
35#include "m4/detection.h"
36#include "m4/vars.h"
37#include "m4/core/rooms.h"
38#include "m4/subtitles.h"
39
40namespace M4 {
41
42struct M4GameDescription;
43
44class M4Engine : public Engine, public Sections {
45private:
46 const M4GameDescription *_gameDescription;
47 Common::RandomSource _randomSource;
48 M4Subtitles _subtitles;
49
53 void m4_inflight();
54
59 Common::InSaveFile *getOriginalSave(int slot) const;
60
61protected:
62 bool _useOriginalSaveLoad = false;
63
64 // Engine APIs
65 Common::Error run() override;
66
70 virtual Vars *createVars() = 0;
71
75 virtual void setupConsole() = 0;
76
77 void pauseEngineIntern(bool pause) override;
78
79public:
80 M4Engine(OSystem *syst, const M4GameDescription *gameDesc);
81 ~M4Engine() override = default;
82
83 uint32 getFeatures() const;
84
85 bool useOriginalSaveLoad() const {
86 return _useOriginalSaveLoad;
87 }
88
93
97 int getGameType() const;
98
103
107 int isDemo() const;
108
112 uint32 getRandomNumber(uint maxNum) {
113 return _randomSource.getRandomNumber(maxNum);
114 }
115
116 void initializePath(const Common::FSNode &gamePath) override;
117
118 bool hasFeature(EngineFeature f) const override {
119 return
123 };
124
125 bool canLoadGameStateCurrently(Common::U32String * msg = nullptr) override;
126 bool canSaveGameStateCurrently(Common::U32String *msg = nullptr) override;
127 void syncSoundSettings() override;
128
129 Common::Error loadGameState(int slot) override;
130 Common::Error loadGameStateDoIt(int slot);
131
137
138 virtual void syncFlags(Common::Serializer &s) = 0;
139
140 Common::Error saveGameStream(Common::WriteStream* stream, bool isAutosave = false) override;
141
143
147 bool autosaveExists() const;
148
152 bool savesExist() const;
153
158
162 bool loadSaveThumbnail(int slotNum, M4sprite *thumbnail) const;
163
167 bool saveGameFromMenu(int slotNum, const Common::String &desc,
168 Graphics::Surface &thumbnail);
169
173 virtual void showSaveScreen();
174
175 enum LoadDialogSource { kLoadFromMainMenu, kLoadFromGameDialog, kLoadFromHotkey };
179 virtual void showLoadScreen(LoadDialogSource fromMainMenu);
180
184 virtual void showEngineInfo() = 0;
185
186 void drawSubtitle(const Common::String &soundId) const {
187 _subtitles.drawSubtitle(soundId);
188 }
189
190 void clearSubtitle() const {
191 _subtitles.clearSubtitle();
192 }
193
194 void updateSubtitleOverlay() const {
195 _subtitles.updateSubtitleOverlay();
196 }
197};
198
199extern M4Engine *g_engine;
200#define SHOULD_QUIT ::M4::g_engine->shouldQuit()
201#define IS_BURGER (g_engine->getGameType() == GType_Burger)
202#define IS_RIDDLE (g_engine->getGameType() == GType_Riddle)
203
204} // End of namespace M4
205
206#endif // M4_H
Definition: error.h:81
Definition: fs.h:69
Definition: random.h:44
uint getRandomNumber(uint max)
Definition: stream.h:745
Definition: serializer.h:80
Definition: str.h:59
Definition: ustr.h:57
Definition: stream.h:77
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: m4.h:44
virtual Vars * createVars()=0
virtual void showSaveScreen()
SaveStateList listSaves() const
void syncSoundSettings() override
int isDemo() const
int getGameType() const
Common::Language getLanguage() const
bool savesExist() const
virtual void showLoadScreen(LoadDialogSource fromMainMenu)
Common::Error run() override
Common::Error loadGameState(int slot) override
Common::String getGameId() const
void pauseEngineIntern(bool pause) override
void initializePath(const Common::FSNode &gamePath) override
Common::Error saveGameStream(Common::WriteStream *stream, bool isAutosave=false) override
bool autosaveExists() const
bool saveGameFromMenu(int slotNum, const Common::String &desc, Graphics::Surface &thumbnail)
bool hasFeature(EngineFeature f) const override
Definition: m4.h:118
Common::Error syncGame(Common::Serializer &s)
Common::Error loadGameStream(Common::SeekableReadStream *stream) override
virtual void setupConsole()=0
bool loadSaveThumbnail(int slotNum, M4sprite *thumbnail) const
bool canLoadGameStateCurrently(Common::U32String *msg=nullptr) override
virtual void showEngineInfo()=0
uint32 getRandomNumber(uint maxNum)
Definition: m4.h:112
bool canSaveGameStateCurrently(Common::U32String *msg=nullptr) override
Definition: subtitles.h:34
Definition: rooms.h:85
Definition: vars.h:68
Definition: system.h:166
Language
Definition: language.h:45
Definition: database.h:28
Definition: surface.h:67
Definition: detection.h:53
Definition: gui.h:31