Added setting to configure zoom / mouse wheel / touchpad sensitivity

pull/60/head
tobspr 4 years ago
parent b963b48df5
commit 8c85018352

@ -3,6 +3,7 @@ export const CHANGELOG = [
version: "1.1.3", version: "1.1.3",
date: "unreleased", date: "unreleased",
entries: [ entries: [
"Added setting to configure zoom / mouse wheel / touchpad sensitivity",
"Allow binding mouse buttons to actions (by Dimava)", "Allow binding mouse buttons to actions (by Dimava)",
"Fix belts being too slow when copied via blueprint (by Dimava)", "Fix belts being too slow when copied via blueprint (by Dimava)",
], ],

@ -105,7 +105,7 @@ export const globalConfig = {
// testAds: true, // testAds: true,
// disableMapOverview: true, // disableMapOverview: true,
disableTutorialHints: true, disableTutorialHints: true,
// disableUpgradeNotification: true, disableUpgradeNotification: true,
// instantBelts: true, // instantBelts: true,
// instantProcessors: true, // instantProcessors: true,
// instantMiners: true, // instantMiners: true,

@ -503,7 +503,7 @@ export class Camera extends BasicSerializableObject {
// event.stopPropagation(); // 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(delta), "Got invalid delta in mouse wheel event: " + event.deltaY);
assert(Number.isFinite(this.zoomLevel), "Got invalid zoom level *before* wheel: " + this.zoomLevel); assert(Number.isFinite(this.zoomLevel), "Got invalid zoom level *before* wheel: " + this.zoomLevel);
this.zoomLevel *= 1 + delta; this.zoomLevel *= 1 + delta;

@ -8,6 +8,7 @@ import { createLogger } from "../core/logging";
import { ExplainedResult } from "../core/explained_result"; import { ExplainedResult } from "../core/explained_result";
import { THEMES, THEME, applyGameTheme } from "../game/theme"; import { THEMES, THEME, applyGameTheme } from "../game/theme";
import { IS_DEMO } from "../core/config"; import { IS_DEMO } from "../core/config";
import { T } from "../translations";
const logger = createLogger("application_settings"); const logger = createLogger("application_settings");
@ -18,27 +19,45 @@ export const uiScales = [
{ {
id: "super_small", id: "super_small",
size: 0.6, size: 0.6,
label: "Super small",
}, },
{ {
id: "small", id: "small",
size: 0.8, size: 0.8,
label: "Small",
}, },
{ {
id: "regular", id: "regular",
size: 1, size: 1,
label: "Regular",
}, },
{ {
id: "large", id: "large",
size: 1.2, size: 1.2,
label: "Large",
}, },
{ {
id: "huge", id: "huge",
size: 1.4, 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", { new EnumSetting("uiScale", {
options: uiScales.sort((a, b) => a.size - b.size), options: uiScales.sort((a, b) => a.size - b.size),
valueGetter: scale => scale.id, valueGetter: scale => scale.id,
textGetter: scale => scale.label, textGetter: scale => T.settings.labels.uiScale.scales[scale.id],
category: categoryApp, category: categoryApp,
restartRequired: false, restartRequired: false,
changeCb: changeCb:
@ -56,6 +75,7 @@ export const allApplicationSettings = [
*/ */
(app, id) => app.updateAfterUiScaleChanged(), (app, id) => app.updateAfterUiScaleChanged(),
}), }),
new BoolSetting( new BoolSetting(
"fullscreen", "fullscreen",
categoryApp, categoryApp,
@ -86,6 +106,18 @@ export const allApplicationSettings = [
*/ */
(app, value) => app.sound.setMusicMuted(value) (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 // GAME
new EnumSetting("theme", { new EnumSetting("theme", {
@ -132,6 +164,7 @@ class SettingsStorage {
this.musicMuted = false; this.musicMuted = false;
this.theme = "light"; this.theme = "light";
this.refreshRate = "60"; this.refreshRate = "60";
this.scrollWheelSensitivity = "regular";
this.alwaysMultiplace = false; this.alwaysMultiplace = false;
this.offerHints = true; this.offerHints = true;
@ -207,6 +240,17 @@ export class ApplicationSettings extends ReadWriteProxy {
return 1; 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() { getIsFullScreen() {
return this.getAllSettings().fullscreen; return this.getAllSettings().fullscreen;
} }
@ -293,7 +337,7 @@ export class ApplicationSettings extends ReadWriteProxy {
} }
getCurrentVersion() { getCurrentVersion() {
return 7; return 8;
} }
/** @param {{settings: SettingsStorage, version: number}} data */ /** @param {{settings: SettingsStorage, version: number}} data */
@ -315,6 +359,11 @@ export class ApplicationSettings extends ReadWriteProxy {
data.version = 7; data.version = 7;
} }
if (data.version < 8) {
data.settings.scrollWheelSensitivity = "regular";
data.version = 8;
}
return ExplainedResult.good(); return ExplainedResult.good();
} }
} }

@ -127,7 +127,7 @@ dialogs:
editKeybinding: editKeybinding:
title: Change Keybinding 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: resetKeybindingsConfirmation:
title: Reset keybindings title: Reset keybindings
@ -511,6 +511,23 @@ settings:
title: Interface scale title: Interface scale
description: >- 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. 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: fullscreen:
title: Fullscreen title: Fullscreen

Loading…
Cancel
Save