mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-25 10:50:47 +00:00
prepare for Issue #350 (Allow to open multiple SWF files into the same ffdec instance), some action commands moved to constants
This commit is contained in:
@@ -22,16 +22,22 @@ package com.jpexs.decompiler.flash;
|
||||
*/
|
||||
public class FrameNode {
|
||||
|
||||
private SWF swf;
|
||||
private int frame;
|
||||
private Object parent;
|
||||
private boolean display;
|
||||
|
||||
public FrameNode(int frame, Object parent, boolean display) {
|
||||
public FrameNode(SWF swf, int frame, Object parent, boolean display) {
|
||||
this.swf = swf;
|
||||
this.frame = frame;
|
||||
this.parent = parent;
|
||||
this.display = display;
|
||||
}
|
||||
|
||||
public SWF getSwf() {
|
||||
return swf;
|
||||
}
|
||||
|
||||
public boolean isDisplayed() {
|
||||
return display;
|
||||
}
|
||||
|
||||
@@ -781,7 +781,7 @@ public final class SWF {
|
||||
}
|
||||
TagNode addNode = null;
|
||||
if (t instanceof ShowFrameTag) {
|
||||
TagNode tti = new TagNode(new FrameNode(frame, parent, false));
|
||||
TagNode tti = new TagNode(new FrameNode(t.getSwf(), frame, parent, false));
|
||||
|
||||
for (int r = ret.size() - 1; r >= 0; r--) {
|
||||
if (!(ret.get(r).tag instanceof DefineSpriteTag)) {
|
||||
|
||||
@@ -1444,8 +1444,8 @@ public class SWFInputStream extends InputStream {
|
||||
* @return CLIPACTIONRECORD value
|
||||
* @throws IOException
|
||||
*/
|
||||
public CLIPACTIONRECORD readCLIPACTIONRECORD() throws IOException {
|
||||
CLIPACTIONRECORD ret = new CLIPACTIONRECORD(this, version, getPos());
|
||||
public CLIPACTIONRECORD readCLIPACTIONRECORD(SWF swf) throws IOException {
|
||||
CLIPACTIONRECORD ret = new CLIPACTIONRECORD(swf, this, version, getPos());
|
||||
if (ret.eventFlags.isClear()) {
|
||||
return null;
|
||||
}
|
||||
@@ -1459,13 +1459,13 @@ public class SWFInputStream extends InputStream {
|
||||
* @return CLIPACTIONS value
|
||||
* @throws IOException
|
||||
*/
|
||||
public CLIPACTIONS readCLIPACTIONS() throws IOException {
|
||||
public CLIPACTIONS readCLIPACTIONS(SWF swf) throws IOException {
|
||||
CLIPACTIONS ret = new CLIPACTIONS();
|
||||
readUI16();//reserved
|
||||
ret.allEventFlags = readCLIPEVENTFLAGS();
|
||||
CLIPACTIONRECORD cr;
|
||||
ret.clipActionRecords = new ArrayList<>();
|
||||
while ((cr = readCLIPACTIONRECORD()) != null) {
|
||||
while ((cr = readCLIPACTIONRECORD(swf)) != null) {
|
||||
ret.clipActionRecords.add(cr);
|
||||
}
|
||||
return ret;
|
||||
@@ -1809,10 +1809,10 @@ public class SWFInputStream extends InputStream {
|
||||
* @return List of BUTTONCONDACTION values
|
||||
* @throws IOException
|
||||
*/
|
||||
public List<BUTTONCONDACTION> readBUTTONCONDACTIONList() throws IOException {
|
||||
public List<BUTTONCONDACTION> readBUTTONCONDACTIONList(SWF swf) throws IOException {
|
||||
List<BUTTONCONDACTION> ret = new ArrayList<>();
|
||||
BUTTONCONDACTION bc;
|
||||
while (!(bc = readBUTTONCONDACTION()).isLast) {
|
||||
while (!(bc = readBUTTONCONDACTION(swf)).isLast) {
|
||||
ret.add(bc);
|
||||
}
|
||||
ret.add(bc);
|
||||
@@ -1825,8 +1825,8 @@ public class SWFInputStream extends InputStream {
|
||||
* @return BUTTONCONDACTION value
|
||||
* @throws IOException
|
||||
*/
|
||||
public BUTTONCONDACTION readBUTTONCONDACTION() throws IOException {
|
||||
BUTTONCONDACTION ret = new BUTTONCONDACTION(this, version, getPos());
|
||||
public BUTTONCONDACTION readBUTTONCONDACTION(SWF swf) throws IOException {
|
||||
BUTTONCONDACTION ret = new BUTTONCONDACTION(swf, this, version, getPos());
|
||||
//ret.actions = readActionList();
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -47,6 +47,9 @@ import javax.swing.JTextField;
|
||||
*/
|
||||
public class FontEmbedDialog extends AppDialog implements ActionListener {
|
||||
|
||||
static final String ACTION_OK = "OK";
|
||||
static final String ACTION_CANCEL = "CANCEL";
|
||||
|
||||
private JComboBox<String> sourceFont;
|
||||
private JCheckBox[] rangeCheckboxes;
|
||||
private String rangeNames[];
|
||||
@@ -130,10 +133,10 @@ public class FontEmbedDialog extends AppDialog implements ActionListener {
|
||||
|
||||
JPanel buttonsPanel = new JPanel(new FlowLayout());
|
||||
JButton okButton = new JButton(AppStrings.translate("button.ok"));
|
||||
okButton.setActionCommand("OK");
|
||||
okButton.setActionCommand(ACTION_OK);
|
||||
okButton.addActionListener(this);
|
||||
JButton cancelButton = new JButton(AppStrings.translate("button.cancel"));
|
||||
cancelButton.setActionCommand("CANCEL");
|
||||
cancelButton.setActionCommand(ACTION_CANCEL);
|
||||
cancelButton.addActionListener(this);
|
||||
buttonsPanel.add(okButton);
|
||||
buttonsPanel.add(cancelButton);
|
||||
@@ -198,11 +201,11 @@ public class FontEmbedDialog extends AppDialog implements ActionListener {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
switch (e.getActionCommand()) {
|
||||
case "OK":
|
||||
case ACTION_OK:
|
||||
result = true;
|
||||
setVisible(false);
|
||||
break;
|
||||
case "CANCEL":
|
||||
case ACTION_CANCEL:
|
||||
result = false;
|
||||
setVisible(false);
|
||||
break;
|
||||
|
||||
@@ -38,6 +38,8 @@ import javax.swing.JPanel;
|
||||
|
||||
public final class ImagePanel extends JPanel implements ActionListener, FlashDisplay {
|
||||
|
||||
static final String ACTION_SELECT_COLOR = "SELECTCOLOR";
|
||||
|
||||
public JLabel label = new JLabel();
|
||||
public DrawableTag drawable;
|
||||
private Timer timer;
|
||||
@@ -68,7 +70,7 @@ public final class ImagePanel extends JPanel implements ActionListener, FlashDis
|
||||
JPanel buttonsPanel = new JPanel(new FlowLayout());
|
||||
JButton selectColorButton = new JButton(View.getIcon("color16"));
|
||||
selectColorButton.addActionListener(this);
|
||||
selectColorButton.setActionCommand("SELECTCOLOR");
|
||||
selectColorButton.setActionCommand(ACTION_SELECT_COLOR);
|
||||
selectColorButton.setToolTipText(AppStrings.translate("button.selectcolor.hint"));
|
||||
buttonsPanel.add(selectColorButton);
|
||||
bottomPanel.add(buttonsPanel, BorderLayout.EAST);
|
||||
@@ -77,7 +79,7 @@ public final class ImagePanel extends JPanel implements ActionListener, FlashDis
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if ("SELECTCOLOR".equals(e.getActionCommand())) {
|
||||
if (e.getActionCommand() == ACTION_SELECT_COLOR) {
|
||||
View.execInEventDispatch(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
@@ -55,6 +55,10 @@ import javax.swing.filechooser.FileFilter;
|
||||
*/
|
||||
public class LoadFromCacheFrame extends AppFrame implements ActionListener {
|
||||
|
||||
static final String ACTION_OPEN = "OPEN";
|
||||
static final String ACTION_SAVE = "SAVE";
|
||||
static final String ACTION_REFRESH = "REFRESH";
|
||||
|
||||
private JList<CacheEntry> list;
|
||||
private JTextField searchField;
|
||||
private List<CacheImplementation> caches;
|
||||
@@ -105,17 +109,17 @@ public class LoadFromCacheFrame extends AppFrame implements ActionListener {
|
||||
JPanel buttonsPanel = new JPanel(new FlowLayout());
|
||||
|
||||
openButton = new JButton(translate("button.open"));
|
||||
openButton.setActionCommand("OPEN");
|
||||
openButton.setActionCommand(ACTION_OPEN);
|
||||
openButton.addActionListener(this);
|
||||
buttonsPanel.add(openButton);
|
||||
|
||||
saveButton = new JButton(translate("button.save"));
|
||||
saveButton.setActionCommand("SAVE");
|
||||
saveButton.setActionCommand(ACTION_SAVE);
|
||||
saveButton.addActionListener(this);
|
||||
buttonsPanel.add(saveButton);
|
||||
|
||||
refreshButton = new JButton(translate("button.refresh"));
|
||||
refreshButton.setActionCommand("REFRESH");
|
||||
refreshButton.setActionCommand(ACTION_REFRESH);
|
||||
refreshButton.addActionListener(this);
|
||||
buttonsPanel.add(refreshButton);
|
||||
|
||||
@@ -228,13 +232,13 @@ public class LoadFromCacheFrame extends AppFrame implements ActionListener {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
switch (e.getActionCommand()) {
|
||||
case "REFRESH":
|
||||
case ACTION_REFRESH:
|
||||
refresh();
|
||||
break;
|
||||
case "OPEN":
|
||||
case ACTION_OPEN:
|
||||
openSWF();
|
||||
break;
|
||||
case "SAVE":
|
||||
case ACTION_SAVE:
|
||||
List<CacheEntry> selected = list.getSelectedValuesList();
|
||||
if (!selected.isEmpty()) {
|
||||
JFileChooser fc = new JFileChooser();
|
||||
|
||||
@@ -73,6 +73,11 @@ import javax.swing.filechooser.FileFilter;
|
||||
*/
|
||||
public class LoadFromMemoryFrame extends AppFrame implements ActionListener {
|
||||
|
||||
static final String ACTION_SELECT_PROCESS = "SELECTPROCESS";
|
||||
static final String ACTION_REFRESH_PROCESS_LIST = "REFRESHPROCESSLIST";
|
||||
static final String ACTION_OPEN_SWF = "OPENSWF";
|
||||
static final String ACTION_SAVE = "SAVE";
|
||||
|
||||
private List<com.jpexs.process.Process> processlist;
|
||||
private List<ReReadableInputStream> foundIs;
|
||||
private com.jpexs.process.Process selProcess;
|
||||
@@ -292,10 +297,10 @@ public class LoadFromMemoryFrame extends AppFrame implements ActionListener {
|
||||
leftPanel.add(new JScrollPane(list), BorderLayout.CENTER);
|
||||
JPanel leftButtonsPanel = new JPanel(new FlowLayout());
|
||||
JButton selectButton = new JButton(translate("button.select"));
|
||||
selectButton.setActionCommand("SELECTPROCESS");
|
||||
selectButton.setActionCommand(ACTION_SELECT_PROCESS);
|
||||
selectButton.addActionListener(this);
|
||||
JButton refreshButton = new JButton(translate("button.refresh"));
|
||||
refreshButton.setActionCommand("REFRESHPROCESSLIST");
|
||||
refreshButton.setActionCommand(ACTION_REFRESH_PROCESS_LIST);
|
||||
refreshButton.addActionListener(this);
|
||||
leftButtonsPanel.add(selectButton);
|
||||
leftButtonsPanel.add(refreshButton);
|
||||
@@ -305,11 +310,11 @@ public class LoadFromMemoryFrame extends AppFrame implements ActionListener {
|
||||
rightPanel.add(new JScrollPane(listRes), BorderLayout.CENTER);
|
||||
JPanel rightButtonsPanel = new JPanel(new FlowLayout());
|
||||
JButton openButton = new JButton(translate("button.open"));
|
||||
openButton.setActionCommand("OPENSWF");
|
||||
openButton.setActionCommand(ACTION_OPEN_SWF);
|
||||
openButton.addActionListener(this);
|
||||
|
||||
JButton saveButton = new JButton(translate("button.save"));
|
||||
saveButton.setActionCommand("SAVE");
|
||||
saveButton.setActionCommand(ACTION_SAVE);
|
||||
saveButton.addActionListener(this);
|
||||
|
||||
rightButtonsPanel.add(openButton);
|
||||
@@ -336,16 +341,16 @@ public class LoadFromMemoryFrame extends AppFrame implements ActionListener {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
switch (e.getActionCommand()) {
|
||||
case "SELECTPROCESS":
|
||||
case ACTION_SELECT_PROCESS:
|
||||
selectProcess();
|
||||
break;
|
||||
case "OPENSWF":
|
||||
case ACTION_OPEN_SWF:
|
||||
openSWF();
|
||||
break;
|
||||
case "REFRESHPROCESSLIST":
|
||||
case ACTION_REFRESH_PROCESS_LIST:
|
||||
refreshList();
|
||||
break;
|
||||
case "SAVE":
|
||||
case ACTION_SAVE:
|
||||
if (foundIs == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -203,7 +203,7 @@ import org.pushingpixels.flamingo.internal.ui.ribbon.appmenu.JRibbonApplicationM
|
||||
*/
|
||||
public final class MainFrame extends AppRibbonFrame implements ActionListener, TreeSelectionListener, Freed {
|
||||
|
||||
private SWF swf;
|
||||
private List<SWF> swfs;
|
||||
public ABCPanel abcPanel;
|
||||
public ActionPanel actionPanel;
|
||||
private MainFrameStatusPanel statusPanel;
|
||||
@@ -437,7 +437,7 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T
|
||||
imageButtonsPanel.setVisible(visible);
|
||||
}
|
||||
|
||||
public MainFrame(SWF swf) {
|
||||
public MainFrame(final SWF swf) {
|
||||
super();
|
||||
|
||||
List<ContainerItem> objs = new ArrayList<>();
|
||||
@@ -523,7 +523,7 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T
|
||||
});
|
||||
setTitle(ApplicationInfo.applicationVerName + ((swf != null && Configuration.displayFileName.get()) ? " - " + Main.getFileTitle() : ""));
|
||||
|
||||
this.swf = swf;
|
||||
this.swfs = Arrays.asList(swf);
|
||||
java.awt.Container cnt = getContentPane();
|
||||
cnt.setLayout(new BorderLayout());
|
||||
cnt.add(getRibbon(), BorderLayout.NORTH);
|
||||
@@ -547,7 +547,7 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T
|
||||
if (swf == null) {
|
||||
tagTree = new JTree((TreeModel) null);
|
||||
} else {
|
||||
tagTree = new JTree(new TagTreeModel(createTagList(objs, null), new SWFRoot((new File(Main.file)).getName())));
|
||||
tagTree = new JTree(new TagTreeModel(this, swfs, abcPanel));
|
||||
}
|
||||
tagTree.addTreeSelectionListener(this);
|
||||
tagTree.setBackground(Color.white);
|
||||
@@ -598,7 +598,7 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T
|
||||
|
||||
try {
|
||||
File ftemp = new File(tempDir);
|
||||
files = exportSelection(errorHandler, tempDir, export);
|
||||
files = exportSelection(swf, errorHandler, tempDir, export);
|
||||
files.clear();
|
||||
|
||||
File[] fs = ftemp.listFiles();
|
||||
@@ -664,14 +664,15 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T
|
||||
if (val instanceof TagNode) {
|
||||
val = ((TagNode) val).tag;
|
||||
}
|
||||
String type = getTagType(val);
|
||||
TagType type = getTagType(val);
|
||||
if (row == 0) {
|
||||
setIcon(View.getIcon("flash16"));
|
||||
} else if (type != null) {
|
||||
if (type.equals("folder") && expanded) {
|
||||
type = "folderopen";
|
||||
if (type == TagType.FOLDER && expanded) {
|
||||
type = TagType.FOLDER_OPEN;
|
||||
}
|
||||
setIcon(View.getIcon(type + "16"));
|
||||
String tagTypeStr = type.toString().toLowerCase().replace("_", "");
|
||||
setIcon(View.getIcon(tagTypeStr + "16"));
|
||||
//setToolTipText("This book is in the Tutorial series.");
|
||||
} else {
|
||||
//setToolTipText(null); //no tool tip
|
||||
@@ -1077,7 +1078,7 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T
|
||||
splitPos = splitPane2.getDividerLocation();
|
||||
splitsInited = true;
|
||||
if (Configuration.gotoMainClassOnStartup.get()) {
|
||||
gotoDocumentClass();
|
||||
gotoDocumentClass(getCurrentSwf());
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -1211,18 +1212,18 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T
|
||||
return ret;
|
||||
}
|
||||
|
||||
public String getTagType(Object t) {
|
||||
public static TagType getTagType(Object t) {
|
||||
if ((t instanceof DefineFontTag)
|
||||
|| (t instanceof DefineFont2Tag)
|
||||
|| (t instanceof DefineFont3Tag)
|
||||
|| (t instanceof DefineFont4Tag)
|
||||
|| (t instanceof DefineCompactedFont)) {
|
||||
return "font";
|
||||
return TagType.FONT;
|
||||
}
|
||||
if ((t instanceof DefineTextTag)
|
||||
|| (t instanceof DefineText2Tag)
|
||||
|| (t instanceof DefineEditTextTag)) {
|
||||
return "text";
|
||||
return TagType.TEXT;
|
||||
}
|
||||
|
||||
if ((t instanceof DefineBitsTag)
|
||||
@@ -1231,88 +1232,73 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T
|
||||
|| (t instanceof DefineBitsJPEG4Tag)
|
||||
|| (t instanceof DefineBitsLosslessTag)
|
||||
|| (t instanceof DefineBitsLossless2Tag)) {
|
||||
return "image";
|
||||
return TagType.IMAGE;
|
||||
}
|
||||
if ((t instanceof DefineShapeTag)
|
||||
|| (t instanceof DefineShape2Tag)
|
||||
|| (t instanceof DefineShape3Tag)
|
||||
|| (t instanceof DefineShape4Tag)) {
|
||||
return "shape";
|
||||
return TagType.SHAPE;
|
||||
}
|
||||
|
||||
if ((t instanceof DefineMorphShapeTag) || (t instanceof DefineMorphShape2Tag)) {
|
||||
return "morphshape";
|
||||
return TagType.MORPH_SHAPE;
|
||||
}
|
||||
|
||||
if (t instanceof DefineSpriteTag) {
|
||||
return "sprite";
|
||||
return TagType.SPRITE;
|
||||
}
|
||||
if ((t instanceof DefineButtonTag) || (t instanceof DefineButton2Tag)) {
|
||||
return "button";
|
||||
return TagType.BUTTON;
|
||||
}
|
||||
if (t instanceof ASMSource) {
|
||||
return "as";
|
||||
return TagType.AS;
|
||||
}
|
||||
if (t instanceof TreeElement) {
|
||||
TreeElement te = (TreeElement) t;
|
||||
if (te.getItem() instanceof ScriptPack) {
|
||||
return "as";
|
||||
return TagType.AS;
|
||||
} else {
|
||||
return "package";
|
||||
return TagType.PACKAGE;
|
||||
}
|
||||
}
|
||||
if (t instanceof PackageNode) {
|
||||
return "package";
|
||||
return TagType.PACKAGE;
|
||||
}
|
||||
if (t instanceof FrameNode) {
|
||||
return "frame";
|
||||
return TagType.FRAME;
|
||||
}
|
||||
if (t instanceof ShowFrameTag) {
|
||||
return "showframe";
|
||||
return TagType.SHOW_FRAME;
|
||||
}
|
||||
|
||||
if (t instanceof DefineVideoStreamTag) {
|
||||
return "movie";
|
||||
return TagType.MOVIE;
|
||||
}
|
||||
|
||||
if ((t instanceof DefineSoundTag) || (t instanceof SoundStreamHeadTag) || (t instanceof SoundStreamHead2Tag)) {
|
||||
return "sound";
|
||||
return TagType.SOUND;
|
||||
}
|
||||
|
||||
if (t instanceof DefineBinaryDataTag) {
|
||||
return "binaryData";
|
||||
return TagType.BINARY_DATA;
|
||||
}
|
||||
|
||||
return "folder";
|
||||
return TagType.FOLDER;
|
||||
}
|
||||
|
||||
public List<Object> getTagsWithType(List<Object> list, String type) {
|
||||
public List<Object> getTagsWithType(List<Object> list, TagType type) {
|
||||
List<Object> ret = new ArrayList<>();
|
||||
for (Object o : list) {
|
||||
String ttype = getTagType(o);
|
||||
if (type.equals(ttype)) {
|
||||
TagType ttype = getTagType(o);
|
||||
if (type == ttype) {
|
||||
ret.add(o);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public List<TagNode> getTagNodesWithType(List<? extends ContainerItem> list, String type, Object parent, boolean display) {
|
||||
List<TagNode> ret = new ArrayList<>();
|
||||
int frameCnt = 0;
|
||||
for (ContainerItem o : list) {
|
||||
String ttype = getTagType(o);
|
||||
if ("showframe".equals(ttype) && "frame".equals(type)) {
|
||||
frameCnt++;
|
||||
ret.add(new TagNode(new FrameNode(frameCnt, parent, display)));
|
||||
} else if (type.equals(ttype)) {
|
||||
ret.add(new TagNode(o));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void renameIdentifier(String identifier) throws InterruptedException {
|
||||
public void renameIdentifier(SWF swf, String identifier) throws InterruptedException {
|
||||
String oldName = identifier;
|
||||
String newName = View.showInputDialog(translate("rename.enternew"), oldName);
|
||||
if (newName != null) {
|
||||
@@ -1421,149 +1407,12 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<TagNode> createTagList(List<ContainerItem> list, Object parent) {
|
||||
List<TagNode> ret = new ArrayList<>();
|
||||
List<TagNode> frames = getTagNodesWithType(list, "frame", parent, true);
|
||||
List<TagNode> shapes = getTagNodesWithType(list, "shape", parent, true);
|
||||
List<TagNode> morphShapes = getTagNodesWithType(list, "morphshape", parent, true);
|
||||
List<TagNode> sprites = getTagNodesWithType(list, "sprite", parent, true);
|
||||
List<TagNode> buttons = getTagNodesWithType(list, "button", parent, true);
|
||||
List<TagNode> images = getTagNodesWithType(list, "image", parent, true);
|
||||
List<TagNode> fonts = getTagNodesWithType(list, "font", parent, true);
|
||||
List<TagNode> texts = getTagNodesWithType(list, "text", parent, true);
|
||||
List<TagNode> movies = getTagNodesWithType(list, "movie", parent, true);
|
||||
List<TagNode> sounds = getTagNodesWithType(list, "sound", parent, true);
|
||||
List<TagNode> binaryData = getTagNodesWithType(list, "binaryData", parent, true);
|
||||
List<TagNode> actionScript = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < sounds.size(); i++) {
|
||||
if (sounds.get(i).tag instanceof SoundStreamHeadTypeTag) {
|
||||
List<SoundStreamBlockTag> blocks = new ArrayList<>();
|
||||
SWF.populateSoundStreamBlocks(list, (Tag) sounds.get(i).tag, blocks);
|
||||
if (blocks.isEmpty()) {
|
||||
sounds.remove(i);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (TagNode n : sprites) {
|
||||
n.subItems = getTagNodesWithType(((DefineSpriteTag) n.tag).subTags, "frame", n.tag, true);
|
||||
}
|
||||
|
||||
List<ExportAssetsTag> exportAssetsTags = new ArrayList<>();
|
||||
for (Object t : list) {
|
||||
if (t instanceof ExportAssetsTag) {
|
||||
exportAssetsTags.add((ExportAssetsTag) t);
|
||||
}
|
||||
/*if (t instanceof ASMSource) {
|
||||
TagNode tti = new TagNode(t);
|
||||
ret.add(tti);
|
||||
} else */
|
||||
if (t instanceof Container) {
|
||||
TagNode tti = new TagNode(t);
|
||||
if (((Container) t).getItemCount() > 0) {
|
||||
List<ContainerItem> subItems = ((Container) t).getSubItems();
|
||||
tti.subItems = createTagList(subItems, t);
|
||||
}
|
||||
//ret.add(tti);
|
||||
}
|
||||
}
|
||||
|
||||
actionScript = SWF.createASTagList(list, null);
|
||||
TagNode textsNode = new TagNode(translate("node.texts"));
|
||||
textsNode.subItems.addAll(texts);
|
||||
|
||||
TagNode imagesNode = new TagNode(translate("node.images"));
|
||||
imagesNode.subItems.addAll(images);
|
||||
|
||||
TagNode moviesNode = new TagNode(translate("node.movies"));
|
||||
moviesNode.subItems.addAll(movies);
|
||||
|
||||
TagNode soundsNode = new TagNode(translate("node.sounds"));
|
||||
soundsNode.subItems.addAll(sounds);
|
||||
|
||||
|
||||
TagNode binaryDataNode = new TagNode(translate("node.binaryData"));
|
||||
binaryDataNode.subItems.addAll(binaryData);
|
||||
|
||||
TagNode fontsNode = new TagNode(translate("node.fonts"));
|
||||
fontsNode.subItems.addAll(fonts);
|
||||
|
||||
|
||||
TagNode spritesNode = new TagNode(translate("node.sprites"));
|
||||
spritesNode.subItems.addAll(sprites);
|
||||
|
||||
TagNode shapesNode = new TagNode(translate("node.shapes"));
|
||||
shapesNode.subItems.addAll(shapes);
|
||||
|
||||
TagNode morphShapesNode = new TagNode(translate("node.morphshapes"));
|
||||
morphShapesNode.subItems.addAll(morphShapes);
|
||||
|
||||
TagNode buttonsNode = new TagNode(translate("node.buttons"));
|
||||
buttonsNode.subItems.addAll(buttons);
|
||||
|
||||
TagNode framesNode = new TagNode(translate("node.frames"));
|
||||
framesNode.subItems.addAll(frames);
|
||||
|
||||
TagNode actionScriptNode = new TagNode(translate("node.scripts"));
|
||||
actionScriptNode.mark = "scripts";
|
||||
actionScriptNode.subItems.addAll(actionScript);
|
||||
|
||||
if (!shapesNode.subItems.isEmpty()) {
|
||||
ret.add(shapesNode);
|
||||
}
|
||||
if (!morphShapesNode.subItems.isEmpty()) {
|
||||
ret.add(morphShapesNode);
|
||||
}
|
||||
if (!spritesNode.subItems.isEmpty()) {
|
||||
ret.add(spritesNode);
|
||||
}
|
||||
if (!textsNode.subItems.isEmpty()) {
|
||||
ret.add(textsNode);
|
||||
}
|
||||
if (!imagesNode.subItems.isEmpty()) {
|
||||
ret.add(imagesNode);
|
||||
}
|
||||
if (!moviesNode.subItems.isEmpty()) {
|
||||
ret.add(moviesNode);
|
||||
}
|
||||
if (!soundsNode.subItems.isEmpty()) {
|
||||
ret.add(soundsNode);
|
||||
}
|
||||
if (!buttonsNode.subItems.isEmpty()) {
|
||||
ret.add(buttonsNode);
|
||||
}
|
||||
if (!fontsNode.subItems.isEmpty()) {
|
||||
ret.add(fontsNode);
|
||||
}
|
||||
if (!binaryDataNode.subItems.isEmpty()) {
|
||||
ret.add(binaryDataNode);
|
||||
}
|
||||
if (!framesNode.subItems.isEmpty()) {
|
||||
ret.add(framesNode);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if (abcPanel != null) {
|
||||
actionScriptNode.subItems.clear();
|
||||
actionScriptNode.tag = abcPanel.classTree.getModel();
|
||||
}
|
||||
if ((!actionScriptNode.subItems.isEmpty()) || (abcPanel != null)) {
|
||||
ret.add(actionScriptNode);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public boolean confirmExperimental() {
|
||||
return View.showConfirmDialog(null, translate("message.confirm.experimental"), translate("message.warning"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.OK_OPTION;
|
||||
}
|
||||
private SearchDialog searchDialog;
|
||||
|
||||
public List<File> exportSelection(AbortRetryIgnoreHandler handler, String selFile, ExportDialog export) throws IOException {
|
||||
public List<File> exportSelection(SWF swf, AbortRetryIgnoreHandler handler, String selFile, ExportDialog export) throws IOException {
|
||||
final ExportMode exportMode = ExportMode.get(export.getOption(ExportDialog.OPTION_ACTIONSCRIPT));
|
||||
final boolean isMp3OrWav = export.getOption(ExportDialog.OPTION_SOUNDS) == 0;
|
||||
final boolean isFormatted = export.getOption(ExportDialog.OPTION_TEXTS) == 1;
|
||||
@@ -1589,25 +1438,25 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T
|
||||
for (Object d : sel) {
|
||||
if (d instanceof TagNode) {
|
||||
TagNode n = (TagNode) d;
|
||||
if ("image".equals(getTagType(n.tag))) {
|
||||
if (getTagType(n.tag) == TagType.IMAGE) {
|
||||
images.add((Tag) n.tag);
|
||||
}
|
||||
if ("shape".equals(getTagType(n.tag))) {
|
||||
if (getTagType(n.tag) == TagType.SHAPE) {
|
||||
shapes.add((Tag) n.tag);
|
||||
}
|
||||
if ("as".equals(getTagType(n.tag))) {
|
||||
if (getTagType(n.tag) == TagType.AS) {
|
||||
actionNodes.add(n);
|
||||
}
|
||||
if ("movie".equals(getTagType(n.tag))) {
|
||||
if (getTagType(n.tag) == TagType.MOVIE) {
|
||||
movies.add((Tag) n.tag);
|
||||
}
|
||||
if ("sound".equals(getTagType(n.tag))) {
|
||||
if (getTagType(n.tag) == TagType.SOUND) {
|
||||
sounds.add((Tag) n.tag);
|
||||
}
|
||||
if ("binaryData".equals(getTagType(n.tag))) {
|
||||
if (getTagType(n.tag) == TagType.BINARY_DATA) {
|
||||
binaryData.add((Tag) n.tag);
|
||||
}
|
||||
if ("text".equals(getTagType(n.tag))) {
|
||||
if (getTagType(n.tag) == TagType.TEXT) {
|
||||
texts.add((Tag) n.tag);
|
||||
}
|
||||
}
|
||||
@@ -1642,6 +1491,10 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T
|
||||
return ret;
|
||||
}
|
||||
|
||||
public SWF getCurrentSwf() {
|
||||
return swfs == null || swfs.isEmpty() ? null : swfs.get(0);
|
||||
}
|
||||
|
||||
private void clearCache() {
|
||||
if (abcPanel != null) {
|
||||
abcPanel.decompiledTextArea.clearScriptCache();
|
||||
@@ -1651,7 +1504,7 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T
|
||||
}
|
||||
}
|
||||
|
||||
public void gotoDocumentClass() {
|
||||
public void gotoDocumentClass(SWF swf) {
|
||||
if (swf == null) {
|
||||
return;
|
||||
}
|
||||
@@ -1741,7 +1594,7 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T
|
||||
doFilter();
|
||||
}
|
||||
|
||||
public void renameOneIdentifier() {
|
||||
public void renameOneIdentifier(final SWF swf) {
|
||||
if (swf.fileAttributes.actionScript3) {
|
||||
final int multiName = abcPanel.decompiledTextArea.getMultinameUnderCursor();
|
||||
if (multiName > 0) {
|
||||
@@ -1770,7 +1623,7 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T
|
||||
public Void doInBackground() throws Exception {
|
||||
Main.startWork(translate("work.renaming") + "...");
|
||||
try {
|
||||
renameIdentifier(identifier);
|
||||
renameIdentifier(swf, identifier);
|
||||
} catch (InterruptedException ex) {
|
||||
Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
@@ -1788,7 +1641,7 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T
|
||||
}
|
||||
}
|
||||
|
||||
public void exportFla() {
|
||||
public void exportFla(final SWF swf) {
|
||||
JFileChooser fc = new JFileChooser();
|
||||
String selDir = Configuration.lastOpenDir.get();
|
||||
fc.setCurrentDirectory(new File(selDir));
|
||||
@@ -1863,7 +1716,7 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T
|
||||
}
|
||||
}
|
||||
|
||||
public void export(final boolean onlySel) {
|
||||
public void export(final SWF swf, final boolean onlySel) {
|
||||
final ExportDialog export = new ExportDialog();
|
||||
export.setVisible(true);
|
||||
if (!export.cancelled) {
|
||||
@@ -1885,7 +1738,7 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T
|
||||
public Void doInBackground() throws Exception {
|
||||
try {
|
||||
if (onlySel) {
|
||||
exportSelection(errorHandler, selFile, export);
|
||||
exportSelection(swf, errorHandler, selFile, export);
|
||||
} else {
|
||||
swf.exportImages(errorHandler, selFile + File.separator + "images");
|
||||
swf.exportShapes(errorHandler, selFile + File.separator + "shapes");
|
||||
@@ -1961,7 +1814,7 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T
|
||||
}
|
||||
}
|
||||
|
||||
public void renameIdentifiers() {
|
||||
public void renameIdentifiers(final SWF swf) {
|
||||
if (confirmExperimental()) {
|
||||
final RenameType renameType = new RenameDialog().display();
|
||||
if (renameType != null) {
|
||||
@@ -2065,7 +1918,7 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T
|
||||
}
|
||||
}
|
||||
|
||||
public void removeNonScripts() {
|
||||
public void removeNonScripts(SWF swf) {
|
||||
List<Tag> tags = new ArrayList<>(swf.tags);
|
||||
for (Tag tag : tags) {
|
||||
System.out.println(tag.getClass());
|
||||
@@ -2135,7 +1988,7 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T
|
||||
byte[] data = Helper.readFile(selfile.getAbsolutePath());
|
||||
try {
|
||||
it.setImage(data);
|
||||
swf.clearImageCache();
|
||||
it.getSwf().clearImageCache();
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, "Invalid image", ex);
|
||||
View.showMessageDialog(null, translate("error.image.invalid"), translate("error"), JOptionPane.ERROR_MESSAGE);
|
||||
@@ -2190,14 +2043,14 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T
|
||||
if (tagsToRemove.size() == 1) {
|
||||
Tag tag = tagsToRemove.get(0);
|
||||
if (View.showConfirmDialog(this, translate("message.confirm.remove").replace("%item%", tag.toString()), translate("message.confirm"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) {
|
||||
swf.removeTag(tag);
|
||||
tag.getSwf().removeTag(tag);
|
||||
showCard(CARDEMPTYPANEL);
|
||||
refreshTree();
|
||||
}
|
||||
} else if (tagsToRemove.size() > 1) {
|
||||
if (View.showConfirmDialog(this, translate("message.confirm.removemultiple").replace("%count%", Integer.toString(tagsToRemove.size())), translate("message.confirm"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) {
|
||||
for (Tag tag : tagsToRemove) {
|
||||
swf.removeTag(tag);
|
||||
tag.getSwf().removeTag(tag);
|
||||
}
|
||||
showCard(CARDEMPTYPANEL);
|
||||
refreshTree();
|
||||
@@ -2212,8 +2065,9 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T
|
||||
break;
|
||||
case ACTION_SAVE_TEXT:
|
||||
if (oldValue instanceof TextTag) {
|
||||
TextTag textTag = (TextTag) oldValue;
|
||||
try {
|
||||
if (((TextTag) oldValue).setFormattedText(new MissingCharacterHandler() {
|
||||
if (textTag.setFormattedText(new MissingCharacterHandler() {
|
||||
@Override
|
||||
public boolean handle(FontTag font, List<Tag> tags, char character) {
|
||||
String fontName = fontPanel.sourceFontsMap.get(font.getFontId());
|
||||
@@ -2230,7 +2084,7 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T
|
||||
return true;
|
||||
|
||||
}
|
||||
}, swf.tags, textValue.getText(), fontPanel.getSelectedFont())) {
|
||||
}, textTag.getSwf().tags, textValue.getText(), fontPanel.getSelectedFont())) {
|
||||
setEditText(false);
|
||||
}
|
||||
} catch (ParseException ex) {
|
||||
@@ -2247,7 +2101,7 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T
|
||||
switch (e.getActionCommand()) {
|
||||
|
||||
case MainFrameRibbon.ACTION_EXPORT_SEL:
|
||||
export(true);
|
||||
export(getCurrentSwf(), true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -2387,6 +2241,8 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T
|
||||
|
||||
|
||||
if ((tagObj instanceof SWFRoot)) {
|
||||
SWFRoot swfRoot = (SWFRoot) tagObj;
|
||||
SWF swf = swfRoot.getSwf();
|
||||
if (mainRibbon.isInternalFlashViewerSelected()) {
|
||||
showCard(CARDSWFPREVIEWPANEL);
|
||||
swfPreviewPanel.load(swf);
|
||||
@@ -2427,19 +2283,23 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T
|
||||
showCard(CARDACTIONSCRIPTPANEL);
|
||||
actionPanel.setSource((ASMSource) tagObj, !forceReload);
|
||||
} else if (tagObj instanceof ImageTag) {
|
||||
showHideImageReplaceButton(((ImageTag) tagObj).importSupported());
|
||||
ImageTag imageTag = (ImageTag) tagObj;
|
||||
showHideImageReplaceButton(imageTag.importSupported());
|
||||
showCard(CARDIMAGEPANEL);
|
||||
imagePanel.setImage(((ImageTag) tagObj).getImage(swf.tags));
|
||||
imagePanel.setImage(imageTag.getImage(imageTag.getSwf().tags));
|
||||
} else if ((tagObj instanceof DrawableTag) && (!(tagObj instanceof TextTag)) && (!(tagObj instanceof FontTag)) && (mainRibbon.isInternalFlashViewerSelected())) {
|
||||
Tag tag = (Tag) tagObj;
|
||||
showCard(CARDDRAWPREVIEWPANEL);
|
||||
previewImagePanel.setDrawable((DrawableTag) tagObj, swf, characters, 50/*FIXME*/);
|
||||
previewImagePanel.setDrawable((DrawableTag) tag, tag.getSwf(), characters, 50/*FIXME*/);
|
||||
} else if ((tagObj instanceof FontTag) && (mainRibbon.isInternalFlashViewerSelected())) {
|
||||
Tag tag = (Tag) tagObj;
|
||||
showCard(CARDFLASHPANEL);
|
||||
previewImagePanel.setDrawable((DrawableTag) tagObj, swf, characters, 50/*FIXME*/);
|
||||
previewImagePanel.setDrawable((DrawableTag) tag, tag.getSwf(), characters, 50/*FIXME*/);
|
||||
showFontTag((FontTag) tagObj);
|
||||
} else if (tagObj instanceof FrameNode && ((FrameNode) tagObj).isDisplayed() && (mainRibbon.isInternalFlashViewerSelected())) {
|
||||
showCard(CARDDRAWPREVIEWPANEL);
|
||||
FrameNode fn = (FrameNode) tagObj;
|
||||
SWF swf = fn.getSwf();
|
||||
List<Tag> controlTags = swf.tags;
|
||||
int containerId = 0;
|
||||
RECT rect = swf.displayRect;
|
||||
@@ -2455,379 +2315,12 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T
|
||||
((CardLayout) viewerCards.getLayout()).show(viewerCards, FLASH_VIEWER_CARD);
|
||||
createAndShowTempSwf(tagObj);
|
||||
|
||||
try {
|
||||
if (tempFile != null) {
|
||||
tempFile.delete();
|
||||
}
|
||||
tempFile = File.createTempFile("temp", ".swf");
|
||||
tempFile.deleteOnExit();
|
||||
|
||||
Color backgroundColor = View.swfBackgroundColor;
|
||||
if (tagObj instanceof FontTag) { //Fonts are always black on white
|
||||
backgroundColor = View.DEFAULT_BACKGROUND_COLOR;
|
||||
}
|
||||
int frameCount = 1;
|
||||
int frameRate = swf.frameRate;
|
||||
HashMap<Integer, VideoFrameTag> videoFrames = new HashMap<>();
|
||||
DefineVideoStreamTag vs = null;
|
||||
if (tagObj instanceof DefineVideoStreamTag) {
|
||||
vs = (DefineVideoStreamTag) tagObj;
|
||||
swf.populateVideoFrames(vs.getCharacterId(), swf.tags, videoFrames);
|
||||
frameCount = videoFrames.size();
|
||||
}
|
||||
|
||||
List<SoundStreamBlockTag> soundFrames = new ArrayList<>();
|
||||
if (tagObj instanceof SoundStreamHeadTypeTag) {
|
||||
SWF.populateSoundStreamBlocks(swf.tags, (Tag) tagObj, soundFrames);
|
||||
frameCount = soundFrames.size();
|
||||
}
|
||||
|
||||
if ((tagObj instanceof DefineMorphShapeTag) || (tagObj instanceof DefineMorphShape2Tag)) {
|
||||
frameCount = 100;
|
||||
frameRate = 50;
|
||||
}
|
||||
|
||||
if (tagObj instanceof DefineSoundTag) {
|
||||
frameCount = 1;
|
||||
}
|
||||
|
||||
byte[] data;
|
||||
try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
|
||||
SWFOutputStream sos2 = new SWFOutputStream(baos, 10);
|
||||
int width = swf.displayRect.Xmax - swf.displayRect.Xmin;
|
||||
int height = swf.displayRect.Ymax - swf.displayRect.Ymin;
|
||||
sos2.writeRECT(swf.displayRect);
|
||||
sos2.writeUI8(0);
|
||||
sos2.writeUI8(frameRate);
|
||||
sos2.writeUI16(frameCount); //framecnt
|
||||
|
||||
/*FileAttributesTag fa = new FileAttributesTag();
|
||||
sos2.writeTag(fa);
|
||||
*/
|
||||
if (tagObj instanceof FrameNode) {
|
||||
FrameNode fn = (FrameNode) tagObj;
|
||||
if (fn.getParent() == null) {
|
||||
for (Tag t : swf.tags) {
|
||||
if (t instanceof SetBackgroundColorTag) {
|
||||
backgroundColor = ((SetBackgroundColorTag) t).backgroundColor.toColor();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sos2.writeTag(new SetBackgroundColorTag(null, new RGB(backgroundColor)));
|
||||
|
||||
if (tagObj instanceof FrameNode) {
|
||||
FrameNode fn = (FrameNode) tagObj;
|
||||
Object parent = fn.getParent();
|
||||
List<ContainerItem> subs = new ArrayList<>();
|
||||
if (parent == null) {
|
||||
subs.addAll(swf.tags);
|
||||
} else {
|
||||
if (parent instanceof Container) {
|
||||
subs = ((Container) parent).getSubItems();
|
||||
}
|
||||
}
|
||||
List<Integer> doneCharacters = new ArrayList<>();
|
||||
int frameCnt = 1;
|
||||
for (Object o : subs) {
|
||||
if (o instanceof ShowFrameTag) {
|
||||
frameCnt++;
|
||||
continue;
|
||||
}
|
||||
if (frameCnt > fn.getFrame()) {
|
||||
break;
|
||||
}
|
||||
Tag t = (Tag) o;
|
||||
Set<Integer> needed = t.getDeepNeededCharacters(characters, new ArrayList<Integer>());
|
||||
for (int n : needed) {
|
||||
if (!doneCharacters.contains(n)) {
|
||||
sos2.writeTag(classicTag(characters.get(n)));
|
||||
doneCharacters.add(n);
|
||||
}
|
||||
}
|
||||
if (t instanceof CharacterTag) {
|
||||
doneCharacters.add(((CharacterTag) t).getCharacterId());
|
||||
}
|
||||
sos2.writeTag(classicTag(t));
|
||||
|
||||
if (parent != null) {
|
||||
if (t instanceof PlaceObjectTypeTag) {
|
||||
PlaceObjectTypeTag pot = (PlaceObjectTypeTag) t;
|
||||
int chid = pot.getCharacterId();
|
||||
int depth = pot.getDepth();
|
||||
MATRIX mat = pot.getMatrix();
|
||||
if (mat == null) {
|
||||
mat = new MATRIX();
|
||||
}
|
||||
mat = (MATRIX) Helper.deepCopy(mat);
|
||||
if (parent instanceof BoundedTag) {
|
||||
RECT r = ((BoundedTag) parent).getRect(characters, new Stack<Integer>());
|
||||
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;
|
||||
}
|
||||
sos2.writeTag(new PlaceObject2Tag(null, false, false, false, false, false, true, false, true, depth, chid, mat, null, 0, null, 0, null));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
sos2.writeTag(new ShowFrameTag(null));
|
||||
} else {
|
||||
|
||||
if (tagObj instanceof DefineBitsTag) {
|
||||
if (jtt != null) {
|
||||
sos2.writeTag(jtt);
|
||||
}
|
||||
} else if (tagObj instanceof AloneTag) {
|
||||
} else {
|
||||
Set<Integer> needed = ((Tag) tagObj).getDeepNeededCharacters(characters, new ArrayList<Integer>());
|
||||
for (int n : needed) {
|
||||
sos2.writeTag(classicTag(characters.get(n)));
|
||||
}
|
||||
}
|
||||
|
||||
sos2.writeTag(classicTag((Tag) tagObj));
|
||||
|
||||
int chtId = 0;
|
||||
if (tagObj instanceof CharacterTag) {
|
||||
chtId = ((CharacterTag) tagObj).getCharacterId();
|
||||
}
|
||||
|
||||
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(characters, new Stack<Integer>());
|
||||
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 / 4;
|
||||
mat.translateY = height / 4;
|
||||
}
|
||||
if (tagObj instanceof FontTag) {
|
||||
|
||||
int countGlyphs = ((FontTag) tagObj).getGlyphShapeTable().size();
|
||||
int fontId = ((FontTag) tagObj).getFontId();
|
||||
int sloupcu = (int) Math.ceil(Math.sqrt(countGlyphs));
|
||||
int radku = (int) Math.ceil(((float) countGlyphs) / ((float) sloupcu));
|
||||
int x = 0;
|
||||
int y = 1;
|
||||
for (int f = 0; f < countGlyphs; f++) {
|
||||
if (x >= sloupcu) {
|
||||
x = 0;
|
||||
y++;
|
||||
}
|
||||
List<TEXTRECORD> rec = new ArrayList<>();
|
||||
TEXTRECORD tr = new TEXTRECORD();
|
||||
int textHeight = height / radku;
|
||||
tr.fontId = fontId;
|
||||
tr.styleFlagsHasFont = true;
|
||||
tr.textHeight = textHeight;
|
||||
tr.glyphEntries = new GLYPHENTRY[1];
|
||||
tr.styleFlagsHasColor = true;
|
||||
tr.textColor = new RGB(0, 0, 0);
|
||||
tr.glyphEntries[0] = new GLYPHENTRY();
|
||||
tr.glyphEntries[0].glyphAdvance = 0;
|
||||
tr.glyphEntries[0].glyphIndex = f;
|
||||
rec.add(tr);
|
||||
mat.translateX = x * width / sloupcu;
|
||||
mat.translateY = y * height / radku;
|
||||
sos2.writeTag(new DefineTextTag(null, 999 + f, new RECT(0, width, 0, height), new MATRIX(), rec));
|
||||
sos2.writeTag(new PlaceObject2Tag(null, false, false, false, true, false, true, true, false, 1 + f, 999 + f, mat, null, 0, null, 0, null));
|
||||
x++;
|
||||
}
|
||||
sos2.writeTag(new ShowFrameTag(null));
|
||||
} else if ((tagObj instanceof DefineMorphShapeTag) || (tagObj instanceof DefineMorphShape2Tag)) {
|
||||
sos2.writeTag(new PlaceObject2Tag(null, false, false, false, true, false, true, true, false, 1, chtId, mat, null, 0, null, 0, null));
|
||||
sos2.writeTag(new ShowFrameTag(null));
|
||||
int numFrames = 100;
|
||||
for (int ratio = 0; ratio < 65536; ratio += 65536 / numFrames) {
|
||||
sos2.writeTag(new PlaceObject2Tag(null, false, false, false, true, false, true, false, true, 1, chtId, mat, null, ratio, null, 0, null));
|
||||
sos2.writeTag(new ShowFrameTag(null));
|
||||
}
|
||||
} else if (tagObj instanceof SoundStreamHeadTypeTag) {
|
||||
for (SoundStreamBlockTag blk : soundFrames) {
|
||||
sos2.writeTag(blk);
|
||||
sos2.writeTag(new ShowFrameTag(null));
|
||||
}
|
||||
} else if (tagObj instanceof DefineSoundTag) {
|
||||
ExportAssetsTag ea = new ExportAssetsTag();
|
||||
DefineSoundTag ds = (DefineSoundTag) tagObj;
|
||||
ea.tags.add(ds.soundId);
|
||||
ea.names.add("my_define_sound");
|
||||
sos2.writeTag(ea);
|
||||
List<Action> actions;
|
||||
DoActionTag doa;
|
||||
|
||||
|
||||
doa = new DoActionTag(null, new byte[]{}, SWF.DEFAULT_VERSION, 0);
|
||||
actions = ASMParser.parse(0, 0, false,
|
||||
"ConstantPool \"_root\" \"my_sound\" \"Sound\" \"my_define_sound\" \"attachSound\"\n"
|
||||
+ "Push \"_root\"\n"
|
||||
+ "GetVariable\n"
|
||||
+ "Push \"my_sound\" 0.0 \"Sound\"\n"
|
||||
+ "NewObject\n"
|
||||
+ "SetMember\n"
|
||||
+ "Push \"my_define_sound\" 1 \"_root\"\n"
|
||||
+ "GetVariable\n"
|
||||
+ "Push \"my_sound\"\n"
|
||||
+ "GetMember\n"
|
||||
+ "Push \"attachSound\"\n"
|
||||
+ "CallMethod\n"
|
||||
+ "Pop\n"
|
||||
+ "Stop", SWF.DEFAULT_VERSION, false);
|
||||
doa.setActions(actions, SWF.DEFAULT_VERSION);
|
||||
sos2.writeTag(doa);
|
||||
sos2.writeTag(new ShowFrameTag(null));
|
||||
|
||||
|
||||
actions = ASMParser.parse(0, 0, false,
|
||||
"ConstantPool \"_root\" \"my_sound\" \"Sound\" \"my_define_sound\" \"attachSound\" \"start\"\n"
|
||||
+ "StopSounds\n"
|
||||
+ "Push \"_root\"\n"
|
||||
+ "GetVariable\n"
|
||||
+ "Push \"my_sound\" 0.0 \"Sound\"\n"
|
||||
+ "NewObject\n"
|
||||
+ "SetMember\n"
|
||||
+ "Push \"my_define_sound\" 1 \"_root\"\n"
|
||||
+ "GetVariable\n"
|
||||
+ "Push \"my_sound\"\n"
|
||||
+ "GetMember\n"
|
||||
+ "Push \"attachSound\"\n"
|
||||
+ "CallMethod\n"
|
||||
+ "Pop\n"
|
||||
+ "Push 9999 0.0 2 \"_root\"\n"
|
||||
+ "GetVariable\n"
|
||||
+ "Push \"my_sound\"\n"
|
||||
+ "GetMember\n"
|
||||
+ "Push \"start\"\n"
|
||||
+ "CallMethod\n"
|
||||
+ "Pop\n"
|
||||
+ "Stop", SWF.DEFAULT_VERSION, false);
|
||||
doa.setActions(actions, SWF.DEFAULT_VERSION);
|
||||
sos2.writeTag(doa);
|
||||
sos2.writeTag(new ShowFrameTag(null));
|
||||
|
||||
actions = ASMParser.parse(0, 0, false,
|
||||
"ConstantPool \"_root\" \"my_sound\" \"Sound\" \"my_define_sound\" \"attachSound\" \"onSoundComplete\" \"start\" \"execParam\"\n"
|
||||
+ "StopSounds\n"
|
||||
+ "Push \"_root\"\n"
|
||||
+ "GetVariable\n"
|
||||
+ "Push \"my_sound\" 0.0 \"Sound\"\n"
|
||||
+ "NewObject\n"
|
||||
+ "SetMember\n"
|
||||
+ "Push \"my_define_sound\" 1 \"_root\"\n"
|
||||
+ "GetVariable\n"
|
||||
+ "Push \"my_sound\"\n"
|
||||
+ "GetMember\n"
|
||||
+ "Push \"attachSound\"\n"
|
||||
+ "CallMethod\n"
|
||||
+ "Pop\n"
|
||||
+ "Push \"_root\"\n"
|
||||
+ "GetVariable\n"
|
||||
+ "Push \"my_sound\"\n"
|
||||
+ "GetMember\n"
|
||||
+ "Push \"onSoundComplete\"\n"
|
||||
+ "DefineFunction2 \"\" 0 2 false true true false true false true false false {\n"
|
||||
+ "Push 0.0 register1 \"my_sound\"\n"
|
||||
+ "GetMember\n"
|
||||
+ "Push \"start\"\n"
|
||||
+ "CallMethod\n"
|
||||
+ "Pop\n"
|
||||
+ "}\n"
|
||||
+ "SetMember\n"
|
||||
+ "Push \"_root\"\n"
|
||||
+ "GetVariable\n"
|
||||
+ "Push \"execParam\"\n"
|
||||
+ "GetMember\n"
|
||||
+ "Push 1 \"_root\"\n"
|
||||
+ "GetVariable\n"
|
||||
+ "Push \"my_sound\"\n"
|
||||
+ "GetMember\n"
|
||||
+ "Push \"start\"\n"
|
||||
+ "CallMethod\n"
|
||||
+ "Pop\n"
|
||||
+ "Stop", SWF.DEFAULT_VERSION, false);
|
||||
doa.setActions(actions, SWF.DEFAULT_VERSION);
|
||||
sos2.writeTag(doa);
|
||||
sos2.writeTag(new ShowFrameTag(null));
|
||||
|
||||
|
||||
actions = ASMParser.parse(0, 0, false,
|
||||
"StopSounds\n"
|
||||
+ "Stop", SWF.DEFAULT_VERSION, false);
|
||||
doa.setActions(actions, SWF.DEFAULT_VERSION);
|
||||
sos2.writeTag(doa);
|
||||
sos2.writeTag(new ShowFrameTag(null));
|
||||
|
||||
|
||||
sos2.writeTag(new ShowFrameTag(null));
|
||||
if (flashPanel != null) {
|
||||
flashPanel.specialPlayback = true;
|
||||
}
|
||||
} else if (tagObj instanceof DefineVideoStreamTag) {
|
||||
|
||||
sos2.writeTag(new PlaceObject2Tag(null, false, false, false, false, false, true, true, false, 1, chtId, mat, null, 0, null, 0, null));
|
||||
List<VideoFrameTag> frs = new ArrayList<>(videoFrames.values());
|
||||
Collections.sort(frs, new Comparator<VideoFrameTag>() {
|
||||
@Override
|
||||
public int compare(VideoFrameTag o1, VideoFrameTag o2) {
|
||||
return o1.frameNum - o2.frameNum;
|
||||
}
|
||||
});
|
||||
boolean first = true;
|
||||
int ratio = 0;
|
||||
for (VideoFrameTag f : frs) {
|
||||
if (!first) {
|
||||
ratio++;
|
||||
sos2.writeTag(new PlaceObject2Tag(null, false, false, false, true, false, false, false, true, 1, 0, null, null, ratio, null, 0, null));
|
||||
}
|
||||
sos2.writeTag(f);
|
||||
sos2.writeTag(new ShowFrameTag(null));
|
||||
first = false;
|
||||
}
|
||||
} else {
|
||||
sos2.writeTag(new PlaceObject2Tag(null, false, false, false, true, false, true, true, false, 1, chtId, mat, null, 0, null, 0, null));
|
||||
sos2.writeTag(new ShowFrameTag(null));
|
||||
}
|
||||
|
||||
|
||||
}//not showframe
|
||||
|
||||
sos2.writeTag(new EndTag(null));
|
||||
data = baos.toByteArray();
|
||||
}
|
||||
|
||||
try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(tempFile))) {
|
||||
SWFOutputStream sos = new SWFOutputStream(fos, 10);
|
||||
sos.write("FWS".getBytes());
|
||||
sos.write(swf.version);
|
||||
sos.writeUI32(sos.getPos() + data.length + 4);
|
||||
sos.write(data);
|
||||
fos.flush();
|
||||
}
|
||||
showCard(CARDFLASHPANEL);
|
||||
if (flashPanel != null) {
|
||||
flashPanel.displaySWF(tempFile.getAbsolutePath(), backgroundColor, frameRate);
|
||||
}
|
||||
|
||||
} catch (IOException | com.jpexs.decompiler.flash.action.parser.ParseException ex) {
|
||||
Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
|
||||
if (tagObj instanceof TextTag) {
|
||||
TextTag textTag = (TextTag) tagObj;
|
||||
parametersPanel.setVisible(true);
|
||||
previewSplitPane.setDividerLocation(previewSplitPane.getWidth() / 2);
|
||||
showDetailWithPreview(CARDTEXTPANEL);
|
||||
textValue.setText(((TextTag) tagObj).getFormattedText(swf.tags));
|
||||
textValue.setText(textTag.getFormattedText(textTag.getSwf().tags));
|
||||
} else if (tagObj instanceof FontTag) {
|
||||
showFontTag((FontTag) tagObj);
|
||||
} else {
|
||||
@@ -2840,6 +2333,7 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T
|
||||
}
|
||||
|
||||
private void createAndShowTempSwf(Object tagObj) {
|
||||
SWF swf;
|
||||
try {
|
||||
if (tempFile != null) {
|
||||
tempFile.delete();
|
||||
@@ -2848,9 +2342,27 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T
|
||||
tempFile.deleteOnExit();
|
||||
|
||||
Color backgroundColor = View.swfBackgroundColor;
|
||||
|
||||
if (tagObj instanceof FontTag) { //Fonts are always black on white
|
||||
backgroundColor = View.DEFAULT_BACKGROUND_COLOR;
|
||||
}
|
||||
|
||||
if (tagObj instanceof FrameNode) {
|
||||
FrameNode fn = (FrameNode) tagObj;
|
||||
swf = fn.getSwf();
|
||||
if (fn.getParent() == null) {
|
||||
for (Tag t : swf.tags) {
|
||||
if (t instanceof SetBackgroundColorTag) {
|
||||
backgroundColor = ((SetBackgroundColorTag) t).backgroundColor.toColor();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Tag tag = (Tag) tagObj;
|
||||
swf = tag.getSwf();
|
||||
}
|
||||
|
||||
int frameCount = 1;
|
||||
int frameRate = swf.frameRate;
|
||||
HashMap<Integer, VideoFrameTag> videoFrames = new HashMap<>();
|
||||
@@ -2889,18 +2401,6 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T
|
||||
/*FileAttributesTag fa = new FileAttributesTag();
|
||||
sos2.writeTag(fa);
|
||||
*/
|
||||
if (tagObj instanceof FrameNode) {
|
||||
FrameNode fn = (FrameNode) tagObj;
|
||||
if (fn.getParent() == null) {
|
||||
for (Tag t : swf.tags) {
|
||||
if (t instanceof SetBackgroundColorTag) {
|
||||
backgroundColor = ((SetBackgroundColorTag) t).backgroundColor.toColor();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sos2.writeTag(new SetBackgroundColorTag(null, new RGB(backgroundColor)));
|
||||
|
||||
if (tagObj instanceof FrameNode) {
|
||||
@@ -3212,7 +2712,7 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T
|
||||
private void showFontTag(FontTag ft) {
|
||||
if (mainRibbon.isInternalFlashViewerSelected() /*|| ft instanceof GFxDefineCompactedFont*/) {
|
||||
((CardLayout) viewerCards.getLayout()).show(viewerCards, INTERNAL_VIEWER_CARD);
|
||||
internelViewerPanel.setDrawable(ft, swf, characters, 1);
|
||||
internelViewerPanel.setDrawable(ft, ft.getSwf(), characters, 1);
|
||||
} else {
|
||||
((CardLayout) viewerCards.getLayout()).show(viewerCards, FLASH_VIEWER_CARD);
|
||||
}
|
||||
@@ -3224,12 +2724,9 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T
|
||||
}
|
||||
|
||||
public void refreshTree() {
|
||||
List<ContainerItem> objs = new ArrayList<>();
|
||||
objs.addAll(swf.tags);
|
||||
|
||||
List<List<String>> expandedNodes = getExpandedNodes(tagTree);
|
||||
|
||||
tagTree.setModel(new TagTreeModel(createTagList(objs, null), new SWFRoot((new File(Main.file)).getName())));
|
||||
tagTree.setModel(new TagTreeModel(this, swfs, abcPanel));
|
||||
|
||||
expandTreeNodes(tagTree, expandedNodes);
|
||||
}
|
||||
|
||||
@@ -644,7 +644,7 @@ public class MainFrameRibbon implements ActionListener {
|
||||
}, 1000); //It takes some time registry change to apply
|
||||
break;
|
||||
case ACTION_GOTO_DOCUMENT_CLASS:
|
||||
mainFrame.gotoDocumentClass();
|
||||
mainFrame.gotoDocumentClass(mainFrame.getCurrentSwf());
|
||||
break;
|
||||
case ACTION_PARALLEL_SPEED_UP:
|
||||
String confStr = translate("message.confirm.parallel") + "\r\n";
|
||||
@@ -691,7 +691,7 @@ public class MainFrameRibbon implements ActionListener {
|
||||
|
||||
switch (e.getActionCommand()) {
|
||||
case ACTION_RENAME_ONE_IDENTIFIER:
|
||||
mainFrame.renameOneIdentifier();
|
||||
mainFrame.renameOneIdentifier(mainFrame.getCurrentSwf());
|
||||
break;
|
||||
case ACTION_ABOUT:
|
||||
Main.about();
|
||||
@@ -722,12 +722,12 @@ public class MainFrameRibbon implements ActionListener {
|
||||
Main.openFileDialog();
|
||||
break;
|
||||
case ACTION_EXPORT_FLA:
|
||||
mainFrame.exportFla();
|
||||
mainFrame.exportFla(mainFrame.getCurrentSwf());
|
||||
break;
|
||||
case ACTION_EXPORT_SEL:
|
||||
case ACTION_EXPORT:
|
||||
boolean onlySel = e.getActionCommand().endsWith("SEL");
|
||||
mainFrame.export(onlySel);
|
||||
mainFrame.export(mainFrame.getCurrentSwf(), onlySel);
|
||||
break;
|
||||
case ACTION_CHECK_UPDATES:
|
||||
if (!Main.checkForUpdates()) {
|
||||
@@ -766,14 +766,14 @@ public class MainFrameRibbon implements ActionListener {
|
||||
mainFrame.restoreControlFlow(all);
|
||||
break;
|
||||
case ACTION_RENAME_IDENTIFIERS:
|
||||
mainFrame.renameIdentifiers();
|
||||
mainFrame.renameIdentifiers(mainFrame.getCurrentSwf());
|
||||
break;
|
||||
case ACTION_DEOBFUSCATE:
|
||||
case ACTION_DEOBFUSCATE_ALL:
|
||||
mainFrame.deobfuscate();
|
||||
break;
|
||||
case ACTION_REMOVE_NON_SCRIPTS:
|
||||
mainFrame.removeNonScripts();
|
||||
mainFrame.removeNonScripts(mainFrame.getCurrentSwf());
|
||||
break;
|
||||
case ACTION_REFRESH_DECOMPILED:
|
||||
mainFrame.refreshDecompiled();
|
||||
|
||||
@@ -33,6 +33,10 @@ import javax.swing.JLabel;
|
||||
*/
|
||||
public class ModeFrame extends AppFrame implements ActionListener {
|
||||
|
||||
static final String ACTION_OPEN = "OPEN";
|
||||
static final String ACTION_PROXY = "PROXY";
|
||||
static final String ACTION_EXIT = "EXIT";
|
||||
|
||||
private JButton openButton = new JButton(translate("button.open"));
|
||||
private JButton proxyButton = new JButton(translate("button.proxy"));
|
||||
private JButton exitButton = new JButton(translate("button.exit"));
|
||||
@@ -43,13 +47,13 @@ public class ModeFrame extends AppFrame implements ActionListener {
|
||||
public ModeFrame() {
|
||||
setSize(350, 200);
|
||||
openButton.addActionListener(this);
|
||||
openButton.setActionCommand("OPEN");
|
||||
openButton.setActionCommand(ACTION_OPEN);
|
||||
openButton.setIcon(View.getIcon("open32"));
|
||||
proxyButton.addActionListener(this);
|
||||
proxyButton.setActionCommand("PROXY");
|
||||
proxyButton.setActionCommand(ACTION_PROXY);
|
||||
proxyButton.setIcon(View.getIcon("proxy32"));
|
||||
exitButton.addActionListener(this);
|
||||
exitButton.setActionCommand("EXIT");
|
||||
exitButton.setActionCommand(ACTION_EXIT);
|
||||
exitButton.setIcon(View.getIcon("exit32"));
|
||||
setResizable(false);
|
||||
Container cont = getContentPane();
|
||||
@@ -78,19 +82,21 @@ public class ModeFrame extends AppFrame implements ActionListener {
|
||||
*/
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (e.getActionCommand().equals("OPEN")) {
|
||||
setVisible(false);
|
||||
if (!Main.openFileDialog()) {
|
||||
setVisible(true);
|
||||
}
|
||||
}
|
||||
if (e.getActionCommand().equals("PROXY")) {
|
||||
setVisible(false);
|
||||
Main.showProxy();
|
||||
}
|
||||
if (e.getActionCommand().equals("EXIT")) {
|
||||
setVisible(false);
|
||||
Main.exit();
|
||||
switch (e.getActionCommand()) {
|
||||
case ACTION_OPEN:
|
||||
setVisible(false);
|
||||
if (!Main.openFileDialog()) {
|
||||
setVisible(true);
|
||||
}
|
||||
break;
|
||||
case ACTION_PROXY:
|
||||
setVisible(false);
|
||||
Main.showProxy();
|
||||
break;
|
||||
case ACTION_EXIT:
|
||||
setVisible(false);
|
||||
Main.exit();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,6 +42,9 @@ import javax.swing.UIManager;
|
||||
*/
|
||||
public class NewVersionDialog extends AppDialog implements ActionListener {
|
||||
|
||||
static final String ACTION_OK = "OK";
|
||||
static final String ACTION_CANCEL = "CANCEL";
|
||||
|
||||
Version latestVersion;
|
||||
|
||||
public NewVersionDialog(List<Version> versions) {
|
||||
@@ -82,11 +85,11 @@ public class NewVersionDialog extends AppDialog implements ActionListener {
|
||||
cnt.add(span);
|
||||
JPanel buttonsPanel = new JPanel(new FlowLayout());
|
||||
JButton buttonOk = new JButton(translate("button.ok"));
|
||||
buttonOk.setActionCommand("OK");
|
||||
buttonOk.setActionCommand(ACTION_OK);
|
||||
buttonOk.addActionListener(this);
|
||||
|
||||
JButton buttonCancel = new JButton(translate("button.cancel"));
|
||||
buttonCancel.setActionCommand("CANCEL");
|
||||
buttonCancel.setActionCommand(ACTION_CANCEL);
|
||||
buttonCancel.addActionListener(this);
|
||||
|
||||
buttonsPanel.add(buttonOk);
|
||||
@@ -108,7 +111,7 @@ public class NewVersionDialog extends AppDialog implements ActionListener {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (e.getActionCommand().equals("OK")) {
|
||||
if (e.getActionCommand() == ACTION_OK) {
|
||||
java.awt.Desktop desktop = null;
|
||||
if (java.awt.Desktop.isDesktopSupported()) {
|
||||
desktop = java.awt.Desktop.getDesktop();
|
||||
|
||||
@@ -36,6 +36,9 @@ import javax.swing.JRadioButton;
|
||||
*/
|
||||
public class RenameDialog extends AppDialog implements ActionListener {
|
||||
|
||||
static final String ACTION_OK = "OK";
|
||||
static final String ACTION_CANCEL = "CANCEL";
|
||||
|
||||
private JRadioButton typeNumberRadioButton = new JRadioButton(translate("rename.type.typenumber"));
|
||||
private JRadioButton randomWordRadioButton = new JRadioButton(translate("rename.type.randomword"));
|
||||
private JButton okButton = new JButton(translate("button.ok"));
|
||||
@@ -70,10 +73,10 @@ public class RenameDialog extends AppDialog implements ActionListener {
|
||||
add(pan, BorderLayout.CENTER);
|
||||
JPanel panButtons = new JPanel(new FlowLayout());
|
||||
panButtons.add(okButton);
|
||||
okButton.setActionCommand("OK");
|
||||
okButton.setActionCommand(ACTION_OK);
|
||||
okButton.addActionListener(this);
|
||||
panButtons.add(cancelButton);
|
||||
cancelButton.setActionCommand("CANCEL");
|
||||
cancelButton.setActionCommand(ACTION_CANCEL);
|
||||
cancelButton.addActionListener(this);
|
||||
add(panButtons, BorderLayout.SOUTH);
|
||||
setModalityType(ModalityType.APPLICATION_MODAL);
|
||||
@@ -95,12 +98,12 @@ public class RenameDialog extends AppDialog implements ActionListener {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
switch (e.getActionCommand()) {
|
||||
case "OK":
|
||||
case ACTION_OK:
|
||||
confirmed = true;
|
||||
Configuration.lastRenameType.set((Integer) (getRenameType() == RenameType.TYPENUMBER ? 1 : 2));
|
||||
setVisible(false);
|
||||
break;
|
||||
case "CANCEL":
|
||||
case ACTION_CANCEL:
|
||||
confirmed = false;
|
||||
setVisible(false);
|
||||
break;
|
||||
|
||||
@@ -16,18 +16,25 @@
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.gui;
|
||||
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class SWFRoot {
|
||||
|
||||
private SWF swf;
|
||||
private String name;
|
||||
|
||||
public SWFRoot(String name) {
|
||||
public SWFRoot(SWF swf, String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public SWF getSwf() {
|
||||
return swf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name;
|
||||
|
||||
@@ -38,6 +38,9 @@ import javax.swing.JTextField;
|
||||
*/
|
||||
public class SearchDialog extends AppDialog implements ActionListener {
|
||||
|
||||
static final String ACTION_OK = "OK";
|
||||
static final String ACTION_CANCEL = "CANCEL";
|
||||
|
||||
public JTextField searchField = new MyTextField();
|
||||
public JCheckBox ignoreCaseCheckBox = new JCheckBox(translate("checkbox.ignorecase"));
|
||||
public JCheckBox regexpCheckBox = new JCheckBox(translate("checkbox.regexp"));
|
||||
@@ -50,10 +53,10 @@ public class SearchDialog extends AppDialog implements ActionListener {
|
||||
cnt.setLayout(new BoxLayout(cnt, BoxLayout.PAGE_AXIS));
|
||||
JPanel panButtons = new JPanel(new FlowLayout());
|
||||
JButton okButton = new JButton(translate("button.ok"));
|
||||
okButton.setActionCommand("OK");
|
||||
okButton.setActionCommand(ACTION_OK);
|
||||
okButton.addActionListener(this);
|
||||
JButton cancelButton = new JButton(translate("button.cancel"));
|
||||
cancelButton.setActionCommand("CANCEL");
|
||||
cancelButton.setActionCommand(ACTION_CANCEL);
|
||||
cancelButton.addActionListener(this);
|
||||
panButtons.add(okButton);
|
||||
panButtons.add(cancelButton);
|
||||
@@ -87,7 +90,7 @@ public class SearchDialog extends AppDialog implements ActionListener {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (e.getActionCommand().equals("OK")) {
|
||||
if (e.getActionCommand() == ACTION_OK) {
|
||||
if (regexpCheckBox.isSelected()) {
|
||||
try {
|
||||
Pattern pat = Pattern.compile(searchField.getText());
|
||||
|
||||
@@ -38,6 +38,9 @@ import jsyntaxpane.DefaultSyntaxKit;
|
||||
*/
|
||||
public class SelectLanguageDialog extends AppDialog implements ActionListener {
|
||||
|
||||
static final String ACTION_OK = "OK";
|
||||
static final String ACTION_CANCEL = "CANCEL";
|
||||
|
||||
JComboBox<Language> languageCombobox = new JComboBox<>();
|
||||
public String languageCode = null;
|
||||
private String[] languages = new String[]{"en", "cs", "zh", "de", "es", "hu", "nl", "pt", "ru", "sv", "uk"};
|
||||
@@ -81,10 +84,10 @@ public class SelectLanguageDialog extends AppDialog implements ActionListener {
|
||||
JPanel buttonsPanel = new JPanel(new FlowLayout());
|
||||
buttonsPanel.setAlignmentX(0.5f);
|
||||
JButton okButton = new JButton(translate("button.ok"));
|
||||
okButton.setActionCommand("OK");
|
||||
okButton.setActionCommand(ACTION_OK);
|
||||
okButton.addActionListener(this);
|
||||
JButton cancelButton = new JButton(translate("button.cancel"));
|
||||
cancelButton.setActionCommand("CANCEL");
|
||||
cancelButton.setActionCommand(ACTION_CANCEL);
|
||||
cancelButton.addActionListener(this);
|
||||
buttonsPanel.add(okButton);
|
||||
buttonsPanel.add(cancelButton);
|
||||
@@ -103,7 +106,7 @@ public class SelectLanguageDialog extends AppDialog implements ActionListener {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
switch (e.getActionCommand()) {
|
||||
case "OK":
|
||||
case ACTION_OK:
|
||||
if (languageCombobox.getSelectedIndex() == -1) {
|
||||
} else {
|
||||
languageCode = ((Language) languageCombobox.getSelectedItem()).code;
|
||||
@@ -116,7 +119,7 @@ public class SelectLanguageDialog extends AppDialog implements ActionListener {
|
||||
reloadUi();
|
||||
}
|
||||
break;
|
||||
case "CANCEL":
|
||||
case ACTION_CANCEL:
|
||||
setVisible(false);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -16,9 +16,20 @@
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.gui;
|
||||
|
||||
import com.jpexs.decompiler.flash.FrameNode;
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.TagNode;
|
||||
import com.jpexs.decompiler.flash.gui.abc.ABCPanel;
|
||||
import com.jpexs.decompiler.flash.gui.abc.ClassesListTreeModel;
|
||||
import com.jpexs.decompiler.flash.gui.abc.TreeElement;
|
||||
import com.jpexs.decompiler.flash.tags.DefineSpriteTag;
|
||||
import com.jpexs.decompiler.flash.tags.ExportAssetsTag;
|
||||
import com.jpexs.decompiler.flash.tags.SoundStreamBlockTag;
|
||||
import com.jpexs.decompiler.flash.tags.Tag;
|
||||
import com.jpexs.decompiler.flash.tags.base.Container;
|
||||
import com.jpexs.decompiler.flash.tags.base.ContainerItem;
|
||||
import com.jpexs.decompiler.flash.tags.base.SoundStreamHeadTypeTag;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.swing.event.TreeModelListener;
|
||||
@@ -27,12 +38,171 @@ import javax.swing.tree.TreePath;
|
||||
|
||||
public class TagTreeModel implements TreeModel {
|
||||
|
||||
private Object root;
|
||||
private SWFRoot root;
|
||||
private List<TagNode> list = new ArrayList<>();
|
||||
private MainFrame mainFrame;
|
||||
|
||||
public TagTreeModel(List<TagNode> list, Object rootName) {
|
||||
this.root = rootName;
|
||||
this.list = list;
|
||||
public TagTreeModel(MainFrame mainFrame, List<SWF> swfs, ABCPanel abcPanel) {
|
||||
this.mainFrame = mainFrame;
|
||||
SWF swf = swfs.get(0); // todo honfika: add multiple swfs
|
||||
this.root = new SWFRoot(swf, new File(Main.file).getName());
|
||||
|
||||
List<ContainerItem> objs = new ArrayList<>();
|
||||
objs.addAll(swf.tags);
|
||||
this.list = createTagList(objs, null, abcPanel);
|
||||
}
|
||||
|
||||
private String translate(String key) {
|
||||
return mainFrame.translate(key);
|
||||
}
|
||||
|
||||
public List<TagNode> getTagNodesWithType(List<? extends ContainerItem> list, TagType type, Object parent, boolean display) {
|
||||
List<TagNode> ret = new ArrayList<>();
|
||||
int frameCnt = 0;
|
||||
for (ContainerItem o : list) {
|
||||
TagType ttype = MainFrame.getTagType(o);
|
||||
if (ttype == TagType.SHOW_FRAME && type == TagType.FRAME) {
|
||||
frameCnt++;
|
||||
ret.add(new TagNode(new FrameNode(o.getSwf(), frameCnt, parent, display)));
|
||||
} else if (type == ttype) {
|
||||
ret.add(new TagNode(o));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
private List<TagNode> createTagList(List<ContainerItem> list, Object parent, ABCPanel abcPanel) {
|
||||
List<TagNode> ret = new ArrayList<>();
|
||||
List<TagNode> frames = getTagNodesWithType(list, TagType.FRAME, parent, true);
|
||||
List<TagNode> shapes = getTagNodesWithType(list, TagType.SHAPE, parent, true);
|
||||
List<TagNode> morphShapes = getTagNodesWithType(list, TagType.MORPH_SHAPE, parent, true);
|
||||
List<TagNode> sprites = getTagNodesWithType(list, TagType.SPRITE, parent, true);
|
||||
List<TagNode> buttons = getTagNodesWithType(list, TagType.BUTTON, parent, true);
|
||||
List<TagNode> images = getTagNodesWithType(list, TagType.IMAGE, parent, true);
|
||||
List<TagNode> fonts = getTagNodesWithType(list, TagType.FONT, parent, true);
|
||||
List<TagNode> texts = getTagNodesWithType(list, TagType.TEXT, parent, true);
|
||||
List<TagNode> movies = getTagNodesWithType(list, TagType.MOVIE, parent, true);
|
||||
List<TagNode> sounds = getTagNodesWithType(list, TagType.SOUND, parent, true);
|
||||
List<TagNode> binaryData = getTagNodesWithType(list, TagType.BINARY_DATA, parent, true);
|
||||
List<TagNode> actionScript = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < sounds.size(); i++) {
|
||||
if (sounds.get(i).tag instanceof SoundStreamHeadTypeTag) {
|
||||
List<SoundStreamBlockTag> blocks = new ArrayList<>();
|
||||
SWF.populateSoundStreamBlocks(list, (Tag) sounds.get(i).tag, blocks);
|
||||
if (blocks.isEmpty()) {
|
||||
sounds.remove(i);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (TagNode n : sprites) {
|
||||
n.subItems = getTagNodesWithType(((DefineSpriteTag) n.tag).subTags, TagType.FRAME, n.tag, true);
|
||||
}
|
||||
|
||||
List<ExportAssetsTag> exportAssetsTags = new ArrayList<>();
|
||||
for (Object t : list) {
|
||||
if (t instanceof ExportAssetsTag) {
|
||||
exportAssetsTags.add((ExportAssetsTag) t);
|
||||
}
|
||||
/*if (t instanceof ASMSource) {
|
||||
TagNode tti = new TagNode(t);
|
||||
ret.add(tti);
|
||||
} else */
|
||||
if (t instanceof Container) {
|
||||
TagNode tti = new TagNode(t);
|
||||
if (((Container) t).getItemCount() > 0) {
|
||||
List<ContainerItem> subItems = ((Container) t).getSubItems();
|
||||
tti.subItems = createTagList(subItems, t, abcPanel);
|
||||
}
|
||||
//ret.add(tti);
|
||||
}
|
||||
}
|
||||
|
||||
actionScript = SWF.createASTagList(list, null);
|
||||
TagNode textsNode = new TagNode(translate("node.texts"));
|
||||
textsNode.subItems.addAll(texts);
|
||||
|
||||
TagNode imagesNode = new TagNode(translate("node.images"));
|
||||
imagesNode.subItems.addAll(images);
|
||||
|
||||
TagNode moviesNode = new TagNode(translate("node.movies"));
|
||||
moviesNode.subItems.addAll(movies);
|
||||
|
||||
TagNode soundsNode = new TagNode(translate("node.sounds"));
|
||||
soundsNode.subItems.addAll(sounds);
|
||||
|
||||
|
||||
TagNode binaryDataNode = new TagNode(translate("node.binaryData"));
|
||||
binaryDataNode.subItems.addAll(binaryData);
|
||||
|
||||
TagNode fontsNode = new TagNode(translate("node.fonts"));
|
||||
fontsNode.subItems.addAll(fonts);
|
||||
|
||||
|
||||
TagNode spritesNode = new TagNode(translate("node.sprites"));
|
||||
spritesNode.subItems.addAll(sprites);
|
||||
|
||||
TagNode shapesNode = new TagNode(translate("node.shapes"));
|
||||
shapesNode.subItems.addAll(shapes);
|
||||
|
||||
TagNode morphShapesNode = new TagNode(translate("node.morphshapes"));
|
||||
morphShapesNode.subItems.addAll(morphShapes);
|
||||
|
||||
TagNode buttonsNode = new TagNode(translate("node.buttons"));
|
||||
buttonsNode.subItems.addAll(buttons);
|
||||
|
||||
TagNode framesNode = new TagNode(translate("node.frames"));
|
||||
framesNode.subItems.addAll(frames);
|
||||
|
||||
TagNode actionScriptNode = new TagNode(translate("node.scripts"));
|
||||
actionScriptNode.mark = "scripts";
|
||||
actionScriptNode.subItems.addAll(actionScript);
|
||||
|
||||
if (!shapesNode.subItems.isEmpty()) {
|
||||
ret.add(shapesNode);
|
||||
}
|
||||
if (!morphShapesNode.subItems.isEmpty()) {
|
||||
ret.add(morphShapesNode);
|
||||
}
|
||||
if (!spritesNode.subItems.isEmpty()) {
|
||||
ret.add(spritesNode);
|
||||
}
|
||||
if (!textsNode.subItems.isEmpty()) {
|
||||
ret.add(textsNode);
|
||||
}
|
||||
if (!imagesNode.subItems.isEmpty()) {
|
||||
ret.add(imagesNode);
|
||||
}
|
||||
if (!moviesNode.subItems.isEmpty()) {
|
||||
ret.add(moviesNode);
|
||||
}
|
||||
if (!soundsNode.subItems.isEmpty()) {
|
||||
ret.add(soundsNode);
|
||||
}
|
||||
if (!buttonsNode.subItems.isEmpty()) {
|
||||
ret.add(buttonsNode);
|
||||
}
|
||||
if (!fontsNode.subItems.isEmpty()) {
|
||||
ret.add(fontsNode);
|
||||
}
|
||||
if (!binaryDataNode.subItems.isEmpty()) {
|
||||
ret.add(binaryDataNode);
|
||||
}
|
||||
if (!framesNode.subItems.isEmpty()) {
|
||||
ret.add(framesNode);
|
||||
}
|
||||
|
||||
if (abcPanel != null) {
|
||||
actionScriptNode.subItems.clear();
|
||||
actionScriptNode.tag = abcPanel.classTree.getModel();
|
||||
}
|
||||
if ((!actionScriptNode.subItems.isEmpty()) || (abcPanel != null)) {
|
||||
ret.add(actionScriptNode);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
private List<Object> searchTag(Object obj, Object parent, List<Object> path) {
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2013 JPEXS
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.gui;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public enum TagType {
|
||||
|
||||
FONT,
|
||||
TEXT,
|
||||
IMAGE,
|
||||
SHAPE,
|
||||
MORPH_SHAPE,
|
||||
SPRITE,
|
||||
BUTTON,
|
||||
AS,
|
||||
PACKAGE,
|
||||
FRAME,
|
||||
SHOW_FRAME,
|
||||
MOVIE,
|
||||
SOUND,
|
||||
BINARY_DATA,
|
||||
FOLDER,
|
||||
FOLDER_OPEN
|
||||
}
|
||||
@@ -330,7 +330,7 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Fr
|
||||
JButton newTraitButton = new JButton(View.getIcon("traitadd16"));
|
||||
newTraitButton.setMargin(new Insets(5, 5, 5, 5));
|
||||
newTraitButton.addActionListener(this);
|
||||
newTraitButton.setActionCommand("ADDTRAIT");
|
||||
newTraitButton.setActionCommand(ACTION_ADD_TRAIT);
|
||||
newTraitButton.setToolTipText(AppStrings.translate("button.addtrait"));
|
||||
iconsPanel.add(newTraitButton);
|
||||
|
||||
@@ -394,7 +394,7 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Fr
|
||||
|
||||
Main.startWork(AppStrings.translate("work.buildingscripttree") + "...");
|
||||
|
||||
filterField.setActionCommand("FILTERSCRIPT");
|
||||
filterField.setActionCommand(ACTION_FILTER_SCRIPT);
|
||||
filterField.addActionListener(this);
|
||||
|
||||
|
||||
@@ -428,16 +428,16 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Fr
|
||||
JButton prevSearchButton = new JButton(View.getIcon("prev16"));
|
||||
prevSearchButton.setMargin(new Insets(3, 3, 3, 3));
|
||||
prevSearchButton.addActionListener(this);
|
||||
prevSearchButton.setActionCommand("SEARCHPREV");
|
||||
prevSearchButton.setActionCommand(ACTION_SEARCH_PREV);
|
||||
|
||||
JButton nextSearchButton = new JButton(View.getIcon("next16"));
|
||||
nextSearchButton.setMargin(new Insets(3, 3, 3, 3));
|
||||
nextSearchButton.addActionListener(this);
|
||||
nextSearchButton.setActionCommand("SEARCHNEXT");
|
||||
nextSearchButton.setActionCommand(ACTION_SEARCH_NEXT);
|
||||
JButton cancelSearchButton = new JButton(View.getIcon("cancel16"));
|
||||
cancelSearchButton.setMargin(new Insets(3, 3, 3, 3));
|
||||
cancelSearchButton.addActionListener(this);
|
||||
cancelSearchButton.setActionCommand("SEARCHCANCEL");
|
||||
cancelSearchButton.setActionCommand(ACTION_SEARCH_CANCEL);
|
||||
searchPos = new JLabel("0/0");
|
||||
searchForLabel = new JLabel(AppStrings.translate("search.info").replace("%text%", "") + " ");
|
||||
searchPanel.add(searchForLabel);
|
||||
|
||||
@@ -38,6 +38,9 @@ import javax.swing.JSlider;
|
||||
*/
|
||||
public class DeobfuscationDialog extends AppDialog implements ActionListener {
|
||||
|
||||
static final String ACTION_OK = "OK";
|
||||
static final String ACTION_CANCEL = "CANCEL";
|
||||
|
||||
public JCheckBox processAllCheckbox = new JCheckBox(translate("processallclasses"));
|
||||
public JSlider codeProcessingLevel;
|
||||
public boolean ok = false;
|
||||
@@ -86,10 +89,10 @@ public class DeobfuscationDialog extends AppDialog implements ActionListener {
|
||||
|
||||
JButton cancelButton = new JButton(translate("button.cancel"));
|
||||
cancelButton.addActionListener(this);
|
||||
cancelButton.setActionCommand("CANCEL");
|
||||
cancelButton.setActionCommand(ACTION_CANCEL);
|
||||
JButton okButton = new JButton(translate("button.ok"));
|
||||
okButton.addActionListener(this);
|
||||
okButton.setActionCommand("OK");
|
||||
okButton.setActionCommand(ACTION_OK);
|
||||
|
||||
JPanel buttonsPanel = new JPanel(new FlowLayout());
|
||||
buttonsPanel.add(okButton);
|
||||
@@ -105,13 +108,15 @@ public class DeobfuscationDialog extends AppDialog implements ActionListener {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (e.getActionCommand().equals("OK")) {
|
||||
ok = true;
|
||||
setVisible(false);
|
||||
}
|
||||
if (e.getActionCommand().equals("CANCEL")) {
|
||||
ok = false;
|
||||
setVisible(false);
|
||||
switch (e.getActionCommand()) {
|
||||
case ACTION_OK:
|
||||
ok = true;
|
||||
setVisible(false);
|
||||
break;
|
||||
case ACTION_CANCEL:
|
||||
ok = false;
|
||||
setVisible(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.jpexs.decompiler.flash.abc.types.traits.Trait;
|
||||
import com.jpexs.decompiler.flash.gui.AppStrings;
|
||||
import com.jpexs.decompiler.flash.gui.HeaderLabel;
|
||||
import com.jpexs.decompiler.flash.gui.View;
|
||||
import static com.jpexs.decompiler.flash.gui.abc.DeobfuscationDialog.ACTION_OK;
|
||||
import com.jpexs.helpers.CancellableWorker;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.CardLayout;
|
||||
@@ -38,6 +39,10 @@ import javax.swing.border.BevelBorder;
|
||||
*/
|
||||
public class DetailPanel extends JPanel implements ActionListener {
|
||||
|
||||
static final String ACTION_SAVE_DETAIL = "SAVEDETAIL";
|
||||
static final String ACTION_EDIT_DETAIL = "EDITDETAIL";
|
||||
static final String ACTION_CANCEL_DETAIL = "CANCELDETAIL";
|
||||
|
||||
public MethodTraitDetailPanel methodTraitPanel;
|
||||
public JPanel unsupportedTraitPanel;
|
||||
public SlotConstTraitDetailPanel slotConstTraitPanel;
|
||||
@@ -86,11 +91,11 @@ public class DetailPanel extends JPanel implements ActionListener {
|
||||
|
||||
buttonsPanel = new JPanel();
|
||||
buttonsPanel.setLayout(new FlowLayout());
|
||||
saveButton.setActionCommand("SAVEDETAIL");
|
||||
saveButton.setActionCommand(ACTION_SAVE_DETAIL);
|
||||
saveButton.addActionListener(this);
|
||||
editButton.setActionCommand("EDITDETAIL");
|
||||
editButton.setActionCommand(ACTION_EDIT_DETAIL);
|
||||
editButton.addActionListener(this);
|
||||
cancelButton.setActionCommand("CANCELDETAIL");
|
||||
cancelButton.setActionCommand(ACTION_CANCEL_DETAIL);
|
||||
cancelButton.addActionListener(this);
|
||||
buttonsPanel.setBorder(new BevelBorder(BevelBorder.RAISED));
|
||||
buttonsPanel.add(editButton);
|
||||
@@ -162,35 +167,37 @@ public class DetailPanel extends JPanel implements ActionListener {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (e.getActionCommand().equals("EDITDETAIL")) {
|
||||
setEditMode(true);
|
||||
methodTraitPanel.methodCodePanel.focusEditor();
|
||||
}
|
||||
if (e.getActionCommand().equals("CANCELDETAIL")) {
|
||||
setEditMode(false);
|
||||
abcPanel.decompiledTextArea.resetEditing();
|
||||
}
|
||||
if (e.getActionCommand().equals("SAVEDETAIL")) {
|
||||
if (cardMap.get(selectedCard) instanceof TraitDetail) {
|
||||
if (((TraitDetail) cardMap.get(selectedCard)).save()) {
|
||||
CancellableWorker worker = new CancellableWorker() {
|
||||
switch (e.getActionCommand()) {
|
||||
case ACTION_EDIT_DETAIL:
|
||||
setEditMode(true);
|
||||
methodTraitPanel.methodCodePanel.focusEditor();
|
||||
break;
|
||||
case ACTION_CANCEL_DETAIL:
|
||||
setEditMode(false);
|
||||
abcPanel.decompiledTextArea.resetEditing();
|
||||
break;
|
||||
case ACTION_SAVE_DETAIL:
|
||||
if (cardMap.get(selectedCard) instanceof TraitDetail) {
|
||||
if (((TraitDetail) cardMap.get(selectedCard)).save()) {
|
||||
CancellableWorker worker = new CancellableWorker() {
|
||||
|
||||
@Override
|
||||
public Void doInBackground() throws Exception {
|
||||
int lasttrait = abcPanel.decompiledTextArea.lastTraitIndex;
|
||||
abcPanel.decompiledTextArea.reloadClass();
|
||||
abcPanel.decompiledTextArea.gotoTrait(lasttrait);
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public Void doInBackground() throws Exception {
|
||||
int lasttrait = abcPanel.decompiledTextArea.lastTraitIndex;
|
||||
abcPanel.decompiledTextArea.reloadClass();
|
||||
abcPanel.decompiledTextArea.gotoTrait(lasttrait);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void done() {
|
||||
View.showMessageDialog(null, AppStrings.translate("message.trait.saved"));
|
||||
}
|
||||
};
|
||||
worker.execute();
|
||||
@Override
|
||||
protected void done() {
|
||||
View.showMessageDialog(null, AppStrings.translate("message.trait.saved"));
|
||||
}
|
||||
};
|
||||
worker.execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,6 +41,10 @@ import javax.swing.JToggleButton;
|
||||
*/
|
||||
public class MethodCodePanel extends JPanel implements ActionListener {
|
||||
|
||||
static final String ACTION_GRAPH = "GRAPH";
|
||||
static final String ACTION_HEX = "HEX";
|
||||
static final String ACTION_HEX_ONLY = "HEXONLY";
|
||||
|
||||
private ASMSourceEditorPane sourceTextArea;
|
||||
public JPanel buttonsPanel;
|
||||
private JToggleButton hexButton;
|
||||
@@ -98,20 +102,20 @@ public class MethodCodePanel extends JPanel implements ActionListener {
|
||||
buttonsPanel.setLayout(new BoxLayout(buttonsPanel, BoxLayout.X_AXIS));
|
||||
|
||||
JButton graphButton = new JButton(View.getIcon("graph16"));
|
||||
graphButton.setActionCommand("GRAPH");
|
||||
graphButton.setActionCommand(ACTION_GRAPH);
|
||||
graphButton.addActionListener(this);
|
||||
graphButton.setToolTipText(AppStrings.translate("button.viewgraph"));
|
||||
graphButton.setMargin(new Insets(3, 3, 3, 3));
|
||||
|
||||
hexButton = new JToggleButton(View.getIcon("hex16"));
|
||||
hexButton.setActionCommand("HEX");
|
||||
hexButton.setActionCommand(ACTION_HEX);
|
||||
hexButton.addActionListener(this);
|
||||
hexButton.setToolTipText(AppStrings.translate("button.viewhex"));
|
||||
hexButton.setMargin(new Insets(3, 3, 3, 3));
|
||||
|
||||
// todo: find icon
|
||||
hexOnlyButton = new JToggleButton(View.getIcon("hex16"));
|
||||
hexOnlyButton.setActionCommand("HEXONLY");
|
||||
hexOnlyButton.setActionCommand(ACTION_HEX_ONLY);
|
||||
hexOnlyButton.addActionListener(this);
|
||||
hexOnlyButton.setToolTipText(AppStrings.translate("button.viewhex"));
|
||||
hexOnlyButton.setMargin(new Insets(3, 3, 3, 3));
|
||||
@@ -134,17 +138,20 @@ public class MethodCodePanel extends JPanel implements ActionListener {
|
||||
if (Main.isWorking()) {
|
||||
return;
|
||||
}
|
||||
if (e.getActionCommand().equals("GRAPH")) {
|
||||
sourceTextArea.graph();
|
||||
}
|
||||
|
||||
if (e.getActionCommand().equals("HEX") || e.getActionCommand().equals("HEXONLY")) {
|
||||
if (e.getActionCommand().equals("HEX")) {
|
||||
hexOnlyButton.setSelected(false);
|
||||
} else {
|
||||
hexButton.setSelected(false);
|
||||
}
|
||||
sourceTextArea.setHex(getExportMode(), false);
|
||||
switch (e.getActionCommand()) {
|
||||
case ACTION_GRAPH:
|
||||
sourceTextArea.graph();
|
||||
break;
|
||||
case ACTION_HEX:
|
||||
case ACTION_HEX_ONLY:
|
||||
if (e.getActionCommand() == ACTION_HEX) {
|
||||
hexOnlyButton.setSelected(false);
|
||||
} else {
|
||||
hexButton.setSelected(false);
|
||||
}
|
||||
sourceTextArea.setHex(getExportMode(), false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -43,6 +43,9 @@ import javax.swing.event.AncestorListener;
|
||||
*/
|
||||
public class NewTraitDialog extends AppDialog implements ActionListener {
|
||||
|
||||
static final String ACTION_OK = "OK";
|
||||
static final String ACTION_CANCEL = "CANCEL";
|
||||
|
||||
private static int modifiers[] = new int[]{
|
||||
Namespace.KIND_PACKAGE,
|
||||
Namespace.KIND_PRIVATE,
|
||||
@@ -121,10 +124,10 @@ public class NewTraitDialog extends AppDialog implements ActionListener {
|
||||
cnt.add(optionsPanel, BorderLayout.CENTER);
|
||||
JPanel buttonsPanel = new JPanel(new FlowLayout());
|
||||
JButton buttonOk = new JButton(AppStrings.translate("button.ok"));
|
||||
buttonOk.setActionCommand("OK");
|
||||
buttonOk.setActionCommand(ACTION_OK);
|
||||
buttonOk.addActionListener(this);
|
||||
JButton buttonCancel = new JButton(AppStrings.translate("button.cancel"));
|
||||
buttonCancel.setActionCommand("CANCEL");
|
||||
buttonCancel.setActionCommand(ACTION_CANCEL);
|
||||
buttonCancel.addActionListener(this);
|
||||
buttonsPanel.add(buttonOk);
|
||||
buttonsPanel.add(buttonCancel);
|
||||
@@ -161,7 +164,7 @@ public class NewTraitDialog extends AppDialog implements ActionListener {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
switch (e.getActionCommand()) {
|
||||
case "OK":
|
||||
case ACTION_OK:
|
||||
if (nameField.getText().trim().isEmpty()) {
|
||||
View.showMessageDialog(null, translate("error.name"), AppStrings.translate("error"), JOptionPane.ERROR_MESSAGE);
|
||||
return;
|
||||
@@ -169,7 +172,7 @@ public class NewTraitDialog extends AppDialog implements ActionListener {
|
||||
result = true;
|
||||
setVisible(false);
|
||||
break;
|
||||
case "CANCEL":
|
||||
case ACTION_CANCEL:
|
||||
result = false;
|
||||
setVisible(false);
|
||||
break;
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.jpexs.decompiler.flash.abc.usages.MultinameUsage;
|
||||
import com.jpexs.decompiler.flash.abc.usages.TraitMultinameUsage;
|
||||
import com.jpexs.decompiler.flash.gui.AppFrame;
|
||||
import com.jpexs.decompiler.flash.gui.View;
|
||||
import static com.jpexs.decompiler.flash.gui.abc.NewTraitDialog.ACTION_OK;
|
||||
import com.jpexs.decompiler.flash.tags.ABCContainerTag;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
@@ -41,6 +42,9 @@ import javax.swing.*;
|
||||
*/
|
||||
public class UsageFrame extends AppFrame implements ActionListener, MouseListener {
|
||||
|
||||
static final String ACTION_GOTO = "GOTO";
|
||||
static final String ACTION_CANCEL = "CANCEL";
|
||||
|
||||
private JButton gotoButton = new JButton(translate("button.goto"));
|
||||
private JButton cancelButton = new JButton(translate("button.cancel"));
|
||||
private JList usageList;
|
||||
@@ -59,9 +63,9 @@ public class UsageFrame extends AppFrame implements ActionListener, MouseListene
|
||||
}
|
||||
usageList = new JList(usageListModel);
|
||||
usageList.setBackground(Color.white);
|
||||
gotoButton.setActionCommand("GOTO");
|
||||
gotoButton.setActionCommand(ACTION_GOTO);
|
||||
gotoButton.addActionListener(this);
|
||||
cancelButton.setActionCommand("CANCEL");
|
||||
cancelButton.setActionCommand(ACTION_CANCEL);
|
||||
cancelButton.addActionListener(this);
|
||||
JPanel buttonsPanel = new JPanel();
|
||||
buttonsPanel.setLayout(new FlowLayout());
|
||||
@@ -114,12 +118,14 @@ public class UsageFrame extends AppFrame implements ActionListener, MouseListene
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (e.getActionCommand().equals("GOTO")) {
|
||||
gotoUsage();
|
||||
setVisible(false);
|
||||
}
|
||||
if (e.getActionCommand().equals("CANCEL")) {
|
||||
setVisible(false);
|
||||
switch (e.getActionCommand()) {
|
||||
case ACTION_GOTO:
|
||||
gotoUsage();
|
||||
setVisible(false);
|
||||
break;
|
||||
case ACTION_CANCEL:
|
||||
setVisible(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -80,6 +80,19 @@ import jsyntaxpane.actions.DocumentSearchData;
|
||||
|
||||
public class ActionPanel extends JPanel implements ActionListener {
|
||||
|
||||
static final String ACTION_SEARCH_PREV = "SEARCHPREV";
|
||||
static final String ACTION_SEARCH_NEXT = "SEARCHNEXT";
|
||||
static final String ACTION_SEARCH_CANCEL = "SEARCHCANCEL";
|
||||
static final String ACTION_GRAPH = "GRAPH";
|
||||
static final String ACTION_HEX = "HEX";
|
||||
static final String ACTION_HEX_ONLY = "HEXONLY";
|
||||
static final String ACTION_SAVE_ACTION = "SAVEACTION";
|
||||
static final String ACTION_EDIT_ACTION = "EDITACTION";
|
||||
static final String ACTION_CANCEL_ACTION = "CANCELACTION";
|
||||
static final String ACTION_SAVE_DECOMPILED = "SAVEDECOMPILED";
|
||||
static final String ACTION_EDIT_DECOMPILED = "EDITDECOMPILED";
|
||||
static final String ACTION_CANCEL_DECOMPILED = "CANCELDECOMPILED";
|
||||
|
||||
public LineMarkedEditorPane editor;
|
||||
public LineMarkedEditorPane decompiledEditor;
|
||||
public List<Tag> list;
|
||||
@@ -422,15 +435,15 @@ public class ActionPanel extends JPanel implements ActionListener {
|
||||
JButton prevSearchButton = new JButton(View.getIcon("prev16"));
|
||||
prevSearchButton.setMargin(new Insets(3, 3, 3, 3));
|
||||
prevSearchButton.addActionListener(this);
|
||||
prevSearchButton.setActionCommand("SEARCHPREV");
|
||||
prevSearchButton.setActionCommand(ACTION_SEARCH_PREV);
|
||||
JButton nextSearchButton = new JButton(View.getIcon("next16"));
|
||||
nextSearchButton.setMargin(new Insets(3, 3, 3, 3));
|
||||
nextSearchButton.addActionListener(this);
|
||||
nextSearchButton.setActionCommand("SEARCHNEXT");
|
||||
nextSearchButton.setActionCommand(ACTION_SEARCH_NEXT);
|
||||
JButton cancelSearchButton = new JButton(View.getIcon("cancel16"));
|
||||
cancelSearchButton.setMargin(new Insets(3, 3, 3, 3));
|
||||
cancelSearchButton.addActionListener(this);
|
||||
cancelSearchButton.setActionCommand("SEARCHCANCEL");
|
||||
cancelSearchButton.setActionCommand(ACTION_SEARCH_CANCEL);
|
||||
searchPos = new JLabel("0/0");
|
||||
searchForLabel = new JLabel(AppStrings.translate("search.info").replace("%text%", ""));
|
||||
searchPanel.add(searchForLabel);
|
||||
@@ -442,20 +455,20 @@ public class ActionPanel extends JPanel implements ActionListener {
|
||||
|
||||
|
||||
JButton graphButton = new JButton(View.getIcon("graph16"));
|
||||
graphButton.setActionCommand("GRAPH");
|
||||
graphButton.setActionCommand(ACTION_GRAPH);
|
||||
graphButton.addActionListener(this);
|
||||
graphButton.setToolTipText(AppStrings.translate("button.viewgraph"));
|
||||
graphButton.setMargin(new Insets(3, 3, 3, 3));
|
||||
|
||||
hexButton = new JToggleButton(View.getIcon("hex16"));
|
||||
hexButton.setActionCommand("HEX");
|
||||
hexButton.setActionCommand(ACTION_HEX);
|
||||
hexButton.addActionListener(this);
|
||||
hexButton.setToolTipText(AppStrings.translate("button.viewhex"));
|
||||
hexButton.setMargin(new Insets(3, 3, 3, 3));
|
||||
|
||||
// todo: find icon
|
||||
hexOnlyButton = new JToggleButton(View.getIcon("hex16"));
|
||||
hexOnlyButton.setActionCommand("HEXONLY");
|
||||
hexOnlyButton.setActionCommand(ACTION_HEX_ONLY);
|
||||
hexOnlyButton.addActionListener(this);
|
||||
hexOnlyButton.setToolTipText(AppStrings.translate("button.viewhex"));
|
||||
hexOnlyButton.setMargin(new Insets(3, 3, 3, 3));
|
||||
@@ -507,23 +520,23 @@ public class ActionPanel extends JPanel implements ActionListener {
|
||||
panB.add(buttonsPan, BorderLayout.SOUTH);
|
||||
|
||||
saveButton.addActionListener(this);
|
||||
saveButton.setActionCommand("SAVEACTION");
|
||||
saveButton.setActionCommand(ACTION_SAVE_ACTION);
|
||||
editButton.addActionListener(this);
|
||||
editButton.setActionCommand("EDITACTION");
|
||||
editButton.setActionCommand(ACTION_EDIT_ACTION);
|
||||
cancelButton.addActionListener(this);
|
||||
cancelButton.setActionCommand("CANCELACTION");
|
||||
cancelButton.setActionCommand(ACTION_CANCEL_ACTION);
|
||||
saveButton.setVisible(false);
|
||||
cancelButton.setVisible(false);
|
||||
|
||||
|
||||
|
||||
saveDecompiledButton.addActionListener(this);
|
||||
saveDecompiledButton.setActionCommand("SAVEDECOMPILED");
|
||||
saveDecompiledButton.setActionCommand(ACTION_SAVE_DECOMPILED);
|
||||
editDecompiledButton.addActionListener(this);
|
||||
editDecompiledButton.setActionCommand("EDITDECOMPILED");
|
||||
editDecompiledButton.setActionCommand(ACTION_EDIT_DECOMPILED);
|
||||
|
||||
cancelDecompiledButton.addActionListener(this);
|
||||
cancelDecompiledButton.setActionCommand("CANCELDECOMPILED");
|
||||
cancelDecompiledButton.setActionCommand(ACTION_CANCEL_DECOMPILED);
|
||||
saveDecompiledButton.setVisible(false);
|
||||
cancelDecompiledButton.setVisible(false);
|
||||
|
||||
@@ -720,7 +733,7 @@ public class ActionPanel extends JPanel implements ActionListener {
|
||||
updateSearchPos();
|
||||
}
|
||||
switch (e.getActionCommand()) {
|
||||
case "GRAPH":
|
||||
case ACTION_GRAPH:
|
||||
if (lastCode != null) {
|
||||
try {
|
||||
GraphFrame gf = new GraphFrame(new ActionGraph(lastCode, new HashMap<Integer, String>(), new HashMap<String, GraphTargetItem>(), new HashMap<String, GraphTargetItem>(), SWF.DEFAULT_VERSION), "");
|
||||
@@ -730,23 +743,23 @@ public class ActionPanel extends JPanel implements ActionListener {
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "EDITACTION":
|
||||
case ACTION_EDIT_ACTION:
|
||||
setEditMode(true);
|
||||
break;
|
||||
case "HEX":
|
||||
case "HEXONLY":
|
||||
if (e.getActionCommand().equals("HEX")) {
|
||||
case ACTION_HEX:
|
||||
case ACTION_HEX_ONLY:
|
||||
if (e.getActionCommand() == ACTION_HEX) {
|
||||
hexOnlyButton.setSelected(false);
|
||||
} else {
|
||||
hexButton.setSelected(false);
|
||||
}
|
||||
setHex(getExportMode());
|
||||
break;
|
||||
case "CANCELACTION":
|
||||
case ACTION_CANCEL_ACTION:
|
||||
setEditMode(false);
|
||||
setHex(getExportMode());
|
||||
break;
|
||||
case "SAVEACTION":
|
||||
case ACTION_SAVE_ACTION:
|
||||
try {
|
||||
String text = editor.getText();
|
||||
if (text.trim().startsWith("#hexdata")) {
|
||||
@@ -766,13 +779,13 @@ public class ActionPanel extends JPanel implements ActionListener {
|
||||
View.showMessageDialog(this, AppStrings.translate("error.action.save").replace("%error%", ex.text).replace("%line%", "" + ex.line), AppStrings.translate("error"), JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
break;
|
||||
case "EDITDECOMPILED":
|
||||
case ACTION_EDIT_DECOMPILED:
|
||||
setDecompiledEditMode(true);
|
||||
break;
|
||||
case "CANCELDECOMPILED":
|
||||
case ACTION_CANCEL_DECOMPILED:
|
||||
setDecompiledEditMode(false);
|
||||
break;
|
||||
case "SAVEDECOMPILED":
|
||||
case ACTION_SAVE_DECOMPILED:
|
||||
try {
|
||||
ActionScriptParser par = new ActionScriptParser();
|
||||
src.setActions(par.actionsFromString(decompiledEditor.getText()), SWF.DEFAULT_VERSION);
|
||||
|
||||
@@ -41,6 +41,9 @@ import javax.swing.JProgressBar;
|
||||
*/
|
||||
public class PlayerControls extends JPanel implements ActionListener {
|
||||
|
||||
static final String ACTION_PAUSE = "PAUSE";
|
||||
static final String ACTION_STOP = "STOP";
|
||||
|
||||
private JButton pauseButton;
|
||||
private boolean paused = false;
|
||||
private FlashDisplay display;
|
||||
@@ -64,11 +67,11 @@ public class PlayerControls extends JPanel implements ActionListener {
|
||||
|
||||
pauseButton = new JButton(AppStrings.translate("preview.pause"), pauseIcon);
|
||||
pauseButton.setMargin(new Insets(0, 0, 0, 0));
|
||||
pauseButton.setActionCommand("PAUSE");
|
||||
pauseButton.setActionCommand(ACTION_PAUSE);
|
||||
pauseButton.addActionListener(this);
|
||||
JButton stopButton = new JButton(AppStrings.translate("preview.stop"), View.getIcon("stop16"));
|
||||
stopButton.setMargin(new Insets(0, 0, 0, 0));
|
||||
stopButton.setActionCommand("STOP");
|
||||
stopButton.setActionCommand(ACTION_STOP);
|
||||
stopButton.addActionListener(this);
|
||||
buttonsPanel.add(pauseButton);
|
||||
buttonsPanel.add(stopButton);
|
||||
@@ -165,14 +168,14 @@ public class PlayerControls extends JPanel implements ActionListener {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
switch (e.getActionCommand()) {
|
||||
case "PAUSE":
|
||||
case ACTION_PAUSE:
|
||||
if (paused) {
|
||||
display.play();
|
||||
} else {
|
||||
display.pause();
|
||||
}
|
||||
break;
|
||||
case "STOP":
|
||||
case ACTION_STOP:
|
||||
display.pause();
|
||||
display.rewind();
|
||||
break;
|
||||
|
||||
@@ -48,6 +48,12 @@ import javax.swing.*;
|
||||
*/
|
||||
public class ProxyFrame extends AppFrame implements ActionListener, CatchedListener, MouseListener, ReplacedListener {
|
||||
|
||||
static final String ACTION_SWITCH_STATE = "SWITCHSTATE";
|
||||
static final String ACTION_OPEN = "OPEN";
|
||||
static final String ACTION_CLEAR = "CLEAR";
|
||||
static final String ACTION_RENAME = "RENAME";
|
||||
static final String ACTION_REMOVE = "REMOVE";
|
||||
|
||||
private JList swfList;
|
||||
private SWFListModel listModel;
|
||||
private JButton switchButton = new JButton(translate("proxy.start"));
|
||||
@@ -87,7 +93,7 @@ public class ProxyFrame extends AppFrame implements ActionListener, CatchedListe
|
||||
swfList.addMouseListener(this);
|
||||
swfList.setFont(new Font("Monospaced", Font.PLAIN, 12));
|
||||
switchButton.addActionListener(this);
|
||||
switchButton.setActionCommand("SWITCHSTATE");
|
||||
switchButton.setActionCommand(ACTION_SWITCH_STATE);
|
||||
Container cnt = getContentPane();
|
||||
cnt.setLayout(new BorderLayout());
|
||||
cnt.add(new JScrollPane(swfList), BorderLayout.CENTER);
|
||||
@@ -108,19 +114,19 @@ public class ProxyFrame extends AppFrame implements ActionListener, CatchedListe
|
||||
JPanel buttonsPanel2 = new JPanel();
|
||||
buttonsPanel2.setLayout(new FlowLayout());
|
||||
JButton openButton = new JButton(translate("open"));
|
||||
openButton.setActionCommand("OPEN");
|
||||
openButton.setActionCommand(ACTION_OPEN);
|
||||
openButton.addActionListener(this);
|
||||
buttonsPanel2.add(openButton);
|
||||
JButton clearButton = new JButton(translate("clear"));
|
||||
clearButton.setActionCommand("CLEAR");
|
||||
clearButton.setActionCommand(ACTION_CLEAR);
|
||||
clearButton.addActionListener(this);
|
||||
buttonsPanel2.add(clearButton);
|
||||
JButton renameButton = new JButton(translate("rename"));
|
||||
renameButton.setActionCommand("RENAME");
|
||||
renameButton.setActionCommand(ACTION_RENAME);
|
||||
renameButton.addActionListener(this);
|
||||
buttonsPanel2.add(renameButton);
|
||||
JButton removeButton = new JButton(translate("remove"));
|
||||
removeButton.setActionCommand("REMOVE");
|
||||
removeButton.setActionCommand(ACTION_REMOVE);
|
||||
removeButton.addActionListener(this);
|
||||
buttonsPanel2.add(removeButton);
|
||||
|
||||
@@ -183,54 +189,56 @@ public class ProxyFrame extends AppFrame implements ActionListener, CatchedListe
|
||||
*/
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (e.getActionCommand().equals("OPEN")) {
|
||||
open();
|
||||
}
|
||||
if (e.getActionCommand().equals("RENAME")) {
|
||||
if (swfList.getSelectedIndex() > -1) {
|
||||
Replacement r = (Replacement) listModel.getElementAt(swfList.getSelectedIndex());
|
||||
String s = View.showInputDialog("URL", r.urlPattern);
|
||||
r.urlPattern = s;
|
||||
listModel.dataChanged(swfList.getSelectedIndex());
|
||||
}
|
||||
}
|
||||
if (e.getActionCommand().equals("CLEAR")) {
|
||||
for (int i = 0; i < listModel.getSize(); i++) {
|
||||
Replacement r = (Replacement) listModel.getElementAt(i);
|
||||
File f;
|
||||
try {
|
||||
f = (new File(Main.tempFile(r.targetFile)));
|
||||
if (f.exists()) {
|
||||
f.delete();
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(ProxyFrame.class.getName()).log(Level.SEVERE, null, ex);
|
||||
switch (e.getActionCommand()) {
|
||||
case ACTION_OPEN:
|
||||
open();
|
||||
break;
|
||||
case ACTION_RENAME:
|
||||
if (swfList.getSelectedIndex() > -1) {
|
||||
Replacement r = (Replacement) listModel.getElementAt(swfList.getSelectedIndex());
|
||||
String s = View.showInputDialog("URL", r.urlPattern);
|
||||
r.urlPattern = s;
|
||||
listModel.dataChanged(swfList.getSelectedIndex());
|
||||
}
|
||||
break;
|
||||
case ACTION_CLEAR:
|
||||
for (int i = 0; i < listModel.getSize(); i++) {
|
||||
Replacement r = (Replacement) listModel.getElementAt(i);
|
||||
File f;
|
||||
try {
|
||||
f = (new File(Main.tempFile(r.targetFile)));
|
||||
if (f.exists()) {
|
||||
f.delete();
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(ProxyFrame.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
|
||||
}
|
||||
listModel.clear();
|
||||
}
|
||||
if (e.getActionCommand().equals("REMOVE")) {
|
||||
int lastIndex = -1;
|
||||
for (int k = listModel.getSize() - 1; k >= 0; k--) {
|
||||
if (swfList.isSelectedIndex(k)) {
|
||||
Replacement r = listModel.removeURL(k);
|
||||
File f = (new File(r.targetFile));
|
||||
if (f.exists()) {
|
||||
f.delete();
|
||||
}
|
||||
lastIndex = k;
|
||||
}
|
||||
}
|
||||
if (lastIndex >= listModel.getSize()) {
|
||||
lastIndex--;
|
||||
}
|
||||
if (lastIndex > -1) {
|
||||
swfList.setSelectedIndex(lastIndex);
|
||||
}
|
||||
}
|
||||
if (e.getActionCommand().equals("SWITCHSTATE")) {
|
||||
Main.switchProxy();
|
||||
listModel.clear();
|
||||
break;
|
||||
case ACTION_REMOVE:
|
||||
int lastIndex = -1;
|
||||
for (int k = listModel.getSize() - 1; k >= 0; k--) {
|
||||
if (swfList.isSelectedIndex(k)) {
|
||||
Replacement r = listModel.removeURL(k);
|
||||
File f = (new File(r.targetFile));
|
||||
if (f.exists()) {
|
||||
f.delete();
|
||||
}
|
||||
lastIndex = k;
|
||||
}
|
||||
}
|
||||
if (lastIndex >= listModel.getSize()) {
|
||||
lastIndex--;
|
||||
}
|
||||
if (lastIndex > -1) {
|
||||
swfList.setSelectedIndex(lastIndex);
|
||||
}
|
||||
break;
|
||||
case ACTION_SWITCH_STATE:
|
||||
Main.switchProxy();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -101,7 +101,7 @@ public class DefineButton2Tag extends CharacterTag implements Container, Bounded
|
||||
int actionOffset = sis.readUI16();
|
||||
characters = sis.readBUTTONRECORDList(true);
|
||||
if (actionOffset > 0) {
|
||||
actions = sis.readBUTTONCONDACTIONList();
|
||||
actions = sis.readBUTTONCONDACTIONList(swf);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -240,7 +240,7 @@ public class PlaceObject2Tag extends CharacterIdTag implements Container, PlaceO
|
||||
clipDepth = sis.readUI16();
|
||||
}
|
||||
if (placeFlagHasClipActions) {
|
||||
clipActions = sis.readCLIPACTIONS();
|
||||
clipActions = sis.readCLIPACTIONS(swf);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -347,7 +347,7 @@ public class PlaceObject3Tag extends CharacterIdTag implements Container, PlaceO
|
||||
}
|
||||
|
||||
if (placeFlagHasClipActions) {
|
||||
clipActions = sis.readCLIPACTIONS();
|
||||
clipActions = sis.readCLIPACTIONS(swf);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -348,7 +348,7 @@ public class PlaceObject4Tag extends CharacterIdTag implements Container, PlaceO
|
||||
}
|
||||
|
||||
if (placeFlagHasClipActions) {
|
||||
clipActions = sis.readCLIPACTIONS();
|
||||
clipActions = sis.readCLIPACTIONS(swf);
|
||||
}
|
||||
amfData = sis.readBytes(sis.available());
|
||||
}
|
||||
|
||||
@@ -67,6 +67,10 @@ public class Tag implements NeedsCharacters, Exportable, ContainerItem {
|
||||
return id;
|
||||
}
|
||||
|
||||
public SWF getSwf() {
|
||||
return swf;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
|
||||
@@ -16,10 +16,14 @@
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.tags.base;
|
||||
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
|
||||
/**
|
||||
* Object which contains other objects
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public interface ContainerItem {
|
||||
|
||||
SWF getSwf();
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.jpexs.decompiler.flash.types;
|
||||
|
||||
import com.jpexs.decompiler.flash.DisassemblyListener;
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.SWFInputStream;
|
||||
import com.jpexs.decompiler.flash.action.Action;
|
||||
import com.jpexs.decompiler.flash.action.ActionListReader;
|
||||
@@ -42,14 +43,21 @@ import java.util.logging.Logger;
|
||||
*/
|
||||
public class BUTTONCONDACTION implements ASMSource, Exportable, ContainerItem {
|
||||
|
||||
private SWF swf;
|
||||
private long pos;
|
||||
|
||||
@Override
|
||||
public SWF getSwf() {
|
||||
return swf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getPos() {
|
||||
return pos;
|
||||
}
|
||||
|
||||
public BUTTONCONDACTION(InputStream is, int version, long containerOffset) throws IOException {
|
||||
public BUTTONCONDACTION(SWF swf, InputStream is, int version, long containerOffset) throws IOException {
|
||||
this.swf = swf;
|
||||
SWFInputStream sis = new SWFInputStream(is, version);
|
||||
pos = containerOffset;
|
||||
int condActionSize = sis.readUI16();
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.jpexs.decompiler.flash.types;
|
||||
|
||||
import com.jpexs.decompiler.flash.DisassemblyListener;
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.SWFInputStream;
|
||||
import com.jpexs.decompiler.flash.action.Action;
|
||||
import com.jpexs.decompiler.flash.action.ActionListReader;
|
||||
@@ -84,10 +85,13 @@ public class CLIPACTIONRECORD implements ASMSource, Exportable, ContainerItem {
|
||||
null,
|
||||
"<Space>"
|
||||
};
|
||||
|
||||
private SWF swf;
|
||||
private long pos;
|
||||
private long hdrPos;
|
||||
|
||||
public CLIPACTIONRECORD(InputStream is, int version, long pos) throws IOException {
|
||||
public CLIPACTIONRECORD(SWF swf, InputStream is, int version, long pos) throws IOException {
|
||||
this.swf = swf;
|
||||
SWFInputStream sis = new SWFInputStream(is, version);
|
||||
eventFlags = sis.readCLIPEVENTFLAGS();
|
||||
if (eventFlags.isClear()) {
|
||||
@@ -104,6 +108,11 @@ public class CLIPACTIONRECORD implements ASMSource, Exportable, ContainerItem {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public SWF getSwf() {
|
||||
return swf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getPos() {
|
||||
return pos;
|
||||
|
||||
@@ -498,19 +498,21 @@ public class Helper {
|
||||
try {
|
||||
f.setAccessible(true);
|
||||
Object v = f.get(obj);
|
||||
if (v instanceof Collection) {
|
||||
((Collection) v).clear();
|
||||
}
|
||||
if (v instanceof Component) {
|
||||
if (((Component) v).getParent() != null) {
|
||||
((Component) v).getParent().remove((Component) v);
|
||||
if (v != null) {
|
||||
if (v instanceof Collection) {
|
||||
((Collection) v).clear();
|
||||
}
|
||||
if (v instanceof Component) {
|
||||
if (((Component) v).getParent() != null) {
|
||||
((Component) v).getParent().remove((Component) v);
|
||||
}
|
||||
}
|
||||
if (v instanceof Freed) {
|
||||
((Freed) v).free();
|
||||
}
|
||||
f.set(obj, null);
|
||||
}
|
||||
if (v instanceof Freed) {
|
||||
((Freed) v).free();
|
||||
}
|
||||
f.set(obj, null);
|
||||
} catch (SecurityException | IllegalArgumentException | IllegalAccessException ex) {
|
||||
} catch (UnsupportedOperationException | SecurityException | IllegalArgumentException | IllegalAccessException ex) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user