Game Development Reference
In-Depth Information
Putting It All Together
The editor can be implemented in Qt (just an example, chosen for its cross-platform support, though C# can also
be supported using Mono on platforms other than Windows). This editor will be an empty skeleton that contains a
plug-in manager dialog and nothing else, since all the functionality will be brought in by the plug-ins. Once again
you need to emphasize the separation of the plug-in systems. They are two systems, one for the UI, and one for the
editor core commands. UI plug-ins will use the commands found in the editor core plug-ins (see Figure 11-1 at the
beginning of this chapter). The main UI editor can even do without a plug-in system if it's so intended, but the editor
core command plug-ins will still exist.
Implementing a Plug-in with Commands
To ensure that you have a simple way of implementing new commands, the method of declaring commands and
plug-ins must be straightforward. In the editor core API, IPlugin is the interface a plug-in must implement. To help
rapid plug-in development, you can write a series of macros. In this sample plug-in, implementing a few commands
would look like the code shown in Listing 11-15.
Listing 11-15. A Sample Plug-in Implementation
#include “EditorApi.h”
void example_my_command1(IParameterValues* pParams)
{
// get our calling parameter values
int numberOfHorses =
pParams->GetInt32("numberOfHorses");
std::string dailyMessage =
pParams->GetText("dailyMessage");
// do something important here for the command...
// return some parameter values
pParams->SetDouble("weightOfAllHorses", 1234.0f);
pParams->SetText("userFullName", "Mihaela Claudia V.");
}
void example_my_command2(IParameterValues* pParams)
{
// now here we'll try to grab an array
FloatArray magicFloats =
pParams->GetFloatArray("magicFloats");
for (size_t i = 0; i < magicFloats.count; ++i)
{
float oneMagicFloat = magicFloats.elements[i];
// do something majestic with the float...
}
// we do not need to return any value now
}
BEGIN_PLUGIN
 
Search WWH ::




Custom Search