From b6fa313cba1075d6c5145a45e6b55709fd589889 Mon Sep 17 00:00:00 2001 From: cha0s Date: Thu, 23 May 2019 05:39:09 -0500 Subject: [PATCH] feat: numeric slot keys --- client/app.js | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/client/app.js b/client/app.js index 38cd101..951bbb9 100644 --- a/client/app.js +++ b/client/app.js @@ -238,6 +238,19 @@ export class App extends decorate(class {}) { case 'e': this.isMenuOpened = !this.isMenuOpened; break; + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case '0': + const slotIndex = (parseInt(key) + 9) % 10; + this.setActiveSlotIndex(slotIndex); + break; } } @@ -342,10 +355,10 @@ export class App extends decorate(class {}) { } const activeSlotIndex = this.selfEntity.activeSlotIndex; if (event.deltaY > 0) { - this.selfEntity.activeSlotIndex = (activeSlotIndex + 1) % 10; + this.setActiveSlotIndex((activeSlotIndex + 1) % 10); } else if (event.deltaY < 0) { - this.selfEntity.activeSlotIndex = (activeSlotIndex + 9) % 10; + this.setActiveSlotIndex((activeSlotIndex + 9) % 10); } } @@ -435,6 +448,12 @@ export class App extends decorate(class {}) { ReactDOM.render(DebugUiComponent, this.debugUiNode); } + setActiveSlotIndex(slotIndex) { + if (this.selfEntity) { + this.selfEntity.activeSlotIndex = slotIndex; + } + } + startProcessingInput() { const config = this.readConfig(); // Pointer input.