diff --git a/examples/web/index.ts b/examples/web/index.ts index 94c795f15cdd5db29e85598cb536c21f002f3baf..4fd1abe16bf97de22ea509d0080796eb2fb983ca 100644 --- a/examples/web/index.ts +++ b/examples/web/index.ts @@ -338,7 +338,6 @@ class GameboyEmulator extends EmulatorBase implements Emulator { this.trigger("booted"); } - // @todo remove this method, or at least most of it async register() { await Promise.all([this.registerKeys()]); } @@ -410,6 +409,10 @@ class GameboyEmulator extends EmulatorBase implements Emulator { return "https://gitlab.stage.hive.pt/joamag/boytacean/-/blob/master/CHANGELOG.md"; } + get romExts(): string[] { + return ["gb"]; + } + get pixelFormat(): PixelFormat { return PixelFormat.RGB; } diff --git a/examples/web/react/app.tsx b/examples/web/react/app.tsx index 8e4167f928dfffa52ddc452d4303559b1257c886..f8982e1884ea4f665243e120630908c3f1b5a514 100644 --- a/examples/web/react/app.tsx +++ b/examples/web/react/app.tsx @@ -130,6 +130,12 @@ export interface Emulator extends ObservableI { */ get engine(): string | null; + /** + * The complete set of file extensions that this emulator + * supports. + */ + get romExts(): string[]; + /** * The pixel format of the emulator's display * image buffer (eg: RGB). @@ -363,9 +369,8 @@ export const App: FC<AppProps> = ({ }; const onFile = async (file: File) => { - // @todo must make this more flexible and not just - // Game Boy only (using the emulator interface) - if (!file.name.endsWith(".gb")) { + const fileExtension = file.name.split(".").pop() ?? ""; + if (!emulator.romExts.includes(fileExtension)) { showToast( `This is probably not a ${emulator.device} ROM file!`, true