2021-08-12 23:19:39 +00:00
|
|
|
|
2021-08-23 18:12:02 +00:00
|
|
|
import { PLATFORMS } from "../common/emu";
|
2021-08-12 23:19:39 +00:00
|
|
|
import { Platform } from "../common/baseplatform";
|
2021-08-15 15:10:01 +00:00
|
|
|
import { RunResult } from "../common/script/env";
|
2021-08-14 16:06:49 +00:00
|
|
|
import { Notebook } from "../common/script/ui/notebook";
|
2021-08-12 23:19:39 +00:00
|
|
|
|
|
|
|
class ScriptingPlatform implements Platform {
|
|
|
|
mainElement: HTMLElement;
|
|
|
|
iframe: HTMLIFrameElement;
|
|
|
|
notebook: Notebook;
|
|
|
|
|
|
|
|
constructor(mainElement: HTMLElement) {
|
|
|
|
this.mainElement = mainElement;
|
2021-08-14 16:06:49 +00:00
|
|
|
this.notebook = new Notebook(document, mainElement);
|
2021-08-12 23:19:39 +00:00
|
|
|
}
|
|
|
|
start() {
|
|
|
|
}
|
|
|
|
reset() {
|
|
|
|
}
|
|
|
|
pause() {
|
|
|
|
}
|
|
|
|
resume() {
|
|
|
|
}
|
2021-08-15 15:10:01 +00:00
|
|
|
loadROM(title, run: RunResult) {
|
|
|
|
this.notebook.updateCells(run.cells);
|
|
|
|
// TODO: save state file
|
2021-08-12 23:19:39 +00:00
|
|
|
}
|
|
|
|
isRunning() {
|
2021-08-15 15:10:01 +00:00
|
|
|
return true;
|
2021-08-12 23:19:39 +00:00
|
|
|
}
|
|
|
|
isDebugging(): boolean {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
getToolForFilename(fn: string): string {
|
|
|
|
return "js";
|
|
|
|
}
|
|
|
|
getDefaultExtension(): string {
|
|
|
|
return ".js";
|
|
|
|
}
|
|
|
|
getPresets() {
|
|
|
|
return [
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PLATFORMS['script'] = ScriptingPlatform;
|