mirror of
https://github.com/tobspr/shapez.io.git
synced 2026-03-02 03:39:21 +00:00
Allow configuring autosave interval
This commit is contained in:
@@ -1,4 +1,15 @@
|
||||
export const CHANGELOG = [
|
||||
{
|
||||
version: "1.1.17",
|
||||
date: "unreleased",
|
||||
entries: [
|
||||
"Allow configuring autosave interval and disabling it in the settings",
|
||||
"The soundtrack now has a higher quality on the standalone version than the web version",
|
||||
"Add setting to disable cut/delete warnings (by hexy)",
|
||||
"Fix bug where belts in blueprints don't orient correctly (by hexy)",
|
||||
"Update tutorial image for tier 2 tunnels to explain mix/match (by jimmyshadow1)",
|
||||
],
|
||||
},
|
||||
{
|
||||
version: "1.1.16",
|
||||
date: "21.06.2020",
|
||||
|
||||
@@ -47,10 +47,16 @@ export class AutomaticSave {
|
||||
return;
|
||||
}
|
||||
|
||||
const saveInterval = this.root.app.settings.getAutosaveIntervalSeconds();
|
||||
if (!saveInterval) {
|
||||
// Disabled
|
||||
return;
|
||||
}
|
||||
|
||||
// Check when the last save was, but make sure that if it fails, we don't spam
|
||||
const lastSaveTime = Math_max(this.lastSaveAttempt, this.root.savegame.getRealLastUpdate());
|
||||
|
||||
let secondsSinceLastSave = (Date.now() - lastSaveTime) / 1000.0;
|
||||
const secondsSinceLastSave = (Date.now() - lastSaveTime) / 1000.0;
|
||||
let shouldSave = false;
|
||||
|
||||
switch (this.saveImportance) {
|
||||
@@ -61,7 +67,7 @@ export class AutomaticSave {
|
||||
|
||||
case enumSavePriority.regular:
|
||||
// Could determine if there is a good / bad point here
|
||||
shouldSave = secondsSinceLastSave > MIN_INTERVAL_SECS;
|
||||
shouldSave = secondsSinceLastSave > saveInterval;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
@@ -89,6 +89,33 @@ export const movementSpeeds = [
|
||||
},
|
||||
];
|
||||
|
||||
export const autosaveIntervals = [
|
||||
{
|
||||
id: "one_minute",
|
||||
seconds: 60,
|
||||
},
|
||||
{
|
||||
id: "two_minutes",
|
||||
seconds: 120,
|
||||
},
|
||||
{
|
||||
id: "five_minutes",
|
||||
seconds: 5 * 60,
|
||||
},
|
||||
{
|
||||
id: "ten_minutes",
|
||||
seconds: 10 * 60,
|
||||
},
|
||||
{
|
||||
id: "twenty_minutes",
|
||||
seconds: 20 * 60,
|
||||
},
|
||||
{
|
||||
id: "disabled",
|
||||
seconds: null,
|
||||
},
|
||||
];
|
||||
|
||||
/** @type {Array<BaseSetting>} */
|
||||
export const allApplicationSettings = [
|
||||
new EnumSetting("language", {
|
||||
@@ -165,6 +192,19 @@ export const allApplicationSettings = [
|
||||
enabled: !IS_DEMO,
|
||||
}),
|
||||
|
||||
new EnumSetting("autosaveInterval", {
|
||||
options: autosaveIntervals,
|
||||
valueGetter: interval => interval.id,
|
||||
textGetter: interval => T.settings.labels.autosaveInterval.intervals[interval.id],
|
||||
category: categoryGame,
|
||||
restartRequired: false,
|
||||
changeCb:
|
||||
/**
|
||||
* @param {Application} app
|
||||
*/
|
||||
(app, id) => null,
|
||||
}),
|
||||
|
||||
new EnumSetting("refreshRate", {
|
||||
options: ["60", "100", "144", "165", "250", "500"],
|
||||
valueGetter: rate => rate,
|
||||
@@ -220,6 +260,7 @@ class SettingsStorage {
|
||||
this.scrollWheelSensitivity = "regular";
|
||||
this.movementSpeed = "regular";
|
||||
this.language = "auto-detect";
|
||||
this.autosaveInterval = "two_minutes";
|
||||
|
||||
this.alwaysMultiplace = false;
|
||||
this.offerHints = true;
|
||||
@@ -321,6 +362,17 @@ export class ApplicationSettings extends ReadWriteProxy {
|
||||
return 1;
|
||||
}
|
||||
|
||||
getAutosaveIntervalSeconds() {
|
||||
const id = this.getAllSettings().autosaveInterval;
|
||||
for (let i = 0; i < autosaveIntervals.length; ++i) {
|
||||
if (autosaveIntervals[i].id === id) {
|
||||
return autosaveIntervals[i].seconds;
|
||||
}
|
||||
}
|
||||
logger.error("Unknown autosave interval id:", id);
|
||||
return 120;
|
||||
}
|
||||
|
||||
getIsFullScreen() {
|
||||
return this.getAllSettings().fullscreen;
|
||||
}
|
||||
@@ -416,7 +468,7 @@ export class ApplicationSettings extends ReadWriteProxy {
|
||||
}
|
||||
|
||||
getCurrentVersion() {
|
||||
return 14;
|
||||
return 15;
|
||||
}
|
||||
|
||||
/** @param {{settings: SettingsStorage, version: number}} data */
|
||||
@@ -472,6 +524,12 @@ export class ApplicationSettings extends ReadWriteProxy {
|
||||
data.settings.disableCutDeleteWarnings = false;
|
||||
data.version = 14;
|
||||
}
|
||||
|
||||
if (data.version < 15) {
|
||||
data.settings.autosaveInterval = "two_minutes";
|
||||
data.version = 15;
|
||||
}
|
||||
|
||||
return ExplainedResult.good();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user