116 lines
3.2 KiB
Text
116 lines
3.2 KiB
Text
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);
|
|
|
|
vbox.addItem(
|
|
gui.widgets.Label.new(root, style, {})
|
|
.setText("Install/remove aircrafts (Showing first 100)")
|
|
);
|
|
|
|
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);
|
|
|
|
var num = 0;
|
|
foreach(var catalog; pkg.root.catalogs())
|
|
{
|
|
foreach(var package; catalog.packages())
|
|
{
|
|
var row = HBoxLayout.new();
|
|
list.addItem(row);
|
|
|
|
var img = "path-for-missing-thumb...";
|
|
var thumbs = package.thumbnails;
|
|
if( size(thumbs) > 0 )
|
|
img = thumbs[0];
|
|
var image_label = gui.widgets.Label.new(content, style, {})
|
|
.setImage(img);
|
|
image_label.setFixedSize(171, 128);
|
|
row.addItem(image_label);
|
|
|
|
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");
|
|
|
|
b.listen("clicked", func
|
|
{
|
|
if( installed )
|
|
{
|
|
p.uninstall();
|
|
installed = 0;
|
|
b.setText("Install");
|
|
}
|
|
else
|
|
{
|
|
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);
|
|
});
|
|
}
|
|
});
|
|
|
|
title_box.addItem(b);
|
|
})();
|
|
|
|
foreach(var cat; ["FDM", "systems", "cockpit", "model"])
|
|
{
|
|
detail_box.addItem(
|
|
gui.widgets.Label.new(content, style, {})
|
|
.setText(cat ~ ": " ~ package.lprop("rating/" ~ cat))
|
|
);
|
|
}
|
|
|
|
row.addSpacing(5);
|
|
|
|
num += 1;
|
|
if( num >= 100 )
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
AircraftCenter.show();
|