2023-09-17 14:18:21 +02:00
|
|
|
import Dialog from "../../tilorswift/js/dialog/Dialog.js";
|
|
|
|
|
|
|
|
export class LoadLevelDialog extends Dialog
|
|
|
|
{
|
|
|
|
constructor() {
|
|
|
|
super();
|
|
|
|
|
|
|
|
this.setMessage('Level laden');
|
|
|
|
this.fileInput = this.createFileInput(['json']);
|
2023-09-18 22:33:55 +02:00
|
|
|
this.fileInput.addEventListener(
|
|
|
|
'change',
|
2023-09-17 14:18:21 +02:00
|
|
|
() => {
|
|
|
|
if (this.fileInput.files.length === 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const reader = new FileReader();
|
|
|
|
reader.addEventListener(
|
|
|
|
'load',
|
|
|
|
(event) => {
|
|
|
|
this.onClose();
|
|
|
|
this.onLoad(event.target.result);
|
|
|
|
}
|
|
|
|
)
|
|
|
|
reader.readAsBinaryString(this.fileInput.files[0]);
|
|
|
|
}
|
2023-09-18 22:33:55 +02:00
|
|
|
)
|
|
|
|
this.onClose = () => {};
|
|
|
|
this.onLoad = () => {};
|
2023-09-17 14:18:21 +02:00
|
|
|
|
|
|
|
this.buttonCancel = this.createButton('Abbrechen');
|
|
|
|
this.buttonCancel.addEventListener(
|
|
|
|
'click',
|
|
|
|
() => {
|
|
|
|
this.onClose();
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
2023-09-19 11:44:56 +02:00
|
|
|
|
|
|
|
openFileBrowser()
|
|
|
|
{
|
|
|
|
this.fileInput.click();
|
|
|
|
}
|
2023-09-17 14:18:21 +02:00
|
|
|
}
|