mirror of
https://github.com/EmulatorJS/EmulatorJS.git
synced 2024-09-20 10:56:30 +00:00
Merge pull request #581 from n-at/main
save buttons order in control settings menu
This commit is contained in:
commit
3f5fd4db24
1 changed files with 129 additions and 121 deletions
250
data/emulator.js
250
data/emulator.js
|
@ -1775,130 +1775,135 @@ class EmulatorJS {
|
||||||
|
|
||||||
let buttons;
|
let buttons;
|
||||||
if ('nes' === this.getCore(true)) {
|
if ('nes' === this.getCore(true)) {
|
||||||
buttons = {
|
buttons = [
|
||||||
8: 'A',
|
{id: 8, label: 'A'},
|
||||||
0: 'B',
|
{id: 0, label: 'B'},
|
||||||
2: 'SELECT',
|
{id: 2, label: 'SELECT'},
|
||||||
3: 'START',
|
{id: 3, label: 'START'},
|
||||||
4: 'UP',
|
{id: 4, label: 'UP'},
|
||||||
5: 'DOWN',
|
{id: 5, label: 'DOWN'},
|
||||||
6: 'LEFT',
|
{id: 6, label: 'LEFT'},
|
||||||
7: 'RIGHT',
|
{id: 7, label: 'RIGHT'},
|
||||||
24: this.localization('QUICK SAVE STATE'),
|
{id: 24, label: this.localization('QUICK SAVE STATE')},
|
||||||
25: this.localization('QUICK LOAD STATE'),
|
{id: 25, label: this.localization('QUICK LOAD STATE')},
|
||||||
26: this.localization('CHANGE STATE SLOT')
|
{id: 26, label: this.localization('CHANGE STATE SLOT')},
|
||||||
}
|
];
|
||||||
} else if ('snes' === this.getCore(true)) {
|
} else if ('snes' === this.getCore(true)) {
|
||||||
buttons = {
|
buttons = [
|
||||||
0: 'B',
|
{id: 8, label: 'A'},
|
||||||
1: 'Y',
|
{id: 0, label: 'B'},
|
||||||
2: 'SELECT',
|
{id: 9, label: 'X'},
|
||||||
3: 'START',
|
{id: 1, label: 'Y'},
|
||||||
4: 'UP',
|
{id: 2, label: 'SELECT'},
|
||||||
5: 'DOWN',
|
{id: 3, label: 'START'},
|
||||||
6: 'LEFT',
|
{id: 4, label: 'UP'},
|
||||||
7: 'RIGHT',
|
{id: 5, label: 'DOWN'},
|
||||||
8: 'A',
|
{id: 6, label: 'LEFT'},
|
||||||
9: 'X',
|
{id: 7, label: 'RIGHT'},
|
||||||
10: 'L',
|
{id: 10, label: 'L'},
|
||||||
11: 'R',
|
{id: 11, label: 'R'},
|
||||||
24: this.localization('QUICK SAVE STATE'),
|
{id: 24, label: this.localization('QUICK SAVE STATE')},
|
||||||
25: this.localization('QUICK LOAD STATE'),
|
{id: 25, label: this.localization('QUICK LOAD STATE')},
|
||||||
26: this.localization('CHANGE STATE SLOT')
|
{id: 26, label: this.localization('CHANGE STATE SLOT')},
|
||||||
};
|
];
|
||||||
} else if ('n64' === this.getCore(true)) {
|
} else if ('n64' === this.getCore(true)) {
|
||||||
buttons = {
|
buttons = [
|
||||||
0: 'A',
|
{id: 0, label: 'A'},
|
||||||
1: 'B',
|
{id: 1, label: 'B'},
|
||||||
3: 'START',
|
{id: 3, label: 'START'},
|
||||||
4: 'UP',
|
{id: 4, label: 'UP'},
|
||||||
5: 'DOWN',
|
{id: 5, label: 'DOWN'},
|
||||||
6: 'LEFT',
|
{id: 6, label: 'LEFT'},
|
||||||
7: 'RIGHT',
|
{id: 7, label: 'RIGHT'},
|
||||||
10: 'L',
|
{id: 10, label: 'L'},
|
||||||
11: 'R',
|
{id: 11, label: 'R'},
|
||||||
12: 'Z',
|
{id: 12, label: 'Z'},
|
||||||
19: 'L STICK UP',
|
{id: 19, label: 'L STICK UP'},
|
||||||
18: 'L STICK DOWN',
|
{id: 18, label: 'L STICK DOWN'},
|
||||||
17: 'L STICK LEFT',
|
{id: 17, label: 'L STICK LEFT'},
|
||||||
16: 'L STICK RIGHT',
|
{id: 16, label: 'L STICK RIGHT'},
|
||||||
23: 'R STICK UP',
|
{id: 23, label: 'R STICK UP'},
|
||||||
22: 'R STICK DOWN',
|
{id: 22, label: 'R STICK DOWN'},
|
||||||
21: 'R STICK LEFT',
|
{id: 21, label: 'R STICK LEFT'},
|
||||||
20: 'R STICK RIGHT',
|
{id: 20, label: 'R STICK RIGHT'},
|
||||||
24: this.localization('QUICK SAVE STATE'),
|
{id: 24, label: this.localization('QUICK SAVE STATE')},
|
||||||
25: this.localization('QUICK LOAD STATE'),
|
{id: 25, label: this.localization('QUICK LOAD STATE')},
|
||||||
26: this.localization('CHANGE STATE SLOT')
|
{id: 26, label: this.localization('CHANGE STATE SLOT')},
|
||||||
};
|
];
|
||||||
} else if ('nds' === this.getCore(true)) {
|
} else if ('nds' === this.getCore(true)) {
|
||||||
buttons = {
|
buttons = [
|
||||||
0: 'B',
|
{id: 8, label: 'A'},
|
||||||
1: 'Y',
|
{id: 0, label: 'B'},
|
||||||
2: 'SELECT',
|
{id: 9, label: 'X'},
|
||||||
3: 'START',
|
{id: 1, label: 'Y'},
|
||||||
4: 'UP',
|
{id: 2, label: 'SELECT'},
|
||||||
5: 'DOWN',
|
{id: 3, label: 'START'},
|
||||||
6: 'LEFT',
|
{id: 4, label: 'UP'},
|
||||||
7: 'RIGHT',
|
{id: 5, label: 'DOWN'},
|
||||||
8: 'A',
|
{id: 6, label: 'LEFT'},
|
||||||
9: 'X',
|
{id: 7, label: 'RIGHT'},
|
||||||
10: 'L',
|
{id: 10, label: 'L'},
|
||||||
11: 'R',
|
{id: 11, label: 'R'},
|
||||||
14: 'Microphone',
|
{id: 14, label: 'Microphone'},
|
||||||
24: this.localization('QUICK SAVE STATE'),
|
{id: 24, label: this.localization('QUICK SAVE STATE')},
|
||||||
25: this.localization('QUICK LOAD STATE'),
|
{id: 25, label: this.localization('QUICK LOAD STATE')},
|
||||||
26: this.localization('CHANGE STATE SLOT')
|
{id: 26, label: this.localization('CHANGE STATE SLOT')},
|
||||||
};
|
];
|
||||||
} else if (['segaMD', 'segaCD', 'sega32x'].includes(this.getCore(true))) {
|
} else if (['segaMD', 'segaCD', 'sega32x'].includes(this.getCore(true))) {
|
||||||
buttons = {
|
buttons = [
|
||||||
0: 'B',
|
{id: 1, label: 'A'},
|
||||||
1: 'A',
|
{id: 0, label: 'B'},
|
||||||
3: 'START',
|
{id: 8, label: 'C'},
|
||||||
8: 'C',
|
{id: 10, label: 'X'},
|
||||||
9: 'Y',
|
{id: 9, label: 'Y'},
|
||||||
10: 'X',
|
{id: 11, label: 'Z'},
|
||||||
11: 'Z',
|
{id: 3, label: 'START'},
|
||||||
4: 'UP',
|
{id: 2, label: 'MODE'},
|
||||||
5: 'DOWN',
|
{id: 4, label: 'UP'},
|
||||||
6: 'LEFT',
|
{id: 5, label: 'DOWN'},
|
||||||
7: 'RIGHT',
|
{id: 6, label: 'LEFT'},
|
||||||
24: this.localization('QUICK SAVE STATE'),
|
{id: 7, label: 'RIGHT'},
|
||||||
25: this.localization('QUICK LOAD STATE'),
|
{id: 24, label: this.localization('QUICK SAVE STATE')},
|
||||||
26: this.localization('CHANGE STATE SLOT')
|
{id: 25, label: this.localization('QUICK LOAD STATE')},
|
||||||
};
|
{id: 26, label: this.localization('CHANGE STATE SLOT')},
|
||||||
|
];
|
||||||
} else {
|
} else {
|
||||||
buttons = {
|
buttons = [
|
||||||
0: 'B',
|
{id: 0, label: 'B'},
|
||||||
1: 'Y',
|
{id: 1, label: 'Y'},
|
||||||
2: 'SELECT',
|
{id: 2, label: 'SELECT'},
|
||||||
3: 'START',
|
{id: 3, label: 'START'},
|
||||||
4: 'UP',
|
{id: 4, label: 'UP'},
|
||||||
5: 'DOWN',
|
{id: 5, label: 'DOWN'},
|
||||||
6: 'LEFT',
|
{id: 6, label: 'LEFT'},
|
||||||
7: 'RIGHT',
|
{id: 7, label: 'RIGHT'},
|
||||||
8: 'A',
|
{id: 8, label: 'A'},
|
||||||
9: 'X',
|
{id: 9, label: 'X'},
|
||||||
10: 'L',
|
{id: 10, label: 'L'},
|
||||||
11: 'R',
|
{id: 11, label: 'R'},
|
||||||
12: 'L2',
|
{id: 12, label: 'L2'},
|
||||||
13: 'R2',
|
{id: 13, label: 'R2'},
|
||||||
14: 'L3',
|
{id: 14, label: 'L3'},
|
||||||
15: 'R3',
|
{id: 15, label: 'R3'},
|
||||||
19: 'L STICK UP',
|
{id: 19, label: 'L STICK UP'},
|
||||||
18: 'L STICK DOWN',
|
{id: 18, label: 'L STICK DOWN'},
|
||||||
17: 'L STICK LEFT',
|
{id: 17, label: 'L STICK LEFT'},
|
||||||
16: 'L STICK RIGHT',
|
{id: 16, label: 'L STICK RIGHT'},
|
||||||
23: 'R STICK UP',
|
{id: 23, label: 'R STICK UP'},
|
||||||
22: 'R STICK DOWN',
|
{id: 22, label: 'R STICK DOWN'},
|
||||||
21: 'R STICK LEFT',
|
{id: 21, label: 'R STICK LEFT'},
|
||||||
20: 'R STICK RIGHT',
|
{id: 20, label: 'R STICK RIGHT'},
|
||||||
24: this.localization('QUICK SAVE STATE'),
|
{id: 24, label: this.localization('QUICK SAVE STATE')},
|
||||||
25: this.localization('QUICK LOAD STATE'),
|
{id: 25, label: this.localization('QUICK LOAD STATE')},
|
||||||
26: this.localization('CHANGE STATE SLOT')
|
{id: 26, label: this.localization('CHANGE STATE SLOT')},
|
||||||
};
|
];
|
||||||
}
|
}
|
||||||
if (['arcade', 'mame'].includes(this.getCore(true))) {
|
if (['arcade', 'mame'].includes(this.getCore(true))) {
|
||||||
buttons[2] = this.localization('INSERT COIN');
|
for (const buttonIdx in buttons) {
|
||||||
|
if (buttons[buttonIdx].id === 2) {
|
||||||
|
buttons[buttonIdx].label = this.localization('INSERT COIN');
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//if (_this.statesSupported === false) {
|
//if (_this.statesSupported === false) {
|
||||||
// delete buttons[24];
|
// delete buttons[24];
|
||||||
|
@ -1976,11 +1981,14 @@ class EmulatorJS {
|
||||||
|
|
||||||
player.appendChild(playerTitle);
|
player.appendChild(playerTitle);
|
||||||
|
|
||||||
for (const k in buttons) {
|
for (const buttonIdx in buttons) {
|
||||||
|
const k = buttons[buttonIdx].id;
|
||||||
|
const controlLabel = buttons[buttonIdx].label;
|
||||||
|
|
||||||
const buttonText = this.createElement("div");
|
const buttonText = this.createElement("div");
|
||||||
buttonText.setAttribute("data-id", k);
|
buttonText.setAttribute("data-id", k);
|
||||||
buttonText.setAttribute("data-index", i);
|
buttonText.setAttribute("data-index", i);
|
||||||
buttonText.setAttribute("data-label", buttons[k]);
|
buttonText.setAttribute("data-label", controlLabel);
|
||||||
buttonText.style = "margin-bottom:10px;";
|
buttonText.style = "margin-bottom:10px;";
|
||||||
buttonText.classList.add("ejs_control_bar");
|
buttonText.classList.add("ejs_control_bar");
|
||||||
|
|
||||||
|
@ -1988,7 +1996,7 @@ class EmulatorJS {
|
||||||
const title = this.createElement("div");
|
const title = this.createElement("div");
|
||||||
title.style = "width:25%;float:left;font-size:12px;";
|
title.style = "width:25%;float:left;font-size:12px;";
|
||||||
const label = this.createElement("label");
|
const label = this.createElement("label");
|
||||||
label.innerText = buttons[k]+":";
|
label.innerText = controlLabel+":";
|
||||||
title.appendChild(label);
|
title.appendChild(label);
|
||||||
|
|
||||||
const textBoxes = this.createElement("div");
|
const textBoxes = this.createElement("div");
|
||||||
|
@ -2057,7 +2065,7 @@ class EmulatorJS {
|
||||||
this.addEventListener(buttonText, "mousedown", (e) => {
|
this.addEventListener(buttonText, "mousedown", (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
this.controlPopup.parentElement.parentElement.removeAttribute("hidden");
|
this.controlPopup.parentElement.parentElement.removeAttribute("hidden");
|
||||||
this.controlPopup.innerText = "[ " + buttons[k] + " ]\n"+this.localization("Press Keyboard");
|
this.controlPopup.innerText = "[ " + controlLabel + " ]\n"+this.localization("Press Keyboard");
|
||||||
this.controlPopup.setAttribute("button-num", k);
|
this.controlPopup.setAttribute("button-num", k);
|
||||||
this.controlPopup.setAttribute("player-num", i);
|
this.controlPopup.setAttribute("player-num", i);
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue