FlightGear version check
This article is a stub. You can help the wiki by expanding it. |
Note When installing/using aircraft the FlightGear version and the aircraft version must match. Otherwise strange bugs should be expected and the version-mismatch combination will not be supported by the FlightGear community. |
If in doubt, people should check the about dialog or /sim/version/
in the property tree using the property browser.
For aircraft developers
This article describes content/features that may not yet be available in the latest stable version of FlightGear (2020.3). You may need to install some extra components, use the latest development (Git) version or even rebuild FlightGear from source, possibly from a custom topic branch using special build settings: .This feature is scheduled for FlightGear (unknown). If you'd like to learn more about getting your own ideas into FlightGear, check out Implementing new features for FlightGear. |
<minimum-flightgear-version>4.0.0</minimum-flightgear-version>
Minimum FlightGear version required for this aircraft, note that this is a "soft" requirement — i.e., it will not necessarily terminate FlightGear or trigger an error, but will only show a warning in the console/log file using a Nasal script that checks if the property is set.
This is mainly intended to make compatibility issues more obvious, such as end-users downloading new aircraft and wanting to use them in conjunction with an old version of FlightGear, which is causing quite a bit of workload on the support forum. We are hoping to also display this info in the about dialog.
The Saab JA-37 Viggen is a good example of using Nasal and properties to provide backwards-compatibility. See ja37.nas for the relevant code.
Fgdata
Note This is currently just proof-of-concept code which will need to be refined/reviewed to be committed to FGData. |
translations
A critical error dialog should preferably support localized error messages. However, PUI XML dialogs cannot directly support translations, so we need to emulate that using Property overlays.
names/strings would need to be resolved by using translations as an overlay |
The easiest way to accomplish this is using the existing format tag to display properties that can be resolved from $FG_ROOT/Translations
$FG_ROOT/Translations/en/dialogs.xml
<?xml version="1.0"?>
<!-- FlightGear dialog texts: English (=default) language resource -->
<PropertyList>
<version-mismatch>
<error-version-conflict>Error: Version Conflict !</error-version-conflict>
<flightgear-version>FlightGear Version</flightgear-version>
<aircraft>Aircraft</aircraft>
<aircraft-version>Aircraft Version</aircraft-version>
<required-flightgear-version>Required FlightGear Version</required-flightgear-version>
<incompatibility-reason>Reason for incompatibility</incompatibility-reason>
<solution>Solution</solution>
</version-mismatch>
</PropertyList>
dialog
$FG_ROOT/gui/dialogs/version-mismatch.xml
<?xml version="1.0"?>
<PropertyList>
<name>version-mismatch</name>
<modal>false</modal>
<layout>vbox</layout>
<text>
<color>
<red>1.0</red>
<green>0.0</green>
<blue>0.0</blue>
</color>
<label>MMMMMMM</label>
<property>/sim/intl/locale/strings/dialogs/version-mismatch/error-version-conflict</property>
<format>%s:</format>
</text>
<canvas>
<name>logo</name>
<halign>right</halign>
<pref-width>100</pref-width>
<pref-height>100</pref-height>
<nasal><load><![CDATA[
var my_canvas = canvas.get( cmdarg() );
var root = my_canvas.createGroup();
var image = getprop("/sim/startup/splash-texture") or
getprop("/sim/splash-texture") or "Textures/Splash1.png";
#var image = "Aircraft/SpaceShuttle/SpaceShuttle-splash.png";
var logo = root.createChild("image")
.setFile( image )
.setSize(512,512);
]]></load></nasal>
</canvas>
<group>
<layout>vbox</layout>
<halign>fill</halign>
<default-padding>10</default-padding>
<empty><stretch>true</stretch></empty>
<group>
<layout>hbox</layout>
<halign>fill</halign>
<default-padding>5</default-padding>
<text>
<halign>left</halign>
<label>MMMMMMM</label>
<property>/sim/intl/locale/strings/dialogs/version-mismatch/aircraft</property>
<format>%s:</format>
</text>
<text>
<halign>left</halign>
<label>MMMMMMMMMMMM</label>
<property>/sim/aircraft</property>
<format>%s</format>
</text>
</group>
<group>
<layout>hbox</layout>
<halign>fill</halign>
<default-padding>5</default-padding>
<text>
<halign>left</halign>
<label>MMMMMMM</label>
<property>/sim/intl/locale/strings/dialogs/version-mismatch/aircraft-version</property>
<format>%s:</format>
</text>
<text>
<halign>left</halign>
<label>MMMMMMMMMMMM</label>
<property>/sim/aircraft-version</property>
<format>%s</format>
</text>
</group>
<group>
<layout>hbox</layout>
<halign>fill</halign>
<default-padding>5</default-padding>
<text>
<halign>left</halign>
<label>MMMMMMM</label>
<property>/sim/intl/locale/strings/dialogs/version-mismatch/required-flightgear-version</property>
<format>%s:</format>
</text>
<text>
<halign>left</halign>
<label>MMMMMMMMMMMM</label>
<property>/sim/aircraft-version</property>
<format>%s</format>
</text>
</group>
<group>
<layout>hbox</layout>
<halign>fill</halign>
<default-padding>5</default-padding>
<text>
<halign>left</halign>
<label>MMMMMMM</label>
<property>/sim/intl/locale/strings/dialogs/version-mismatch/incompatibility-reason</property>
<format>%s:</format>
</text>
<text>
<halign>left</halign>
<label>Outdated binary</label>
</text>
</group>
<group>
<layout>hbox</layout>
<halign>fill</halign>
<default-padding>5</default-padding>
<text>
<halign>left</halign>
<label>MMMMMMM</label>
<property>/sim/intl/locale/strings/dialogs/version-mismatch/solution</property>
<format>%s:</format>
</text>
<text>
<halign>left</halign>
<label>Upgrade FlightGear or downgrade aircraft</label>
</text>
</group>
<button>
<legend>Exit</legend>
<default>true</default>
<equal>true</equal>
<binding>
<command>exit</command>
</binding>
</button>
<empty><stretch>true</stretch></empty>
</group>
</PropertyList>
Nasal module
This script ensures that the check will be executed for each loaded aircraft, without having to touch any aircraft-set.xml files, and it will also work with reset & re-init.
# $FG_ROOT/Nasal/version_check.nas
# anonymous function that will be called directly
(func() {
# get current aircraft
var ac = getprop("/sim/aircraft");
var url = 'http://wiki.flightgear.org/FlightGear_Version_Check';
var fgversion = getprop("/sim/version/flightgear");
logprint(3, "FlightGear v" ~ fgversion);
var acversion = getprop("/sim/minimum-flightgear-version");
if (acversion == nil) {
logprint(4, ac ~ "-set.xml file missing version info, see " ~ url);
return; # version not specified
}
logprint(3, "Aircraft requires FlightGear v" ~ acversion);
# parse the version number into major/minor and patch level
# http://wiki.flightgear.org/Nasal_library#split.28.29
var (major, minor, patch) = split(".", acversion);
})();
Why is this necessary ?
(copy forum responses here)