Merge pull request #620 from allancoding/main

Add new option EJS_alignStartButton
This commit is contained in:
Ethan O'Brien 2023-08-14 21:15:06 -05:00 committed by GitHub
commit f662b76447
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 14 additions and 4 deletions

View file

@ -173,7 +173,6 @@
.ejs_start_button:active, .ejs_start_button:hover { .ejs_start_button:active, .ejs_start_button:hover {
animation: ejs_start_button_pulse 2s infinite; animation: ejs_start_button_pulse 2s infinite;
bottom: 65px;
} }
@keyframes ejs_start_button_pulse { @keyframes ejs_start_button_pulse {

View file

@ -250,6 +250,7 @@ class EmulatorJS {
this.listeners = []; this.listeners = [];
this.setElements(element); this.setElements(element);
this.setColor(this.config.color || ""); 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)"; this.config.backgroundColor = (typeof this.config.backgroundColor === "string") ? this.config.backgroundColor : "rgb(51, 51, 51)";
if (this.config.adUrl) { if (this.config.adUrl) {
this.config.adSize = (Array.isArray(this.config.adSize)) ? this.config.adSize : ["300px", "250px"]; this.config.adSize = (Array.isArray(this.config.adSize)) ? this.config.adSize : ["300px", "250px"];
@ -405,8 +406,17 @@ class EmulatorJS {
createStartButton() { createStartButton() {
const button = this.createElement("div"); const button = this.createElement("div");
button.classList.add("ejs_start_button"); 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"); 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.elements.parent.appendChild(button);
this.addEventListener(button, "touchstart", () => { this.addEventListener(button, "touchstart", () => {
this.touch = true; this.touch = true;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -58,6 +58,7 @@
config.adMode = window.EJS_AdMode; config.adMode = window.EJS_AdMode;
config.adTimer = window.EJS_AdTimer; config.adTimer = window.EJS_AdTimer;
config.adSize = window.EJS_AdSize; config.adSize = window.EJS_AdSize;
config.alignStartButton = window.EJS_alignStartButton;
config.VirtualGamepadSettings = window.EJS_VirtualGamepadSettings; config.VirtualGamepadSettings = window.EJS_VirtualGamepadSettings;
config.buttonOpts = window.EJS_Buttons; config.buttonOpts = window.EJS_Buttons;
config.volume = window.EJS_volume; config.volume = window.EJS_volume;