MCPcopy Index your code
hub / github.com/EmulatorJS/EmulatorJS / downloadStartState

Method downloadStartState

data/src/emulator.js:678–701  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

676 this.msgElem.innerText = message;
677 }
678 downloadStartState() {
679 return new Promise((resolve, reject) => {
680 if (typeof this.config.loadState !== "string" && !this.toData(this.config.loadState, true)) {
681 resolve();
682 return;
683 }
684 this.textElem.innerText = this.localization("Download Game State");
685
686 this.downloadFile(this.config.loadState, (progress) => {
687 this.textElem.innerText = this.localization("Download Game State") + progress;
688 }, true, { responseType: "arraybuffer", method: "GET" }).then((res) => {
689 if (res === -1) {
690 this.startGameError(this.localization("Error downloading game state"));
691 return;
692 }
693 this.on("start", () => {
694 setTimeout(() => {
695 this.gameManager.loadState(new Uint8Array(res.data));
696 }, 10);
697 })
698 resolve();
699 });
700 })
701 }
702 downloadGameFile(assetUrl, type, progressMessage, decompressProgressMessage) {
703 return new Promise(async (resolve, reject) => {
704 if ((typeof assetUrl !== "string" || !assetUrl.trim()) && !this.toData(assetUrl, true)) {

Callers 1

downloadFilesMethod · 0.95

Calls 6

toDataMethod · 0.95
localizationMethod · 0.95
downloadFileMethod · 0.95
startGameErrorMethod · 0.95
onMethod · 0.95
loadStateMethod · 0.80

Tested by

no test coverage detected