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
40class cInit;
41
42namespace Hpl1 {
43
44struct Hpl1GameDescription;
45
46class Hpl1Engine : public Engine {
47private:
48 const ADGameDescription *_gameDescription;
49 Common::RandomSource _randomSource;
50 cInit *_gameInit;
51
52protected:
53 // Engine APIs
54 Common::Error run() override;
55
56 void pauseEngineIntern(bool pause) override;
57
58public:
59 Graphics::Screen *_screen = nullptr;
60
61public:
62 Hpl1Engine(OSystem *syst, const ADGameDescription *gameDesc);
63 ~Hpl1Engine() override;
64
65 uint32 getFeatures() const;
66
71
75 uint32 getRandomNumber(uint maxNum) {
76 return _randomSource.getRandomNumber(maxNum);
77 }
78
79 bool hasFeature(EngineFeature f) const override {
80 return (f == kSupportsLoadingDuringRuntime) ||
82 };
83
84 bool canLoadGameStateCurrently(Common::U32String *msg = nullptr) override {
85 return true;
86 }
87
88 Common::String createSaveFile(const Common::String &internalName);
89
90 Common::String mapInternalSaveToFile(const Common::String &internalName);
91
92 void removeSaveFile(const Common::String &internalName);
93
94 Common::StringArray listInternalSaves(const Common::String &pattern);
95
96 Common::Error loadGameState(int slot) override;
97
103
104 Common::Error saveGameStream(Common::WriteStream *stream, bool isAutosave = false) override {
105 Common::Serializer s(nullptr, stream);
106 return syncGame(s);
107 }
109 Common::Serializer s(stream, nullptr);
110 return syncGame(s);
111 }
112};
113
114extern Hpl1Engine *g_engine;
115#define SHOULD_QUIT ::Hpl1::g_engine->shouldQuit()
116
117} // namespace Hpl1
118
119#endif
Definition: error.h:81
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
@ kSupportsLoadingDuringRuntime
Definition: engine.h:305
Definition: screen.h:47
Definition: hpl1.h:46
Common::Error syncGame(Common::Serializer &s)
Common::String getGameId() const
Common::Error saveGameStream(Common::WriteStream *stream, bool isAutosave=false) override
Definition: hpl1.h:104
bool hasFeature(EngineFeature f) const override
Definition: hpl1.h:79
bool canLoadGameStateCurrently(Common::U32String *msg=nullptr) override
Definition: hpl1.h:84
Common::Error run() override
void pauseEngineIntern(bool pause) override
Common::Error loadGameState(int slot) override
uint32 getRandomNumber(uint maxNum)
Definition: hpl1.h:75
Common::Error loadGameStream(Common::SeekableReadStream *stream) override
Definition: hpl1.h:108
Definition: system.h:166
Definition: Init.h:70
Engine * g_engine
Definition: advancedDetector.h:164