Skip to content

Commit

Permalink
Game pages: fix multiple starts of the emulators
Browse files Browse the repository at this point in the history
  • Loading branch information
avivace committed Dec 26, 2024
1 parent 1c9eacd commit 5f5076b
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 27 deletions.
54 changes: 27 additions & 27 deletions plugins/Emulator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
<template>
<div>
<div v-show="loading == 0" @click="start()">
<center>
<i class="pi pi-play" style="font-size: 5rem"></i> <br />
<h4>Click here to start the emulation</h4>
</center>
<i class="pi pi-play" style="font-size: 5rem"></i> <br />
<h4>Click here to start the emulation</h4>
</div>

<div
Expand Down Expand Up @@ -196,31 +194,33 @@ export default {
},
methods: {
start: function () {
// Expose the context to the non-vue emulator code below so it can access the canvas and the emulator settings.
window.vm = this;

// Download the ROM from the found endpoint
fetch(this.romEndpoint).then((response) => {
let gameblob = response.blob().then((blob) => {
// Get the Blob
this.gamerom = blob;
this.loading = 1;
// Lesssssgooooooo
this.playROM();
// Let's check if there are some query param we should honor
if (this.$route.query.palette) {
// Set the desired palette
let queryvalue = parseInt(this.$route.query.palette);
if (queryvalue < 0) {
queryvalue = 0;
} else if (queryvalue > 85) {
queryvalue = 85;
if (this.loading == 0) {
// Expose the context to the non-vue emulator code below so it can access the canvas and the emulator settings.
window.vm = this;

// Download the ROM from the found endpoint
fetch(this.romEndpoint).then((response) => {
let gameblob = response.blob().then((blob) => {
// Get the Blob
this.gamerom = blob;
this.loading = 1;
// Lesssssgooooooo
this.playROM();
// Let's check if there are some query param we should honor
if (this.$route.query.palette) {
// Set the desired palette
let queryvalue = parseInt(this.$route.query.palette);
if (queryvalue < 0) {
queryvalue = 0;
} else if (queryvalue > 85) {
queryvalue = 85;
}
this.pal = queryvalue;
this.setPal(queryvalue);
}
this.pal = queryvalue;
this.setPal(queryvalue);
}
});
});
});
}
},
togglemute: function () {
if (this.mute) {
Expand Down
3 changes: 3 additions & 0 deletions plugins/Medusa.vue
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ export default {
window.Module._unmute();
},
start: function () {
if (this.started == true){
return;
}
this.started = true;
window.vm = this;
window.Module = {
Expand Down
3 changes: 3 additions & 0 deletions plugins/Nes.vue
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ export default {
},
methods: {
start: function () {
if (this.loading == 1) {
return;
}
// Expose the context to the non-vue emulator code below so it can access the canvas and the emulator settings.
window.vm = this;
Expand Down

0 comments on commit 5f5076b

Please sign in to comment.