PluginExamples

From X-Plane SDK
Revision as of 21:56, 20 April 2009 by Admin (Talk | contribs)

Jump to: navigation, search

V2.00 SDK

Example source code for C/C++ and Delphi

These examples show how to use the new 2.00 Functions.

You will need to define XPLM200 in your project for this example.

[SDK200Tests_cpp.zip] [SDK200Tests_dpr.zip]

You will need this obj file that I created. http://www.xpluginsdk.org/downloads/penguin.zip

Copy it to the XPlane V9 application directory.

V1.02 SDK

There are project files for Microsoft VC6, Metrowerks CW8, XCode 2.2 and make files for gcc. The Delphi projects have been modified so that they will build under Delphi on Windows or Kylix on Linux.

Important Note: to ensure that the sample projects on this page will find the correct headers and libraries first create a new folder, XPSDK102.

Download and expand XPSDK1.0.2 from the downloads page, creating an SDK folder.

Put this and the expanded plugin example files found below on this page into the newly created XPSDK102 folder.

e.g.

\XPSDK102 
	\SDK
        \SDKExamples
        \AdvancedSDKExamples
	\WidgetLibraryExample

I have personally built all projects using this layout on all platforms.

Example Plugins Projects and Sources (C and Delphi/Kylix)

Download this package to get a wide variety of examples--including HelloWorld--that are buildable on Mac, Windows, and Linux.

[SDKExamples.zip]

(This download contains project files for MSVC6, X-Code, CodeWarrior, GCC (Linux) and Delphi. It contain C and pascal source.)

Advanced Examples Plugins Projects and Sources (C and Delphi/Kylix)

EngineStarter, ShowEvents and TestEnums will be added as Delphi/Kylix projects when time permits.

TestWidgets is C only at the moment as it uses the new XPWidgetsEx.lib which is a static library.

18th April, 2007

The ExampleGauge plugin source has been changed so it will work on an Intel Mac.

[AdvancedSDKExamples.zip]

(Contains C code, project files for MSVC6, X-Code, CodeWarrior, GCC makefile, and some ports to Delphi/pascal.)

Example Plugin Binaries (Linux, Mac and Windows)

Standard, Utility (Allows inspection of datarefs) and Advanced Plugins (Demonstrates advanced usage of the SDK)

These are all in the one archive for each platform supported.

Each of these has corresponding project and source files above, apart from the Utility plugins.

[SDKPluginsLinuxBin.tar.bz2] - (Build Date :- 20/07/2006)

[SDKPluginsMacBin.sit] - (Build Date :- 20/07/2006)

[SDKPluginsWindowsBin.zip] - (Build Date :- 20/07/2006)

(Contains pre-built binaries for all of the examples, advanced examples, and some of the tools.)

Added XCode 2.2 Projects.

Tools (Available in binary)

DataRefEditor

This uses the DataRefs.txt file from the SDK website to determine what datarefs to show.

Uses moveable window to list datarefs. More than one window supported so they can be arranged and sized to suit. Use the window edges to resize the window, select anywhere within the window to move it. More than one window supported so they can be arranged and sized to suit. Type into bottom of the window to filter the datarefs, press return to allow Xplane keyboard focus. Left click on a value to edit it. The right most scroller allows the array indexes to be accessed from 0 to 99. The left most scroller controls the bank in steps of 100 to be selected, this allows arrays up to 4000 elements to be accessed.

DataRefTester

This uses the DataRefs.txt file from the SDK website to determine what datarefs to show.

New features as of 02/2006

Now allows the first 4096 elements to be viewed. %%%Added GoTo button to allow direct access to any element. %%%Tab completion, type in the first part of a dataref and then press the tab key. %%%It will find the nearest match, repeat until the whole dataref is located.

New features as of 08/2005

In the filters widget I have added 2 check boxes and a button %%%The first enables/disables the Dark Screen. %%%The second enables/disables Full Screen %%%Full Screen is when the dataref list takes up the whole screen. %%%If you disable this then the dataref list will scroll in the top quarter of the screen.

There is also a save button. %%%This will save the dataref names and values in a comma delimited file called DataRefTesterValues.txt. %%%This will be saved in the plugins directory.

If you have applied a filter then only those daterefs will be saved. %%%This is a very useful addition and the resulting file can be imported into a spreadsheet for instance.

DataInspector

This uses the DataRefs.txt file from the SDK website to determine what datarefs to show.

New features as of 02/2006

Now allows the first 4096 elements to be viewed or edited. %%%Tab completion, type in the first part of a dataref and then press the tab key. %%%It will find the nearest match, repeat until the whole dataref is located.

New features as of 08/2005

I have replaced the first 4 menu options with 4 more find widgets. %%%This means we have 8 in total now.

A very useful feature that I have added is persistency. %%%This means that any datarefs that you have typed in will be saved when you exit xplane. %%%The next time you start xplane they will be loaded and you can use them again.

They are stored in a file called "DataInspector.dat" and it resides in the plugins directory. %%%There is an example file in the archives below. %%%Copy it to the plugins directory along with the plugin.


On Linux the plugin uses this path so make sure yours is the same. %%%"Resources/plugins/DataRefs.txt" %%%It should be as that was from a fresh install on my linux system.

Copy all of the above plugin files into the Xplane Resources\Plugins directory to see what they look like.

This is a good way to see what the examples do.


Notes for Advanced Examples

EngineStarter plugin added 01/10/2005.

This examples shows how to start the engines in V8. Setting the Starter Duration in V8 does not work.

It also shows some fancy widgetry. The widget windows will resize depending on how many engines there are.

5 New plugins added 08/2005

"TestWidgets"

This example shows how to use the two new widgets, popups and listbox, that are in the XPWidgetsEx.lib.

[WidgetLibraryExample.zip |http://www.xsquawkbox.net/xpsdk/lib/std_examples/WidgetLibraryExample.zip]

We have packaged this separately in a static library so that it can be used now. %%%Eventually these will make their way into the XPWidgets DLL. %%%They way they are accessed should ensure that a rebuild is all that is required when they appear in the next XPWidgets release. %%%Other widgets will be added to the static lib as they come along.

We have included the library as a complete set of projects. %%%These are for VC6, CW8 and GCC and includes the source files. %%%The reason for including the source files is to allow developers to use other compilers. %%%These are also a good starting point for developers who want to create their own widgets.

This is an addition to the SDK Widgets so please respect the copyright and license that comes with this library.

"FMSUtility"

This example shows how to access the FMS from within a plugin. %%%It uses all the FMS Get and Set functions. %%%This is just a basic example but I am sure it could be expanded into a more complex example.

"ExampleGauges"

This example shows how to use OpenGL to display a floating panel that contains a gauge. %%%The gauge show N1 and can be moved around the cockpit.

This plugin has a directory that has to be copied as a child directory of plugins. %%%It contains the bitmaps used by this plugin.

You will find it in the "AdvancedSDKExamples.zip" file. %%%e.g. this is the zip contents.

AdvancedSDKExamples

  Delphi
  ExampleGauge (Copy this whole directory to plugins)
  Projects
  SampleCode

This plugin will work on all platforms and there is a project file for Delphi/Kylix. %%%It relies on cross platform bitmap loader code that I have supplied. %%%It originally used Glaux, but this was not available for all cases so I removed it.


"ShowEvents"

This shows all the drawing phases.

"TestEnums"

This shows how to send key and joystick command enums.

Older Advanced Examples

"ReloadPlugins"

Use this when developing and you don't want to keep stopping and starting XPlane. %%%In select reload plugins and then wait for the message box to appear, once the plugin has been copied press OK. %%%On the Mac copy the plugin and then select the reload plugin option. %%%This does not work on Linux yet. %%%On later versions of V8 this now works the same on all 3 platforms.

NOTE %%%THIS PLUGIN IS MEANT FOR DEBUGGING PURPOSES ONLY. %%%WE ADVISE YOU NOT TO USE THIS IN A RELEASE ENVIRONMENT AS IT CAN INTRODUCE SIDE EFFECTS.

"InputOutput"

Show reading datarefs and then writing a dateref depending on input criteria.

"PluginMessaging."

Shows inter plugin messaging, just copy over all the messaging plugins and you will be able to test messaging between 8 plugins.

"Override", "Control", "Position"

Shows how to override and then position the aircraft or move the control surfaces.