From 487a99bb5661d5a614f332f7fd9aaa0e83c2f948 Mon Sep 17 00:00:00 2001 From: Jaysc Date: Fri, 12 Jun 2020 18:55:35 +0100 Subject: [PATCH 1/4] added fastpan feature --- src/js/game/camera.js | 8 ++++++-- src/js/game/key_action_mapper.js | 1 + src/js/profile/application_settings.js | 7 +++++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/js/game/camera.js b/src/js/game/camera.js index 1125bf84..9503c839 100644 --- a/src/js/game/camera.js +++ b/src/js/game/camera.js @@ -901,8 +901,12 @@ export class Camera extends BasicSerializableObject { forceX += 1; } - this.center.x += moveAmount * forceX * this.root.app.settings.getMovementSpeed(); - this.center.y += moveAmount * forceY * this.root.app.settings.getMovementSpeed(); + let movementSpeed = this.root.app.settings.getMovementSpeed( + actionMapper.getBinding(KEYMAPPINGS.navigation.fastPan).isCurrentlyPressed() + ); + + this.center.x += moveAmount * forceX * movementSpeed; + this.center.y += moveAmount * forceY * movementSpeed; } } } diff --git a/src/js/game/key_action_mapper.js b/src/js/game/key_action_mapper.js index 58077f01..ea886a7a 100644 --- a/src/js/game/key_action_mapper.js +++ b/src/js/game/key_action_mapper.js @@ -36,6 +36,7 @@ export const KEYMAPPINGS = { centerMap: { keyCode: 32 }, // SPACE mapZoomIn: { keyCode: 187, repeated: true }, // "+" mapZoomOut: { keyCode: 189, repeated: true }, // "-" + fastPan: { keyCode: 16 }, //shift createMarker: { keyCode: key("M") }, }, diff --git a/src/js/profile/application_settings.js b/src/js/profile/application_settings.js index 87c2c244..5a3a6cbc 100644 --- a/src/js/profile/application_settings.js +++ b/src/js/profile/application_settings.js @@ -302,11 +302,14 @@ export class ApplicationSettings extends ReadWriteProxy { return 1; } - getMovementSpeed() { + /** + * @param {boolean} fastpan + */ + getMovementSpeed(fastpan = false) { const id = this.getAllSettings().movementSpeed; for (let i = 0; i < movementSpeeds.length; ++i) { if (movementSpeeds[i].id === id) { - return movementSpeeds[i].multiplier; + return movementSpeeds[fastpan && i + 1 < movementSpeeds.length ? i + 1 : i].multiplier; } } logger.error("Unknown movement speed id:", id); From 8a726f99b604412f38fd7a497caabfe7602df0ed Mon Sep 17 00:00:00 2001 From: Jaysc Date: Sat, 13 Jun 2020 14:14:35 +0100 Subject: [PATCH 2/4] Changed fastpan to mapMoveFaster and translation --- src/js/game/camera.js | 2 +- src/js/game/key_action_mapper.js | 2 +- src/js/profile/application_settings.js | 6 +++--- translations/base-en.yaml | 1 + 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/js/game/camera.js b/src/js/game/camera.js index 9503c839..efb5d15b 100644 --- a/src/js/game/camera.js +++ b/src/js/game/camera.js @@ -902,7 +902,7 @@ export class Camera extends BasicSerializableObject { } let movementSpeed = this.root.app.settings.getMovementSpeed( - actionMapper.getBinding(KEYMAPPINGS.navigation.fastPan).isCurrentlyPressed() + actionMapper.getBinding(KEYMAPPINGS.navigation.mapMoveFaster).isCurrentlyPressed() ); this.center.x += moveAmount * forceX * movementSpeed; diff --git a/src/js/game/key_action_mapper.js b/src/js/game/key_action_mapper.js index ea886a7a..2f98c84e 100644 --- a/src/js/game/key_action_mapper.js +++ b/src/js/game/key_action_mapper.js @@ -32,11 +32,11 @@ export const KEYMAPPINGS = { mapMoveRight: { keyCode: key("D") }, mapMoveDown: { keyCode: key("S") }, mapMoveLeft: { keyCode: key("A") }, + mapMoveFaster: { keyCode: 16 }, //shift centerMap: { keyCode: 32 }, // SPACE mapZoomIn: { keyCode: 187, repeated: true }, // "+" mapZoomOut: { keyCode: 189, repeated: true }, // "-" - fastPan: { keyCode: 16 }, //shift createMarker: { keyCode: key("M") }, }, diff --git a/src/js/profile/application_settings.js b/src/js/profile/application_settings.js index 5a3a6cbc..827c22a5 100644 --- a/src/js/profile/application_settings.js +++ b/src/js/profile/application_settings.js @@ -303,13 +303,13 @@ export class ApplicationSettings extends ReadWriteProxy { } /** - * @param {boolean} fastpan + * @param {boolean} moveFaster */ - getMovementSpeed(fastpan = false) { + getMovementSpeed(moveFaster = false) { const id = this.getAllSettings().movementSpeed; for (let i = 0; i < movementSpeeds.length; ++i) { if (movementSpeeds[i].id === id) { - return movementSpeeds[fastpan && i + 1 < movementSpeeds.length ? i + 1 : i].multiplier; + return movementSpeeds[moveFaster && i + 1 < movementSpeeds.length ? i + 1 : i].multiplier; } } logger.error("Unknown movement speed id:", id); diff --git a/translations/base-en.yaml b/translations/base-en.yaml index 7430f7dd..f0283780 100644 --- a/translations/base-en.yaml +++ b/translations/base-en.yaml @@ -687,6 +687,7 @@ keybindings: mapMoveRight: Move Right mapMoveDown: Move Down mapMoveLeft: Move Left + mapMoveFaster: Move Faster centerMap: Center Map mapZoomIn: Zoom in From 7552d23f407722da8a27d03fc065f2dd8eef3e05 Mon Sep 17 00:00:00 2001 From: Jaysc Date: Sat, 13 Jun 2020 21:40:20 +0100 Subject: [PATCH 3/4] multiply by 2 logic --- src/js/profile/application_settings.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/profile/application_settings.js b/src/js/profile/application_settings.js index 827c22a5..8807758b 100644 --- a/src/js/profile/application_settings.js +++ b/src/js/profile/application_settings.js @@ -309,7 +309,7 @@ export class ApplicationSettings extends ReadWriteProxy { const id = this.getAllSettings().movementSpeed; for (let i = 0; i < movementSpeeds.length; ++i) { if (movementSpeeds[i].id === id) { - return movementSpeeds[moveFaster && i + 1 < movementSpeeds.length ? i + 1 : i].multiplier; + return movementSpeeds[i].multiplier * (moveFaster ? 2 : 1); } } logger.error("Unknown movement speed id:", id); From 5de2c2de94f32a3e10c728e2514635d0a10d0467 Mon Sep 17 00:00:00 2001 From: Jaysc Date: Sun, 14 Jun 2020 14:16:37 +0100 Subject: [PATCH 4/4] Removed logic from application_settings --- src/js/game/camera.js | 6 +++--- src/js/profile/application_settings.js | 7 ++----- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/js/game/camera.js b/src/js/game/camera.js index efb5d15b..6aefeae9 100644 --- a/src/js/game/camera.js +++ b/src/js/game/camera.js @@ -901,9 +901,9 @@ export class Camera extends BasicSerializableObject { forceX += 1; } - let movementSpeed = this.root.app.settings.getMovementSpeed( - actionMapper.getBinding(KEYMAPPINGS.navigation.mapMoveFaster).isCurrentlyPressed() - ); + let movementSpeed = + this.root.app.settings.getMovementSpeed() * + (actionMapper.getBinding(KEYMAPPINGS.navigation.mapMoveFaster).isCurrentlyPressed() ? 2 : 1); this.center.x += moveAmount * forceX * movementSpeed; this.center.y += moveAmount * forceY * movementSpeed; diff --git a/src/js/profile/application_settings.js b/src/js/profile/application_settings.js index 8807758b..87c2c244 100644 --- a/src/js/profile/application_settings.js +++ b/src/js/profile/application_settings.js @@ -302,14 +302,11 @@ export class ApplicationSettings extends ReadWriteProxy { return 1; } - /** - * @param {boolean} moveFaster - */ - getMovementSpeed(moveFaster = false) { + getMovementSpeed() { const id = this.getAllSettings().movementSpeed; for (let i = 0; i < movementSpeeds.length; ++i) { if (movementSpeeds[i].id === id) { - return movementSpeeds[i].multiplier * (moveFaster ? 2 : 1); + return movementSpeeds[i].multiplier; } } logger.error("Unknown movement speed id:", id);