271
edits
(Fix compiler errors) |
Ccawley2011 (talk | contribs) (Update to reflect the recent MetaEngine changes) |
||
Line 58: | Line 58: | ||
=== Subclassing AdvancedMetaEngine === | === Subclassing AdvancedMetaEngine === | ||
Let's implement the plugin interface:<br> | Let's implement the plugin interface:<br> | ||
You'll have to create a custom AdvancedMetaEngine subclass. This provides the information and functionality related to the engine that can be used by the launcher without loading and running the game engine, which includes | You'll have to create a custom AdvancedMetaEngine subclass. This provides the information and functionality related to the engine that can be used by the launcher without loading and running the game engine, which includes defining keymaps and achievements, listing savegames, and instancing the engine. You'll also have to create a custom AdvancedMetaEngineDetection subclass. This provides the information related to detecting games, which is always included in the main ScummVM executable regardless of whether or not the engine is enabled. | ||
The following example illustrates this. It contains the necessary fundamentals of the details of the games and the code to create the engine, as well as REGISTER macros that register the meta engine with ScummVM. For the Quux example, If you create an empty file named quux.txt, the engine will detect it. | The following example illustrates this. It contains the necessary fundamentals of the details of the games and the code to create the engine, as well as REGISTER macros that register the meta engine with ScummVM. For the Quux example, If you create an empty file named quux.txt, the engine will detect it. | ||
Line 293: | Line 293: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== Example: engines/quux/detection. | === Example: engines/quux/detection.cpp === | ||
<syntaxhighlight lang="cpp"> | |||
#include "base/plugins.h" | |||
#include "engines/advancedDetector.h" | |||
namespace Quux { | |||
static const PlainGameDescriptor quuxGames[] = { | |||
{ "quux", "Quux the Example Module" }, | |||
{ "quuxcd", "Quux the Example Module (CD version)" }, | |||
{ 0, 0 } | |||
}; | |||
static const ADGameDescription gameDescriptions[] = { | |||
{ | |||
"quux", | |||
0, | |||
AD_ENTRY1s("quux.txt", 0, 0), | |||
Common::EN_ANY, | |||
Common::kPlatformDOS, | |||
ADGF_NO_FLAGS, | |||
GUIO1(GUIO_NOMIDI) | |||
}, | |||
AD_TABLE_END_MARKER | |||
}; | |||
} // End of namespace Quux | |||
class | class QuuxMetaEngineDetection : public AdvancedMetaEngineDetection { | ||
public: | public: | ||
QuuxMetaEngineDetection() : AdvancedMetaEngineDetection(Quux::gameDescriptions, sizeof(ADGameDescription), Quux::quuxGames) { | |||
} | |||
const char *getEngineId() const override { | const char *getEngineId() const override { | ||
Line 317: | Line 336: | ||
return "Copyright (C) Quux Entertainment Ltd."; | return "Copyright (C) Quux Entertainment Ltd."; | ||
} | } | ||
}; | }; | ||
REGISTER_PLUGIN_STATIC(QUUX_DETECTION, PLUGIN_TYPE_ENGINE_DETECTION, QuuxMetaEngineDetection); | |||
</syntaxhighlight> | </syntaxhighlight> | ||
=== Example: engines/quux/ | === Example: engines/quux/metaengine.cpp === | ||
<syntaxhighlight lang="cpp"> | <syntaxhighlight lang="cpp"> | ||
#include "quux/quux.h" | #include "quux/quux.h" | ||
#include "engines/ | #include "engines/advancedDetector.h" | ||
class QuuxMetaEngine : public AdvancedMetaEngine { | |||
public: | |||
const char *getName() const override { | |||
return "quux"; | |||
} | |||
} | |||
bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const override; | |||
}; | }; | ||
bool QuuxMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const { | bool QuuxMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const { | ||
Line 373: | Line 372: | ||
MODULE_OBJS := \ | MODULE_OBJS := \ | ||
metaengine.o \ | |||
quux.o | quux.o | ||
Line 386: | Line 385: | ||
# Include common rules | # Include common rules | ||
include $(srcdir)/rules.mk | include $(srcdir)/rules.mk | ||
# Detection objects | |||
DETECT_OBJS += $(MODULE)/detection.o | |||
</syntaxhighlight> | </syntaxhighlight> | ||
edits