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

advancedDetector.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_ADVANCED_DETECTOR_H
00024 #define ENGINES_ADVANCED_DETECTOR_H
00025 
00026 #include "engines/metaengine.h"
00027 #include "engines/engine.h"
00028 
00029 #include "common/hash-str.h"
00030 
00031 #include "common/gui_options.h" // FIXME: Temporary hack?
00032 
00033 namespace Common {
00034 class Error;
00035 class FSList;
00036 }
00037 
00043 struct ADGameFileDescription {
00044     const char *fileName; 
00045     uint16 fileType;      
00046     const char *md5;      
00047     int32 fileSize;       
00048 };
00049 
00054 #define AD_LISTEND {NULL, 0, NULL, 0}
00055 
00060 #define AD_ENTRY1(f, x) {{ f, 0, x, -1}, AD_LISTEND}
00061 
00066 #define AD_ENTRY1s(f, x, s) {{ f, 0, x, s}, AD_LISTEND}
00067 
00068 enum ADGameFlags {
00069     ADGF_NO_FLAGS        =  0,
00070     ADGF_AUTOGENTARGET   = (1 << 20), 
00071     ADGF_UNSTABLE        = (1 << 21), 
00072     ADGF_TESTING         = (1 << 22), 
00073     ADGF_PIRATED         = (1 << 23), 
00074     ADGF_ADDENGLISH      = (1 << 24), 
00075     ADGF_MACRESFORK      = (1 << 25), 
00076     ADGF_USEEXTRAASTITLE = (1 << 26), 
00077     ADGF_DROPLANGUAGE    = (1 << 27), 
00078     ADGF_DROPPLATFORM    = (1 << 28), 
00079     ADGF_CD              = (1 << 29), 
00080     ADGF_DEMO            = (1 << 30)  
00081 };
00082 
00083 struct ADGameDescription {
00084     const char *gameId;
00085     const char *extra;
00086     ADGameFileDescription filesDescriptions[14];
00087     Common::Language language;
00088     Common::Platform platform;
00089 
00095     uint32 flags;
00096 
00097     const char *guiOptions;
00098 };
00099 
00103 struct ADDetectedGame {
00104     bool hasUnknownFiles;
00105     FilePropertiesMap matchedFiles;
00106     const ADGameDescription *desc;
00107 
00108     ADDetectedGame() : desc(nullptr), hasUnknownFiles(false) {}
00109     explicit ADDetectedGame(const ADGameDescription *d) : desc(d), hasUnknownFiles(false) {}
00110 };
00111 
00113 typedef Common::Array<ADDetectedGame> ADDetectedGames;
00114 
00119 #define AD_TABLE_END_MARKER \
00120     { NULL, NULL, { { NULL, 0, NULL, 0 } }, Common::UNK_LANG, Common::kPlatformUnknown, ADGF_NO_FLAGS, GUIO0() }
00121 
00122 struct ADFileBasedFallback {
00127     const ADGameDescription *desc;
00128 
00133     const char *filenames[10];
00134 };
00135 
00136 
00137 enum ADFlags {
00146     kADFlagUseExtraAsHint = (1 << 0)
00147 };
00148 
00149 
00154 struct ADExtraGuiOptionsMap {
00158     const char *guioFlag;
00159 
00163     ExtraGuiOption option;
00164 };
00165 
00166 #define AD_EXTRA_GUI_OPTIONS_TERMINATOR { 0, { 0, 0, 0, 0 } }
00167 
00171 class AdvancedMetaEngine : public MetaEngine {
00172 protected:
00179     const byte *_gameDescriptors;
00180 
00185     const uint _descItemSize;
00186 
00191     const PlainGameDescriptor *_gameIds;
00192 
00196     const ADExtraGuiOptionsMap * const _extraGuiOptions;
00197 
00206     uint _md5Bytes;
00207 
00219     const char *_singleId;
00220 
00226     uint32 _flags;
00227 
00233     Common::String _guiOptions;
00234 
00239     uint32 _maxScanDepth;
00240 
00248     const char * const *_directoryGlobs;
00249 
00259     bool _matchFullPaths;
00260 
00261 public:
00262     AdvancedMetaEngine(const void *descs, uint descItemSize, const PlainGameDescriptor *gameIds, const ADExtraGuiOptionsMap *extraGuiOptions = 0);
00263 
00268     PlainGameList getSupportedGames() const override;
00269 
00270     PlainGameDescriptor findGame(const char *gameId) const override;
00271 
00272     DetectedGames detectGames(const Common::FSList &fslist) const override;
00273 
00274     virtual Common::Error createInstance(OSystem *syst, Engine **engine) const;
00275 
00276     virtual const ExtraGuiOptions getExtraGuiOptions(const Common::String &target) const;
00277 
00278 protected:
00279     // To be implemented by subclasses
00280     virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const = 0;
00281 
00282     typedef Common::HashMap<Common::String, Common::FSNode, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> FileMap;
00283 
00288     virtual ADDetectedGame fallbackDetect(const FileMap &allFiles, const Common::FSList &fslist) const {
00289         return ADDetectedGame();
00290     }
00291 
00292 private:
00293     void initSubSystems(const ADGameDescription *gameDesc) const;
00294 
00295 protected:
00307     virtual ADDetectedGames detectGame(const Common::FSNode &parent, const FileMap &allFiles, Common::Language language, Common::Platform platform, const Common::String &extra) const;
00308 
00321     ADDetectedGame detectGameFilebased(const FileMap &allFiles, const Common::FSList &fslist, const ADFileBasedFallback *fileBasedFallback) const;
00322 
00327     void composeFileHashMap(FileMap &allFiles, const Common::FSList &fslist, int depth, const Common::String &parentName = Common::String()) const;
00328 
00330     bool getFileProperties(const Common::FSNode &parent, const FileMap &allFiles, const ADGameDescription &game, const Common::String fname, FileProperties &fileProps) const;
00331 
00333     DetectedGame toDetectedGame(const ADDetectedGame &adGame) const;
00334 };
00335 
00336 #endif


Generated on Sat Mar 16 2019 05:01:18 for ResidualVM by doxygen 1.7.1
curved edge   curved edge