1
0
Fork 0
fgdata/Nasal/canvas/PropertyElement.nas

80 lines
1.8 KiB
Text
Raw Normal View History

2012-08-01 23:14:18 +00:00
# PropertyElement
# ==============================================================================
# Baseclass for all property controlled elements/objects
#
var PropertyElement = {
# Constructor
#
# @param node Node to be used for element or vector [parent, type] for
# creation of a new node with name type and given parent
# @param id ID/Name (Should be unique)
new: func(node, id)
{
2020-05-05 18:13:06 +00:00
if (isvec(node)) {
var node = aircraft.makeNode(node[0]).addChild(node[1], 0, 0);
2020-05-05 18:13:06 +00:00
}
else {
2012-08-01 23:14:18 +00:00
var node = aircraft.makeNode(node);
2020-05-05 18:13:06 +00:00
}
2012-08-01 23:14:18 +00:00
if( !isa(node, props.Node) )
return debug.warn("Not a props.Node!");
var m = {
parents: [PropertyElement],
_node: node
};
if( id != nil )
m.set("id", id);
return m;
},
# Destructor (has to be called manually!)
del: func()
{
me._node.remove();
},
set: func(key, value)
{
me._node.getNode(key, 1).setValue(value);
return me;
},
setBool: func(key, value)
{
me._node.getNode(key, 1).setBoolValue(value);
return me;
},
setDouble: func(key, value)
{
me._node.getNode(key, 1).setDoubleValue(value);
return me;
},
setInt: func(key, value)
{
me._node.getNode(key, 1).setIntValue(value);
return me;
},
get: func(key, default = nil)
{
var node = me._node.getNode(key);
if( node != nil )
return node.getValue();
else
return default;
Canvas Scripting Layer (Mapping): - first stab at refactoring the map.nas module, and trying to let the API evolve according to our requirements - split up the module into separate files (some of them will disappear soon) - split up the "drawing" loops into separate functions so that they can be individually called - move actual "drawing" to map_layers.nas - introduce some OOP helpers to prepare a pure Layer-based design - prepare helpers: LayeredMap, GenericMap, AirportMap (TODO: use a real "Layer" class) - move airport features (taxiways, runways, parking, tower) to separate layers (i.e. canvas groups) - avoid using a single update callback and use different layer-specific callbacks to update individual layers more efficiently - add some boilerplate hashes to prepare the MVC design - allow lazy updating of layers, where canvas groups are only populated on demand, to save some time during instantiation, i.e. loading an airport without "parking" selected, will only populate the layer once the checkbox is checked - extend the original code such that it supports showing multiple airports at once - add some proof of concept "navaid" layer using SVG files for navaid symbols (added only NDB symbol from wikimedia commons) regressions: - runway highlighting needs to be re-implemented - parking highlighting will be done differently - enforcing a specific drawing order for layers is currently not explicitly supported, so that taxiways may be rendered on top of runways Also: - integrated with the latest changes in git/master (HEAD) -i.e. metar support - further generalized map.nas - partially moved instantiation from Nasal space to XML space (WIP) - create "toggle layer" checkboxes procedurally in Nasal space - prepared the code to be better reusable in other dialogs (e.g. route manager, map dialog etc) - completely removed the "highlighting" (runway/parking) feature for now, because we talked about re-implementing it anyhow
2012-09-20 23:49:17 +00:00
},
getBool: func(key)
{
me._node.getNode(key, 1).getBoolValue();
},
# Trigger an update of the element
#
# Elements are automatically updated once a frame, with a delay of one frame.
# If you wan't to get an element updated in the current frame you have to use
# this method.
update: func
{
me.setBool("update", 1);
}
2012-08-01 23:14:18 +00:00
};