diff --git a/js/interface/settings.js b/js/interface/settings.js index 3a5dfdc2..1771612e 100644 --- a/js/interface/settings.js +++ b/js/interface/settings.js @@ -363,6 +363,10 @@ const Settings = { updateStreamerModeNotification(); }}); new Setting('cdn_mirror', {value: false}); + new Setting('recovery_save_interval', {value: 30, type: 'number', min: 0, onChange() { + clearTimeout(AutoBackup.loop_timeout); + AutoBackup.backupProjectLoop(false); + }}); //Interface new Setting('interface_mode', {category: 'interface', value: 'auto', type: 'select', options: { diff --git a/js/misc.js b/js/misc.js index 96523b92..c7592082 100644 --- a/js/misc.js +++ b/js/misc.js @@ -283,6 +283,8 @@ const AutoBackup = { ] }) } + + AutoBackup.backupProjectLoop(false); } }, async backupOpenProject() { @@ -369,6 +371,21 @@ const AutoBackup = { reject(); } }); + }, + loop_timeout: null, + backupProjectLoop(run_save = true) { + if (run_save && Project && (Outliner.root.length || Project.textures.length)) { + try { + AutoBackup.backupOpenProject(); + } catch (err) { + console.error('Unable to create backup. ', err) + } + } + let interval = settings.recovery_save_interval.value; + if (interval != 0) { + interval = Math.max(interval, 5); + AutoBackup.loop_timeout = setTimeout(() => AutoBackup.backupProjectLoop(true), interval * 1000); + } } } @@ -376,13 +393,8 @@ const AutoBackup = { setInterval(function() { if (Project && (Outliner.root.length || Project.textures.length)) { Validator.validate(); - try { - AutoBackup.backupOpenProject(); - } catch (err) { - console.error('Unable to create backup. ', err) - } } -}, 1e3*30) +}, 1e3*30); //Misc const TickUpdates = { Run() { diff --git a/lang/en.json b/lang/en.json index a1bcc34a..bf499f30 100644 --- a/lang/en.json +++ b/lang/en.json @@ -876,6 +876,8 @@ "settings.streamer_mode.desc": "Hides sensitive information like recent models", "settings.cdn_mirror": "Use CDN Mirror", "settings.cdn_mirror.desc": "Use the mirror CDN to download plugins. The mirror receives updates faster and works in some regions where the default does not work.", + "settings.recovery_save_interval": "Recovery Point Save Interval", + "settings.recovery_save_interval.desc": "Blockbench regularly saves the open project in the background to recover in case of a computer crash. Set the interval in seconds. Set to 0 to disable saving.", "settings.interface_scale": "Interface Scale", "settings.interface_scale.desc": "Scale of the entire Blockbench interface", @@ -1691,6 +1693,8 @@ "action.import_texture.desc": "Import one or more textures from your file system", "action.create_texture": "Create Texture", "action.create_texture.desc": "Create a blank texture or template texture", + "action.create_texture_group": "Create Texture Group", + "action.create_texture_group.desc": "Create a group for your textures", "action.append_to_template": "Append Elements to Template...", "action.append_to_template.desc": "Add the currently selected elements to the texture template", "action.save_textures": "Save Textures",