-
-
Notifications
You must be signed in to change notification settings - Fork 78
/
Copy pathRunDefMac.tsx
55 lines (53 loc) · 1.96 KB
/
RunDefMac.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import {useEffect, useState} from "react";
import {type EmulatorCDROM} from "./emulator/emulator-common";
import {type RunDef} from "./run-def";
import Mac from "./Mac";
import {getCDROMInfo} from "./cdroms";
export type RunDefMacProps = {
runDef: RunDef;
onDone: () => void;
};
export default function RunDefMac({runDef, onDone}: RunDefMacProps) {
const [cdroms, setCDROMs] = useState<EmulatorCDROM[] | undefined>(
runDef.cdromURLs.length ? undefined : []
);
const [cdromErrorText, setCDROMErrorText] = useState<string | undefined>(
undefined
);
useEffect(() => {
if (runDef.cdromURLs.length) {
Promise.all(runDef.cdromURLs.map(getCDROMInfo))
.then(setCDROMs)
.catch(error => {
setCDROMErrorText(`Could not load the CD-ROM: ${error}`);
setCDROMs([]);
});
}
}, [runDef.cdromURLs]);
runDef.disks.forEach(disk => disk.generatedSpec()); // Prefetch the disk definition
return cdroms ? (
<Mac
disks={runDef.disks}
includeInfiniteHD={runDef.includeInfiniteHD}
includeSavedHD={runDef.includeSavedHD}
includeLibrary={runDef.includeLibrary}
libraryDownloadURLs={runDef.libraryDownloadURLs}
diskFiles={runDef.diskFiles}
cdroms={cdroms}
initialErrorText={cdromErrorText}
machine={runDef.machine}
ramSize={runDef.ramSize}
screenSize={runDef.screenSize}
ethernetProvider={runDef.ethernetProvider}
customDate={runDef.customDate}
debugFallback={runDef.debugFallback}
debugAudio={runDef.debugAudio}
debugPaused={runDef.debugPaused}
debugLog={runDef.debugLog}
debugTrackpad={runDef.debugTrackpad}
onDone={onDone}
/>
) : (
<div style={{color: "#aaa"}}>Loading CD-ROM Metadata…</div>
);
}