mirror of
https://github.com/tobspr/shapez.io.git
synced 2026-03-02 03:39:21 +00:00
Merge pull request #112 from mini-bomba/move-speed
Added movement speed setting
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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>} */
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user