From cb75cc52d8b6f00720faafba6490e840dd3fa695 Mon Sep 17 00:00:00 2001 From: Allan Niles <60013695a@gmail.com> Date: Mon, 14 Aug 2023 17:19:17 -0600 Subject: [PATCH] add new option EJS_alignStartButton --- data/emulator.css | 1 - data/emulator.js | 12 +++++++++++- data/loader.js | 1 + 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/data/emulator.css b/data/emulator.css index af33a9c..f88e5ab 100644 --- a/data/emulator.css +++ b/data/emulator.css @@ -173,7 +173,6 @@ .ejs_start_button:active, .ejs_start_button:hover { animation: ejs_start_button_pulse 2s infinite; - bottom: 65px; } @keyframes ejs_start_button_pulse { diff --git a/data/emulator.js b/data/emulator.js index 6e9a610..3a659f3 100644 --- a/data/emulator.js +++ b/data/emulator.js @@ -250,6 +250,7 @@ class EmulatorJS { this.listeners = []; this.setElements(element); this.setColor(this.config.color || ""); + this.config.alignStartButton = (typeof this.config.alignStartButton === "string") ? this.config.alignStartButton : "bottom"; this.config.backgroundColor = (typeof this.config.backgroundColor === "string") ? this.config.backgroundColor : "rgb(51, 51, 51)"; if (this.config.adUrl) { this.config.adSize = (Array.isArray(this.config.adSize)) ? this.config.adSize : ["300px", "250px"]; @@ -405,8 +406,17 @@ class EmulatorJS { createStartButton() { const button = this.createElement("div"); button.classList.add("ejs_start_button"); - if (typeof this.config.backgroundImg === "string") button.classList.add("ejs_start_button_border"); + let border = 0; + if (typeof this.config.backgroundImg === "string"){ + button.classList.add("ejs_start_button_border"); + border = 1; + } button.innerText = this.localization("Start Game"); + if (this.config.alignStartButton == "top"){ + button.style.bottom = "calc(100% - 20px)"; + }else if (this.config.alignStartButton == "center"){ + button.style.bottom = "calc(50% + 22.5px + "+border+"px)"; + } this.elements.parent.appendChild(button); this.addEventListener(button, "touchstart", () => { this.touch = true; diff --git a/data/loader.js b/data/loader.js index 1a5f460..ac503a1 100644 --- a/data/loader.js +++ b/data/loader.js @@ -58,6 +58,7 @@ config.adMode = window.EJS_AdMode; config.adTimer = window.EJS_AdTimer; config.adSize = window.EJS_AdSize; + config.alignStartButton = window.EJS_alignStartButton; config.VirtualGamepadSettings = window.EJS_VirtualGamepadSettings; config.buttonOpts = window.EJS_Buttons; config.volume = window.EJS_volume;