diff --git a/src/js/changelog.js b/src/js/changelog.js index dd219290..215e7dcf 100644 --- a/src/js/changelog.js +++ b/src/js/changelog.js @@ -3,6 +3,7 @@ export const CHANGELOG = [ version: "1.1.3", date: "unreleased", entries: [ + "Added setting to configure zoom / mouse wheel / touchpad sensitivity", "Allow binding mouse buttons to actions (by Dimava)", "Fix belts being too slow when copied via blueprint (by Dimava)", ], diff --git a/src/js/core/config.js b/src/js/core/config.js index 05555793..c84dee3a 100644 --- a/src/js/core/config.js +++ b/src/js/core/config.js @@ -105,7 +105,7 @@ export const globalConfig = { // testAds: true, // disableMapOverview: true, disableTutorialHints: true, - // disableUpgradeNotification: true, + disableUpgradeNotification: true, // instantBelts: true, // instantProcessors: true, // instantMiners: true, diff --git a/src/js/game/camera.js b/src/js/game/camera.js index f4441ad7..1a389cad 100644 --- a/src/js/game/camera.js +++ b/src/js/game/camera.js @@ -503,7 +503,7 @@ export class Camera extends BasicSerializableObject { // event.stopPropagation(); } - const delta = Math.sign(event.deltaY) * -0.15; + const delta = Math.sign(event.deltaY) * -0.15 * this.root.app.settings.getScrollWheelSensitivity(); assert(Number.isFinite(delta), "Got invalid delta in mouse wheel event: " + event.deltaY); assert(Number.isFinite(this.zoomLevel), "Got invalid zoom level *before* wheel: " + this.zoomLevel); this.zoomLevel *= 1 + delta; diff --git a/src/js/profile/application_settings.js b/src/js/profile/application_settings.js index 96cbed2f..ff0051f1 100644 --- a/src/js/profile/application_settings.js +++ b/src/js/profile/application_settings.js @@ -8,6 +8,7 @@ import { createLogger } from "../core/logging"; import { ExplainedResult } from "../core/explained_result"; import { THEMES, THEME, applyGameTheme } from "../game/theme"; import { IS_DEMO } from "../core/config"; +import { T } from "../translations"; const logger = createLogger("application_settings"); @@ -18,27 +19,45 @@ export const uiScales = [ { id: "super_small", size: 0.6, - label: "Super small", }, { id: "small", size: 0.8, - label: "Small", }, { id: "regular", size: 1, - label: "Regular", }, { id: "large", size: 1.2, - label: "Large", }, { id: "huge", size: 1.4, - label: "Huge", + }, +]; + +export const scrollWheelSensitivities = [ + { + id: "super_slow", + scale: 0.25, + }, + { + id: "slow", + scale: 0.5, + }, + { + id: "regular", + scale: 1, + }, + { + id: "fast", + scale: 2, + }, + { + id: "super_fast", + scale: 4, }, ]; @@ -47,7 +66,7 @@ export const allApplicationSettings = [ new EnumSetting("uiScale", { options: uiScales.sort((a, b) => a.size - b.size), valueGetter: scale => scale.id, - textGetter: scale => scale.label, + textGetter: scale => T.settings.labels.uiScale.scales[scale.id], category: categoryApp, restartRequired: false, changeCb: @@ -56,6 +75,7 @@ export const allApplicationSettings = [ */ (app, id) => app.updateAfterUiScaleChanged(), }), + new BoolSetting( "fullscreen", categoryApp, @@ -86,6 +106,18 @@ export const allApplicationSettings = [ */ (app, value) => app.sound.setMusicMuted(value) ), + new EnumSetting("scrollWheelSensitivity", { + options: scrollWheelSensitivities.sort((a, b) => a.scale - b.scale), + valueGetter: scale => scale.id, + textGetter: scale => T.settings.labels.scrollWheelSensitivity.sensitivity[scale.id], + category: categoryApp, + restartRequired: false, + changeCb: + /** + * @param {Application} app + */ + (app, id) => app.updateAfterUiScaleChanged(), + }), // GAME new EnumSetting("theme", { @@ -132,6 +164,7 @@ class SettingsStorage { this.musicMuted = false; this.theme = "light"; this.refreshRate = "60"; + this.scrollWheelSensitivity = "regular"; this.alwaysMultiplace = false; this.offerHints = true; @@ -207,6 +240,17 @@ export class ApplicationSettings extends ReadWriteProxy { return 1; } + getScrollWheelSensitivity() { + const id = this.getAllSettings().scrollWheelSensitivity; + for (let i = 0; i < scrollWheelSensitivities.length; ++i) { + if (scrollWheelSensitivities[i].id === id) { + return scrollWheelSensitivities[i].scale; + } + } + logger.error("Unknown scroll wheel sensitivity id:", id); + return 1; + } + getIsFullScreen() { return this.getAllSettings().fullscreen; } @@ -293,7 +337,7 @@ export class ApplicationSettings extends ReadWriteProxy { } getCurrentVersion() { - return 7; + return 8; } /** @param {{settings: SettingsStorage, version: number}} data */ @@ -315,6 +359,11 @@ export class ApplicationSettings extends ReadWriteProxy { data.version = 7; } + if (data.version < 8) { + data.settings.scrollWheelSensitivity = "regular"; + data.version = 8; + } + return ExplainedResult.good(); } } diff --git a/translations/base-en.yaml b/translations/base-en.yaml index 9940b0b5..e861b773 100644 --- a/translations/base-en.yaml +++ b/translations/base-en.yaml @@ -127,7 +127,7 @@ dialogs: editKeybinding: title: Change Keybinding - desc: Press the key you want to assign, or escape to cancel. + desc: Press the key or mouse button you want to assign, or escape to cancel. resetKeybindingsConfirmation: title: Reset keybindings @@ -511,6 +511,23 @@ settings: title: Interface scale description: >- Changes the size of the user interface. The interface will still scale based on your device resolution, but this setting controls the amount of scale. + scales: + super_small: Super small + small: Small + regular: Regular + large: Large + huge: Huge + + scrollWheelSensitivity: + title: Zoom sensitivity + description: >- + Changes how sensitive the zoom is (Either mouse wheel or trackpad). + sensitivity: + super_slow: Super slow + slow: Slow + regular: Regular + fast: Fast + super_fast: Super fast fullscreen: title: Fullscreen