Add message box with instructions before updating

This commit is contained in:
JannisX11 2023-07-29 17:53:09 +02:00
parent 9fce77c389
commit 7744d48f6b
3 changed files with 15 additions and 2 deletions

View File

@ -191,7 +191,7 @@ const Blockbench = {
} }
}, },
showMessageBox(options = 0, cb) { showMessageBox(options = 0, cb) {
new MessageBox(options, cb).show(); return new MessageBox(options, cb).show();
}, },
async textPrompt(title, value, callback, placeholder = null) { async textPrompt(title, value, callback, placeholder = null) {
let answer = await new Promise((resolve) => { let answer = await new Promise((resolve) => {

View File

@ -648,10 +648,20 @@ window.onbeforeunload = function (event) {
} }
} }
function closeBlockbenchWindow() { async function closeBlockbenchWindow() {
for (let project of ModelProject.all.slice()) { for (let project of ModelProject.all.slice()) {
project.closeOnQuit(); project.closeOnQuit();
} }
if (Blockbench.hasFlag('update_downloaded')) {
await new Promise(resolve => {
Blockbench.showMessageBox({
title: 'message.installing_update.title',
message: tl('message.installing_update.message', '60'),
icon: 'update',
width: 534
}, resolve);
})
}
window.onbeforeunload = null; window.onbeforeunload = null;
Blockbench.addFlag('allow_closing'); Blockbench.addFlag('allow_closing');
Blockbench.dispatchEvent('before_closing') Blockbench.dispatchEvent('before_closing')
@ -694,6 +704,7 @@ ipcRenderer.on('update-available', (event, arg) => {
console.error(err); console.error(err);
}) })
ipcRenderer.on('update-downloaded', (event) => { ipcRenderer.on('update-downloaded', (event) => {
Blockbench.addFlag('update_downloaded');
action.setName(tl('message.update_after_restart')); action.setName(tl('message.update_after_restart'));
MenuBar.menus.help.removeAction(action); MenuBar.menus.help.removeAction(action);
icon_node.textContent = 'done'; icon_node.textContent = 'done';

View File

@ -290,6 +290,8 @@
"message.update_notification.title": "Could not Install Update", "message.update_notification.title": "Could not Install Update",
"message.update_notification.message": "A new Blockbench version is available. Please enable Automatic Updates in the settings in order to update!", "message.update_notification.message": "A new Blockbench version is available. Please enable Automatic Updates in the settings in order to update!",
"message.update_after_restart": "The update will be installed after the next restart", "message.update_after_restart": "The update will be installed after the next restart",
"message.installing_update.title": "Update Available",
"message.installing_update.message": "A new version is ready to be installed. After closing the app, please allow for around %0 seconds before opening Blockbench again or turning off the computer, for the update to be installed.",
"message.import_particle_texture.import": "Import Particle Texture", "message.import_particle_texture.import": "Import Particle Texture",
"message.import_particle_texture.message": "Would you like to import a texture file to be used for your particle?", "message.import_particle_texture.message": "Would you like to import a texture file to be used for your particle?",