mirror of
https://github.com/tobspr/shapez.io.git
synced 2026-03-02 03:39:21 +00:00
Added setting to configure zoom / mouse wheel / touchpad sensitivity
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user