diff --git a/js/io/formats/skin.js b/js/io/formats/skin.js index f564a16..a966928 100644 --- a/js/io/formats/skin.js +++ b/js/io/formats/skin.js @@ -375,7 +375,7 @@ BARS.defineActions(function() { condition: {formats: ['skin']}, value: false, onChange(exploded_view) { - Undo.initEdit({elements: Cube.all}); + Undo.initEdit({elements: Cube.all, exploded_view: !exploded_view}); Cube.all.forEach(cube => { let center = [ cube.from[0] + (cube.to[0] - cube.from[0]) / 2, @@ -387,7 +387,7 @@ BARS.defineActions(function() { cube.from.V3_add(center); cube.to.V3_add(center); }) - Undo.finishEdit('explode_skin_model'); + Undo.finishEdit('explode_skin_model', {elements: Cube.all, exploded_view: exploded_view}); Canvas.updateAllPositions(); this.setIcon(this.icon); } @@ -396,6 +396,12 @@ BARS.defineActions(function() { explode_skin_model.value = false; explode_skin_model.updateEnabledState(); }) + Blockbench.on('load_undo_save', data => { + if (data.save.exploded_view !== undefined) { + explode_skin_model.value = data.save.exploded_view; + explode_skin_model.updateEnabledState(); + } + }) }) skin_presets.steve = `{ diff --git a/js/undo.js b/js/undo.js index b1b2724..7e64587 100644 --- a/js/undo.js +++ b/js/undo.js @@ -211,6 +211,10 @@ var Undo = { } }) } + + if (aspects.exploded_view !== undefined) { + this.exploded_view = !!aspects.exploded_view; + } }, loadSave(save, reference, mode) { var is_session = mode === 'session'; @@ -441,6 +445,9 @@ var Undo = { display[slot].extend(data).update() } } + + Blockbench.dispatchEvent('load_undo_save', {save, reference, mode}) + if (open_dialog == 'uv_dialog') { for (var key in uv_dialog.editors) { if (uv_dialog.editors[key]) {