@@ -15,12 +15,16 @@ class UndoSystem {
15
15
}
16
16
}
17
17
initEdit ( aspects , amended = false ) {
18
+ // todo: selecting all groups, moving, then undoing, unselects all multi-selected groups
18
19
if ( aspects && aspects . cubes ) {
19
20
console . warn ( 'Aspect "cubes" is deprecated. Please use "elements" instead.' ) ;
20
21
aspects . elements = aspects . cubes ;
21
22
}
22
23
this . startChange ( amended ) ;
23
- this . current_save = new UndoSystem . save ( aspects )
24
+ this . current_save = new UndoSystem . save ( aspects ) ;
25
+ if ( aspects . selection ) {
26
+ this . current_selection_save = new UndoSystem . selectionSave ( typeof aspects . selection == 'object' ? typeof aspects . selection : 0 ) ;
27
+ }
24
28
Blockbench . dispatchEvent ( 'init_edit' , { aspects, amended, save : this . current_save } )
25
29
return this . current_save ;
26
30
}
@@ -40,7 +44,18 @@ class UndoSystem {
40
44
type : 'edit' ,
41
45
time : Date . now ( )
42
46
}
43
- this . current_save = entry . post
47
+
48
+ if ( aspects . selection && this . current_selection_save ) {
49
+ let selection_aspects = typeof aspects . selection == 'object' ? aspects . selection : this . current_selection_save . aspects ;
50
+ let selection_before = this . current_selection_save ;
51
+ let selection_post = new UndoSystem . selectionSave ( selection_aspects ) ;
52
+ if ( ! selection_before . matches ( selection_post ) ) {
53
+ entry . selection_before = selection_before ;
54
+ entry . selection_post = selection_post ;
55
+ }
56
+ }
57
+
58
+
44
59
if ( this . history . length > this . index ) {
45
60
this . history . length = this . index ;
46
61
}
@@ -89,7 +104,6 @@ class UndoSystem {
89
104
type : 'selection' ,
90
105
time : Date . now ( )
91
106
}
92
- this . current_selection_save = entry . selection_post
93
107
if ( this . history . length > this . index ) {
94
108
this . history . length = this . index ;
95
109
}
@@ -239,7 +253,7 @@ UndoSystem.save = class {
239
253
240
254
this . mode = Modes . selected . id ;
241
255
242
- if ( aspects . selection ) {
256
+ /* if (aspects.selection) {
243
257
this.selection = [];
244
258
this.mesh_selection = {};
245
259
selected.forEach(obj => {
@@ -251,8 +265,7 @@ UndoSystem.save = class {
251
265
if (Group.multi_selected.length) {
252
266
this.selected_groups = Group.multi_selected.map(g => g.uuid);
253
267
}
254
-
255
- }
268
+ }*/
256
269
257
270
if ( aspects . elements ) {
258
271
this . elements = { }
@@ -440,7 +453,7 @@ UndoSystem.save = class {
440
453
}
441
454
}
442
455
443
- if ( this . selection && ! is_session ) {
456
+ /* if (this.selection && !is_session) {
444
457
selected.length = 0;
445
458
Outliner.elements.forEach((obj) => {
446
459
if (this.selection.includes(obj.uuid)) {
@@ -450,7 +463,7 @@ UndoSystem.save = class {
450
463
}
451
464
}
452
465
})
453
- }
466
+ }*/
454
467
455
468
if ( this . groups ) {
456
469
for ( let saved_group of this . groups ) {
@@ -619,7 +632,7 @@ UndoSystem.save = class {
619
632
if ( this . animations ) {
620
633
for ( var uuid in this . animations ) {
621
634
622
- var animation = ( reference . animations && reference . animations [ uuid ] ) ? this . getItemByUUID ( Animator . animations , uuid ) : null ;
635
+ var animation = ( reference . animations && reference . animations [ uuid ] ) ? Undo . getItemByUUID ( Animator . animations , uuid ) : null ;
623
636
if ( ! animation ) {
624
637
animation = new Animation ( )
625
638
animation . uuid = uuid
@@ -631,7 +644,7 @@ UndoSystem.save = class {
631
644
}
632
645
for ( var uuid in reference . animations ) {
633
646
if ( ! this . animations [ uuid ] ) {
634
- var animation = this . getItemByUUID ( Animator . animations , uuid )
647
+ var animation = Undo . getItemByUUID ( Animator . animations , uuid )
635
648
if ( animation ) {
636
649
animation . remove ( false )
637
650
}
@@ -641,7 +654,7 @@ UndoSystem.save = class {
641
654
if ( this . animation_controllers ) {
642
655
for ( var uuid in this . animation_controllers ) {
643
656
644
- var controller = ( reference . animation_controllers && reference . animation_controllers [ uuid ] ) ? this . getItemByUUID ( AnimationController . all , uuid ) : null ;
657
+ var controller = ( reference . animation_controllers && reference . animation_controllers [ uuid ] ) ? Undo . getItemByUUID ( AnimationController . all , uuid ) : null ;
645
658
if ( ! controller ) {
646
659
controller = new AnimationController ( ) ;
647
660
controller . uuid = uuid ;
@@ -653,7 +666,7 @@ UndoSystem.save = class {
653
666
}
654
667
for ( var uuid in reference . animation_controllers ) {
655
668
if ( ! this . animation_controllers [ uuid ] ) {
656
- var controller = this . getItemByUUID ( AnimationController . all , uuid ) ;
669
+ var controller = Undo . getItemByUUID ( AnimationController . all , uuid ) ;
657
670
if ( controller ) {
658
671
controller . remove ( false ) ;
659
672
}
0 commit comments