2006-05-22 17:42:57 +00:00
|
|
|
<?xml version="1.0"?>
|
|
|
|
|
|
|
|
<PropertyList>
|
|
|
|
<name>property-browser</name>
|
|
|
|
<layout>vbox</layout>
|
2009-01-10 21:59:27 +00:00
|
|
|
<resizable>true</resizable>
|
2006-05-22 17:42:57 +00:00
|
|
|
<default-padding>3</default-padding>
|
|
|
|
|
|
|
|
<group>
|
|
|
|
<layout>hbox</layout>
|
2006-05-23 09:46:57 +00:00
|
|
|
<default-padding>1</default-padding>
|
|
|
|
|
2006-05-26 08:30:41 +00:00
|
|
|
<button>
|
|
|
|
<legend></legend>
|
|
|
|
<pref-width>16</pref-width>
|
|
|
|
<pref-height>16</pref-height>
|
|
|
|
<border>2</border>
|
2008-05-14 10:19:17 +00:00
|
|
|
<!-- looks better in anthrax style -->
|
2007-03-26 15:25:27 +00:00
|
|
|
<color>
|
|
|
|
<red>0.34</red>
|
|
|
|
<green>0.33</green>
|
|
|
|
<blue>0.35</blue>
|
|
|
|
</color>
|
2008-05-14 10:19:17 +00:00
|
|
|
<!-- -->
|
2006-05-26 08:30:41 +00:00
|
|
|
<binding>
|
|
|
|
<command>nasal</command>
|
2007-03-26 15:25:27 +00:00
|
|
|
<script>clone(dir)</script>
|
2006-05-26 08:30:41 +00:00
|
|
|
</binding>
|
|
|
|
</button>
|
|
|
|
|
2006-05-23 09:46:57 +00:00
|
|
|
<empty><whatever/></empty>
|
|
|
|
|
2006-05-22 17:42:57 +00:00
|
|
|
<text>
|
|
|
|
<label>/</label>
|
|
|
|
<property>/sim/gui/dialogs/property-browser/title</property>
|
|
|
|
<live>true</live>
|
|
|
|
</text>
|
|
|
|
|
|
|
|
<empty><stretch>true</stretch></empty>
|
2006-05-23 09:46:57 +00:00
|
|
|
|
|
|
|
<button>
|
|
|
|
<legend></legend>
|
|
|
|
<key>Esc</key>
|
|
|
|
<pref-width>16</pref-width>
|
|
|
|
<pref-height>16</pref-height>
|
|
|
|
<border>2</border>
|
|
|
|
<binding>
|
|
|
|
<command>dialog-close</command>
|
|
|
|
</binding>
|
|
|
|
</button>
|
2006-05-22 17:42:57 +00:00
|
|
|
</group>
|
|
|
|
|
2007-03-26 15:25:27 +00:00
|
|
|
<hrule/>
|
2006-05-22 17:42:57 +00:00
|
|
|
|
|
|
|
<property-list>
|
|
|
|
<name>property-list</name>
|
2018-09-02 11:57:29 +00:00
|
|
|
<pref-height>500</pref-height>
|
2009-01-10 21:59:27 +00:00
|
|
|
<halign>fill</halign>
|
|
|
|
<valign>fill</valign>
|
|
|
|
<stretch>true</stretch>
|
2006-05-22 17:42:57 +00:00
|
|
|
<property>/sim/gui/dialogs/property-browser/list</property>
|
|
|
|
<binding>
|
|
|
|
<command>dialog-apply</command>
|
|
|
|
<object-name>property-list</object-name>
|
|
|
|
</binding>
|
|
|
|
<binding>
|
|
|
|
<command>nasal</command>
|
2006-05-25 18:12:52 +00:00
|
|
|
<script>select()</script>
|
2006-05-22 17:42:57 +00:00
|
|
|
</binding>
|
|
|
|
</property-list>
|
|
|
|
|
|
|
|
<group>
|
|
|
|
<layout>hbox</layout>
|
|
|
|
<default-padding>2</default-padding>
|
|
|
|
|
2006-05-25 18:12:52 +00:00
|
|
|
<empty><whatever/></empty>
|
|
|
|
|
2006-05-22 17:42:57 +00:00
|
|
|
<text>
|
|
|
|
<label>--</label>
|
|
|
|
<live>true</live>
|
2009-01-10 21:59:27 +00:00
|
|
|
<halign>fill</halign>
|
|
|
|
<stretch>true</stretch>
|
2006-05-22 17:42:57 +00:00
|
|
|
<property>/sim/gui/dialogs/property-browser/label</property>
|
2009-01-10 21:59:27 +00:00
|
|
|
<pref-width>170</pref-width>
|
2006-05-22 17:42:57 +00:00
|
|
|
</text>
|
|
|
|
|
|
|
|
<input>
|
|
|
|
<name>input</name>
|
2009-01-10 21:59:27 +00:00
|
|
|
<halign>fill</halign>
|
|
|
|
<stretch>true</stretch>
|
|
|
|
<pref-width>170</pref-width>
|
2006-05-22 17:42:57 +00:00
|
|
|
<property>/sim/gui/dialogs/property-browser/input</property>
|
|
|
|
</input>
|
|
|
|
|
|
|
|
<button>
|
|
|
|
<legend>Set</legend>
|
2006-05-23 09:46:57 +00:00
|
|
|
<pref-width>50</pref-width>
|
2006-05-22 17:42:57 +00:00
|
|
|
<default>true</default>
|
|
|
|
<binding>
|
|
|
|
<command>dialog-apply</command>
|
|
|
|
<object-name>input</object-name>
|
|
|
|
</binding>
|
|
|
|
<binding>
|
|
|
|
<command>nasal</command>
|
|
|
|
<script>set()</script>
|
|
|
|
</binding>
|
|
|
|
</button>
|
|
|
|
</group>
|
|
|
|
|
|
|
|
<nasal>
|
|
|
|
<open>
|
2006-05-26 08:30:41 +00:00
|
|
|
var self = cmdarg();
|
|
|
|
var dlgname = self.getNode("name").getValue();
|
|
|
|
var dlg = props.globals.getNode("/sim/gui/dialogs/" ~ dlgname, 1);
|
2006-05-22 17:42:57 +00:00
|
|
|
var title = dlg.getNode("title", 1);
|
|
|
|
var label = dlg.getNode("label", 1);
|
|
|
|
var input = dlg.getNode("input", 1);
|
|
|
|
var list = dlg.getNode("list", 1);
|
2008-05-14 10:19:17 +00:00
|
|
|
var node = nil; # selected node entry (props.Node)
|
|
|
|
var dir = nil; # current directory (string)
|
2006-05-23 20:30:32 +00:00
|
|
|
var update_interval = 2;
|
2006-05-25 18:12:52 +00:00
|
|
|
var root_title = "Internal Properties";
|
|
|
|
var no_selection = "[none]";
|
2006-05-22 17:42:57 +00:00
|
|
|
|
2007-06-17 13:44:54 +00:00
|
|
|
var update = func(w) {
|
2008-12-21 08:52:49 +00:00
|
|
|
self.setValues({ "dialog-name": dlgname, "object-name": w });
|
2006-05-26 08:50:14 +00:00
|
|
|
fgcommand("dialog-update", self);
|
2006-05-22 17:42:57 +00:00
|
|
|
}
|
|
|
|
|
2007-06-17 13:44:54 +00:00
|
|
|
var squeeze = func(s, n) {
|
2008-05-14 10:19:17 +00:00
|
|
|
if (n >= size(s) or 7 > n )
|
2006-05-22 17:42:57 +00:00
|
|
|
return s;
|
2008-05-14 10:19:17 +00:00
|
|
|
|
2006-05-22 17:42:57 +00:00
|
|
|
var l = substr(s, 0, (n - 3) / 2);
|
|
|
|
var r = substr(s, size(s) + size(l) + 3 - n);
|
|
|
|
return l ~ "..." ~ r;
|
|
|
|
}
|
|
|
|
|
2007-06-17 13:44:54 +00:00
|
|
|
var select = func {
|
2006-05-22 17:42:57 +00:00
|
|
|
var lst = list.getValue();
|
|
|
|
node = props.globals.getNode(lst);
|
2008-05-14 10:19:17 +00:00
|
|
|
if (node == nil)
|
2006-05-23 09:46:57 +00:00
|
|
|
node = props.globals;
|
2008-05-14 10:19:17 +00:00
|
|
|
|
|
|
|
setprop("/sim/gui/dialogs/property-browser/selected", node.getPath());
|
2008-12-21 08:52:49 +00:00
|
|
|
if (node.getAttribute("children")) {
|
2006-05-22 17:42:57 +00:00
|
|
|
dir = node.getPath();
|
2006-05-25 18:12:52 +00:00
|
|
|
title.setValue(node.getPath() == "" ? root_title : lst);
|
2006-05-22 17:42:57 +00:00
|
|
|
node = nil;
|
2006-05-25 18:12:52 +00:00
|
|
|
label.setValue(no_selection);
|
2006-05-22 17:42:57 +00:00
|
|
|
input.setValue("");
|
|
|
|
} else {
|
|
|
|
var name = node.getName();
|
2006-05-23 20:30:32 +00:00
|
|
|
var index = node.getIndex();
|
2006-05-22 17:42:57 +00:00
|
|
|
var type = node.getType();
|
2008-05-14 10:19:17 +00:00
|
|
|
if (index)
|
2006-05-23 20:30:32 +00:00
|
|
|
name ~= "[" ~ index ~ "]";
|
2008-05-14 10:19:17 +00:00
|
|
|
|
2006-05-22 17:42:57 +00:00
|
|
|
var value = nil;
|
|
|
|
if (type == "BOOL") {
|
|
|
|
value = node.getBoolValue() ? "true" : "false";
|
2006-05-23 09:46:57 +00:00
|
|
|
title.setValue("Hint: Ctrl-click toggles bool values");
|
2008-12-21 08:52:49 +00:00
|
|
|
settimer(func title.setValue(dir), 5, 1);
|
2006-05-22 17:42:57 +00:00
|
|
|
} elsif (type == "STRING") {
|
|
|
|
value = node.getValue();
|
|
|
|
} elsif (type == "NONE") {
|
|
|
|
value = "";
|
|
|
|
} elsif (type != "ALIAS") {
|
|
|
|
value = node.getValue() ~ "";
|
|
|
|
}
|
2006-05-24 09:36:20 +00:00
|
|
|
label.setValue(squeeze(name, 30));
|
2006-05-22 17:42:57 +00:00
|
|
|
input.setValue(value);
|
|
|
|
}
|
2006-05-24 09:36:20 +00:00
|
|
|
update("input");
|
2006-05-22 17:42:57 +00:00
|
|
|
}
|
2006-05-24 09:36:20 +00:00
|
|
|
|
2007-06-17 13:44:54 +00:00
|
|
|
var set = func {
|
2008-05-14 10:19:17 +00:00
|
|
|
if (node != nil)
|
2006-05-22 17:42:57 +00:00
|
|
|
node.setValue(input.getValue());
|
|
|
|
}
|
|
|
|
|
2007-06-17 13:44:54 +00:00
|
|
|
var clone = func(startdir) {
|
|
|
|
var base = props.globals.getNode("/sim/gui/dialogs", 1);
|
|
|
|
var name = "property-browser-";
|
2008-12-21 15:54:18 +00:00
|
|
|
for (var i = 1; 1; i += 1)
|
2007-06-17 13:44:54 +00:00
|
|
|
if (base.getNode(name ~ i, 0) == nil)
|
|
|
|
break;
|
|
|
|
base = base.getNode(name ~ i, 1).getPath();
|
2007-03-26 15:25:27 +00:00
|
|
|
setprop(base ~ "/last", startdir);
|
2006-05-26 08:30:41 +00:00
|
|
|
self.setValues({
|
2008-12-21 08:52:49 +00:00
|
|
|
"name": name ~ i,
|
|
|
|
"dialog-name": name ~ i,
|
|
|
|
"group[0]/text/property": base ~ "/title",
|
|
|
|
"property-list/property": base ~ "/list",
|
|
|
|
"group[1]/text/property": base ~ "/label",
|
|
|
|
"group[1]/input/property": base ~ "/input",
|
2006-05-26 08:30:41 +00:00
|
|
|
});
|
|
|
|
fgcommand("dialog-new", self);
|
|
|
|
fgcommand("dialog-show", self);
|
2018-10-25 15:23:19 +00:00
|
|
|
|
|
|
|
var originalPath = '/sim/gui/dialogs/property-browser';
|
|
|
|
# reset the values, so we don't use incorrect paths
|
|
|
|
# when the last browser is closed and then re-opened
|
|
|
|
# bug: https://sourceforge.net/p/flightgear/codetickets/2044/
|
|
|
|
self.setValues({
|
|
|
|
"name": "property-browser",
|
|
|
|
"dialog-name": "property-browser",
|
|
|
|
"group[0]/text/property": originalPath ~ "/title",
|
|
|
|
"property-list/property": originalPath ~ "/list",
|
|
|
|
"group[1]/text/property": originalPath ~ "/label",
|
|
|
|
"group[1]/input/property": originalPath ~ "/input",
|
|
|
|
});
|
2006-05-26 08:30:41 +00:00
|
|
|
}
|
|
|
|
|
2007-06-17 13:44:54 +00:00
|
|
|
var auto_update = func {
|
2006-05-24 09:36:20 +00:00
|
|
|
list.setValue(dir);
|
|
|
|
update("property-list");
|
2008-05-14 10:19:17 +00:00
|
|
|
if (update_interval)
|
2007-05-07 16:24:16 +00:00
|
|
|
settimer(auto_update, update_interval, 1);
|
2006-05-23 20:30:32 +00:00
|
|
|
}
|
|
|
|
|
2006-05-24 09:36:20 +00:00
|
|
|
dir = dlg.getNode("last") != nil ? dlg.getNode("last").getValue() : "/";
|
2006-05-23 20:30:32 +00:00
|
|
|
list.setValue(dir);
|
2006-05-25 18:12:52 +00:00
|
|
|
select();
|
2006-05-23 20:30:32 +00:00
|
|
|
auto_update();
|
2006-05-22 17:42:57 +00:00
|
|
|
</open>
|
|
|
|
|
|
|
|
<close>
|
2006-05-24 09:36:20 +00:00
|
|
|
update_interval = 0;
|
2008-05-14 10:19:17 +00:00
|
|
|
if (find("property-browser-", dlgname) >= 0)
|
2006-05-26 10:42:45 +00:00
|
|
|
dlg.getParent().removeChildren(dlgname);
|
2008-05-14 10:19:17 +00:00
|
|
|
else
|
2006-05-26 08:30:41 +00:00
|
|
|
dlg.getNode("last", 1).setValue(dir);
|
2006-05-22 17:42:57 +00:00
|
|
|
</close>
|
|
|
|
</nasal>
|
|
|
|
</PropertyList>
|