This commit is contained in:
Adrien MALINGREY 2023-07-01 21:24:14 +02:00
parent 47016ccde4
commit 307042003e

12
app.js
View File

@ -69,7 +69,7 @@ const AWARDED_LINE_CLEARS = {
[T_SPIN.T_SPIN]: [4, 8, 12, 16] [T_SPIN.T_SPIN]: [4, 8, 12, 16]
} }
const KEY_NAMES = { const KEY_NAMES = new Proxy({
["ArrowLeft"] : "←", ["ArrowLeft"] : "←",
["ArrowRight"] : "→", ["ArrowRight"] : "→",
["ArrowUp"] : "↑", ["ArrowUp"] : "↑",
@ -86,7 +86,11 @@ const KEY_NAMES = {
["Échap."] : "Escape", ["Échap."] : "Escape",
["Ret. arrière"]: "Backspace", ["Ret. arrière"]: "Backspace",
["Entrée"] : "Enter", ["Entrée"] : "Enter",
} }, {
get(obj, keyName) {
return obj[keyName] || keyName
}
})
const CLEARED_LINES_NAMES = [ const CLEARED_LINES_NAMES = [
"", "",
@ -494,7 +498,7 @@ function changeKey() {
let input = controller.domElement.getElementsByTagName("input")[0] let input = controller.domElement.getElementsByTagName("input")[0]
input.select() input.select()
input.onkeydown = function (event) { input.onkeydown = function (event) {
controller.setValue(KEY_NAMES[event.key] || event.key) controller.setValue(KEY_NAMES[event.key])
input.blur() input.blur()
} }
input.onblur = function (event) { input.onblur = function (event) {
@ -567,7 +571,7 @@ class Settings {
bindKeys() { bindKeys() {
this.keyBind = {} this.keyBind = {}
for (let actionName in playerActions) { for (let actionName in playerActions) {
this.keyBind[KEY_NAMES[this[actionName]] || this[actionName]] = playerActions[actionName] this.keyBind[KEY_NAMES[this[actionName]]] = playerActions[actionName]
} }
} }