Skip to content

Commit 5f5076b

Browse files
committed
Game pages: fix multiple starts of the emulators
1 parent 1c9eacd commit 5f5076b

File tree

3 files changed

+33
-27
lines changed

3 files changed

+33
-27
lines changed

plugins/Emulator.vue

+27-27
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@
66
<template>
77
<div>
88
<div v-show="loading == 0" @click="start()">
9-
<center>
10-
<i class="pi pi-play" style="font-size: 5rem"></i> <br />
11-
<h4>Click here to start the emulation</h4>
12-
</center>
9+
<i class="pi pi-play" style="font-size: 5rem"></i> <br />
10+
<h4>Click here to start the emulation</h4>
1311
</div>
1412

1513
<div
@@ -196,31 +194,33 @@ export default {
196194
},
197195
methods: {
198196
start: function () {
199-
// Expose the context to the non-vue emulator code below so it can access the canvas and the emulator settings.
200-
window.vm = this;
201-
202-
// Download the ROM from the found endpoint
203-
fetch(this.romEndpoint).then((response) => {
204-
let gameblob = response.blob().then((blob) => {
205-
// Get the Blob
206-
this.gamerom = blob;
207-
this.loading = 1;
208-
// Lesssssgooooooo
209-
this.playROM();
210-
// Let's check if there are some query param we should honor
211-
if (this.$route.query.palette) {
212-
// Set the desired palette
213-
let queryvalue = parseInt(this.$route.query.palette);
214-
if (queryvalue < 0) {
215-
queryvalue = 0;
216-
} else if (queryvalue > 85) {
217-
queryvalue = 85;
197+
if (this.loading == 0) {
198+
// Expose the context to the non-vue emulator code below so it can access the canvas and the emulator settings.
199+
window.vm = this;
200+
201+
// Download the ROM from the found endpoint
202+
fetch(this.romEndpoint).then((response) => {
203+
let gameblob = response.blob().then((blob) => {
204+
// Get the Blob
205+
this.gamerom = blob;
206+
this.loading = 1;
207+
// Lesssssgooooooo
208+
this.playROM();
209+
// Let's check if there are some query param we should honor
210+
if (this.$route.query.palette) {
211+
// Set the desired palette
212+
let queryvalue = parseInt(this.$route.query.palette);
213+
if (queryvalue < 0) {
214+
queryvalue = 0;
215+
} else if (queryvalue > 85) {
216+
queryvalue = 85;
217+
}
218+
this.pal = queryvalue;
219+
this.setPal(queryvalue);
218220
}
219-
this.pal = queryvalue;
220-
this.setPal(queryvalue);
221-
}
221+
});
222222
});
223-
});
223+
}
224224
},
225225
togglemute: function () {
226226
if (this.mute) {

plugins/Medusa.vue

+3
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ export default {
7979
window.Module._unmute();
8080
},
8181
start: function () {
82+
if (this.started == true){
83+
return;
84+
}
8285
this.started = true;
8386
window.vm = this;
8487
window.Module = {

plugins/Nes.vue

+3
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,9 @@ export default {
155155
},
156156
methods: {
157157
start: function () {
158+
if (this.loading == 1) {
159+
return;
160+
}
158161
// Expose the context to the non-vue emulator code below so it can access the canvas and the emulator settings.
159162
window.vm = this;
160163

0 commit comments

Comments
 (0)