ScummVM API documentation
hpl1.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 HPL1_HPL1_H
23 #define HPL1_HPL1_H
24 
25 #include "common/bitarray.h"
26 #include "common/error.h"
27 #include "common/fs.h"
28 #include "common/hash-str.h"
29 #include "common/random.h"
30 #include "common/scummsys.h"
31 #include "common/serializer.h"
32 #include "common/system.h"
33 #include "common/util.h"
34 #include "engines/engine.h"
35 #include "engines/savestate.h"
36 #include "graphics/screen.h"
37 
38 #include "hpl1/detection.h"
39 
40 class cInit;
41 
42 namespace Hpl1 {
43 
44 struct Hpl1GameDescription;
45 
46 class Hpl1Engine : public Engine {
47 private:
48  const ADGameDescription *_gameDescription;
49  Common::RandomSource _randomSource;
50  cInit *_gameInit;
51 
52 protected:
53  // Engine APIs
54  Common::Error run() override;
55 
56  void pauseEngineIntern(bool pause) override;
57 
58 public:
59  Graphics::Screen *_screen = nullptr;
60 
61 public:
62  Hpl1Engine(OSystem *syst, const ADGameDescription *gameDesc);
63  ~Hpl1Engine() override;
64 
65  uint32 getFeatures() const;
66 
70  Common::String getGameId() const;
71 
75  uint32 getRandomNumber(uint maxNum) {
76  return _randomSource.getRandomNumber(maxNum);
77  }
78 
79  bool hasFeature(EngineFeature f) const override {
80  return (f == kSupportsLoadingDuringRuntime) ||
83  };
84 
85  bool canLoadGameStateCurrently(Common::U32String *msg = nullptr) override {
86  return true;
87  }
88 
89  Common::String createSaveFile(const Common::String &internalName);
90 
91  Common::String mapInternalSaveToFile(const Common::String &internalName);
92 
93  void removeSaveFile(const Common::String &internalName);
94 
95  Common::StringArray listInternalSaves(const Common::String &pattern);
96 
97  Common::Error loadGameState(int slot) override;
98 
104 
105  Common::Error saveGameStream(Common::WriteStream *stream, bool isAutosave = false) override {
106  Common::Serializer s(nullptr, stream);
107  return syncGame(s);
108  }
110  Common::Serializer s(stream, nullptr);
111  return syncGame(s);
112  }
113 };
114 
115 extern Hpl1Engine *g_engine;
116 #define SHOULD_QUIT ::Hpl1::g_engine->shouldQuit()
117 
118 } // namespace Hpl1
119 
120 #endif
Common::Error syncGame(Common::Serializer &s)
uint32 getRandomNumber(uint maxNum)
Definition: hpl1.h:75
Definition: str.h:59
EngineFeature
Definition: engine.h:253
Definition: stream.h:77
Definition: error.h:84
Definition: advancedDetector.h:163
Definition: random.h:44
uint getRandomNumber(uint max)
Definition: stream.h:745
Definition: screen.h:48
Engine * g_engine
Definition: serializer.h:79
Definition: engine.h:267
Common::String getGameId() const
Definition: ustr.h:57
Definition: hpl1.h:46
Common::Error saveGameStream(Common::WriteStream *stream, bool isAutosave=false) override
Definition: hpl1.h:105
Common::Error run() override
Definition: system.h:161
Common::Error loadGameState(int slot) override
bool canLoadGameStateCurrently(Common::U32String *msg=nullptr) override
Definition: hpl1.h:85
Common::Error loadGameStream(Common::SeekableReadStream *stream) override
Definition: hpl1.h:109
Definition: Init.h:70
Definition: engine.h:144
bool hasFeature(EngineFeature f) const override
Definition: hpl1.h:79
Definition: algorithms.h:27
void pauseEngineIntern(bool pause) override