Add background image option

This commit is contained in:
Ethan O'Brien 2023-07-18 09:59:31 -05:00
parent 73301c2ae9
commit 8c767b7351
2 changed files with 13 additions and 0 deletions

View file

@ -189,6 +189,18 @@ class EmulatorJS {
} }
this.game.classList.add("ejs_game"); this.game.classList.add("ejs_game");
if (typeof this.config.backgroundImg === "string") {
this.game.style["background-image"] = "url('"+this.config.backgroundImg+"')";
this.game.style["background-size"] = "contain";
this.game.style["background-position"] = "center";
this.game.style["background-repeat"] = "no-repeat";
this.on("start", () => {
this.game.style["background-image"] = "";
this.game.style["background-size"] = "";
this.game.style["background-position"] = "";
this.game.style["background-repeat"] = "";
})
}
if (Array.isArray(this.config.cheats)) { if (Array.isArray(this.config.cheats)) {
for (let i=0; i<this.config.cheats.length; i++) { for (let i=0; i<this.config.cheats.length; i++) {

View file

@ -66,6 +66,7 @@
config.gameParentUrl = window.EJS_gameParentUrl; config.gameParentUrl = window.EJS_gameParentUrl;
config.netplayUrl = window.EJS_netplayServer; config.netplayUrl = window.EJS_netplayServer;
config.gameId = window.EJS_gameID; config.gameId = window.EJS_gameID;
config.backgroundImg = window.EJS_backgroundImage;
if (typeof window.EJS_language === "string" && window.EJS_language !== "en-US") { if (typeof window.EJS_language === "string" && window.EJS_language !== "en-US") {
try { try {