mirror of
https://github.com/tobspr/shapez.io.git
synced 2024-10-27 20:34:29 +00:00
Allow configuring autosave interval
This commit is contained in:
parent
dd97c9ab80
commit
a8b37792e4
@ -269,7 +269,7 @@ gulp.task("build.prod", gulp.series("utils.cleanup", "step.prod.all", "step.post
|
|||||||
// Builds everything (standalone-beta)
|
// Builds everything (standalone-beta)
|
||||||
gulp.task(
|
gulp.task(
|
||||||
"step.standalone-beta.code",
|
"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("step.standalone-beta.mainbuild", gulp.parallel("step.baseResources", "step.standalone-beta.code"));
|
||||||
gulp.task(
|
gulp.task(
|
||||||
@ -284,7 +284,7 @@ gulp.task(
|
|||||||
// Builds everything (standalone-prod)
|
// Builds everything (standalone-prod)
|
||||||
gulp.task(
|
gulp.task(
|
||||||
"step.standalone-prod.code",
|
"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("step.standalone-prod.mainbuild", gulp.parallel("step.baseResources", "step.standalone-prod.code"));
|
||||||
gulp.task(
|
gulp.task(
|
||||||
|
@ -40,6 +40,30 @@ function gulptasksSounds($, gulp, buildFolder) {
|
|||||||
.pipe(gulp.dest(path.join(builtSoundsDir, "music")));
|
.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
|
// Encodes the ui sounds
|
||||||
gulp.task("sounds.sfxGenerateSprites", () => {
|
gulp.task("sounds.sfxGenerateSprites", () => {
|
||||||
return gulp
|
return gulp
|
||||||
@ -91,8 +115,10 @@ function gulptasksSounds($, gulp, buildFolder) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
gulp.task("sounds.buildall", gulp.parallel("sounds.music", "sounds.sfx"));
|
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.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"));
|
gulp.task("sounds.dev", gulp.series("sounds.buildall", "sounds.copy"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,15 @@
|
|||||||
export const CHANGELOG = [
|
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",
|
version: "1.1.16",
|
||||||
date: "21.06.2020",
|
date: "21.06.2020",
|
||||||
|
@ -47,10 +47,16 @@ export class AutomaticSave {
|
|||||||
return;
|
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
|
// 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());
|
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;
|
let shouldSave = false;
|
||||||
|
|
||||||
switch (this.saveImportance) {
|
switch (this.saveImportance) {
|
||||||
@ -61,7 +67,7 @@ export class AutomaticSave {
|
|||||||
|
|
||||||
case enumSavePriority.regular:
|
case enumSavePriority.regular:
|
||||||
// Could determine if there is a good / bad point here
|
// Could determine if there is a good / bad point here
|
||||||
shouldSave = secondsSinceLastSave > MIN_INTERVAL_SECS;
|
shouldSave = secondsSinceLastSave > saveInterval;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
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>} */
|
/** @type {Array<BaseSetting>} */
|
||||||
export const allApplicationSettings = [
|
export const allApplicationSettings = [
|
||||||
new EnumSetting("language", {
|
new EnumSetting("language", {
|
||||||
@ -165,6 +192,19 @@ export const allApplicationSettings = [
|
|||||||
enabled: !IS_DEMO,
|
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", {
|
new EnumSetting("refreshRate", {
|
||||||
options: ["60", "100", "144", "165", "250", "500"],
|
options: ["60", "100", "144", "165", "250", "500"],
|
||||||
valueGetter: rate => rate,
|
valueGetter: rate => rate,
|
||||||
@ -220,6 +260,7 @@ class SettingsStorage {
|
|||||||
this.scrollWheelSensitivity = "regular";
|
this.scrollWheelSensitivity = "regular";
|
||||||
this.movementSpeed = "regular";
|
this.movementSpeed = "regular";
|
||||||
this.language = "auto-detect";
|
this.language = "auto-detect";
|
||||||
|
this.autosaveInterval = "two_minutes";
|
||||||
|
|
||||||
this.alwaysMultiplace = false;
|
this.alwaysMultiplace = false;
|
||||||
this.offerHints = true;
|
this.offerHints = true;
|
||||||
@ -321,6 +362,17 @@ export class ApplicationSettings extends ReadWriteProxy {
|
|||||||
return 1;
|
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() {
|
getIsFullScreen() {
|
||||||
return this.getAllSettings().fullscreen;
|
return this.getAllSettings().fullscreen;
|
||||||
}
|
}
|
||||||
@ -416,7 +468,7 @@ export class ApplicationSettings extends ReadWriteProxy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getCurrentVersion() {
|
getCurrentVersion() {
|
||||||
return 14;
|
return 15;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @param {{settings: SettingsStorage, version: number}} data */
|
/** @param {{settings: SettingsStorage, version: number}} data */
|
||||||
@ -472,6 +524,12 @@ export class ApplicationSettings extends ReadWriteProxy {
|
|||||||
data.settings.disableCutDeleteWarnings = false;
|
data.settings.disableCutDeleteWarnings = false;
|
||||||
data.version = 14;
|
data.version = 14;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (data.version < 15) {
|
||||||
|
data.settings.autosaveInterval = "two_minutes";
|
||||||
|
data.version = 15;
|
||||||
|
}
|
||||||
|
|
||||||
return ExplainedResult.good();
|
return ExplainedResult.good();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user