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/hash-str.h"
30 #include "common/random.h"
31 #include "common/serializer.h"
32 #include "common/util.h"
33 #include "engines/engine.h"
34 #include "engines/savestate.h"
35 #include "graphics/screen.h"
36 
37 #include "m4/detection.h"
38 #include "m4/vars.h"
39 #include "m4/core/rooms.h"
40 
41 namespace M4 {
42 
43 struct M4GameDescription;
44 
45 class M4Engine : public Engine, public Sections {
46 private:
47  const M4GameDescription *_gameDescription;
48  Common::RandomSource _randomSource;
49 
53  void m4_inflight();
54 
59  Common::InSaveFile *getOriginalSave(int slot) const;
60 
61 protected:
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 public:
78  M4Engine(OSystem *syst, const M4GameDescription *gameDesc);
79  ~M4Engine() override;
80 
81  uint32 getFeatures() const;
82 
83  bool useOriginalSaveLoad() const {
84  return _useOriginalSaveLoad;
85  }
86 
90  Common::String getGameId() const;
91 
95  int getGameType() const;
96 
101 
105  int isDemo() const;
106 
110  uint32 getRandomNumber(uint maxNum) {
111  return _randomSource.getRandomNumber(maxNum);
112  }
113 
114  bool hasFeature(EngineFeature f) const override {
115  return
119  };
120 
121  bool canLoadGameStateCurrently(Common::U32String * msg = nullptr) override;
122  bool canSaveGameStateCurrently(Common::U32String *msg = nullptr) override;
123  void syncSoundSettings() override;
124 
125  Common::Error loadGameState(int slot) override;
126  Common::Error loadGameStateDoIt(int slot);
127 
133 
134  virtual void syncFlags(Common::Serializer &s) = 0;
135 
136  Common::Error saveGameStream(Common::WriteStream* stream, bool isAutosave = false) override;
137 
139 
143  bool autosaveExists() const;
144 
148  bool savesExist() const;
149 
153  SaveStateList listSaves() const;
154 
158  bool loadSaveThumbnail(int slotNum, M4sprite *thumbnail) const;
159 
163  bool saveGameFromMenu(int slotNum, const Common::String &desc,
164  Graphics::Surface &thumbnail);
165 
169  virtual void showSaveScreen();
170 
171  enum LoadDialogSource { kLoadFromMainMenu, kLoadFromGameDialog, kLoadFromHotkey };
175  virtual void showLoadScreen(LoadDialogSource fromMainMenu);
176 
180  virtual void showEngineInfo() = 0;
181 };
182 
183 extern M4Engine *g_engine;
184 #define SHOULD_QUIT ::M4::g_engine->shouldQuit()
185 
186 } // End of namespace M4
187 
188 #endif // M4_H
Definition: detection.h:53
Definition: str.h:59
Common::Error loadGameStream(Common::SeekableReadStream *stream) override
bool saveGameFromMenu(int slotNum, const Common::String &desc, Graphics::Surface &thumbnail)
Definition: surface.h:67
EngineFeature
Definition: engine.h:253
int getGameType() const
Definition: stream.h:77
Definition: vars.h:69
Definition: error.h:84
virtual Vars * createVars()=0
virtual void showSaveScreen()
bool hasFeature(EngineFeature f) const override
Definition: m4.h:114
Common::String getGameId() const
Definition: random.h:44
virtual void setupConsole()=0
Common::Error run() override
int isDemo() const
uint getRandomNumber(uint max)
Definition: stream.h:745
Common::Error syncGame(Common::Serializer &s)
Definition: serializer.h:79
Definition: engine.h:267
bool loadSaveThumbnail(int slotNum, M4sprite *thumbnail) const
Common::Error saveGameStream(Common::WriteStream *stream, bool isAutosave=false) override
Common::Language getLanguage() const
Definition: ustr.h:57
virtual void showLoadScreen(LoadDialogSource fromMainMenu)
virtual void showEngineInfo()=0
Definition: database.h:28
Definition: gui.h:31
uint32 getRandomNumber(uint maxNum)
Definition: m4.h:110
bool canLoadGameStateCurrently(Common::U32String *msg=nullptr) override
bool autosaveExists() const
bool savesExist() const
Definition: system.h:161
Definition: engine.h:285
Definition: rooms.h:87
void syncSoundSettings() override
Definition: m4.h:45
Definition: engine.h:144
Common::Error loadGameState(int slot) override
SaveStateList listSaves() const
bool canSaveGameStateCurrently(Common::U32String *msg=nullptr) override
Language
Definition: language.h:45