2014-06-10 16:47:13 +00:00
|
|
|
var AircraftCenter = {
|
|
|
|
show: func
|
|
|
|
{
|
|
|
|
var dlg = canvas.Window.new([550,500], "dialog")
|
|
|
|
.set("title", "Aircraft Center")
|
|
|
|
.set("resize", 1);
|
|
|
|
dlg.getCanvas(1)
|
|
|
|
.set("background", canvas.style.getColor("bg_color"));
|
|
|
|
var root = dlg.getCanvas().createGroup();
|
|
|
|
|
|
|
|
var vbox = VBoxLayout.new();
|
|
|
|
dlg.setLayout(vbox);
|
|
|
|
|
2014-06-11 22:49:18 +00:00
|
|
|
var packages = pkg.root.search({
|
|
|
|
'rating-FDM': 2,
|
|
|
|
'rating-cockpit': 2,
|
|
|
|
'rating-model': 2,
|
|
|
|
'rating-systems': 1
|
|
|
|
});
|
|
|
|
|
|
|
|
var info_text =
|
|
|
|
"Install/remove aircrafts (Showing " ~ size(packages) ~ " aircrafts)";
|
|
|
|
|
2014-06-10 16:47:13 +00:00
|
|
|
vbox.addItem(
|
|
|
|
gui.widgets.Label.new(root, style, {})
|
2014-06-11 22:49:18 +00:00
|
|
|
.setText(info_text)
|
2014-06-10 16:47:13 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
var scroll = gui.widgets.ScrollArea.new(root, style, {size: [96, 128]})
|
|
|
|
.move(20, 100);
|
|
|
|
vbox.addItem(scroll, 1);
|
|
|
|
|
|
|
|
var content = scroll.getContent()
|
|
|
|
.set("font", "LiberationFonts/LiberationSans-Bold.ttf")
|
|
|
|
.set("character-size", 16)
|
|
|
|
.set("alignment", "left-center");
|
|
|
|
|
|
|
|
var list = VBoxLayout.new();
|
|
|
|
scroll.setLayout(list);
|
|
|
|
|
2014-06-11 22:49:18 +00:00
|
|
|
foreach(var package; packages)
|
2014-06-10 16:47:13 +00:00
|
|
|
{
|
2014-06-11 22:49:18 +00:00
|
|
|
var row = HBoxLayout.new();
|
|
|
|
list.addItem(row);
|
|
|
|
|
|
|
|
var image_label = gui.widgets.Label.new(content, style, {});
|
|
|
|
image_label.setFixedSize(171, 128);
|
|
|
|
row.addItem(image_label);
|
|
|
|
|
|
|
|
var thumbs = package.thumbnails;
|
|
|
|
if( size(thumbs) > 0 )
|
|
|
|
image_label.setImage(thumbs[0]);
|
|
|
|
else
|
|
|
|
image_label.setText("No thumbnail available");
|
|
|
|
|
|
|
|
var detail_box = VBoxLayout.new();
|
|
|
|
detail_box.setSpacing(0);
|
|
|
|
row.addItem(detail_box);
|
|
|
|
|
|
|
|
var title_box = HBoxLayout.new();
|
|
|
|
detail_box.addItem(title_box);
|
|
|
|
|
|
|
|
title_box.addItem(
|
|
|
|
gui.widgets.Label.new(content, style, {})
|
|
|
|
.setText(package.name)
|
|
|
|
);
|
|
|
|
title_box.addStretch(1);
|
|
|
|
(func {
|
|
|
|
var p = package;
|
|
|
|
var b = gui.widgets.Button.new(content, style, {});
|
|
|
|
var installed = p.installed;
|
|
|
|
|
|
|
|
if( installed )
|
|
|
|
b.setText("Remove");
|
|
|
|
else
|
|
|
|
b.setText("Install");
|
2014-06-10 22:38:56 +00:00
|
|
|
|
2014-06-11 22:49:18 +00:00
|
|
|
b.listen("clicked", func
|
|
|
|
{
|
2014-06-10 22:38:56 +00:00
|
|
|
if( installed )
|
2014-06-11 22:49:18 +00:00
|
|
|
{
|
|
|
|
p.uninstall();
|
|
|
|
installed = 0;
|
2014-06-10 22:38:56 +00:00
|
|
|
b.setText("Install");
|
2014-06-11 22:49:18 +00:00
|
|
|
}
|
|
|
|
else
|
2014-06-10 22:38:56 +00:00
|
|
|
{
|
2014-06-11 22:49:18 +00:00
|
|
|
b.setEnabled(0)
|
|
|
|
.setText("Wait...");
|
|
|
|
p.install()
|
|
|
|
.progress(func(i, cur, total)
|
|
|
|
b.setText(sprintf("%.1f%%", (cur / total) * 100))
|
|
|
|
)
|
|
|
|
.fail(func b.setText('Failed'))
|
|
|
|
.done(func {
|
|
|
|
installed = 1;
|
|
|
|
b.setText("Remove")
|
|
|
|
.setEnabled(1);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
2014-06-10 16:47:13 +00:00
|
|
|
|
2014-06-11 22:49:18 +00:00
|
|
|
title_box.addItem(b);
|
|
|
|
})();
|
2014-06-10 16:47:13 +00:00
|
|
|
|
2014-06-11 22:49:18 +00:00
|
|
|
foreach(var cat; ["FDM", "systems", "cockpit", "model"])
|
|
|
|
{
|
|
|
|
detail_box.addItem(
|
|
|
|
gui.widgets.Label.new(content, style, {})
|
|
|
|
.setText(cat ~ ": " ~ package.lprop("rating/" ~ cat))
|
|
|
|
);
|
2014-06-10 16:47:13 +00:00
|
|
|
}
|
2014-06-11 22:49:18 +00:00
|
|
|
|
|
|
|
row.addSpacing(5);
|
2014-06-10 16:47:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
AircraftCenter.show();
|