From e5012930ef69c2fdf4e530f8e4c470045e26fcce Mon Sep 17 00:00:00 2001 From: Exund Date: Tue, 27 Jun 2023 18:56:41 +0200 Subject: [PATCH] Fix saving + depths selection --- .../flash/gui/tagtree/TagTreeContextMenu.java | 28 +++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeContextMenu.java b/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeContextMenu.java index b2b16fe64..eaa733ec2 100644 --- a/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeContextMenu.java +++ b/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeContextMenu.java @@ -4109,10 +4109,11 @@ public class TagTreeContextMenu extends JPopupMenu { private void collectDepthAsSprites(ActionEvent e) { List frames = getSelectedItems(); - Timelined timelined = ((Frame) frames.get(0)).timeline.timelined; + Frame first = (Frame) frames.get(0); + Timelined timelined = first.timeline.timelined; SWF swf = timelined instanceof SWF ? (SWF) timelined : ((DefineSpriteTag) timelined).getSwf(); - Set originalDepths = new HashSet<>(); + Set originalDepths = new TreeSet<>(); for (TreeItem item : frames) { Frame f = (Frame) item; @@ -4144,7 +4145,13 @@ public class TagTreeContextMenu extends JPopupMenu { sprite.addTag(showFrame); } - swf.addTag(sprite); + if(replace) { + timelined.addTag(timelined.indexOfTag(first.innerTags.get(0)), sprite); + } else { + timelined.addTag(sprite); + } + sprite.setTimelined(timelined); + sprite.getTimeline(); sprites.put(d, sprite); } @@ -4183,9 +4190,11 @@ public class TagTreeContextMenu extends JPopupMenu { } } - if (depth != -1) { + if (sprites.containsKey(depth)) { DefineSpriteTag sprite = sprites.get(depth); Tag clone = t.cloneTag(); + clone.setModified(true); + if (firstMatrix && i == 0 && clone instanceof PlaceObjectTypeTag) { PlaceObjectTypeTag place = (PlaceObjectTypeTag) clone; if (place.getMatrix() == null) { @@ -4200,7 +4209,7 @@ public class TagTreeContextMenu extends JPopupMenu { } } } - + clone.setTimelined(sprite); sprite.addTag(i, clone); @@ -4214,8 +4223,6 @@ public class TagTreeContextMenu extends JPopupMenu { } } - Frame first = (Frame) frames.get(0); - for (Entry entry : sprites.entrySet()) { DefineSpriteTag sprite = entry.getValue(); @@ -4267,10 +4274,14 @@ public class TagTreeContextMenu extends JPopupMenu { place.matrix.translateY = minY; } - place.setTimelined(first.timeline.timelined); + place.setTimelined(timelined); first.innerTags.add(place); + timelined.addTag(timelined.indexOfTag(first.innerTags.get(0)), place); } } + + sprite.setSwf(swf, true); + sprite.resetTimeline(); } swf.updateCharacters(); @@ -4278,6 +4289,7 @@ public class TagTreeContextMenu extends JPopupMenu { swf.computeDependentCharacters(); swf.computeDependentFrames(); } + swf.resetTimelines(swf); mainPanel.refreshTree(swf); } catch (InterruptedException | IOException ex) { Logger.getLogger(TagTreeContextMenu.class.getName()).log(Level.SEVERE, null, ex);