Game Development Reference
In-Depth Information
Of course, you can choose any format for the manifest file, like JSON or a custom text format. The important thing
is that the plug-in's DLL does not contain any information about the plug-in or its commands. Only the manifest file
holds that information.
Plug-ins can be located in a directory structure, as shown in Listing 11-5.
Listing 11-5. Example of Plug-in and Editor Directory Structure
\Plugins
\Example1
Example1.dll
Example1.plugin.xml
\Example2
Example2.dll
Example2.plugin.xml
EditorCore.dll (the editor code library)
EditorUI.exe (the main editor application)
One reason for storing the plug-in information inside external files is that plug-ins can be listed (with all their details)
in the editor's plug-in manager without being loaded into memory. In this way, you can avoid loading some plug-ins you
do not need to load, but still have information about them. For example, there can be special editor configurations for
lighting artists, programmers, or level designers, and these configuration files can be shared among users.
As you can see from the plug-in manifest, you have added information about the name, description, author, and
other useful properties, but also about the plug-in's dependencies (other plug-in GUIDs 5 ). Optionally, there should be
information about the commands, such as name, description, parameters, and return values, since you do not store
this information in the C++ source files. This information can be used by a debug layer to check the command syntax
at runtime and help the discovery of incorrect command calls during development.
For plug-in identification, you will use a GUID in the form shown in Listing 11-6.
Listing 11-6. The GUID Structure Used to Identify Plug-ins
// A plug-in unique ID, in a GUID form (see more about Microsoft
// GUID) and online/offline GUID generators
struct PluginGuid
{
PluginGuid();
// construct the guid from several elements/parts
// example:
// as text: 31D9B906-6125-4784-81FF-119C15267FCA
// as C++: 0x31d9b906, 0x6125, 0x4784, 0x81,
// 0xff, 0x11, 0x9c, 0x15, 0x26, 0x7f, 0xca
PluginGuid(uint32 a, uint16 b, uint16 c, uint8 d,
uint8 e, uint8 f, uint8 g, uint8 h, uint8 i,
uint8 j, uint8 k);
bool operator == (const PluginGuid& rOther) const;
// convert a GUID string to binary
// string format: "11191906-6125-4784-81FF-119C15267FC3"
bool fromString(const char* pGUID);
5 Wikipedia. “Globally unique identifier.” http://en.wikipedia.org/wiki/Globally_unique_identifier .
 
Search WWH ::




Custom Search