diff --git a/trunk/src/com/jpexs/decompiler/flash/Main.java b/trunk/src/com/jpexs/decompiler/flash/Main.java index ee3336927..39b3dda4f 100644 --- a/trunk/src/com/jpexs/decompiler/flash/Main.java +++ b/trunk/src/com/jpexs/decompiler/flash/Main.java @@ -504,9 +504,9 @@ public class Main { boolean exportOK; try { printHeader(); - dump_tags = true; SWF exfile = new SWF(new FileInputStream(inFile)); exfile.addEventListener(new EventListener() { + @Override public void handleEvent(String event, Object data) { if (event.equals("export")) { System.out.println((String) data); diff --git a/trunk/src/com/jpexs/decompiler/flash/SWF.java b/trunk/src/com/jpexs/decompiler/flash/SWF.java index d002556ca..7c3bb4db4 100644 --- a/trunk/src/com/jpexs/decompiler/flash/SWF.java +++ b/trunk/src/com/jpexs/decompiler/flash/SWF.java @@ -46,6 +46,7 @@ import com.jpexs.decompiler.flash.flv.FLVTAG; import com.jpexs.decompiler.flash.flv.VIDEODATA; import com.jpexs.decompiler.flash.graph.GraphSourceItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import com.jpexs.decompiler.flash.gui.FrameNode; import com.jpexs.decompiler.flash.gui.TagNode; import com.jpexs.decompiler.flash.helpers.Helper; import com.jpexs.decompiler.flash.helpers.Highlighting; @@ -55,10 +56,16 @@ import com.jpexs.decompiler.flash.tags.DefineBitsJPEG4Tag; import com.jpexs.decompiler.flash.tags.DefineBitsLossless2Tag; import com.jpexs.decompiler.flash.tags.DefineBitsLosslessTag; import com.jpexs.decompiler.flash.tags.DefineBitsTag; +import com.jpexs.decompiler.flash.tags.DefineButton2Tag; +import com.jpexs.decompiler.flash.tags.DefineButtonTag; import com.jpexs.decompiler.flash.tags.DefineSoundTag; +import com.jpexs.decompiler.flash.tags.DefineSpriteTag; import com.jpexs.decompiler.flash.tags.DefineVideoStreamTag; import com.jpexs.decompiler.flash.tags.DoABCTag; +import com.jpexs.decompiler.flash.tags.DoInitActionTag; +import com.jpexs.decompiler.flash.tags.ExportAssetsTag; import com.jpexs.decompiler.flash.tags.JPEGTablesTag; +import com.jpexs.decompiler.flash.tags.ShowFrameTag; import com.jpexs.decompiler.flash.tags.SoundStreamBlockTag; import com.jpexs.decompiler.flash.tags.SoundStreamHeadTypeTag; import com.jpexs.decompiler.flash.tags.Tag; @@ -418,18 +425,91 @@ public class SWF { t.abc.addEventListener(evl); t.abc.export(outdir, isPcode, abcTags, "tag " + (i + 1) + "/" + abcTags.size() + " "); } - for (DoABCTag t : abcTags) { - } if (!asV3Found) { List list2 = new ArrayList(); list2.addAll(tags); - List list = TagNode.createTagList(list2); + List list = createASTagList(list2, null); + TagNode.setExport(list, true); - return TagNode.exportNodeAS(list, outdir, isPcode); + if(!outdir.endsWith(File.separator)){ + outdir+=File.separator; + } + outdir += "scripts" + File.separator; + return TagNode.exportNodeAS(list, outdir, isPcode,evl); } return asV3Found; } + + public static List createASTagList(List list, Object parent) { + List ret = new ArrayList(); + int frame = 1; + List frames = new ArrayList(); + + List exportAssetsTags = new ArrayList(); + for (Object t : list) { + if (t instanceof ExportAssetsTag) { + exportAssetsTags.add((ExportAssetsTag) t); + } + if (t instanceof ShowFrameTag) { + TagNode tti = new TagNode(new FrameNode(frame, parent, false)); + + for (int r = ret.size() - 1; r >= 0; r--) { + if (!(ret.get(r).tag instanceof DefineSpriteTag)) { + if (!(ret.get(r).tag instanceof DefineButtonTag)) { + if (!(ret.get(r).tag instanceof DefineButton2Tag)) { + if (!(ret.get(r).tag instanceof DoInitActionTag)) { + tti.subItems.add(ret.get(r)); + ret.remove(r); + } + } + } + } + } + frame++; + frames.add(tti); + } else if (t instanceof ASMSource) { + TagNode tti = new TagNode(t); + ret.add(tti); + } else if (t instanceof Container) { + if (((Container) t).getItemCount() > 0) { + + TagNode tti = new TagNode(t); + List subItems = ((Container) t).getSubItems(); + + tti.subItems = createASTagList(subItems, t); + ret.add(tti); + } + } + + } + ret.addAll(frames); + for (int i = ret.size() - 1; i >= 0; i--) { + if (ret.get(i).tag instanceof DefineSpriteTag) { + ((DefineSpriteTag) ret.get(i).tag).exportAssetsTags = exportAssetsTags; + } + if (ret.get(i).tag instanceof DefineButtonTag) { + ((DefineButtonTag) ret.get(i).tag).exportAssetsTags = exportAssetsTags; + } + if (ret.get(i).tag instanceof DefineButton2Tag) { + ((DefineButton2Tag) ret.get(i).tag).exportAssetsTags = exportAssetsTags; + } + if (ret.get(i).tag instanceof DoInitActionTag) { + ((DoInitActionTag) ret.get(i).tag).exportAssetsTags = exportAssetsTags; + } + if (ret.get(i).tag instanceof ASMSource) { + ASMSource ass = (ASMSource) ret.get(i).tag; + if (ass.containsSource()) { + continue; + } + } + if (ret.get(i).subItems.isEmpty()) { + ret.remove(i); + } + } + return ret; + } + protected HashSet listeners = new HashSet(); public void addEventListener(EventListener listener) { diff --git a/trunk/src/com/jpexs/decompiler/flash/SWFInputStream.java b/trunk/src/com/jpexs/decompiler/flash/SWFInputStream.java index 7cab86918..3d0992d03 100644 --- a/trunk/src/com/jpexs/decompiler/flash/SWFInputStream.java +++ b/trunk/src/com/jpexs/decompiler/flash/SWFInputStream.java @@ -652,7 +652,7 @@ public class SWFInputStream extends InputStream { method = 2; goesPrev = readActionListAtPos(true, localData, stack, cpool, sis, rri, ip, retdups, ip); }*/ - goesPrev = readActionListAtPos(true, localData, stack, cpool, sis, rri, ip, retdups, ip); + goesPrev = readActionListAtPos(false,true, localData, stack, cpool, sis, rri, ip, retdups, ip); if (goesPrev) { } else { @@ -708,7 +708,7 @@ public class SWFInputStream extends InputStream { return ret; } - private static boolean readActionListAtPos(boolean enableVariables, List localData, Stack stack, ConstantPool cpool, SWFInputStream sis, ReReadableInputStream rri, int ip, List ret, int startIp) throws IOException { + private static boolean readActionListAtPos(boolean notCompileTime,boolean enableVariables, List localData, Stack stack, ConstantPool cpool, SWFInputStream sis, ReReadableInputStream rri, int ip, List ret, int startIp) throws IOException { boolean debugMode = false; boolean decideBranch = false; boolean retv = false; @@ -805,7 +805,7 @@ public class SWFInputStream extends InputStream { } else if (next.equals("c")) { goaif = true; } - } else if (top.isCompileTime() && ((!top.isVariableComputed()) || (top.isVariableComputed() && enableVariables))) { + } else if (top.isCompileTime() && ((!top.isVariableComputed()) || (top.isVariableComputed() && enableVariables && (!notCompileTime)))) { //if(top.isCompileTime()) { //if(false){ if (enableVariables) { @@ -922,14 +922,18 @@ public class SWFInputStream extends InputStream { rri.setPos(ip); filePos = rri.getPos(); if (goaif) { + if(aif.ignoreUsed && aif.jumpUsed){ + break; + } aif.ignoreUsed = true; aif.jumpUsed = true; int oldPos = rri.getPos(); Stack substack = (Stack) stack.clone(); - if (readActionListAtPos(enableVariables, localData, substack, cpool, sis, rri, rri.getPos() + aif.offset, ret, startIp)) { + if (readActionListAtPos(true,enableVariables, localData, substack, cpool, sis, rri, rri.getPos() + aif.offset, ret, startIp)) { retv = true; } rri.setPos(oldPos); + notCompileTime = true; } prevIp = ip; } diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java b/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java index b413b12cf..ec39e98ad 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java @@ -671,74 +671,7 @@ public class MainFrame extends JFrame implements ActionListener, TreeSelectionLi } } - public static List createASTagList(List list, Object parent) { - List ret = new ArrayList(); - int frame = 1; - List frames = new ArrayList(); - - List exportAssetsTags = new ArrayList(); - for (Object t : list) { - if (t instanceof ExportAssetsTag) { - exportAssetsTags.add((ExportAssetsTag) t); - } - if (t instanceof ShowFrameTag) { - TagNode tti = new TagNode(new FrameNode(frame, parent, false)); - - for (int r = ret.size() - 1; r >= 0; r--) { - if (!(ret.get(r).tag instanceof DefineSpriteTag)) { - if (!(ret.get(r).tag instanceof DefineButtonTag)) { - if (!(ret.get(r).tag instanceof DefineButton2Tag)) { - if (!(ret.get(r).tag instanceof DoInitActionTag)) { - tti.subItems.add(ret.get(r)); - ret.remove(r); - } - } - } - } - } - frame++; - frames.add(tti); - } else if (t instanceof ASMSource) { - TagNode tti = new TagNode(t); - ret.add(tti); - } else if (t instanceof Container) { - if (((Container) t).getItemCount() > 0) { - - TagNode tti = new TagNode(t); - List subItems = ((Container) t).getSubItems(); - - tti.subItems = createASTagList(subItems, t); - ret.add(tti); - } - } - - } - ret.addAll(frames); - for (int i = ret.size() - 1; i >= 0; i--) { - if (ret.get(i).tag instanceof DefineSpriteTag) { - ((DefineSpriteTag) ret.get(i).tag).exportAssetsTags = exportAssetsTags; - } - if (ret.get(i).tag instanceof DefineButtonTag) { - ((DefineButtonTag) ret.get(i).tag).exportAssetsTags = exportAssetsTags; - } - if (ret.get(i).tag instanceof DefineButton2Tag) { - ((DefineButton2Tag) ret.get(i).tag).exportAssetsTags = exportAssetsTags; - } - if (ret.get(i).tag instanceof DoInitActionTag) { - ((DoInitActionTag) ret.get(i).tag).exportAssetsTags = exportAssetsTags; - } - if (ret.get(i).tag instanceof ASMSource) { - ASMSource ass = (ASMSource) ret.get(i).tag; - if (ass.containsSource()) { - continue; - } - } - if (ret.get(i).subItems.isEmpty()) { - ret.remove(i); - } - } - return ret; - } + public List getSelectedNodes() { List ret = new ArrayList(); @@ -937,7 +870,7 @@ public class MainFrame extends JFrame implements ActionListener, TreeSelectionLi } } - actionScript = createASTagList(list, null); + actionScript = SWF.createASTagList(list, null); TagNode textsNode = new TagNode("texts"); textsNode.subItems.addAll(texts); diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/TagNode.java b/trunk/src/com/jpexs/decompiler/flash/gui/TagNode.java index ecd47fadb..8de8ebb5f 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/TagNode.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/TagNode.java @@ -233,8 +233,12 @@ public class TagNode { return exportNodeAS(nodeList, outdir, isPcode, null); } - public static boolean exportNodeAS(List nodeList, String outdir, boolean isPcode, EventListener ev) { + public static boolean exportNodeAS(List nodeList, String outdir, boolean isPcode, EventListener ev) { File dir = new File(outdir); + + if(!outdir.endsWith(File.separator)){ + outdir=outdir + File.separator; + } List existingNames = new ArrayList(); for (TagNode node : nodeList) { String name = ""; @@ -256,7 +260,7 @@ public class TagNode { dir.mkdirs(); } try { - String f = outdir + File.separatorChar + name + ".as"; + String f = outdir + name + ".as"; if (ev != null) { ev.handleEvent("export", "Exporting " + f + " ..."); } @@ -277,7 +281,7 @@ public class TagNode { } } } else { - exportNodeAS(node.subItems, outdir + File.separatorChar + name, isPcode, ev); + exportNodeAS(node.subItems, outdir+name, isPcode, ev); } } diff --git a/trunk/src/com/jpexs/decompiler/flash/types/shaperecords/SHAPERECORD.java b/trunk/src/com/jpexs/decompiler/flash/types/shaperecords/SHAPERECORD.java index 9d6a23d53..3648df987 100644 --- a/trunk/src/com/jpexs/decompiler/flash/types/shaperecords/SHAPERECORD.java +++ b/trunk/src/com/jpexs/decompiler/flash/types/shaperecords/SHAPERECORD.java @@ -64,7 +64,7 @@ public abstract class SHAPERECORD implements Cloneable { params += " stroke=\"" + ((shapeNum >= 3) ? lineStyle.colorA.toHexRGB() : lineStyle.color.toHexRGB()) + "\""; } if (useLineStyle2 && lineStyle2 != null) { - params += " stroke-width=\"" + twipToPixel(lineStyle2.width) + "\" stroke=\"" + lineStyle2.color.toHexRGB() + "\""; + params += " stroke-width=\"" + twipToPixel(lineStyle2.width) + "\""+(lineStyle2.color!=null?" stroke=\"" + lineStyle2.color.toHexRGB() + "\"":""); } String points = ""; int x = 0;