- don't use random numbers for cloned dialogs, but good old boring
sequential numbers (looks nicer, and is slightly less risky) - use var keyword on functions
This commit is contained in:
parent
2ae2d60de2
commit
cb405c955f
1 changed files with 20 additions and 15 deletions
|
@ -115,12 +115,12 @@
|
||||||
var root_title = "Internal Properties";
|
var root_title = "Internal Properties";
|
||||||
var no_selection = "[none]";
|
var no_selection = "[none]";
|
||||||
|
|
||||||
update = func(w) {
|
var update = func(w) {
|
||||||
self.setValues({"dialog-name": dlgname, "object-name": w});
|
self.setValues({"dialog-name": dlgname, "object-name": w});
|
||||||
fgcommand("dialog-update", self);
|
fgcommand("dialog-update", self);
|
||||||
}
|
}
|
||||||
|
|
||||||
squeeze = func(s, n) {
|
var squeeze = func(s, n) {
|
||||||
if (n >= size(s) or 7 > n ) {
|
if (n >= size(s) or 7 > n ) {
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
@ -129,7 +129,7 @@
|
||||||
return l ~ "..." ~ r;
|
return l ~ "..." ~ r;
|
||||||
}
|
}
|
||||||
|
|
||||||
select = func {
|
var select = func {
|
||||||
var lst = list.getValue();
|
var lst = list.getValue();
|
||||||
node = props.globals.getNode(lst);
|
node = props.globals.getNode(lst);
|
||||||
if (node == nil) {
|
if (node == nil) {
|
||||||
|
@ -166,29 +166,34 @@
|
||||||
update("input");
|
update("input");
|
||||||
}
|
}
|
||||||
|
|
||||||
set = func {
|
var set = func {
|
||||||
if (node != nil) {
|
if (node != nil) {
|
||||||
node.setValue(input.getValue());
|
node.setValue(input.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
clone = func(startdir) {
|
var clone = func(startdir) {
|
||||||
var name = "property-browser--" ~ int(rand() * 10000000);
|
var base = props.globals.getNode("/sim/gui/dialogs", 1);
|
||||||
var base = "/sim/gui/dialogs/" ~ name ~ "/";
|
var name = "property-browser-";
|
||||||
|
var i = nil;
|
||||||
|
for (i = 1; 1; i += 1)
|
||||||
|
if (base.getNode(name ~ i, 0) == nil)
|
||||||
|
break;
|
||||||
|
base = base.getNode(name ~ i, 1).getPath();
|
||||||
setprop(base ~ "/last", startdir);
|
setprop(base ~ "/last", startdir);
|
||||||
self.setValues({
|
self.setValues({
|
||||||
"name": name,
|
"name": name ~ i,
|
||||||
"dialog-name": name,
|
"dialog-name": name ~ i,
|
||||||
"group[0]/text/property": base ~ "title",
|
"group[0]/text/property": base ~ "/title",
|
||||||
"property-list/property": base ~ "list",
|
"property-list/property": base ~ "/list",
|
||||||
"group[1]/text/property": base ~ "label",
|
"group[1]/text/property": base ~ "/label",
|
||||||
"group[1]/input/property": base ~ "input",
|
"group[1]/input/property": base ~ "/input",
|
||||||
});
|
});
|
||||||
fgcommand("dialog-new", self);
|
fgcommand("dialog-new", self);
|
||||||
fgcommand("dialog-show", self);
|
fgcommand("dialog-show", self);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto_update = func {
|
var auto_update = func {
|
||||||
list.setValue(dir);
|
list.setValue(dir);
|
||||||
update("property-list");
|
update("property-list");
|
||||||
if (update_interval) {
|
if (update_interval) {
|
||||||
|
@ -204,7 +209,7 @@
|
||||||
|
|
||||||
<close>
|
<close>
|
||||||
update_interval = 0;
|
update_interval = 0;
|
||||||
if (find("--", dlgname) >= 0) {
|
if (find("property-browser-", dlgname) >= 0) {
|
||||||
dlg.getParent().removeChildren(dlgname);
|
dlg.getParent().removeChildren(dlgname);
|
||||||
} else {
|
} else {
|
||||||
dlg.getNode("last", 1).setValue(dir);
|
dlg.getNode("last", 1).setValue(dir);
|
||||||
|
|
Loading…
Add table
Reference in a new issue