ScummVM API documentation
fool.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 FOOL_H
23 #define FOOL_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 "graphics/macgui/macwindowmanager.h"
34 
35 #include "fool/detection.h"
36 
37 #define SCREEN_WIDTH 0x200
38 #define SCREEN_HEIGHT 0x156
39 #define MENU_HEIGHT 0x14
40 #define SCREEN_PAGE_SIZE (SCREEN_WIDTH*SCREEN_HEIGHT/8) // 0x5580
41 
42 namespace Fool {
43 
44 struct FoolGameDescription;
45 
46 enum FoolVersion {
47  kFool11 = 1,
48  kFool20 = 2,
49  kFool30 = 4,
50  kFoolDemo10 = 8,
51 };
52 
53 class FoolEngine : public Engine {
54 private:
55  const FOOLGameDescription *_gameDescription;
56  Common::RandomSource _randomSource;
57 protected:
58  // Engine APIs
59  Common::Error run() override;
60 
61 public:
63  Graphics::MacWindowManager *_wm = nullptr;
64 
65  FoolEngine(OSystem *syst, const FOOLGameDescription *gameDesc);
66  ~FoolEngine() override;
67 
68  uint32 getFeatures() const;
69 
73  Common::String getGameId() const;
74 
78  uint32 getRandomNumber(uint maxNum) {
79  return _randomSource.getRandomNumber(maxNum);
80  }
81 
82  bool hasFeature(EngineFeature f) const override {
83  return
87  };
88 
89  bool canLoadGameStateCurrently(Common::U32String *msg = nullptr) override {
90  return true;
91  }
92  bool canSaveGameStateCurrently(Common::U32String *msg = nullptr) override {
93  return true;
94  }
95 
96  const Common::String getTarget() {
97  return _targetName;
98  }
99 
105 
106  Common::Error saveGameStream(Common::WriteStream *stream, bool isAutosave = false) override {
107  Common::Serializer s(nullptr, stream);
108  return syncGame(s);
109  }
111  Common::Serializer s(stream, nullptr);
112  return syncGame(s);
113  }
114 };
115 
116 extern FoolEngine *g_engine;
117 #define SHOULD_QUIT ::Fool::g_engine->shouldQuit()
118 
119 } // End of namespace Fool
120 
121 #endif // FOOL_H
Definition: managed_surface.h:51
Definition: str.h:59
EngineFeature
Definition: engine.h:282
Common::Error syncGame(Common::Serializer &s)
Definition: stream.h:77
Definition: error.h:81
bool canSaveGameStateCurrently(Common::U32String *msg=nullptr) override
Definition: fool.h:92
Definition: random.h:44
uint getRandomNumber(uint max)
Definition: stream.h:745
Engine * g_engine
Definition: serializer.h:80
Definition: macwindowmanager.h:149
Definition: engine.h:296
Definition: ustr.h:57
const Common::String _targetName
Definition: engine.h:186
Definition: detection.h:27
Common::String getGameId() const
Common::Error run() override
bool canLoadGameStateCurrently(Common::U32String *msg=nullptr) override
Definition: fool.h:89
Common::Error loadGameStream(Common::SeekableReadStream *stream) override
Definition: fool.h:110
Definition: system.h:166
Definition: fool.h:53
Definition: engine.h:314
bool hasFeature(EngineFeature f) const override
Definition: fool.h:82
uint32 getRandomNumber(uint maxNum)
Definition: fool.h:78
Definition: engine.h:149
Common::Error saveGameStream(Common::WriteStream *stream, bool isAutosave=false) override
Definition: fool.h:106
Definition: detection.h:29