mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-02 07:05:00 +00:00
TagTree nodes/items hierarchy refactored
This commit is contained in:
@@ -20,14 +20,21 @@ package com.jpexs.decompiler.flash;
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class PackageNode implements TreeElementItem {
|
||||
public class AS3PackageNodeItem implements TreeElementItem {
|
||||
|
||||
private SWF swf;
|
||||
public String packageName;
|
||||
|
||||
public PackageNode(String packageName) {
|
||||
public AS3PackageNodeItem(String packageName, SWF swf) {
|
||||
this.swf = swf;
|
||||
this.packageName = packageName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SWF getSwf() {
|
||||
return swf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return packageName;
|
||||
@@ -16,24 +16,27 @@
|
||||
*/
|
||||
package com.jpexs.decompiler.flash;
|
||||
|
||||
import com.jpexs.decompiler.flash.tags.Tag;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class FrameNode implements TreeElementItem {
|
||||
public class FrameNodeItem implements TreeItem {
|
||||
|
||||
private SWF swf;
|
||||
private int frame;
|
||||
private Object parent;
|
||||
private Tag parent;
|
||||
private boolean display;
|
||||
|
||||
public FrameNode(SWF swf, int frame, Object parent, boolean display) {
|
||||
public FrameNodeItem(SWF swf, int frame, Tag parent, boolean display) {
|
||||
this.swf = swf;
|
||||
this.frame = frame;
|
||||
this.parent = parent;
|
||||
this.display = display;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SWF getSwf() {
|
||||
return swf;
|
||||
}
|
||||
@@ -51,7 +54,7 @@ public class FrameNode implements TreeElementItem {
|
||||
return frame;
|
||||
}
|
||||
|
||||
public Object getParent() {
|
||||
public Tag getParent() {
|
||||
return parent;
|
||||
}
|
||||
}
|
||||
@@ -55,6 +55,7 @@ import com.jpexs.decompiler.flash.flv.AUDIODATA;
|
||||
import com.jpexs.decompiler.flash.flv.FLVOutputStream;
|
||||
import com.jpexs.decompiler.flash.flv.FLVTAG;
|
||||
import com.jpexs.decompiler.flash.flv.VIDEODATA;
|
||||
import com.jpexs.decompiler.flash.gui.AS2PackageNodeItem;
|
||||
import com.jpexs.decompiler.flash.helpers.collections.MyEntry;
|
||||
import com.jpexs.decompiler.flash.tags.ABCContainerTag;
|
||||
import com.jpexs.decompiler.flash.tags.DefineBinaryDataTag;
|
||||
@@ -86,6 +87,11 @@ import com.jpexs.decompiler.flash.tags.base.RemoveTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.ShapeTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.SoundStreamHeadTypeTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.TextTag;
|
||||
import com.jpexs.decompiler.flash.treenodes.AS2PackageNode;
|
||||
import com.jpexs.decompiler.flash.treenodes.ContainerNode;
|
||||
import com.jpexs.decompiler.flash.treenodes.FrameNode;
|
||||
import com.jpexs.decompiler.flash.treenodes.TagNode;
|
||||
import com.jpexs.decompiler.flash.treenodes.TreeNode;
|
||||
import com.jpexs.decompiler.flash.types.CXFORM;
|
||||
import com.jpexs.decompiler.flash.types.CXFORMWITHALPHA;
|
||||
import com.jpexs.decompiler.flash.types.MATRIX;
|
||||
@@ -154,7 +160,7 @@ import javax.imageio.ImageIO;
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public final class SWF {
|
||||
public final class SWF implements TreeItem {
|
||||
|
||||
/**
|
||||
* Default version of SWF file format
|
||||
@@ -418,6 +424,11 @@ public final class SWF {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public SWF getSwf() {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get title of the file
|
||||
*
|
||||
@@ -713,7 +724,7 @@ public final class SWF {
|
||||
List<File> ret = new ArrayList<>();
|
||||
List<ContainerItem> list2 = new ArrayList<>();
|
||||
list2.addAll(tags);
|
||||
List<TagNode> list = createASTagList(list2, null);
|
||||
List<TreeNode> list = createASTagList(list2, null);
|
||||
|
||||
TagNode.setExport(list, true);
|
||||
if (!outdir.endsWith(File.separator)) {
|
||||
@@ -811,27 +822,27 @@ public final class SWF {
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static List<TagNode> createASTagList(List<? extends ContainerItem> list, Object parent) {
|
||||
List<TagNode> ret = new ArrayList<>();
|
||||
public static List<TreeNode> createASTagList(List<? extends ContainerItem> list, Tag parent) {
|
||||
List<TreeNode> ret = new ArrayList<>();
|
||||
int frame = 1;
|
||||
List<TagNode> frames = new ArrayList<>();
|
||||
List<TreeNode> frames = new ArrayList<>();
|
||||
|
||||
List<ExportAssetsTag> exportAssetsTags = new ArrayList<>();
|
||||
for (ContainerItem t : list) {
|
||||
if (t instanceof ExportAssetsTag) {
|
||||
exportAssetsTags.add((ExportAssetsTag) t);
|
||||
}
|
||||
TagNode addNode = null;
|
||||
TreeNode addNode = null;
|
||||
if (t instanceof ShowFrameTag) {
|
||||
TagNode tti = new TagNode(new FrameNode(t.getSwf(), frame, parent, false), t.getSwf());
|
||||
FrameNode tti = new FrameNode(new FrameNodeItem(t.getSwf(), 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)) {
|
||||
if (!(ret.get(r).tag instanceof PackageNode)) {
|
||||
tti.subItems.add(ret.get(r));
|
||||
if (!(ret.get(r).getItem() instanceof DefineSpriteTag)) {
|
||||
if (!(ret.get(r).getItem() instanceof DefineButtonTag)) {
|
||||
if (!(ret.get(r).getItem() instanceof DefineButton2Tag)) {
|
||||
if (!(ret.get(r).getItem() instanceof DoInitActionTag)) {
|
||||
if (!(ret.get(r).getItem() instanceof AS2PackageNodeItem)) {
|
||||
tti.subNodes.add(ret.get(r));
|
||||
ret.remove(r);
|
||||
}
|
||||
}
|
||||
@@ -842,23 +853,24 @@ public final class SWF {
|
||||
frame++;
|
||||
frames.add(tti);
|
||||
} else if (t instanceof ASMSource) {
|
||||
TagNode tti = new TagNode(t, t.getSwf());
|
||||
ContainerNode tti = new ContainerNode(t);
|
||||
//ret.add(tti);
|
||||
addNode = tti;
|
||||
} else if (t instanceof Container) {
|
||||
if (((Container) t).getItemCount() > 0) {
|
||||
|
||||
TagNode tti = new TagNode(t, t.getSwf());
|
||||
ContainerNode tti = new ContainerNode(t);
|
||||
List<ContainerItem> subItems = ((Container) t).getSubItems();
|
||||
|
||||
tti.subItems = createASTagList(subItems, t);
|
||||
Tag tag = t instanceof Tag ? (Tag) t : null;
|
||||
tti.subNodes = createASTagList(subItems, tag);
|
||||
addNode = tti;
|
||||
//ret.add(tti);
|
||||
}
|
||||
}
|
||||
if (addNode != null) {
|
||||
if (addNode.tag instanceof CharacterIdTag) {
|
||||
CharacterIdTag cit = (CharacterIdTag) addNode.tag;
|
||||
if (addNode.getItem() instanceof CharacterIdTag) {
|
||||
CharacterIdTag cit = (CharacterIdTag) addNode.getItem();
|
||||
String path = cit.getExportName();
|
||||
if (path == null) {
|
||||
path = "";
|
||||
@@ -869,17 +881,17 @@ public final class SWF {
|
||||
} else {
|
||||
pathParts = new String[]{path};
|
||||
}
|
||||
List<TagNode> items = ret;
|
||||
List<TreeNode> items = ret;
|
||||
int pos = 0;
|
||||
TagNode selNode = null;
|
||||
TreeNode selNode = null;
|
||||
do {
|
||||
if (pos == pathParts.length - 1) {
|
||||
break;
|
||||
}
|
||||
selNode = null;
|
||||
for (TagNode node : items) {
|
||||
if (node.tag instanceof PackageNode) {
|
||||
PackageNode pkg = (PackageNode) node.tag;
|
||||
for (TreeNode node : items) {
|
||||
if (node.getItem() instanceof AS2PackageNodeItem) {
|
||||
AS2PackageNodeItem pkg = (AS2PackageNodeItem) node.getItem();
|
||||
if (pkg.packageName.equals(pathParts[pos])) {
|
||||
selNode = node;
|
||||
break;
|
||||
@@ -888,8 +900,8 @@ public final class SWF {
|
||||
}
|
||||
int pkgCount = 0;
|
||||
for (; pkgCount < items.size(); pkgCount++) {
|
||||
if (items.get(pkgCount).tag instanceof PackageNode) {
|
||||
PackageNode pkg = (PackageNode) items.get(pkgCount).tag;
|
||||
if (items.get(pkgCount).getItem() instanceof AS3PackageNodeItem) {
|
||||
AS2PackageNodeItem pkg = (AS2PackageNodeItem) items.get(pkgCount).getItem();
|
||||
if (pkg.packageName.compareTo(pathParts[pos]) > 0) {
|
||||
break;
|
||||
}
|
||||
@@ -898,19 +910,19 @@ public final class SWF {
|
||||
}
|
||||
}
|
||||
if (selNode == null) {
|
||||
items.add(pkgCount, selNode = new TagNode(new PackageNode(pathParts[pos]), t.getSwf()));
|
||||
items.add(pkgCount, selNode = new AS2PackageNode(new AS2PackageNodeItem(pathParts[pos], t.getSwf())));
|
||||
}
|
||||
pos++;
|
||||
if (selNode != null) {
|
||||
items = selNode.subItems;
|
||||
items = selNode.subNodes;
|
||||
}
|
||||
|
||||
} while (selNode != null);
|
||||
|
||||
int clsCount = 0;
|
||||
for (; clsCount < items.size(); clsCount++) {
|
||||
if (items.get(clsCount).tag instanceof CharacterIdTag) {
|
||||
CharacterIdTag ct = (CharacterIdTag) items.get(clsCount).tag;
|
||||
if (items.get(clsCount).getItem() instanceof CharacterIdTag) {
|
||||
CharacterIdTag ct = (CharacterIdTag) items.get(clsCount).getItem();
|
||||
String expName = ct.getExportName();
|
||||
if (expName == null) {
|
||||
expName = "";
|
||||
@@ -918,7 +930,7 @@ public final class SWF {
|
||||
if (expName.contains(".")) {
|
||||
expName = expName.substring(expName.lastIndexOf('.') + 1);
|
||||
}
|
||||
if ((ct.getClass().getName() + "_" + expName).compareTo(addNode.tag.getClass().getName() + "_" + pathParts[pos]) > 0) {
|
||||
if ((ct.getClass().getName() + "_" + expName).compareTo(addNode.getItem().getClass().getName() + "_" + pathParts[pos]) > 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -932,25 +944,25 @@ public final class SWF {
|
||||
}
|
||||
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).getItem() instanceof DefineSpriteTag) {
|
||||
((DefineSpriteTag) ret.get(i).getItem()).exportAssetsTags = exportAssetsTags;
|
||||
}
|
||||
if (ret.get(i).tag instanceof DefineButtonTag) {
|
||||
((DefineButtonTag) ret.get(i).tag).exportAssetsTags = exportAssetsTags;
|
||||
if (ret.get(i).getItem() instanceof DefineButtonTag) {
|
||||
((DefineButtonTag) ret.get(i).getItem()).exportAssetsTags = exportAssetsTags;
|
||||
}
|
||||
if (ret.get(i).tag instanceof DefineButton2Tag) {
|
||||
((DefineButton2Tag) ret.get(i).tag).exportAssetsTags = exportAssetsTags;
|
||||
if (ret.get(i).getItem() instanceof DefineButton2Tag) {
|
||||
((DefineButton2Tag) ret.get(i).getItem()).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 (ret.get(i).getItem() instanceof ASMSource) {
|
||||
ASMSource ass = (ASMSource) ret.get(i).getItem();
|
||||
if (ass.containsSource()) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (ret.get(i).subItems.isEmpty()) {
|
||||
if (ret.get(i).subNodes.isEmpty()) {
|
||||
ret.remove(i);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,14 +20,21 @@ package com.jpexs.decompiler.flash;
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class StringNode implements TreeElementItem {
|
||||
public class StringItem implements TreeItem {
|
||||
|
||||
public SWF swf;
|
||||
private String str;
|
||||
|
||||
public StringNode(String str) {
|
||||
public StringItem(String str, SWF swf) {
|
||||
this.swf = swf;
|
||||
this.str = str;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SWF getSwf() {
|
||||
return swf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return str;
|
||||
@@ -1,384 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2013 JPEXS
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash;
|
||||
|
||||
import com.jpexs.decompiler.flash.action.Action;
|
||||
import com.jpexs.decompiler.flash.configuration.Configuration;
|
||||
import com.jpexs.decompiler.flash.helpers.FileTextWriter;
|
||||
import com.jpexs.decompiler.flash.tags.DefineBitsJPEG2Tag;
|
||||
import com.jpexs.decompiler.flash.tags.DefineBitsJPEG3Tag;
|
||||
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.DefineEditTextTag;
|
||||
import com.jpexs.decompiler.flash.tags.DefineFont2Tag;
|
||||
import com.jpexs.decompiler.flash.tags.DefineFont3Tag;
|
||||
import com.jpexs.decompiler.flash.tags.DefineFont4Tag;
|
||||
import com.jpexs.decompiler.flash.tags.DefineFontTag;
|
||||
import com.jpexs.decompiler.flash.tags.DefineMorphShape2Tag;
|
||||
import com.jpexs.decompiler.flash.tags.DefineMorphShapeTag;
|
||||
import com.jpexs.decompiler.flash.tags.DefineShape2Tag;
|
||||
import com.jpexs.decompiler.flash.tags.DefineShape3Tag;
|
||||
import com.jpexs.decompiler.flash.tags.DefineShape4Tag;
|
||||
import com.jpexs.decompiler.flash.tags.DefineShapeTag;
|
||||
import com.jpexs.decompiler.flash.tags.DefineSpriteTag;
|
||||
import com.jpexs.decompiler.flash.tags.DefineText2Tag;
|
||||
import com.jpexs.decompiler.flash.tags.DefineTextTag;
|
||||
import com.jpexs.decompiler.flash.tags.ExportAssetsTag;
|
||||
import com.jpexs.decompiler.flash.tags.ShowFrameTag;
|
||||
import com.jpexs.decompiler.flash.tags.Tag;
|
||||
import com.jpexs.decompiler.flash.tags.base.ASMSource;
|
||||
import com.jpexs.decompiler.flash.tags.base.Container;
|
||||
import com.jpexs.decompiler.flash.tags.base.ContainerItem;
|
||||
import com.jpexs.decompiler.flash.tags.base.Exportable;
|
||||
import com.jpexs.decompiler.graph.ExportMode;
|
||||
import com.jpexs.decompiler.graph.TranslateException;
|
||||
import com.jpexs.helpers.CancellableWorker;
|
||||
import com.jpexs.helpers.Helper;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class TagNode implements TreeNode {
|
||||
|
||||
public List<TagNode> subItems;
|
||||
public TreeElementItem tag;
|
||||
private SWF swf;
|
||||
public boolean export = false;
|
||||
public String mark;
|
||||
|
||||
public List<TagNode> getAllSubs() {
|
||||
List<TagNode> ret = new ArrayList<>();
|
||||
ret.addAll(subItems);
|
||||
for (TagNode n : subItems) {
|
||||
ret.addAll(n.getAllSubs());
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public TagNode(Tag tag) {
|
||||
this(tag, tag.getSwf());
|
||||
}
|
||||
|
||||
public TagNode(TreeElementItem tag, SWF swf) {
|
||||
this.swf = swf;
|
||||
this.tag = tag;
|
||||
this.subItems = new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SWF getSwf() {
|
||||
return swf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return tag.toString();
|
||||
}
|
||||
|
||||
public static List<TagNode> createTagList(List<ContainerItem> list, SWF swf) {
|
||||
List<TagNode> ret = new ArrayList<>();
|
||||
int frame = 1;
|
||||
List<TagNode> frames = new ArrayList<>();
|
||||
List<TagNode> shapes = new ArrayList<>();
|
||||
List<TagNode> morphShapes = new ArrayList<>();
|
||||
List<TagNode> sprites = new ArrayList<>();
|
||||
List<TagNode> buttons = new ArrayList<>();
|
||||
List<TagNode> images = new ArrayList<>();
|
||||
List<TagNode> fonts = new ArrayList<>();
|
||||
List<TagNode> texts = new ArrayList<>();
|
||||
|
||||
|
||||
List<ExportAssetsTag> exportAssetsTags = new ArrayList<>();
|
||||
for (ContainerItem t : list) {
|
||||
if (t instanceof ExportAssetsTag) {
|
||||
exportAssetsTags.add((ExportAssetsTag) t);
|
||||
}
|
||||
if ((t instanceof DefineFontTag)
|
||||
|| (t instanceof DefineFont2Tag)
|
||||
|| (t instanceof DefineFont3Tag)
|
||||
|| (t instanceof DefineFont4Tag)) {
|
||||
fonts.add(new TagNode(t, t.getSwf()));
|
||||
}
|
||||
if ((t instanceof DefineTextTag)
|
||||
|| (t instanceof DefineText2Tag)
|
||||
|| (t instanceof DefineEditTextTag)) {
|
||||
texts.add(new TagNode(t, t.getSwf()));
|
||||
}
|
||||
|
||||
if ((t instanceof DefineBitsTag)
|
||||
|| (t instanceof DefineBitsJPEG2Tag)
|
||||
|| (t instanceof DefineBitsJPEG3Tag)
|
||||
|| (t instanceof DefineBitsJPEG4Tag)
|
||||
|| (t instanceof DefineBitsLosslessTag)
|
||||
|| (t instanceof DefineBitsLossless2Tag)) {
|
||||
images.add(new TagNode(t, t.getSwf()));
|
||||
}
|
||||
if ((t instanceof DefineShapeTag)
|
||||
|| (t instanceof DefineShape2Tag)
|
||||
|| (t instanceof DefineShape3Tag)
|
||||
|| (t instanceof DefineShape4Tag)) {
|
||||
shapes.add(new TagNode(t, t.getSwf()));
|
||||
}
|
||||
|
||||
if ((t instanceof DefineMorphShapeTag) || (t instanceof DefineMorphShape2Tag)) {
|
||||
morphShapes.add(new TagNode(t, t.getSwf()));
|
||||
}
|
||||
|
||||
if (t instanceof DefineSpriteTag) {
|
||||
sprites.add(new TagNode(t, t.getSwf()));
|
||||
}
|
||||
if ((t instanceof DefineButtonTag) || (t instanceof DefineButton2Tag)) {
|
||||
buttons.add(new TagNode(t, t.getSwf()));
|
||||
}
|
||||
if (t instanceof ShowFrameTag) {
|
||||
TagNode tti = new TagNode(new StringNode("frame" + frame), t.getSwf());
|
||||
|
||||
/* 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);
|
||||
} /*if (t instanceof ASMSource) {
|
||||
TagNode tti = new TagNode(t);
|
||||
ret.add(tti);
|
||||
} else */
|
||||
if (t instanceof Container) {
|
||||
TagNode tti = new TagNode(t, t.getSwf());
|
||||
if (((Container) t).getItemCount() > 0) {
|
||||
List<ContainerItem> subItems = ((Container) t).getSubItems();
|
||||
tti.subItems = createTagList(subItems, t.getSwf());
|
||||
}
|
||||
//ret.add(tti);
|
||||
}
|
||||
}
|
||||
|
||||
TagNode textsNode = new TagNode(new StringNode("texts"), swf);
|
||||
textsNode.subItems.addAll(texts);
|
||||
|
||||
TagNode imagesNode = new TagNode(new StringNode("images"), swf);
|
||||
imagesNode.subItems.addAll(images);
|
||||
|
||||
TagNode fontsNode = new TagNode(new StringNode("fonts"), swf);
|
||||
fontsNode.subItems.addAll(fonts);
|
||||
|
||||
|
||||
TagNode spritesNode = new TagNode(new StringNode("sprites"), swf);
|
||||
spritesNode.subItems.addAll(sprites);
|
||||
|
||||
TagNode shapesNode = new TagNode(new StringNode("shapes"), swf);
|
||||
shapesNode.subItems.addAll(shapes);
|
||||
|
||||
TagNode morphShapesNode = new TagNode(new StringNode("morphshapes"), swf);
|
||||
morphShapesNode.subItems.addAll(morphShapes);
|
||||
|
||||
TagNode buttonsNode = new TagNode(new StringNode("buttons"), swf);
|
||||
buttonsNode.subItems.addAll(buttons);
|
||||
|
||||
TagNode framesNode = new TagNode(new StringNode("frames"), swf);
|
||||
framesNode.subItems.addAll(frames);
|
||||
ret.add(shapesNode);
|
||||
ret.add(morphShapesNode);;
|
||||
ret.add(spritesNode);
|
||||
ret.add(textsNode);
|
||||
ret.add(imagesNode);
|
||||
ret.add(buttonsNode);
|
||||
ret.add(fontsNode);
|
||||
ret.add(framesNode);
|
||||
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 static void setExport(List<TagNode> nodeList, boolean export) {
|
||||
for (TagNode node : nodeList) {
|
||||
node.export = export;
|
||||
setExport(node.subItems, export);
|
||||
}
|
||||
}
|
||||
|
||||
public static int getTagCountRecursive(List<TagNode> nodeList) {
|
||||
int count = 0;
|
||||
|
||||
for (TagNode node : nodeList) {
|
||||
if (node.subItems.isEmpty()) {
|
||||
if ((node.tag instanceof ASMSource) && (node.export)) {
|
||||
count += 1;
|
||||
}
|
||||
} else {
|
||||
count += getTagCountRecursive(node.subItems);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
public static List<File> exportNodeAS(final AbortRetryIgnoreHandler handler, final List<TagNode> nodeList, final String outdir, final ExportMode exportMode, final EventListener ev) throws IOException {
|
||||
try {
|
||||
List<File> result = CancellableWorker.call(new Callable<List<File>>() {
|
||||
|
||||
@Override
|
||||
public List<File> call() throws Exception {
|
||||
AtomicInteger cnt = new AtomicInteger(1);
|
||||
int totalCount = TagNode.getTagCountRecursive(nodeList);
|
||||
return exportNodeAS(handler, nodeList, outdir, exportMode, cnt, totalCount, ev);
|
||||
}
|
||||
}, Configuration.exportTimeout.get(), TimeUnit.SECONDS);
|
||||
return result;
|
||||
} catch (ExecutionException | InterruptedException | TimeoutException ex) {
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
private static List<File> exportNodeAS(AbortRetryIgnoreHandler handler, List<TagNode> nodeList, String outdir, ExportMode exportMode, AtomicInteger index, int count, EventListener ev) throws IOException {
|
||||
File dir = new File(outdir);
|
||||
List<File> ret = new ArrayList<>();
|
||||
if (!outdir.endsWith(File.separator)) {
|
||||
outdir += File.separator;
|
||||
}
|
||||
List<String> existingNames = new ArrayList<>();
|
||||
for (TagNode node : nodeList) {
|
||||
String name = "";
|
||||
if (node.tag instanceof Exportable) {
|
||||
name = ((Exportable) node.tag).getExportFileName();
|
||||
} else {
|
||||
name = Helper.makeFileName(node.tag.toString());
|
||||
}
|
||||
int i = 1;
|
||||
String baseName = name;
|
||||
while (existingNames.contains(name)) {
|
||||
i++;
|
||||
name = baseName + "_" + i;
|
||||
}
|
||||
existingNames.add(name);
|
||||
if (node.subItems.isEmpty()) {
|
||||
if ((node.tag instanceof ASMSource) && (node.export)) {
|
||||
if (!dir.exists()) {
|
||||
if (!dir.mkdirs()) {
|
||||
if (!dir.exists()) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
boolean retry;
|
||||
do {
|
||||
retry = false;
|
||||
try {
|
||||
String f = outdir + name + ".as";
|
||||
int currentIndex = index.getAndIncrement();
|
||||
if (ev != null) {
|
||||
ev.handleEvent("exporting", "Exporting " + currentIndex + "/" + count + " " + f);
|
||||
}
|
||||
|
||||
long startTime = System.currentTimeMillis();
|
||||
|
||||
File file = new File(f);
|
||||
ASMSource asm = ((ASMSource) node.tag);
|
||||
try (FileTextWriter writer = new FileTextWriter(new FileOutputStream(f))) {
|
||||
if (exportMode == ExportMode.HEX) {
|
||||
asm.getActionSourcePrefix(writer);
|
||||
asm.getActionBytesAsHex(writer);
|
||||
asm.getActionSourceSuffix(writer);
|
||||
} else if (exportMode != ExportMode.SOURCE) {
|
||||
asm.getActionSourcePrefix(writer);
|
||||
asm.getASMSource(SWF.DEFAULT_VERSION, exportMode, writer, null);
|
||||
asm.getActionSourceSuffix(writer);
|
||||
} else {
|
||||
List<Action> as = asm.getActions(SWF.DEFAULT_VERSION);
|
||||
Action.setActionsAddresses(as, 0, SWF.DEFAULT_VERSION);
|
||||
Action.actionsToSource(asm, as, SWF.DEFAULT_VERSION, ""/*FIXME*/, writer);
|
||||
}
|
||||
}
|
||||
|
||||
long stopTime = System.currentTimeMillis();
|
||||
|
||||
if (ev != null) {
|
||||
long time = stopTime - startTime;
|
||||
ev.handleEvent("exported", "Exported " + currentIndex + "/" + count + " " + f + ", " + Helper.formatTimeSec(time));
|
||||
}
|
||||
|
||||
ret.add(file);
|
||||
} catch (InterruptedException ex) {
|
||||
} catch (IOException | OutOfMemoryError | TranslateException | StackOverflowError ex) {
|
||||
Logger.getLogger(TagNode.class.getName()).log(Level.SEVERE, "Decompilation error in file: " + name + ".as", ex);
|
||||
if (handler != null) {
|
||||
int action = handler.getNewInstance().handle(ex);
|
||||
switch (action) {
|
||||
case AbortRetryIgnoreHandler.ABORT:
|
||||
throw ex;
|
||||
case AbortRetryIgnoreHandler.RETRY:
|
||||
retry = true;
|
||||
break;
|
||||
case AbortRetryIgnoreHandler.IGNORE:
|
||||
retry = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} while (retry);
|
||||
}
|
||||
} else {
|
||||
ret.addAll(exportNodeAS(handler, node.subItems, outdir + name, exportMode, index, count, ev));
|
||||
}
|
||||
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,6 @@ package com.jpexs.decompiler.flash;
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public interface TreeElementItem {
|
||||
public interface TreeElementItem extends TreeItem {
|
||||
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ package com.jpexs.decompiler.flash;
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public interface TreeNode {
|
||||
public interface TreeItem {
|
||||
|
||||
public SWF getSwf();
|
||||
}
|
||||
@@ -16,13 +16,13 @@
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.abc;
|
||||
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.TreeElementItem;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.Multiname;
|
||||
import com.jpexs.decompiler.flash.abc.types.Namespace;
|
||||
import com.jpexs.decompiler.flash.abc.types.traits.Trait;
|
||||
import com.jpexs.decompiler.flash.configuration.Configuration;
|
||||
import com.jpexs.decompiler.flash.gui.AppStrings;
|
||||
import com.jpexs.decompiler.flash.helpers.FileTextWriter;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.flash.helpers.NulWriter;
|
||||
@@ -53,6 +53,11 @@ public class ScriptPack implements TreeElementItem {
|
||||
public List<Integer> traitIndices;
|
||||
private ClassPath path;
|
||||
|
||||
@Override
|
||||
public SWF getSwf() {
|
||||
return abc.swf;
|
||||
}
|
||||
|
||||
public ClassPath getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.types.traits.Trait;
|
||||
import com.jpexs.decompiler.flash.abc.types.traits.Traits;
|
||||
import com.jpexs.decompiler.flash.configuration.Configuration;
|
||||
import com.jpexs.decompiler.flash.gui.AppStrings;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.ExportMode;
|
||||
import com.jpexs.decompiler.graph.Graph;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2013 JPEXS
|
||||
* Copyright (C) 2013 JPEXS
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -17,21 +17,29 @@
|
||||
package com.jpexs.decompiler.flash.gui;
|
||||
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.TreeNode;
|
||||
import com.jpexs.decompiler.flash.TreeItem;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class TagTreeRoot implements TreeNode {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "root";
|
||||
public class AS2PackageNodeItem implements TreeItem {
|
||||
|
||||
private SWF swf;
|
||||
public String packageName;
|
||||
|
||||
public AS2PackageNodeItem(String packageName, SWF swf) {
|
||||
this.swf = swf;
|
||||
this.packageName = packageName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SWF getSwf() {
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
return swf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return packageName;
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,6 @@
|
||||
package com.jpexs.decompiler.flash.gui;
|
||||
|
||||
import com.jpexs.decompiler.flash.ApplicationInfo;
|
||||
import static com.jpexs.decompiler.flash.ApplicationInfo.applicationVerName;
|
||||
import com.jpexs.decompiler.flash.EventListener;
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.SWFSourceInfo;
|
||||
@@ -54,7 +53,6 @@ import java.util.logging.ConsoleHandler;
|
||||
import java.util.logging.FileHandler;
|
||||
import java.util.logging.Formatter;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.LogRecord;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.logging.SimpleFormatter;
|
||||
import java.util.regex.Matcher;
|
||||
|
||||
@@ -18,12 +18,10 @@ package com.jpexs.decompiler.flash.gui;
|
||||
|
||||
import com.jpexs.decompiler.flash.AbortRetryIgnoreHandler;
|
||||
import com.jpexs.decompiler.flash.ApplicationInfo;
|
||||
import com.jpexs.decompiler.flash.FrameNode;
|
||||
import com.jpexs.decompiler.flash.FrameNodeItem;
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.SWFOutputStream;
|
||||
import com.jpexs.decompiler.flash.TagNode;
|
||||
import com.jpexs.decompiler.flash.TreeElementItem;
|
||||
import com.jpexs.decompiler.flash.TreeNode;
|
||||
import com.jpexs.decompiler.flash.TreeItem;
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.RenameType;
|
||||
import com.jpexs.decompiler.flash.abc.ScriptPack;
|
||||
@@ -93,6 +91,9 @@ import com.jpexs.decompiler.flash.tags.base.SoundStreamHeadTypeTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.TextTag;
|
||||
import com.jpexs.decompiler.flash.tags.gfx.DefineCompactedFont;
|
||||
import com.jpexs.decompiler.flash.tags.text.ParseException;
|
||||
import com.jpexs.decompiler.flash.treenodes.SWFRoot;
|
||||
import com.jpexs.decompiler.flash.treenodes.TagNode;
|
||||
import com.jpexs.decompiler.flash.treenodes.TreeNode;
|
||||
import com.jpexs.decompiler.flash.types.GLYPHENTRY;
|
||||
import com.jpexs.decompiler.flash.types.MATRIX;
|
||||
import com.jpexs.decompiler.flash.types.RECT;
|
||||
@@ -243,7 +244,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
|
||||
private AbortRetryIgnoreHandler errorHandler = new GuiAbortRetryIgnoreHandler();
|
||||
private CancellableWorker setSourceWorker;
|
||||
public TreeNode oldNode;
|
||||
public TreeElementItem oldTag;
|
||||
public TreeItem oldTag;
|
||||
private File tempFile;
|
||||
|
||||
private static final String ACTION_SELECT_COLOR = "SELECTCOLOR";
|
||||
@@ -337,8 +338,8 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
|
||||
for (TreePath treePath : paths) {
|
||||
Object tagObj = treePath.getLastPathComponent();
|
||||
|
||||
if (tagObj instanceof TagNode) {
|
||||
Object tag = ((TagNode) tagObj).tag;
|
||||
if (tagObj instanceof TreeNode) {
|
||||
TreeItem tag = ((TreeNode) tagObj).getItem();
|
||||
if (!(tag instanceof Tag)) {
|
||||
allSelectedIsTag = false;
|
||||
break;
|
||||
@@ -355,8 +356,8 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
|
||||
if (paths.length == 1) {
|
||||
Object tagObj = paths[0].getLastPathComponent();
|
||||
|
||||
if (tagObj instanceof TagNode) {
|
||||
Object tag = ((TagNode) tagObj).tag;
|
||||
if (tagObj instanceof TreeNode) {
|
||||
TreeItem tag = ((TreeNode) tagObj).getItem();
|
||||
|
||||
if (tag instanceof ImageTag && ((ImageTag) tag).importSupported()) {
|
||||
replaceImageSelectionMenuItem.setVisible(true);
|
||||
@@ -967,11 +968,11 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
|
||||
}
|
||||
|
||||
public void updateClassesList() {
|
||||
List<TagNode> nodes = getASTagNode(tagTree);
|
||||
List<TreeNode> nodes = getASTagNode(tagTree);
|
||||
boolean updateNeeded = false;
|
||||
for (TagNode n : nodes) {
|
||||
if (n.tag instanceof ClassesListTreeModel) {
|
||||
((ClassesListTreeModel) n.tag).update();
|
||||
for (TreeNode n : nodes) {
|
||||
if (n.getItem() instanceof ClassesListTreeModel) {
|
||||
((ClassesListTreeModel) n.getItem()).update();
|
||||
updateNeeded = true;
|
||||
}
|
||||
}
|
||||
@@ -989,11 +990,11 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
|
||||
}
|
||||
|
||||
public void doFilter() {
|
||||
List<TagNode> nodes = getASTagNode(tagTree);
|
||||
List<TreeNode> nodes = getASTagNode(tagTree);
|
||||
boolean updateNeeded = false;
|
||||
for (TagNode n : nodes) {
|
||||
if (n.tag instanceof ClassesListTreeModel) {
|
||||
((ClassesListTreeModel) n.tag).setFilter(filterField.getText());
|
||||
for (TreeNode n : nodes) {
|
||||
if (n.getItem() instanceof ClassesListTreeModel) {
|
||||
((ClassesListTreeModel) n.getItem()).setFilter(filterField.getText());
|
||||
updateNeeded = true;
|
||||
}
|
||||
}
|
||||
@@ -1213,50 +1214,50 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
|
||||
}
|
||||
}
|
||||
|
||||
public List<Object> getSelected(JTree tree) {
|
||||
public List<TreeNode> getSelected(JTree tree) {
|
||||
TreeSelectionModel tsm = tree.getSelectionModel();
|
||||
TreePath[] tps = tsm.getSelectionPaths();
|
||||
List<Object> ret = new ArrayList<>();
|
||||
List<TreeNode> ret = new ArrayList<>();
|
||||
if (tps == null) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
for (TreePath tp : tps) {
|
||||
Object o = tp.getLastPathComponent();
|
||||
ret.add(o);
|
||||
ret.add((TreeNode) o);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public List<Object> getAllSubs(JTree tree, Object o) {
|
||||
TreeModel tm = tree.getModel();
|
||||
List<Object> ret = new ArrayList<>();
|
||||
public List<TreeNode> getAllSubs(JTree tree, Object o) {
|
||||
TagTreeModel tm = (TagTreeModel) tree.getModel();
|
||||
List<TreeNode> ret = new ArrayList<>();
|
||||
for (int i = 0; i < tm.getChildCount(o); i++) {
|
||||
Object c = tm.getChild(o, i);
|
||||
TreeNode c = tm.getChild(o, i);
|
||||
ret.add(c);
|
||||
ret.addAll(getAllSubs(tree, c));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public List<Object> getAllSelected(JTree tree) {
|
||||
public List<TreeNode> getAllSelected(TagTree tree) {
|
||||
TreeSelectionModel tsm = tree.getSelectionModel();
|
||||
TreePath[] tps = tsm.getSelectionPaths();
|
||||
List<Object> ret = new ArrayList<>();
|
||||
List<TreeNode> ret = new ArrayList<>();
|
||||
if (tps == null) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
for (TreePath tp : tps) {
|
||||
Object o = tp.getLastPathComponent();
|
||||
ret.add(o);
|
||||
ret.add((TreeNode) o);
|
||||
ret.addAll(getAllSubs(tree, o));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public List<TagNode> getASTagNode(JTree tree) {
|
||||
List<TagNode> result = new ArrayList<>();
|
||||
public List<TreeNode> getASTagNode(TagTree tree) {
|
||||
List<TreeNode> result = new ArrayList<>();
|
||||
TagTreeModel tm = (TagTreeModel) tree.getModel();
|
||||
if (tm == null) {
|
||||
return result;
|
||||
@@ -1264,16 +1265,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
|
||||
TreeNode root = tm.getRoot();
|
||||
for (int j = 0; j < tm.getChildCount(root); j++) {
|
||||
SWFRoot swfRoot = (SWFRoot) tm.getChild(root, j);
|
||||
for (int i = 0; i < tm.getChildCount(swfRoot); i++) {
|
||||
TreeNode node = tm.getChild(swfRoot, i);
|
||||
if (node instanceof TagNode) {
|
||||
TagNode tagNode = (TagNode) node;
|
||||
TreeElementItem tag = tagNode.tag;
|
||||
if (tag != null && "scripts".equals(tagNode.mark)) {
|
||||
result.add((TagNode) node);
|
||||
}
|
||||
}
|
||||
}
|
||||
result.add(swfRoot.scriptsNode);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -1289,58 +1281,49 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
|
||||
final boolean isFormatted = export.getOption(ExportDialog.OPTION_TEXTS) == 1;
|
||||
|
||||
List<File> ret = new ArrayList<>();
|
||||
List<Object> sel = getAllSelected(tagTree);
|
||||
List<TreeNode> sel = getAllSelected(tagTree);
|
||||
|
||||
for (SWF swf : swfs) {
|
||||
List<ScriptPack> tlsList = new ArrayList<>();
|
||||
JPEGTablesTag jtt = null;
|
||||
for (Tag t : swf.tags) {
|
||||
if (t instanceof JPEGTablesTag) {
|
||||
jtt = (JPEGTablesTag) t;
|
||||
break;
|
||||
}
|
||||
}
|
||||
List<Tag> images = new ArrayList<>();
|
||||
List<Tag> shapes = new ArrayList<>();
|
||||
List<Tag> movies = new ArrayList<>();
|
||||
List<Tag> sounds = new ArrayList<>();
|
||||
List<Tag> texts = new ArrayList<>();
|
||||
List<TagNode> actionNodes = new ArrayList<>();
|
||||
List<TreeNode> actionNodes = new ArrayList<>();
|
||||
List<Tag> binaryData = new ArrayList<>();
|
||||
for (Object d : sel) {
|
||||
for (TreeNode d : sel) {
|
||||
if (d.getItem().getSwf() != swf) {
|
||||
continue;
|
||||
}
|
||||
if (d instanceof TagNode) {
|
||||
TagNode n = (TagNode) d;
|
||||
if (n.getSwf() != swf) {
|
||||
continue;
|
||||
if (TagTree.getTreeNodeType(n.getItem()) == TreeNodeType.IMAGE) {
|
||||
images.add((Tag) n.getItem());
|
||||
}
|
||||
if (TagTree.getTagType(n.tag) == TagType.IMAGE) {
|
||||
images.add((Tag) n.tag);
|
||||
if (TagTree.getTreeNodeType(n.getItem()) == TreeNodeType.SHAPE) {
|
||||
shapes.add((Tag) n.getItem());
|
||||
}
|
||||
if (TagTree.getTagType(n.tag) == TagType.SHAPE) {
|
||||
shapes.add((Tag) n.tag);
|
||||
}
|
||||
if (TagTree.getTagType(n.tag) == TagType.AS) {
|
||||
if (TagTree.getTreeNodeType(n.getItem()) == TreeNodeType.AS) {
|
||||
actionNodes.add(n);
|
||||
}
|
||||
if (TagTree.getTagType(n.tag) == TagType.MOVIE) {
|
||||
movies.add((Tag) n.tag);
|
||||
if (TagTree.getTreeNodeType(n.getItem()) == TreeNodeType.MOVIE) {
|
||||
movies.add((Tag) n.getItem());
|
||||
}
|
||||
if (TagTree.getTagType(n.tag) == TagType.SOUND) {
|
||||
sounds.add((Tag) n.tag);
|
||||
if (TagTree.getTreeNodeType(n.getItem()) == TreeNodeType.SOUND) {
|
||||
sounds.add((Tag) n.getItem());
|
||||
}
|
||||
if (TagTree.getTagType(n.tag) == TagType.BINARY_DATA) {
|
||||
binaryData.add((Tag) n.tag);
|
||||
if (TagTree.getTreeNodeType(n.getItem()) == TreeNodeType.BINARY_DATA) {
|
||||
binaryData.add((Tag) n.getItem());
|
||||
}
|
||||
if (TagTree.getTagType(n.tag) == TagType.TEXT) {
|
||||
texts.add((Tag) n.tag);
|
||||
if (TagTree.getTreeNodeType(n.getItem()) == TreeNodeType.TEXT) {
|
||||
texts.add((Tag) n.getItem());
|
||||
}
|
||||
}
|
||||
if (d instanceof TreeElement) {
|
||||
if (((TreeElement) d).isLeaf()) {
|
||||
TreeElement treeElement = (TreeElement) d;
|
||||
if (treeElement.getSwf() == swf) {
|
||||
tlsList.add((ScriptPack) treeElement.getItem());
|
||||
}
|
||||
tlsList.add((ScriptPack) treeElement.getItem());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1358,9 +1341,9 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
|
||||
ret.add(tls.export(selFile, abcList, exportMode, Configuration.parallelSpeedUp.get()));
|
||||
}
|
||||
} else {
|
||||
List<TagNode> allNodes = new ArrayList<>();
|
||||
List<TagNode> asNodes = getASTagNode(tagTree);
|
||||
for (TagNode asn : asNodes) {
|
||||
List<TreeNode> allNodes = new ArrayList<>();
|
||||
List<TreeNode> asNodes = getASTagNode(tagTree);
|
||||
for (TreeNode asn : asNodes) {
|
||||
allNodes.add(asn);
|
||||
TagNode.setExport(allNodes, false);
|
||||
TagNode.setExport(actionNodes, true);
|
||||
@@ -1381,7 +1364,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
|
||||
return swfs.get(0);
|
||||
}
|
||||
|
||||
return treeNode.getSwf();
|
||||
return treeNode.getItem().getSwf();
|
||||
}
|
||||
|
||||
private void clearCache() {
|
||||
@@ -1883,11 +1866,12 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
|
||||
return;
|
||||
}
|
||||
|
||||
if (tagObj instanceof TagNode) {
|
||||
tagObj = ((TagNode) tagObj).tag;
|
||||
TreeItem item = null;
|
||||
if (tagObj instanceof TreeNode) {
|
||||
item = ((TreeNode) tagObj).getItem();
|
||||
}
|
||||
if (tagObj instanceof ImageTag) {
|
||||
ImageTag it = (ImageTag) tagObj;
|
||||
if (item instanceof ImageTag) {
|
||||
ImageTag it = (ImageTag) item;
|
||||
if (it.importSupported()) {
|
||||
JFileChooser fc = new JFileChooser();
|
||||
fc.setCurrentDirectory(new File(Configuration.lastOpenDir.get()));
|
||||
@@ -1933,11 +1917,12 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
|
||||
return;
|
||||
}
|
||||
|
||||
if (tagObj instanceof TagNode) {
|
||||
tagObj = ((TagNode) tagObj).tag;
|
||||
TreeItem item = null;
|
||||
if (tagObj instanceof TreeNode) {
|
||||
item = ((TreeNode) tagObj).getItem();
|
||||
}
|
||||
if (tagObj instanceof DefineBinaryDataTag) {
|
||||
DefineBinaryDataTag bt = (DefineBinaryDataTag) tagObj;
|
||||
DefineBinaryDataTag bt = (DefineBinaryDataTag) item;
|
||||
JFileChooser fc = new JFileChooser();
|
||||
fc.setCurrentDirectory(new File(Configuration.lastOpenDir.get()));
|
||||
JFrame f = new JFrame();
|
||||
@@ -1954,14 +1939,11 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
|
||||
}
|
||||
break;
|
||||
case ACTION_REMOVE_ITEM:
|
||||
List<Object> sel = getSelected(tagTree);
|
||||
List<TreeNode> sel = getSelected(tagTree);
|
||||
|
||||
List<Tag> tagsToRemove = new ArrayList<>();
|
||||
for (Object o : sel) {
|
||||
Object tag = o;
|
||||
if (o instanceof TagNode) {
|
||||
tag = ((TagNode) o).tag;
|
||||
}
|
||||
for (TreeNode o : sel) {
|
||||
TreeItem tag = o.getItem();
|
||||
if (tag instanceof Tag) {
|
||||
tagsToRemove.add((Tag) tag);
|
||||
}
|
||||
@@ -2047,7 +2029,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
|
||||
@Override
|
||||
public void valueChanged(TreeSelectionEvent e) {
|
||||
TreeNode treeNode = (TreeNode) e.getPath().getLastPathComponent();
|
||||
SWF swf = treeNode.getSwf();
|
||||
SWF swf = treeNode.getItem().getSwf();
|
||||
if (swfs.contains(swf)) {
|
||||
updateUi(swf);
|
||||
} else {
|
||||
@@ -2084,13 +2066,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
|
||||
|
||||
oldNode = treeNode;
|
||||
|
||||
TreeElementItem tagObj = null;
|
||||
if (treeNode instanceof TagNode) {
|
||||
tagObj = ((TagNode) treeNode).tag;
|
||||
}
|
||||
if (treeNode instanceof TreeElement) {
|
||||
tagObj = ((TreeElement) treeNode).getItem();
|
||||
}
|
||||
TreeItem tagObj = treeNode.getItem();
|
||||
|
||||
oldTag = tagObj;
|
||||
|
||||
@@ -2162,7 +2138,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
|
||||
|
||||
if (treeNode instanceof SWFRoot) {
|
||||
SWFRoot swfRoot = (SWFRoot) treeNode;
|
||||
SWF swf = swfRoot.getSwf();
|
||||
SWF swf = swfRoot.getItem();
|
||||
if (mainMenu.isInternalFlashViewerSelected()) {
|
||||
showCard(CARDSWFPREVIEWPANEL);
|
||||
swfPreviewPanel.load(swf);
|
||||
@@ -2218,9 +2194,9 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
|
||||
showCard(CARDFLASHPANEL);
|
||||
previewImagePanel.setDrawable((DrawableTag) tag, tag.getSwf(), tag.getSwf().characters, 50/*FIXME*/);
|
||||
showFontTag((FontTag) tagObj);
|
||||
} else if (tagObj instanceof FrameNode && ((FrameNode) tagObj).isDisplayed() && (mainMenu.isInternalFlashViewerSelected())) {
|
||||
} else if (tagObj instanceof FrameNodeItem && ((FrameNodeItem) tagObj).isDisplayed() && (mainMenu.isInternalFlashViewerSelected())) {
|
||||
showCard(CARDDRAWPREVIEWPANEL);
|
||||
FrameNode fn = (FrameNode) tagObj;
|
||||
FrameNodeItem fn = (FrameNodeItem) tagObj;
|
||||
SWF swf = fn.getSwf();
|
||||
List<Tag> controlTags = swf.tags;
|
||||
int containerId = 0;
|
||||
@@ -2233,7 +2209,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
|
||||
totalFrameCount = ((DefineSpriteTag) fn.getParent()).frameCount;
|
||||
}
|
||||
previewImagePanel.setImage(SWF.frameToImage(containerId, fn.getFrame() - 1, swf.tags, controlTags, rect, totalFrameCount, new Stack<Integer>()));
|
||||
} else if (((tagObj instanceof FrameNode) && ((FrameNode) tagObj).isDisplayed()) || ((tagObj instanceof CharacterTag) || (tagObj instanceof FontTag)) && (tagObj instanceof Tag)) {
|
||||
} else if (((tagObj instanceof FrameNodeItem) && ((FrameNodeItem) tagObj).isDisplayed()) || ((tagObj instanceof CharacterTag) || (tagObj instanceof FontTag)) && (tagObj instanceof Tag)) {
|
||||
((CardLayout) viewerCards.getLayout()).show(viewerCards, FLASH_VIEWER_CARD);
|
||||
createAndShowTempSwf(tagObj);
|
||||
|
||||
@@ -2271,8 +2247,8 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
|
||||
backgroundColor = View.DEFAULT_BACKGROUND_COLOR;
|
||||
}
|
||||
|
||||
if (tagObj instanceof FrameNode) {
|
||||
FrameNode fn = (FrameNode) tagObj;
|
||||
if (tagObj instanceof FrameNodeItem) {
|
||||
FrameNodeItem fn = (FrameNodeItem) tagObj;
|
||||
swf = fn.getSwf();
|
||||
if (fn.getParent() == null) {
|
||||
for (Tag t : swf.tags) {
|
||||
@@ -2327,9 +2303,9 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
|
||||
*/
|
||||
sos2.writeTag(new SetBackgroundColorTag(null, new RGB(backgroundColor)));
|
||||
|
||||
if (tagObj instanceof FrameNode) {
|
||||
FrameNode fn = (FrameNode) tagObj;
|
||||
Object parent = fn.getParent();
|
||||
if (tagObj instanceof FrameNodeItem) {
|
||||
FrameNodeItem fn = (FrameNodeItem) tagObj;
|
||||
Tag parent = fn.getParent();
|
||||
List<ContainerItem> subs = new ArrayList<>();
|
||||
if (parent == null) {
|
||||
subs.addAll(swf.tags);
|
||||
@@ -2340,15 +2316,15 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
|
||||
}
|
||||
List<Integer> doneCharacters = new ArrayList<>();
|
||||
int frameCnt = 1;
|
||||
for (Object o : subs) {
|
||||
if (o instanceof ShowFrameTag) {
|
||||
for (ContainerItem item : subs) {
|
||||
if (item instanceof ShowFrameTag) {
|
||||
frameCnt++;
|
||||
continue;
|
||||
}
|
||||
if (frameCnt > fn.getFrame()) {
|
||||
break;
|
||||
}
|
||||
Tag t = (Tag) o;
|
||||
Tag t = (Tag) item;
|
||||
Set<Integer> needed = t.getDeepNeededCharacters(swf.characters, new ArrayList<Integer>());
|
||||
for (int n : needed) {
|
||||
if (!doneCharacters.contains(n)) {
|
||||
|
||||
@@ -16,13 +16,12 @@
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.gui;
|
||||
|
||||
import com.jpexs.decompiler.flash.FrameNode;
|
||||
import com.jpexs.decompiler.flash.PackageNode;
|
||||
import com.jpexs.decompiler.flash.TagNode;
|
||||
import com.jpexs.decompiler.flash.AS3PackageNodeItem;
|
||||
import com.jpexs.decompiler.flash.FrameNodeItem;
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.TreeElementItem;
|
||||
import com.jpexs.decompiler.flash.TreeNode;
|
||||
import com.jpexs.decompiler.flash.TreeItem;
|
||||
import com.jpexs.decompiler.flash.abc.ScriptPack;
|
||||
import com.jpexs.decompiler.flash.gui.abc.TreeElement;
|
||||
import com.jpexs.decompiler.flash.tags.DefineBinaryDataTag;
|
||||
import com.jpexs.decompiler.flash.tags.DefineBitsJPEG2Tag;
|
||||
import com.jpexs.decompiler.flash.tags.DefineBitsJPEG3Tag;
|
||||
@@ -51,11 +50,14 @@ import com.jpexs.decompiler.flash.tags.DefineVideoStreamTag;
|
||||
import com.jpexs.decompiler.flash.tags.ShowFrameTag;
|
||||
import com.jpexs.decompiler.flash.tags.SoundStreamHead2Tag;
|
||||
import com.jpexs.decompiler.flash.tags.SoundStreamHeadTag;
|
||||
import com.jpexs.decompiler.flash.tags.Tag;
|
||||
import com.jpexs.decompiler.flash.tags.base.ASMSource;
|
||||
import com.jpexs.decompiler.flash.tags.gfx.DefineCompactedFont;
|
||||
import com.jpexs.decompiler.flash.treenodes.TreeNode;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Font;
|
||||
import java.awt.Graphics;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -88,18 +90,11 @@ public class TagTree extends JTree {
|
||||
expanded, leaf, row,
|
||||
hasFocus);
|
||||
TreeNode treeNode = (TreeNode) value;
|
||||
TreeElementItem val = null;
|
||||
if (treeNode instanceof TagNode) {
|
||||
val = ((TagNode) treeNode).tag;
|
||||
} else if (treeNode instanceof TreeElement) {
|
||||
val = ((TreeElement) treeNode).getItem();
|
||||
}
|
||||
TagType type = getTagType(val);
|
||||
if (val instanceof SWFRoot) {
|
||||
setIcon(View.getIcon("flash16"));
|
||||
} else if (type != null) {
|
||||
if (type == TagType.FOLDER && expanded) {
|
||||
type = TagType.FOLDER_OPEN;
|
||||
TreeItem val = treeNode.getItem();
|
||||
TreeNodeType type = getTreeNodeType(val);
|
||||
if (type != null) {
|
||||
if (type == TreeNodeType.FOLDER && expanded) {
|
||||
type = TreeNodeType.FOLDER_OPEN;
|
||||
}
|
||||
String tagTypeStr = type.toString().toLowerCase().replace("_", "");
|
||||
setIcon(View.getIcon(tagTypeStr + "16"));
|
||||
@@ -116,7 +111,15 @@ public class TagTree extends JTree {
|
||||
//setBackground(Color.green);
|
||||
setBackgroundNonSelectionColor(Color.white);
|
||||
//setBackgroundSelectionColor(Color.ORANGE);
|
||||
//setFont(getFont().deriveFont(Font.BOLD));
|
||||
|
||||
if (treeNode instanceof TreeNode) {
|
||||
if (treeNode.getItem() instanceof Tag) {
|
||||
Tag tag = (Tag) treeNode.getItem();
|
||||
if (tag.isModified()) {
|
||||
setFont(getFont().deriveFont(Font.BOLD));
|
||||
}
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -135,18 +138,18 @@ public class TagTree extends JTree {
|
||||
});
|
||||
}
|
||||
|
||||
public static TagType getTagType(TreeElementItem t) {
|
||||
public static TreeNodeType getTreeNodeType(TreeItem t) {
|
||||
if ((t instanceof DefineFontTag)
|
||||
|| (t instanceof DefineFont2Tag)
|
||||
|| (t instanceof DefineFont3Tag)
|
||||
|| (t instanceof DefineFont4Tag)
|
||||
|| (t instanceof DefineCompactedFont)) {
|
||||
return TagType.FONT;
|
||||
return TreeNodeType.FONT;
|
||||
}
|
||||
if ((t instanceof DefineTextTag)
|
||||
|| (t instanceof DefineText2Tag)
|
||||
|| (t instanceof DefineEditTextTag)) {
|
||||
return TagType.TEXT;
|
||||
return TreeNodeType.TEXT;
|
||||
}
|
||||
|
||||
if ((t instanceof DefineBitsTag)
|
||||
@@ -155,60 +158,67 @@ public class TagTree extends JTree {
|
||||
|| (t instanceof DefineBitsJPEG4Tag)
|
||||
|| (t instanceof DefineBitsLosslessTag)
|
||||
|| (t instanceof DefineBitsLossless2Tag)) {
|
||||
return TagType.IMAGE;
|
||||
return TreeNodeType.IMAGE;
|
||||
}
|
||||
if ((t instanceof DefineShapeTag)
|
||||
|| (t instanceof DefineShape2Tag)
|
||||
|| (t instanceof DefineShape3Tag)
|
||||
|| (t instanceof DefineShape4Tag)) {
|
||||
return TagType.SHAPE;
|
||||
return TreeNodeType.SHAPE;
|
||||
}
|
||||
|
||||
if ((t instanceof DefineMorphShapeTag) || (t instanceof DefineMorphShape2Tag)) {
|
||||
return TagType.MORPH_SHAPE;
|
||||
return TreeNodeType.MORPH_SHAPE;
|
||||
}
|
||||
|
||||
if (t instanceof DefineSpriteTag) {
|
||||
return TagType.SPRITE;
|
||||
return TreeNodeType.SPRITE;
|
||||
}
|
||||
if ((t instanceof DefineButtonTag) || (t instanceof DefineButton2Tag)) {
|
||||
return TagType.BUTTON;
|
||||
return TreeNodeType.BUTTON;
|
||||
}
|
||||
if (t instanceof ASMSource) {
|
||||
return TagType.AS;
|
||||
return TreeNodeType.AS;
|
||||
}
|
||||
if (t instanceof ScriptPack) {
|
||||
return TagType.AS;
|
||||
return TreeNodeType.AS;
|
||||
}
|
||||
if (t instanceof PackageNode) {
|
||||
return TagType.PACKAGE;
|
||||
if (t instanceof AS2PackageNodeItem) {
|
||||
return TreeNodeType.PACKAGE;
|
||||
}
|
||||
if (t instanceof FrameNode) {
|
||||
return TagType.FRAME;
|
||||
if (t instanceof AS3PackageNodeItem) {
|
||||
return TreeNodeType.PACKAGE;
|
||||
}
|
||||
if (t instanceof FrameNodeItem) {
|
||||
return TreeNodeType.FRAME;
|
||||
}
|
||||
if (t instanceof ShowFrameTag) {
|
||||
return TagType.SHOW_FRAME;
|
||||
return TreeNodeType.SHOW_FRAME;
|
||||
}
|
||||
|
||||
if (t instanceof DefineVideoStreamTag) {
|
||||
return TagType.MOVIE;
|
||||
return TreeNodeType.MOVIE;
|
||||
}
|
||||
|
||||
if ((t instanceof DefineSoundTag) || (t instanceof SoundStreamHeadTag) || (t instanceof SoundStreamHead2Tag)) {
|
||||
return TagType.SOUND;
|
||||
return TreeNodeType.SOUND;
|
||||
}
|
||||
|
||||
if (t instanceof DefineBinaryDataTag) {
|
||||
return TagType.BINARY_DATA;
|
||||
return TreeNodeType.BINARY_DATA;
|
||||
}
|
||||
|
||||
return TagType.FOLDER;
|
||||
if (t instanceof SWF) {
|
||||
return TreeNodeType.FLASH;
|
||||
}
|
||||
|
||||
return TreeNodeType.FOLDER;
|
||||
}
|
||||
|
||||
public List<TreeElementItem> getTagsWithType(List<TreeElementItem> list, TagType type) {
|
||||
public List<TreeElementItem> getTagsWithType(List<TreeElementItem> list, TreeNodeType type) {
|
||||
List<TreeElementItem> ret = new ArrayList<>();
|
||||
for (TreeElementItem item : list) {
|
||||
TagType ttype = getTagType(item);
|
||||
TreeNodeType ttype = getTreeNodeType(item);
|
||||
if (type == ttype) {
|
||||
ret.add(item);
|
||||
}
|
||||
|
||||
@@ -16,21 +16,25 @@
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.gui;
|
||||
|
||||
import com.jpexs.decompiler.flash.FrameNode;
|
||||
import com.jpexs.decompiler.flash.FrameNodeItem;
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.StringNode;
|
||||
import com.jpexs.decompiler.flash.TagNode;
|
||||
import com.jpexs.decompiler.flash.StringItem;
|
||||
import com.jpexs.decompiler.flash.TreeElementItem;
|
||||
import com.jpexs.decompiler.flash.TreeNode;
|
||||
import com.jpexs.decompiler.flash.gui.abc.ClassesListTreeModel;
|
||||
import com.jpexs.decompiler.flash.gui.abc.TreeElement;
|
||||
import com.jpexs.decompiler.flash.tags.DefineSpriteTag;
|
||||
import com.jpexs.decompiler.flash.tags.ExportAssetsTag;
|
||||
import com.jpexs.decompiler.flash.tags.SoundStreamBlockTag;
|
||||
import com.jpexs.decompiler.flash.tags.Tag;
|
||||
import com.jpexs.decompiler.flash.tags.base.Container;
|
||||
import com.jpexs.decompiler.flash.tags.base.ContainerItem;
|
||||
import com.jpexs.decompiler.flash.tags.base.SoundStreamHeadTypeTag;
|
||||
import com.jpexs.decompiler.flash.treenodes.ClassesListNode;
|
||||
import com.jpexs.decompiler.flash.treenodes.ContainerNode;
|
||||
import com.jpexs.decompiler.flash.treenodes.FrameNode;
|
||||
import com.jpexs.decompiler.flash.treenodes.SWFRoot;
|
||||
import com.jpexs.decompiler.flash.treenodes.StringNode;
|
||||
import com.jpexs.decompiler.flash.treenodes.TagTreeRoot;
|
||||
import com.jpexs.decompiler.flash.treenodes.TreeNode;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@@ -55,10 +59,8 @@ public class TagTreeModel implements TreeModel {
|
||||
List<ContainerItem> objs = new ArrayList<>();
|
||||
objs.addAll(swf.tags);
|
||||
ClassesListTreeModel classTreeModel = new ClassesListTreeModel(swf);
|
||||
List<TagNode> list = createTagList(objs, null, swf, classTreeModel);
|
||||
|
||||
SWFRoot swfRoot = new SWFRoot(swf, new File(swf.getFileTitle()).getName(), list);
|
||||
swfRoot.classTreeModel = classTreeModel;
|
||||
SWFRoot swfRoot = new SWFRoot(swf, new File(swf.getFileTitle()).getName());
|
||||
swfRoot.list = createTagList(objs, null, swf, swfRoot, classTreeModel);
|
||||
this.swfs.add(swfRoot);
|
||||
swfToSwfRoot.put(swf, swfRoot);
|
||||
}
|
||||
@@ -68,39 +70,41 @@ public class TagTreeModel implements TreeModel {
|
||||
return mainFrame.translate(key);
|
||||
}
|
||||
|
||||
public List<TagNode> getTagNodesWithType(List<? extends ContainerItem> list, TagType type, Object parent, boolean display) {
|
||||
List<TagNode> ret = new ArrayList<>();
|
||||
public List<TreeNode> getTagNodesWithType(List<? extends ContainerItem> list, TreeNodeType type, Tag parent, boolean display) {
|
||||
List<TreeNode> ret = new ArrayList<>();
|
||||
int frameCnt = 0;
|
||||
for (ContainerItem o : list) {
|
||||
TagType ttype = TagTree.getTagType(o);
|
||||
if (ttype == TagType.SHOW_FRAME && type == TagType.FRAME) {
|
||||
TreeNodeType ttype = TagTree.getTreeNodeType(o);
|
||||
if (ttype == TreeNodeType.SHOW_FRAME && type == TreeNodeType.FRAME) {
|
||||
frameCnt++;
|
||||
ret.add(new TagNode(new FrameNode(o.getSwf(), frameCnt, parent, display), o.getSwf()));
|
||||
ret.add(new FrameNode(new FrameNodeItem(o.getSwf(), frameCnt, parent, display)));
|
||||
} else if (type == ttype) {
|
||||
ret.add(new TagNode(o, o.getSwf()));
|
||||
ret.add(new ContainerNode(o));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
private List<TagNode> createTagList(List<ContainerItem> list, Object parent, SWF swf, ClassesListTreeModel classTreeModel) {
|
||||
List<TagNode> ret = new ArrayList<>();
|
||||
List<TagNode> frames = getTagNodesWithType(list, TagType.FRAME, parent, true);
|
||||
List<TagNode> shapes = getTagNodesWithType(list, TagType.SHAPE, parent, true);
|
||||
List<TagNode> morphShapes = getTagNodesWithType(list, TagType.MORPH_SHAPE, parent, true);
|
||||
List<TagNode> sprites = getTagNodesWithType(list, TagType.SPRITE, parent, true);
|
||||
List<TagNode> buttons = getTagNodesWithType(list, TagType.BUTTON, parent, true);
|
||||
List<TagNode> images = getTagNodesWithType(list, TagType.IMAGE, parent, true);
|
||||
List<TagNode> fonts = getTagNodesWithType(list, TagType.FONT, parent, true);
|
||||
List<TagNode> texts = getTagNodesWithType(list, TagType.TEXT, parent, true);
|
||||
List<TagNode> movies = getTagNodesWithType(list, TagType.MOVIE, parent, true);
|
||||
List<TagNode> sounds = getTagNodesWithType(list, TagType.SOUND, parent, true);
|
||||
List<TagNode> binaryData = getTagNodesWithType(list, TagType.BINARY_DATA, parent, true);
|
||||
private List<TreeNode> createTagList(List<ContainerItem> list, Tag parent, SWF swf, SWFRoot swfRoot, ClassesListTreeModel classTreeModel) {
|
||||
boolean hasAbc = swf.abcList != null && !swf.abcList.isEmpty();
|
||||
|
||||
List<TreeNode> ret = new ArrayList<>();
|
||||
List<TreeNode> frames = getTagNodesWithType(list, TreeNodeType.FRAME, parent, true);
|
||||
List<TreeNode> shapes = getTagNodesWithType(list, TreeNodeType.SHAPE, parent, true);
|
||||
List<TreeNode> morphShapes = getTagNodesWithType(list, TreeNodeType.MORPH_SHAPE, parent, true);
|
||||
List<TreeNode> sprites = getTagNodesWithType(list, TreeNodeType.SPRITE, parent, true);
|
||||
List<TreeNode> buttons = getTagNodesWithType(list, TreeNodeType.BUTTON, parent, true);
|
||||
List<TreeNode> images = getTagNodesWithType(list, TreeNodeType.IMAGE, parent, true);
|
||||
List<TreeNode> fonts = getTagNodesWithType(list, TreeNodeType.FONT, parent, true);
|
||||
List<TreeNode> texts = getTagNodesWithType(list, TreeNodeType.TEXT, parent, true);
|
||||
List<TreeNode> movies = getTagNodesWithType(list, TreeNodeType.MOVIE, parent, true);
|
||||
List<TreeNode> sounds = getTagNodesWithType(list, TreeNodeType.SOUND, parent, true);
|
||||
List<TreeNode> binaryData = getTagNodesWithType(list, TreeNodeType.BINARY_DATA, parent, true);
|
||||
|
||||
for (int i = 0; i < sounds.size(); i++) {
|
||||
if (sounds.get(i).tag instanceof SoundStreamHeadTypeTag) {
|
||||
if (sounds.get(i).getItem() instanceof SoundStreamHeadTypeTag) {
|
||||
List<SoundStreamBlockTag> blocks = new ArrayList<>();
|
||||
SWF.populateSoundStreamBlocks(list, (Tag) sounds.get(i).tag, blocks);
|
||||
SWF.populateSoundStreamBlocks(list, (Tag) sounds.get(i).getItem(), blocks);
|
||||
if (blocks.isEmpty()) {
|
||||
sounds.remove(i);
|
||||
i--;
|
||||
@@ -108,8 +112,9 @@ public class TagTreeModel implements TreeModel {
|
||||
}
|
||||
}
|
||||
|
||||
for (TagNode n : sprites) {
|
||||
n.subItems = getTagNodesWithType(((DefineSpriteTag) n.tag).subTags, TagType.FRAME, n.tag, true);
|
||||
for (TreeNode n : sprites) {
|
||||
Tag tag = n.getItem() instanceof Tag ? (Tag) n.getItem() : null;
|
||||
n.subNodes = getTagNodesWithType(((DefineSpriteTag) n.getItem()).subTags, TreeNodeType.FRAME, tag, true);
|
||||
}
|
||||
|
||||
List<ExportAssetsTag> exportAssetsTags = new ArrayList<>();
|
||||
@@ -117,101 +122,88 @@ public class TagTreeModel implements TreeModel {
|
||||
if (t instanceof ExportAssetsTag) {
|
||||
exportAssetsTags.add((ExportAssetsTag) t);
|
||||
}
|
||||
/*if (t instanceof ASMSource) {
|
||||
TagNode tti = new TagNode(t);
|
||||
ret.add(tti);
|
||||
} else */
|
||||
if (t instanceof Container) {
|
||||
TagNode tti = new TagNode(t, t.getSwf());
|
||||
if (((Container) t).getItemCount() > 0) {
|
||||
List<ContainerItem> subItems = ((Container) t).getSubItems();
|
||||
tti.subItems = createTagList(subItems, t, swf, classTreeModel);
|
||||
}
|
||||
//ret.add(tti);
|
||||
}
|
||||
}
|
||||
|
||||
List<TagNode> actionScript = SWF.createASTagList(list, null);
|
||||
TagNode textsNode = new TagNode(new StringNode(translate("node.texts")), swf);
|
||||
textsNode.subItems.addAll(texts);
|
||||
List<TreeNode> actionScript = SWF.createASTagList(list, null);
|
||||
StringNode textsNode = new StringNode(new StringItem(translate("node.texts"), swf));
|
||||
textsNode.subNodes.addAll(texts);
|
||||
|
||||
TagNode imagesNode = new TagNode(new StringNode(translate("node.images")), swf);
|
||||
imagesNode.subItems.addAll(images);
|
||||
StringNode imagesNode = new StringNode(new StringItem(translate("node.images"), swf));
|
||||
imagesNode.subNodes.addAll(images);
|
||||
|
||||
TagNode moviesNode = new TagNode(new StringNode(translate("node.movies")), swf);
|
||||
moviesNode.subItems.addAll(movies);
|
||||
StringNode moviesNode = new StringNode(new StringItem(translate("node.movies"), swf));
|
||||
moviesNode.subNodes.addAll(movies);
|
||||
|
||||
TagNode soundsNode = new TagNode(new StringNode(translate("node.sounds")), swf);
|
||||
soundsNode.subItems.addAll(sounds);
|
||||
StringNode soundsNode = new StringNode(new StringItem(translate("node.sounds"), swf));
|
||||
soundsNode.subNodes.addAll(sounds);
|
||||
|
||||
|
||||
TagNode binaryDataNode = new TagNode(new StringNode(translate("node.binaryData")), swf);
|
||||
binaryDataNode.subItems.addAll(binaryData);
|
||||
StringNode binaryDataNode = new StringNode(new StringItem(translate("node.binaryData"), swf));
|
||||
binaryDataNode.subNodes.addAll(binaryData);
|
||||
|
||||
TagNode fontsNode = new TagNode(new StringNode(translate("node.fonts")), swf);
|
||||
fontsNode.subItems.addAll(fonts);
|
||||
StringNode fontsNode = new StringNode(new StringItem(translate("node.fonts"), swf));
|
||||
fontsNode.subNodes.addAll(fonts);
|
||||
|
||||
|
||||
TagNode spritesNode = new TagNode(new StringNode(translate("node.sprites")), swf);
|
||||
spritesNode.subItems.addAll(sprites);
|
||||
StringNode spritesNode = new StringNode(new StringItem(translate("node.sprites"), swf));
|
||||
spritesNode.subNodes.addAll(sprites);
|
||||
|
||||
TagNode shapesNode = new TagNode(new StringNode(translate("node.shapes")), swf);
|
||||
shapesNode.subItems.addAll(shapes);
|
||||
StringNode shapesNode = new StringNode(new StringItem(translate("node.shapes"), swf));
|
||||
shapesNode.subNodes.addAll(shapes);
|
||||
|
||||
TagNode morphShapesNode = new TagNode(new StringNode(translate("node.morphshapes")), swf);
|
||||
morphShapesNode.subItems.addAll(morphShapes);
|
||||
StringNode morphShapesNode = new StringNode(new StringItem(translate("node.morphshapes"), swf));
|
||||
morphShapesNode.subNodes.addAll(morphShapes);
|
||||
|
||||
TagNode buttonsNode = new TagNode(new StringNode(translate("node.buttons")), swf);
|
||||
buttonsNode.subItems.addAll(buttons);
|
||||
StringNode buttonsNode = new StringNode(new StringItem(translate("node.buttons"), swf));
|
||||
buttonsNode.subNodes.addAll(buttons);
|
||||
|
||||
TagNode framesNode = new TagNode(new StringNode(translate("node.frames")), swf);
|
||||
framesNode.subItems.addAll(frames);
|
||||
StringNode framesNode = new StringNode(new StringItem(translate("node.frames"), swf));
|
||||
framesNode.subNodes.addAll(frames);
|
||||
|
||||
TagNode actionScriptNode = new TagNode(new StringNode(translate("node.scripts")), swf);
|
||||
actionScriptNode.mark = "scripts";
|
||||
actionScriptNode.subItems.addAll(actionScript);
|
||||
TreeNode actionScriptNode;
|
||||
if (hasAbc) {
|
||||
actionScriptNode = new ClassesListNode(classTreeModel);
|
||||
} else {
|
||||
actionScriptNode = new StringNode(new StringItem(translate("node.scripts"), swf));
|
||||
actionScriptNode.subNodes.addAll(actionScript);
|
||||
}
|
||||
swfRoot.scriptsNode = actionScriptNode;
|
||||
|
||||
if (!shapesNode.subItems.isEmpty()) {
|
||||
if (!shapesNode.subNodes.isEmpty()) {
|
||||
ret.add(shapesNode);
|
||||
}
|
||||
if (!morphShapesNode.subItems.isEmpty()) {
|
||||
if (!morphShapesNode.subNodes.isEmpty()) {
|
||||
ret.add(morphShapesNode);
|
||||
}
|
||||
if (!spritesNode.subItems.isEmpty()) {
|
||||
if (!spritesNode.subNodes.isEmpty()) {
|
||||
ret.add(spritesNode);
|
||||
}
|
||||
if (!textsNode.subItems.isEmpty()) {
|
||||
if (!textsNode.subNodes.isEmpty()) {
|
||||
ret.add(textsNode);
|
||||
}
|
||||
if (!imagesNode.subItems.isEmpty()) {
|
||||
if (!imagesNode.subNodes.isEmpty()) {
|
||||
ret.add(imagesNode);
|
||||
}
|
||||
if (!moviesNode.subItems.isEmpty()) {
|
||||
if (!moviesNode.subNodes.isEmpty()) {
|
||||
ret.add(moviesNode);
|
||||
}
|
||||
if (!soundsNode.subItems.isEmpty()) {
|
||||
if (!soundsNode.subNodes.isEmpty()) {
|
||||
ret.add(soundsNode);
|
||||
}
|
||||
if (!buttonsNode.subItems.isEmpty()) {
|
||||
if (!buttonsNode.subNodes.isEmpty()) {
|
||||
ret.add(buttonsNode);
|
||||
}
|
||||
if (!fontsNode.subItems.isEmpty()) {
|
||||
if (!fontsNode.subNodes.isEmpty()) {
|
||||
ret.add(fontsNode);
|
||||
}
|
||||
if (!binaryDataNode.subItems.isEmpty()) {
|
||||
if (!binaryDataNode.subNodes.isEmpty()) {
|
||||
ret.add(binaryDataNode);
|
||||
}
|
||||
if (!framesNode.subItems.isEmpty()) {
|
||||
if (!framesNode.subNodes.isEmpty()) {
|
||||
ret.add(framesNode);
|
||||
}
|
||||
|
||||
boolean hasAbc = swf.abcList != null && !swf.abcList.isEmpty();
|
||||
|
||||
if (hasAbc) {
|
||||
actionScriptNode.subItems.clear();
|
||||
actionScriptNode.tag = classTreeModel;
|
||||
}
|
||||
if ((!actionScriptNode.subItems.isEmpty()) || hasAbc) {
|
||||
if ((!actionScriptNode.subNodes.isEmpty()) || hasAbc) {
|
||||
ret.add(actionScriptNode);
|
||||
}
|
||||
|
||||
@@ -234,9 +226,9 @@ public class TagTreeModel implements TreeModel {
|
||||
return newPath;
|
||||
}
|
||||
}
|
||||
if (n instanceof TagNode) {
|
||||
TagNode nd = (TagNode) n;
|
||||
if (nd.tag == obj) {
|
||||
if (n instanceof TreeNode) {
|
||||
TreeNode nd = (TreeNode) n;
|
||||
if (nd.getItem() == obj) {
|
||||
return newPath;
|
||||
}
|
||||
}
|
||||
@@ -267,38 +259,39 @@ public class TagTreeModel implements TreeModel {
|
||||
|
||||
@Override
|
||||
public TreeNode getChild(Object parent, int index) {
|
||||
if (parent instanceof TagNode) {
|
||||
if (((TagNode) parent).tag instanceof ClassesListTreeModel) {
|
||||
ClassesListTreeModel clt = (ClassesListTreeModel) ((TagNode) parent).tag;
|
||||
TreeNode parentNode = (TreeNode) parent;
|
||||
if (parent instanceof TreeElement) {
|
||||
return ((TreeElement) parent).getChild(index);
|
||||
} else {
|
||||
if (parentNode.getItem() instanceof ClassesListTreeModel) {
|
||||
ClassesListTreeModel clt = (ClassesListTreeModel) parentNode.getItem();
|
||||
return clt.getChild(clt.getRoot(), index);
|
||||
}
|
||||
} else if (parent instanceof TreeElement) {
|
||||
return ((TreeElement) parent).getChild(index);
|
||||
}
|
||||
if (parent == root) {
|
||||
return swfs.get(index);
|
||||
} else if (parent instanceof SWFRoot) {
|
||||
return ((SWFRoot) parent).list.get(index);
|
||||
}
|
||||
return ((TagNode) parent).subItems.get(index);
|
||||
return parentNode.subNodes.get(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getChildCount(Object parent) {
|
||||
TreeNode parentNode = (TreeNode) parent;
|
||||
if (parent == root) {
|
||||
return swfs.size();
|
||||
} else if (parent instanceof TagNode) {
|
||||
if (((TagNode) parent).tag instanceof ClassesListTreeModel) {
|
||||
ClassesListTreeModel clt = (ClassesListTreeModel) ((TagNode) parent).tag;
|
||||
return clt.getChildCount(clt.getRoot());
|
||||
}
|
||||
return ((TagNode) parent).subItems.size();
|
||||
} else if (parent instanceof TreeElement) {
|
||||
return ((TreeElement) parent).getChildCount();
|
||||
} else if (parent instanceof SWFRoot) {
|
||||
return ((SWFRoot) parent).list.size();
|
||||
} else {
|
||||
if (parentNode.getItem() instanceof ClassesListTreeModel) {
|
||||
ClassesListTreeModel clt = (ClassesListTreeModel) parentNode.getItem();
|
||||
return clt.getChildCount(clt.getRoot());
|
||||
}
|
||||
return parentNode.subNodes.size();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -312,23 +305,20 @@ public class TagTreeModel implements TreeModel {
|
||||
|
||||
@Override
|
||||
public int getIndexOfChild(Object parent, Object child) {
|
||||
if (parent instanceof TagNode) {
|
||||
if (((TagNode) parent).tag instanceof ClassesListTreeModel) {
|
||||
ClassesListTreeModel clt = (ClassesListTreeModel) ((TagNode) parent).tag;
|
||||
return clt.getIndexOfChild(clt.getRoot(), child);
|
||||
}
|
||||
}
|
||||
TreeNode parentNode = (TreeNode) parent;
|
||||
if (parent == root) {
|
||||
return swfs.indexOf(child);
|
||||
} else if (parent instanceof TagNode) {
|
||||
List<TagNode> subTags = ((TagNode) parent).subItems;
|
||||
return subTags.indexOf(child);
|
||||
} else if (parent instanceof TreeElement) {
|
||||
return ((TreeElement) parent).getIndexOfChild((TreeElement) child);
|
||||
} else if (parent instanceof SWFRoot) {
|
||||
return ((SWFRoot) parent).list.indexOf(child);
|
||||
}
|
||||
return -1;
|
||||
} else {
|
||||
if (parentNode.getItem() instanceof ClassesListTreeModel) {
|
||||
ClassesListTreeModel clt = (ClassesListTreeModel) parentNode.getItem();
|
||||
return clt.getIndexOfChild(clt.getRoot(), child);
|
||||
}
|
||||
return parentNode.subNodes.indexOf(child);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -20,8 +20,9 @@ package com.jpexs.decompiler.flash.gui;
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public enum TagType {
|
||||
public enum TreeNodeType {
|
||||
|
||||
FLASH,
|
||||
FONT,
|
||||
TEXT,
|
||||
IMAGE,
|
||||
@@ -53,6 +53,7 @@ import com.jpexs.decompiler.flash.gui.abc.tablemodels.UIntTableModel;
|
||||
import com.jpexs.decompiler.flash.helpers.Freed;
|
||||
import com.jpexs.decompiler.flash.helpers.collections.MyEntry;
|
||||
import com.jpexs.decompiler.flash.tags.ABCContainerTag;
|
||||
import com.jpexs.decompiler.flash.treenodes.TreeNode;
|
||||
import com.jpexs.helpers.CancellableWorker;
|
||||
import com.jpexs.helpers.Helper;
|
||||
import java.awt.BorderLayout;
|
||||
@@ -117,41 +118,44 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Fr
|
||||
searchIgnoreCase = ignoreCase;
|
||||
searchRegexp = regexp;
|
||||
TagTreeModel ttm = (TagTreeModel) mainPanel.tagTree.getModel();
|
||||
ClassesListTreeModel clModel = ttm.getSwfRoot(mainPanel.getCurrentSwf()).classTreeModel;
|
||||
List<MyEntry<ClassPath, ScriptPack>> allpacks = clModel.getList();
|
||||
TreeNode scriptsNode = ttm.getSwfRoot(mainPanel.getCurrentSwf()).scriptsNode;
|
||||
found = new ArrayList<>();
|
||||
final Pattern pat = regexp ?
|
||||
Pattern.compile(txt, ignoreCase ? Pattern.CASE_INSENSITIVE : 0) :
|
||||
Pattern.compile(Pattern.quote(txt), ignoreCase ? Pattern.CASE_INSENSITIVE : 0);
|
||||
int pos = 0;
|
||||
for (final MyEntry<ClassPath, ScriptPack> item : allpacks) {
|
||||
pos++;
|
||||
String workText = AppStrings.translate("work.searching");
|
||||
String decAdd = "";
|
||||
if (!decompiledTextArea.isCached(item.value)) {
|
||||
decAdd = ", " + AppStrings.translate("work.decompiling");
|
||||
}
|
||||
|
||||
try {
|
||||
CancellableWorker worker = new CancellableWorker() {
|
||||
if (scriptsNode.getItem() instanceof ClassesListTreeModel) {
|
||||
ClassesListTreeModel clModel = (ClassesListTreeModel) scriptsNode.getItem();
|
||||
List<MyEntry<ClassPath, ScriptPack>> allpacks = clModel.getList();
|
||||
final Pattern pat = regexp ?
|
||||
Pattern.compile(txt, ignoreCase ? Pattern.CASE_INSENSITIVE : 0) :
|
||||
Pattern.compile(Pattern.quote(txt), ignoreCase ? Pattern.CASE_INSENSITIVE : 0);
|
||||
int pos = 0;
|
||||
for (final MyEntry<ClassPath, ScriptPack> item : allpacks) {
|
||||
pos++;
|
||||
String workText = AppStrings.translate("work.searching");
|
||||
String decAdd = "";
|
||||
if (!decompiledTextArea.isCached(item.value)) {
|
||||
decAdd = ", " + AppStrings.translate("work.decompiling");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void doInBackground() throws Exception {
|
||||
decompiledTextArea.cacheScriptPack(item.value, swf.abcList);
|
||||
if (pat.matcher(decompiledTextArea.getCachedText(item.value)).find()) {
|
||||
found.add(item.value);
|
||||
foundPath.add(item.key);
|
||||
try {
|
||||
CancellableWorker worker = new CancellableWorker() {
|
||||
|
||||
@Override
|
||||
public Void doInBackground() throws Exception {
|
||||
decompiledTextArea.cacheScriptPack(item.value, swf.abcList);
|
||||
if (pat.matcher(decompiledTextArea.getCachedText(item.value)).find()) {
|
||||
found.add(item.value);
|
||||
foundPath.add(item.key);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
worker.execute();
|
||||
Main.startWork(workText + " \"" + txt + "\"" + decAdd + " - (" + pos + "/" + allpacks.size() + ") " + item.key.toString() + "... ", worker);
|
||||
worker.get();
|
||||
} catch (InterruptedException ex) {
|
||||
break;
|
||||
} catch (ExecutionException ex) {
|
||||
Logger.getLogger(ABCPanel.class.getName()).log(Level.SEVERE, null, ex);
|
||||
};
|
||||
worker.execute();
|
||||
Main.startWork(workText + " \"" + txt + "\"" + decAdd + " - (" + pos + "/" + allpacks.size() + ") " + item.key.toString() + "... ", worker);
|
||||
worker.get();
|
||||
} catch (InterruptedException ex) {
|
||||
break;
|
||||
} catch (ExecutionException ex) {
|
||||
Logger.getLogger(ABCPanel.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -527,16 +531,19 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Fr
|
||||
|
||||
public void hilightScript(SWF swf, String name) {
|
||||
TagTreeModel ttm = (TagTreeModel) mainPanel.tagTree.getModel();
|
||||
ClassesListTreeModel clModel = ttm.getSwfRoot(swf).classTreeModel;
|
||||
ScriptPack pack = null;
|
||||
for (MyEntry<ClassPath, ScriptPack> item : clModel.getList()) {
|
||||
if (item.key.toString().equals(name)) {
|
||||
pack = item.value;
|
||||
break;
|
||||
TreeNode scriptsNode = ttm.getSwfRoot(swf).scriptsNode;
|
||||
if (scriptsNode.getItem() instanceof ClassesListTreeModel) {
|
||||
ClassesListTreeModel clModel = (ClassesListTreeModel) scriptsNode.getItem();
|
||||
ScriptPack pack = null;
|
||||
for (MyEntry<ClassPath, ScriptPack> item : clModel.getList()) {
|
||||
if (item.key.toString().equals(name)) {
|
||||
pack = item.value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (pack != null) {
|
||||
hilightScript(pack);
|
||||
}
|
||||
}
|
||||
if (pack != null) {
|
||||
hilightScript(pack);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,13 +18,13 @@ package com.jpexs.decompiler.flash.gui.abc;
|
||||
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.TreeElementItem;
|
||||
import com.jpexs.decompiler.flash.TreeNode;
|
||||
import com.jpexs.decompiler.flash.abc.ClassPath;
|
||||
import com.jpexs.decompiler.flash.abc.ScriptPack;
|
||||
import com.jpexs.decompiler.flash.abc.types.traits.Trait;
|
||||
import com.jpexs.decompiler.flash.abc.types.traits.TraitClass;
|
||||
import com.jpexs.decompiler.flash.gui.AppStrings;
|
||||
import com.jpexs.decompiler.flash.helpers.collections.MyEntry;
|
||||
import com.jpexs.decompiler.flash.treenodes.TreeNode;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.swing.event.TreeModelEvent;
|
||||
@@ -101,6 +101,11 @@ public class ClassesListTreeModel implements TreeModel, TreeElementItem {
|
||||
setFilter(filter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SWF getSwf() {
|
||||
return swf;
|
||||
}
|
||||
|
||||
public final void update() {
|
||||
this.list = swf.getAS3Packs();
|
||||
TreeModelEvent event = new TreeModelEvent(this, new TreePath(classTree.getRoot()));
|
||||
@@ -110,7 +115,7 @@ public class ClassesListTreeModel implements TreeModel, TreeElementItem {
|
||||
}
|
||||
|
||||
public final void setFilter(String filter) {
|
||||
classTree = new Tree(swf);
|
||||
classTree = new Tree();
|
||||
filter = (filter == null || filter.isEmpty()) ? null : filter.toLowerCase();
|
||||
for (MyEntry<ClassPath, ScriptPack> item : list) {
|
||||
if (filter != null) {
|
||||
|
||||
@@ -16,24 +16,20 @@
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.gui.abc;
|
||||
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.TreeElementItem;
|
||||
import com.jpexs.decompiler.flash.abc.ScriptPack;
|
||||
import com.jpexs.decompiler.flash.treenodes.AS3PackageNode;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
public class Tree {
|
||||
|
||||
private final TreeElement ROOT;
|
||||
private final TreeElement ROOT = new AS3PackageNode("", "", null, null);
|
||||
|
||||
public Tree(SWF swf) {
|
||||
ROOT = new TreeElement(swf, "", "", null, null);
|
||||
}
|
||||
|
||||
public void add(String name, String path, TreeElementItem item) {
|
||||
public void add(String name, String path, ScriptPack item) {
|
||||
StringTokenizer st = new StringTokenizer(path, ".");
|
||||
TreeElement parent = ROOT;
|
||||
while (st.hasMoreTokens()) {
|
||||
String pathElement = st.nextToken();
|
||||
parent = parent.getBranch(pathElement);
|
||||
parent = parent.getBranch(pathElement, item.getSwf());
|
||||
}
|
||||
parent.addLeaf(name, item);
|
||||
}
|
||||
|
||||
@@ -16,36 +16,36 @@
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.gui.abc;
|
||||
|
||||
import com.jpexs.decompiler.flash.PackageNode;
|
||||
import com.jpexs.decompiler.flash.AS3PackageNodeItem;
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.TreeElementItem;
|
||||
import com.jpexs.decompiler.flash.TreeNode;
|
||||
import com.jpexs.decompiler.flash.abc.ScriptPack;
|
||||
import com.jpexs.decompiler.flash.treenodes.AS3PackageNode;
|
||||
import com.jpexs.decompiler.flash.treenodes.ScriptPackNode;
|
||||
import com.jpexs.decompiler.flash.treenodes.TreeNode;
|
||||
import java.util.*;
|
||||
import javax.swing.tree.TreePath;
|
||||
|
||||
public class TreeElement implements TreeNode {
|
||||
public abstract class TreeElement extends TreeNode {
|
||||
|
||||
private SortedMap<String, TreeElement> branches;
|
||||
private SortedMap<String, TreeElement> leafs;
|
||||
private String name;
|
||||
private String path;
|
||||
private TreeElementItem item;
|
||||
private TreeElement parent;
|
||||
private SWF swf;
|
||||
|
||||
public TreeElement(SWF swf, String name, String path, TreeElementItem item, TreeElement parent) {
|
||||
this.swf = swf;
|
||||
public TreeElement(String name, String path, TreeElementItem item, TreeElement parent) {
|
||||
super(item);
|
||||
this.name = name;
|
||||
this.path = path;
|
||||
this.item = item;
|
||||
this.parent = parent;
|
||||
branches = new TreeMap<>();
|
||||
leafs = new TreeMap<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SWF getSwf() {
|
||||
return swf;
|
||||
public TreeElementItem getItem() {
|
||||
return (TreeElementItem) item;
|
||||
}
|
||||
|
||||
public TreeElement getParent() {
|
||||
@@ -69,26 +69,22 @@ public class TreeElement implements TreeNode {
|
||||
return new TreePath(pathList.toArray());
|
||||
}
|
||||
|
||||
public TreeElementItem getItem() {
|
||||
return item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name;
|
||||
}
|
||||
|
||||
TreeElement getBranch(String pathElement) {
|
||||
TreeElement getBranch(String pathElement, SWF swf) {
|
||||
TreeElement branch = branches.get(pathElement);
|
||||
if (branch == null) {
|
||||
branch = new TreeElement(swf, pathElement, path + "." + pathElement, new PackageNode(pathElement), this);
|
||||
branch = new AS3PackageNode(pathElement, path + "." + pathElement, new AS3PackageNodeItem(pathElement, swf), this);
|
||||
branches.put(pathElement, branch);
|
||||
}
|
||||
return branch;
|
||||
}
|
||||
|
||||
void addLeaf(String pathElement, TreeElementItem item) {
|
||||
TreeElement child = new TreeElement(swf, pathElement, path + "." + pathElement, item, this);
|
||||
void addLeaf(String pathElement, ScriptPack item) {
|
||||
ScriptPackNode child = new ScriptPackNode(pathElement, path + "." + pathElement, item, this);
|
||||
leafs.put(pathElement, child);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@ package com.jpexs.decompiler.flash.gui.action;
|
||||
|
||||
import com.jpexs.decompiler.flash.DisassemblyListener;
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.TagNode;
|
||||
import com.jpexs.decompiler.flash.action.Action;
|
||||
import com.jpexs.decompiler.flash.action.ActionGraph;
|
||||
import com.jpexs.decompiler.flash.action.parser.ParseException;
|
||||
@@ -39,6 +38,7 @@ import com.jpexs.decompiler.flash.helpers.HilightedText;
|
||||
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
|
||||
import com.jpexs.decompiler.flash.helpers.hilight.Highlighting;
|
||||
import com.jpexs.decompiler.flash.tags.base.ASMSource;
|
||||
import com.jpexs.decompiler.flash.treenodes.TreeNode;
|
||||
import com.jpexs.decompiler.graph.ExportMode;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.helpers.Cache;
|
||||
@@ -208,11 +208,11 @@ public class ActionPanel extends JPanel implements ActionListener {
|
||||
}
|
||||
}
|
||||
|
||||
private Map<String, ASMSource> getASMs(String path, List<TagNode> nodes) {
|
||||
private Map<String, ASMSource> getASMs(String path, List<TreeNode> nodes) {
|
||||
Map<String, ASMSource> ret = new HashMap<>();
|
||||
for (TagNode n : nodes) {
|
||||
for (TreeNode n : nodes) {
|
||||
String subPath = path + "/" + n.toString();
|
||||
if (n.tag instanceof ASMSource) {
|
||||
if (n.getItem() instanceof ASMSource) {
|
||||
//cacheScript((ASMSource) n.tag);
|
||||
String npath = subPath;
|
||||
int ppos = 1;
|
||||
@@ -220,10 +220,10 @@ public class ActionPanel extends JPanel implements ActionListener {
|
||||
ppos++;
|
||||
npath = subPath + "[" + ppos + "]";
|
||||
}
|
||||
ret.put(subPath, (ASMSource) n.tag);
|
||||
ret.put(subPath, (ASMSource) n.getItem());
|
||||
}
|
||||
|
||||
ret.putAll(getASMs(subPath, n.subItems));
|
||||
ret.putAll(getASMs(subPath, n.subNodes));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@@ -232,7 +232,7 @@ public class ActionPanel extends JPanel implements ActionListener {
|
||||
if ((txt != null) && (!txt.isEmpty())) {
|
||||
searchIgnoreCase = ignoreCase;
|
||||
searchRegexp = regexp;
|
||||
List<TagNode> list = SWF.createASTagList(mainPanel.getCurrentSwf().tags, null);
|
||||
List<TreeNode> list = SWF.createASTagList(mainPanel.getCurrentSwf().tags, null);
|
||||
Map<String, ASMSource> asms = getASMs("", list);
|
||||
found = new ArrayList<>();
|
||||
Pattern pat = null;
|
||||
|
||||
@@ -50,6 +50,7 @@ public class Tag implements NeedsCharacters, Exportable, ContainerItem {
|
||||
protected String name;
|
||||
public Tag previousTag;
|
||||
protected SWF swf;
|
||||
private boolean modified;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
@@ -282,6 +283,14 @@ public class Tag implements NeedsCharacters, Exportable, ContainerItem {
|
||||
return pos;
|
||||
}
|
||||
|
||||
public void setModified(boolean value) {
|
||||
modified = value;
|
||||
}
|
||||
|
||||
public boolean isModified() {
|
||||
return modified;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Integer> getNeededCharacters() {
|
||||
return new HashSet<>();
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.tags.base;
|
||||
|
||||
import com.jpexs.decompiler.flash.TreeElementItem;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -23,7 +24,7 @@ import java.util.List;
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public interface Container {
|
||||
public interface Container extends TreeElementItem {
|
||||
|
||||
/**
|
||||
* Returns all sub-items
|
||||
|
||||
@@ -16,15 +16,13 @@
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.tags.base;
|
||||
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.TreeElementItem;
|
||||
import com.jpexs.decompiler.flash.TreeItem;
|
||||
|
||||
/**
|
||||
* Object which contains other objects
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public interface ContainerItem extends TreeElementItem {
|
||||
public interface ContainerItem extends TreeItem {
|
||||
|
||||
SWF getSwf();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (C) 2013 JPEXS
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.treenodes;
|
||||
|
||||
import com.jpexs.decompiler.flash.gui.AS2PackageNodeItem;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class AS2PackageNode extends TreeNode {
|
||||
|
||||
public AS2PackageNode(AS2PackageNodeItem item) {
|
||||
super(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AS2PackageNodeItem getItem() {
|
||||
return (AS2PackageNodeItem) item;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (C) 2013 JPEXS
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.treenodes;
|
||||
|
||||
import com.jpexs.decompiler.flash.AS3PackageNodeItem;
|
||||
import com.jpexs.decompiler.flash.TreeElementItem;
|
||||
import com.jpexs.decompiler.flash.gui.abc.TreeElement;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class AS3PackageNode extends TreeElement {
|
||||
|
||||
public AS3PackageNode(String name, String path, AS3PackageNodeItem item, TreeElement parent) {
|
||||
super(name, path, item, parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AS3PackageNodeItem getItem() {
|
||||
return (AS3PackageNodeItem) item;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (C) 2013 JPEXS
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.treenodes;
|
||||
|
||||
import com.jpexs.decompiler.flash.gui.abc.ClassesListTreeModel;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class ClassesListNode extends TreeNode {
|
||||
|
||||
public ClassesListNode(ClassesListTreeModel item) {
|
||||
super(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassesListTreeModel getItem() {
|
||||
return (ClassesListTreeModel) item;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (C) 2013 JPEXS
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.treenodes;
|
||||
|
||||
import com.jpexs.decompiler.flash.tags.base.ContainerItem;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class ContainerNode extends TreeNode {
|
||||
|
||||
public ContainerNode(ContainerItem item) {
|
||||
super(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ContainerItem getItem() {
|
||||
return (ContainerItem) item;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (C) 2013 JPEXS
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.treenodes;
|
||||
|
||||
import com.jpexs.decompiler.flash.FrameNodeItem;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class FrameNode extends TreeNode {
|
||||
|
||||
public FrameNode(FrameNodeItem item) {
|
||||
super(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FrameNodeItem getItem() {
|
||||
return (FrameNodeItem) item;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,34 +14,29 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.gui;
|
||||
package com.jpexs.decompiler.flash.treenodes;
|
||||
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.TagNode;
|
||||
import com.jpexs.decompiler.flash.TreeNode;
|
||||
import com.jpexs.decompiler.flash.gui.abc.ClassesListTreeModel;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class SWFRoot implements TreeNode {
|
||||
public class SWFRoot extends TreeNode {
|
||||
|
||||
private SWF swf;
|
||||
private String name;
|
||||
public List<TagNode> list;
|
||||
public ClassesListTreeModel classTreeModel;
|
||||
public List<TreeNode> list;
|
||||
public TreeNode scriptsNode;
|
||||
|
||||
public SWFRoot(SWF swf, String name, List<TagNode> list) {
|
||||
this.swf = swf;
|
||||
public SWFRoot(SWF swf, String name) {
|
||||
super(swf);
|
||||
this.name = name;
|
||||
this.list = list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SWF getSwf() {
|
||||
return swf;
|
||||
public SWF getItem() {
|
||||
return (SWF) item;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (C) 2013 JPEXS
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.treenodes;
|
||||
|
||||
import com.jpexs.decompiler.flash.TreeElementItem;
|
||||
import com.jpexs.decompiler.flash.abc.ScriptPack;
|
||||
import com.jpexs.decompiler.flash.gui.abc.TreeElement;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class ScriptPackNode extends TreeElement {
|
||||
|
||||
public ScriptPackNode(String name, String path, ScriptPack item, TreeElement parent) {
|
||||
super(name, path, item, parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ScriptPack getItem() {
|
||||
return (ScriptPack) item;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (C) 2013 JPEXS
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.treenodes;
|
||||
|
||||
import com.jpexs.decompiler.flash.StringItem;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class StringNode extends TreeNode {
|
||||
|
||||
public StringNode(StringItem item) {
|
||||
super(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StringItem getItem() {
|
||||
return (StringItem) item;
|
||||
}
|
||||
|
||||
}
|
||||
191
trunk/src/com/jpexs/decompiler/flash/treenodes/TagNode.java
Normal file
191
trunk/src/com/jpexs/decompiler/flash/treenodes/TagNode.java
Normal file
@@ -0,0 +1,191 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2013 JPEXS
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.treenodes;
|
||||
|
||||
import com.jpexs.decompiler.flash.AbortRetryIgnoreHandler;
|
||||
import com.jpexs.decompiler.flash.EventListener;
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.action.Action;
|
||||
import com.jpexs.decompiler.flash.configuration.Configuration;
|
||||
import com.jpexs.decompiler.flash.helpers.FileTextWriter;
|
||||
import com.jpexs.decompiler.flash.tags.Tag;
|
||||
import com.jpexs.decompiler.flash.tags.base.ASMSource;
|
||||
import com.jpexs.decompiler.flash.tags.base.Exportable;
|
||||
import com.jpexs.decompiler.graph.ExportMode;
|
||||
import com.jpexs.decompiler.graph.TranslateException;
|
||||
import com.jpexs.helpers.CancellableWorker;
|
||||
import com.jpexs.helpers.Helper;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class TagNode extends ContainerNode {
|
||||
|
||||
public TagNode(Tag tag) {
|
||||
super(tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Tag getItem() {
|
||||
return (Tag) item;
|
||||
}
|
||||
|
||||
public static void setExport(List<TreeNode> nodeList, boolean export) {
|
||||
for (TreeNode node : nodeList) {
|
||||
node.export = export;
|
||||
setExport(node.subNodes, export);
|
||||
}
|
||||
}
|
||||
|
||||
public static int getTagCountRecursive(List<TreeNode> nodeList) {
|
||||
int count = 0;
|
||||
|
||||
for (TreeNode node : nodeList) {
|
||||
if (node.subNodes.isEmpty()) {
|
||||
if ((node.item instanceof ASMSource) && (node.export)) {
|
||||
count += 1;
|
||||
}
|
||||
} else {
|
||||
count += getTagCountRecursive(node.subNodes);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
public static List<File> exportNodeAS(final AbortRetryIgnoreHandler handler, final List<TreeNode> nodeList, final String outdir, final ExportMode exportMode, final EventListener ev) throws IOException {
|
||||
try {
|
||||
List<File> result = CancellableWorker.call(new Callable<List<File>>() {
|
||||
|
||||
@Override
|
||||
public List<File> call() throws Exception {
|
||||
AtomicInteger cnt = new AtomicInteger(1);
|
||||
int totalCount = TagNode.getTagCountRecursive(nodeList);
|
||||
return exportNodeAS(handler, nodeList, outdir, exportMode, cnt, totalCount, ev);
|
||||
}
|
||||
}, Configuration.exportTimeout.get(), TimeUnit.SECONDS);
|
||||
return result;
|
||||
} catch (ExecutionException | InterruptedException | TimeoutException ex) {
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
private static List<File> exportNodeAS(AbortRetryIgnoreHandler handler, List<TreeNode> nodeList, String outdir, ExportMode exportMode, AtomicInteger index, int count, EventListener ev) throws IOException {
|
||||
File dir = new File(outdir);
|
||||
List<File> ret = new ArrayList<>();
|
||||
if (!outdir.endsWith(File.separator)) {
|
||||
outdir += File.separator;
|
||||
}
|
||||
List<String> existingNames = new ArrayList<>();
|
||||
for (TreeNode node : nodeList) {
|
||||
String name = "";
|
||||
if (node.item instanceof Exportable) {
|
||||
name = ((Exportable) node.item).getExportFileName();
|
||||
} else {
|
||||
name = Helper.makeFileName(node.item.toString());
|
||||
}
|
||||
int i = 1;
|
||||
String baseName = name;
|
||||
while (existingNames.contains(name)) {
|
||||
i++;
|
||||
name = baseName + "_" + i;
|
||||
}
|
||||
existingNames.add(name);
|
||||
if (node.subNodes.isEmpty()) {
|
||||
if ((node.item instanceof ASMSource) && (node.export)) {
|
||||
if (!dir.exists()) {
|
||||
if (!dir.mkdirs()) {
|
||||
if (!dir.exists()) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
boolean retry;
|
||||
do {
|
||||
retry = false;
|
||||
try {
|
||||
String f = outdir + name + ".as";
|
||||
int currentIndex = index.getAndIncrement();
|
||||
if (ev != null) {
|
||||
ev.handleEvent("exporting", "Exporting " + currentIndex + "/" + count + " " + f);
|
||||
}
|
||||
|
||||
long startTime = System.currentTimeMillis();
|
||||
|
||||
File file = new File(f);
|
||||
ASMSource asm = ((ASMSource) node.item);
|
||||
try (FileTextWriter writer = new FileTextWriter(new FileOutputStream(f))) {
|
||||
if (exportMode == ExportMode.HEX) {
|
||||
asm.getActionSourcePrefix(writer);
|
||||
asm.getActionBytesAsHex(writer);
|
||||
asm.getActionSourceSuffix(writer);
|
||||
} else if (exportMode != ExportMode.SOURCE) {
|
||||
asm.getActionSourcePrefix(writer);
|
||||
asm.getASMSource(SWF.DEFAULT_VERSION, exportMode, writer, null);
|
||||
asm.getActionSourceSuffix(writer);
|
||||
} else {
|
||||
List<Action> as = asm.getActions(SWF.DEFAULT_VERSION);
|
||||
Action.setActionsAddresses(as, 0, SWF.DEFAULT_VERSION);
|
||||
Action.actionsToSource(asm, as, SWF.DEFAULT_VERSION, ""/*FIXME*/, writer);
|
||||
}
|
||||
}
|
||||
|
||||
long stopTime = System.currentTimeMillis();
|
||||
|
||||
if (ev != null) {
|
||||
long time = stopTime - startTime;
|
||||
ev.handleEvent("exported", "Exported " + currentIndex + "/" + count + " " + f + ", " + Helper.formatTimeSec(time));
|
||||
}
|
||||
|
||||
ret.add(file);
|
||||
} catch (InterruptedException ex) {
|
||||
} catch (IOException | OutOfMemoryError | TranslateException | StackOverflowError ex) {
|
||||
Logger.getLogger(TagNode.class.getName()).log(Level.SEVERE, "Decompilation error in file: " + name + ".as", ex);
|
||||
if (handler != null) {
|
||||
int action = handler.getNewInstance().handle(ex);
|
||||
switch (action) {
|
||||
case AbortRetryIgnoreHandler.ABORT:
|
||||
throw ex;
|
||||
case AbortRetryIgnoreHandler.RETRY:
|
||||
retry = true;
|
||||
break;
|
||||
case AbortRetryIgnoreHandler.IGNORE:
|
||||
retry = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} while (retry);
|
||||
}
|
||||
} else {
|
||||
ret.addAll(exportNodeAS(handler, node.subNodes, outdir + name, exportMode, index, count, ev));
|
||||
}
|
||||
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2013 JPEXS
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.treenodes;
|
||||
|
||||
import com.jpexs.decompiler.flash.StringItem;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class TagTreeRoot extends TreeNode {
|
||||
|
||||
public TagTreeRoot() {
|
||||
super(new StringItem("root", null));
|
||||
}
|
||||
}
|
||||
55
trunk/src/com/jpexs/decompiler/flash/treenodes/TreeNode.java
Normal file
55
trunk/src/com/jpexs/decompiler/flash/treenodes/TreeNode.java
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2013 JPEXS
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.treenodes;
|
||||
|
||||
import com.jpexs.decompiler.flash.TreeItem;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public abstract class TreeNode {
|
||||
|
||||
protected TreeItem item;
|
||||
public boolean export = false;
|
||||
public List<TreeNode> subNodes;
|
||||
|
||||
public TreeNode(TreeItem item) {
|
||||
this.item = item;
|
||||
this.subNodes = new ArrayList<>();
|
||||
}
|
||||
|
||||
public TreeItem getItem() {
|
||||
return item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return item.toString();
|
||||
}
|
||||
|
||||
public List<TreeNode> getAllSubs() {
|
||||
List<TreeNode> ret = new ArrayList<>();
|
||||
ret.addAll(subNodes);
|
||||
for (TreeNode n : subNodes) {
|
||||
ret.addAll(n.getAllSubs());
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user