From 479c899a8ee1da6e474769c9178377404a80a45e Mon Sep 17 00:00:00 2001 From: David Triphon Date: Sun, 19 Jul 2020 15:02:31 -0700 Subject: [PATCH] Attempted to migrate middle click to pan only and away from the main click code. Turning on setting breaks camera panning. Unsure about the correctness of the change. Still learning the code org. --- src/js/game/camera.js | 11 +++++------ src/js/profile/application_settings.js | 4 ++-- translations/base-en.yaml | 6 +++--- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/js/game/camera.js b/src/js/game/camera.js index 234214af..fad36415 100644 --- a/src/js/game/camera.js +++ b/src/js/game/camera.js @@ -437,12 +437,8 @@ export class Camera extends BasicSerializableObject { return; } - const middleMousePressed = event.button === 1 && event.buttons === 4; this.touchPostMoveVelocity = new Vector(0, 0); - if ( - event.button === 0 || - (middleMousePressed && this.root.app.settings.getSetting("middleMouseScroll")) - ) { + if (event.button === 0) { this.combinedSingleTouchStartHandler(event.clientX, event.clientY); } else if (event.button === 1) { this.downPreHandler.dispatch(new Vector(event.clientX, event.clientY), enumMouseButton.middle); @@ -466,7 +462,10 @@ export class Camera extends BasicSerializableObject { return; } - if (event.button === 0) { + if ( + (!this.root.app.settings.getSetting("middleMousePan") && event.button === 0) || + (this.root.app.settings.getSetting("middleMousePan") && event.button === 1) + ) { this.combinedSingleTouchMoveHandler(event.clientX, event.clientY); } diff --git a/src/js/profile/application_settings.js b/src/js/profile/application_settings.js index ad037f02..8421bb97 100644 --- a/src/js/profile/application_settings.js +++ b/src/js/profile/application_settings.js @@ -252,7 +252,7 @@ export const allApplicationSettings = [ new BoolSetting("compactBuildingInfo", categoryGame, (app, value) => {}), new BoolSetting("disableCutDeleteWarnings", categoryGame, (app, value) => {}), new BoolSetting("rotationByBuilding", categoryGame, (app, value) => {}), - new BoolSetting("middleMouseScroll", categoryGame, (app, value) => {}), + new BoolSetting("middleMousePan", categoryGame, (app, value) => {}), ]; export function getApplicationSettingById(id) { @@ -280,7 +280,7 @@ class SettingsStorage { this.compactBuildingInfo = false; this.disableCutDeleteWarnings = false; this.rotationByBuilding = true; - this.middleMouseScroll = false; + this.middleMousePan = false; this.enableColorBlindHelper = false; diff --git a/translations/base-en.yaml b/translations/base-en.yaml index 4daba3e9..fb5b7abf 100644 --- a/translations/base-en.yaml +++ b/translations/base-en.yaml @@ -774,10 +774,10 @@ settings: description: >- Disables the warning dialogs brought up when cutting/deleting more than 100 entities. - middleMouseScroll: - title: Middle mouse scroll + middleMousePan: + title: Pan camera with middle click description: >- - Allows for scrolling with the middle mouse button in addition to left click. + Click with the middle mouse button instead of left click to pan the camera. Allows panning camera while a building is selected. keybindings: title: Keybindings