ScummVM API documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
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 class Application;
48 class Game;
49 class TeCore;
50 class TeSoundManager;
51 class TeRenderer;
52 class TeResourceManager;
53 class TeInputMgr;
54 
55 class TetraedgeFSNode;
56 
57 class TetraedgeFSList : public Common::Array<TetraedgeFSNode> {};
59 public:
60  TetraedgeFSNode() : _archive(nullptr) {}
61  explicit TetraedgeFSNode(Common::Archive *archive) : _archive(archive) {}
62  TetraedgeFSNode(Common::Archive *archive, const Common::Path &archivePath) : _archive(archive), _archivePath(archivePath) {}
63 
64  Common::SeekableReadStream *createReadStream() const;
65  bool isReadable() const;
66  bool isDirectory() const;
67  Common::Path getPath() const;
68  Common::String toString() const;
69  int getDepth() const;
70  bool exists() const;
71  bool loadXML(Common::XMLParser &parser) const;
72  Common::String getName() const;
73  TetraedgeFSNode getChild(const Common::Path &path) const;
74  bool getChildren(TetraedgeFSList &fslist, Common::FSNode::ListMode mode = Common::FSNode::kListDirectoriesOnly, bool hidden = true) const;
75  bool operator<(const TetraedgeFSNode& node) const;
76  void maybeAddToSearchMan() const;
77 private:
78  Common::Archive *_archive;
79  Common::Path _archivePath;
80 };
81 
82 class TetraedgeEngine : public Engine {
83 public:
84  enum TetraedgeGameType {
85  kNone,
86  kSyberia,
87  kSyberia2,
88  kAmerzone
89  };
90 
91 private:
92  const ADGameDescription *_gameDescription;
93  Common::RandomSource _randomSource;
94  TeCore *_core;
95  Application *_application;
96  Game *_game;
97  TeSoundManager *_soundManager;
98  TeRenderer *_renderer;
99  TeResourceManager *_resourceManager;
100  TeInputMgr *_inputMgr;
101  enum TetraedgeGameType _gameType;
102  Common::Array<Common::Archive *> _rootArchives;
103 
104 protected:
105  // Engine APIs
106  Common::Error run() override;
107 
108 public:
109  TetraedgeEngine(OSystem *syst, const ADGameDescription *gameDesc);
110  ~TetraedgeEngine() override;
111 
112  const Common::Array<Common::Archive *>& getRootArchives() const { return _rootArchives; }
113 
114  uint32 getFeatures() const;
115 
116  void closeGameDialogs();
117 
121  Common::String getGameId() const;
122 
123  Common::Language getGameLanguage() const;
124 
125  Common::Platform getGamePlatform() const;
126 
127  bool isUtf8Release() const;
128 
129  bool isGameDemo() const;
130 
134  uint32 getRandomNumber(uint maxNum) {
135  return _randomSource.getRandomNumber(maxNum);
136  }
137 
138  bool hasFeature(EngineFeature f) const override {
139  return
140  (f == kSupportsLoadingDuringRuntime) ||
141  (f == kSupportsSavingDuringRuntime) ||
142  (f == kSupportsReturnToLauncher) ||
143  (f == kSupportsChangingOptionsDuringRuntime) ||
144  (f == kSupportsQuitDialogOverride);
145  };
146 
147  bool canLoadGameStateCurrently(Common::U32String *msg = nullptr) override;
148  bool canSaveGameStateCurrently(Common::U32String *msg = nullptr) override;
149  bool canSaveAutosaveCurrently() override;
150 
155  Common::Error syncGame(Common::Serializer &s);
156 
157  Common::Error saveGameState(int slot, const Common::String &desc, bool isAutosave) override;
158 
159  Common::Error saveGameStream(Common::WriteStream *stream, bool isAutosave = false) override {
160  Common::Serializer s(nullptr, stream);
161  return syncGame(s);
162  }
163 
164  static void getSavegameThumbnail(Graphics::Surface &thumb);
165 
166  Common::Error loadGameState(int slot) override;
167  Common::Error loadGameStream(Common::SeekableReadStream *stream) override;
168  int getDefaultScreenWidth() const;
169  int getDefaultScreenHeight() const;
170 
171  Application *getApplication();
172  Game *getGame();
173  TeCore *getCore();
174  TeSoundManager *getSoundManager();
175  TeRenderer *getRenderer();
176  TeResourceManager *getResourceManager();
177  TeInputMgr *getInputMgr();
178  TetraedgeGameType gameType() const { return _gameType; }
179  bool gameIsAmerzone() const { return _gameType == kAmerzone; }
180 
181  void openConfigDialog();
182  bool onKeyUp(const Common::KeyState &state);
183 
184  static Common::StringArray splitString(const Common::String &text, char c);
185 
186  /* Pick the renderer type to use.
187  Currently will only return kRendererTypeOpenGL or kRendererTypeTinyGL */
188  Graphics::RendererType preferredRendererType() const;
189 
190 private:
191  void configureSearchPaths();
192  void registerConfigDefaults();
193 };
194 
195 extern TetraedgeEngine *g_engine;
196 
197 } // namespace Tetraedge
198 
199 #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:253
Definition: stream.h:77
Definition: error.h:84
Definition: tetraedge.h:82
Definition: array.h:52
Definition: advancedDetector.h:163
Definition: random.h:44
Definition: tetraedge.h:58
bool hasFeature(EngineFeature f) const override
Definition: tetraedge.h:138
Definition: path.h:52
uint getRandomNumber(uint max)
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:159
Definition: xmlparser.h:98
Definition: te_renderer.h:33
Definition: ustr.h:57
Definition: tetraedge.h:57
ListMode
Definition: fs.h:86
Definition: application.h:50
Definition: keyboard.h:294
uint32 getRandomNumber(uint maxNum)
Definition: tetraedge.h:134
Definition: system.h:161
Definition: te_sound_manager.h:33
Definition: te_input_mgr.h:31
Definition: engine.h:144
Platform
Definition: platform.h:46
Definition: te_core.h:37
Language
Definition: language.h:45