From ab7584d9e9c66a4d67bb97f1c37ae83da391d405 Mon Sep 17 00:00:00 2001 From: Dimava Date: Wed, 27 May 2020 15:25:30 +0300 Subject: [PATCH] Make ctrl/shift/alt keubindings changeable --- src/js/game/hud/parts/building_placer.js | 11 +++++++---- src/js/game/hud/parts/mass_selector.js | 4 ++-- src/js/game/key_action_mapper.js | 10 +++++----- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/js/game/hud/parts/building_placer.js b/src/js/game/hud/parts/building_placer.js index fa477dbd..b7330130 100644 --- a/src/js/game/hud/parts/building_placer.js +++ b/src/js/game/hud/parts/building_placer.js @@ -159,14 +159,14 @@ export class HUDBuildingPlacer extends BaseHUDPart { if ( metaBuilding && metaBuilding.getRotateAutomaticallyWhilePlacing(this.currentVariant.get()) && - !this.root.app.inputMgr.ctrlIsDown + !this.root.keyMapper.getBinding(KEYMAPPINGS.placementModifiers.placementDisableAutoOrientation).currentlyDown ) { const delta = newPos.sub(oldPos); const angleDeg = Math_degrees(delta.angle()); this.currentBaseRotation = (Math.round(angleDeg / 90) * 90 + 360) % 360; // Holding alt inverts the placement - if (this.root.app.inputMgr.altIsDown) { + if (this.root.keyMapper.getBinding(KEYMAPPINGS.placementModifiers.placeInverse).currentlyDown) { this.currentBaseRotation = (180 + this.currentBaseRotation) % 360; } } @@ -464,13 +464,16 @@ export class HUDBuildingPlacer extends BaseHUDPart { ) { // Succesfully placed - if (metaBuilding.getFlipOrientationAfterPlacement() && !this.root.app.inputMgr.ctrlIsDown) { + if ( + metaBuilding.getFlipOrientationAfterPlacement() && + !this.root.keyMapper.getBinding(KEYMAPPINGS.placementModifiers.placementDisableAutoOrientation).currentlyDown + ) { this.currentBaseRotation = (180 + this.currentBaseRotation) % 360; } if ( !metaBuilding.getStayInPlacementMode() && - !this.root.app.inputMgr.shiftIsDown && + !this.root.keyMapper.getBinding(KEYMAPPINGS.placementModifiers.placeMultiple).currentlyDown && !this.root.app.settings.getAllSettings().alwaysMultiplace ) { // Stop placement diff --git a/src/js/game/hud/parts/mass_selector.js b/src/js/game/hud/parts/mass_selector.js index ddcf9117..79c119b2 100644 --- a/src/js/game/hud/parts/mass_selector.js +++ b/src/js/game/hud/parts/mass_selector.js @@ -89,7 +89,7 @@ export class HUDMassSelector extends BaseHUDPart { * @param {enumMouseButton} mouseButton */ onMouseDown(pos, mouseButton) { - if (!this.root.app.inputMgr.ctrlIsDown) { + if (!this.root.keyMapper.getBinding(KEYMAPPINGS.massSelect.massSelectStart).currentlyDown) { return; } @@ -97,7 +97,7 @@ export class HUDMassSelector extends BaseHUDPart { return; } - if (!this.root.app.inputMgr.shiftIsDown) { + if (!this.root.keyMapper.getBinding(KEYMAPPINGS.massSelect.massSelectSelectMultiple).currentlyDown) { // Start new selection this.entityUidsMarkedForDeletion = new Set(); } diff --git a/src/js/game/key_action_mapper.js b/src/js/game/key_action_mapper.js index 9ab089c3..2423cdb4 100644 --- a/src/js/game/key_action_mapper.js +++ b/src/js/game/key_action_mapper.js @@ -58,15 +58,15 @@ export const KEYMAPPINGS = { }, massSelect: { - massSelectStart: { keyCode: 17, builtin: true }, // CTRL - massSelectSelectMultiple: { keyCode: 16, builtin: true }, // SHIFT + massSelectStart: { keyCode: 17 }, // CTRL + massSelectSelectMultiple: { keyCode: 16 }, // SHIFT confirmMassDelete: { keyCode: key("X") }, }, placementModifiers: { - placementDisableAutoOrientation: { keyCode: 17, builtin: true }, // CTRL - placeMultiple: { keyCode: 16, builtin: true }, // SHIFT - placeInverse: { keyCode: 18, builtin: true }, // ALT + placementDisableAutoOrientation: { keyCode: 17 }, // CTRL + placeMultiple: { keyCode: 16 }, // SHIFT + placeInverse: { keyCode: 18 }, // ALT }, };