diff --git a/src/com/jpexs/decompiler/flash/SWF.java b/src/com/jpexs/decompiler/flash/SWF.java index 6e6aa138e..1778e4c42 100644 --- a/src/com/jpexs/decompiler/flash/SWF.java +++ b/src/com/jpexs/decompiler/flash/SWF.java @@ -369,6 +369,29 @@ public final class SWF implements TreeItem, Timelined { saveTo(os, compression); } + public String getHeaderBytes() { + String ret = ""; + if (compression == SWFCompression.LZMA) { + ret += 'Z'; + } else if (compression == SWFCompression.ZLIB) { + ret += 'C'; + } else { + if (gfx) { + ret += 'G'; + } else { + ret += 'F'; + } + } + if (gfx) { + ret += 'F'; + ret += 'X'; + } else { + ret += 'W'; + ret += 'S'; + } + return ret; + } + /** * Saves this SWF into new file * @@ -1566,7 +1589,7 @@ public final class SWF implements TreeItem, Timelined { new RetryTask(new RunnableIOEx() { @Override public void run() throws IOException { - File f = new File(foutdir + File.separator + (fframes.get(fi)+1) + ".png"); + File f = new File(foutdir + File.separator + (fframes.get(fi) + 1) + ".png"); ImageIO.write(frameImages.next(), "PNG", f); ret.add(f); } diff --git a/src/com/jpexs/decompiler/flash/gui/HeaderInfoPanel.java b/src/com/jpexs/decompiler/flash/gui/HeaderInfoPanel.java new file mode 100644 index 000000000..a63ee1038 --- /dev/null +++ b/src/com/jpexs/decompiler/flash/gui/HeaderInfoPanel.java @@ -0,0 +1,108 @@ +/* + * Copyright (C) 2014 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.decompiler.flash.gui; + +import com.jpexs.decompiler.flash.AppStrings; +import com.jpexs.decompiler.flash.SWF; +import com.jpexs.decompiler.flash.gui.helpers.SpringUtilities; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.SpringLayout; + +/** + * + * @author JPEXS + */ +public class HeaderInfoPanel extends JPanel { + + private final JLabel signatureLabel = new JLabel(); + private final JLabel compressionLabel = new JLabel(); + private final JLabel gfxLabel = new JLabel(); + private final JLabel versionLabel = new JLabel(); + private final JLabel fileSizeLabel = new JLabel(); + private final JLabel frameRateLabel = new JLabel(); + private final JLabel frameCountLabel = new JLabel(); + private final JLabel displayRectTwipsLabel = new JLabel(); + private final JLabel displayRectPixelsLabel = new JLabel(); + + public HeaderInfoPanel() { + setLayout(new SpringLayout()); + + add(new JLabel(AppStrings.translate("header.signature"))); + add(signatureLabel); + add(new JLabel(AppStrings.translate("header.compression"))); + add(compressionLabel); + add(new JLabel(AppStrings.translate("header.version"))); + add(versionLabel); + add(new JLabel(AppStrings.translate("header.gfx"))); + add(gfxLabel); + add(new JLabel(AppStrings.translate("header.filesize"))); + add(fileSizeLabel); + add(new JLabel(AppStrings.translate("header.framerate"))); + add(frameRateLabel); + add(new JLabel(AppStrings.translate("header.framecount"))); + add(frameCountLabel); + add(new JLabel(AppStrings.translate("header.displayrect"))); + add(displayRectTwipsLabel); + add(new JLabel("")); + add(displayRectPixelsLabel); + + + SpringUtilities.makeCompactGrid(this, + 9, 2, //rows, cols + 6, 6, //initX, initY + 6, 6); //xPad, yPad + } + + public void load(SWF swf) { + signatureLabel.setText(swf.getHeaderBytes()); + switch (swf.compression) { + case LZMA: + compressionLabel.setText(AppStrings.translate("header.compression.lzma")); + break; + case ZLIB: + compressionLabel.setText(AppStrings.translate("header.compression.zlib")); + break; + case NONE: + compressionLabel.setText(AppStrings.translate("header.compression.none")); + break; + } + versionLabel.setText("" + swf.version); + gfxLabel.setText(swf.gfx ? AppStrings.translate("yes") : AppStrings.translate("no")); + fileSizeLabel.setText("" + swf.fileSize); + frameRateLabel.setText("" + swf.frameRate); + frameCountLabel.setText("" + swf.frameCount); + displayRectTwipsLabel.setText(AppStrings.translate("header.displayrect.value.twips") + .replace("%xmin%", ""+swf.displayRect.Xmin) + .replace("%ymin%", ""+swf.displayRect.Ymin) + .replace("%xmax%", ""+swf.displayRect.Xmax) + .replace("%ymax%", ""+swf.displayRect.Ymax)); + displayRectPixelsLabel.setText(AppStrings.translate("header.displayrect.value.pixels") + .replace("%xmin%", ""+fmtDouble(swf.displayRect.Xmin/SWF.unitDivisor)) + .replace("%ymin%", ""+fmtDouble(swf.displayRect.Ymin/SWF.unitDivisor)) + .replace("%xmax%", ""+fmtDouble(swf.displayRect.Xmax/SWF.unitDivisor)) + .replace("%ymax%", ""+fmtDouble(swf.displayRect.Ymax/SWF.unitDivisor))); + } + private String fmtDouble(double d){ + String r = ""+d; + if(r.endsWith(".0")){ + r = r.substring(0,r.length()-2); + } + return r; + } + +} diff --git a/src/com/jpexs/decompiler/flash/gui/MainPanel.java b/src/com/jpexs/decompiler/flash/gui/MainPanel.java index fbd4a0c1a..6639557b3 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/MainPanel.java @@ -123,6 +123,7 @@ import com.jpexs.decompiler.flash.treeitems.StringItem; import com.jpexs.decompiler.flash.treeitems.TreeItem; import com.jpexs.decompiler.flash.treenodes.ContainerNode; import com.jpexs.decompiler.flash.treenodes.FrameNode; +import com.jpexs.decompiler.flash.treenodes.HeaderNode; import com.jpexs.decompiler.flash.treenodes.TagNode; import com.jpexs.decompiler.flash.treenodes.TreeNode; import com.jpexs.decompiler.flash.types.MATRIX; @@ -232,6 +233,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec private static final String CARDDUMPVIEW = "Dump view"; private static final String CARDACTIONSCRIPTPANEL = "ActionScript card"; private static final String CARDACTIONSCRIPT3PANEL = "ActionScript3 card"; + private static final String CARDHEADER = "Header card"; private static final String DETAILCARDAS3NAVIGATOR = "Traits list"; private static final String DETAILCARDEMPTYPANEL = "Empty card"; private static final String SPLIT_PANE1 = "SPLITPANE1"; @@ -243,6 +245,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec private JTextField filterField = new MyTextField(""); private JPanel searchPanel; private final PreviewPanel previewPanel; + private HeaderInfoPanel headerPanel; private DumpViewPanel dumpViewPanel; private final JPanel treePanel; private TreePanelMode treePanelMode; @@ -480,7 +483,10 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec displayPanel.add(previewPanel, CARDPREVIEWPANEL); displayPanel.add(createFolderPreviewCard(), CARDFOLDERPREVIEWPANEL); displayPanel.add(createDumpPreviewCard(), CARDDUMPVIEW); - + + headerPanel = new HeaderInfoPanel(); + displayPanel.add(headerPanel,CARDHEADER); + displayPanel.add(new JPanel(), CARDEMPTYPANEL); showCard(CARDEMPTYPANEL); @@ -2244,7 +2250,10 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec previewPanel.setImageReplaceButtonVisible(false); - if (treeNode instanceof StringNode) { + if(treeNode instanceof HeaderNode) { + showCard(CARDHEADER); + headerPanel.load(((HeaderNode)treeNode).getItem().getSwf()); + } else if (treeNode instanceof StringNode) { showCard(CARDFOLDERPREVIEWPANEL); showFolderPreview(treeNode); } else if (treeNode instanceof SWFNode) { diff --git a/src/com/jpexs/decompiler/flash/gui/TagTree.java b/src/com/jpexs/decompiler/flash/gui/TagTree.java index 9ea761325..39de34d27 100644 --- a/src/com/jpexs/decompiler/flash/gui/TagTree.java +++ b/src/com/jpexs/decompiler/flash/gui/TagTree.java @@ -59,6 +59,7 @@ import com.jpexs.decompiler.flash.timeline.Frame; import com.jpexs.decompiler.flash.treeitems.AS2PackageNodeItem; import com.jpexs.decompiler.flash.treeitems.AS3PackageNodeItem; import com.jpexs.decompiler.flash.treeitems.FrameNodeItem; +import com.jpexs.decompiler.flash.treeitems.HeaderItem; import com.jpexs.decompiler.flash.treeitems.SWFList; import com.jpexs.decompiler.flash.treeitems.StringItem; import com.jpexs.decompiler.flash.treeitems.TreeElementItem; @@ -186,6 +187,11 @@ public class TagTree extends JTree implements ActionListener { } public static TreeNodeType getTreeNodeType(TreeItem t) { + + if(t instanceof HeaderItem){ + return TreeNodeType.HEADER; + } + if ((t instanceof DefineFontTag) || (t instanceof DefineFont2Tag) || (t instanceof DefineFont3Tag) diff --git a/src/com/jpexs/decompiler/flash/gui/TagTreeModel.java b/src/com/jpexs/decompiler/flash/gui/TagTreeModel.java index 6fe32a88a..bb741543f 100644 --- a/src/com/jpexs/decompiler/flash/gui/TagTreeModel.java +++ b/src/com/jpexs/decompiler/flash/gui/TagTreeModel.java @@ -35,11 +35,13 @@ import com.jpexs.decompiler.flash.tags.base.SoundStreamHeadTypeTag; import com.jpexs.decompiler.flash.timeline.Timeline; import com.jpexs.decompiler.flash.timeline.Timelined; import com.jpexs.decompiler.flash.treeitems.FrameNodeItem; +import com.jpexs.decompiler.flash.treeitems.HeaderItem; import com.jpexs.decompiler.flash.treeitems.SWFList; import com.jpexs.decompiler.flash.treeitems.StringItem; import com.jpexs.decompiler.flash.treeitems.TreeElementItem; import com.jpexs.decompiler.flash.treeitems.TreeItem; import com.jpexs.decompiler.flash.treenodes.FrameNode; +import com.jpexs.decompiler.flash.treenodes.HeaderNode; import com.jpexs.decompiler.flash.treenodes.TagNode; import com.jpexs.decompiler.flash.treenodes.TreeNode; import java.io.ByteArrayInputStream; @@ -242,6 +244,9 @@ public class TagTreeModel implements TreeModel { } swfNode.scriptsNode = actionScriptNode; + + ret.add(new HeaderNode(new HeaderItem(swf))); + if (!shapesNode.subNodes.isEmpty()) { ret.add(shapesNode); } diff --git a/src/com/jpexs/decompiler/flash/gui/TreeNodeType.java b/src/com/jpexs/decompiler/flash/gui/TreeNodeType.java index 72e9089bd..a3bdc59a9 100644 --- a/src/com/jpexs/decompiler/flash/gui/TreeNodeType.java +++ b/src/com/jpexs/decompiler/flash/gui/TreeNodeType.java @@ -1,46 +1,47 @@ -/* - * Copyright (C) 2010-2014 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.decompiler.flash.gui; - -/** - * - * @author JPEXS - */ -public enum TreeNodeType { - - FLASH, - FONT, - TEXT, - IMAGE, - SHAPE, - MORPH_SHAPE, - SPRITE, - BUTTON, - AS, - PACKAGE, - FRAME, - SHOW_FRAME, - MOVIE, - SOUND, - BINARY_DATA, - OTHER_TAG, - FOLDER, - FOLDER_OPEN, - BUNDLE_ZIP, - BUNDLE_SWC, - BUNDLE_BINARY -} +/* + * Copyright (C) 2010-2014 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.decompiler.flash.gui; + +/** + * + * @author JPEXS + */ +public enum TreeNodeType { + + FLASH, + FONT, + TEXT, + IMAGE, + SHAPE, + MORPH_SHAPE, + SPRITE, + BUTTON, + AS, + PACKAGE, + FRAME, + SHOW_FRAME, + MOVIE, + SOUND, + BINARY_DATA, + OTHER_TAG, + FOLDER, + FOLDER_OPEN, + BUNDLE_ZIP, + BUNDLE_SWC, + BUNDLE_BINARY, + HEADER +} diff --git a/src/com/jpexs/decompiler/flash/gui/graphics/header16.png b/src/com/jpexs/decompiler/flash/gui/graphics/header16.png new file mode 100644 index 000000000..03ddd799f Binary files /dev/null and b/src/com/jpexs/decompiler/flash/gui/graphics/header16.png differ diff --git a/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties b/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties index 787fa0763..de0f127c7 100644 --- a/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties +++ b/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties @@ -491,4 +491,20 @@ menu.settings.dumpView = Dump view menu.view = View menu.file.view.resources = Resources -menu.file.view.hex = Hex dump \ No newline at end of file +menu.file.view.hex = Hex dump + +node.header = header + +header.signature = Signature: +header.compression = Compression: +header.compression.lzma = LZMA +header.compression.zlib = ZLIB +header.compression.none = No compression +header.version = SWF Version: +header.gfx = GFX: +header.filesize = File size: +header.framerate = Frame rate: +header.framecount = Frame count: +header.displayrect = Display rect: +header.displayrect.value.twips = %xmin%,%ymin% => %xmax%,%ymax% twips +header.displayrect.value.pixels = %xmin%,%ymin% => %xmax%,%ymax% pixels \ No newline at end of file diff --git a/src/com/jpexs/decompiler/flash/gui/locales/MainFrame_cs.properties b/src/com/jpexs/decompiler/flash/gui/locales/MainFrame_cs.properties index 521f267be..e162109ae 100644 --- a/src/com/jpexs/decompiler/flash/gui/locales/MainFrame_cs.properties +++ b/src/com/jpexs/decompiler/flash/gui/locales/MainFrame_cs.properties @@ -482,4 +482,19 @@ abc.action.find-declaration = Naj\u00edt deklaraci menu.view = Zobrazen\u00ed menu.file.view.resources = Zdroje -menu.file.view.hex = Hex dump \ No newline at end of file +menu.file.view.hex = Hex dump + +node.header = hlavi\u010dka +header.signature = Signatura: +header.compression = Komprese: +header.compression.lzma = LZMA +header.compression.zlib = ZLIB +header.compression.none = Bez komprese +header.version = Verze SWF: +header.gfx = GFX: +header.filesize = Velikost souboru: +header.framerate = Frekvence sn\u00edmk\u016f: +header.framecount = Po\u010det sn\u00edmk\u016f: +header.displayrect = Zobrazen\u00fd obd\u00e9ln\u00edk: +header.displayrect.value.twips = %xmin%,%ymin% => %xmax%,%ymax% twip\u016f +header.displayrect.value.pixels = %xmin%,%ymin% => %xmax%,%ymax% pixel\u016f \ No newline at end of file diff --git a/src/com/jpexs/decompiler/flash/treeitems/HeaderItem.java b/src/com/jpexs/decompiler/flash/treeitems/HeaderItem.java new file mode 100644 index 000000000..0baefd1ff --- /dev/null +++ b/src/com/jpexs/decompiler/flash/treeitems/HeaderItem.java @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2014 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.decompiler.flash.treeitems; + +import com.jpexs.decompiler.flash.AppStrings; +import com.jpexs.decompiler.flash.SWF; + +/** + * + * @author JPEXS + */ +public class HeaderItem implements TreeItem { + + private SWF swf; + + public HeaderItem(SWF swf) { + this.swf = swf; + } + + + + @Override + public SWF getSwf() { + return swf; + } + + @Override + public String toString() { + return AppStrings.translate("node.header"); + } + + + +} diff --git a/src/com/jpexs/decompiler/flash/treenodes/HeaderNode.java b/src/com/jpexs/decompiler/flash/treenodes/HeaderNode.java new file mode 100644 index 000000000..ba079d9f2 --- /dev/null +++ b/src/com/jpexs/decompiler/flash/treenodes/HeaderNode.java @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2014 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.decompiler.flash.treenodes; + +import com.jpexs.decompiler.flash.treeitems.HeaderItem; + +/** + * + * @author JPEXS + */ +public class HeaderNode extends TreeNode { + + public HeaderNode(HeaderItem item) { + super(item); + } + + @Override + public HeaderItem getItem() { + return (HeaderItem) item; + } + +}