From e880d5ecee76ac012c7674a5bdf853b22a085a36 Mon Sep 17 00:00:00 2001 From: mfranz Date: Mon, 18 Jun 2007 16:35:03 +0000 Subject: [PATCH] - 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 --- Aircraft/ufo/ufo-set.xml | 13 +++++++++++++ Aircraft/ufo/ufo.nas | 36 ++++++++++++++++++++++++++++-------- 2 files changed, 41 insertions(+), 8 deletions(-) diff --git a/Aircraft/ufo/ufo-set.xml b/Aircraft/ufo/ufo-set.xml index 5f9953190..e10974de5 100644 --- a/Aircraft/ufo/ufo-set.xml +++ b/Aircraft/ufo/ufo-set.xml @@ -74,6 +74,10 @@ e export object data + + l + load model file via file selector + m toggle marker for active (= last selected) object @@ -150,6 +154,15 @@ + + l + Open file selector + + nasal + + + + m Toggle "active object" marker diff --git a/Aircraft/ufo/ufo.nas b/Aircraft/ufo/ufo.nas index 750b58ae0..82cdf3c05 100644 --- a/Aircraft/ufo/ufo.nas +++ b/Aircraft/ufo/ufo.nas @@ -620,19 +620,39 @@ var print_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"; - 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); - 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 ----------------------------------------------------------------------------------------- var status_dialog = gui.Dialog.new("/sim/gui/dialogs/ufo/status/dialog", "Aircraft/ufo/Dialogs/status.xml");