2006-05-22 17:42:57 +00:00
|
|
|
<?xml version="1.0"?>
|
|
|
|
|
|
|
|
<PropertyList>
|
|
|
|
<name>property-browser</name>
|
|
|
|
<layout>vbox</layout>
|
|
|
|
<default-padding>3</default-padding>
|
|
|
|
|
|
|
|
<group>
|
|
|
|
<layout>hbox</layout>
|
2006-05-23 09:46:57 +00:00
|
|
|
<default-padding>1</default-padding>
|
|
|
|
|
|
|
|
<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>
|
|
|
|
|
|
|
|
<hrule><empty/></hrule>
|
|
|
|
|
|
|
|
<property-list>
|
|
|
|
<name>property-list</name>
|
|
|
|
<pref-width>450</pref-width>
|
2006-05-23 09:46:57 +00:00
|
|
|
<pref-height>290</pref-height>
|
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>
|
|
|
|
<script>selected()</script>
|
|
|
|
</binding>
|
|
|
|
</property-list>
|
|
|
|
|
|
|
|
<group>
|
|
|
|
<layout>hbox</layout>
|
|
|
|
<default-padding>2</default-padding>
|
|
|
|
|
|
|
|
<text>
|
|
|
|
<label>--</label>
|
|
|
|
<live>true</live>
|
|
|
|
<property>/sim/gui/dialogs/property-browser/label</property>
|
2006-05-23 09:46:57 +00:00
|
|
|
<pref-width>190</pref-width>
|
2006-05-22 17:42:57 +00:00
|
|
|
</text>
|
|
|
|
|
|
|
|
<input>
|
|
|
|
<name>input</name>
|
2006-05-23 09:46:57 +00:00
|
|
|
<pref-width>190</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>
|
|
|
|
var dlg = props.globals.getNode("/sim/gui/dialogs/property-browser", 1);
|
|
|
|
var title = dlg.getNode("title", 1);
|
|
|
|
var label = dlg.getNode("label", 1);
|
|
|
|
var input = dlg.getNode("input", 1);
|
|
|
|
var list = dlg.getNode("list", 1);
|
2006-05-24 09:36:20 +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-22 17:42:57 +00:00
|
|
|
|
|
|
|
update = func(w) {
|
|
|
|
fgcommand("dialog-update", props.Node.new({"object-name": w,
|
|
|
|
"dialog-name": "property-browser"}));
|
|
|
|
}
|
|
|
|
|
|
|
|
squeeze = func(s, n) {
|
|
|
|
if (size(s) <= n or n < 7) {
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
var l = substr(s, 0, (n - 3) / 2);
|
|
|
|
var r = substr(s, size(s) + size(l) + 3 - n);
|
|
|
|
return l ~ "..." ~ r;
|
|
|
|
}
|
|
|
|
|
|
|
|
selected = func {
|
|
|
|
var lst = list.getValue();
|
|
|
|
node = props.globals.getNode(lst);
|
|
|
|
if (node == nil) {
|
2006-05-23 09:46:57 +00:00
|
|
|
node = props.globals;
|
2006-05-22 17:42:57 +00:00
|
|
|
}
|
|
|
|
if (size(node.getChildren())) {
|
|
|
|
dir = node.getPath();
|
2006-05-24 09:36:20 +00:00
|
|
|
title.setValue(node.getPath() == "" ? "Internal Properties" : lst);
|
2006-05-22 17:42:57 +00:00
|
|
|
node = nil;
|
|
|
|
label.setValue(" --");
|
|
|
|
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();
|
2006-05-23 20:30:32 +00:00
|
|
|
if (index) {
|
|
|
|
name ~= "[" ~ index ~ "]";
|
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");
|
|
|
|
settimer(func {title.setValue(dir) }, 5);
|
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
|
|
|
|
2006-05-22 17:42:57 +00:00
|
|
|
set = func {
|
|
|
|
if (node != nil) {
|
|
|
|
node.setValue(input.getValue());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-05-23 20:30:32 +00:00
|
|
|
auto_update = func {
|
2006-05-24 09:36:20 +00:00
|
|
|
list.setValue(dir);
|
|
|
|
update("property-list");
|
|
|
|
if (update_interval) {
|
2006-05-23 20:30:32 +00:00
|
|
|
settimer(auto_update, update_interval);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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-23 09:46:57 +00:00
|
|
|
selected();
|
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;
|
2006-05-22 17:42:57 +00:00
|
|
|
dlg.getNode("last", 1).setValue(dir);
|
|
|
|
</close>
|
|
|
|
</nasal>
|
|
|
|
</PropertyList>
|