Merge branch 'master' of gitorious.org:fg/fgdata into work
This commit is contained in:
commit
61fac9c400
5 changed files with 65 additions and 5 deletions
|
@ -43,7 +43,7 @@
|
|||
|
||||
|
||||
|
||||
<technique n="2">
|
||||
<technique n="2">
|
||||
<predicate>
|
||||
<and>
|
||||
<property>/sim/rendering/shaders/skydome</property>
|
||||
|
@ -328,9 +328,10 @@
|
|||
</technique>
|
||||
|
||||
|
||||
<technique n="3">
|
||||
<technique n="3">
|
||||
<predicate>
|
||||
<and>
|
||||
<property>/sim/rendering/shaders/skydome</property>
|
||||
<property>/sim/rendering/shaders/urban</property>
|
||||
<less-equal>
|
||||
<value type="float">1.0</value>
|
||||
|
|
|
@ -818,6 +818,7 @@ var get = func(name)
|
|||
# support (Wrapped in anonymous function do not polute the canvas namespace)
|
||||
|
||||
(func {
|
||||
var legacy_dir = getprop("/sim/fg-root") ~ "/Nasal/canvas";
|
||||
var version_str = getprop("/sim/version/flightgear");
|
||||
if( string.scanf(version_str, "%u.%u.%u", var fg_version = []) < 1 )
|
||||
debug.warn("Canvas: Error parsing flightgear version (" ~ version_str ~ ")");
|
||||
|
@ -834,6 +835,10 @@ else
|
|||
{button: {legend: "Ok", binding: {command: "dialog-close"}}}
|
||||
);
|
||||
}
|
||||
|
||||
# Load support for older versions of FlightGear (TODO generalize :) )
|
||||
if( fg_version[0] == 2 and fg_version[1] == 8 )
|
||||
io.load_nasal(legacy_dir ~ "/api.nas.2.8", "canvas");
|
||||
}
|
||||
|
||||
Canvas.property_root = props.globals.getNode("canvas/by-index", 1);
|
||||
|
|
54
Nasal/canvas/api.nas.2.8
Normal file
54
Nasal/canvas/api.nas.2.8
Normal file
|
@ -0,0 +1,54 @@
|
|||
# Canvas backward support for using 3.0 API with FlightGear 2.8
|
||||
|
||||
(func {
|
||||
|
||||
# 2.8 uses multiple properties for representing a color. Also different names
|
||||
# are used for the colors and no CSS syntax like #rrggbb are supported.
|
||||
var color_components = ["red", "green", "blue", "alpha"];
|
||||
var setColorNodes = func(obj, name, color)
|
||||
{
|
||||
if( size(color) == 1 )
|
||||
color = color[0];
|
||||
|
||||
if( typeof(color) != "vector" )
|
||||
debug.warn("Wrong type for color");
|
||||
else if( size(color) < 3 or size(color) > 4 )
|
||||
debug.warn("Color needs 3 or 4 values (RGB or RGBA)");
|
||||
else
|
||||
{
|
||||
var node = obj._node.getNode(name, 1);
|
||||
for(var i = 0; i < size(color_components); i += 1)
|
||||
node.getNode(color_components[i], 1)
|
||||
.setDoubleValue( i < size(color) ? color[i]
|
||||
: 1 ); # default alpha is 1
|
||||
}
|
||||
|
||||
return obj;
|
||||
};
|
||||
|
||||
Element.setColor = func setColorNodes(me, "color", arg);
|
||||
Element.setColorFill = func {
|
||||
setColorNodes(me, "color-fill", arg);
|
||||
me.setBool("fill", 1);
|
||||
};
|
||||
Path.setColor = Element.setColor;
|
||||
Path.setColorFill = Element.setColorFill;
|
||||
Text.setColor = Element.setColor;
|
||||
Text.setColorFill = Element.setColorFill;
|
||||
|
||||
# 2.8 uses multiple properties instead of a single string property
|
||||
Canvas.setStrokeDashArray = func(pattern)
|
||||
{
|
||||
me._node.removeChildren('stroke-dasharray');
|
||||
|
||||
if( typeof(pattern) == 'vector' )
|
||||
me._node.setValues({'stroke-dasharray': pattern});
|
||||
else
|
||||
debug.warn("setStrokeDashArray: vector expected!");
|
||||
|
||||
return me;
|
||||
};
|
||||
|
||||
print("Canvas API: FlightGear 2.8 backward support loaded.");
|
||||
|
||||
})();
|
|
@ -56,7 +56,7 @@ var assignButton = func(cmd) {
|
|||
|
||||
<text>
|
||||
<halign>left</halign>
|
||||
<label>Select the command you wish to assign to this button</label>
|
||||
<label>Select the command you wish to assign to this button.</label>
|
||||
</text>
|
||||
|
||||
<hrule/>
|
||||
|
|
|
@ -737,10 +737,10 @@
|
|||
</item>
|
||||
|
||||
<item>
|
||||
<name>joystick-info</name>
|
||||
<name>joystick-config</name>
|
||||
<binding>
|
||||
<command>dialog-show</command>
|
||||
<dialog-name>joystick-info</dialog-name>
|
||||
<dialog-name>joystick-config</dialog-name>
|
||||
</binding>
|
||||
</item>
|
||||
|
||||
|
|
Loading…
Reference in a new issue