Merged AS1/2/3 frame, displaying shapes, images,...

This commit is contained in:
Jindra Petk
2013-01-12 16:22:49 +01:00
parent 4a8870aa2e
commit 29c8fb98f9
104 changed files with 1956 additions and 2218 deletions

View File

@@ -20,6 +20,7 @@ import com.jpexs.asdec.abc.NotSameException;
import com.jpexs.asdec.abc.avm2.AVM2Code;
import com.jpexs.asdec.gui.AboutDialog;
import com.jpexs.asdec.gui.LoadingDialog;
import com.jpexs.asdec.gui.MainFrame;
import com.jpexs.asdec.gui.ModeFrame;
import com.jpexs.asdec.gui.View;
import com.jpexs.asdec.gui.proxy.ProxyFrame;
@@ -60,8 +61,6 @@ import org.w3c.dom.NodeList;
*/
public class Main {
public static com.jpexs.asdec.abc.gui.MainFrame abcMainFrame;
public static com.jpexs.asdec.action.gui.MainFrame actionMainFrame;
public static ProxyFrame proxyFrame;
public static String file;
public static String maskURL;
@@ -77,6 +76,7 @@ public class Main {
private static TrayIcon trayIcon;
private static MenuItem stopMenuItem;
private static boolean commandLineMode = false;
public static MainFrame mainFrame;
public static boolean isCommandLineMode() {
return commandLineMode;
@@ -143,12 +143,14 @@ public class Main {
public static void startWork(String name) {
working = true;
if (abcMainFrame != null) {
abcMainFrame.setStatus(name);
}
if (actionMainFrame != null) {
actionMainFrame.setStatus(name);
if (mainFrame != null) {
if (mainFrame.abcPanel != null) {
mainFrame.setStatus(name);
}
}
/*if (actionMainFrame != null) {
actionMainFrame.setStatus(name);
}*/
if (loadingDialog != null) {
loadingDialog.setDetail(name);
}
@@ -159,12 +161,14 @@ public class Main {
public static void stopWork() {
working = false;
if (abcMainFrame != null) {
abcMainFrame.setStatus("");
}
if (actionMainFrame != null) {
actionMainFrame.setStatus("");
if (mainFrame != null) {
if (mainFrame.abcPanel != null) {
mainFrame.setStatus("");
}
}
/*if (actionMainFrame != null) {
actionMainFrame.setStatus("");
}*/
if (loadingDialog != null) {
loadingDialog.setDetail("");
}
@@ -199,12 +203,12 @@ public class Main {
FileInputStream fis = new FileInputStream(file);
DEBUG_COPY = true;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
swf.saveTo(baos);
} catch (NotSameException nse) {
Logger.getLogger(Main.class.getName()).log(Level.FINE, null, nse);
JOptionPane.showMessageDialog(null, "WARNING: The SWF decompiler may have problems saving this file. Recommended usage is READ ONLY.");
}
/*try {
swf.saveTo(baos);
} catch (NotSameException nse) {
Logger.getLogger(Main.class.getName()).log(Level.FINE, null, nse);
JOptionPane.showMessageDialog(null, "WARNING: The SWF decompiler may have problems saving this file. Recommended usage is READ ONLY.");
}*/
DEBUG_COPY = false;
//DEBUG_COPY=true;
} catch (Exception ex) {
@@ -213,45 +217,25 @@ public class Main {
loadingDialog.setVisible(false);
return false;
}
List<Tag> listAbc = new ArrayList<Tag>();
for (Tag t : swf.tags) {
if (t instanceof DoABCTag) {
listAbc.add(t);
}
}
if (false) {
JOptionPane.showMessageDialog(null, "This SWF file does not contain any ActionScript parts");
try {
mainFrame = new MainFrame(swf);
loadingDialog.setVisible(false);
if (!openFileDialog()) {
System.exit(0);
}
} else {
if (listAbc.size() > 0) {
List<DoABCTag> listAbc2 = new ArrayList<DoABCTag>();
for (Tag tag : listAbc) {
listAbc2.add((DoABCTag) tag);
}
abcMainFrame = new com.jpexs.asdec.abc.gui.MainFrame(listAbc2);
abcMainFrame.display();
} else {
actionMainFrame = new com.jpexs.asdec.action.gui.MainFrame(swf.tags);
actionMainFrame.display();
}
mainFrame.setVisible(true);
} catch (Exception ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
loadingDialog.setVisible(false);
return true;
}
}
public static boolean openFile(String swfFile) {
if (abcMainFrame != null) {
abcMainFrame.setVisible(false);
}
if (actionMainFrame != null) {
actionMainFrame.setVisible(false);
if (mainFrame != null) {
mainFrame.setVisible(false);
}
/*if (actionMainFrame != null) {
actionMainFrame.setVisible(false);
}*/
Main.file = swfFile;
if (Main.loadingDialog == null) {
Main.loadingDialog = new LoadingDialog();

View File

@@ -29,7 +29,6 @@ import com.jpexs.asdec.tags.DoABCTag;
import com.jpexs.asdec.tags.JPEGTablesTag;
import com.jpexs.asdec.tags.Tag;
import com.jpexs.asdec.tags.base.ASMSource;
import com.jpexs.asdec.tags.base.TagName;
import com.jpexs.asdec.types.ALPHABITMAPDATA;
import com.jpexs.asdec.types.ALPHACOLORMAPDATA;
import com.jpexs.asdec.types.BITMAPDATA;
@@ -395,11 +394,9 @@ public class SWF {
}
List<String> existingNames = new ArrayList<String>();
for (TagNode node : nodeList) {
String name;
if (node.tag instanceof TagName) {
name = ((TagName) node.tag).getName();
} else {
name = node.tag.toString();
String name="";
if (node.tag instanceof Tag) {
name = ((Tag) node.tag).getExportName();
}
int i = 1;
String baseName = name;
@@ -470,7 +467,7 @@ public class SWF {
return "unk";
}
private boolean hasErrorHeader(byte data[]) {
public static boolean hasErrorHeader(byte data[]) {
if (data.length > 4) {
if ((data[0] & 0xff) == 0xff) {
if ((data[1] & 0xff) == 0xd9) {
@@ -529,82 +526,20 @@ public class SWF {
}
}
if (t instanceof DefineBitsLosslessTag) {
DefineBitsLosslessTag dbl = (DefineBitsLosslessTag) t;
BufferedImage bi = new BufferedImage(dbl.bitmapWidth, dbl.bitmapHeight, BufferedImage.TYPE_INT_RGB);
Graphics g = bi.getGraphics();
COLORMAPDATA colorMapData = null;
BITMAPDATA bitmapData = null;
if (dbl.bitmapFormat == DefineBitsLosslessTag.FORMAT_8BIT_COLORMAPPED) {
colorMapData = dbl.getColorMapData();
}
if ((dbl.bitmapFormat == DefineBitsLosslessTag.FORMAT_15BIT_RGB) || (dbl.bitmapFormat == DefineBitsLosslessTag.FORMAT_24BIT_RGB)) {
bitmapData = dbl.getBitmapData();
}
int pos32aligned = 0;
int pos = 0;
for (int y = 0; y < dbl.bitmapHeight; y++) {
for (int x = 0; x < dbl.bitmapWidth; x++) {
if (dbl.bitmapFormat == DefineBitsLosslessTag.FORMAT_8BIT_COLORMAPPED) {
RGB color = colorMapData.colorTableRGB[colorMapData.colorMapPixelData[pos32aligned]];
g.setColor(new Color(color.red, color.green, color.blue));
}
if (dbl.bitmapFormat == DefineBitsLosslessTag.FORMAT_15BIT_RGB) {
g.setColor(new Color(bitmapData.bitmapPixelDataPix15[pos].red * 8, bitmapData.bitmapPixelDataPix15[pos].green * 8, bitmapData.bitmapPixelDataPix15[pos].blue * 8));
}
if (dbl.bitmapFormat == DefineBitsLosslessTag.FORMAT_24BIT_RGB) {
g.setColor(new Color(bitmapData.bitmapPixelDataPix24[pos].red, bitmapData.bitmapPixelDataPix24[pos].green, bitmapData.bitmapPixelDataPix24[pos].blue));
}
g.fillRect(x, y, 1, 1);
pos32aligned++;
pos++;
}
while ((pos32aligned % 4 != 0)) {
pos32aligned++;
}
}
ImageIO.write(bi, "PNG", new File(outdir + File.separator + dbl.characterID + ".png"));
DefineBitsLosslessTag dbl = (DefineBitsLosslessTag) t;
ImageIO.write(dbl.getImage(), "PNG", new File(outdir + File.separator + dbl.characterID + ".png"));
}
if (t instanceof DefineBitsLossless2Tag) {
DefineBitsLossless2Tag dbl = (DefineBitsLossless2Tag) t;
BufferedImage bi = new BufferedImage(dbl.bitmapWidth, dbl.bitmapHeight, BufferedImage.TYPE_INT_ARGB);
Graphics g = bi.getGraphics();
ALPHACOLORMAPDATA colorMapData = null;
ALPHABITMAPDATA bitmapData = null;
if (dbl.bitmapFormat == DefineBitsLossless2Tag.FORMAT_8BIT_COLORMAPPED) {
colorMapData = dbl.getColorMapData();
}
if ((dbl.bitmapFormat == DefineBitsLossless2Tag.FORMAT_15BIT_RGB) || (dbl.bitmapFormat == DefineBitsLossless2Tag.FORMAT_24BIT_RGB)) {
bitmapData = dbl.getBitmapData();
}
int pos32aligned = 0;
int pos = 0;
for (int y = 0; y < dbl.bitmapHeight; y++) {
for (int x = 0; x < dbl.bitmapWidth; x++) {
if ((dbl.bitmapFormat == DefineBitsLossless2Tag.FORMAT_8BIT_COLORMAPPED)) {
RGBA color = colorMapData.colorTableRGB[colorMapData.colorMapPixelData[pos32aligned]];
g.setColor(new Color(color.red, color.green, color.blue, color.alpha));
}
if ((dbl.bitmapFormat == DefineBitsLossless2Tag.FORMAT_15BIT_RGB) || (dbl.bitmapFormat == DefineBitsLossless2Tag.FORMAT_24BIT_RGB)) {
g.setColor(new Color(bitmapData.bitmapPixelData[pos].red, bitmapData.bitmapPixelData[pos].green, bitmapData.bitmapPixelData[pos].blue, bitmapData.bitmapPixelData[pos].alpha));
}
g.fillRect(x, y, 1, 1);
pos32aligned++;
pos++;
}
while ((pos32aligned % 4 != 0)) {
pos32aligned++;
}
}
ImageIO.write(bi, "PNG", new File(outdir + File.separator + dbl.characterID + ".png"));
ImageIO.write(dbl.getImage(), "PNG", new File(outdir + File.separator + dbl.characterID + ".png"));
}
if ((jtt != null) && (t instanceof DefineBitsTag)) {
DefineBitsTag dbt = (DefineBitsTag) t;
FileOutputStream fos = null;
try {
fos = new FileOutputStream(outdir + File.separator + dbt.characterID + ".jpg");
byte data[] = jtt.getData(10);
fos.write(data, hasErrorHeader(data) ? 4 : 0, data.length - (hasErrorHeader(data) ? 6 : 2));
fos.write(dbt.jpegData, hasErrorHeader(dbt.jpegData) ? 6 : 2, dbt.jpegData.length - (hasErrorHeader(data) ? 6 : 2));
fos.write(dbt.getFullImageData(jtt));
} finally {
if (fos != null) {
try {

View File

@@ -409,6 +409,7 @@ public class SWFInputStream extends InputStream {
ret.Xmax = (int) readSB(NBits);
ret.Ymin = (int) readSB(NBits);
ret.Ymax = (int) readSB(NBits);
ret.nbits=NBits;
alignByte();
return ret;
}
@@ -711,7 +712,7 @@ public class SWFInputStream extends InputStream {
ret = new DefineFont4Tag(data, version, pos);
break;
default:
ret = new Tag(tagID, data, pos);
ret = new Tag(tagID,"Unknown", data, pos);
}
ret.forceWriteAsLong = readLong;
byte dataNew[] = ret.getData(version);
@@ -744,7 +745,7 @@ public class SWFInputStream extends InputStream {
e += (Long.toHexString(data[j] & 0xff) + " ");
}
}
log.severe(e);
log.fine(e);
}
}
return ret;
@@ -995,16 +996,19 @@ public class SWFInputStream extends InputStream {
int NScaleBits = (int) readUB(5);
ret.scaleX = (int)readSB(NScaleBits);
ret.scaleY = (int)readSB(NScaleBits);
ret.bitsScale=NScaleBits;
}
ret.hasRotate = readUB(1) == 1;
if (ret.hasRotate) {
int NRotateBits = (int) readUB(5);
ret.rotateSkew0 = (int)readSB(NRotateBits);
ret.rotateSkew1 = (int)readSB(NRotateBits);
ret.bitsRotate=NRotateBits;
}
int NTranslateBits = (int) readUB(5);
ret.translateX = (int) readSB(NTranslateBits);
ret.translateY = (int) readSB(NTranslateBits);
ret.bitsTranslate=NTranslateBits;
alignByte();
return ret;
}
@@ -2233,6 +2237,7 @@ public class SWFInputStream extends InputStream {
}
dataLen++;
}
x--;
while ((x % 4) != 0) {
dataLen++;
readUI8();

View File

@@ -341,7 +341,6 @@ public class SWFOutputStream extends OutputStream {
nBits = enlargeBitCountS(nBits, value.Xmax);
nBits = enlargeBitCountS(nBits, value.Ymin);
nBits = enlargeBitCountS(nBits, value.Ymax);
writeUB(5, nBits);
writeSB(nBits, value.Xmin);
writeSB(nBits, value.Xmax);
@@ -374,7 +373,7 @@ public class SWFOutputStream extends OutputStream {
* @throws IOException
*/
public void writeTag(Tag tag) throws IOException {
byte data[] = tag.getData(version);
byte data[] = tag.getData(version);
int tagLength = data.length;
int tagID = tag.getId();
int tagIDLength = (tagID << 6);
@@ -415,6 +414,9 @@ public class SWFOutputStream extends OutputStream {
* @return Number of bits
*/
public static int getNeededBitsS(int v) {
if(v==0){
//return 0;
}
int counter = 32;
int mask = 0x80000000;
final int val = (v < 0) ? -v : v;
@@ -521,10 +523,9 @@ public class SWFOutputStream extends OutputStream {
int NTranslateBits=0;
NTranslateBits = enlargeBitCountS(NTranslateBits, value.translateX);
NTranslateBits = enlargeBitCountS(NTranslateBits, value.translateY);
writeUB(5, NTranslateBits);
writeSB(NTranslateBits, value.translateX);
writeSB(NTranslateBits, value.translateY);
alignByte();

View File

@@ -0,0 +1,351 @@
/*
* Copyright (C) 2010-2011 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.asdec.abc.gui;
import com.jpexs.asdec.Configuration;
import com.jpexs.asdec.Main;
import com.jpexs.asdec.abc.ABC;
import com.jpexs.asdec.abc.gui.tablemodels.*;
import com.jpexs.asdec.gui.LoadingPanel;
import com.jpexs.asdec.gui.View;
import com.jpexs.asdec.tags.DoABCTag;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.*;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.*;
import javax.swing.border.BevelBorder;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.table.*;
import jsyntaxpane.DefaultSyntaxKit;
public class ABCPanel extends JPanel implements ItemListener, ActionListener {
public TraitsList navigator;
public ClassesListTree classTree;
public ABC abc;
public List<DoABCTag> list;
public JComboBox abcComboBox;
public int listIndex = 0;
public DecompiledEditorPane decompiledTextArea;
public JScrollPane decompiledScrollPane;
public JSplitPane splitPaneDecompiledVSDetail;
public JSplitPane splitPaneTreeVSNavigator;
public JSplitPane splitPaneTreeNavVSDecompiledDetail;
private JTable constantTable;
public JComboBox constantTypeList;
public JLabel asmLabel = new JLabel("P-code source (editable)");
public JLabel decLabel = new JLabel("ActionScript source");
public DetailPanel detailPanel;
public JTextField filterField = new JTextField("");
private JTable autoResizeColWidth(JTable table, TableModel model) {
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
table.setModel(model);
int margin = 5;
for (int i = 0; i < table.getColumnCount(); i++) {
int vColIndex = i;
DefaultTableColumnModel colModel = (DefaultTableColumnModel) table.getColumnModel();
TableColumn col = colModel.getColumn(vColIndex);
int width;
// Get width of column header
TableCellRenderer renderer = col.getHeaderRenderer();
if (renderer == null) {
renderer = table.getTableHeader().getDefaultRenderer();
}
Component comp = renderer.getTableCellRendererComponent(table, col.getHeaderValue(), false, false, 0, 0);
width = comp.getPreferredSize().width;
// Get maximum width of column data
for (int r = 0; r < table.getRowCount(); r++) {
renderer = table.getCellRenderer(r, vColIndex);
comp = renderer.getTableCellRendererComponent(table, table.getValueAt(r, vColIndex), false, false,
r, vColIndex);
width = Math.max(width, comp.getPreferredSize().width);
}
// Add margin
width += 2 * margin;
// Set the width
col.setPreferredWidth(width);
}
((DefaultTableCellRenderer) table.getTableHeader().getDefaultRenderer()).setHorizontalAlignment(
SwingConstants.LEFT);
// table.setAutoCreateRowSorter(true);
table.getTableHeader().setReorderingAllowed(false);
return table;
}
public void setAbc(ABC abc) {
this.abc = abc;
updateConstList();
}
public void updateConstList() {
switch (constantTypeList.getSelectedIndex()) {
case 0:
autoResizeColWidth(constantTable, new UIntTableModel(abc));
break;
case 1:
autoResizeColWidth(constantTable, new IntTableModel(abc));
break;
case 2:
autoResizeColWidth(constantTable, new DoubleTableModel(abc));
break;
case 3:
autoResizeColWidth(constantTable, new DecimalTableModel(abc));
break;
case 4:
autoResizeColWidth(constantTable, new StringTableModel(abc));
break;
case 5:
autoResizeColWidth(constantTable, new NamespaceTableModel(abc));
break;
case 6:
autoResizeColWidth(constantTable, new NamespaceSetTableModel(abc));
break;
case 7:
autoResizeColWidth(constantTable, new MultinameTableModel(abc));
break;
}
//DefaultTableColumnModel colModel = (DefaultTableColumnModel) constantTable.getColumnModel();
//colModel.getColumn(0).setMaxWidth(50);
}
public void switchAbc(int index) {
listIndex = index;
if (index == -1) {
classTree.setDoABCTags(list);
} else {
List<DoABCTag> oneList = new ArrayList<DoABCTag>();
oneList.add(list.get(index));
this.abc = list.get(index).abc;
classTree.setDoABCTags(oneList);
}
updateConstList();
}
public void initSplits(){
splitPaneDecompiledVSDetail.setDividerLocation(getWidth()*1/3);
splitPaneTreeVSNavigator.setDividerLocation(getHeight()/2);
splitPaneTreeNavVSDecompiledDetail.setDividerLocation(getWidth()*1/3);
}
public ABCPanel(List<DoABCTag> list) {
DefaultSyntaxKit.initKit();
this.list = list;
if(list.size()>0){
this.abc = list.get(listIndex).abc;
}
setLayout(new BorderLayout());
decompiledTextArea = new DecompiledEditorPane();
decompiledScrollPane = new JScrollPane(decompiledTextArea);
detailPanel = new DetailPanel();
JPanel panB = new JPanel();
panB.setLayout(new BorderLayout());
panB.add(decompiledScrollPane, BorderLayout.CENTER);
panB.add(decLabel, BorderLayout.NORTH);
decLabel.setHorizontalAlignment(SwingConstants.CENTER);
decLabel.setBorder(new BevelBorder(BevelBorder.RAISED));
splitPaneDecompiledVSDetail = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
panB, detailPanel);
decompiledTextArea.setContentType("text/actionscript");
JPanel pan2 = new JPanel();
pan2.setLayout(new BorderLayout());
pan2.add((abcComboBox = new JComboBox(new ABCComboBoxModel(list))), BorderLayout.NORTH);
navigator = new TraitsList();
navigator.setABC(list, abc);
JPanel navPanel = new JPanel(new BorderLayout());
JLabel traitsLabel = new JLabel("Traits");
navPanel.add(traitsLabel, BorderLayout.NORTH);
traitsLabel.setBorder(new BevelBorder(BevelBorder.RAISED));
navPanel.add(new JScrollPane(navigator), BorderLayout.CENTER);
Main.startWork("Building script tree...");
filterField.setActionCommand("FILTERSCRIPT");
filterField.addActionListener(this);
filterField.getDocument().addDocumentListener(new DocumentListener() {
@Override
public void changedUpdate(DocumentEvent e) {
warn();
}
@Override
public void removeUpdate(DocumentEvent e) {
warn();
}
@Override
public void insertUpdate(DocumentEvent e) {
warn();
}
public void warn() {
doFilter();
}
});
JPanel treePanel = new JPanel();
treePanel.setLayout(new BorderLayout());
treePanel.add(new JScrollPane(classTree = new ClassesListTree(list)), BorderLayout.CENTER);
JPanel searchPanel = new JPanel();
searchPanel.setLayout(new BorderLayout());
searchPanel.add(filterField, BorderLayout.CENTER);
JLabel picLabel = new JLabel(new ImageIcon(View.loadImage("com/jpexs/asdec/gui/graphics/search.png")));
searchPanel.add(picLabel, BorderLayout.EAST);
treePanel.add(searchPanel, BorderLayout.NORTH);
splitPaneTreeVSNavigator = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
treePanel,
navPanel);
Main.startWork("Creating window...");
JTabbedPane tabbedPane = new JTabbedPane();
tabbedPane.addTab("Scripts", splitPaneTreeVSNavigator);
pan2.add(tabbedPane, BorderLayout.CENTER);
abcComboBox.addItemListener(this);
splitPaneTreeNavVSDecompiledDetail = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
pan2,
splitPaneDecompiledVSDetail);
//pan2.setPreferredSize(new Dimension(300, 200));
add(splitPaneTreeNavVSDecompiledDetail, BorderLayout.CENTER);
JPanel panConstants = new JPanel();
panConstants.setLayout(new BorderLayout());
constantTypeList = new JComboBox(new String[]{"UINT", "INT", "DOUBLE", "DECIMAL", "STRING", "NAMESPACE", "NAMESPACESET", "MULTINAME"});
constantTable = new JTable();
if(abc!=null){
autoResizeColWidth(constantTable, new UIntTableModel(abc));
}
constantTable.setAutoCreateRowSorter(true);
final List<DoABCTag> inlist = list;
constantTable.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 2) {
if (constantTypeList.getSelectedIndex() == 7) { //MULTINAME
int rowIndex = constantTable.getSelectedRow();
if (rowIndex == -1) {
return;
}
int multinameIndex = constantTable.convertRowIndexToModel(rowIndex);
if (multinameIndex > 0) {
UsageFrame usageFrame = new UsageFrame(inlist, abc, multinameIndex);
usageFrame.setVisible(true);
}
}
}
}
});
constantTypeList.addItemListener(this);
panConstants.add(constantTypeList, BorderLayout.NORTH);
panConstants.add(new JScrollPane(constantTable), BorderLayout.CENTER);
tabbedPane.addTab("Constants", panConstants);
}
public void doFilter() {
classTree.applyFilter(filterField.getText());
}
public void reload() {
switchAbc(listIndex - 1);
}
public void itemStateChanged(ItemEvent e) {
if (e.getSource() == abcComboBox) {
int index = ((JComboBox) e.getSource()).getSelectedIndex();
if (index == -1) {
return;
}
switchAbc(index - 1);
}
if (e.getSource() == constantTypeList) {
int index = ((JComboBox) e.getSource()).getSelectedIndex();
if (index == -1) {
return;
}
updateConstList();
}
}
public void display() {
setVisible(true);
splitPaneTreeVSNavigator.setDividerLocation(0.5);
splitPaneDecompiledVSDetail.setDividerLocation(0.5);
}
@Override
public void actionPerformed(ActionEvent e) {
if (e.getActionCommand().equals("FILTERSCRIPT")) {
doFilter();
}
}
}

View File

@@ -138,12 +138,12 @@ public class ClassesListTree extends JTree implements TreeSelectionListener {
break;
}
}
Main.abcMainFrame.navigator.setABC(abcList, scriptLeaf.abc);
Main.abcMainFrame.navigator.setClassIndex(classIndex);
Main.abcMainFrame.setAbc(scriptLeaf.abc);
Main.abcMainFrame.decompiledTextArea.setScript(scriptLeaf.abc.script_info[scriptLeaf.scriptIndex], scriptLeaf.abc, abcList);
Main.abcMainFrame.decompiledTextArea.setClassIndex(classIndex);
Main.abcMainFrame.detailPanel.methodTraitPanel.methodCodePanel.sourceTextArea.setText("");
Main.mainFrame.abcPanel.navigator.setABC(abcList, scriptLeaf.abc);
Main.mainFrame.abcPanel.navigator.setClassIndex(classIndex);
Main.mainFrame.abcPanel.setAbc(scriptLeaf.abc);
Main.mainFrame.abcPanel.decompiledTextArea.setScript(scriptLeaf.abc.script_info[scriptLeaf.scriptIndex], scriptLeaf.abc, abcList);
Main.mainFrame.abcPanel.decompiledTextArea.setClassIndex(classIndex);
Main.mainFrame.abcPanel.detailPanel.methodTraitPanel.methodCodePanel.sourceTextArea.setText("");
Main.stopWork();
}
}).start();

View File

@@ -43,7 +43,7 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements MouseL
public int lastTraitIndex = 0;
public void setNoTrait() {
Main.abcMainFrame.detailPanel.showCard(DetailPanel.UNSUPPORTED_TRAIT_CARD);
Main.mainFrame.abcPanel.detailPanel.showCard(DetailPanel.UNSUPPORTED_TRAIT_CARD);
}
public void setClassIndex(int classIndex) {
@@ -55,17 +55,17 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements MouseL
if (bi == -1) {
return false;
}
Main.abcMainFrame.detailPanel.showCard(DetailPanel.METHOD_TRAIT_CARD);
if (Main.abcMainFrame.detailPanel.methodTraitPanel.methodCodePanel.sourceTextArea.bodyIndex != bi) {
Main.abcMainFrame.detailPanel.methodTraitPanel.methodCodePanel.sourceTextArea.setBodyIndex(bi, abc);
Main.abcMainFrame.detailPanel.methodTraitPanel.methodBodyParamsPanel.loadFromBody(abc.bodies[bi]);
Main.abcMainFrame.detailPanel.methodTraitPanel.methodInfoPanel.load(abc.bodies[bi].method_info, abc);
Main.mainFrame.abcPanel.detailPanel.showCard(DetailPanel.METHOD_TRAIT_CARD);
if (Main.mainFrame.abcPanel.detailPanel.methodTraitPanel.methodCodePanel.sourceTextArea.bodyIndex != bi) {
Main.mainFrame.abcPanel.detailPanel.methodTraitPanel.methodCodePanel.sourceTextArea.setBodyIndex(bi, abc);
Main.mainFrame.abcPanel.detailPanel.methodTraitPanel.methodBodyParamsPanel.loadFromBody(abc.bodies[bi]);
Main.mainFrame.abcPanel.detailPanel.methodTraitPanel.methodInfoPanel.load(abc.bodies[bi].method_info, abc);
}
boolean success = false;
for (Highlighting h : highlights) {
if ((pos >= h.startPos) && (pos < h.startPos + h.len)) {
try {
Main.abcMainFrame.detailPanel.methodTraitPanel.methodCodePanel.sourceTextArea.selectInstruction(abc.bodies[bi].code.adr2pos(h.offset));
Main.mainFrame.abcPanel.detailPanel.methodTraitPanel.methodCodePanel.sourceTextArea.selectInstruction(abc.bodies[bi].code.adr2pos(h.offset));
} catch (ConvertException ex) {
}
@@ -77,8 +77,8 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements MouseL
}
public void displayClass(int classIndex) {
if (Main.abcMainFrame.navigator.getClassIndex() != classIndex) {
Main.abcMainFrame.navigator.setClassIndex(classIndex);
if (Main.mainFrame.abcPanel.navigator.getClassIndex() != classIndex) {
Main.mainFrame.abcPanel.navigator.setClassIndex(classIndex);
}
}
private int classIndex = -1;
@@ -112,8 +112,8 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements MouseL
Trait tr = abc.findTraitByTraitId(classIndex, (int) th.offset);
if (tr != null) {
if (tr instanceof TraitSlotConst) {
Main.abcMainFrame.detailPanel.slotConstTraitPanel.load((TraitSlotConst) tr, abc);
Main.abcMainFrame.detailPanel.showCard(DetailPanel.SLOT_CONST_TRAIT_CARD);
Main.mainFrame.abcPanel.detailPanel.slotConstTraitPanel.load((TraitSlotConst) tr, abc);
Main.mainFrame.abcPanel.detailPanel.showCard(DetailPanel.SLOT_CONST_TRAIT_CARD);
return;
}
}

View File

@@ -97,9 +97,9 @@ public class DetailPanel extends JPanel implements ActionListener {
if (e.getActionCommand().equals("SAVEDETAIL")) {
if (cardMap.get(selectedCard) instanceof TraitDetail) {
if (((TraitDetail) cardMap.get(selectedCard)).save()) {
int lasttrait = Main.abcMainFrame.decompiledTextArea.lastTraitIndex;
Main.abcMainFrame.decompiledTextArea.reloadClass();
Main.abcMainFrame.decompiledTextArea.gotoTrait(lasttrait);
int lasttrait = Main.mainFrame.abcPanel.decompiledTextArea.lastTraitIndex;
Main.mainFrame.abcPanel.decompiledTextArea.reloadClass();
Main.mainFrame.abcPanel.decompiledTextArea.gotoTrait(lasttrait);
JOptionPane.showMessageDialog(this, "Trait Successfully saved");
}
}

View File

@@ -1,580 +0,0 @@
/*
* Copyright (C) 2010-2011 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.asdec.abc.gui;
import com.jpexs.asdec.Configuration;
import com.jpexs.asdec.Main;
import com.jpexs.asdec.abc.ABC;
import com.jpexs.asdec.abc.gui.tablemodels.*;
import com.jpexs.asdec.gui.LoadingPanel;
import com.jpexs.asdec.gui.View;
import com.jpexs.asdec.tags.DoABCTag;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.*;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.*;
import javax.swing.border.BevelBorder;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.table.*;
import jsyntaxpane.DefaultSyntaxKit;
public class MainFrame extends JFrame implements ActionListener, ItemListener {
public TraitsList navigator;
public ClassesListTree classTree;
public ABC abc;
public List<DoABCTag> list;
public JComboBox abcComboBox;
public int listIndex = 0;
public DecompiledEditorPane decompiledTextArea;
public JScrollPane decompiledScrollPane;
public JSplitPane splitPane1;
public JSplitPane splitPane2;
public JSplitPane splitPane3;
//private ConstantsListModel constantListModel;
private JTable constantTable;
//private JList constantsList;
public JComboBox constantTypeList;
public JPanel statusPanel = new JPanel();
public LoadingPanel loadingPanel = new LoadingPanel(20, 20);
public JLabel statusLabel = new JLabel("");
public JLabel asmLabel = new JLabel("P-code source (editable)");
public JLabel decLabel = new JLabel("ActionScript source");
public DetailPanel detailPanel;
public JTextField filterField = new JTextField("");
public void setStatus(String s) {
if (s.equals("")) {
loadingPanel.setVisible(false);
} else {
loadingPanel.setVisible(true);
}
statusLabel.setText(s);
}
private JTable autoResizeColWidth(JTable table, TableModel model) {
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
table.setModel(model);
int margin = 5;
for (int i = 0; i < table.getColumnCount(); i++) {
int vColIndex = i;
DefaultTableColumnModel colModel = (DefaultTableColumnModel) table.getColumnModel();
TableColumn col = colModel.getColumn(vColIndex);
int width;
// Get width of column header
TableCellRenderer renderer = col.getHeaderRenderer();
if (renderer == null) {
renderer = table.getTableHeader().getDefaultRenderer();
}
Component comp = renderer.getTableCellRendererComponent(table, col.getHeaderValue(), false, false, 0, 0);
width = comp.getPreferredSize().width;
// Get maximum width of column data
for (int r = 0; r < table.getRowCount(); r++) {
renderer = table.getCellRenderer(r, vColIndex);
comp = renderer.getTableCellRendererComponent(table, table.getValueAt(r, vColIndex), false, false,
r, vColIndex);
width = Math.max(width, comp.getPreferredSize().width);
}
// Add margin
width += 2 * margin;
// Set the width
col.setPreferredWidth(width);
}
((DefaultTableCellRenderer) table.getTableHeader().getDefaultRenderer()).setHorizontalAlignment(
SwingConstants.LEFT);
// table.setAutoCreateRowSorter(true);
table.getTableHeader().setReorderingAllowed(false);
return table;
}
public void setAbc(ABC abc) {
this.abc = abc;
updateConstList();
}
public void updateConstList() {
switch (constantTypeList.getSelectedIndex()) {
case 0:
autoResizeColWidth(constantTable, new UIntTableModel(abc));
break;
case 1:
autoResizeColWidth(constantTable, new IntTableModel(abc));
break;
case 2:
autoResizeColWidth(constantTable, new DoubleTableModel(abc));
break;
case 3:
autoResizeColWidth(constantTable, new DecimalTableModel(abc));
break;
case 4:
autoResizeColWidth(constantTable, new StringTableModel(abc));
break;
case 5:
autoResizeColWidth(constantTable, new NamespaceTableModel(abc));
break;
case 6:
autoResizeColWidth(constantTable, new NamespaceSetTableModel(abc));
break;
case 7:
autoResizeColWidth(constantTable, new MultinameTableModel(abc));
break;
}
//DefaultTableColumnModel colModel = (DefaultTableColumnModel) constantTable.getColumnModel();
//colModel.getColumn(0).setMaxWidth(50);
}
public void switchAbc(int index) {
listIndex = index;
if (index == -1) {
classTree.setDoABCTags(list);
} else {
List<DoABCTag> oneList = new ArrayList<DoABCTag>();
oneList.add(list.get(index));
this.abc = list.get(index).abc;
classTree.setDoABCTags(oneList);
}
//decompiledTextArea.setABC(abc);
//navigator.setABC(abc);
//constantTypeList = new JComboBox(new String[]{"UINT", "INT", "DOUBLE", "STRING", "NAMESPACE", "NAMESPACESET", "MULTINAME"});
updateConstList();
}
public MainFrame(List<DoABCTag> list) {
View.setWindowIcon(this);
DefaultSyntaxKit.initKit();
this.list = list;
setSize(1024, 600);
this.abc = list.get(listIndex).abc;
getContentPane().setLayout(new BorderLayout());
decompiledTextArea = new DecompiledEditorPane();
decompiledScrollPane = new JScrollPane(decompiledTextArea);
detailPanel = new DetailPanel();
JPanel panB = new JPanel();
panB.setLayout(new BorderLayout());
panB.add(decompiledScrollPane, BorderLayout.CENTER);
panB.add(decLabel, BorderLayout.NORTH);
decLabel.setHorizontalAlignment(SwingConstants.CENTER);
decLabel.setBorder(new BevelBorder(BevelBorder.RAISED));
splitPane1 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
panB, detailPanel);
decompiledTextArea.setContentType("text/actionscript");
JPanel pan2 = new JPanel();
pan2.setLayout(new BorderLayout());
pan2.add((abcComboBox = new JComboBox(new ABCComboBoxModel(list))), BorderLayout.NORTH);
navigator = new TraitsList();
navigator.setABC(list, abc);
JPanel navPanel = new JPanel(new BorderLayout());
JLabel traitsLabel = new JLabel("Traits");
navPanel.add(traitsLabel, BorderLayout.NORTH);
traitsLabel.setBorder(new BevelBorder(BevelBorder.RAISED));
navPanel.add(new JScrollPane(navigator), BorderLayout.CENTER);
Main.startWork("Building script tree...");
filterField.setActionCommand("FILTERSCRIPT");
filterField.addActionListener(this);
filterField.getDocument().addDocumentListener(new DocumentListener() {
@Override
public void changedUpdate(DocumentEvent e) {
warn();
}
@Override
public void removeUpdate(DocumentEvent e) {
warn();
}
@Override
public void insertUpdate(DocumentEvent e) {
warn();
}
public void warn() {
doFilter();
}
});
JPanel treePanel = new JPanel();
treePanel.setLayout(new BorderLayout());
treePanel.add(new JScrollPane(classTree = new ClassesListTree(list)), BorderLayout.CENTER);
JPanel searchPanel = new JPanel();
searchPanel.setLayout(new BorderLayout());
searchPanel.add(filterField, BorderLayout.CENTER);
JLabel picLabel = new JLabel(new ImageIcon(View.loadImage("com/jpexs/asdec/gui/graphics/search.png")));
searchPanel.add(picLabel, BorderLayout.EAST);
treePanel.add(searchPanel, BorderLayout.NORTH);
splitPane2 = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
treePanel,
navPanel);
Main.startWork("Creating window...");
JTabbedPane tabbedPane = new JTabbedPane();
tabbedPane.addTab("Scripts", splitPane2);
pan2.add(tabbedPane, BorderLayout.CENTER);
abcComboBox.addItemListener(this);
splitPane3 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
pan2,
splitPane1);
pan2.setPreferredSize(new Dimension(300, 200));
loadingPanel.setPreferredSize(new Dimension(30, 30));
statusPanel = new JPanel();
statusPanel.setPreferredSize(new Dimension(1, 30));
statusPanel.setBorder(new BevelBorder(BevelBorder.LOWERED));
statusPanel.setLayout(new BorderLayout());
statusPanel.add(loadingPanel, BorderLayout.WEST);
statusPanel.add(statusLabel, BorderLayout.CENTER);
loadingPanel.setVisible(false);
getContentPane().add(splitPane3, BorderLayout.CENTER);
getContentPane().add(statusPanel, BorderLayout.SOUTH);
addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
if (Main.proxyFrame != null) {
if (Main.proxyFrame.isVisible()) {
return;
}
}
Main.exit();
}
});
setTitle(Main.applicationName + " - " + Main.getFileTitle());
JMenuBar menuBar = new JMenuBar();
JMenu menuFile = new JMenu("File");
JMenuItem miOpen = new JMenuItem("Open...");
miOpen.setIcon(new ImageIcon(View.loadImage("com/jpexs/asdec/gui/graphics/open16.png")));
miOpen.setActionCommand("OPEN");
miOpen.addActionListener(this);
JMenuItem miSave = new JMenuItem("Save");
miSave.setIcon(new ImageIcon(View.loadImage("com/jpexs/asdec/gui/graphics/save16.png")));
miSave.setActionCommand("SAVE");
miSave.addActionListener(this);
JMenuItem miSaveAs = new JMenuItem("Save as...");
miSaveAs.setIcon(new ImageIcon(View.loadImage("com/jpexs/asdec/gui/graphics/save16.png")));
miSaveAs.setActionCommand("SAVEAS");
miSaveAs.addActionListener(this);
JMenu menuExportAll = new JMenu("Export all");
JMenuItem miExportAllAS = new JMenuItem("ActionScript...");
miExportAllAS.setIcon(new ImageIcon(View.loadImage("com/jpexs/asdec/gui/graphics/exportas16.png")));
miExportAllAS.setActionCommand("EXPORT");
miExportAllAS.addActionListener(this);
JMenuItem miExportAllPCode = new JMenuItem("PCode...");
miExportAllPCode.setIcon(new ImageIcon(View.loadImage("com/jpexs/asdec/gui/graphics/exportpc16.png")));
miExportAllPCode.setActionCommand("EXPORTPCODE");
miExportAllPCode.addActionListener(this);
menuExportAll.add(miExportAllAS);
menuExportAll.add(miExportAllPCode);
JMenu menuExportSel = new JMenu("Export selection");
JMenuItem miExportSelAS = new JMenuItem("ActionScript...");
miExportSelAS.setIcon(new ImageIcon(View.loadImage("com/jpexs/asdec/gui/graphics/exportas16.png")));
miExportSelAS.setActionCommand("EXPORTSEL");
miExportSelAS.addActionListener(this);
JMenuItem miExportSelPCode = new JMenuItem("PCode...");
miExportSelPCode.setIcon(new ImageIcon(View.loadImage("com/jpexs/asdec/gui/graphics/exportpc16.png")));
miExportSelPCode.setActionCommand("EXPORTPCODESEL");
miExportSelPCode.addActionListener(this);
menuExportSel.add(miExportSelAS);
menuExportSel.add(miExportSelPCode);
menuFile.add(miOpen);
menuFile.add(miSave);
menuFile.add(miSaveAs);
menuFile.add(menuExportAll);
menuFile.add(menuExportSel);
menuFile.addSeparator();
JMenuItem miClose = new JMenuItem("Exit");
miClose.setIcon(new ImageIcon(View.loadImage("com/jpexs/asdec/gui/graphics/exit16.png")));
miClose.setActionCommand("EXIT");
miClose.addActionListener(this);
menuFile.add(miClose);
menuBar.add(menuFile);
JMenu menuDeobfuscation = new JMenu("Deobfuscation");
JCheckBoxMenuItem miSubLimiter = new JCheckBoxMenuItem("Enable sub limiter");
miSubLimiter.setActionCommand("SUBLIMITER");
miSubLimiter.addActionListener(this);
JMenuItem miRenameIdentifiers = new JMenuItem("Rename identifiers");
miRenameIdentifiers.setActionCommand("RENAMEIDENTIFIERS");
miRenameIdentifiers.addActionListener(this);
menuDeobfuscation.add(miSubLimiter);
menuDeobfuscation.add(miRenameIdentifiers);
//menuBar.add(menuOptions);
JMenu menuTools = new JMenu("Tools");
JMenuItem miProxy = new JMenuItem("Proxy");
miProxy.setActionCommand("SHOWPROXY");
miProxy.setIcon(new ImageIcon(View.loadImage("com/jpexs/asdec/gui/graphics/proxy16.png")));
miProxy.addActionListener(this);
menuTools.add(miProxy);
menuTools.add(menuDeobfuscation);
menuBar.add(menuTools);
JMenu menuHelp = new JMenu("Help");
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);
JPanel panConstants = new JPanel();
panConstants.setLayout(new BorderLayout());
constantTypeList = new JComboBox(new String[]{"UINT", "INT", "DOUBLE", "DECIMAL", "STRING", "NAMESPACE", "NAMESPACESET", "MULTINAME"});
constantTable = new JTable();
autoResizeColWidth(constantTable, new UIntTableModel(abc));
constantTable.setAutoCreateRowSorter(true);
final List<DoABCTag> inlist = list;
constantTable.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 2) {
if (constantTypeList.getSelectedIndex() == 7) { //MULTINAME
int rowIndex = constantTable.getSelectedRow();
if (rowIndex == -1) {
return;
}
int multinameIndex = constantTable.convertRowIndexToModel(rowIndex);
if (multinameIndex > 0) {
UsageFrame usageFrame = new UsageFrame(inlist, abc, multinameIndex);
usageFrame.setVisible(true);
}
}
}
}
});
constantTypeList.addItemListener(this);
panConstants.add(constantTypeList, BorderLayout.NORTH);
panConstants.add(new JScrollPane(constantTable), BorderLayout.CENTER);
tabbedPane.addTab("Constants", panConstants);
View.centerScreen(this);
Main.stopWork();
}
private void doFilter() {
classTree.applyFilter(filterField.getText());
}
public void actionPerformed(ActionEvent e) {
if (e.getActionCommand().equals("FILTERSCRIPT")) {
doFilter();
}
if (e.getActionCommand().equals("EXIT")) {
setVisible(false);
if (Main.proxyFrame != null) {
if (Main.proxyFrame.isVisible()) {
return;
}
}
Main.exit();
}
if (Main.isWorking()) {
return;
}
if (e.getActionCommand().equals("ABOUT")) {
Main.about();
}
if (e.getActionCommand().equals("SHOWPROXY")) {
Main.showProxy();
}
if (e.getActionCommand().equals("SUBLIMITER")) {
if (e.getSource() instanceof JCheckBoxMenuItem) {
Main.setSubLimiter(((JCheckBoxMenuItem) e.getSource()).getState());
}
}
if (e.getActionCommand().equals("SAVE")) {
try {
Main.saveFile(Main.file);
} catch (IOException ex) {
Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex);
JOptionPane.showMessageDialog(null, "Cannot save file", "Error", JOptionPane.ERROR_MESSAGE);
}
}
if (e.getActionCommand().equals("SAVEAS")) {
if (Main.saveFileDialog()) {
setTitle(Main.applicationName + " - " + Main.getFileTitle());
}
}
if (e.getActionCommand().equals("OPEN")) {
Main.openFileDialog();
}
if (e.getActionCommand().startsWith("EXPORT")) {
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().startsWith("EXPORTPCODE");
final boolean onlySel = e.getActionCommand().endsWith("SEL");
(new Thread() {
@Override
public void run() {
try {
if (onlySel) {
List<TreeLeafScript> tlsList = classTree.getSelectedScripts();
if (tlsList.isEmpty()) {
JOptionPane.showMessageDialog(null, "No script selected!");
}
for (int i = 0; i < tlsList.size(); i++) {
TreeLeafScript tls = tlsList.get(i);
Main.startWork("Exporting " + (i + 1) + "/" + tlsList.size() + " " + tls.abc.script_info[tls.scriptIndex].getPath(tls.abc) + " ...");
tls.abc.script_info[tls.scriptIndex].export(tls.abc, list, selFile, isPcode);
}
} else {
Main.swf.exportActionScript(selFile, isPcode);
}
} catch (Exception ignored) {
JOptionPane.showMessageDialog(null, "Cannot write to the file");
}
Main.stopWork();
}
}).start();
}
}
if (e.getActionCommand().equals("CHECKUPDATES")) {
if (!Main.checkForUpdates()) {
JOptionPane.showMessageDialog(null, "No new version available.");
}
}
if (e.getActionCommand().equals("RENAMEIDENTIFIERS")) {
if (JOptionPane.showConfirmDialog(null, "Following procedure can damage SWF file which can be then unplayable.\r\nUSE IT ON YOUR OWN RISK. Do you want to continue?", "Warning", JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.OK_OPTION) {
int pocet = 0;
Main.startWork("Renaming identifiers...");
for (DoABCTag tag : list) {
pocet += tag.abc.deobfuscateIdentifiers();
}
JOptionPane.showMessageDialog(null, "Identifiers renamed: " + pocet);
reload();
Main.stopWork();
}
}
}
public void reload() {
switchAbc(listIndex - 1);
}
public void itemStateChanged(ItemEvent e) {
if (e.getSource() == abcComboBox) {
int index = ((JComboBox) e.getSource()).getSelectedIndex();
if (index == -1) {
return;
}
switchAbc(index - 1);
}
if (e.getSource() == constantTypeList) {
int index = ((JComboBox) e.getSource()).getSelectedIndex();
if (index == -1) {
return;
}
updateConstList();
}
}
public void display() {
setVisible(true);
splitPane2.setDividerLocation(0.5);
splitPane1.setDividerLocation(0.5);
}
}

View File

@@ -100,7 +100,7 @@ public class MethodBodyParamsPanel extends JPanel implements ChangeListener {
body.max_regs = Integer.parseInt(localCountField.getText());
body.max_scope_depth = Integer.parseInt(maxScopeDepthField.getText());
} else {
if (!body.autoFillStats(Main.abcMainFrame.abc)) {
if (!body.autoFillStats(Main.mainFrame.abcPanel.abc)) {
JOptionPane.showMessageDialog(null, "Cannot get code stats for automatic body params.\r\nUncheck autofill to avoid this message.", "Warning", JOptionPane.WARNING_MESSAGE);
}
}

View File

@@ -74,7 +74,7 @@ public class MethodCodePanel extends JPanel implements ActionListener {
sourceTextArea.exec();
}
if (e.getActionCommand().equals("VERIFYBODY")) {
sourceTextArea.verify(Main.abcMainFrame.abc.constants, Main.abcMainFrame.abc);
sourceTextArea.verify(Main.mainFrame.abcPanel.abc.constants, Main.mainFrame.abcPanel.abc);
}
}
}

View File

@@ -44,7 +44,7 @@ public class MethodTraitDetailPanel extends JTabbedPane implements TraitDetail {
if (!methodInfoPanel.save()) {
return false;
}
if (!methodCodePanel.sourceTextArea.save(Main.abcMainFrame.abc.constants)) {
if (!methodCodePanel.sourceTextArea.save(Main.mainFrame.abcPanel.abc.constants)) {
return false;
}
if (!methodBodyParamsPanel.save()) {

View File

@@ -62,7 +62,7 @@ public class TraitsList extends JList implements ListSelectionListener {
int index = getSelectedIndex();
Main.abcMainFrame.decompiledTextArea.gotoTrait(index);
Main.mainFrame.abcPanel.decompiledTextArea.gotoTrait(index);
}
}

View File

@@ -79,7 +79,7 @@ public class UsageFrame extends JFrame implements ActionListener, MouseListener
MultinameUsage usage = usageListModel.getUsage(usageList.getSelectedIndex());
if (usage instanceof InsideClassMultinameUsage) {
InsideClassMultinameUsage icu = (InsideClassMultinameUsage) usage;
Main.abcMainFrame.classTree.selectClass(icu.classIndex);
Main.mainFrame.abcPanel.classTree.selectClass(icu.classIndex);
try {
Thread.sleep(100);
} catch (InterruptedException ex) {
@@ -101,7 +101,7 @@ public class UsageFrame extends JFrame implements ActionListener, MouseListener
traitIndex = abc.class_info[mmu.classIndex].static_traits.traits.length + abc.instance_info[mmu.classIndex].instance_traits.traits.length + (mmu.isStatic ? 1 : 0);
}
}
Main.abcMainFrame.decompiledTextArea.gotoTrait(traitIndex);
Main.mainFrame.abcPanel.decompiledTextArea.gotoTrait(traitIndex);
}
}
}

View File

@@ -40,6 +40,9 @@ public class DecimalTableModel implements TableModel {
* @see #getColumnCount
*/
public int getRowCount() {
if(abc==null){
return 0;
}
return abc.constants.constant_decimal.length;
}

View File

@@ -40,6 +40,9 @@ public class DoubleTableModel implements TableModel {
* @see #getColumnCount
*/
public int getRowCount() {
if(abc==null){
return 0;
}
return abc.constants.constant_double.length;
}

View File

@@ -40,6 +40,9 @@ public class IntTableModel implements TableModel {
* @see #getColumnCount
*/
public int getRowCount() {
if(abc==null){
return 0;
}
return abc.constants.constant_int.length;
}

View File

@@ -41,6 +41,9 @@ public class MultinameTableModel implements TableModel {
* @see #getColumnCount
*/
public int getRowCount() {
if(abc==null){
return 0;
}
return abc.constants.constant_multiname.length;
}

View File

@@ -40,6 +40,9 @@ public class NamespaceSetTableModel implements TableModel {
* @see #getColumnCount
*/
public int getRowCount() {
if(abc==null){
return 0;
}
return abc.constants.constant_namespace_set.length;
}

View File

@@ -40,6 +40,9 @@ public class NamespaceTableModel implements TableModel {
* @see #getColumnCount
*/
public int getRowCount() {
if(abc==null){
return 0;
}
return abc.constants.constant_namespace.length;
}

View File

@@ -40,6 +40,9 @@ public class StringTableModel implements TableModel {
* @see #getColumnCount
*/
public int getRowCount() {
if(abc==null){
return 0;
}
return abc.constants.constant_string.length;
}

View File

@@ -40,6 +40,9 @@ public class UIntTableModel implements TableModel {
* @see #getColumnCount
*/
public int getRowCount() {
if(abc==null){
return 0;
}
return abc.constants.constant_uint.length;
}

View File

@@ -0,0 +1,175 @@
/*
* Copyright (C) 2010-2011 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.asdec.action.gui;
import com.jpexs.asdec.Configuration;
import com.jpexs.asdec.Main;
import com.jpexs.asdec.SWF;
import com.jpexs.asdec.action.TagNode;
import com.jpexs.asdec.action.parser.ASMParser;
import com.jpexs.asdec.action.parser.ParseException;
import com.jpexs.asdec.gui.LoadingPanel;
import com.jpexs.asdec.gui.View;
import com.jpexs.asdec.helpers.Highlighting;
import com.jpexs.asdec.tags.Tag;
import com.jpexs.asdec.tags.base.ASMSource;
import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.ByteArrayInputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.List;
import javax.swing.*;
import javax.swing.border.BevelBorder;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import javax.swing.tree.DefaultTreeCellRenderer;
import jsyntaxpane.DefaultSyntaxKit;
public class ActionPanel extends JPanel implements TreeSelectionListener, ActionListener {
public JTree tagTree;
public JEditorPane editor;
public JEditorPane decompiledEditor;
public List<Tag> list;
public JSplitPane splitPane;
public JSplitPane splitPane2;
public JButton saveButton = new JButton("Save");
public JButton saveHexButton = new JButton("Save hex");
public JButton loadHexButton = new JButton("Load hex");
public JLabel asmLabel = new JLabel("P-code source (editable)");
public JLabel decLabel = new JLabel("ActionScript source");
public ActionPanel(List<Tag> list) {
this.list = list;
DefaultSyntaxKit.initKit();
editor = new JEditorPane();
decompiledEditor = new JEditorPane();
tagTree = new JTree(new TagTreeModel(list));
DefaultTreeCellRenderer treeRenderer = new DefaultTreeCellRenderer();
ClassLoader cldr = this.getClass().getClassLoader();
java.net.URL imageURL = cldr.getResource("com/jpexs/asdec/action/gui/graphics/class.png");
ImageIcon leafIcon = new ImageIcon(imageURL);
treeRenderer.setLeafIcon(leafIcon);
tagTree.setCellRenderer(treeRenderer);
JPanel panB = new JPanel();
panB.setLayout(new BorderLayout());
asmLabel.setHorizontalAlignment(SwingConstants.CENTER);
asmLabel.setBorder(new BevelBorder(BevelBorder.RAISED));
panB.add(asmLabel, BorderLayout.NORTH);
panB.add(new JScrollPane(editor), BorderLayout.CENTER);
JPanel buttonsPan = new JPanel();
buttonsPan.setLayout(new FlowLayout());
buttonsPan.add(saveButton);
//buttonsPan.add(saveHexButton);
//buttonsPan.add(loadHexButton);
panB.add(buttonsPan, BorderLayout.SOUTH);
saveHexButton.addActionListener(this);
saveHexButton.setActionCommand("SAVEHEXACTION");
loadHexButton.addActionListener(this);
loadHexButton.setActionCommand("LOADHEXACTION");
saveButton.addActionListener(this);
saveButton.setActionCommand("SAVEACTION");
JPanel panA = new JPanel();
panA.setLayout(new BorderLayout());
panA.add(new JScrollPane(decompiledEditor), BorderLayout.CENTER);
panA.add(decLabel, BorderLayout.NORTH);
decLabel.setHorizontalAlignment(SwingConstants.CENTER);
decLabel.setBorder(new BevelBorder(BevelBorder.RAISED));
setLayout(new BorderLayout());
add(splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(tagTree), splitPane2 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, panA, panB)), BorderLayout.CENTER);
editor.setContentType("text/flasm");
decompiledEditor.setContentType("text/actionscript");
tagTree.addTreeSelectionListener(this);
}
public void initSplits(){
splitPane.setDividerLocation(getWidth()/3);
splitPane2.setDividerLocation(getWidth()/3);
}
public void valueChanged(TreeSelectionEvent e) {
if (Main.isWorking()) {
return;
}
Object obj = tagTree.getLastSelectedPathComponent();
if (obj instanceof TagNode) {
obj = ((TagNode) obj).tag;
if (obj instanceof ASMSource) {
Main.startWork("Decompiling...");
final ASMSource asm = (ASMSource) obj;
(new Thread() {
@Override
public void run() {
editor.setText(asm.getASMSource(SWF.DEFAULT_VERSION));
if (Main.DO_DECOMPILE) {
List<com.jpexs.asdec.action.Action> as = asm.getActions(SWF.DEFAULT_VERSION);
com.jpexs.asdec.action.Action.setActionsAddresses(as, 0, SWF.DEFAULT_VERSION);
decompiledEditor.setText(Highlighting.stripHilights(com.jpexs.asdec.action.Action.actionsToSource(as, SWF.DEFAULT_VERSION)));
}
Main.stopWork();
}
}).start();
}
}
}
public void display() {
setVisible(true);
splitPane.setDividerLocation(0.5);
splitPane2.setDividerLocation(0.5);
}
public void actionPerformed(ActionEvent e) {
if (e.getActionCommand().equals("SAVEACTION")) {
TagNode ti = (TagNode) tagTree.getLastSelectedPathComponent();
if (ti.tag instanceof ASMSource) {
ASMSource dat = (ASMSource) ti.tag;
try {
dat.setActions(ASMParser.parse(new ByteArrayInputStream(editor.getText().getBytes()), SWF.DEFAULT_VERSION), SWF.DEFAULT_VERSION);
valueChanged(null);
JOptionPane.showMessageDialog(this, "Code successfully saved");
} catch (IOException ex) {
} catch (ParseException ex) {
JOptionPane.showMessageDialog(this, "" + ex.text + " on line " + ex.line, "Error", JOptionPane.ERROR_MESSAGE);
}
}
}
}
}

View File

@@ -1,359 +0,0 @@
/*
* Copyright (C) 2010-2011 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.asdec.action.gui;
import com.jpexs.asdec.Configuration;
import com.jpexs.asdec.Main;
import com.jpexs.asdec.SWF;
import com.jpexs.asdec.action.TagNode;
import com.jpexs.asdec.action.parser.ASMParser;
import com.jpexs.asdec.action.parser.ParseException;
import com.jpexs.asdec.gui.LoadingPanel;
import com.jpexs.asdec.gui.View;
import com.jpexs.asdec.helpers.Highlighting;
import com.jpexs.asdec.tags.Tag;
import com.jpexs.asdec.tags.base.ASMSource;
import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.ByteArrayInputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.List;
import javax.swing.*;
import javax.swing.border.BevelBorder;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import javax.swing.tree.DefaultTreeCellRenderer;
import jsyntaxpane.DefaultSyntaxKit;
public class MainFrame extends JFrame implements TreeSelectionListener, ActionListener {
public JTree tagTree;
public JEditorPane editor;
public JEditorPane decompiledEditor;
public List<Tag> list;
public JSplitPane splitPane;
public JSplitPane splitPane2;
public JButton saveButton = new JButton("Save");
public JButton saveHexButton = new JButton("Save hex");
public JButton loadHexButton = new JButton("Load hex");
public JLabel asmLabel = new JLabel("P-code source (editable)");
public JLabel decLabel = new JLabel("ActionScript source");
public JPanel statusPanel = new JPanel();
public LoadingPanel loadingPanel = new LoadingPanel(20, 20);
public JLabel statusLabel = new JLabel("");
public MainFrame(List<Tag> list) {
this.list = list;
DefaultSyntaxKit.initKit();
editor = new JEditorPane();
decompiledEditor = new JEditorPane();
tagTree = new JTree(new TagTreeModel(list));
DefaultTreeCellRenderer treeRenderer = new DefaultTreeCellRenderer();
ClassLoader cldr = this.getClass().getClassLoader();
java.net.URL imageURL = cldr.getResource("com/jpexs/asdec/action/gui/graphics/class.png");
ImageIcon leafIcon = new ImageIcon(imageURL);
treeRenderer.setLeafIcon(leafIcon);
tagTree.setCellRenderer(treeRenderer);
JPanel panB = new JPanel();
panB.setLayout(new BorderLayout());
asmLabel.setHorizontalAlignment(SwingConstants.CENTER);
asmLabel.setBorder(new BevelBorder(BevelBorder.RAISED));
panB.add(asmLabel, BorderLayout.NORTH);
panB.add(new JScrollPane(editor), BorderLayout.CENTER);
JPanel buttonsPan = new JPanel();
buttonsPan.setLayout(new FlowLayout());
buttonsPan.add(saveButton);
//buttonsPan.add(saveHexButton);
//buttonsPan.add(loadHexButton);
panB.add(buttonsPan, BorderLayout.SOUTH);
saveHexButton.addActionListener(this);
saveHexButton.setActionCommand("SAVEHEXACTION");
loadHexButton.addActionListener(this);
loadHexButton.setActionCommand("LOADHEXACTION");
saveButton.addActionListener(this);
saveButton.setActionCommand("SAVEACTION");
JPanel panA = new JPanel();
panA.setLayout(new BorderLayout());
panA.add(new JScrollPane(decompiledEditor), BorderLayout.CENTER);
panA.add(decLabel, BorderLayout.NORTH);
decLabel.setHorizontalAlignment(SwingConstants.CENTER);
decLabel.setBorder(new BevelBorder(BevelBorder.RAISED));
loadingPanel.setPreferredSize(new Dimension(30, 30));
statusPanel = new JPanel();
statusPanel.setPreferredSize(new Dimension(1, 30));
statusPanel.setBorder(new BevelBorder(BevelBorder.LOWERED));
statusPanel.setLayout(new BorderLayout());
statusPanel.add(loadingPanel, BorderLayout.WEST);
statusPanel.add(statusLabel, BorderLayout.CENTER);
loadingPanel.setVisible(false);
Container cont = getContentPane();
cont.setLayout(new BorderLayout());
cont.add(splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(tagTree), splitPane2 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, panA, panB)), BorderLayout.CENTER);
cont.add(statusPanel, BorderLayout.SOUTH);
editor.setContentType("text/flasm");
decompiledEditor.setContentType("text/actionscript");
setSize(640, 480);
tagTree.addTreeSelectionListener(this);
addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
if (Main.proxyFrame != null) {
if (Main.proxyFrame.isVisible()) {
return;
}
}
Main.exit();
}
});
View.setWindowIcon(this);
View.centerScreen(this);
JMenuBar menuBar = new JMenuBar();
JMenu menuFile = new JMenu("File");
JMenuItem miOpen = new JMenuItem("Open...");
miOpen.setIcon(new ImageIcon(View.loadImage("com/jpexs/asdec/gui/graphics/open16.png")));
miOpen.setActionCommand("OPEN");
miOpen.addActionListener(this);
JMenuItem miSave = new JMenuItem("Save");
miSave.setIcon(new ImageIcon(View.loadImage("com/jpexs/asdec/gui/graphics/save16.png")));
miSave.setActionCommand("SAVE");
miSave.addActionListener(this);
JMenuItem miSaveAs = new JMenuItem("Save as...");
miSaveAs.setIcon(new ImageIcon(View.loadImage("com/jpexs/asdec/gui/graphics/save16.png")));
miSaveAs.setActionCommand("SAVEAS");
miSaveAs.addActionListener(this);
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(miExportPCode);
menuFile.addSeparator();
JMenuItem miClose = new JMenuItem("Exit");
miClose.setIcon(new ImageIcon(View.loadImage("com/jpexs/asdec/gui/graphics/exit16.png")));
miClose.setActionCommand("EXIT");
miClose.addActionListener(this);
menuFile.add(miClose);
menuBar.add(menuFile);
JMenu menuTools = new JMenu("Tools");
JMenuItem miProxy = new JMenuItem("Proxy");
miProxy.setActionCommand("SHOWPROXY");
miProxy.setIcon(new ImageIcon(View.loadImage("com/jpexs/asdec/gui/graphics/proxy16.png")));
miProxy.addActionListener(this);
menuTools.add(miProxy);
menuBar.add(menuTools);
JMenu menuHelp = new JMenu("Help");
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);
setTitle(Main.applicationName + " - " + Main.getFileTitle());
Main.stopWork();
}
public void valueChanged(TreeSelectionEvent e) {
if (Main.isWorking()) {
return;
}
Object obj = tagTree.getLastSelectedPathComponent();
if (obj instanceof TagNode) {
obj = ((TagNode) obj).tag;
if (obj instanceof ASMSource) {
Main.startWork("Decompiling...");
final ASMSource asm = (ASMSource) obj;
(new Thread() {
@Override
public void run() {
editor.setText(asm.getASMSource(SWF.DEFAULT_VERSION));
if (Main.DO_DECOMPILE) {
List<com.jpexs.asdec.action.Action> as = asm.getActions(SWF.DEFAULT_VERSION);
com.jpexs.asdec.action.Action.setActionsAddresses(as, 0, SWF.DEFAULT_VERSION);
decompiledEditor.setText(Highlighting.stripHilights(com.jpexs.asdec.action.Action.actionsToSource(as, SWF.DEFAULT_VERSION)));
}
Main.stopWork();
}
}).start();
}
}
}
public void display() {
setVisible(true);
splitPane.setDividerLocation(0.5);
splitPane2.setDividerLocation(0.5);
}
public void actionPerformed(ActionEvent e) {
if (e.getActionCommand().equals("EXIT")) {
System.exit(0);
}
if (e.getActionCommand().equals("ABOUT")) {
Main.about();
}
if (e.getActionCommand().equals("SHOWPROXY")) {
Main.showProxy();
}
if (Main.isWorking()) {
return;
}
if (e.getActionCommand().equals("SAVEHEXACTION")) {
TagNode ti = (TagNode) tagTree.getLastSelectedPathComponent();
if (ti.tag instanceof ASMSource) {
ASMSource dat = (ASMSource) ti.tag;
FileOutputStream fos;
try {
fos = new FileOutputStream("out.hex");
fos.write(dat.getActionBytes());
fos.close();
} catch (IOException ex) {
}
}
}
if (e.getActionCommand().equals("LOADHEXACTION")) {
TagNode ti = (TagNode) tagTree.getLastSelectedPathComponent();
if (ti.tag instanceof ASMSource) {
ASMSource dat = (ASMSource) ti.tag;
FileInputStream fis;
try {
fis = new FileInputStream("out.hex");
byte data[] = new byte[fis.available()];
dat.setActionBytes(data);
fis.read(data);
fis.close();
editor.setText(dat.getASMSource(SWF.DEFAULT_VERSION));
} catch (IOException ex) {
}
}
}
if (e.getActionCommand().equals("SAVEACTION")) {
TagNode ti = (TagNode) tagTree.getLastSelectedPathComponent();
if (ti.tag instanceof ASMSource) {
ASMSource dat = (ASMSource) ti.tag;
try {
dat.setActions(ASMParser.parse(new ByteArrayInputStream(editor.getText().getBytes()), SWF.DEFAULT_VERSION), SWF.DEFAULT_VERSION);
valueChanged(null);
JOptionPane.showMessageDialog(this, "Code successfully saved");
} catch (IOException ex) {
} catch (ParseException ex) {
JOptionPane.showMessageDialog(this, "" + ex.text + " on line " + ex.line, "Error", JOptionPane.ERROR_MESSAGE);
}
}
}
if (e.getActionCommand().equals("SAVE")) {
try {
Main.saveFile(Main.file);
} catch (IOException ex) {
}
}
if (e.getActionCommand().equals("SAVEAS")) {
if (Main.saveFileDialog()) {
setTitle(Main.applicationName + " - " + Main.getFileTitle());
}
}
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 {
Main.swf.exportActionScript(selFile, isPcode);
} catch (Exception ignored) {
JOptionPane.showMessageDialog(null, "Cannot write to the file");
}
Main.stopWork();
}
}).start();
}
}
}
public void setStatus(String s) {
if (s.equals("")) {
loadingPanel.setVisible(false);
} else {
loadingPanel.setVisible(true);
}
statusLabel.setText(s);
}
}

View File

@@ -1,134 +0,0 @@
package com.jpexs.asdec.gui;
import java.awt.Canvas;
import java.awt.Dimension;
import org.eclipse.swt.SWT;
import org.eclipse.swt.awt.SWT_AWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.ole.win32.OleAutomation;
import org.eclipse.swt.ole.win32.OleClientSite;
import org.eclipse.swt.ole.win32.OleFrame;
import org.eclipse.swt.ole.win32.Variant;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class FlashPanel extends Canvas {
private Thread swtThread;
private OleFrame oleFrame;
private OleClientSite clientSite;
private Shell shell;
private int width;
private int height;
public FlashPanel(int width, int height) {
setPreferredSize(new Dimension(width, height));
this.width = width;
this.height = height;
}
private void disposeClient() {
if (clientSite != null) {
clientSite.dispose();
}
clientSite = null;
}
public void dispose() {
oleFrame.getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
shell.dispose();
}
});
disconnect();
}
private void startDisplay() {
if (this.swtThread == null) {
final Canvas canvas = this;
this.swtThread = new Thread() {
@Override
public void run() {
try {
Display display = new Display();
shell = SWT_AWT.new_Shell(display, canvas);
shell.setLayout(new FillLayout());
synchronized (this) {
oleFrame = new OleFrame(shell, SWT.NONE);
clientSite = new OleClientSite(oleFrame, SWT.NONE, "Shell.Explorer");
this.notifyAll();
}
shell.open();
while (!isInterrupted() && !shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
shell.dispose();
display.dispose();
} catch (Exception e) {
interrupt();
}
}
};
this.swtThread.start();
}
synchronized (this.swtThread) {
while (this.oleFrame == null) {
try {
this.swtThread.wait(100);
} catch (InterruptedException e) {
this.oleFrame = null;
this.swtThread = null;
break;
}
}
}
setSize(getWidth() - 1, getHeight() - 1);
setSize(getWidth() + 1, getHeight() + 1);
}
public void displaySWF(String swf) {
startDisplay();
final String loadSWF = swf;
oleFrame.getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
OleAutomation explorer = new OleAutomation(clientSite);
int[] navigate = explorer.getIDsOfNames(new String[]{"Navigate"});
if (navigate != null) {
Variant result = explorer.invoke(navigate[0], new Variant[]{new Variant(loadSWF)});
if (result == null) {
disposeClient();
} else {
result.dispose();
}
} else {
disposeClient();
}
}
});
}
/**
* Stops the swt background thread.
*/
private void disconnect() {
if (swtThread != null) {
oleFrame = null;
swtThread.interrupt();
swtThread = null;
}
}
}

View File

@@ -0,0 +1,49 @@
package com.jpexs.asdec.gui;
import java.awt.BorderLayout;
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.File;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;
/*
* Copyright (C) 2010-2011 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/>.
*/
public class ImagePanel extends JPanel {
public JLabel label=new JLabel();
public ImagePanel() {
super(new BorderLayout());
label.setHorizontalAlignment(JLabel.CENTER);
add(label,BorderLayout.CENTER);
}
public void setImage(byte data[]){
ImageIcon icon = new ImageIcon(data);
label.setIcon(icon);
}
public void setImage(Image image){
ImageIcon icon = new ImageIcon(image);
label.setIcon(icon);
}
}

View File

@@ -0,0 +1,673 @@
package com.jpexs.asdec.gui;
import com.jpexs.flashplayer.FlashPanel;
import com.jpexs.asdec.Configuration;
import com.jpexs.asdec.Main;
import com.jpexs.asdec.SWF;
import com.jpexs.asdec.SWFInputStream;
import com.jpexs.asdec.SWFOutputStream;
import com.jpexs.asdec.abc.gui.ABCPanel;
import com.jpexs.asdec.abc.gui.TreeLeafScript;
import com.jpexs.asdec.action.gui.ActionPanel;
import com.jpexs.asdec.tags.DefineBitsJPEG2Tag;
import com.jpexs.asdec.tags.DefineBitsJPEG3Tag;
import com.jpexs.asdec.tags.DefineBitsJPEG4Tag;
import com.jpexs.asdec.tags.DefineBitsLossless2Tag;
import com.jpexs.asdec.tags.DefineBitsLosslessTag;
import com.jpexs.asdec.tags.DefineBitsTag;
import com.jpexs.asdec.tags.DefineButton2Tag;
import com.jpexs.asdec.tags.DefineButtonTag;
import com.jpexs.asdec.tags.DefineEditTextTag;
import com.jpexs.asdec.tags.DefineFont2Tag;
import com.jpexs.asdec.tags.DefineFont3Tag;
import com.jpexs.asdec.tags.DefineFont4Tag;
import com.jpexs.asdec.tags.DefineFontTag;
import com.jpexs.asdec.tags.DefineMorphShape2Tag;
import com.jpexs.asdec.tags.DefineMorphShapeTag;
import com.jpexs.asdec.tags.DefineShape2Tag;
import com.jpexs.asdec.tags.DefineShape3Tag;
import com.jpexs.asdec.tags.DefineShape4Tag;
import com.jpexs.asdec.tags.DefineShapeTag;
import com.jpexs.asdec.tags.DefineSpriteTag;
import com.jpexs.asdec.tags.DefineText2Tag;
import com.jpexs.asdec.tags.DefineTextTag;
import com.jpexs.asdec.tags.DoABCTag;
import com.jpexs.asdec.tags.DoActionTag;
import com.jpexs.asdec.tags.DoInitActionTag;
import com.jpexs.asdec.tags.EndTag;
import com.jpexs.asdec.tags.ExportAssetsTag;
import com.jpexs.asdec.tags.PlaceObject2Tag;
import com.jpexs.asdec.tags.PlaceObject3Tag;
import com.jpexs.asdec.tags.PlaceObjectTag;
import com.jpexs.asdec.tags.RemoveObject2Tag;
import com.jpexs.asdec.tags.RemoveObjectTag;
import com.jpexs.asdec.tags.SetBackgroundColorTag;
import com.jpexs.asdec.tags.ShowFrameTag;
import com.jpexs.asdec.tags.Tag;
import com.jpexs.asdec.tags.base.ASMSource;
import com.jpexs.asdec.tags.base.BoundedTag;
import com.jpexs.asdec.tags.base.CharacterTag;
import com.jpexs.asdec.tags.base.Container;
import com.jpexs.asdec.tags.base.FontTag;
import com.jpexs.asdec.types.GLYPHENTRY;
import com.jpexs.asdec.types.MATRIX;
import com.jpexs.asdec.types.RECT;
import com.jpexs.asdec.types.RGB;
import com.jpexs.asdec.types.TEXTRECORD;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.ImageIcon;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTabbedPane;
import javax.swing.JTree;
import javax.swing.border.BevelBorder;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import com.jpexs.flashplayer.FlashPanel;
/**
*
* @author Jindra
*/
public class MainFrame extends JFrame implements ActionListener {
FlashPanel fPanel;
private SWF swf;
public ABCPanel abcPanel;
public ActionPanel actionPanel;
private JTabbedPane tabPane;
public LoadingPanel loadingPanel = new LoadingPanel(20, 20);
public JLabel statusLabel = new JLabel("");
public JPanel statusPanel = new JPanel();
public void setStatus(String s) {
if (s.equals("")) {
loadingPanel.setVisible(false);
} else {
loadingPanel.setVisible(true);
}
statusLabel.setText(s);
}
public MainFrame(SWF swf) {
setSize(1024, 768);
tabPane = new JTabbedPane();
View.setWindowIcon(this);
addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
if (Main.proxyFrame != null) {
if (Main.proxyFrame.isVisible()) {
return;
}
}
Main.exit();
}
});
setTitle(Main.applicationName + " - " + Main.getFileTitle());
JMenuBar menuBar = new JMenuBar();
JMenu menuFile = new JMenu("File");
JMenuItem miOpen = new JMenuItem("Open...");
miOpen.setIcon(new ImageIcon(View.loadImage("com/jpexs/asdec/gui/graphics/open16.png")));
miOpen.setActionCommand("OPEN");
miOpen.addActionListener(this);
JMenuItem miSave = new JMenuItem("Save");
miSave.setIcon(new ImageIcon(View.loadImage("com/jpexs/asdec/gui/graphics/save16.png")));
miSave.setActionCommand("SAVE");
miSave.addActionListener(this);
JMenuItem miSaveAs = new JMenuItem("Save as...");
miSaveAs.setIcon(new ImageIcon(View.loadImage("com/jpexs/asdec/gui/graphics/save16.png")));
miSaveAs.setActionCommand("SAVEAS");
miSaveAs.addActionListener(this);
JMenu menuExportAll = new JMenu("Export all");
JMenuItem miExportAllAS = new JMenuItem("ActionScript...");
miExportAllAS.setIcon(new ImageIcon(View.loadImage("com/jpexs/asdec/gui/graphics/exportas16.png")));
miExportAllAS.setActionCommand("EXPORT");
miExportAllAS.addActionListener(this);
JMenuItem miExportAllPCode = new JMenuItem("PCode...");
miExportAllPCode.setIcon(new ImageIcon(View.loadImage("com/jpexs/asdec/gui/graphics/exportpc16.png")));
miExportAllPCode.setActionCommand("EXPORTPCODE");
miExportAllPCode.addActionListener(this);
menuExportAll.add(miExportAllAS);
menuExportAll.add(miExportAllPCode);
JMenu menuExportSel = new JMenu("Export selection");
JMenuItem miExportSelAS = new JMenuItem("ActionScript...");
miExportSelAS.setIcon(new ImageIcon(View.loadImage("com/jpexs/asdec/gui/graphics/exportas16.png")));
miExportSelAS.setActionCommand("EXPORTSEL");
miExportSelAS.addActionListener(this);
JMenuItem miExportSelPCode = new JMenuItem("PCode...");
miExportSelPCode.setIcon(new ImageIcon(View.loadImage("com/jpexs/asdec/gui/graphics/exportpc16.png")));
miExportSelPCode.setActionCommand("EXPORTPCODESEL");
miExportSelPCode.addActionListener(this);
menuExportSel.add(miExportSelAS);
menuExportSel.add(miExportSelPCode);
menuFile.add(miOpen);
menuFile.add(miSave);
menuFile.add(miSaveAs);
menuFile.add(menuExportAll);
menuFile.add(menuExportSel);
menuFile.addSeparator();
JMenuItem miClose = new JMenuItem("Exit");
miClose.setIcon(new ImageIcon(View.loadImage("com/jpexs/asdec/gui/graphics/exit16.png")));
miClose.setActionCommand("EXIT");
miClose.addActionListener(this);
menuFile.add(miClose);
menuBar.add(menuFile);
JMenu menuDeobfuscation = new JMenu("Deobfuscation");
JCheckBoxMenuItem miSubLimiter = new JCheckBoxMenuItem("Enable sub limiter");
miSubLimiter.setActionCommand("SUBLIMITER");
miSubLimiter.addActionListener(this);
JMenuItem miRenameIdentifiers = new JMenuItem("Rename identifiers");
miRenameIdentifiers.setActionCommand("RENAMEIDENTIFIERS");
miRenameIdentifiers.addActionListener(this);
menuDeobfuscation.add(miSubLimiter);
menuDeobfuscation.add(miRenameIdentifiers);
JMenu menuTools = new JMenu("Tools");
JMenuItem miProxy = new JMenuItem("Proxy");
miProxy.setActionCommand("SHOWPROXY");
miProxy.setIcon(new ImageIcon(View.loadImage("com/jpexs/asdec/gui/graphics/proxy16.png")));
miProxy.addActionListener(this);
menuTools.add(miProxy);
menuTools.add(menuDeobfuscation);
menuBar.add(menuTools);
JMenu menuHelp = new JMenu("Help");
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);
setSize(800, 600);
List<Object> objs = new ArrayList<Object>();
objs.addAll(swf.tags);
this.swf = swf;
getContentPane().setLayout(new BorderLayout());
fPanel = new FlashPanel(400, 400);
List<Tag> shapes = new ArrayList<Tag>();
List<Tag> images = new ArrayList<Tag>();
List<Tag> morphShapes = new ArrayList<Tag>();
List<Tag> sprites = new ArrayList<Tag>();
List<Tag> fonts = new ArrayList<Tag>();
List<Tag> texts = new ArrayList<Tag>();
List<Tag> buttons = new ArrayList<Tag>();
List<DoABCTag> abcList = new ArrayList<DoABCTag>();
getShapes(objs, shapes);
getImages(objs, images);
getMorphShapes(objs, morphShapes);
getSprites(objs, sprites);
getFonts(objs, fonts);
getTexts(objs, texts);
getButtons(objs, buttons);
getActionScript3(objs, abcList);
getContentPane().add(tabPane, BorderLayout.CENTER);
if (!shapes.isEmpty()) {
tabPane.addTab("Shapes", new TagPanel(shapes, swf));
}
if (!morphShapes.isEmpty()) {
tabPane.addTab("MorphShapes", new TagPanel(morphShapes, swf));
}
if (!images.isEmpty()) {
tabPane.addTab("Images", new TagPanel(images, swf));
}
if (!sprites.isEmpty()) {
tabPane.addTab("Sprites", new TagPanel(sprites, swf));
}
if (!fonts.isEmpty()) {
tabPane.addTab("Fonts", new TagPanel(fonts, swf));
}
if (!texts.isEmpty()) {
tabPane.addTab("Texts", new TagPanel(texts, swf));
}
if (!buttons.isEmpty()) {
tabPane.addTab("Buttons", new TagPanel(buttons, swf));
}
/*tabPane.addTab("Tags", new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(tagTree), new JScrollPane(fPanel)));*/
tabPane.setTabPlacement(JTabbedPane.LEFT);
if (!abcList.isEmpty()) {
tabPane.addTab("ActionScript3", abcPanel = new ABCPanel(abcList));
} else {
actionPanel = new ActionPanel(swf.tags);
if(actionPanel.tagTree.getRowCount()>1){
tabPane.addTab("ActionScript",actionPanel);
}
}
addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
fPanel.dispose();
}
});
loadingPanel.setPreferredSize(new Dimension(30, 30));
statusPanel = new JPanel();
statusPanel.setPreferredSize(new Dimension(1, 30));
statusPanel.setBorder(new BevelBorder(BevelBorder.LOWERED));
statusPanel.setLayout(new BorderLayout());
statusPanel.add(loadingPanel, BorderLayout.WEST);
statusPanel.add(statusLabel, BorderLayout.CENTER);
loadingPanel.setVisible(false);
add(statusPanel, BorderLayout.SOUTH);
View.centerScreen(this);
Main.stopWork();
}
@Override
public void setVisible(boolean b) {
super.setVisible(b);
if (b) {
if (abcPanel != null) {
abcPanel.initSplits();
}
if (actionPanel != null) {
actionPanel.initSplits();
}
}
}
public static void getShapes(List<Object> list, List<Tag> shapes) {
for (Object t : list) {
if (t instanceof Container) {
getShapes(((Container) t).getSubItems(), shapes);
}
if ((t instanceof DefineShapeTag)
|| (t instanceof DefineShape2Tag)
|| (t instanceof DefineShape3Tag)
|| (t instanceof DefineShape4Tag)) {
shapes.add((Tag) t);
}
}
}
public static void getFonts(List<Object> list, List<Tag> fonts) {
for (Object t : list) {
if (t instanceof Container) {
getFonts(((Container) t).getSubItems(), fonts);
}
if ((t instanceof DefineFontTag)
|| (t instanceof DefineFont2Tag)
|| (t instanceof DefineFont3Tag)
|| (t instanceof DefineFont4Tag)) {
fonts.add((Tag) t);
}
}
}
public static void getActionScript3(List<Object> list, List<DoABCTag> actionScripts) {
for (Object t : list) {
if (t instanceof Container) {
getActionScript3(((Container) t).getSubItems(), actionScripts);
}
if (t instanceof DoABCTag) {
actionScripts.add((DoABCTag) t);
}
}
}
public static void getMorphShapes(List<Object> list, List<Tag> morphShapes) {
for (Object t : list) {
if (t instanceof Container) {
getMorphShapes(((Container) t).getSubItems(), morphShapes);
}
if ((t instanceof DefineMorphShapeTag) || (t instanceof DefineMorphShape2Tag)) {
morphShapes.add((Tag) t);
}
}
}
public static void getImages(List<Object> list, List<Tag> images) {
for (Object t : list) {
if (t instanceof Container) {
getImages(((Container) t).getSubItems(), images);
}
if ((t instanceof DefineBitsTag)
|| (t instanceof DefineBitsJPEG2Tag)
|| (t instanceof DefineBitsJPEG3Tag)
|| (t instanceof DefineBitsJPEG4Tag)
|| (t instanceof DefineBitsLosslessTag)
|| (t instanceof DefineBitsLossless2Tag)) {
images.add((Tag) t);
}
}
}
public static void getTexts(List<Object> list, List<Tag> texts) {
for (Object t : list) {
if (t instanceof Container) {
getTexts(((Container) t).getSubItems(), texts);
}
if ((t instanceof DefineTextTag)
|| (t instanceof DefineText2Tag)
|| (t instanceof DefineEditTextTag)) {
texts.add((Tag) t);
}
}
}
public static void getSprites(List<Object> list, List<Tag> sprites) {
for (Object t : list) {
if (t instanceof Container) {
getSprites(((Container) t).getSubItems(), sprites);
}
if (t instanceof DefineSpriteTag) {
sprites.add((Tag) t);
}
}
}
public static void getButtons(List<Object> list, List<Tag> buttons) {
for (Object t : list) {
if (t instanceof Container) {
getButtons(((Container) t).getSubItems(), buttons);
}
if ((t instanceof DefineButtonTag) || (t instanceof DefineButton2Tag)) {
buttons.add((Tag) t);
}
}
}
public static List<TagNode> createTagList(List<Object> list) {
List<TagNode> ret = new ArrayList<TagNode>();
int frame = 1;
List<TagNode> frames = new ArrayList<TagNode>();
List<TagNode> shapes = new ArrayList<TagNode>();
List<TagNode> morphShapes = new ArrayList<TagNode>();
List<TagNode> sprites = new ArrayList<TagNode>();
List<TagNode> buttons = new ArrayList<TagNode>();
List<TagNode> images = new ArrayList<TagNode>();
List<TagNode> fonts = new ArrayList<TagNode>();
List<TagNode> texts = new ArrayList<TagNode>();
List<ExportAssetsTag> exportAssetsTags = new ArrayList<ExportAssetsTag>();
for (Object 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));
}
if ((t instanceof DefineTextTag)
|| (t instanceof DefineText2Tag)
|| (t instanceof DefineEditTextTag)) {
texts.add(new TagNode(t));
}
if ((t instanceof DefineBitsTag)
|| (t instanceof DefineBitsJPEG2Tag)
|| (t instanceof DefineBitsJPEG3Tag)
|| (t instanceof DefineBitsJPEG4Tag)
|| (t instanceof DefineBitsLosslessTag)
|| (t instanceof DefineBitsLossless2Tag)) {
images.add(new TagNode(t));
}
if ((t instanceof DefineShapeTag)
|| (t instanceof DefineShape2Tag)
|| (t instanceof DefineShape3Tag)
|| (t instanceof DefineShape4Tag)) {
shapes.add(new TagNode(t));
}
if ((t instanceof DefineMorphShapeTag) || (t instanceof DefineMorphShape2Tag)) {
morphShapes.add(new TagNode(t));
}
if (t instanceof DefineSpriteTag) {
sprites.add(new TagNode(t));
}
if ((t instanceof DefineButtonTag) || (t instanceof DefineButton2Tag)) {
buttons.add(new TagNode(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);
} /*if (t instanceof ASMSource) {
TagNode tti = new TagNode(t);
ret.add(tti);
} else */
if (t instanceof Container) {
TagNode tti = new TagNode(t);
if (((Container) t).getItemCount() > 0) {
List<Object> subItems = ((Container) t).getSubItems();
tti.subItems = createTagList(subItems);
}
//ret.add(tti);
}
}
TagNode textsNode = new TagNode("texts");
textsNode.subItems.addAll(texts);
TagNode imagesNode = new TagNode("images");
imagesNode.subItems.addAll(images);
TagNode fontsNode = new TagNode("fonts");
fontsNode.subItems.addAll(fonts);
TagNode spritesNode = new TagNode("sprites");
spritesNode.subItems.addAll(sprites);
TagNode shapesNode = new TagNode("shapes");
shapesNode.subItems.addAll(shapes);
TagNode morphShapesNode = new TagNode("morphshapes");
morphShapesNode.subItems.addAll(morphShapes);
TagNode buttonsNode = new TagNode("buttons");
buttonsNode.subItems.addAll(buttons);
TagNode framesNode = new TagNode("frames");
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 void actionPerformed(ActionEvent e) {
if (e.getActionCommand().equals("EXIT")) {
setVisible(false);
if (Main.proxyFrame != null) {
if (Main.proxyFrame.isVisible()) {
return;
}
}
Main.exit();
}
if (Main.isWorking()) {
return;
}
if (e.getActionCommand().equals("ABOUT")) {
Main.about();
}
if (e.getActionCommand().equals("SHOWPROXY")) {
Main.showProxy();
}
if (e.getActionCommand().equals("SUBLIMITER")) {
if (e.getSource() instanceof JCheckBoxMenuItem) {
Main.setSubLimiter(((JCheckBoxMenuItem) e.getSource()).getState());
}
}
if (e.getActionCommand().equals("SAVE")) {
try {
Main.saveFile(Main.file);
} catch (IOException ex) {
Logger.getLogger(com.jpexs.asdec.abc.gui.ABCPanel.class.getName()).log(Level.SEVERE, null, ex);
JOptionPane.showMessageDialog(null, "Cannot save file", "Error", JOptionPane.ERROR_MESSAGE);
}
}
if (e.getActionCommand().equals("SAVEAS")) {
if (Main.saveFileDialog()) {
setTitle(Main.applicationName + " - " + Main.getFileTitle());
}
}
if (e.getActionCommand().equals("OPEN")) {
Main.openFileDialog();
}
if (e.getActionCommand().startsWith("EXPORT")) {
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().startsWith("EXPORTPCODE");
final boolean onlySel = e.getActionCommand().endsWith("SEL");
(new Thread() {
@Override
public void run() {
try {
if (onlySel) {
List<TreeLeafScript> tlsList = abcPanel.classTree.getSelectedScripts();
if (tlsList.isEmpty()) {
JOptionPane.showMessageDialog(null, "No script selected!");
}
for (int i = 0; i < tlsList.size(); i++) {
TreeLeafScript tls = tlsList.get(i);
Main.startWork("Exporting " + (i + 1) + "/" + tlsList.size() + " " + tls.abc.script_info[tls.scriptIndex].getPath(tls.abc) + " ...");
tls.abc.script_info[tls.scriptIndex].export(tls.abc, abcPanel.list, selFile, isPcode);
}
} else {
Main.swf.exportActionScript(selFile, isPcode);
}
} catch (Exception ignored) {
JOptionPane.showMessageDialog(null, "Cannot write to the file");
}
Main.stopWork();
}
}).start();
}
}
if (e.getActionCommand().equals("CHECKUPDATES")) {
if (!Main.checkForUpdates()) {
JOptionPane.showMessageDialog(null, "No new version available.");
}
}
if (e.getActionCommand().equals("RENAMEIDENTIFIERS")) {
if (JOptionPane.showConfirmDialog(null, "Following procedure can damage SWF file which can be then unplayable.\r\nUSE IT ON YOUR OWN RISK. Do you want to continue?", "Warning", JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.OK_OPTION) {
int pocet = 0;
Main.startWork("Renaming identifiers...");
for (DoABCTag tag : abcPanel.list) {
pocet += tag.abc.deobfuscateIdentifiers();
}
JOptionPane.showMessageDialog(null, "Identifiers renamed: " + pocet);
abcPanel.reload();
Main.stopWork();
}
}
}
}

View File

@@ -1,239 +0,0 @@
package com.jpexs.asdec.gui;
import com.jpexs.asdec.Main;
import com.jpexs.asdec.SWF;
import com.jpexs.asdec.SWFInputStream;
import com.jpexs.asdec.SWFOutputStream;
import com.jpexs.asdec.tags.DefineFont2Tag;
import com.jpexs.asdec.tags.DefineFont3Tag;
import com.jpexs.asdec.tags.DefineFontTag;
import com.jpexs.asdec.tags.DefineMorphShape2Tag;
import com.jpexs.asdec.tags.DefineMorphShapeTag;
import com.jpexs.asdec.tags.DefineShapeTag;
import com.jpexs.asdec.tags.DefineSpriteTag;
import com.jpexs.asdec.tags.DefineTextTag;
import com.jpexs.asdec.tags.DoActionTag;
import com.jpexs.asdec.tags.EndTag;
import com.jpexs.asdec.tags.PlaceObject2Tag;
import com.jpexs.asdec.tags.PlaceObject3Tag;
import com.jpexs.asdec.tags.PlaceObjectTag;
import com.jpexs.asdec.tags.RemoveObject2Tag;
import com.jpexs.asdec.tags.RemoveObjectTag;
import com.jpexs.asdec.tags.SetBackgroundColorTag;
import com.jpexs.asdec.tags.ShowFrameTag;
import com.jpexs.asdec.tags.Tag;
import com.jpexs.asdec.tags.base.BoundedTag;
import com.jpexs.asdec.tags.base.CharacterTag;
import com.jpexs.asdec.tags.base.Container;
import com.jpexs.asdec.tags.base.FontTag;
import com.jpexs.asdec.types.GLYPHENTRY;
import com.jpexs.asdec.types.MATRIX;
import com.jpexs.asdec.types.RECT;
import com.jpexs.asdec.types.RGB;
import com.jpexs.asdec.types.TEXTRECORD;
import java.awt.BorderLayout;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTree;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
/**
*
* @author Jindra
*/
public class TagBrowserFrame extends JFrame implements TreeSelectionListener {
JTree tagTree;
FlashPanel fPanel;
private SWF swf;
public TagBrowserFrame(SWF swf) {
setDefaultCloseOperation(EXIT_ON_CLOSE);
setSize(800, 600);
List<Object> objs = new ArrayList<Object>();
objs.addAll(swf.tags);
this.swf=swf;
tagTree = new JTree(new TagTreeModel(swf.tags));
getContentPane().setLayout(new BorderLayout());
fPanel = new FlashPanel(400, 400);
getContentPane().add(new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(tagTree), new JScrollPane(fPanel)), BorderLayout.CENTER);
addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
fPanel.dispose();
}
});
tagTree.addTreeSelectionListener(this);
}
private File tempFile;
public static void main(String[] args) throws IOException {
if(args.length<1){
return;
}
View.setWinLookAndFeel();
SWF swf = new SWF(new FileInputStream(args[0]));
TagBrowserFrame tbf = new TagBrowserFrame(swf);
tbf.setVisible(true);
tbf.fPanel.displaySWF(args[0]);
}
@Override
public void valueChanged(TreeSelectionEvent e) {
Object obj = tagTree.getLastSelectedPathComponent();
if (obj instanceof TagNode) {
Object tagObj = ((TagNode) obj).tag;
if (((tagObj instanceof CharacterTag)||(tagObj instanceof FontTag)) && (tagObj instanceof Tag)) {
try {
if(tempFile!=null){
tempFile.delete();
}
tempFile=new File("D:\\temp.swf");//File.createTempFile("temp", ".swf");
tempFile.deleteOnExit();
FileOutputStream fos = new FileOutputStream(tempFile);
SWFOutputStream sos = new SWFOutputStream(fos, 10);
sos.write("FWS".getBytes());
sos.write(13);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
SWFOutputStream sos2 = new SWFOutputStream(baos, 10);
int width = 8000;
int height = 6000;
RECT rct = new RECT();
rct.Ymax = height;
rct.Xmax = width;
sos2.writeRECT(rct);
sos2.writeUI8(0);
sos2.writeUI8(30);
sos2.writeUI16(1); //framecnt
sos2.writeTag(new SetBackgroundColorTag(new RGB(255, 0, 255)));
for(Tag tag:swf.tags){
if((!(tag instanceof PlaceObjectTag))
&&(!(tag instanceof PlaceObject2Tag))
&&(!(tag instanceof PlaceObject3Tag))
&&(!(tag instanceof RemoveObjectTag))
&&(!(tag instanceof RemoveObject2Tag))
&&(!(tag instanceof DoActionTag))
&&(!(tag instanceof ShowFrameTag))
){
sos2.writeTag(tag);
}
}
int chtId=0;
if(tagObj instanceof CharacterTag){
chtId=((CharacterTag) tagObj).getCharacterID();
}
//sos2.writeTag((Tag) tagObj);
MATRIX mat = new MATRIX();
mat.hasRotate = false;
mat.hasScale = false;
mat.translateX = 0;
mat.translateY = 0;
if (tagObj instanceof BoundedTag) {
RECT r = ((BoundedTag) tagObj).getRect();
mat.translateX = -r.Xmin;
mat.translateY = -r.Ymin;
mat.translateX = mat.translateX + width / 2 - r.getWidth() / 2;
mat.translateY = mat.translateY + height / 2 - r.getHeight() / 2;
}else{
mat.translateX=width/2;
mat.translateY=height/2;
}
if(tagObj instanceof FontTag){
int countGlyphs=0;
int fontId=0;
if(tagObj instanceof DefineFontTag){
countGlyphs=((DefineFontTag)tagObj).glyphShapeTable.length;
fontId=((DefineFontTag)tagObj).fontId;
}
if(tagObj instanceof DefineFont2Tag){
countGlyphs=((DefineFont2Tag)tagObj).glyphShapeTable.length;
fontId=((DefineFont2Tag)tagObj).fontId;
}
if(tagObj instanceof DefineFont3Tag){
countGlyphs=((DefineFont3Tag)tagObj).glyphShapeTable.length;
fontId=((DefineFont3Tag)tagObj).fontId;
}
List<TEXTRECORD> rec=new ArrayList<TEXTRECORD>();
TEXTRECORD tr=new TEXTRECORD();
tr.fontId=fontId;
tr.styleFlagsHasFont=true;
tr.textHeight=460;
tr.glyphEntries=new GLYPHENTRY[countGlyphs];
tr.styleFlagsHasColor=true;
tr.textColor=new RGB(0,0,0);
int adv=300;
int maxadv=0;
for(int f=0;f<countGlyphs;f++){
tr.glyphEntries[f]=new GLYPHENTRY();
tr.glyphEntries[f].glyphAdvance=adv;
adv+=300;
if(adv>maxadv){
maxadv=adv;
}
tr.glyphEntries[f].glyphIndex=f;
}
rec.add(tr);
System.out.println("countGlyphs="+countGlyphs);
sos2.writeTag(new DefineTextTag(999, new RECT(0,width,0,height), new MATRIX(), SWFOutputStream.getNeededBitsU(countGlyphs-1), SWFOutputStream.getNeededBitsU(maxadv), rec));
sos2.writeTag(new PlaceObject2Tag(false, false, false, true, false, true, true, false, 1, 999, mat, null, 0, null, 0, null));
sos2.writeTag(new ShowFrameTag());
}else
if ((tagObj instanceof DefineMorphShapeTag) || (tagObj instanceof DefineMorphShape2Tag)) {
sos2.writeTag(new PlaceObject2Tag(false, false, false, true, false, true, true, false, 1, chtId, mat, null, 0, null, 0, null));
sos2.writeTag(new ShowFrameTag());
int numFrames = 100;
for (int ratio = 0; ratio < 65536; ratio += 65536 / numFrames) {
sos2.writeTag(new PlaceObject2Tag(false, false, false, true, false, true, false, true, 1, chtId, mat, null, ratio, null, 0, null));
sos2.writeTag(new ShowFrameTag());
}
} else {
sos2.writeTag(new PlaceObjectTag(chtId, 1, mat, null));
sos2.writeTag(new ShowFrameTag());
}
sos2.writeTag(new EndTag());
byte data[] = baos.toByteArray();
sos.writeUI32(sos.getPos() + data.length + 4);
sos.write(data);
fos.close();
fPanel.displaySWF(tempFile.getAbsolutePath());
(new Thread(){
@Override
public void run() {
while(!tagTree.requestFocusInWindow())
;
}
}).start();
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
}
}

View File

@@ -0,0 +1,279 @@
/*
* 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.asdec.gui;
import com.jpexs.flashplayer.FlashPanel;
import com.jpexs.asdec.SWF;
import com.jpexs.asdec.SWFOutputStream;
import com.jpexs.asdec.tags.DefineBitsJPEG2Tag;
import com.jpexs.asdec.tags.DefineBitsJPEG3Tag;
import com.jpexs.asdec.tags.DefineBitsJPEG4Tag;
import com.jpexs.asdec.tags.DefineBitsLossless2Tag;
import com.jpexs.asdec.tags.DefineBitsLosslessTag;
import com.jpexs.asdec.tags.DefineBitsTag;
import com.jpexs.asdec.tags.DefineFont2Tag;
import com.jpexs.asdec.tags.DefineFont3Tag;
import com.jpexs.asdec.tags.DefineFontTag;
import com.jpexs.asdec.tags.DefineMorphShape2Tag;
import com.jpexs.asdec.tags.DefineMorphShapeTag;
import com.jpexs.asdec.tags.DefineTextTag;
import com.jpexs.asdec.tags.DoABCTag;
import com.jpexs.asdec.tags.DoActionTag;
import com.jpexs.asdec.tags.DoInitActionTag;
import com.jpexs.asdec.tags.EndTag;
import com.jpexs.asdec.tags.JPEGTablesTag;
import com.jpexs.asdec.tags.PlaceObject2Tag;
import com.jpexs.asdec.tags.PlaceObject3Tag;
import com.jpexs.asdec.tags.PlaceObjectTag;
import com.jpexs.asdec.tags.RemoveObject2Tag;
import com.jpexs.asdec.tags.RemoveObjectTag;
import com.jpexs.asdec.tags.ShowFrameTag;
import com.jpexs.asdec.tags.SymbolClassTag;
import com.jpexs.asdec.tags.Tag;
import com.jpexs.asdec.tags.base.BoundedTag;
import com.jpexs.asdec.tags.base.CharacterTag;
import com.jpexs.asdec.tags.base.FontTag;
import com.jpexs.asdec.types.GLYPHENTRY;
import com.jpexs.asdec.types.MATRIX;
import com.jpexs.asdec.types.RECT;
import com.jpexs.asdec.types.RGB;
import com.jpexs.asdec.types.TEXTRECORD;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
/**
*
* @author JPEXS
*/
public class TagPanel extends JPanel implements ListSelectionListener {
public JList tagList;
public FlashPanel flashPanel;
public JPanel displayPanel;
public ImagePanel imagePanel;
private SWF swf;
final static String CARDFLASHPANEL = "Flash card";
final static String CARDIMAGEPANEL = "Image card";
final static String CARDEMPTYPANEL = "Empty card";
private JPEGTablesTag jtt;
public TagPanel(List<Tag> list, SWF swf) {
this.swf = swf;
for(Tag t:swf.tags){
if(t instanceof JPEGTablesTag){
jtt=(JPEGTablesTag)t;
}
}
tagList = new JList(list.toArray(new Tag[list.size()]));
tagList.addListSelectionListener(this);
setLayout(new BorderLayout());
flashPanel = new FlashPanel(400, 400);
displayPanel = new JPanel(new CardLayout());
displayPanel.add(flashPanel, CARDFLASHPANEL);
imagePanel = new ImagePanel();
CardLayout cl = (CardLayout) (displayPanel.getLayout());
cl.show(displayPanel, CARDEMPTYPANEL);
displayPanel.add(imagePanel, CARDIMAGEPANEL);
displayPanel.add(new JPanel(), CARDEMPTYPANEL);
JSplitPane sp=new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(tagList), new JScrollPane(displayPanel));
sp.setDividerLocation(200);
add(sp, BorderLayout.CENTER);
}
private File tempFile;
public void showCard(String card){
CardLayout cl = (CardLayout) (displayPanel.getLayout());
cl.show(displayPanel, card);
}
@Override
public void valueChanged(ListSelectionEvent e) {
Tag tagObj = (Tag) tagList.getSelectedValue();
if(tagObj instanceof DefineBitsTag){
showCard(CARDIMAGEPANEL);
imagePanel.setImage(((DefineBitsTag)tagObj).getFullImageData(jtt));
}else
if(tagObj instanceof DefineBitsJPEG2Tag){
showCard(CARDIMAGEPANEL);
imagePanel.setImage(((DefineBitsJPEG2Tag)tagObj).imageData);
}else
if(tagObj instanceof DefineBitsJPEG3Tag){
showCard(CARDIMAGEPANEL);
imagePanel.setImage(((DefineBitsJPEG3Tag)tagObj).imageData);
}else
if(tagObj instanceof DefineBitsJPEG4Tag){
showCard(CARDIMAGEPANEL);
imagePanel.setImage(((DefineBitsJPEG4Tag)tagObj).imageData);
}else
if(tagObj instanceof DefineBitsLosslessTag){
showCard(CARDIMAGEPANEL);
imagePanel.setImage(((DefineBitsLosslessTag)tagObj).getImage());
}else
if(tagObj instanceof DefineBitsLossless2Tag){
showCard(CARDIMAGEPANEL);
imagePanel.setImage(((DefineBitsLossless2Tag)tagObj).getImage());
} else
if (((tagObj instanceof CharacterTag) || (tagObj instanceof FontTag)) && (tagObj instanceof Tag)) {
try {
if (tempFile != null) {
tempFile.delete();
}
tempFile = File.createTempFile("temp", ".swf");
tempFile.deleteOnExit();
FileOutputStream fos = new FileOutputStream(tempFile);
SWFOutputStream sos = new SWFOutputStream(fos, 10);
sos.write("FWS".getBytes());
sos.write(13);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
SWFOutputStream sos2 = new SWFOutputStream(baos, 10);
int width = 8000;
int height = 6000;
RECT rct = new RECT();
rct.Ymax = height;
rct.Xmax = width;
sos2.writeRECT(rct);
sos2.writeUI8(0);
sos2.writeUI8(30);
sos2.writeUI16(1); //framecnt
//sos2.writeTag(new SetBackgroundColorTag(new RGB(255, 0, 255)));
for (Tag tag : swf.tags) {
if ((!(tag instanceof PlaceObjectTag))
&& (!(tag instanceof PlaceObject2Tag))
&& (!(tag instanceof PlaceObject3Tag))
&& (!(tag instanceof RemoveObjectTag))
&& (!(tag instanceof RemoveObject2Tag))
&& (!(tag instanceof DoActionTag))
&& (!(tag instanceof DoInitActionTag))
&& (!(tag instanceof DoABCTag))
&& (!(tag instanceof SymbolClassTag))
&& (!(tag instanceof ShowFrameTag))) {
sos2.writeTag(tag);
}
}
int chtId = 0;
if (tagObj instanceof CharacterTag) {
chtId = ((CharacterTag) tagObj).getCharacterID();
}
//sos2.writeTag((Tag) tagObj);
MATRIX mat = new MATRIX();
mat.hasRotate = false;
mat.hasScale = false;
mat.translateX = 0;
mat.translateY = 0;
if (tagObj instanceof BoundedTag) {
RECT r = ((BoundedTag) tagObj).getRect();
mat.translateX = -r.Xmin;
mat.translateY = -r.Ymin;
mat.translateX = mat.translateX + width / 2 - r.getWidth() / 2;
mat.translateY = mat.translateY + height / 2 - r.getHeight() / 2;
} else {
mat.translateX = width / 2;
mat.translateY = height / 2;
}
if (tagObj instanceof FontTag) {
int countGlyphs = 0;
int fontId = 0;
if (tagObj instanceof DefineFontTag) {
countGlyphs = ((DefineFontTag) tagObj).glyphShapeTable.length;
fontId = ((DefineFontTag) tagObj).fontId;
}
if (tagObj instanceof DefineFont2Tag) {
countGlyphs = ((DefineFont2Tag) tagObj).glyphShapeTable.length;
fontId = ((DefineFont2Tag) tagObj).fontId;
}
if (tagObj instanceof DefineFont3Tag) {
countGlyphs = ((DefineFont3Tag) tagObj).glyphShapeTable.length;
fontId = ((DefineFont3Tag) tagObj).fontId;
}
List<TEXTRECORD> rec = new ArrayList<TEXTRECORD>();
TEXTRECORD tr = new TEXTRECORD();
tr.fontId = fontId;
tr.styleFlagsHasFont = true;
tr.textHeight = 460;
tr.glyphEntries = new GLYPHENTRY[countGlyphs];
tr.styleFlagsHasColor = true;
tr.textColor = new RGB(0, 0, 0);
int adv = 300;
int maxadv = 0;
for (int f = 0; f < countGlyphs; f++) {
tr.glyphEntries[f] = new GLYPHENTRY();
tr.glyphEntries[f].glyphAdvance = adv;
adv += 300;
if (adv > maxadv) {
maxadv = adv;
}
tr.glyphEntries[f].glyphIndex = f;
}
rec.add(tr);
sos2.writeTag(new DefineTextTag(999, new RECT(0, width, 0, height), new MATRIX(), SWFOutputStream.getNeededBitsU(countGlyphs - 1), SWFOutputStream.getNeededBitsU(maxadv), rec));
sos2.writeTag(new PlaceObject2Tag(false, false, false, true, false, true, true, false, 1, 999, mat, null, 0, null, 0, null));
sos2.writeTag(new ShowFrameTag());
} else if ((tagObj instanceof DefineMorphShapeTag) || (tagObj instanceof DefineMorphShape2Tag)) {
sos2.writeTag(new PlaceObject2Tag(false, false, false, true, false, true, true, false, 1, chtId, mat, null, 0, null, 0, null));
sos2.writeTag(new ShowFrameTag());
int numFrames = 100;
for (int ratio = 0; ratio < 65536; ratio += 65536 / numFrames) {
sos2.writeTag(new PlaceObject2Tag(false, false, false, true, false, true, false, true, 1, chtId, mat, null, ratio, null, 0, null));
sos2.writeTag(new ShowFrameTag());
}
} else {
sos2.writeTag(new PlaceObject2Tag(false, false, false, true, false, true, true, false, 1, chtId, mat, null, 0, null, 0, null));
sos2.writeTag(new ShowFrameTag());
}
sos2.writeTag(new EndTag());
byte data[] = baos.toByteArray();
sos.writeUI32(sos.getPos() + data.length + 4);
sos.write(data);
fos.close();
flashPanel.displaySWF(tempFile.getAbsolutePath());
(new Thread() {
@Override
public void run() {
while (!tagList.requestFocusInWindow())
;
}
}).start();
} catch (Exception ex) {
}
showCard(CARDFLASHPANEL);
}
}
}

View File

@@ -137,13 +137,8 @@ public class ProxyFrame extends JFrame implements ActionListener, CatchedListene
public void windowClosing(WindowEvent e) {
setVisible(false);
Main.removeTrayIcon();
if (Main.abcMainFrame != null) {
if (Main.abcMainFrame.isVisible()) {
return;
}
}
if (Main.actionMainFrame != null) {
if (Main.actionMainFrame.isVisible()) {
if (Main.mainFrame != null) {
if (Main.mainFrame.isVisible()) {
return;
}
}

View File

@@ -67,7 +67,7 @@ public class CSMTextSettingsTag extends Tag {
* @throws IOException
*/
public CSMTextSettingsTag(byte data[], int version, long pos) throws IOException {
super(74, data, pos);
super(74, "CSMTextSettings", data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
textID = sis.readUI16();
useFlashType = (int) sis.readUB(2);

View File

@@ -58,18 +58,8 @@ public class DebugIDTag extends Tag {
* @throws IOException
*/
public DebugIDTag(byte data[], int version, long pos) throws IOException {
super(63, data, pos);
super(63,"DebugID", data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
debugId = sis.readBytes(16);
}
/**
* Returns string representation of the object
*
* @return String representation of the object
*/
@Override
public String toString() {
return "DebugID";
}
}

View File

@@ -48,14 +48,9 @@ public class DefineBinaryDataTag extends Tag {
}
public DefineBinaryDataTag(byte[] data, int version, long pos) throws IOException {
super(87, data, pos);
super(87,"DefineBinaryData", data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
tag = sis.readUI16();
binaryData = sis.readBytes(sis.available());
}
@Override
public String toString() {
return "DefineBinaryData";
}
}

View File

@@ -17,23 +17,25 @@
package com.jpexs.asdec.tags;
import com.jpexs.asdec.SWFInputStream;
import com.jpexs.asdec.tags.base.CharacterTag;
import java.io.ByteArrayInputStream;
import java.io.IOException;
public class DefineBitsJPEG2Tag extends Tag {
public class DefineBitsJPEG2Tag extends CharacterTag{
public int characterID;
public byte[] imageData;
@Override
public int getCharacterID() {
return characterID;
}
public DefineBitsJPEG2Tag(byte[] data, int version, long pos) throws IOException {
super(21, data, pos);
super(21,"DefineBitsJPEG2", data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
characterID = sis.readUI16();
imageData = sis.readBytes(sis.available());
}
@Override
public String toString() {
return "DefineBitsJPEG2";
}
}

View File

@@ -18,19 +18,26 @@ package com.jpexs.asdec.tags;
import com.jpexs.asdec.SWFInputStream;
import com.jpexs.asdec.SWFOutputStream;
import com.jpexs.asdec.tags.base.CharacterTag;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
public class DefineBitsJPEG3Tag extends Tag {
public class DefineBitsJPEG3Tag extends CharacterTag {
public int characterID;
public byte imageData[];
public byte bitmapAlphaData[];
@Override
public int getCharacterID() {
return characterID;
}
public DefineBitsJPEG3Tag(byte[] data, int version, long pos) throws IOException {
super(35, data, pos);
super(35,"DefineBitsJPEG3", data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
characterID = sis.readUI16();
long alphaDataOffset = sis.readUI32();
@@ -58,9 +65,4 @@ public class DefineBitsJPEG3Tag extends Tag {
}
return baos.toByteArray();
}
@Override
public String toString() {
return "DefineBitsJPEG3";
}
}

View File

@@ -18,6 +18,7 @@ package com.jpexs.asdec.tags;
import com.jpexs.asdec.SWFInputStream;
import com.jpexs.asdec.SWFOutputStream;
import com.jpexs.asdec.tags.base.CharacterTag;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -28,13 +29,19 @@ import java.io.OutputStream;
*
* @author JPEXS
*/
public class DefineBitsJPEG4Tag extends Tag {
public class DefineBitsJPEG4Tag extends CharacterTag {
public int characterID;
public int deblockParam;
public byte imageData[];
public byte bitmapAlphaData[];
@Override
public int getCharacterID() {
return characterID;
}
/**
* Gets data bytes
*
@@ -65,7 +72,7 @@ public class DefineBitsJPEG4Tag extends Tag {
* @throws IOException
*/
public DefineBitsJPEG4Tag(byte data[], int version, long pos) throws IOException {
super(90, data, pos);
super(90, "DefineBitsJPEG4",data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
characterID = sis.readUI16();
long alphaDataOffset = sis.readUI32();
@@ -73,14 +80,4 @@ public class DefineBitsJPEG4Tag extends Tag {
imageData = sis.readBytes(alphaDataOffset);
bitmapAlphaData = sis.readBytes(sis.available());
}
/**
* Returns string representation of the object
*
* @return String representation of the object
*/
@Override
public String toString() {
return "DefineBitsJPEG4";
}
}

View File

@@ -18,15 +18,20 @@ package com.jpexs.asdec.tags;
import com.jpexs.asdec.SWFInputStream;
import com.jpexs.asdec.SWFOutputStream;
import com.jpexs.asdec.tags.base.CharacterTag;
import com.jpexs.asdec.types.ALPHABITMAPDATA;
import com.jpexs.asdec.types.ALPHACOLORMAPDATA;
import com.jpexs.asdec.types.RGBA;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.zip.InflaterInputStream;
public class DefineBitsLossless2Tag extends Tag {
public class DefineBitsLossless2Tag extends CharacterTag {
public int characterID;
public int bitmapFormat;
@@ -38,8 +43,15 @@ public class DefineBitsLossless2Tag extends Tag {
public static final int FORMAT_15BIT_RGB = 4;
public static final int FORMAT_24BIT_RGB = 5;
@Override
public int getCharacterID() {
return characterID;
}
public DefineBitsLossless2Tag(byte[] data, int version, long pos) throws IOException {
super(36, data, pos);
super(36,"DefineBitsLossless2", data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
characterID = sis.readUI16();
bitmapFormat = sis.readUI8();
@@ -107,8 +119,36 @@ public class DefineBitsLossless2Tag extends Tag {
return baos.toByteArray();
}
@Override
public String toString() {
return "DefineBitsLossless2";
public BufferedImage getImage() {
BufferedImage bi = new BufferedImage(bitmapWidth, bitmapHeight, BufferedImage.TYPE_INT_ARGB);
Graphics g = bi.getGraphics();
ALPHACOLORMAPDATA colorMapData = null;
ALPHABITMAPDATA bitmapData = null;
if (bitmapFormat == DefineBitsLossless2Tag.FORMAT_8BIT_COLORMAPPED) {
colorMapData = getColorMapData();
}
if ((bitmapFormat == DefineBitsLossless2Tag.FORMAT_15BIT_RGB) || (bitmapFormat == DefineBitsLossless2Tag.FORMAT_24BIT_RGB)) {
bitmapData = getBitmapData();
}
int pos32aligned = 0;
int pos = 0;
for (int y = 0; y < bitmapHeight; y++) {
for (int x = 0; x < bitmapWidth; x++) {
if ((bitmapFormat == DefineBitsLossless2Tag.FORMAT_8BIT_COLORMAPPED)) {
RGBA color = colorMapData.colorTableRGB[colorMapData.colorMapPixelData[pos32aligned]];
g.setColor(new Color(color.red, color.green, color.blue, color.alpha));
}
if ((bitmapFormat == DefineBitsLossless2Tag.FORMAT_15BIT_RGB) || (bitmapFormat == DefineBitsLossless2Tag.FORMAT_24BIT_RGB)) {
g.setColor(new Color(bitmapData.bitmapPixelData[pos].red, bitmapData.bitmapPixelData[pos].green, bitmapData.bitmapPixelData[pos].blue, bitmapData.bitmapPixelData[pos].alpha));
}
g.fillRect(x, y, 1, 1);
pos32aligned++;
pos++;
}
while ((pos32aligned % 4 != 0)) {
pos32aligned++;
}
}
return bi;
}
}

View File

@@ -18,15 +18,21 @@ package com.jpexs.asdec.tags;
import com.jpexs.asdec.SWFInputStream;
import com.jpexs.asdec.SWFOutputStream;
import com.jpexs.asdec.tags.base.CharacterTag;
import com.jpexs.asdec.types.BITMAPDATA;
import com.jpexs.asdec.types.COLORMAPDATA;
import com.jpexs.asdec.types.RGB;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.zip.InflaterInputStream;
public class DefineBitsLosslessTag extends Tag {
public class DefineBitsLosslessTag extends CharacterTag {
public int characterID;
public int bitmapFormat;
@@ -41,6 +47,49 @@ public class DefineBitsLosslessTag extends Tag {
private BITMAPDATA bitmapData;
private boolean decompressed = false;
public BufferedImage getImage() {
BufferedImage bi = new BufferedImage(bitmapWidth, bitmapHeight, BufferedImage.TYPE_INT_RGB);
Graphics g = bi.getGraphics();
COLORMAPDATA colorMapData = null;
BITMAPDATA bitmapData = null;
if (bitmapFormat == DefineBitsLosslessTag.FORMAT_8BIT_COLORMAPPED) {
colorMapData = getColorMapData();
}
if ((bitmapFormat == DefineBitsLosslessTag.FORMAT_15BIT_RGB) || (bitmapFormat == DefineBitsLosslessTag.FORMAT_24BIT_RGB)) {
bitmapData = getBitmapData();
}
int pos32aligned = 0;
int pos = 0;
for (int y = 0; y < bitmapHeight; y++) {
for (int x = 0; x < bitmapWidth; x++) {
if (bitmapFormat == DefineBitsLosslessTag.FORMAT_8BIT_COLORMAPPED) {
RGB color = colorMapData.colorTableRGB[colorMapData.colorMapPixelData[pos32aligned]];
g.setColor(new Color(color.red, color.green, color.blue));
}
if (bitmapFormat == DefineBitsLosslessTag.FORMAT_15BIT_RGB) {
g.setColor(new Color(bitmapData.bitmapPixelDataPix15[pos].red * 8, bitmapData.bitmapPixelDataPix15[pos].green * 8, bitmapData.bitmapPixelDataPix15[pos].blue * 8));
}
if (bitmapFormat == DefineBitsLosslessTag.FORMAT_24BIT_RGB) {
g.setColor(new Color(bitmapData.bitmapPixelDataPix24[pos].red, bitmapData.bitmapPixelDataPix24[pos].green, bitmapData.bitmapPixelDataPix24[pos].blue));
}
g.fillRect(x, y, 1, 1);
pos32aligned++;
pos++;
}
while ((pos32aligned % 4 != 0)) {
pos32aligned++;
}
}
return bi;
}
@Override
public int getCharacterID() {
return characterID;
}
public COLORMAPDATA getColorMapData() {
if (!decompressed) {
uncompressData();
@@ -70,7 +119,7 @@ public class DefineBitsLosslessTag extends Tag {
}
public DefineBitsLosslessTag(byte[] data, int version, long pos) throws IOException {
super(20, data, pos);
super(20, "DefineBitsLossless", data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
characterID = sis.readUI16();
bitmapFormat = sis.readUI8();
@@ -106,9 +155,4 @@ public class DefineBitsLosslessTag extends Tag {
}
return baos.toByteArray();
}
@Override
public String toString() {
return "DefineBitsLossless";
}
}

View File

@@ -16,25 +16,57 @@
*/
package com.jpexs.asdec.tags;
import com.jpexs.asdec.SWF;
import com.jpexs.asdec.SWFInputStream;
import com.jpexs.asdec.SWFOutputStream;
import com.jpexs.asdec.tags.base.CharacterTag;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
public class DefineBitsTag extends Tag {
public class DefineBitsTag extends CharacterTag {
public int characterID;
public byte jpegData[];
public DefineBitsTag(byte[] data, int version, long pos) throws IOException {
super(6, data, pos);
super(6, "DefineBits", data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
characterID = sis.readUI16();
jpegData = sis.readBytes(sis.available());
}
public byte[] getFullImageData(JPEGTablesTag jtt) {
if ((jtt != null)) {
ByteArrayOutputStream baos = null;
try {
baos = new ByteArrayOutputStream();
byte jttdata[] = jtt.getData(10);
if(jttdata.length!=0){
baos.write(jttdata, SWF.hasErrorHeader(jttdata) ? 4 : 0, jttdata.length - (SWF.hasErrorHeader(jttdata) ? 6 : 2));
baos.write(jpegData, SWF.hasErrorHeader(jpegData) ? 6 : 2, jpegData.length - (SWF.hasErrorHeader(jttdata) ? 6 : 2));
}else{
baos.write(jpegData,0,jpegData.length);
}
} finally {
if (baos != null) {
try {
baos.close();
} catch (Exception ex) {
//ignore
}
}
}
return baos.toByteArray();
}
return null;
}
/**
* Gets data bytes
*
@@ -55,7 +87,7 @@ public class DefineBitsTag extends Tag {
}
@Override
public String toString() {
return "DefineBits";
public int getCharacterID() {
return characterID;
}
}

View File

@@ -22,7 +22,6 @@ import com.jpexs.asdec.SWFOutputStream;
import com.jpexs.asdec.abc.CopyOutputStream;
import com.jpexs.asdec.tags.base.CharacterTag;
import com.jpexs.asdec.tags.base.Container;
import com.jpexs.asdec.tags.base.TagName;
import com.jpexs.asdec.types.BUTTONCONDACTION;
import com.jpexs.asdec.types.BUTTONRECORD;
import java.io.ByteArrayInputStream;
@@ -40,7 +39,7 @@ import java.util.logging.Logger;
*
* @author JPEXS
*/
public class DefineButton2Tag extends Tag implements Container, TagName,CharacterTag {
public class DefineButton2Tag extends CharacterTag implements Container {
/**
* ID for this character
@@ -58,10 +57,6 @@ public class DefineButton2Tag extends Tag implements Container, TagName,Characte
* Actions to execute at particular button events
*/
public List<BUTTONCONDACTION> actions = new ArrayList<BUTTONCONDACTION>();
/**
* List of ExportAssetsTag used for converting to String
*/
public List<ExportAssetsTag> exportAssetsTags = new ArrayList<ExportAssetsTag>();
@Override
public int getCharacterID() {
@@ -76,7 +71,7 @@ public class DefineButton2Tag extends Tag implements Container, TagName,Characte
* @throws IOException
*/
public DefineButton2Tag(byte data[], int version, long pos) throws IOException {
super(34, data, pos);
super(34,"DefineButton2", data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
buttonId = sis.readUI16();
sis.readUB(7); //reserved
@@ -174,20 +169,4 @@ public class DefineButton2Tag extends Tag implements Container, TagName,Characte
public int getItemCount() {
return actions.size();
}
public String getName() {
return "DefineButton2Tag" + buttonId;
}
@Override
public String toString() {
String name = "";
for (ExportAssetsTag eat : exportAssetsTags) {
int pos = eat.tags.indexOf(buttonId);
if (pos > -1) {
name = ": " + eat.names.get(pos);
}
}
return "DefineButton2 (" + buttonId + name + ")";
}
}

View File

@@ -61,19 +61,9 @@ public class DefineButtonCxformTag extends Tag {
* @throws IOException
*/
public DefineButtonCxformTag(byte data[], int version, long pos) throws IOException {
super(23, data, pos);
super(23, "DefineButtonCxform",data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
buttonId = sis.readUI16();
buttonColorTransform = sis.readCXFORM();
}
/**
* Returns string representation of the object
*
* @return String representation of the object
*/
@Override
public String toString() {
return "DefineButtonCxform";
}
}

View File

@@ -30,7 +30,7 @@ import java.io.OutputStream;
*
* @author JPEXS
*/
public class DefineButtonSoundTag extends Tag implements CharacterTag{
public class DefineButtonSoundTag extends CharacterTag{
public int buttonId;
public int buttonSoundChar0;
@@ -90,7 +90,7 @@ public class DefineButtonSoundTag extends Tag implements CharacterTag{
* @throws IOException
*/
public DefineButtonSoundTag(byte data[], int version, long pos) throws IOException {
super(17, data, pos);
super(17, "DefineButtonSound",data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
buttonId = sis.readUI16();
buttonSoundChar0 = sis.readUI16();
@@ -111,13 +111,4 @@ public class DefineButtonSoundTag extends Tag implements CharacterTag{
}
}
/**
* Returns string representation of the object
*
* @return String representation of the object
*/
@Override
public String toString() {
return "DefineButtonSound";
}
}

View File

@@ -23,7 +23,6 @@ import com.jpexs.asdec.abc.CopyOutputStream;
import com.jpexs.asdec.action.Action;
import com.jpexs.asdec.tags.base.ASMSource;
import com.jpexs.asdec.tags.base.CharacterTag;
import com.jpexs.asdec.tags.base.TagName;
import com.jpexs.asdec.types.BUTTONRECORD;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -39,7 +38,7 @@ import java.util.logging.Logger;
*
* @author JPEXS
*/
public class DefineButtonTag extends Tag implements ASMSource, TagName, CharacterTag {
public class DefineButtonTag extends CharacterTag implements ASMSource {
/**
* ID for this character
@@ -54,11 +53,6 @@ public class DefineButtonTag extends Tag implements ASMSource, TagName, Characte
*/
//public List<Action> actions;
public byte[] actionBytes;
/**
* List of ExportAssetsTag used for converting to String
*/
public List<ExportAssetsTag> exportAssetsTags = new ArrayList<ExportAssetsTag>();
@Override
public int getCharacterID() {
@@ -73,7 +67,7 @@ public class DefineButtonTag extends Tag implements ASMSource, TagName, Characte
* @throws IOException
*/
public DefineButtonTag(byte[] data, int version, long pos) throws IOException {
super(7, data, pos);
super(7, "DefineButton",data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
buttonId = sis.readUI16();
characters = sis.readBUTTONRECORDList(false);
@@ -109,22 +103,6 @@ public class DefineButtonTag extends Tag implements ASMSource, TagName, Characte
return baos.toByteArray();
}
public String getName() {
return "DefineButtonTag" + buttonId;
}
@Override
public String toString() {
String name = "";
for (ExportAssetsTag eat : exportAssetsTags) {
int pos = eat.tags.indexOf(buttonId);
if (pos > -1) {
name = ": " + eat.names.get(pos);
}
}
return "DefineButton (" + buttonId + name + ")";
}
/**
* Converts actions to ASM source
*

View File

@@ -31,7 +31,7 @@ import java.io.OutputStream;
*
* @author JPEXS
*/
public class DefineEditTextTag extends Tag implements CharacterTag {
public class DefineEditTextTag extends CharacterTag {
public int characterID;
public RECT bounds;
@@ -139,7 +139,7 @@ public class DefineEditTextTag extends Tag implements CharacterTag {
* @throws IOException
*/
public DefineEditTextTag(byte data[], int version, long pos) throws IOException {
super(37, data, pos);
super(37, "DefineEditText", data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
characterID = sis.readUI16();
bounds = sis.readRECT();
@@ -188,13 +188,4 @@ public class DefineEditTextTag extends Tag implements CharacterTag {
}
/**
* Returns string representation of the object
*
* @return String representation of the object
*/
@Override
public String toString() {
return "DefineEditText";
}
}

View File

@@ -146,7 +146,7 @@ public class DefineFont2Tag extends Tag implements FontTag {
* @throws IOException
*/
public DefineFont2Tag(byte data[], int version, long pos) throws IOException {
super(48, data, pos);
super(48,"DefineFont2", data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
fontId = sis.readUI16();
fontFlagsHasLayout = sis.readUB(1) == 1;
@@ -209,13 +209,4 @@ public class DefineFont2Tag extends Tag implements FontTag {
}
}
/**
* Returns string representation of the object
*
* @return String representation of the object
*/
@Override
public String toString() {
return "DefineFont2";
}
}

View File

@@ -55,7 +55,7 @@ public class DefineFont3Tag extends Tag implements FontTag {
public KERNINGRECORD fontKerningTable[];
public DefineFont3Tag(byte[] data, int version, long pos) throws IOException {
super(75, data, pos);
super(75, "DefineFont3",data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
fontId = sis.readUI16();
fontFlagsHasLayout = sis.readUB(1) == 1;
@@ -200,8 +200,4 @@ public class DefineFont3Tag extends Tag implements FontTag {
return baos.toByteArray();
}
@Override
public String toString() {
return "DefineFont3";
}
}

View File

@@ -24,7 +24,7 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
public class DefineFont4Tag extends Tag implements CharacterTag{
public class DefineFont4Tag extends CharacterTag{
public int fontID;
public boolean fontFlagsHasFontData;
@@ -39,7 +39,7 @@ public class DefineFont4Tag extends Tag implements CharacterTag{
}
public DefineFont4Tag(byte[] data, int version, long pos) throws IOException {
super(91, data, pos);
super(91,"DefineFont4", data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
fontID = sis.readUI16();
sis.readUB(5);
@@ -74,8 +74,4 @@ public class DefineFont4Tag extends Tag implements CharacterTag{
return baos.toByteArray();
}
@Override
public String toString() {
return "DefineFont4";
}
}

View File

@@ -33,7 +33,7 @@ public class DefineFontAlignZonesTag extends Tag {
public List<ZONERECORD> zoneTable;
public DefineFontAlignZonesTag(byte[] data, int version, long pos) throws IOException {
super(73, data, pos);
super(73, "DefineFontAlignZones",data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
fontID = sis.readUI16();
CSMTableHint = (int) sis.readUB(2);
@@ -68,8 +68,4 @@ public class DefineFontAlignZonesTag extends Tag {
return baos.toByteArray();
}
@Override
public String toString() {
return "DefineFontAlignZones";
}
}

View File

@@ -81,7 +81,7 @@ public class DefineFontInfo2Tag extends Tag {
* @throws IOException
*/
public DefineFontInfo2Tag(byte data[], int version, long pos) throws IOException {
super(62, data, pos);
super(62,"DefineFontInfo2", data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
fontID = sis.readUI16();
int fontNameLen = sis.readUI8();
@@ -99,14 +99,4 @@ public class DefineFontInfo2Tag extends Tag {
codeTable[i] = sis.readUI16();
}
}
/**
* Returns string representation of the object
*
* @return String representation of the object
*/
@Override
public String toString() {
return "DefineFontInfo2";
}
}

View File

@@ -84,7 +84,7 @@ public class DefineFontInfoTag extends Tag {
* @throws IOException
*/
public DefineFontInfoTag(byte data[], int version, long pos) throws IOException {
super(13, data, pos);
super(13,"DefineFontInfo", data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
fontId = sis.readUI16();
int fontNameLen = sis.readUI8();
@@ -105,14 +105,4 @@ public class DefineFontInfoTag extends Tag {
}
} while (sis.available() > 0);
}
/**
* Returns string representation of the object
*
* @return String representation of the object
*/
@Override
public String toString() {
return "DefineFontInfo";
}
}

View File

@@ -27,15 +27,10 @@ public class DefineFontNameTag extends Tag {
public String fontCopyright;
public DefineFontNameTag(byte[] data, int version, long pos) throws IOException {
super(88, data, pos);
super(88,"DefineFontName", data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
fontId = sis.readUI16();
fontName = sis.readString();
fontCopyright = sis.readString();
}
@Override
public String toString() {
return "DefineFontName";
}
}

View File

@@ -69,7 +69,7 @@ public class DefineFontTag extends Tag implements FontTag{
* @throws IOException
*/
public DefineFontTag(byte data[], int version, long pos) throws IOException {
super(10, data, pos);
super(10,"DefineFont", data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
fontId = sis.readUI16();
int firstOffset = sis.readUI16();
@@ -85,13 +85,4 @@ public class DefineFontTag extends Tag implements FontTag{
}
}
/**
* Returns string representation of the object
*
* @return String representation of the object
*/
@Override
public String toString() {
return "DefineFont";
}
}

View File

@@ -34,7 +34,7 @@ import java.io.OutputStream;
*
* @author JPEXS
*/
public class DefineMorphShape2Tag extends Tag implements CharacterTag, BoundedTag {
public class DefineMorphShape2Tag extends CharacterTag implements BoundedTag {
public int characterId;
public RECT startBounds;
@@ -105,7 +105,7 @@ public class DefineMorphShape2Tag extends Tag implements CharacterTag, BoundedTa
* @throws IOException
*/
public DefineMorphShape2Tag(byte data[], int version, long pos) throws IOException {
super(84, data, pos);
super(84, "DefineMorphShape2", data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
characterId = sis.readUI16();
startBounds = sis.readRECT();
@@ -122,13 +122,4 @@ public class DefineMorphShape2Tag extends Tag implements CharacterTag, BoundedTa
endEdges = sis.readSHAPE(1);
}
/**
* Returns string representation of the object
*
* @return String representation of the object
*/
@Override
public String toString() {
return "DefineMorphShape2";
}
}

View File

@@ -34,7 +34,7 @@ import java.io.OutputStream;
*
* @author JPEXS
*/
public class DefineMorphShapeTag extends Tag implements CharacterTag, BoundedTag{
public class DefineMorphShapeTag extends CharacterTag implements BoundedTag{
public int characterId;
public RECT startBounds;
@@ -88,7 +88,7 @@ public class DefineMorphShapeTag extends Tag implements CharacterTag, BoundedTag
* @throws IOException
*/
public DefineMorphShapeTag(byte data[], int version, long pos) throws IOException {
super(46, data, pos);
super(46,"DefineMorphShape", data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
characterId = sis.readUI16();
startBounds = sis.readRECT();
@@ -100,15 +100,6 @@ public class DefineMorphShapeTag extends Tag implements CharacterTag, BoundedTag
endEdges = sis.readSHAPE(1);
}
/**
* Returns string representation of the object
*
* @return String representation of the object
*/
@Override
public String toString() {
return "DefineMorphShape";
}
@Override
public RECT getRect() {

View File

@@ -33,7 +33,7 @@ public class DefineScalingGridTag extends Tag {
private RECT splitter;
public DefineScalingGridTag(byte[] data, int version, long pos) throws IOException {
super(78, data, pos);
super(78, "DefineScalingGrid",data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
characterId = sis.readUI16();
splitter = sis.readRECT();
@@ -57,9 +57,4 @@ public class DefineScalingGridTag extends Tag {
}
return baos.toByteArray();
}
@Override
public String toString() {
return "DefineScalingGrid";
}
}

View File

@@ -72,7 +72,7 @@ public class DefineSceneAndFrameLabelDataTag extends Tag {
* @throws IOException
*/
public DefineSceneAndFrameLabelDataTag(byte data[], int version, long pos) throws IOException {
super(86, data, pos);
super(86, "DefineSceneAndFrameLabelData",data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
int sceneCount = (int) sis.readEncodedU32();
sceneOffsets = new long[sceneCount];
@@ -88,14 +88,4 @@ public class DefineSceneAndFrameLabelDataTag extends Tag {
}
}
/**
* Returns string representation of the object
*
* @return String representation of the object
*/
@Override
public String toString() {
return "DefineSceneAndFrameLabelData";
}
}

View File

@@ -26,7 +26,7 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
public class DefineShape2Tag extends Tag implements CharacterTag, BoundedTag{
public class DefineShape2Tag extends CharacterTag implements BoundedTag{
public int shapeId;
public RECT shapeBounds;
@@ -44,24 +44,11 @@ public class DefineShape2Tag extends Tag implements CharacterTag, BoundedTag{
}
public DefineShape2Tag(byte[] data, int version, long pos) throws IOException {
super(22, data, pos);
super(22, "DefineShape2",data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
shapeId = sis.readUI16();
shapeBounds = sis.readRECT();
shapes = sis.readSHAPEWITHSTYLE(2);
}
public List<ExportAssetsTag> exportAssetsTags = new ArrayList<ExportAssetsTag>();
@Override
public String toString() {
String name = "";
for (ExportAssetsTag eat : exportAssetsTags) {
int pos = eat.tags.indexOf(shapeId);
if (pos > -1) {
name = ": " + eat.names.get(pos);
}
}
return "DefineShape2 (" + shapeId + name + ")";
}
}

View File

@@ -26,7 +26,7 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
public class DefineShape3Tag extends Tag implements CharacterTag,BoundedTag{
public class DefineShape3Tag extends CharacterTag implements BoundedTag{
public int shapeId;
public RECT shapeBounds;
@@ -42,24 +42,10 @@ public class DefineShape3Tag extends Tag implements CharacterTag,BoundedTag{
}
public DefineShape3Tag(byte[] data, int version, long pos) throws IOException {
super(32, data, pos);
super(32,"DefineShape3", data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
shapeId = sis.readUI16();
shapeBounds = sis.readRECT();
shapes = sis.readSHAPEWITHSTYLE(3);
}
public List<ExportAssetsTag> exportAssetsTags = new ArrayList<ExportAssetsTag>();
@Override
public String toString() {
String name = "";
for (ExportAssetsTag eat : exportAssetsTags) {
int pos = eat.tags.indexOf(shapeId);
if (pos > -1) {
name = ": " + eat.names.get(pos);
}
}
return "DefineShape3 (" + shapeId + name + ")";
}
}

View File

@@ -26,7 +26,7 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
public class DefineShape4Tag extends Tag implements CharacterTag,BoundedTag{
public class DefineShape4Tag extends CharacterTag implements BoundedTag{
public int shapeId;
public RECT shapeBounds;
@@ -47,7 +47,7 @@ public class DefineShape4Tag extends Tag implements CharacterTag,BoundedTag{
}
public DefineShape4Tag(byte[] data, int version, long pos) throws IOException {
super(83, data, pos);
super(83, "DefineShape4", data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
shapeId = sis.readUI16();
shapeBounds = sis.readRECT();
@@ -58,18 +58,4 @@ public class DefineShape4Tag extends Tag implements CharacterTag,BoundedTag{
usesScalingStrokes = sis.readUB(1) == 1;
shapes = sis.readSHAPEWITHSTYLE(4);
}
public List<ExportAssetsTag> exportAssetsTags = new ArrayList<ExportAssetsTag>();
@Override
public String toString() {
String name = "";
for (ExportAssetsTag eat : exportAssetsTags) {
int pos = eat.tags.indexOf(shapeId);
if (pos > -1) {
name = ": " + eat.names.get(pos);
}
}
return "DefineShape4 (" + shapeId + name + ")";
}
}

View File

@@ -26,7 +26,7 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
public class DefineShapeTag extends Tag implements CharacterTag, BoundedTag {
public class DefineShapeTag extends CharacterTag implements BoundedTag {
public int shapeId;
public RECT shapeBounds;
@@ -40,29 +40,13 @@ public class DefineShapeTag extends Tag implements CharacterTag, BoundedTag {
public DefineShapeTag(byte[] data, int version, long pos) throws IOException {
super(2, data, pos);
super(2,"DefineShape", data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
shapeId = sis.readUI16();
shapeBounds = sis.readRECT();
shapes = sis.readSHAPEWITHSTYLE(1);
}
public List<ExportAssetsTag> exportAssetsTags = new ArrayList<ExportAssetsTag>();
@Override
public String toString() {
String name = "";
for (ExportAssetsTag eat : exportAssetsTags) {
int pos = eat.tags.indexOf(shapeId);
if (pos > -1) {
name = ": " + eat.names.get(pos);
}
}
return "DefineShape (" + shapeId + name + ")";
}
@Override
public int getCharacterID() {
return shapeId;

View File

@@ -29,7 +29,7 @@ import java.io.OutputStream;
*
* @author JPEXS
*/
public class DefineSoundTag extends Tag implements CharacterTag {
public class DefineSoundTag extends CharacterTag {
public int soundId;
public int soundFormat;
@@ -82,7 +82,7 @@ public class DefineSoundTag extends Tag implements CharacterTag {
* @throws IOException
*/
public DefineSoundTag(byte data[], int version, long pos) throws IOException {
super(14, data, pos);
super(14,"DefineSound", data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
soundId = sis.readUI16();
soundFormat = (int) sis.readUB(4);
@@ -91,14 +91,4 @@ public class DefineSoundTag extends Tag implements CharacterTag {
soundSampleCount = sis.readUI32();
soundData = sis.readBytes(sis.available());
}
/**
* Returns string representation of the object
*
* @return String representation of the object
*/
@Override
public String toString() {
return "DefineSound";
}
}

View File

@@ -22,7 +22,6 @@ import com.jpexs.asdec.SWFOutputStream;
import com.jpexs.asdec.abc.CopyOutputStream;
import com.jpexs.asdec.tags.base.CharacterTag;
import com.jpexs.asdec.tags.base.Container;
import com.jpexs.asdec.tags.base.TagName;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -33,7 +32,7 @@ import java.util.List;
/**
* Defines a sprite character
*/
public class DefineSpriteTag extends Tag implements Container, TagName, CharacterTag {
public class DefineSpriteTag extends CharacterTag implements Container {
/**
* Character ID of sprite
@@ -47,11 +46,7 @@ public class DefineSpriteTag extends Tag implements Container, TagName, Characte
* A series of tags
*/
public List<Tag> subTags;
/**
* List of ExportAssetsTag used for converting to String
*/
public List<ExportAssetsTag> exportAssetsTags = new ArrayList<ExportAssetsTag>();
private int level;
private int level;
@Override
public int getCharacterID() {
@@ -69,7 +64,7 @@ public class DefineSpriteTag extends Tag implements Container, TagName, Characte
* @throws IOException
*/
public DefineSpriteTag(byte[] data, int version, int level, long pos) throws IOException {
super(39, data, pos);
super(39,"DefineSprite", data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version, pos);
spriteId = sis.readUI16();
frameCount = sis.readUI16();
@@ -105,22 +100,7 @@ public class DefineSpriteTag extends Tag implements Container, TagName, Characte
return baos.toByteArray();
}
@Override
public String getName() {
return "DefineSpriteTag" + spriteId;
}
@Override
public String toString() {
String name = "";
for (ExportAssetsTag eat : exportAssetsTags) {
int pos = eat.tags.indexOf(spriteId);
if (pos > -1) {
name = ": " + eat.names.get(pos);
}
}
return "DefineSpriteTag (" + spriteId + name + ")";
}
/**
* Returns all sub-items

View File

@@ -34,7 +34,7 @@ import java.util.List;
*
* @author JPEXS
*/
public class DefineText2Tag extends Tag implements CharacterTag {
public class DefineText2Tag extends CharacterTag {
public int characterID;
public RECT textBounds;
@@ -82,7 +82,7 @@ public class DefineText2Tag extends Tag implements CharacterTag {
* @throws IOException
*/
public DefineText2Tag(byte data[], int version, long pos) throws IOException {
super(33, data, pos);
super(33,"DefineText2", data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
characterID = sis.readUI16();
textBounds = sis.readRECT();
@@ -96,13 +96,4 @@ public class DefineText2Tag extends Tag implements CharacterTag {
}
}
/**
* Returns string representation of the object
*
* @return String representation of the object
*/
@Override
public String toString() {
return "DefineText2";
}
}

View File

@@ -34,7 +34,7 @@ import java.util.List;
*
* @author JPEXS
*/
public class DefineTextTag extends Tag implements CharacterTag{
public class DefineTextTag extends CharacterTag{
public int characterID;
public RECT textBounds;
@@ -49,7 +49,7 @@ public class DefineTextTag extends Tag implements CharacterTag{
}
public DefineTextTag(int characterID, RECT textBounds, MATRIX textMatrix, int glyphBits, int advanceBits, List<TEXTRECORD> textRecords) {
super(11, new byte[0], 0);
super(11,"DefineText", new byte[0], 0);
this.characterID = characterID;
this.textBounds = textBounds;
this.textMatrix = textMatrix;
@@ -94,7 +94,7 @@ public class DefineTextTag extends Tag implements CharacterTag{
* @throws IOException
*/
public DefineTextTag(byte data[], int version, long pos) throws IOException {
super(11, data, pos);
super(11,"DefineText", data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
characterID = sis.readUI16();
textBounds = sis.readRECT();
@@ -107,14 +107,4 @@ public class DefineTextTag extends Tag implements CharacterTag{
textRecords.add(tr);
}
}
/**
* Returns string representation of the object
*
* @return String representation of the object
*/
@Override
public String toString() {
return "DefineText";
}
}

View File

@@ -29,7 +29,7 @@ import java.io.OutputStream;
*
* @author JPEXS
*/
public class DefineVideoStreamTag extends Tag implements CharacterTag {
public class DefineVideoStreamTag extends CharacterTag {
public int characterID;
public int numFrames;
@@ -77,7 +77,7 @@ public class DefineVideoStreamTag extends Tag implements CharacterTag {
* @throws IOException
*/
public DefineVideoStreamTag(byte data[], int version, long pos) throws IOException {
super(60, data, pos);
super(60, "DefineVideoStream",data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
characterID = sis.readUI16();
numFrames = sis.readUI16();
@@ -89,13 +89,4 @@ public class DefineVideoStreamTag extends Tag implements CharacterTag {
codecID = sis.readUI8();
}
/**
* Returns string representation of the object
*
* @return String representation of the object
*/
@Override
public String toString() {
return "DefineVideoStream";
}
}

View File

@@ -44,15 +44,13 @@ public class DoABCTag extends Tag implements Comparable<DoABCTag> {
*/
public String name;
/**
* Returns string representation of the object
*
* @return String representation of the object
*/
@Override
public String toString() {
public String getName() {
return "DoABC (" + name + ")";
}
/**
* Constructor
@@ -62,7 +60,7 @@ public class DoABCTag extends Tag implements Comparable<DoABCTag> {
* @throws IOException
*/
public DoABCTag(byte[] data, int version, long pos) throws IOException {
super(82, data, pos);
super(82,"DoABC",data, pos);
InputStream is = new ByteArrayInputStream(data);
SWFInputStream sis = new SWFInputStream(is, version);
flags = sis.readUI32();

View File

@@ -46,7 +46,7 @@ public class DoActionTag extends Tag implements ASMSource {
* @throws IOException
*/
public DoActionTag(byte[] data, int version, long pos) {
super(12, data, pos);
super(12, "DoAction",data, pos);
try {
ByteArrayInputStream bais = new ByteArrayInputStream(data);
SWFInputStream sis = new SWFInputStream(bais, version);

View File

@@ -20,7 +20,7 @@ import com.jpexs.asdec.SWFInputStream;
import com.jpexs.asdec.SWFOutputStream;
import com.jpexs.asdec.action.Action;
import com.jpexs.asdec.tags.base.ASMSource;
import com.jpexs.asdec.tags.base.TagName;
import com.jpexs.asdec.tags.base.CharacterTag;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -29,7 +29,7 @@ import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
public class DoInitActionTag extends Tag implements ASMSource, TagName {
public class DoInitActionTag extends CharacterTag implements ASMSource {
/**
* Identifier of Sprite
@@ -39,11 +39,7 @@ public class DoInitActionTag extends Tag implements ASMSource, TagName {
* List of actions to perform
*/
//public List<Action> actions = new ArrayList<Action>();
public byte[] actionBytes;
/**
* List of ExportAssetsTag used for converting to String
*/
public List<ExportAssetsTag> exportAssetsTags = new ArrayList<ExportAssetsTag>();
public byte[] actionBytes;
/**
* Constructor
@@ -53,7 +49,7 @@ public class DoInitActionTag extends Tag implements ASMSource, TagName {
* @throws IOException
*/
public DoInitActionTag(byte[] data, int version, long pos) throws IOException {
super(59, data, pos);
super(59, "DoInitAction",data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
spriteId = sis.readUI16();
//actions = sis.readActionList();
@@ -78,23 +74,7 @@ public class DoInitActionTag extends Tag implements ASMSource, TagName {
} catch (IOException e) {
}
return baos.toByteArray();
}
@Override
public String toString() {
String name = "";
for (ExportAssetsTag eat : exportAssetsTags) {
int pos = eat.tags.indexOf(spriteId);
if (pos > -1) {
name = ": " + eat.names.get(pos);
}
}
return "DoInitAction (" + spriteId + name + ")";
}
public String getName() {
return "DoInitAction" + spriteId;
}
}
/**
* Whether or not this object contains ASM source
@@ -141,4 +121,9 @@ public class DoInitActionTag extends Tag implements ASMSource, TagName {
public void setActionBytes(byte[] actionBytes) {
this.actionBytes = actionBytes;
}
@Override
public int getCharacterID() {
return spriteId;
}
}

View File

@@ -64,19 +64,10 @@ public class EnableDebugger2Tag extends Tag {
* @throws IOException
*/
public EnableDebugger2Tag(byte data[], int version, long pos) throws IOException {
super(64, data, pos);
super(64,"EnableDebugger2", data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
reserved = sis.readUI16();
passwordHash = sis.readString();
}
/**
* Returns string representation of the object
*
* @return String representation of the object
*/
@Override
public String toString() {
return "EnableDebugger2";
}
}

View File

@@ -63,18 +63,8 @@ public class EnableDebuggerTag extends Tag {
* @throws IOException
*/
public EnableDebuggerTag(byte data[], int version, long pos) throws IOException {
super(58, data, pos);
super(58,"EnableDebugger", data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
passwordHash = sis.readString();
}
/**
* Returns string representation of the object
*
* @return String representation of the object
*/
@Override
public String toString() {
return "EnableDebugger";
}
}

View File

@@ -44,23 +44,13 @@ public class EndTag extends Tag {
* @throws IOException
*/
public EndTag(byte data[], int version, long pos) throws IOException {
super(0, data, pos);
super(0,"End", data, pos);
}
public EndTag() {
super(0, new byte[0], 0);
super(0,"End", new byte[0], 0);
}
/**
* Returns string representation of the object
*
* @return String representation of the object
*/
@Override
public String toString() {
return "End";
}
}

View File

@@ -46,7 +46,7 @@ public class ExportAssetsTag extends Tag {
* @throws IOException
*/
public ExportAssetsTag(byte[] data, int version, long pos) throws IOException {
super(56, data, pos);
super(56, "ExportAssets",data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
int count = sis.readUI16();
tags = new ArrayList<Integer>();
@@ -81,13 +81,4 @@ public class ExportAssetsTag extends Tag {
return baos.toByteArray();
}
/**
* Returns string representation of the object
*
* @return String representation of the object
*/
@Override
public String toString() {
return "ExportAssets";
}
}

View File

@@ -35,7 +35,7 @@ public class FileAttributesTag extends Tag {
private int reserved3;
public FileAttributesTag(byte[] data, int version, long pos) throws IOException {
super(69, data, pos);
super(69,"FileAttributes", data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
reserved1 = (int) sis.readUB(1); // reserved
// UB[1] == 0 (reserved)
@@ -74,8 +74,4 @@ public class FileAttributesTag extends Tag {
return baos.toByteArray();
}
@Override
public String toString() {
return "FileAttributes";
}
}

View File

@@ -29,7 +29,7 @@ public class FrameLabelTag extends Tag {
private boolean namedAnchor = false;
public FrameLabelTag(byte[] data, int version, long pos) throws IOException {
super(43, data, pos);
super(43,"FrameLabel", data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
name = sis.readString();
if (sis.available() > 0) {
@@ -39,10 +39,6 @@ public class FrameLabelTag extends Tag {
}
}
@Override
public String toString() {
return "FrameLabel";
}
/**
* Gets data bytes

View File

@@ -45,7 +45,7 @@ public class ImportAssets2Tag extends Tag {
* @throws IOException
*/
public ImportAssets2Tag(byte data[], int version, long pos) throws IOException {
super(57, data, pos);
super(57, "ImportAssets2",data, pos);
assets = new HashMap<Integer, String>();
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
url = sis.readString();
@@ -84,13 +84,4 @@ public class ImportAssets2Tag extends Tag {
return baos.toByteArray();
}
/**
* Returns string representation of the object
*
* @return String representation of the object
*/
@Override
public String toString() {
return "ImportAssets2";
}
}

View File

@@ -45,7 +45,7 @@ public class ImportAssetsTag extends Tag {
* @throws IOException
*/
public ImportAssetsTag(byte data[], int version, long pos) throws IOException {
super(57, data, pos);
super(57,"ImportAssets", data, pos);
assets = new HashMap<Integer, String>();
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
url = sis.readString();
@@ -79,14 +79,4 @@ public class ImportAssetsTag extends Tag {
}
return baos.toByteArray();
}
/**
* Returns string representation of the object
*
* @return String representation of the object
*/
@Override
public String toString() {
return "ImportAssets";
}
}

View File

@@ -21,11 +21,7 @@ import java.io.IOException;
public class JPEGTablesTag extends Tag {
public JPEGTablesTag(byte[] data, long pos) throws IOException {
super(8, data, pos); //data is JPEG data
super(8, "JPEGTables",data, pos); //data is JPEG data
}
@Override
public String toString() {
return "JPEGTables";
}
}

View File

@@ -28,7 +28,7 @@ public class MetadataTag extends Tag {
public String xmlMetadata;
public MetadataTag(byte[] data, int version, long pos) {
super(77, data, pos);
super(77,"Metadata", data, pos);
try {
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
xmlMetadata = sis.readString();
@@ -54,8 +54,4 @@ public class MetadataTag extends Tag {
return baos.toByteArray();
}
@Override
public String toString() {
return "Metadata";
}
}

View File

@@ -1,36 +0,0 @@
/*
* Copyright (C) 2010-2011 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.asdec.tags;
/**
*
* @author JPEXS
*/
public class NotDefinedTag extends Tag {
private String name;
public NotDefinedTag(String name, int id, byte[] data, long pos) {
super(id, data, pos);
this.name = name;
}
@Override
public String toString() {
return name;
}
}

View File

@@ -158,7 +158,7 @@ public class PlaceObject2Tag extends Tag implements Container {
}
public PlaceObject2Tag(boolean placeFlagHasClipActions, boolean placeFlagHasClipDepth, boolean placeFlagHasName, boolean placeFlagHasRatio, boolean placeFlagHasColorTransform, boolean placeFlagHasMatrix, boolean placeFlagHasCharacter, boolean placeFlagMove, int depth, int characterId, MATRIX matrix, CXFORMWITHALPHA colorTransform, int ratio, String name, int clipDepth, CLIPACTIONS clipActions) {
super(26, new byte[0], 0);
super(26,"PlaceObject2", new byte[0], 0);
this.placeFlagHasClipActions = placeFlagHasClipActions;
this.placeFlagHasClipDepth = placeFlagHasClipDepth;
this.placeFlagHasName = placeFlagHasName;
@@ -187,7 +187,7 @@ public class PlaceObject2Tag extends Tag implements Container {
* @throws IOException
*/
public PlaceObject2Tag(byte data[], int version, long pos) throws IOException {
super(26, data, pos);
super(26,"PlaceObject2", data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
placeFlagHasClipActions = sis.readUB(1) == 1;
placeFlagHasClipDepth = sis.readUB(1) == 1;
@@ -221,16 +221,6 @@ public class PlaceObject2Tag extends Tag implements Container {
}
}
/**
* Returns string representation of the object
*
* @return String representation of the object
*/
@Override
public String toString() {
return "PlaceObject2";
}
/**
* Returns all sub-items
*

View File

@@ -228,7 +228,7 @@ public class PlaceObject3Tag extends Tag implements Container {
* @throws IOException
*/
public PlaceObject3Tag(byte data[], int version, long pos) throws IOException {
super(70, data, pos);
super(70,"PlaceObject3", data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
placeFlagHasClipActions = sis.readUB(1) == 1;
placeFlagHasClipDepth = sis.readUB(1) == 1;
@@ -287,16 +287,6 @@ public class PlaceObject3Tag extends Tag implements Container {
}
}
/**
* Returns string representation of the object
*
* @return String representation of the object
*/
@Override
public String toString() {
return "PlaceObject3";
}
/**
* Returns all sub-items
*

View File

@@ -80,7 +80,7 @@ public class PlaceObjectTag extends Tag {
* @throws IOException
*/
public PlaceObjectTag(byte data[], int version, long pos) throws IOException {
super(4, data, pos);
super(4,"PlaceObject", data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
characterId = sis.readUI16();
depth = sis.readUI16();
@@ -91,7 +91,7 @@ public class PlaceObjectTag extends Tag {
}
public PlaceObjectTag(int characterId, int depth, MATRIX matrix, CXFORM colorTransform) {
super(4, new byte[0], 0);
super(4,"PlaceObject", new byte[0], 0);
this.characterId = characterId;
this.depth = depth;
this.matrix = matrix;
@@ -99,14 +99,5 @@ public class PlaceObjectTag extends Tag {
}
/**
* Returns string representation of the object
*
* @return String representation of the object
*/
@Override
public String toString() {
return "PlaceObject";
}
}

View File

@@ -31,7 +31,7 @@ public class ProductInfoTag extends Tag {
public long compilationDate;
public ProductInfoTag(byte[] data, int version, long pos) throws IOException {
super(41, data, pos);
super(41, "ProductInfo",data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
/*
* 0: Unknown
@@ -59,8 +59,4 @@ public class ProductInfoTag extends Tag {
compilationDate |= sis.readUI32() << 32;
}
@Override
public String toString() {
return "ProductInfo";
}
}

View File

@@ -63,20 +63,10 @@ public class ProtectTag extends Tag {
* @throws IOException
*/
public ProtectTag(byte data[], int version, long pos) throws IOException {
super(24, data, pos);
super(24,"Protect", data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
if (sis.available() > 0) {
passwordHash = sis.readString();
}
}
/**
* Returns string representation of the object
*
* @return String representation of the object
*/
@Override
public String toString() {
return "Protect";
}
}

View File

@@ -25,13 +25,8 @@ public class RemoveObject2Tag extends Tag {
public int depth;
public RemoveObject2Tag(byte[] data, int version, long pos) throws IOException {
super(28, data, pos);
super(28,"RemoveObject2",data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
depth = sis.readUI16();
}
@Override
public String toString() {
return "RemoveObject2";
}
}

View File

@@ -66,19 +66,10 @@ public class RemoveObjectTag extends Tag {
* @throws IOException
*/
public RemoveObjectTag(byte data[], int version, long pos) throws IOException {
super(5, data, pos);
super(5,"RemoveObject", data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
characterId = sis.readUI16();
depth = sis.readUI16();
}
/**
* Returns string representation of the object
*
* @return String representation of the object
*/
@Override
public String toString() {
return "RemoveObject";
}
}

View File

@@ -29,7 +29,7 @@ public class ScriptLimitsTag extends Tag {
public int scriptTimeoutSeconds;
public ScriptLimitsTag(byte[] data, int version, long pos) throws IOException {
super(65, data, pos);
super(65,"ScriptLimits", data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
maxRecursionDepth = sis.readUI16();
scriptTimeoutSeconds = sis.readUI16();
@@ -53,9 +53,4 @@ public class ScriptLimitsTag extends Tag {
}
return baos.toByteArray();
}
@Override
public String toString() {
return "ScriptLimits";
}
}

View File

@@ -29,13 +29,13 @@ public class SetBackgroundColorTag extends Tag {
public RGB backgroundColor;
public SetBackgroundColorTag(byte[] data, int version, long pos) throws IOException {
super(9, data, pos);
super(9,"SetBackgroundColor", data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
backgroundColor = sis.readRGB();
}
public SetBackgroundColorTag(RGB backgroundColor) {
super(9, new byte[0], 0);
super(9,"SetBackgroundColor", new byte[0], 0);
this.backgroundColor = backgroundColor;
}
@@ -51,9 +51,5 @@ public class SetBackgroundColorTag extends Tag {
}
@Override
public String toString() {
return "SetBackgroundColor";
}
}

View File

@@ -66,19 +66,10 @@ public class SetTabIndexTag extends Tag {
* @throws IOException
*/
public SetTabIndexTag(byte data[], int version, long pos) throws IOException {
super(66, data, pos);
super(66,"SetTabIndex", data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
depth = sis.readUI16();
tabIndex = sis.readUI16();
}
/**
* Returns string representation of the object
*
* @return String representation of the object
*/
@Override
public String toString() {
return "SetTabIndex";
}
}

View File

@@ -27,11 +27,11 @@ public class ShowFrameTag extends Tag {
* Constructor
*/
public ShowFrameTag(long pos) {
super(1, new byte[0], pos);
super(1,"ShowFrame", new byte[0], pos);
}
public ShowFrameTag(){
super(1, new byte[0], 0);
super(1,"ShowFrame", new byte[0], 0);
}
/**
@@ -45,13 +45,4 @@ public class ShowFrameTag extends Tag {
return super.getData(version);
}
/**
* Returns string representation of the object
*
* @return String representation of the object
*/
@Override
public String toString() {
return "ShowFrame";
}
}

View File

@@ -33,16 +33,6 @@ public class SoundStreamBlockTag extends Tag {
* @throws IOException
*/
public SoundStreamBlockTag(byte data[], int version, long pos) throws IOException {
super(19, data, pos); //all data is streamSoundData
}
/**
* Returns string representation of the object
*
* @return String representation of the object
*/
@Override
public String toString() {
return "SoundStreamBlock";
super(19,"SoundStreamBlock", data, pos); //all data is streamSoundData
}
}

View File

@@ -77,7 +77,7 @@ public class SoundStreamHead2Tag extends Tag {
* @throws IOException
*/
public SoundStreamHead2Tag(byte data[], int version, long pos) throws IOException {
super(45, data, pos);
super(45,"SoundStreamHead2", data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
sis.readUB(4);//reserved
playBackSoundRate = (int) sis.readUB(2);
@@ -92,14 +92,4 @@ public class SoundStreamHead2Tag extends Tag {
latencySeek = sis.readSI16();
}
}
/**
* Returns string representation of the object
*
* @return String representation of the object
*/
@Override
public String toString() {
return "SoundStreamHead2";
}
}

View File

@@ -77,7 +77,7 @@ public class SoundStreamHeadTag extends Tag {
* @throws IOException
*/
public SoundStreamHeadTag(byte data[], int version, long pos) throws IOException {
super(18, data, pos);
super(18,"SoundStreamHead", data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
sis.readUB(4);//reserved
playBackSoundRate = (int) sis.readUB(2);
@@ -92,14 +92,4 @@ public class SoundStreamHeadTag extends Tag {
latencySeek = sis.readSI16();
}
}
/**
* Returns string representation of the object
*
* @return String representation of the object
*/
@Override
public String toString() {
return "SoundStreamHead";
}
}

View File

@@ -60,19 +60,10 @@ public class StartSound2Tag extends Tag {
* @throws IOException
*/
public StartSound2Tag(byte data[], int version, long pos) throws IOException {
super(89, data, pos);
super(89,"StartSound2", data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
soundClassName = sis.readString();
soundInfo = sis.readSOUNDINFO();
}
/**
* Returns string representation of the object
*
* @return String representation of the object
*/
@Override
public String toString() {
return "StartSound2";
}
}

View File

@@ -61,19 +61,9 @@ public class StartSoundTag extends Tag {
* @throws IOException
*/
public StartSoundTag(byte data[], int version, long pos) throws IOException {
super(15, data, pos);
super(15,"StartSound", data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
soundId = sis.readUI16();
soundInfo = sis.readSOUNDINFO();
}
/**
* Returns string representation of the object
*
* @return String representation of the object
*/
@Override
public String toString() {
return "StartSound";
}
}

View File

@@ -29,7 +29,7 @@ public class SymbolClassTag extends Tag {
public String classNames[];
public SymbolClassTag(byte[] data, int version, long pos) throws IOException {
super(76, data, pos);
super(76,"SymbolClass", data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
int numSymbols = sis.readUI16();
tagIDs = new int[numSymbols];
@@ -64,9 +64,4 @@ public class SymbolClassTag extends Tag {
}
return baos.toByteArray();
}
@Override
public String toString() {
return "SymbolClass";
}
}

View File

@@ -37,7 +37,18 @@ public class Tag {
*/
public boolean forceWriteAsLong = false;
private final long pos;
protected String name;
public String getName() {
return name;
}
public String getExportName(){
return getName();
}
/**
* Returns identifier of tag type
*
@@ -51,10 +62,12 @@ public class Tag {
* Constructor
*
* @param id Tag type identifier
* @param name Tag name
* @param data Bytes of data
*/
public Tag(int id, byte[] data, long pos) {
public Tag(int id, String name, byte[] data, long pos) {
this.id = id;
this.name = name;
this.data = data;
this.pos = pos;
}
@@ -85,7 +98,7 @@ public class Tag {
*/
@Override
public String toString() {
return "Tag id:" + id;
return getName();
}
public final long getOrigDataLength() {

View File

@@ -56,18 +56,8 @@ public class TagStub extends Tag {
* @throws IOException
*/
public TagStub(byte data[], int version, long pos) throws IOException {
super(0, data, pos);
super(0,"", data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
}
/**
* Returns string representation of the object
*
* @return String representation of the object
*/
@Override
public String toString() {
return "";
}
}

View File

@@ -62,20 +62,10 @@ public class VideoFrameTag extends Tag {
* @throws IOException
*/
public VideoFrameTag(byte data[], int version, long pos) throws IOException {
super(61, data, pos);
super(61,"VideoFrame", data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
streamID = sis.readUI16();
frameNum = sis.readUI16();
videoData = sis.readBytes(sis.available()); //TODO: Parse video packets
}
/**
* Returns string representation of the object
*
* @return String representation of the object
*/
@Override
public String toString() {
return "VideoFrame";
}
}

View File

@@ -1,9 +1,46 @@
package com.jpexs.asdec.tags.base;
import com.jpexs.asdec.tags.ExportAssetsTag;
import com.jpexs.asdec.tags.Tag;
import java.util.ArrayList;
import java.util.List;
/**
*
* @author JPEXS
*/
public interface CharacterTag {
public int getCharacterID();
public abstract class CharacterTag extends Tag {
public CharacterTag(int id, String name, byte[] data, long pos) {
super(id, name, data, pos);
}
public abstract int getCharacterID();
/**
* List of ExportAssetsTag used for converting to String
*/
public List<ExportAssetsTag> exportAssetsTags = new ArrayList<ExportAssetsTag>();
@Override
public String getName() {
String nameAppend = "";
for (ExportAssetsTag eat : exportAssetsTags) {
int pos = eat.tags.indexOf(getCharacterID());
if (pos > -1) {
nameAppend = ": " + eat.names.get(pos);
}
}
return super.getName()+" (" + getCharacterID() + nameAppend + ")";
}
@Override
public String getExportName() {
return super.getName()+"_"+getCharacterID();
}
}

Some files were not shown because too many files have changed in this diff Show More