1
0
Fork 0

sort the model list again after adding models from the file selector,

or the binsearch will have a hard time ...
This commit is contained in:
mfranz 2007-06-19 21:21:14 +00:00
parent 2487ef043d
commit 35bd6c379a

View file

@ -35,9 +35,9 @@ var printf = func(_...) { print(call(sprintf, _)) }
var init_prop = func(prop, value) { var init_prop = func(prop, value) {
if (prop.getValue() != nil) { if (prop.getValue() != nil)
value = prop.getValue(); value = prop.getValue();
}
prop.setDoubleValue(value); prop.setDoubleValue(value);
return value; return value;
} }
@ -52,15 +52,14 @@ var search = func(list, which) {
while (1) { while (1) {
middle = int((left + right) / 2); middle = int((left + right) / 2);
var c = cmp(list[middle], which); var c = cmp(list[middle], which);
if (!c) { if (!c)
return middle; return middle;
} elsif (left == middle) { elsif (left == middle)
return -1; return -1;
} elsif (c > 0) { elsif (c > 0)
right = middle; right = middle;
} else { else
left = middle; left = middle;
}
} }
} }
@ -71,9 +70,9 @@ var search = func(list, which) {
var scan_models = func(base) { var scan_models = func(base) {
var result = []; var result = [];
var list = directory(getprop("/sim/fg-root") ~ "/" ~ base); var list = directory(getprop("/sim/fg-root") ~ "/" ~ base);
if (list == nil) { if (list == nil)
return result; return result;
}
var xml = {}; var xml = {};
var ac = {}; var ac = {};
foreach (var d; list) { foreach (var d; list) {
@ -603,17 +602,15 @@ var print_data = func {
foreach (var m; data.getChildren("model")) { foreach (var m; data.getChildren("model")) {
var stg = m.getNode("stg-path").getValue(); var stg = m.getNode("stg-path").getValue();
var obj = m.getNode("object-line").getValue(); var obj = m.getNode("object-line").getValue();
if (contains(bucket, stg)) { if (contains(bucket, stg))
append(bucket[stg], obj); append(bucket[stg], obj);
} else { else
bucket[stg] = [obj]; bucket[stg] = [obj];
}
} }
foreach (var key; keys(bucket)) { foreach (var key; keys(bucket)) {
print("\n# ", key); print("\n# ", key);
foreach (var obj; bucket[key]) { foreach (var obj; bucket[key])
print(obj); print(obj);
}
} }
print(rule); print(rule);
} }
@ -648,6 +645,7 @@ var fsel_callback = func {
model = substr(model, size(root)); model = substr(model, size(root));
append(modellist, model); append(modellist, model);
modellist = sort(modellist, cmp);
modelmgr.set_modelpath(model); modelmgr.set_modelpath(model);
} }
@ -661,9 +659,8 @@ var adjust_dialog = gui.Dialog.new("/sim/gui/dialogs/ufo/adjust/dialog", "Aircra
adjust_dialog.center_sliders = func { adjust_dialog.center_sliders = func {
var ns = adjust_dialog.namespace(); var ns = adjust_dialog.namespace();
if (ns != nil) { if (ns != nil)
ns.center(); ns.center();
}
} }