ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

metaengine.h

Go to the documentation of this file.
00001 /* ScummVM - Graphic Adventure Engine
00002  *
00003  * ScummVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the COPYRIGHT
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #ifndef ENGINES_METAENGINE_H
00024 #define ENGINES_METAENGINE_H
00025 
00026 #include "common/achievements.h"
00027 #include "common/scummsys.h"
00028 #include "common/error.h"
00029 #include "common/array.h"
00030 
00031 #include "engines/game.h"
00032 #include "engines/savestate.h"
00033 
00034 #include "base/plugins.h"
00035 
00036 class Engine;
00037 class OSystem;
00038 
00039 namespace Common {
00040 class Keymap;
00041 class FSList;
00042 class OutSaveFile;
00043 class String;
00044 
00045 typedef SeekableReadStream InSaveFile;
00046 }
00047 
00048 namespace Graphics {
00049 struct Surface;
00050 }
00051 
00052 namespace GUI {
00053 class GuiObject;
00054 class OptionsContainerWidget;
00055 }
00056 
00061 struct ExtraGuiOption {
00062     const char *label;          // option label, e.g. "Fullscreen mode"
00063     const char *tooltip;        // option tooltip (when the mouse hovers above it)
00064     const char *configOption;   // confMan key, e.g. "fullscreen"
00065     bool defaultState;          // the detault state of the checkbox (checked or not)
00066 };
00067 
00068 typedef Common::Array<ExtraGuiOption> ExtraGuiOptions;
00069 
00070 #define EXTENDED_SAVE_VERSION 4
00071 
00072 struct ExtendedSavegameHeader {
00073     char id[6];
00074     uint8 version;
00075     Common::String saveName;
00076     Common::String description;
00077     uint32 date;
00078     uint16 time;
00079     uint32 playtime;
00080     Graphics::Surface *thumbnail;
00081     bool isAutosave;
00082 
00083     ExtendedSavegameHeader() {
00084         memset(id, 0, 6);
00085         version = 0;
00086         date = 0;
00087         time = 0;
00088         playtime = 0;
00089         thumbnail = nullptr;
00090         isAutosave = false;
00091     }
00092 };
00093 
00102 class MetaEngine : public PluginObject {
00103 private:
00107     static void saveScreenThumbnail(Common::OutSaveFile *saveFile);
00108 public:
00109     virtual ~MetaEngine() {}
00110 
00112     virtual const char *getEngineId() const = 0;
00113 
00115     virtual const char *getOriginalCopyright() const = 0;
00116 
00118     virtual PlainGameList getSupportedGames() const = 0;
00119 
00121     virtual PlainGameDescriptor findGame(const char *gameId) const = 0;
00122 
00128     virtual DetectedGames detectGames(const Common::FSList &fslist) const = 0;
00129 
00140     virtual Common::Error createInstance(OSystem *syst, Engine **engine) const = 0;
00141 
00160     virtual SaveStateList listSaves(const char *target) const;
00161 
00172     SaveStateList listSaves(const char *target, bool saveMode) const;
00173 
00178     virtual int getAutosaveSlot() const {
00179         return 0;
00180     }
00181 
00195     virtual const ExtraGuiOptions getExtraGuiOptions(const Common::String &target) const {
00196         return ExtraGuiOptions();
00197     }
00198 
00205     virtual void registerDefaultSettings(const Common::String &target) const;
00206 
00221     virtual GUI::OptionsContainerWidget *buildEngineOptionsWidget(GUI::GuiObject *boss, const Common::String &name, const Common::String &target) const;
00222 
00232     virtual const Common::AchievementsInfo getAchievementsInfo(const Common::String &target) const {
00233         return Common::AchievementsInfo();
00234     }
00235 
00246     virtual int getMaximumSaveSlot() const {
00247         return 0;
00248     }
00249 
00262     virtual void removeSaveState(const char *target, int slot) const;
00263 
00273     virtual SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const;
00274 
00281     virtual const char *getSavegameFile(int saveGameIdx, const char *target = nullptr) const;
00282 
00288     virtual const char *getSavegamePattern(const char *target = nullptr) const;
00289 
00293     virtual Common::Array<Common::Keymap *> initKeymaps(const char *target) const;
00294 
00297 
00302     enum MetaEngineFeature {
00308         kSupportsListSaves,
00309 
00313         kSupportsLoadingDuringStartup,
00314 
00319         kSupportsDeleteSave,
00320 
00335         kSavesSupportMetaInfo,
00336 
00342         kSavesSupportThumbnail,
00343 
00350         kSavesSupportCreationDate,
00351 
00358         kSavesSupportPlayTime,
00359 
00370         kSimpleSavesNames,
00371 
00379         kSavesUseExtendedFormat
00380     };
00381 
00386     virtual bool hasFeature(MetaEngineFeature f) const;
00387 
00388     static void appendExtendedSave(Common::OutSaveFile *saveFile, uint32 playtime,
00389         Common::String desc, bool isAutosave);
00390     static void parseSavegameHeader(ExtendedSavegameHeader *header, SaveStateDescriptor *desc);
00391     static void fillDummyHeader(ExtendedSavegameHeader *header);
00392     static WARN_UNUSED_RESULT bool readSavegameHeader(Common::InSaveFile *in, ExtendedSavegameHeader *header, bool skipThumbnail = true);
00393 
00395 };
00396 
00400 class EngineManager : public Common::Singleton<EngineManager> {
00401 public:
00407     DetectionResults detectGames(const Common::FSList &fslist) const;
00408 
00410     const Plugin *findPlugin(const Common::String &engineId) const;
00411 
00413     const PluginList &getPlugins() const;
00414 
00416     QualifiedGameDescriptor findTarget(const Common::String &target, const Plugin **plugin = NULL) const;
00417 
00425     QualifiedGameList findGamesMatching(const Common::String &engineId, const Common::String &gameId) const;
00426 
00432     Common::String createTargetForGame(const DetectedGame &game);
00433 
00435     void upgradeTargetIfNecessary(const Common::String &target) const;
00436 
00437 private:
00439     QualifiedGameList findGameInLoadedPlugins(const Common::String &gameId) const;
00440 
00442     const Plugin *findLoadedPlugin(const Common::String &engineId) const;
00443 
00445     void upgradeTargetForEngineId(const Common::String &target) const;
00446 };
00447 
00449 #define EngineMan EngineManager::instance()
00450 
00451 #endif


Generated on Sat Jul 11 2020 05:01:10 for ResidualVM by doxygen 1.7.1
curved edge   curved edge