Game Development Reference
In-Depth Information
Listing 11-12. The Command Callback Function Type
typedef void (*TPfnCommand)(IParameterValues* pParams);
For debugging and auto-documentation purposes, the editor core API can provide detailed command
information through the ICommand interface, which can hold the command description from the plug-in manifest file,
plus the command callback function pointer, as shown in Listing 11-13.
Listing 11-13. The Command Information Provider Interface
struct ICommand
{
virtual ~ICommand(){}
virtual const char* GetName() const = 0;
virtual const char* GetDescription() const = 0;
virtual const char* GetIconFilename() const = 0;
virtual TPfnCommand GetCommandFunc() = 0;
virtual const IParameterDefinitions*
GetParameterDefinitions() const = 0;
};
Direct Editor API Command Calls
You can call the editor core interface for executing commands directly from C++ or use a wrapper tool for another
language like C# (SWIG). To call the commands in C++, use the code shown in Listing 11-14.
Listing 11-14. How to Call a Command
// create a parameter values bag
IParameterValues* pParams =
pEditor->CreateParameterValues();
// set some parameter values
pParams->SetInt32(“someParam1”, 123);
pParams->SetText(“someName”, “Elena Lenutza Nedelcu”);
pParams->SetText(“someOtherName”, “Dorinel Nedelcu”);
// the actual command call
pEditor->Call(“someCommandName”, pParams);
// retrieve the return values
float fRetVal = pParams->GetFloat(“returnSomeValue”);
int someNum = pParams->GetInt32(“otherValue”);
Remote Editor API Command Calls
You can use sockets for calling the commands remotely, since they're cross-platform and relatively easy to use from
any language or environment. On the editor core DLL side, you will have a network server executable, and on the
editor UI side, you will have a network client sending and receiving command data.
Communication can be accomplished through reliable UDP or TCP. For a local editor on the same machine, TCP
would be okay even for LAN scenarios. If you are not so keen on using TCP because you consider it slow, UDP should
suffice to send commands. All logic remains the same in this networked scenario, but this setup opens doors to online
collaboration of multiple clients operating on the same data on the server. I'm not going to discuss this here, since it's
a subject for a whole chapter (a challenging and interesting one!).
Networked editing is also feasible for debugging and remote in-editor live tutorials.
 
Search WWH ::




Custom Search