Howto:Add new fgcommands to FlightGear: Difference between revisions

Jump to navigation Jump to search
m
Line 212: Line 212:
= Adding new commands =
= Adding new commands =
All new commands must have the previously described signature, the functions should then be added to the list of built-in commands, beginning in line [http://gitorious.org/fg/flightgear/blobs/next/src/Main/fg_commands.cxx#line1552 1552]. The list of built-in commands maps the human-readable names used in README.commands to the names of the internal C++ functions implementing them.
All new commands must have the previously described signature, the functions should then be added to the list of built-in commands, beginning in line [http://gitorious.org/fg/flightgear/blobs/next/src/Main/fg_commands.cxx#line1552 1552]. The list of built-in commands maps the human-readable names used in README.commands to the names of the internal C++ functions implementing them.
In addition to directly editing the default initialization routine in fg_init.cxx, you can also dynamically add/remove fgcommands from your SGSubsystem, by getting a handle to the SGCommandMgr singleton, specifying a command name, and a corresponding callback (which can be a static member of your SGSubsystem):
<syntaxhighlight lang="php">
SGCommandMgr::instance()->addCommand("command-name", commandCallback);
</syntaxhighlight>
This is something that would be typicall done in your constructor or the SGSubsystem::init() method.


When you send patches or file merge requests for new fgcommands, please also make sure to send patches for README.commands, too - so that your new commands are documented there.
When you send patches or file merge requests for new fgcommands, please also make sure to send patches for README.commands, too - so that your new commands are documented there.

Navigation menu