Allow configuring autosave interval

This commit is contained in:
tobspr 2020-06-22 12:09:02 +02:00
parent dd97c9ab80
commit a8b37792e4
6 changed files with 107 additions and 6 deletions

View File

@ -269,7 +269,7 @@ gulp.task("build.prod", gulp.series("utils.cleanup", "step.prod.all", "step.post
// Builds everything (standalone-beta)
gulp.task(
"step.standalone-beta.code",
gulp.series("sounds.fullbuild", "translations.fullBuild", "js.standalone-beta")
gulp.series("sounds.fullbuildHQ", "translations.fullBuild", "js.standalone-beta")
);
gulp.task("step.standalone-beta.mainbuild", gulp.parallel("step.baseResources", "step.standalone-beta.code"));
gulp.task(
@ -284,7 +284,7 @@ gulp.task(
// Builds everything (standalone-prod)
gulp.task(
"step.standalone-prod.code",
gulp.series("sounds.fullbuild", "translations.fullBuild", "js.standalone-prod")
gulp.series("sounds.fullbuildHQ", "translations.fullBuild", "js.standalone-prod")
);
gulp.task("step.standalone-prod.mainbuild", gulp.parallel("step.baseResources", "step.standalone-prod.code"));
gulp.task(

View File

@ -40,6 +40,30 @@ function gulptasksSounds($, gulp, buildFolder) {
.pipe(gulp.dest(path.join(builtSoundsDir, "music")));
});
// Encodes the game music in high quality for the standalone
gulp.task("sounds.musicHQ", () => {
return gulp
.src([path.join(soundsDir, "music", "**", "*.wav"), path.join(soundsDir, "music", "**", "*.mp3")])
.pipe($.plumber())
.pipe(
$.cache(
$.fluentFfmpeg("mp3", function (cmd) {
return cmd
.audioBitrate(256)
.audioChannels(2)
.audioFrequency(44100)
.audioCodec("libmp3lame")
.audioFilters(["volume=0.15"]);
}),
{
name: "music-high-quality",
fileCache,
}
)
)
.pipe(gulp.dest(path.join(builtSoundsDir, "music")));
});
// Encodes the ui sounds
gulp.task("sounds.sfxGenerateSprites", () => {
return gulp
@ -91,8 +115,10 @@ function gulptasksSounds($, gulp, buildFolder) {
});
gulp.task("sounds.buildall", gulp.parallel("sounds.music", "sounds.sfx"));
gulp.task("sounds.buildallHQ", gulp.parallel("sounds.musicHQ", "sounds.sfx"));
gulp.task("sounds.fullbuild", gulp.series("sounds.clear", "sounds.buildall", "sounds.copy"));
gulp.task("sounds.fullbuildHQ", gulp.series("sounds.clear", "sounds.buildallHQ", "sounds.copy"));
gulp.task("sounds.dev", gulp.series("sounds.buildall", "sounds.copy"));
}

View File

@ -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",

View File

@ -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:

View File

@ -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();
}
}

View File

@ -1 +1 @@
1.1.16
1.1.17