diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java index 19518d5cf..321ce5a6b 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java @@ -272,10 +272,10 @@ public final class SWF implements SWFContainerItem, Timelined { public SWFList swfList; @Internal - public String file; + private String file; @Internal - public String fileTitle; + private String fileTitle; @Internal private Map characters; @@ -673,12 +673,37 @@ public final class SWF implements SWFContainerItem, Timelined { } } + /** + * Constructs an empty SWF + */ public SWF() { } + /** + * Construct SWF from stream + * + * @param is Stream to read SWF from + * @param parallelRead Use parallel threads? + * @throws IOException + * @throws java.lang.InterruptedException + */ public SWF(InputStream is, boolean parallelRead) throws IOException, InterruptedException { - this(is, null, parallelRead, false); + this(is, null, null, null, parallelRead, false); + } + + /** + * Construct SWF from stream + * + * @param is Stream to read SWF from + * @param file Path to the file + * @param fileTitle Title of the SWF + * @param parallelRead Use parallel threads? + * @throws IOException + * @throws java.lang.InterruptedException + */ + public SWF(InputStream is, String file, String fileTitle, boolean parallelRead) throws IOException, InterruptedException { + this(is, file, fileTitle, null, parallelRead, false); } /** @@ -691,7 +716,22 @@ public final class SWF implements SWFContainerItem, Timelined { * @throws java.lang.InterruptedException */ public SWF(InputStream is, ProgressListener listener, boolean parallelRead) throws IOException, InterruptedException { - this(is, listener, parallelRead, false); + this(is, null, null, listener, parallelRead, false); + } + + /** + * Construct SWF from stream + * + * @param is Stream to read SWF from + * @param file Path to the file + * @param fileTitle Title of the SWF + * @param listener + * @param parallelRead Use parallel threads? + * @throws IOException + * @throws java.lang.InterruptedException + */ + public SWF(InputStream is, String file, String fileTitle, ProgressListener listener, boolean parallelRead) throws IOException, InterruptedException { + this(is, file, fileTitle, listener, parallelRead, false); } /** @@ -708,13 +748,17 @@ public final class SWF implements SWFContainerItem, Timelined { * Construct SWF from stream * * @param is Stream to read SWF from + * @param file Path to the file + * @param fileTitle Title of the SWF * @param listener * @param parallelRead Use parallel threads? * @param checkOnly Check only file validity * @throws IOException * @throws java.lang.InterruptedException */ - public SWF(InputStream is, ProgressListener listener, boolean parallelRead, boolean checkOnly) throws IOException, InterruptedException { + public SWF(InputStream is, String file, String fileTitle, ProgressListener listener, boolean parallelRead, boolean checkOnly) throws IOException, InterruptedException { + this.file = file; + this.fileTitle = fileTitle; ByteArrayOutputStream baos = new ByteArrayOutputStream(); SWFHeader header = decompress(is, baos, true); gfx = header.gfx; @@ -777,6 +821,10 @@ public final class SWF implements SWFContainerItem, Timelined { return this; } + public String getFile() { + return file; + } + /** * Get title of the file * @@ -797,6 +845,11 @@ public final class SWF implements SWFContainerItem, Timelined { return new File(title).getName(); } + public void setFile(String file) { + this.file = file; + fileTitle = null; + } + private static void getAbcTags(List list, List actionScripts) { for (Tag t : list) { if (t instanceof DefineSpriteTag) { @@ -1516,7 +1569,7 @@ public final class SWF implements SWFContainerItem, Timelined { path = File.separator + Helper.makeFileName(getCharacter(containerId).getExportFileName()); } if (frames == null) { - int frameCnt = tim.getFrames().size(); + int frameCnt = tim.getFrameCount(); frames = new ArrayList<>(); for (int i = 0; i < frameCnt; i++) { frames.add(i); @@ -2450,7 +2503,7 @@ public final class SWF implements SWFContainerItem, Timelined { Stack clipDepths = new Stack<>(); for (int frame : frames) { sb.append("\t\tcase ").append(frame).append(":\r\n"); - Frame frameObj = timeline.getFrames().get(frame); + Frame frameObj = timeline.getFrame(frame); for (int i = 1; i <= maxDepth + 1; i++) { while (!clipDepths.isEmpty() && clipDepths.peek() <= i) { clipDepths.pop(); @@ -2664,10 +2717,10 @@ public final class SWF implements SWFContainerItem, Timelined { } public static void frameToSvg(Timeline timeline, int frame, int time, DepthState stateUnderCursor, int mouseButton, SVGExporter exporter, ColorTransform colorTransform, int level, double zoom) throws IOException { - if (timeline.getFrames().size() <= frame) { + if (timeline.getFrameCount() <= frame) { return; } - Frame frameObj = timeline.getFrames().get(frame); + Frame frameObj = timeline.getFrame(frame); List clips = new ArrayList<>(); List prevClips = new ArrayList<>(); @@ -2767,7 +2820,7 @@ public final class SWF implements SWFContainerItem, Timelined { } } - if (timeline.getFrames().isEmpty()) { + if (timeline.getFrameCount() == 0) { return new SerializableImage(1, 1, SerializableImage.TYPE_INT_ARGB); } @@ -2797,7 +2850,7 @@ public final class SWF implements SWFContainerItem, Timelined { public static void framesToImage(Timeline timeline, List ret, int startFrame, int stopFrame, RenderContext renderContext, RECT displayRect, int totalFrameCount, Stack visited, Matrix transformation, ColorTransform colorTransform, double zoom) { RECT rect = displayRect; - for (int f = 0; f < timeline.getFrames().size(); f++) { + for (int f = 0; f < timeline.getFrameCount(); f++) { SerializableImage image = new SerializableImage((int) (rect.getWidth() / SWF.unitDivisor) + 1, (int) (rect.getHeight() / SWF.unitDivisor) + 1, SerializableImage.TYPE_INT_ARGB); image.fillTransparent(); @@ -2810,10 +2863,10 @@ public final class SWF implements SWFContainerItem, Timelined { public static void frameToImage(Timeline timeline, int frame, int time, RenderContext renderContext, SerializableImage image, Matrix transformation, ColorTransform colorTransform) { double unzoom = SWF.unitDivisor; - if (timeline.getFrames().size() <= frame) { + if (timeline.getFrameCount() <= frame) { return; } - Frame frameObj = timeline.getFrames().get(frame); + Frame frameObj = timeline.getFrame(frame); Graphics2D g = (Graphics2D) image.getGraphics(); g.setPaint(frameObj.backgroundColor.toColor()); g.fill(new Rectangle(image.getWidth(), image.getHeight())); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWFInputStream.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWFInputStream.java index 2bbb57b9f..0445030e7 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWFInputStream.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWFInputStream.java @@ -1453,7 +1453,7 @@ public class SWFInputStream implements AutoCloseable { } } } catch (IOException ex) { - logger.log(Level.SEVERE, "Error during tag reading. ID: " + tag.getId() + " name: " + tag.getName() + " pos: " + data.getPos(), ex); + logger.log(Level.SEVERE, "Error during tag reading. SWF: " + swf.getShortFileName() + " ID: " + tag.getId() + " name: " + tag.getName() + " pos: " + data.getPos(), ex); ret = new TagStub(swf, tag.getId(), "ErrorTag", data, null); } ret.forceWriteAsLong = tag.forceWriteAsLong; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWFSearch.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWFSearch.java index 7164458d5..83a67585c 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWFSearch.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWFSearch.java @@ -90,7 +90,7 @@ public class SWFSearch { MemoryInputStream mis = (MemoryInputStream) ret.get(addr); mis.reset(); PosMarkedInputStream pmi = new PosMarkedInputStream(mis); - SWF swf = noCheck ? new SWF(pmi) : new SWF(pmi, null, false, true); + SWF swf = noCheck ? new SWF(pmi) : new SWF(pmi, null, null, null, false, true); boolean valid = swf.fileSize > 0 && swf.version > 0 && (!swf.tags.isEmpty() || noCheck) diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineBinaryDataTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineBinaryDataTag.java index d7e57b9d9..acfb09a69 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineBinaryDataTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineBinaryDataTag.java @@ -1,18 +1,19 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.tags; import com.jpexs.decompiler.flash.SWF; @@ -29,6 +30,7 @@ import com.jpexs.helpers.utf8.Utf8Helper; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; +import java.io.InputStream; import java.io.OutputStream; import java.util.Arrays; @@ -87,8 +89,8 @@ public class DefineBinaryDataTag extends CharacterTag { if (Configuration.autoLoadEmbeddedSwfs.get()) { try { - SWF bswf = new SWF(new ByteArrayInputStream(binaryData.getArray(), binaryData.getPos(), binaryData.getLength()), Configuration.parallelSpeedUp.get()); - bswf.fileTitle = "(SWF Data)"; + InputStream is = new ByteArrayInputStream(binaryData.getArray(), binaryData.getPos(), binaryData.getLength()); + SWF bswf = new SWF(is, null, "(SWF Data)", Configuration.parallelSpeedUp.get()); innerSwf = bswf; bswf.binaryData = this; } catch (IOException | InterruptedException ex) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineSpriteTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineSpriteTag.java index 9d59e3eb7..40b0dce87 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineSpriteTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineSpriteTag.java @@ -29,7 +29,6 @@ import com.jpexs.decompiler.flash.tags.base.CharacterTag; import com.jpexs.decompiler.flash.tags.base.DrawableTag; import com.jpexs.decompiler.flash.tags.base.PlaceObjectTypeTag; import com.jpexs.decompiler.flash.tags.base.RenderContext; -import com.jpexs.decompiler.flash.timeline.Frame; import com.jpexs.decompiler.flash.timeline.Timeline; import com.jpexs.decompiler.flash.timeline.Timelined; import com.jpexs.decompiler.flash.types.BasicType; @@ -301,14 +300,14 @@ public class DefineSpriteTag extends CharacterTag implements DrawableTag, Timeli @Override public int getNumFrames() { // flashplayer ignores the count stored in frameCount - return getTimeline().getFrames().size(); // frameCount + return getTimeline().getFrameCount(); // frameCount } private int getRealFrameCount() { int cnt = 1; - List frames = getTimeline().getFrames(); - for (int i = 1; i < frames.size(); i++) { - if (frames.get(i).layersChanged) { + Timeline timeline = getTimeline(); + for (int i = 1; i < timeline.getFrameCount(); i++) { + if (timeline.getFrame(i).layersChanged) { cnt++; } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/Timeline.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/Timeline.java index d82c06b18..048a71ea1 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/Timeline.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/Timeline.java @@ -95,11 +95,16 @@ public class Timeline { } } - public List getFrames() { + public Iterable getFrames() { ensureInitialized(); return frames; } + public Frame getFrame(int index) { + ensureInitialized(); + return frames.get(index); + } + public void addFrame(Frame frame) { ensureInitialized(); frames.add(frame); @@ -149,7 +154,8 @@ public class Timeline { } public int getFrameCount() { - return getFrames().size(); + ensureInitialized(); + return frames.size(); } public int getFrameForAction(ASMSource asm) { @@ -389,7 +395,7 @@ public class Timeline { } public void getNeededCharacters(int frame, Set usedCharacters) { - Frame frameObj = getFrames().get(frame); + Frame frameObj = getFrame(frame); for (int depth : frameObj.layers.keySet()) { DepthState layer = frameObj.layers.get(depth); if (layer.characterId != -1) { @@ -424,7 +430,7 @@ public class Timeline { } public void getSounds(int frame, int time, DepthState stateUnderCursor, int mouseButton, List sounds, List soundClasses) { - Frame fr = getFrames().get(frame); + Frame fr = getFrame(frame); sounds.addAll(fr.sounds); soundClasses.addAll(fr.soundClasses); for (int d = maxDepth; d >= 0; d--) { @@ -455,7 +461,7 @@ public class Timeline { } public void getObjectsOutlines(int frame, int time, int ratio, DepthState stateUnderCursor, int mouseButton, Matrix transformation, List objs, List outlines) { - Frame fr = getFrames().get(frame); + Frame fr = getFrame(frame); Stack clips = new Stack<>(); for (int d = maxDepth; d >= 0; d--) { Clip currentClip = null; @@ -527,7 +533,7 @@ public class Timeline { } public Shape getOutline(int frame, int time, int ratio, RenderContext renderContext, Matrix transformation) { - Frame fr = getFrames().get(frame); + Frame fr = getFrame(frame); Area area = new Area(); Stack clips = new Stack<>(); for (int d = maxDepth; d >= 0; d--) { @@ -602,7 +608,7 @@ public class Timeline { } public boolean isSingleFrame(int frame) { - Frame frameObj = getFrames().get(frame); + Frame frameObj = getFrame(frame); for (int i = 1; i <= maxDepth; i++) { if (!frameObj.layers.containsKey(i)) { continue; diff --git a/src/com/jpexs/decompiler/flash/gui/AdvancedSettingsDialog.java b/src/com/jpexs/decompiler/flash/gui/AdvancedSettingsDialog.java index 6145be35e..269e2ab7e 100644 --- a/src/com/jpexs/decompiler/flash/gui/AdvancedSettingsDialog.java +++ b/src/com/jpexs/decompiler/flash/gui/AdvancedSettingsDialog.java @@ -338,7 +338,7 @@ public class AdvancedSettingsDialog extends AppDialog implements ActionListener if (!((JTextField) c).getText().isEmpty()) { c.requestFocusInWindow(); return; - }//else null + } // else null } values.put(name, value); } @@ -356,8 +356,10 @@ public class AdvancedSettingsDialog extends AppDialog implements ActionListener throw new Error(ex.getMessage()); } if (item.get() == null || !item.get().equals(value)) { - item.set(value); - modified = true; + if (item.hasValue() || value != null) { + item.set(value); + modified = true; + } } } Configuration.saveConfig(); diff --git a/src/com/jpexs/decompiler/flash/gui/ImagePanel.java b/src/com/jpexs/decompiler/flash/gui/ImagePanel.java index f88eb9c55..0590ac38b 100644 --- a/src/com/jpexs/decompiler/flash/gui/ImagePanel.java +++ b/src/com/jpexs/decompiler/flash/gui/ImagePanel.java @@ -320,7 +320,7 @@ public final class ImagePanel extends JPanel implements ActionListener, MediaDis private void showSelectedName() { if (selectedDepth > -1 && frame > -1) { - DepthState ds = timelined.getTimeline().getFrames().get(frame).layers.get(selectedDepth); + DepthState ds = timelined.getTimeline().getFrame(frame).layers.get(selectedDepth); if (ds != null) { CharacterTag cht = timelined.getTimeline().swf.getCharacter(ds.characterId); if (cht != null) { @@ -524,7 +524,7 @@ public final class ImagePanel extends JPanel implements ActionListener, MediaDis loaded = true; - if (drawable.getTimeline().getFrames().isEmpty()) { + if (drawable.getTimeline().getFrameCount() == 0) { clearImagePanel(); return; } @@ -691,7 +691,7 @@ public final class ImagePanel extends JPanel implements ActionListener, MediaDis gg.setTransform(AffineTransform.getTranslateInstance(0, 0)); List dss = new ArrayList<>(); List os = new ArrayList<>(); - DepthState ds = drawable.getTimeline().getFrames().get(frame).layers.get(selectedDepth); + DepthState ds = drawable.getTimeline().getFrame(frame).layers.get(selectedDepth); if (ds != null) { CharacterTag cht = swf.getCharacter(ds.characterId); if (cht != null) { diff --git a/src/com/jpexs/decompiler/flash/gui/LoadFromMemoryFrame.java b/src/com/jpexs/decompiler/flash/gui/LoadFromMemoryFrame.java index 4a8a4bc3f..d60663054 100644 --- a/src/com/jpexs/decompiler/flash/gui/LoadFromMemoryFrame.java +++ b/src/com/jpexs/decompiler/flash/gui/LoadFromMemoryFrame.java @@ -146,7 +146,7 @@ public class LoadFromMemoryFrame extends AppFrame implements ActionListener { try { PosMarkedInputStream pmi = new PosMarkedInputStream(ret.get(addr)); ReReadableInputStream is = new ReReadableInputStream(pmi); - SWF swf = new SWF(is, null, false, true); + SWF swf = new SWF(is, null, null, null, false, true); long limit = pmi.getPos(); is.seek(0); is = new ReReadableInputStream(new LimitedInputStream(is, limit)); diff --git a/src/com/jpexs/decompiler/flash/gui/Main.java b/src/com/jpexs/decompiler/flash/gui/Main.java index 599eb8d9e..3c6665999 100644 --- a/src/com/jpexs/decompiler/flash/gui/Main.java +++ b/src/com/jpexs/decompiler/flash/gui/Main.java @@ -341,24 +341,21 @@ public class Main { for (Entry streamEntry : bundle.getAll().entrySet()) { InputStream stream = streamEntry.getValue(); stream.reset(); - SWF swf = new SWF(stream, new ProgressListener() { + SWF swf = new SWF(stream, null, streamEntry.getKey(), new ProgressListener() { @Override public void progress(int p) { startWork(AppStrings.translate("work.reading.swf"), p); } }, Configuration.parallelSpeedUp.get()); - swf.fileTitle = streamEntry.getKey(); result.add(swf); } } else { - SWF swf = new SWF(inputStream, new ProgressListener() { + SWF swf = new SWF(inputStream, sourceInfo.getFile(), sourceInfo.getFileTitle(), new ProgressListener() { @Override public void progress(int p) { startWork(AppStrings.translate("work.reading.swf"), p); } }, Configuration.parallelSpeedUp.get()); - swf.file = sourceInfo.getFile(); - swf.fileTitle = sourceInfo.getFileTitle(); result.add(swf); } @@ -409,8 +406,7 @@ public class Main { public static void saveFile(SWF swf, String outfile, SaveFileMode mode) throws IOException { if (mode == SaveFileMode.SAVEAS && !swf.swfList.isBundle) { - swf.file = outfile; - swf.fileTitle = null; + swf.setFile(outfile); swf.swfList.sourceInfo.setFile(outfile); } File outfileF = new File(outfile); @@ -625,8 +621,8 @@ public class Main { switch (mode) { case SAVE: case SAVEAS: - if (swf.file != null) { - ext = Path.getExtension(swf.file); + if (swf.getFile() != null) { + ext = Path.getExtension(swf.getFile()); } break; case EXE: diff --git a/src/com/jpexs/decompiler/flash/gui/MainFrameMenu.java b/src/com/jpexs/decompiler/flash/gui/MainFrameMenu.java index f29ab0a5c..d3531c77f 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainFrameMenu.java +++ b/src/com/jpexs/decompiler/flash/gui/MainFrameMenu.java @@ -78,11 +78,11 @@ public abstract class MainFrameMenu { } catch (IOException ex) { Logger.getLogger(MainFrameClassicMenu.class.getName()).log(Level.SEVERE, "Cannot save SWF", ex); } - } else if (swf.file == null) { + } else if (swf.getFile() == null) { saved = saveAs(swf, SaveFileMode.SAVEAS); } else { try { - Main.saveFile(swf, swf.file); + Main.saveFile(swf, swf.getFile()); saved = true; } catch (IOException ex) { Logger.getLogger(MainFrameClassicMenu.class.getName()).log(Level.SEVERE, null, ex); diff --git a/src/com/jpexs/decompiler/flash/gui/MainPanel.java b/src/com/jpexs/decompiler/flash/gui/MainPanel.java index c35362d66..608a55041 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/MainPanel.java @@ -149,6 +149,7 @@ import java.io.ByteArrayInputStream; import java.io.File; import java.io.FileInputStream; import java.io.IOException; +import java.io.InputStream; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -1450,7 +1451,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec if (!selDir.endsWith(File.separator)) { selDir += File.separator; } - String fileName = new File(swf.file).getName(); + String fileName = new File(swf.getFile()).getName(); fileName = fileName.substring(0, fileName.length() - 4) + ".fla"; fc.setSelectedFile(new File(selDir + fileName)); List flaFilters = new ArrayList<>(); @@ -1518,9 +1519,9 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec Helper.freeMem(); try { if (compressed) { - swf.exportFla(errorHandler, selfile.getAbsolutePath(), new File(swf.file).getName(), ApplicationInfo.APPLICATION_NAME, ApplicationInfo.applicationVerName, ApplicationInfo.version, Configuration.parallelSpeedUp.get(), selectedVersion); + swf.exportFla(errorHandler, selfile.getAbsolutePath(), new File(swf.getFile()).getName(), ApplicationInfo.APPLICATION_NAME, ApplicationInfo.applicationVerName, ApplicationInfo.version, Configuration.parallelSpeedUp.get(), selectedVersion); } else { - swf.exportXfl(errorHandler, selfile.getAbsolutePath(), new File(swf.file).getName(), ApplicationInfo.APPLICATION_NAME, ApplicationInfo.applicationVerName, ApplicationInfo.version, Configuration.parallelSpeedUp.get(), selectedVersion); + swf.exportXfl(errorHandler, selfile.getAbsolutePath(), new File(swf.getFile()).getName(), ApplicationInfo.APPLICATION_NAME, ApplicationInfo.applicationVerName, ApplicationInfo.version, Configuration.parallelSpeedUp.get(), selectedVersion); } } catch (IOException ex) { View.showMessageDialog(null, translate("error.export") + ": " + ex.getClass().getName() + " " + ex.getLocalizedMessage(), translate("error"), JOptionPane.ERROR_MESSAGE); @@ -2316,14 +2317,14 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec try { for (DefineBinaryDataTag binaryDataTag : binaryDataTags) { try { - SWF bswf = new SWF(new ByteArrayInputStream(binaryDataTag.binaryData.getRangeData()), new ProgressListener() { + InputStream is = new ByteArrayInputStream(binaryDataTag.binaryData.getRangeData()); + SWF bswf = new SWF(is, null, "(SWF Data)", new ProgressListener() { @Override public void progress(int p) { Main.getLoadingDialog().setPercent(p); } }, Configuration.parallelSpeedUp.get()); - bswf.fileTitle = "(SWF Data)"; binaryDataTag.innerSwf = bswf; bswf.binaryData = binaryDataTag; } catch (IOException ex) { diff --git a/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeContextMenu.java b/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeContextMenu.java index adeda0c80..03bd0a5c8 100644 --- a/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeContextMenu.java +++ b/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeContextMenu.java @@ -473,7 +473,7 @@ public class TagTreeContextMenu extends JPopupMenu implements ActionListener { tagsToRemove.add(((TagScript) tag).getTag()); } else if (tag instanceof Frame) { Frame frameNode = (Frame) tag; - Frame frame = frameNode.timeline.getFrames().get(frameNode.frame); + Frame frame = frameNode.timeline.getFrame(frameNode.frame); if (frame.showFrameTag != null) { tagsToRemove.add(frame.showFrameTag); } else { diff --git a/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeModel.java b/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeModel.java index 3cf489643..32231c9b1 100644 --- a/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeModel.java +++ b/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeModel.java @@ -185,7 +185,7 @@ public class TagTreeModel implements TreeModel { Timeline timeline = swf.getTimeline(); int frameCount = timeline.getFrameCount(); for (int i = 0; i < frameCount; i++) { - frames.add(timeline.getFrames().get(i)); + frames.add(timeline.getFrame(i)); } for (int i = sounds.size() - 1; i >= 0; i--) { @@ -414,7 +414,7 @@ public class TagTreeModel implements TreeModel { } else if (parentNode instanceof Frame) { return ((Frame) parentNode).innerTags.get(index); } else if (parentNode instanceof DefineSpriteTag) { - return ((DefineSpriteTag) parentNode).getTimeline().getFrames().get(index); + return ((DefineSpriteTag) parentNode).getTimeline().getFrame(index); } else if (parentNode instanceof DefineBinaryDataTag) { return ((DefineBinaryDataTag) parentNode).innerSwf; } else if (parentNode instanceof AS2Package) { diff --git a/src/com/jpexs/decompiler/flash/gui/timeline/TimelineBodyPanel.java b/src/com/jpexs/decompiler/flash/gui/timeline/TimelineBodyPanel.java index c02c44df1..af102a6aa 100644 --- a/src/com/jpexs/decompiler/flash/gui/timeline/TimelineBodyPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/timeline/TimelineBodyPanel.java @@ -41,7 +41,7 @@ import javax.swing.JPanel; */ public class TimelineBodyPanel extends JPanel implements MouseListener, KeyListener { - private final Timeline timeLine; + private final Timeline timeline; public static final Color motionTweenColor = new Color(0x59, 0xfe, 0x7c); @@ -85,10 +85,10 @@ public class TimelineBodyPanel extends JPanel implements MouseListener, KeyListe listeners.remove(l); } - public TimelineBodyPanel(Timeline timeLine) { + public TimelineBodyPanel(Timeline timeline) { - this.timeLine = timeLine; - Dimension dim = new Dimension(TimelinePanel.FRAME_WIDTH * timeLine.getFrameCount() + 1, TimelinePanel.FRAME_HEIGHT * timeLine.getMaxDepth()); + this.timeline = timeline; + Dimension dim = new Dimension(TimelinePanel.FRAME_WIDTH * timeline.getFrameCount() + 1, TimelinePanel.FRAME_HEIGHT * timeline.getMaxDepth()); setSize(dim); setPreferredSize(dim); addMouseListener(this); @@ -111,11 +111,11 @@ public class TimelineBodyPanel extends JPanel implements MouseListener, KeyListe int end_f = (clip.x + clip.width) / TimelinePanel.FRAME_WIDTH; int end_d = (clip.y + clip.height) / TimelinePanel.FRAME_HEIGHT; - int max_d = timeLine.getMaxDepth(); + int max_d = timeline.getMaxDepth(); if (max_d < end_d) { end_d = max_d; } - int max_f = timeLine.getFrameCount() - 1; + int max_f = timeline.getFrameCount() - 1; if (max_f < end_f) { end_f = max_f; } @@ -128,7 +128,7 @@ public class TimelineBodyPanel extends JPanel implements MouseListener, KeyListe for (int f = start_f; f <= end_f; f++) { for (int d = start_d; d <= end_d; d++) { - DepthState fl = timeLine.getFrames().get(f).layers.get(d); + DepthState fl = timeline.getFrame(f).layers.get(d); if (fl == null) { if ((f + 1) % 5 == 0) { g.setColor(emptyFrameSecondColor); @@ -143,19 +143,19 @@ public class TimelineBodyPanel extends JPanel implements MouseListener, KeyListe } for (int f = start_f; f <= end_f; f++) { for (int d = start_d; d <= end_d; d++) { - DepthState fl = timeLine.getFrames().get(f).layers.get(d); + DepthState fl = timeline.getFrame(f).layers.get(d); boolean motionTween = fl == null ? false : fl.motionTween; DepthState flNext = null; if (f < max_f) { - flNext = timeLine.getFrames().get(f + 1).layers.get(d); + flNext = timeline.getFrame(f + 1).layers.get(d); } DepthState flPrev = null; if (f > 0) { - flPrev = timeLine.getFrames().get(f - 1).layers.get(d); + flPrev = timeline.getFrame(f - 1).layers.get(d); } - CharacterTag cht = fl == null ? null : timeLine.swf.getCharacter(fl.characterId); + CharacterTag cht = fl == null ? null : timeline.swf.getCharacter(fl.characterId); boolean shapeTween = cht != null && (cht instanceof MorphShapeTag); boolean motionTweenStart = (!motionTween) && (flNext != null && flNext.motionTween); boolean motionTweenEnd = (!motionTween) && (flPrev != null && flPrev.motionTween); @@ -180,18 +180,18 @@ public class TimelineBodyPanel extends JPanel implements MouseListener, KeyListe if (fl == null) { - if (timeLine.getDepthMaxFrame().containsKey(d) && f < timeLine.getDepthMaxFrame().get(d)) { + if (timeline.getDepthMaxFrame().containsKey(d) && f < timeline.getDepthMaxFrame().get(d)) { int draw_f = f; - DepthState prev_ds = f < 1 ? null : timeLine.getFrames().get(f - 1).layers.get(d); + DepthState prev_ds = f < 1 ? null : timeline.getFrame(f - 1).layers.get(d); if (f == 0 || prev_ds != null) { draw_f = f; keyfound[d - start_d] = true; } else if (!keyfound[d - start_d]) { for (; draw_f >= 0; draw_f--) { - if (timeLine.getFrames().get(draw_f).layers.get(d) != null) { - if (timeLine.getFrames().get(draw_f).layers.get(d).characterId != -1) { + if (timeline.getFrame(draw_f).layers.get(d) != null) { + if (timeline.getFrame(draw_f).layers.get(d).characterId != -1) { break; } } @@ -200,9 +200,9 @@ public class TimelineBodyPanel extends JPanel implements MouseListener, KeyListe continue; } int num_frames = 1; - for (int i = draw_f + 1; i < timeLine.getFrames().size(); i++) { - if (timeLine.getFrames().get(i).layers.get(d) != null) { - if (timeLine.getFrames().get(i).layers.get(d).characterId != -1) { + for (int i = draw_f + 1; i < timeline.getFrameCount(); i++) { + if (timeline.getFrame(i).layers.get(d) != null) { + if (timeline.getFrame(i).layers.get(d).characterId != -1) { break; } } @@ -241,7 +241,7 @@ public class TimelineBodyPanel extends JPanel implements MouseListener, KeyListe } if (d == 0) { - if (!timeLine.getFrames().get(f).actions.isEmpty()) { + if (!timeline.getFrame(f).actions.isEmpty()) { g.setColor(aColor); g.setFont(getFont().deriveFont(fontSize)); int awidth = g.getFontMetrics().stringWidth("a"); @@ -257,7 +257,7 @@ public class TimelineBodyPanel extends JPanel implements MouseListener, KeyListe keyfound[d - start_d] = true; } else if (!keyfound[d - start_d]) { for (int k = f - 1; k >= 0; k--) { - fl = timeLine.getFrames().get(k).layers.get(d); + fl = timeline.getFrame(k).layers.get(d); if (fl == null) { break; } @@ -271,8 +271,8 @@ public class TimelineBodyPanel extends JPanel implements MouseListener, KeyListe continue; } int num_frames = 1; - for (int n = draw_f + 1; n < timeLine.getFrameCount(); n++) { - fl = timeLine.getFrames().get(n).layers.get(d); + for (int n = draw_f + 1; n < timeline.getFrameCount(); n++) { + fl = timeline.getFrame(n).layers.get(d); if (fl == null) { break; } @@ -364,10 +364,10 @@ public class TimelineBodyPanel extends JPanel implements MouseListener, KeyListe Point p = e.getPoint(); p.x = p.x / TimelinePanel.FRAME_WIDTH; p.y = p.y / TimelinePanel.FRAME_HEIGHT; - if (p.x >= timeLine.getFrameCount()) { - p.x = timeLine.getFrameCount() - 1; + if (p.x >= timeline.getFrameCount()) { + p.x = timeline.getFrameCount() - 1; } - int maxDepth = timeLine.getMaxDepth(); + int maxDepth = timeline.getMaxDepth(); if (p.y > maxDepth) { p.y = maxDepth; } @@ -402,7 +402,7 @@ public class TimelineBodyPanel extends JPanel implements MouseListener, KeyListe } break; case 39: //right - if (cursor.x < timeLine.getFrames().size() - 1) { + if (cursor.x < timeline.getFrameCount() - 1) { frameSelect(cursor.x + 1, cursor.y); } break; @@ -412,7 +412,7 @@ public class TimelineBodyPanel extends JPanel implements MouseListener, KeyListe } break; case 40: //down - if (cursor.y < timeLine.getMaxDepth()) { + if (cursor.y < timeline.getMaxDepth()) { frameSelect(cursor.x, cursor.y + 1); } break;