FlightGear version check: Difference between revisions
(→dialog) |
Red Leader (talk | contribs) m (titles, etc.) |
||
Line 1: | Line 1: | ||
{{Stub}} | {{Stub}} | ||
{{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.}} | {{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.}} | ||
Line 21: | Line 20: | ||
The [[Saab JA-37 Viggen]] is a good example of using Nasal and properties to provide backwards-compatibility. See [{{github url|NikolaiVChr/flightgear-saab-ja-37-viggen|Aircraft/JA37/Nasal/ja37.nas|l=1105/1203}} ja37.nas] for the relevant code. | The [[Saab JA-37 Viggen]] is a good example of using Nasal and properties to provide backwards-compatibility. See [{{github url|NikolaiVChr/flightgear-saab-ja-37-viggen|Aircraft/JA37/Nasal/ja37.nas|l=1105/1203}} 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.}} | {{Note|This is currently just proof-of-concept code which will need to be refined/reviewed to be committed to FGData.}} | ||
[[File:Property-browser-showing-version-info.png|thumb|Property browser showing the <code>/sim/version</code> properties.]] | [[File:Property-browser-showing-version-info.png|thumb|Property browser showing the <code>/sim/version</code> properties.]] | ||
=== | === 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 | 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. | ||
{{FGCquote | {{FGCquote | ||
|1= names/strings would need to be resolved by using translations as an overlay | |1= names/strings would need to be resolved by using translations as an overlay | ||
Line 62: | Line 62: | ||
<PropertyList> | <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> | </PropertyList> | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== | === Dialog === | ||
$FG_ROOT/gui/dialogs/version-mismatch.xml | $FG_ROOT/gui/dialogs/version-mismatch.xml | ||
<syntaxhighlight lang="xml"> | <syntaxhighlight lang="xml"> | ||
Line 226: | Line 225: | ||
=== Nasal module === | === 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]]. | 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]]. | ||
<syntaxhighlight lang="nasal"> | <syntaxhighlight lang="nasal"> | ||
# $FG_ROOT/Nasal/version_check.nas | # $FG_ROOT/Nasal/version_check.nas | ||
Line 253: | Line 253: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
== Why is this necessary ? == | == Why is this necessary? == | ||
(copy forum responses here) | <!-- (copy forum responses here) --> | ||
== Related content == | == Related content == | ||
=== Forum topics === | === Forum topics === | ||
* [http://forum.flightgear.org/viewtopic.php?f=6&t=28020 version checking for matching fgfs and -set.xml files] | * [http://forum.flightgear.org/viewtopic.php?f=6&t=28020 version checking for matching fgfs and -set.xml files] |
Revision as of 09:00, 18 November 2015
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 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
if (getprop("/sim/version/do-compatibility-check",1))
(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);
})();