From ae55f1a7cb84bffb7b083d68a5e88f4993e2c29f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=F8=EDk?= Date: Thu, 27 Dec 2012 15:22:36 +0100 Subject: [PATCH] AS2: exporting Checking for updates --- trunk/src/com/jpexs/asdec/Main.java | 162 +++++++++++++++++- .../com/jpexs/asdec/abc/gui/MainFrame.java | 11 ++ trunk/src/com/jpexs/asdec/action/Action.java | 51 +++--- trunk/src/com/jpexs/asdec/action/TagNode.java | 113 ++++++++++++ .../com/jpexs/asdec/action/gui/MainFrame.java | 64 ++++++- .../jpexs/asdec/action/gui/TagTreeModel.java | 80 +-------- .../action/treemodel/UnsupportedTreeItem.java | 2 +- .../src/com/jpexs/asdec/gui/AboutDialog.java | 2 +- .../com/jpexs/asdec/gui/LoadingDialog.java | 2 +- trunk/src/com/jpexs/asdec/gui/ModeFrame.java | 2 +- .../jpexs/asdec/tags/DefineButton2Tag.java | 12 +- .../com/jpexs/asdec/tags/DefineButtonTag.java | 14 +- .../com/jpexs/asdec/tags/DefineSpriteTag.java | 13 +- .../com/jpexs/asdec/tags/DoInitActionTag.java | 15 +- .../TagTreeItem.java => tags/TagName.java} | 27 +-- 15 files changed, 413 insertions(+), 157 deletions(-) create mode 100644 trunk/src/com/jpexs/asdec/action/TagNode.java rename trunk/src/com/jpexs/asdec/{action/gui/TagTreeItem.java => tags/TagName.java} (60%) diff --git a/trunk/src/com/jpexs/asdec/Main.java b/trunk/src/com/jpexs/asdec/Main.java index da62ed766..43c23618c 100644 --- a/trunk/src/com/jpexs/asdec/Main.java +++ b/trunk/src/com/jpexs/asdec/Main.java @@ -18,21 +18,31 @@ package com.jpexs.asdec; import com.jpexs.asdec.abc.NotSameException; import com.jpexs.asdec.abc.avm2.AVM2Code; +import com.jpexs.asdec.action.TagNode; import com.jpexs.asdec.gui.AboutDialog; import com.jpexs.asdec.gui.LoadingDialog; import com.jpexs.asdec.gui.ModeFrame; import com.jpexs.asdec.gui.View; import com.jpexs.asdec.gui.proxy.ProxyFrame; +import com.jpexs.asdec.helpers.Highlighting; +import com.jpexs.asdec.tags.ASMSource; +import com.jpexs.asdec.tags.DefineSpriteTag; import com.jpexs.asdec.tags.DoABCTag; +import com.jpexs.asdec.tags.DoInitActionTag; import com.jpexs.asdec.tags.Tag; +import com.jpexs.asdec.tags.TagName; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.io.*; +import java.net.Socket; import java.util.ArrayList; +import java.util.Calendar; import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; import java.util.regex.Matcher; import java.util.regex.Pattern; import javax.swing.JFileChooser; @@ -40,6 +50,11 @@ import javax.swing.JFrame; import javax.swing.JOptionPane; import javax.swing.SwingWorker; import javax.swing.filechooser.FileFilter; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import org.w3c.dom.Document; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; /** * Main executable class @@ -56,7 +71,9 @@ public class Main { public static SWF swf; public static final String version = "1.0.1"; public static String applicationName = "JP ActionScript Decompiler v." + version; - public static String shortApplicationName = "ASDec v." + version; + public static String shortApplicationName = "ASDec"; + public static String shortApplicationVerName = shortApplicationName + " v." + version; + public static String projectPage = "http://code.google.com/p/asdec/"; public static LoadingDialog loadingDialog; public static ModeFrame modeFrame; private static boolean working = false; @@ -73,7 +90,8 @@ public class Main { */ public static boolean DEBUG_MODE = false; /** - * Turn off reading unsafe tags (tags which can cause problems with recompiling) + * Turn off reading unsafe tags (tags which can cause problems with + * recompiling) */ public static boolean DISABLE_DANGEROUS = false; /** @@ -163,14 +181,68 @@ public class Main { public static boolean exportSWF(String inFile, String outdir, boolean isPcode) throws Exception { SWF swf = parseSWF(inFile); - boolean asFound = false; + boolean asV3Found = false; for (Tag t : swf.tags) { if (t instanceof DoABCTag) { ((DoABCTag) t).abc.export(outdir, isPcode); - asFound = true; + asV3Found = true; } } - return asFound; + if (!asV3Found) { + List list2 = new ArrayList(); + list2.addAll(swf.tags); + return exportNode(TagNode.createTagList(list2), outdir, isPcode); + } + return asV3Found; + } + + public static boolean exportNode(List nodeList, String outdir, boolean isPcode) { + File dir = new File(outdir); + if (!dir.exists()) { + dir.mkdirs(); + } + List existingNames = new ArrayList(); + for (TagNode node : nodeList) { + String name = ""; + if (node.tag instanceof TagName) { + name = ((TagName) node.tag).getName(); + } else { + name = 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) { + try { + String f = outdir + File.separatorChar + name + ".as"; + Main.startWork("Exporting " + f + " ..."); + String ret = ""; + if (isPcode) { + ret = ((ASMSource) node.tag).getASMSource(10); //TODO:Ensure correct version here + } else { + List as = ((ASMSource) node.tag).getActions(10);//TODO:Ensure correct version here + com.jpexs.asdec.action.Action.setActionsAddresses(as, 0, 10);//TODO:Ensure correct version here + ret = (Highlighting.stripHilights(com.jpexs.asdec.action.Action.actionsToSource(as, 10))); //TODO:Ensure correct version here + } + + + FileOutputStream fos = new FileOutputStream(f); + fos.write(ret.getBytes()); + fos.close(); + } catch (Exception ex) { + } + } + } else { + exportNode(node.subItems, outdir + File.separatorChar + name, isPcode); + } + + } + return true; } private static class OpenFileWorker extends SwingWorker { @@ -429,6 +501,7 @@ public class Main { View.setWinLookAndFeel(); Configuration.load(); if (args.length < 1) { + autoCheckForUpdates(); showModeFrame(); } else { if (args[0].equals("-proxy")) { @@ -522,6 +595,7 @@ public class Main { printCmdLineUsage(); System.exit(0); } else if (args.length == 1) { + autoCheckForUpdates(); openFile(args[0]); } else { badArguments(); @@ -629,4 +703,82 @@ public class Main { public static void about() { (new AboutDialog()).setVisible(true); } + + public static void autoCheckForUpdates() { + Calendar lastUpdatesCheckDate = (Calendar) Configuration.getConfig("lastUpdatesCheckDate", null); + if ((lastUpdatesCheckDate == null) || (lastUpdatesCheckDate.getTime().getTime() < Calendar.getInstance().getTime().getTime() - 1000 * 60 * 60 * 24)) { + checkForUpdates(); + } + } + + public static boolean checkForUpdates() { + try { + Socket sock = new Socket("code.google.com", 80); + OutputStream os = sock.getOutputStream(); + os.write("GET /feeds/p/asdec/downloads/basic HTTP/1.1\r\nHost: code.google.com\r\nConnection: close\r\n\r\n".getBytes()); + BufferedReader br = new BufferedReader(new InputStreamReader(sock.getInputStream())); + String s = ""; + String response = ""; + boolean start = false; + while ((s = br.readLine()) != null) { + if (start) { + response += s + "\r\n"; + } + if (s.equals("")) { + start = true; + } + } + DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); + Document doc = builder.parse(new ByteArrayInputStream(response.getBytes())); + NodeList contents = doc.getElementsByTagName("content"); + for (int i = 0; i < contents.getLength(); i++) { + Node nod = contents.item(i); + String cont = nod.getTextContent().trim(); + String parts[] = cont.split("\n"); + boolean featured = false; + for (String part : parts) { + if (part.trim().equals("Featured")) { + featured = true; + break; + } + } + if ((parts.length > 4) && (featured)) { + String downloadName = parts[1]; + String link = parts[parts.length - 2]; + if (downloadName.startsWith(shortApplicationName + " version ")) { + String downVersion = downloadName.substring((shortApplicationName + " version ").length()); + if (link.startsWith(" actions, int version) { + try{ List tree = actionsToTree(new HashMap(), actions, version); + return treeToString(tree); + }catch(Exception ex){ + return "//Decompilation error :"+ex.getLocalizedMessage(); + } } /** @@ -776,32 +781,36 @@ public class Action { } } catch (UnknownJumpException uje) { if ((adr2ip(actions, uje.addr, version) >= start) && (adr2ip(actions, uje.addr, version) <= end)) { - currentLoop.loopContinue = uje.addr; - onTrue = uje.output; - List contList = new ArrayList(); - for (TreeItem ti : onTrue) { - if (ti instanceof ContinueTreeItem) { - contList.add((ContinueTreeItem) ti); - } - if (ti instanceof Block) { - List subcont = ((Block) ti).getContinues(); - for (int k = 0; k < subcont.size(); k++) { - contList.add(subcont.get(k)); + if (currentLoop == null) { + output.add(new UnsupportedTreeItem(action, "UnknownJump")); + } else { + currentLoop.loopContinue = uje.addr; + onTrue = uje.output; + List contList = new ArrayList(); + for (TreeItem ti : onTrue) { + if (ti instanceof ContinueTreeItem) { + contList.add((ContinueTreeItem) ti); } - } - } - for (int u = 0; u < contList.size(); u++) { - if (contList.get(u) instanceof ContinueTreeItem) { - if (((ContinueTreeItem) contList.get(u)).loopPos == uje.addr) { - if (!((ContinueTreeItem) contList.get(u)).isKnown) { - ((ContinueTreeItem) contList.get(u)).isKnown = true; - ((ContinueTreeItem) contList.get(u)).loopPos = currentLoop.loopBreak; + if (ti instanceof Block) { + List subcont = ((Block) ti).getContinues(); + for (int k = 0; k < subcont.size(); k++) { + contList.add(subcont.get(k)); } } } + for (int u = 0; u < contList.size(); u++) { + if (contList.get(u) instanceof ContinueTreeItem) { + if (((ContinueTreeItem) contList.get(u)).loopPos == uje.addr) { + if (!((ContinueTreeItem) contList.get(u)).isKnown) { + ((ContinueTreeItem) contList.get(u)).isKnown = true; + ((ContinueTreeItem) contList.get(u)).loopPos = currentLoop.loopBreak; + } + } + } + } + finalExpression = actionsToTree(registerNames, unknownJumps, loopList, jumpsOrIfs, stack, constants, actions, adr2ip(actions, uje.addr, version), jumpIp - 2, version); + isFor = true; } - finalExpression = actionsToTree(registerNames, unknownJumps, loopList, jumpsOrIfs, stack, constants, actions, adr2ip(actions, uje.addr, version), jumpIp - 2, version); - isFor = true; } else { //throw new ConvertException("Unknown pattern: jump to nowhere", ip); } diff --git a/trunk/src/com/jpexs/asdec/action/TagNode.java b/trunk/src/com/jpexs/asdec/action/TagNode.java new file mode 100644 index 000000000..5fd0ce833 --- /dev/null +++ b/trunk/src/com/jpexs/asdec/action/TagNode.java @@ -0,0 +1,113 @@ +/* + * Copyright (C) 2010-2012 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 . + */ +package com.jpexs.asdec.action; + +import com.jpexs.asdec.tags.ASMSource; +import com.jpexs.asdec.tags.Container; +import com.jpexs.asdec.tags.DefineButton2Tag; +import com.jpexs.asdec.tags.DefineButtonTag; +import com.jpexs.asdec.tags.DefineSpriteTag; +import com.jpexs.asdec.tags.DoInitActionTag; +import com.jpexs.asdec.tags.ExportAssetsTag; +import com.jpexs.asdec.tags.ShowFrameTag; +import java.util.ArrayList; +import java.util.List; + +public class TagNode { + + public List subItems; + public Object tag; + + public TagNode(Object tag) { + this.tag = tag; + this.subItems = new ArrayList(); + } + + @Override + public String toString() { + return tag.toString(); + } + + public static List createTagList(List list) { + List ret = new ArrayList(); + int frame = 1; + List frames = new ArrayList(); + + List exportAssetsTags = new ArrayList(); + for (Object t : list) { + if (t instanceof ExportAssetsTag) { + exportAssetsTags.add((ExportAssetsTag) t); + } + if (t instanceof ShowFrameTag) { + TagNode tti = new TagNode("frame" + frame); + + for (int r = ret.size() - 1; r >= 0; r--) { + if (!(ret.get(r).tag instanceof DefineSpriteTag)) { + if (!(ret.get(r).tag instanceof DefineButtonTag)) { + if (!(ret.get(r).tag instanceof DefineButton2Tag)) { + if (!(ret.get(r).tag instanceof DoInitActionTag)) { + tti.subItems.add(ret.get(r)); + ret.remove(r); + } + } + } + } + } + frame++; + frames.add(tti); + } else if (t instanceof ASMSource) { + TagNode tti = new TagNode(t); + ret.add(tti); + } else if (t instanceof Container) { + if (((Container) t).getItemCount() > 0) { + + TagNode tti = new TagNode(t); + List subItems = ((Container) t).getSubItems(); + + tti.subItems = createTagList(subItems); + ret.add(tti); + } + } + + } + ret.addAll(frames); + for (int i = ret.size() - 1; i >= 0; i--) { + if (ret.get(i).tag instanceof DefineSpriteTag) { + ((DefineSpriteTag) ret.get(i).tag).exportAssetsTags = exportAssetsTags; + } + if (ret.get(i).tag instanceof DefineButtonTag) { + ((DefineButtonTag) ret.get(i).tag).exportAssetsTags = exportAssetsTags; + } + if (ret.get(i).tag instanceof DefineButton2Tag) { + ((DefineButton2Tag) ret.get(i).tag).exportAssetsTags = exportAssetsTags; + } + if (ret.get(i).tag instanceof DoInitActionTag) { + ((DoInitActionTag) ret.get(i).tag).exportAssetsTags = exportAssetsTags; + } + if (ret.get(i).tag instanceof ASMSource) { + ASMSource ass = (ASMSource) ret.get(i).tag; + if (ass.containsSource()) { + continue; + } + } + if (ret.get(i).subItems.size() == 0) { + ret.remove(i); + } + } + return ret; + } +} diff --git a/trunk/src/com/jpexs/asdec/action/gui/MainFrame.java b/trunk/src/com/jpexs/asdec/action/gui/MainFrame.java index 97f56aa30..a41489c1c 100644 --- a/trunk/src/com/jpexs/asdec/action/gui/MainFrame.java +++ b/trunk/src/com/jpexs/asdec/action/gui/MainFrame.java @@ -16,6 +16,8 @@ */ package com.jpexs.asdec.action.gui; +import com.jpexs.asdec.Configuration; +import com.jpexs.asdec.action.TagNode; import com.jpexs.asdec.Main; import com.jpexs.asdec.action.parser.ASMParser; import com.jpexs.asdec.action.parser.ParseException; @@ -23,6 +25,7 @@ import com.jpexs.asdec.gui.LoadingPanel; import com.jpexs.asdec.gui.View; import com.jpexs.asdec.helpers.Highlighting; import com.jpexs.asdec.tags.ASMSource; +import com.jpexs.asdec.tags.DoABCTag; import com.jpexs.asdec.tags.Tag; import java.awt.BorderLayout; import java.awt.Container; @@ -36,6 +39,7 @@ import java.io.ByteArrayInputStream; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; +import java.util.ArrayList; import java.util.List; import javax.swing.*; import javax.swing.border.BevelBorder; @@ -154,14 +158,20 @@ public class MainFrame extends JFrame implements TreeSelectionListener, ActionLi miSaveAs.setIcon(new ImageIcon(View.loadImage("com/jpexs/asdec/gui/graphics/save16.png"))); miSaveAs.setActionCommand("SAVEAS"); miSaveAs.addActionListener(this); - JMenuItem miExport = new JMenuItem("Export..."); + JMenuItem miExport = new JMenuItem("Export as ActionScript..."); miExport.setIcon(new ImageIcon(View.loadImage("com/jpexs/asdec/gui/graphics/exportas16.png"))); miExport.setActionCommand("EXPORT"); miExport.addActionListener(this); + + JMenuItem miExportPCode = new JMenuItem("Export as PCode..."); + miExportPCode.setIcon(new ImageIcon(View.loadImage("com/jpexs/asdec/gui/graphics/exportpc16.png"))); + miExportPCode.setActionCommand("EXPORTPCODE"); + miExportPCode.addActionListener(this); menuFile.add(miOpen); menuFile.add(miSave); menuFile.add(miSaveAs); - //menuFile.add(miExport); + menuFile.add(miExport); + menuFile.add(miExportPCode); menuFile.addSeparator(); JMenuItem miClose = new JMenuItem("Exit"); miClose.setIcon(new ImageIcon(View.loadImage("com/jpexs/asdec/gui/graphics/exit16.png"))); @@ -182,7 +192,12 @@ public class MainFrame extends JFrame implements TreeSelectionListener, ActionLi JMenuItem miAbout = new JMenuItem("About..."); miAbout.setActionCommand("ABOUT"); miAbout.addActionListener(this); + + JMenuItem miCheckUpdates = new JMenuItem("Check for updates..."); + miCheckUpdates.setActionCommand("CHECKUPDATES"); + miCheckUpdates.addActionListener(this); menuHelp.add(miAbout); + menuHelp.add(miCheckUpdates); menuBar.add(menuHelp); setJMenuBar(menuBar); @@ -195,8 +210,8 @@ public class MainFrame extends JFrame implements TreeSelectionListener, ActionLi return; } Object obj = tagTree.getLastSelectedPathComponent(); - if (obj instanceof TagTreeItem) { - obj = ((TagTreeItem) obj).tag; + if (obj instanceof TagNode) { + obj = ((TagNode) obj).tag; if (obj instanceof ASMSource) { Main.startWork("Decompiling..."); final ASMSource asm = (ASMSource) obj; @@ -238,7 +253,7 @@ public class MainFrame extends JFrame implements TreeSelectionListener, ActionLi } if (e.getActionCommand().equals("SAVEHEXACTION")) { - TagTreeItem ti = (TagTreeItem) tagTree.getLastSelectedPathComponent(); + TagNode ti = (TagNode) tagTree.getLastSelectedPathComponent(); if (ti.tag instanceof ASMSource) { ASMSource dat = (ASMSource) ti.tag; FileOutputStream fos; @@ -253,7 +268,7 @@ public class MainFrame extends JFrame implements TreeSelectionListener, ActionLi } if (e.getActionCommand().equals("LOADHEXACTION")) { - TagTreeItem ti = (TagTreeItem) tagTree.getLastSelectedPathComponent(); + TagNode ti = (TagNode) tagTree.getLastSelectedPathComponent(); if (ti.tag instanceof ASMSource) { ASMSource dat = (ASMSource) ti.tag; FileInputStream fis; @@ -271,7 +286,7 @@ public class MainFrame extends JFrame implements TreeSelectionListener, ActionLi } if (e.getActionCommand().equals("SAVEACTION")) { - TagTreeItem ti = (TagTreeItem) tagTree.getLastSelectedPathComponent(); + TagNode ti = (TagNode) tagTree.getLastSelectedPathComponent(); if (ti.tag instanceof ASMSource) { ASMSource dat = (ASMSource) ti.tag; try { @@ -298,6 +313,41 @@ public class MainFrame extends JFrame implements TreeSelectionListener, ActionLi if (e.getActionCommand().equals("OPEN")) { Main.openFileDialog(); } + + if (e.getActionCommand().equals("CHECKUPDATES")) { + if(!Main.checkForUpdates()){ + JOptionPane.showMessageDialog(null, "No new version available."); + } + } + + if (e.getActionCommand().equals("EXPORT") || e.getActionCommand().equals("EXPORTPCODE")) { + JFileChooser chooser = new JFileChooser(); + chooser.setCurrentDirectory(new java.io.File((String) Configuration.getConfig("lastExportDir", "."))); + chooser.setDialogTitle("Select directory to export"); + chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + chooser.setAcceptAllFileFilterUsed(false); + if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) { + Main.startWork("Exporting..."); + final String selFile = chooser.getSelectedFile().getAbsolutePath(); + Configuration.setConfig("lastExportDir", chooser.getSelectedFile().getParentFile().getAbsolutePath()); + final boolean isPcode = e.getActionCommand().equals("EXPORTPCODE"); + (new Thread() { + @Override + public void run() { + try { + List list2 = new ArrayList(); + list2.addAll(list); + Main.exportNode(TagNode.createTagList(list2), selFile, isPcode); + } catch (Exception ignored) { + JOptionPane.showMessageDialog(null, "Cannot write to the file"); + } + Main.stopWork(); + } + }).start(); + + } + + } } public void setStatus(String s) { diff --git a/trunk/src/com/jpexs/asdec/action/gui/TagTreeModel.java b/trunk/src/com/jpexs/asdec/action/gui/TagTreeModel.java index 11ebf6d52..e848726d8 100644 --- a/trunk/src/com/jpexs/asdec/action/gui/TagTreeModel.java +++ b/trunk/src/com/jpexs/asdec/action/gui/TagTreeModel.java @@ -16,6 +16,7 @@ */ package com.jpexs.asdec.action.gui; +import com.jpexs.asdec.action.TagNode; import com.jpexs.asdec.tags.*; import java.util.ArrayList; import java.util.List; @@ -26,81 +27,12 @@ import javax.swing.tree.TreePath; public class TagTreeModel implements TreeModel { private String root = ""; - private List list = new ArrayList(); + private List list = new ArrayList(); public TagTreeModel(List list) { List list2 = new ArrayList(); list2.addAll(list); - this.list = processTagList(list2); - } - - public List processTagList(List list) { - List ret = new ArrayList(); - int frame = 1; - List frames = new ArrayList(); - - List exportAssetsTags = new ArrayList(); - for (Object t : list) { - if (t instanceof ExportAssetsTag) { - exportAssetsTags.add((ExportAssetsTag) t); - } - if (t instanceof ShowFrameTag) { - TagTreeItem tti = new TagTreeItem("frame" + frame); - - for (int r = ret.size() - 1; r >= 0; r--) { - if (!(ret.get(r).tag instanceof DefineSpriteTag)) { - if (!(ret.get(r).tag instanceof DefineButtonTag)) { - if (!(ret.get(r).tag instanceof DefineButton2Tag)) { - if (!(ret.get(r).tag instanceof DoInitActionTag)) { - tti.subItems.add(ret.get(r)); - ret.remove(r); - } - } - } - } - } - frame++; - frames.add(tti); - } else if (t instanceof ASMSource) { - TagTreeItem tti = new TagTreeItem(t); - ret.add(tti); - } else if (t instanceof Container) { - if (((Container) t).getItemCount() > 0) { - - TagTreeItem tti = new TagTreeItem(t); - List subItems = ((Container) t).getSubItems(); - - tti.subItems = processTagList(subItems); - ret.add(tti); - } - } - - } - ret.addAll(frames); - for (int i = ret.size() - 1; i >= 0; i--) { - if (ret.get(i).tag instanceof DefineSpriteTag) { - ((DefineSpriteTag) ret.get(i).tag).exportAssetsTags = exportAssetsTags; - } - if (ret.get(i).tag instanceof DefineButtonTag) { - ((DefineButtonTag) ret.get(i).tag).exportAssetsTags = exportAssetsTags; - } - if (ret.get(i).tag instanceof DefineButton2Tag) { - ((DefineButton2Tag) ret.get(i).tag).exportAssetsTags = exportAssetsTags; - } - if (ret.get(i).tag instanceof DoInitActionTag) { - ((DoInitActionTag) ret.get(i).tag).exportAssetsTags = exportAssetsTags; - } - if (ret.get(i).tag instanceof ASMSource) { - ASMSource ass = (ASMSource) ret.get(i).tag; - if (ass.containsSource()) { - continue; - } - } - if (ret.get(i).subItems.size() == 0) { - ret.remove(i); - } - } - return ret; + this.list = TagNode.createTagList(list2); } public Object getRoot() { @@ -111,7 +43,7 @@ public class TagTreeModel implements TreeModel { if (parent == root) { return list.get(index); } else { - return ((TagTreeItem) parent).subItems.get(index); + return ((TagNode) parent).subItems.get(index); } } @@ -119,7 +51,7 @@ public class TagTreeModel implements TreeModel { if (parent == root) { return list.size(); } else { - return ((TagTreeItem) parent).subItems.size(); + return ((TagNode) parent).subItems.size(); } } @@ -139,7 +71,7 @@ public class TagTreeModel implements TreeModel { } return -1; } else { - List subTags = ((TagTreeItem) parent).subItems; + List subTags = ((TagNode) parent).subItems; for (int t = 0; t < subTags.size(); t++) { if (subTags.get(t) == child) { return t; diff --git a/trunk/src/com/jpexs/asdec/action/treemodel/UnsupportedTreeItem.java b/trunk/src/com/jpexs/asdec/action/treemodel/UnsupportedTreeItem.java index 55e509828..50ccb9121 100644 --- a/trunk/src/com/jpexs/asdec/action/treemodel/UnsupportedTreeItem.java +++ b/trunk/src/com/jpexs/asdec/action/treemodel/UnsupportedTreeItem.java @@ -29,6 +29,6 @@ public class UnsupportedTreeItem extends TreeItem { @Override public String toString(ConstantPool constants) { - return "Unsupported:" + value + ";"; + return "//Unsupported by decompiler:" + value + ";"; } } diff --git a/trunk/src/com/jpexs/asdec/gui/AboutDialog.java b/trunk/src/com/jpexs/asdec/gui/AboutDialog.java index a7095fe7f..a2a9af9e2 100644 --- a/trunk/src/com/jpexs/asdec/gui/AboutDialog.java +++ b/trunk/src/com/jpexs/asdec/gui/AboutDialog.java @@ -81,7 +81,7 @@ public class AboutDialog extends JDialog { dateLabel.setHorizontalAlignment(SwingConstants.CENTER); cp.add(dateLabel); - LinkLabel wwwLabel = new LinkLabel("http://code.google.com/p/asdec/"); + LinkLabel wwwLabel = new LinkLabel(Main.projectPage); wwwLabel.setForeground(Color.blue); wwwLabel.setPreferredSize(new Dimension(300, 25)); wwwLabel.setHorizontalAlignment(SwingConstants.CENTER); diff --git a/trunk/src/com/jpexs/asdec/gui/LoadingDialog.java b/trunk/src/com/jpexs/asdec/gui/LoadingDialog.java index 3e9047159..b18a39ba7 100644 --- a/trunk/src/com/jpexs/asdec/gui/LoadingDialog.java +++ b/trunk/src/com/jpexs/asdec/gui/LoadingDialog.java @@ -41,7 +41,7 @@ public class LoadingDialog extends JFrame implements ImageObserver { */ public LoadingDialog() { setResizable(false); - setTitle(Main.shortApplicationName); + setTitle(Main.shortApplicationVerName); setSize(300, 150); setLayout(new BorderLayout()); diff --git a/trunk/src/com/jpexs/asdec/gui/ModeFrame.java b/trunk/src/com/jpexs/asdec/gui/ModeFrame.java index a1bfd953e..958f6e414 100644 --- a/trunk/src/com/jpexs/asdec/gui/ModeFrame.java +++ b/trunk/src/com/jpexs/asdec/gui/ModeFrame.java @@ -64,7 +64,7 @@ public class ModeFrame extends JFrame implements ActionListener { cont.add(exitButton); View.centerScreen(this); View.setWindowIcon(this); - setTitle(Main.shortApplicationName); + setTitle(Main.shortApplicationVerName); this.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { diff --git a/trunk/src/com/jpexs/asdec/tags/DefineButton2Tag.java b/trunk/src/com/jpexs/asdec/tags/DefineButton2Tag.java index b705e3d48..7e0810712 100644 --- a/trunk/src/com/jpexs/asdec/tags/DefineButton2Tag.java +++ b/trunk/src/com/jpexs/asdec/tags/DefineButton2Tag.java @@ -35,7 +35,7 @@ import java.util.List; * * @author JPEXS */ -public class DefineButton2Tag extends Tag implements Container { +public class DefineButton2Tag extends Tag implements Container,TagName { /** * ID for this character @@ -165,12 +165,10 @@ public class DefineButton2Tag extends Tag implements Container { return actions.size(); } - /** - * Returns string representation of the object - * - * @return String representation of the object - */ - @Override + public String getName() { + return "DefineButton2Tag"+buttonId; + } + public String toString() { String name = ""; for (ExportAssetsTag eat : exportAssetsTags) { diff --git a/trunk/src/com/jpexs/asdec/tags/DefineButtonTag.java b/trunk/src/com/jpexs/asdec/tags/DefineButtonTag.java index 9a00d8eb1..70b0730e2 100644 --- a/trunk/src/com/jpexs/asdec/tags/DefineButtonTag.java +++ b/trunk/src/com/jpexs/asdec/tags/DefineButtonTag.java @@ -34,7 +34,7 @@ import java.util.List; * * @author JPEXS */ -public class DefineButtonTag extends Tag implements ASMSource { +public class DefineButtonTag extends Tag implements ASMSource,TagName { /** * ID for this character @@ -98,12 +98,12 @@ public class DefineButtonTag extends Tag implements ASMSource { return baos.toByteArray(); } - /** - * Returns string representation of the object - * - * @return String representation of the object - */ - @Override + public String getName() { + return "DefineButtonTag"+buttonId; + } + + + public String toString() { String name = ""; for (ExportAssetsTag eat : exportAssetsTags) { diff --git a/trunk/src/com/jpexs/asdec/tags/DefineSpriteTag.java b/trunk/src/com/jpexs/asdec/tags/DefineSpriteTag.java index cb4ef3e9d..86d2ce4e4 100644 --- a/trunk/src/com/jpexs/asdec/tags/DefineSpriteTag.java +++ b/trunk/src/com/jpexs/asdec/tags/DefineSpriteTag.java @@ -30,7 +30,7 @@ import java.util.List; /** * Defines a sprite character */ -public class DefineSpriteTag extends Tag implements Container { +public class DefineSpriteTag extends Tag implements Container,TagName { /** * Character ID of sprite @@ -94,12 +94,13 @@ public class DefineSpriteTag extends Tag implements Container { return baos.toByteArray(); } - /** - * Returns string representation of the object - * - * @return String representation of the object - */ @Override + public String getName() { + return "DefineSpriteTag"+spriteId; + } + + + public String toString() { String name = ""; for (ExportAssetsTag eat : exportAssetsTags) { diff --git a/trunk/src/com/jpexs/asdec/tags/DoInitActionTag.java b/trunk/src/com/jpexs/asdec/tags/DoInitActionTag.java index b73501839..563343cc3 100644 --- a/trunk/src/com/jpexs/asdec/tags/DoInitActionTag.java +++ b/trunk/src/com/jpexs/asdec/tags/DoInitActionTag.java @@ -25,7 +25,7 @@ import java.io.IOException; import java.util.ArrayList; import java.util.List; -public class DoInitActionTag extends Tag implements ASMSource { +public class DoInitActionTag extends Tag implements ASMSource,TagName { /** * Identifier of Sprite @@ -76,12 +76,7 @@ public class DoInitActionTag extends Tag implements ASMSource { return baos.toByteArray(); } - /** - * Returns string representation of the object - * - * @return String representation of the object - */ - @Override + public String toString() { String name = ""; for (ExportAssetsTag eat : exportAssetsTags) { @@ -92,6 +87,12 @@ public class DoInitActionTag extends Tag implements ASMSource { return "DoInitActionTag (" + spriteId + name + ")"; } + public String getName() { + return "DoInitActionTag"+spriteId; + } + + + /** * Whether or not this object contains ASM source * diff --git a/trunk/src/com/jpexs/asdec/action/gui/TagTreeItem.java b/trunk/src/com/jpexs/asdec/tags/TagName.java similarity index 60% rename from trunk/src/com/jpexs/asdec/action/gui/TagTreeItem.java rename to trunk/src/com/jpexs/asdec/tags/TagName.java index 0265726a8..e66845a96 100644 --- a/trunk/src/com/jpexs/asdec/action/gui/TagTreeItem.java +++ b/trunk/src/com/jpexs/asdec/tags/TagName.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010-2011 JPEXS + * Copyright (C) 2010-2012 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 @@ -14,23 +14,12 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package com.jpexs.asdec.action.gui; +package com.jpexs.asdec.tags; -import java.util.ArrayList; -import java.util.List; - -public class TagTreeItem { - - public List subItems; - public Object tag; - - public TagTreeItem(Object tag) { - this.tag = tag; - this.subItems = new ArrayList(); - } - - @Override - public String toString() { - return tag.toString(); - } +/** + * + * @author JPEXS + */ +public interface TagName { + public String getName(); }