1
0
Fork 0

- l-key opens file selector to load 3D model file from the disk. This model

is added to the list and activated.
- simplify savexml handling using the "data" node for temporary data
This commit is contained in:
mfranz 2007-06-18 16:35:03 +00:00
parent a28b48b294
commit e880d5ecee
2 changed files with 41 additions and 8 deletions

View file

@ -74,6 +74,10 @@
<name>e</name> <name>e</name>
<desc>export object data</desc> <desc>export object data</desc>
</key> </key>
<key>
<name>l</name>
<desc>load model file via file selector</desc>
</key>
<key> <key>
<name>m</name> <name>m</name>
<desc>toggle marker for active (= last selected) object</desc> <desc>toggle marker for active (= last selected) object</desc>
@ -150,6 +154,15 @@
</binding> </binding>
</key> </key>
<key n="108">
<name>l</name>
<desc>Open file selector</desc>
<binding>
<command>nasal</command>
<script>ufo.file_select_model()</script>
</binding>
</key>
<key n="109"> <key n="109">
<name>m</name> <name>m</name>
<desc>Toggle "active object" marker</desc> <desc>Toggle "active object" marker</desc>

View file

@ -620,19 +620,39 @@ var print_data = func {
var export_data = func { var export_data = func {
savexml = func(name, node) {
fgcommand("savexml", props.Node.new({ "filename": name, "sourcenode": node }));
}
var tmp = "save-ufo-data";
save = props.globals.getNode(tmp, 1);
props.copy(modelmgr.get_data(), save.getNode("models", 1));
var path = getprop("/sim/fg-home") ~ "/ufo-model-export.xml"; var path = getprop("/sim/fg-home") ~ "/ufo-model-export.xml";
savexml(path, save.getPath()); var args = props.Node.new({ filename : path });
props.copy(modelmgr.get_data(), args.getNode("data", 1));
fgcommand("savexml", args);
print("model data exported to ", path); print("model data exported to ", path);
props.globals.removeChild(tmp);
} }
var file_selector = nil;
# called via l-key (load object from disk)
var file_select_model = func {
if (file_selector == nil) {
file_selector = gui.FileSelector.new(fsel_callback,
"Select *.ac or *.xml model file",
"Load Model", getprop("/sim/fg-root"));
}
file_selector.open();
}
var fsel_callback = func {
var model = cmdarg().getValue();
var root = io.fixpath(getprop("/sim/fg-root")) ~ "/";
if (substr(model, 0, size(root)) == root)
model = substr(model, size(root));
append(modellist, model);
modelmgr.set_modelpath(model);
}
# dialogs ----------------------------------------------------------------------------------------- # dialogs -----------------------------------------------------------------------------------------
var status_dialog = gui.Dialog.new("/sim/gui/dialogs/ufo/status/dialog", "Aircraft/ufo/Dialogs/status.xml"); var status_dialog = gui.Dialog.new("/sim/gui/dialogs/ufo/status/dialog", "Aircraft/ufo/Dialogs/status.xml");