diff --git a/src/js/game/camera.js b/src/js/game/camera.js index 1a389cad..1125bf84 100644 --- a/src/js/game/camera.js +++ b/src/js/game/camera.js @@ -901,8 +901,8 @@ export class Camera extends BasicSerializableObject { forceX += 1; } - this.center.x += moveAmount * forceX; - this.center.y += moveAmount * forceY; + this.center.x += moveAmount * forceX * this.root.app.settings.getMovementSpeed(); + this.center.y += moveAmount * forceY * this.root.app.settings.getMovementSpeed(); } } } diff --git a/src/js/profile/application_settings.js b/src/js/profile/application_settings.js index 3b337b85..3a426377 100644 --- a/src/js/profile/application_settings.js +++ b/src/js/profile/application_settings.js @@ -62,6 +62,33 @@ export const scrollWheelSensitivities = [ }, ]; +export const movementSpeeds = [ + { + id: "super_slow", + multiplier: 0.25, + }, + { + id: "slow", + multiplier: 0.5, + }, + { + id: "regular", + multiplier: 1, + }, + { + id: "fast", + multiplier: 2, + }, + { + id: "super_fast", + multiplier: 4, + }, + { + id: "extremely_fast", + multiplier: 8, + }, +]; + /** @type {Array} */ export const allApplicationSettings = [ new EnumSetting("language", { @@ -131,6 +158,14 @@ export const allApplicationSettings = [ }), // GAME + new EnumSetting("movementSpeed", { + options: movementSpeeds.sort((a, b) => a.multiplier - b.multiplier), + valueGetter: multiplier => multiplier.id, + textGetter: multiplier => T.settings.labels.movementSpeed.speeds[multiplier.id], + category: categoryGame, + restartRequired: false, + changeCb: (app, id) => {}, + }), new EnumSetting("theme", { options: Object.keys(THEMES), valueGetter: theme => theme, @@ -176,6 +211,7 @@ class SettingsStorage { this.theme = "light"; this.refreshRate = "60"; this.scrollWheelSensitivity = "regular"; + this.movementSpeed = "regular"; this.language = "auto-detect"; this.alwaysMultiplace = false; @@ -263,6 +299,17 @@ export class ApplicationSettings extends ReadWriteProxy { return 1; } + getMovementSpeed() { + const id = this.getAllSettings().movementSpeed; + for (let i = 0; i < movementSpeeds.length; ++i) { + if (movementSpeeds[i].id === id) { + return movementSpeeds[i].multiplier; + } + } + logger.error("Unknown movement speed id:", id); + return 1; + } + getIsFullScreen() { return this.getAllSettings().fullscreen; } @@ -358,7 +405,7 @@ export class ApplicationSettings extends ReadWriteProxy { } getCurrentVersion() { - return 9; + return 10; } /** @param {{settings: SettingsStorage, version: number}} data */ @@ -390,6 +437,11 @@ export class ApplicationSettings extends ReadWriteProxy { data.version = 9; } + if (data.version < 10) { + data.settings.movementSpeed = "regular"; + data.version = 10; + } + return ExplainedResult.good(); } } diff --git a/translations/base-en.yaml b/translations/base-en.yaml index 4adee0bd..7430f7dd 100644 --- a/translations/base-en.yaml +++ b/translations/base-en.yaml @@ -609,6 +609,18 @@ settings: fast: Fast super_fast: Super fast + movementSpeed: + title: Movement speed + description: >- + Changes how fast the view moves when using the keyboard. + speeds: + super_slow: Super slow + slow: Slow + regular: Regular + fast: Fast + super_fast: Super Fast + extremely_fast: Extremely Fast + language: title: Language description: >- diff --git a/translations/base-pl.yaml b/translations/base-pl.yaml index 802bb697..24458891 100644 --- a/translations/base-pl.yaml +++ b/translations/base-pl.yaml @@ -619,6 +619,18 @@ settings: fast: Duża super_fast: Bardzo Duża + movementSpeed: + title: Prędkość poruszania + description: >- + Zmienia, jak szybko widok porusza się, używając skrótów klawiszowych. + speeds: + super_slow: Bardzo wolna + slow: Wolna + regular: Zwykła + fast: Szybka + super_fast: Bardzo szybka + extremely_fast: Ekstremalnie szybka + language: title: Język description: >-