Fix #841 undo not tracking exploded skin view

This commit is contained in:
JannisX11 2021-03-10 19:37:36 +01:00
parent 335eef8435
commit 31b8c91c41
2 changed files with 15 additions and 2 deletions

View File

@ -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 = `{

View File

@ -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]) {