mirror of
https://github.com/tobspr/shapez.io.git
synced 2026-02-12 02:49:20 +00:00
add addKeybinding button
This commit is contained in:
parent
1d13a8fcfa
commit
5b6e4502d2
@ -339,6 +339,7 @@ export class KeyActionMapper {
|
||||
for (const category in KEYMAPPINGS) {
|
||||
for (const key in KEYMAPPINGS[category]) {
|
||||
let payload = Object.assign({}, KEYMAPPINGS[category][key]);
|
||||
payload.keyCodes = payload.keyCodes.slice();
|
||||
if (overrides[key]) {
|
||||
payload.keyCodes[0] = overrides[key];
|
||||
}
|
||||
|
||||
@ -44,7 +44,7 @@ export class KeybindingsState extends TextualGameState {
|
||||
} else {
|
||||
this.trackClicks(editBtn, () => this.editKeybinding(keybindingId));
|
||||
}
|
||||
elem.querySelector(".resetKeybinding").before(mappingDiv, editBtn);
|
||||
elem.querySelector(".resetKeybinding,.addKeybinding").before(mappingDiv, editBtn);
|
||||
}
|
||||
|
||||
onEnter() {
|
||||
@ -75,6 +75,16 @@ export class KeybindingsState extends TextualGameState {
|
||||
title.innerText = T.keybindings.mappings[keybindingId] || `unset(${keybindingId})`;
|
||||
elem.appendChild(title);
|
||||
|
||||
const addBtn = document.createElement("button");
|
||||
addBtn.classList.add("styledButton", "addKeybinding", /* REMOVE THIS */ "editKeybinding");
|
||||
this.trackClicks(addBtn, () => {
|
||||
let index = mapped.keyCodes.length;
|
||||
mapped.keyCodes.push(0);
|
||||
this.addEditField(elem, keybindingId, index, mapped.builtin);
|
||||
this.editKeybinding(keybindingId + "_" + index);
|
||||
});
|
||||
elem.appendChild(addBtn);
|
||||
|
||||
const resetBtn = document.createElement("button");
|
||||
resetBtn.classList.add("styledButton", "resetKeybinding");
|
||||
if (mapped.builtin) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user