mirror of
https://github.com/tobspr/shapez.io.git
synced 2024-10-27 20:34:29 +00:00
Merge pull request #112 from mini-bomba/move-speed
Added movement speed setting
This commit is contained in:
commit
63568ffb2c
@ -901,8 +901,8 @@ export class Camera extends BasicSerializableObject {
|
|||||||
forceX += 1;
|
forceX += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.center.x += moveAmount * forceX;
|
this.center.x += moveAmount * forceX * this.root.app.settings.getMovementSpeed();
|
||||||
this.center.y += moveAmount * forceY;
|
this.center.y += moveAmount * forceY * this.root.app.settings.getMovementSpeed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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<BaseSetting>} */
|
/** @type {Array<BaseSetting>} */
|
||||||
export const allApplicationSettings = [
|
export const allApplicationSettings = [
|
||||||
new EnumSetting("language", {
|
new EnumSetting("language", {
|
||||||
@ -131,6 +158,14 @@ export const allApplicationSettings = [
|
|||||||
}),
|
}),
|
||||||
|
|
||||||
// GAME
|
// 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", {
|
new EnumSetting("theme", {
|
||||||
options: Object.keys(THEMES),
|
options: Object.keys(THEMES),
|
||||||
valueGetter: theme => theme,
|
valueGetter: theme => theme,
|
||||||
@ -176,6 +211,7 @@ class SettingsStorage {
|
|||||||
this.theme = "light";
|
this.theme = "light";
|
||||||
this.refreshRate = "60";
|
this.refreshRate = "60";
|
||||||
this.scrollWheelSensitivity = "regular";
|
this.scrollWheelSensitivity = "regular";
|
||||||
|
this.movementSpeed = "regular";
|
||||||
this.language = "auto-detect";
|
this.language = "auto-detect";
|
||||||
|
|
||||||
this.alwaysMultiplace = false;
|
this.alwaysMultiplace = false;
|
||||||
@ -263,6 +299,17 @@ export class ApplicationSettings extends ReadWriteProxy {
|
|||||||
return 1;
|
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() {
|
getIsFullScreen() {
|
||||||
return this.getAllSettings().fullscreen;
|
return this.getAllSettings().fullscreen;
|
||||||
}
|
}
|
||||||
@ -358,7 +405,7 @@ export class ApplicationSettings extends ReadWriteProxy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getCurrentVersion() {
|
getCurrentVersion() {
|
||||||
return 9;
|
return 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @param {{settings: SettingsStorage, version: number}} data */
|
/** @param {{settings: SettingsStorage, version: number}} data */
|
||||||
@ -390,6 +437,11 @@ export class ApplicationSettings extends ReadWriteProxy {
|
|||||||
data.version = 9;
|
data.version = 9;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (data.version < 10) {
|
||||||
|
data.settings.movementSpeed = "regular";
|
||||||
|
data.version = 10;
|
||||||
|
}
|
||||||
|
|
||||||
return ExplainedResult.good();
|
return ExplainedResult.good();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -609,6 +609,18 @@ settings:
|
|||||||
fast: Fast
|
fast: Fast
|
||||||
super_fast: Super 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:
|
language:
|
||||||
title: Language
|
title: Language
|
||||||
description: >-
|
description: >-
|
||||||
|
@ -619,6 +619,18 @@ settings:
|
|||||||
fast: Duża
|
fast: Duża
|
||||||
super_fast: Bardzo 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:
|
language:
|
||||||
title: Język
|
title: Język
|
||||||
description: >-
|
description: >-
|
||||||
|
Loading…
Reference in New Issue
Block a user