ScummVM API documentation
tetraedge.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 TETRAEDGE_TETRAEDGE_H
23 #define TETRAEDGE_TETRAEDGE_H
24 
25 #include "common/scummsys.h"
26 #include "common/system.h"
27 #include "common/error.h"
28 #include "common/events.h"
29 #include "common/file.h"
30 #include "common/fs.h"
31 #include "common/hash-str.h"
32 #include "common/random.h"
33 #include "common/serializer.h"
34 #include "common/util.h"
35 #include "common/formats/xmlparser.h"
36 #include "engines/engine.h"
37 #include "engines/savestate.h"
38 #include "graphics/screen.h"
39 #include "graphics/renderer.h"
40 
41 #include "tetraedge/detection.h"
42 
43 namespace Tetraedge {
44 
45 struct TetraedgeGameDescription;
46 
47 enum TETRAEDGEAction {
48  kActionNone,
49  kActionSkip,
50  kActionLoad,
51  kActionSave,
52 };
53 
54 class Application;
55 class Game;
56 class TeCore;
57 class TeSoundManager;
58 class TeRenderer;
59 class TeResourceManager;
60 class TeInputMgr;
61 
62 class TetraedgeFSNode;
63 
64 class TetraedgeFSList : public Common::Array<TetraedgeFSNode> {};
66 public:
67  TetraedgeFSNode() : _archive(nullptr) {}
68  explicit TetraedgeFSNode(Common::Archive *archive) : _archive(archive) {}
69  TetraedgeFSNode(Common::Archive *archive, const Common::Path &archivePath) : _archive(archive), _archivePath(archivePath) {}
70 
71  Common::SeekableReadStream *createReadStream() const;
72  bool isReadable() const;
73  bool isDirectory() const;
74  Common::Path getPath() const;
75  Common::String toString() const;
76  int getDepth() const;
77  bool exists() const;
78  bool loadXML(Common::XMLParser &parser) const;
79  Common::String getName() const;
80  TetraedgeFSNode getChild(const Common::Path &path) const;
81  bool getChildren(TetraedgeFSList &fslist, Common::FSNode::ListMode mode = Common::FSNode::kListDirectoriesOnly, bool hidden = true) const;
82  bool operator<(const TetraedgeFSNode& node) const;
83  void maybeAddToSearchMan() const;
84 private:
85  Common::Archive *_archive;
86  Common::Path _archivePath;
87 };
88 
89 class TetraedgeEngine : public Engine {
90 public:
91  enum TetraedgeGameType {
92  kNone,
93  kSyberia,
94  kSyberia2,
95  kAmerzone
96  };
97 
98 private:
99  const ADGameDescription *_gameDescription;
100  Common::RandomSource _randomSource;
101  TeCore *_core;
102  Application *_application;
103  Game *_game;
104  TeSoundManager *_soundManager;
105  TeRenderer *_renderer;
106  TeResourceManager *_resourceManager;
107  TeInputMgr *_inputMgr;
108  enum TetraedgeGameType _gameType;
109  Common::Array<Common::Archive *> _rootArchives;
110 
111 protected:
112  // Engine APIs
113  Common::Error run() override;
114 
115 public:
116  TetraedgeEngine(OSystem *syst, const ADGameDescription *gameDesc);
117  ~TetraedgeEngine() override;
118 
119  const Common::Array<Common::Archive *>& getRootArchives() const { return _rootArchives; }
120 
121  uint32 getFeatures() const;
122 
123  void closeGameDialogs();
124 
128  Common::String getGameId() const;
129 
130  Common::Language getGameLanguage() const;
131 
132  Common::Platform getGamePlatform() const;
133 
134  bool isUtf8Release() const;
135 
136  bool isGameDemo() const;
137 
141  uint32 getRandomNumber(uint maxNum) {
142  return _randomSource.getRandomNumber(maxNum);
143  }
144 
145  bool hasFeature(EngineFeature f) const override {
146  return
147  (f == kSupportsLoadingDuringRuntime) ||
148  (f == kSupportsSavingDuringRuntime) ||
149  (f == kSupportsReturnToLauncher) ||
150  (f == kSupportsChangingOptionsDuringRuntime) ||
151  (f == kSupportsQuitDialogOverride);
152  };
153 
154  bool canLoadGameStateCurrently(Common::U32String *msg = nullptr) override;
155  bool canSaveGameStateCurrently(Common::U32String *msg = nullptr) override;
156  bool canSaveAutosaveCurrently() override;
157 
162  Common::Error syncGame(Common::Serializer &s);
163 
164  Common::Error saveGameState(int slot, const Common::String &desc, bool isAutosave) override;
165 
166  Common::Error saveGameStream(Common::WriteStream *stream, bool isAutosave = false) override {
167  Common::Serializer s(nullptr, stream);
168  return syncGame(s);
169  }
170 
171  static void getSavegameThumbnail(Graphics::Surface &thumb);
172 
173  Common::Error loadGameState(int slot) override;
174  Common::Error loadGameStream(Common::SeekableReadStream *stream) override;
175  int getDefaultScreenWidth() const;
176  int getDefaultScreenHeight() const;
177 
178  Application *getApplication();
179  Game *getGame();
180  TeCore *getCore();
181  TeSoundManager *getSoundManager();
182  TeRenderer *getRenderer();
183  TeResourceManager *getResourceManager();
184  TeInputMgr *getInputMgr();
185  TetraedgeGameType gameType() const { return _gameType; }
186  bool gameIsAmerzone() const { return _gameType == kAmerzone; }
187 
188  void openConfigDialog();
189  bool onActionEnd(const Common::CustomEventType &state);
190 
191  static Common::StringArray splitString(const Common::String &text, char c);
192 
193  /* Pick the renderer type to use.
194  Currently will only return kRendererTypeOpenGL or kRendererTypeTinyGL */
195  Graphics::RendererType preferredRendererType() const;
196 
197 private:
198  void configureSearchPaths();
199  void registerConfigDefaults();
200 };
201 
202 extern TetraedgeEngine *g_engine;
203 
204 } // namespace Tetraedge
205 
206 #endif
Definition: game.h:46
Definition: str.h:59
Definition: detection.h:27
Definition: surface.h:67
RendererType
Definition: renderer.h:45
EngineFeature
Definition: engine.h:260
Definition: stream.h:77
Definition: error.h:81
Definition: tetraedge.h:89
Definition: array.h:52
Definition: advancedDetector.h:164
Definition: random.h:44
Definition: tetraedge.h:65
bool hasFeature(EngineFeature f) const override
Definition: tetraedge.h:145
Definition: path.h:52
uint getRandomNumber(uint max)
uint32 CustomEventType
Definition: events.h:204
Definition: stream.h:745
Definition: te_resource_manager.h:40
Engine * g_engine
Definition: serializer.h:79
Definition: archive.h:141
Common::Error saveGameStream(Common::WriteStream *stream, bool isAutosave=false) override
Definition: tetraedge.h:166
Definition: xmlparser.h:98
Definition: te_renderer.h:33
Definition: ustr.h:57
Definition: tetraedge.h:64
ListMode
Definition: fs.h:86
Definition: application.h:50
uint32 getRandomNumber(uint maxNum)
Definition: tetraedge.h:141
Definition: system.h:163
Definition: te_sound_manager.h:33
Definition: te_input_mgr.h:31
Definition: engine.h:146
Platform
Definition: platform.h:46
Definition: te_core.h:37
Language
Definition: language.h:45