diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/Timelined.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/Timelined.java index ab6f33b35..1b5c08922 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/Timelined.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/Timelined.java @@ -54,6 +54,12 @@ public interface Timelined extends BoundedTag { * @param value True if modified */ public void setModified(boolean value); + + /** + * Gets modification flag. + * @return True of modified + */ + public boolean isModified(); /** * Gets tags. diff --git a/src/com/jpexs/decompiler/flash/easygui/EasySwfPanel.java b/src/com/jpexs/decompiler/flash/easygui/EasySwfPanel.java index 893bd4017..199da0152 100644 --- a/src/com/jpexs/decompiler/flash/easygui/EasySwfPanel.java +++ b/src/com/jpexs/decompiler/flash/easygui/EasySwfPanel.java @@ -126,10 +126,13 @@ public class EasySwfPanel extends JPanel { final boolean transformEnabled = transformEnabled(); undoManager.doOperation(new DoableOperation() { + private boolean wasModified = false; + @Override public void doOperation() { timelinePanel.setFrame(frame, depth); DepthState ds = stagePanel.getTimelined().getTimeline().getFrame(frame).layers.get(depth); + wasModified = ds.placeObjectTag.isModified(); ds.placeObjectTag.setMatrix(newMatrix); ds.placeObjectTag.setPlaceFlagHasMatrix(newMatrix != null); ds.placeObjectTag.setModified(true); @@ -151,6 +154,9 @@ public class EasySwfPanel extends JPanel { DepthState ds = stagePanel.getTimelined().getTimeline().getFrame(frame).layers.get(depth); ds.placeObjectTag.setMatrix(fpreviousMatrix); ds.placeObjectTag.setPlaceFlagHasMatrix(fpreviousMatrix != null); + if (!wasModified) { + ds.placeObjectTag.setModified(false); + } stagePanel.getTimelined().resetTimeline(); stagePanel.repaint(); if (transformEnabled()) { @@ -190,26 +196,27 @@ public class EasySwfPanel extends JPanel { || (tag instanceof ButtonTag) ) { - undoManager.doOperation(new DoableOperation() { + undoManager.doOperation(new TimelinedTagListDoableOperation(stagePanel.getTimelined()) { - private PlaceObject2Tag place; - private RemoveObject2Tag remove; - private List tags; - private int frame = stagePanel.getFrame(); - private int depth = stagePanel.getSelectedDepth(); + private List swfTags; + private final int fframe = stagePanel.getFrame(); + private final int fdepth = stagePanel.getSelectedDepth(); @Override public void doOperation() { - timelinePanel.setFrame(frame, depth); + super.doOperation(); + timelinePanel.setFrame(fframe, fdepth); CharacterTag ch = (CharacterTag) tag; int maxDepth = stagePanel.getTimelined().getTimeline().getMaxDepth(); int newDepth = maxDepth + 1; Timelined timelined = stagePanel.getTimelined(); - tags = timelined.getSwf().getTags().toArrayList(); + if (timelined.getSwf() != timelined) { + swfTags = timelined.getSwf().getTags().toArrayList(); + } - ShowFrameTag showFrameTag = timelined.getTimeline().getFrame(frame).showFrameTag; - place = new PlaceObject2Tag(timelined.getSwf()); + ShowFrameTag showFrameTag = timelined.getTimeline().getFrame(fframe).showFrameTag; + PlaceObject2Tag place = new PlaceObject2Tag(timelined.getSwf()); place.depth = newDepth; place.placeFlagHasCharacter = true; place.characterId = ch.getCharacterId(); @@ -221,7 +228,7 @@ public class EasySwfPanel extends JPanel { } else { timelined.addTag(timelined.indexOfTag(showFrameTag), place); - remove = new RemoveObject2Tag(timelined.getSwf()); + RemoveObject2Tag remove = new RemoveObject2Tag(timelined.getSwf()); remove.depth = newDepth; timelined.addTag(timelined.indexOfTag(showFrameTag) + 1, remove); } @@ -230,7 +237,7 @@ public class EasySwfPanel extends JPanel { DefineBeforeUsageFixer fixer = new DefineBeforeUsageFixer(); boolean tagOrderChanged = fixer.fixDefineBeforeUsage(timelined.getSwf()); if (!tagOrderChanged) { - tags = null; + swfTags = null; } timelined.resetTimeline(); @@ -241,33 +248,25 @@ public class EasySwfPanel extends JPanel { @Override public void undoOperation() { - Timelined timelined = place.getTimelined(); - timelined.removeTag(place); - if (remove != null) { - timelined.removeTag(remove); - } + super.undoOperation(); timelined.resetTimeline(); //Tag order changed, put the original tags back - if (tags != null) { + if (swfTags != null) { SWF swf = timelined.getSwf(); ReadOnlyTagList newTags = swf.getTags(); int size = newTags.size(); for (int i = 0; i < size; i++) { swf.removeTag(0); } - for (int i = 0; i < tags.size(); i++) { - if (tags.get(i) == place) { - continue; - } - swf.addTag(tags.get(i)); + for (int i = 0; i < swfTags.size(); i++) { + swf.addTag(swfTags.get(i)); } swf.resetTimeline(); - } - + } stagePanel.repaint(); timelinePanel.refresh(); - timelinePanel.setFrame(frame, depth); + timelinePanel.setFrame(fframe, fdepth); } @Override diff --git a/src/com/jpexs/decompiler/flash/easygui/TimelinedTagListDoableOperation.java b/src/com/jpexs/decompiler/flash/easygui/TimelinedTagListDoableOperation.java index 3a5f8d934..af21403c5 100644 --- a/src/com/jpexs/decompiler/flash/easygui/TimelinedTagListDoableOperation.java +++ b/src/com/jpexs/decompiler/flash/easygui/TimelinedTagListDoableOperation.java @@ -29,6 +29,7 @@ public abstract class TimelinedTagListDoableOperation implements DoableOperation private final Timelined timelined; protected List tags; + protected boolean wasModified = false; public TimelinedTagListDoableOperation(Timelined timelined) { this.timelined = timelined; @@ -37,6 +38,7 @@ public abstract class TimelinedTagListDoableOperation implements DoableOperation @Override public void doOperation() { saveTagList(); + wasModified = timelined.isModified(); timelined.setModified(true); } @@ -55,13 +57,16 @@ public abstract class TimelinedTagListDoableOperation implements DoableOperation timelined.addTag(tags.get(i)); } timelined.resetTimeline(); - timelined.setFrameCount(timelined.getTimeline().getFrameCount()); + timelined.setFrameCount(timelined.getTimeline().getFrameCount()); } } @Override public void undoOperation() { restoreTagList(); + if (!wasModified) { + timelined.setModified(false); + } } @Override diff --git a/src/com/jpexs/decompiler/flash/gui/MainPanel.java b/src/com/jpexs/decompiler/flash/gui/MainPanel.java index ebc20bb74..70fb5c700 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/MainPanel.java @@ -5961,6 +5961,11 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se } + @Override + public boolean isModified() { + return false; + } + @Override public ReadOnlyTagList getTags() { if (cachedTags == null) { diff --git a/src/com/jpexs/decompiler/flash/gui/PreviewPanel.java b/src/com/jpexs/decompiler/flash/gui/PreviewPanel.java index 3c01f07d6..cc46877ca 100644 --- a/src/com/jpexs/decompiler/flash/gui/PreviewPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/PreviewPanel.java @@ -2778,6 +2778,11 @@ public class PreviewPanel extends JPersistentSplitPane implements TagEditorPanel } + @Override + public boolean isModified() { + return false; + } + @Override public ReadOnlyTagList getTags() { if (cachedTags == null) { diff --git a/src/com/jpexs/decompiler/flash/gui/TimelinedMaker.java b/src/com/jpexs/decompiler/flash/gui/TimelinedMaker.java index e571c0465..404f158e0 100644 --- a/src/com/jpexs/decompiler/flash/gui/TimelinedMaker.java +++ b/src/com/jpexs/decompiler/flash/gui/TimelinedMaker.java @@ -305,6 +305,11 @@ public class TimelinedMaker { public void setModified(boolean value) { } + @Override + public boolean isModified() { + return false; + } + @Override public ReadOnlyTagList getTags() { return ReadOnlyTagList.EMPTY;