diff --git a/trunk/src/com/jpexs/decompiler/flash/SWF.java b/trunk/src/com/jpexs/decompiler/flash/SWF.java index 80069b16c..6d99694df 100644 --- a/trunk/src/com/jpexs/decompiler/flash/SWF.java +++ b/trunk/src/com/jpexs/decompiler/flash/SWF.java @@ -1404,7 +1404,7 @@ public class SWF { } if (name instanceof DirectValueTreeItem) { - variables.add(new KeyValue((DirectValueTreeItem) name, constantPool)); + variables.add(new KeyValue<>((DirectValueTreeItem) name, constantPool)); usageTypes.put((DirectValueTreeItem) name, usageType); } diff --git a/trunk/src/com/jpexs/decompiler/flash/TagNode.java b/trunk/src/com/jpexs/decompiler/flash/TagNode.java index 3a1e400f4..2351d9358 100644 --- a/trunk/src/com/jpexs/decompiler/flash/TagNode.java +++ b/trunk/src/com/jpexs/decompiler/flash/TagNode.java @@ -17,6 +17,7 @@ package com.jpexs.decompiler.flash; import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.helpers.Helper; import com.jpexs.decompiler.flash.helpers.Highlighting; import com.jpexs.decompiler.flash.tags.DefineBitsJPEG2Tag; import com.jpexs.decompiler.flash.tags.DefineBitsJPEG3Tag; @@ -42,9 +43,9 @@ import com.jpexs.decompiler.flash.tags.DefineText2Tag; import com.jpexs.decompiler.flash.tags.DefineTextTag; import com.jpexs.decompiler.flash.tags.ExportAssetsTag; import com.jpexs.decompiler.flash.tags.ShowFrameTag; -import com.jpexs.decompiler.flash.tags.Tag; import com.jpexs.decompiler.flash.tags.base.ASMSource; import com.jpexs.decompiler.flash.tags.base.Container; +import com.jpexs.decompiler.flash.tags.base.Exportable; import java.io.File; import java.io.FileOutputStream; import java.util.ArrayList; @@ -240,10 +241,10 @@ public class TagNode { List existingNames = new ArrayList<>(); for (TagNode node : nodeList) { String name = ""; - if (node.tag instanceof Tag) { - name = ((Tag) node.tag).getExportFileName(); + if (node.tag instanceof Exportable) { + name = ((Exportable) node.tag).getExportFileName(); } else { - name = node.tag.toString(); + name = Helper.makeFileName(node.tag.toString()); } int i = 1; String baseName = name; @@ -266,12 +267,13 @@ public class TagNode { ev.handleEvent("export", "Exporting " + f + " ..."); } String res; + ASMSource asm = ((ASMSource) node.tag); if (isPcode) { - res = Highlighting.stripHilights(((ASMSource) node.tag).getASMSource(SWF.DEFAULT_VERSION, false)); + res = asm.getActionSourcePrefix() + Highlighting.stripHilights(asm.getASMSource(SWF.DEFAULT_VERSION, false)) + asm.getActionSourceSuffix(); } else { - List as = ((ASMSource) node.tag).getActions(SWF.DEFAULT_VERSION); + List as = asm.getActions(SWF.DEFAULT_VERSION); Action.setActionsAddresses(as, 0, SWF.DEFAULT_VERSION); - res = (Highlighting.stripHilights(Action.actionsToSource(as, SWF.DEFAULT_VERSION))); + res = asm.getActionSourcePrefix() + Highlighting.stripHilights(Action.actionsToSource(as, SWF.DEFAULT_VERSION)) + asm.getActionSourceSuffix(); } try (FileOutputStream fos = new FileOutputStream(f)) { fos.write(res.getBytes("utf-8")); diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/ABC.java b/trunk/src/com/jpexs/decompiler/flash/abc/ABC.java index b375a60b2..790d23f53 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/ABC.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/ABC.java @@ -31,7 +31,6 @@ import com.jpexs.decompiler.flash.abc.types.traits.TraitMethodGetterSetter; import com.jpexs.decompiler.flash.abc.types.traits.TraitSlotConst; import com.jpexs.decompiler.flash.abc.types.traits.Traits; import com.jpexs.decompiler.flash.abc.usages.*; -import com.jpexs.decompiler.flash.helpers.Helper; import com.jpexs.decompiler.flash.tags.ABCContainerTag; import java.io.*; import java.util.ArrayList; diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/Main.java b/trunk/src/com/jpexs/decompiler/flash/gui/Main.java index eae68c22f..699853000 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/Main.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/Main.java @@ -48,7 +48,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Calendar; import java.util.Properties; -import java.util.TreeMap; import java.util.logging.ConsoleHandler; import java.util.logging.FileHandler; import java.util.logging.Level; diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java b/trunk/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java index b4bfdf5d8..078378b80 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java @@ -52,8 +52,6 @@ import java.io.StringReader; import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; import java.util.regex.Pattern; import javax.swing.BoxLayout; import javax.swing.JButton; @@ -100,6 +98,7 @@ public class ActionPanel extends JPanel implements ActionListener { private String srcWithHex; private String srcNoHex; private String lastDecompiled = ""; + private ASMSource lastASM; public JPanel searchPanel; public JLabel searchPos; private List found = new ArrayList<>(); @@ -295,8 +294,9 @@ public class ActionPanel extends JPanel implements ActionListener { lastCode = asm.getActions(SWF.DEFAULT_VERSION); decompiledHilights = sc.hilights; lastDecompiled = sc.text; + lastASM = asm; stripped = lastDecompiled; - decompiledEditor.setText(lastDecompiled); + decompiledEditor.setText(asm.getActionSourcePrefix() + lastDecompiled + asm.getActionSourceSuffix()); } setEditMode(false); setDecompiledEditMode(false); @@ -540,7 +540,17 @@ public class ActionPanel extends JPanel implements ActionListener { } public void setDecompiledEditMode(boolean val) { + String pref = lastASM.getActionSourcePrefix(); + int lastPos = decompiledEditor.getCaretPosition(); if (val) { + String newText = lastDecompiled; + decompiledEditor.setText(newText); + if (lastPos > -1) { + int newpos = lastPos - pref.length(); + if (newpos < newText.length() && newpos >= 0) { + decompiledEditor.setCaretPosition(newpos); + } + } decompiledEditor.setEditable(true); saveDecompiledButton.setVisible(true); editDecompiledButton.setVisible(false); @@ -549,6 +559,14 @@ public class ActionPanel extends JPanel implements ActionListener { decompiledEditor.getCaret().setVisible(true); decLabel.setIcon(View.getIcon("editing16")); } else { + String newText = pref + lastDecompiled + lastASM.getActionSourceSuffix(); + decompiledEditor.setText(newText); + if (lastPos > -1) { + int newpos = lastPos + pref.length(); + if (newpos < newText.length()) { + decompiledEditor.setCaretPosition(newpos); + } + } decompiledEditor.setEditable(false); saveDecompiledButton.setVisible(false); editDecompiledButton.setVisible(true); @@ -610,19 +628,13 @@ public class ActionPanel extends JPanel implements ActionListener { setDecompiledEditMode(true); } else if (e.getActionCommand().equals("CANCELDECOMPILED")) { setDecompiledEditMode(false); - decompiledEditor.setText(lastDecompiled); } else if (e.getActionCommand().equals("SAVEDECOMPILED")) { try { ActionScriptParser par = new ActionScriptParser(); src.setActions(par.parse(decompiledEditor.getText()), SWF.DEFAULT_VERSION); setSource(this.src, false); JOptionPane.showMessageDialog(this, translate("message.action.saved")); - saveDecompiledButton.setVisible(false); - cancelDecompiledButton.setVisible(false); - editDecompiledButton.setVisible(true); - experimentalLabel.setVisible(true); - decompiledEditor.setEditable(false); - editDecompiledMode = false; + setDecompiledEditMode(false); } catch (IOException ex) { } catch (ParseException ex) { JOptionPane.showMessageDialog(this, translate("error.action.save").replace("%error%", ex.text).replace("%line%", "" + ex.line), translate("error"), JOptionPane.ERROR_MESSAGE); diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DefineButtonTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DefineButtonTag.java index 20773f256..912106f2e 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DefineButtonTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DefineButtonTag.java @@ -83,6 +83,7 @@ public class DefineButtonTag extends CharacterTag implements ASMSource, BoundedT * * @param data Data bytes * @param version SWF version + * @param pos * @throws IOException */ public DefineButtonTag(byte[] data, int version, long pos) throws IOException { @@ -262,4 +263,14 @@ public class DefineButtonTag extends CharacterTag implements ASMSource, BoundedT public int getNumFrames() { return 1; } + + @Override + public String getActionSourcePrefix() { + return ""; + } + + @Override + public String getActionSourceSuffix() { + return ""; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DoActionTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DoActionTag.java index a6922a45b..28358a3b0 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DoActionTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DoActionTag.java @@ -150,4 +150,14 @@ public class DoActionTag extends Tag implements ASMSource { public void removeDisassemblyListener(DisassemblyListener listener) { listeners.remove(listener); } + + @Override + public String getActionSourcePrefix() { + return ""; + } + + @Override + public String getActionSourceSuffix() { + return ""; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DoInitActionTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DoInitActionTag.java index 244659de6..1e9367a1f 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DoInitActionTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DoInitActionTag.java @@ -192,4 +192,14 @@ public class DoInitActionTag extends CharacterIdTag implements ASMSource { } return pathParts[pathParts.length - 1]; } + + @Override + public String getActionSourcePrefix() { + return ""; + } + + @Override + public String getActionSourceSuffix() { + return ""; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/PlaceObject2Tag.java b/trunk/src/com/jpexs/decompiler/flash/tags/PlaceObject2Tag.java index 22855e7dc..f61e78fb0 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/PlaceObject2Tag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/PlaceObject2Tag.java @@ -367,4 +367,22 @@ public class PlaceObject2Tag extends Tag implements Container, PlaceObjectTypeTa public void setClassName(String className) { //not supported } + + @Override + public String toString() { + if (name != null) { + return super.toString() + " (" + name + ")"; + } else { + return super.toString(); + } + } + + @Override + public CLIPACTIONS getClipActions() { + if (placeFlagHasClipActions) { + return clipActions; + } else { + return null; + } + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/PlaceObject3Tag.java b/trunk/src/com/jpexs/decompiler/flash/tags/PlaceObject3Tag.java index 6ac864b08..23cdd9884 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/PlaceObject3Tag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/PlaceObject3Tag.java @@ -484,4 +484,22 @@ public class PlaceObject3Tag extends Tag implements Container, PlaceObjectTypeTa placeFlagHasClassName = true; this.className = className; } + + @Override + public String toString() { + if (name != null) { + return super.toString() + " (" + name + ")"; + } else { + return super.toString(); + } + } + + @Override + public CLIPACTIONS getClipActions() { + if (placeFlagHasClipActions) { + return clipActions; + } else { + return null; + } + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/PlaceObjectTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/PlaceObjectTag.java index ea15cbba0..19e9ca1b2 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/PlaceObjectTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/PlaceObjectTag.java @@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash.tags; import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.SWFOutputStream; +import com.jpexs.decompiler.flash.types.CLIPACTIONS; import com.jpexs.decompiler.flash.types.CXFORM; import com.jpexs.decompiler.flash.types.CXFORMWITHALPHA; import com.jpexs.decompiler.flash.types.MATRIX; @@ -196,4 +197,9 @@ public class PlaceObjectTag extends Tag implements PlaceObjectTypeTag { public void setClassName(String className) { //not supported } + + @Override + public CLIPACTIONS getClipActions() { + return null; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/PlaceObjectTypeTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/PlaceObjectTypeTag.java index 950b2e766..1772f49ba 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/PlaceObjectTypeTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/PlaceObjectTypeTag.java @@ -1,5 +1,6 @@ package com.jpexs.decompiler.flash.tags; +import com.jpexs.decompiler.flash.types.CLIPACTIONS; import com.jpexs.decompiler.flash.types.CXFORM; import com.jpexs.decompiler.flash.types.CXFORMWITHALPHA; import com.jpexs.decompiler.flash.types.MATRIX; @@ -46,4 +47,6 @@ public interface PlaceObjectTypeTag { public boolean flagMove(); public int getRatio(); + + public CLIPACTIONS getClipActions(); } diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/Tag.java b/trunk/src/com/jpexs/decompiler/flash/tags/Tag.java index e9ec2282a..b14006560 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/Tag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/Tag.java @@ -17,6 +17,7 @@ package com.jpexs.decompiler.flash.tags; import com.jpexs.decompiler.flash.tags.base.CharacterTag; +import com.jpexs.decompiler.flash.tags.base.Exportable; import com.jpexs.decompiler.flash.tags.base.NeedsCharacters; import java.util.HashMap; import java.util.HashSet; @@ -26,7 +27,7 @@ import java.util.Set; /** * Represents Tag inside SWF file */ -public class Tag implements NeedsCharacters { +public class Tag implements NeedsCharacters, Exportable { /** * Identifier of tag type @@ -49,6 +50,7 @@ public class Tag implements NeedsCharacters { return name; } + @Override public String getExportFileName() { return getName(); } @@ -68,6 +70,7 @@ public class Tag implements NeedsCharacters { * @param id Tag type identifier * @param name Tag name * @param data Bytes of data + * @param pos */ public Tag(int id, String name, byte[] data, long pos) { this.id = id; diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/base/ASMSource.java b/trunk/src/com/jpexs/decompiler/flash/tags/base/ASMSource.java index 91ae1587b..12167e867 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/base/ASMSource.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/base/ASMSource.java @@ -68,4 +68,8 @@ public interface ASMSource { public void addDisassemblyListener(DisassemblyListener listener); public void removeDisassemblyListener(DisassemblyListener listener); + + public String getActionSourcePrefix(); + + public String getActionSourceSuffix(); } diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/base/Exportable.java b/trunk/src/com/jpexs/decompiler/flash/tags/base/Exportable.java new file mode 100644 index 000000000..b9eb8ac8d --- /dev/null +++ b/trunk/src/com/jpexs/decompiler/flash/tags/base/Exportable.java @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2013 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.tags.base; + +/** + * + * @author JPEXS + */ +public interface Exportable { + + public String getExportFileName(); +} diff --git a/trunk/src/com/jpexs/decompiler/flash/types/BUTTONCONDACTION.java b/trunk/src/com/jpexs/decompiler/flash/types/BUTTONCONDACTION.java index 8cff8ba00..3733530ad 100644 --- a/trunk/src/com/jpexs/decompiler/flash/types/BUTTONCONDACTION.java +++ b/trunk/src/com/jpexs/decompiler/flash/types/BUTTONCONDACTION.java @@ -21,7 +21,9 @@ import com.jpexs.decompiler.flash.DisassemblyListener; import com.jpexs.decompiler.flash.ReReadableInputStream; import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.helpers.Helper; import com.jpexs.decompiler.flash.tags.base.ASMSource; +import com.jpexs.decompiler.flash.tags.base.Exportable; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; @@ -35,7 +37,7 @@ import java.util.logging.Logger; * * @author JPEXS */ -public class BUTTONCONDACTION implements ASMSource { +public class BUTTONCONDACTION implements ASMSource, Exportable { private long pos; @@ -204,4 +206,59 @@ public class BUTTONCONDACTION implements ASMSource { public void removeDisassemblyListener(DisassemblyListener listener) { listeners.remove(listener); } + + private String getHeader(boolean asFilename) { + List events = new ArrayList<>(); + if (condOverUpToOverDown) { + events.add("press"); + } + if (condOverDownToOverUp) { + events.add("release"); + } + if (condOutDownToIdle) { + events.add("releaseOutside"); + } + if (condIdleToOverUp) { + events.add("rollOver"); + } + if (condOverUpToIddle) { + events.add("rollOut"); + } + if (condOverDownToOutDown) { + events.add("dragOut"); + } + if (condOutDownToOverDown) { + events.add("dragOver"); + } + if (condKeyPress > 0) { + if (asFilename) { + events.add("keyPress " + Helper.makeFileName(CLIPACTIONRECORD.keyToString(condKeyPress).replace("<", "").replace(">", "")) + ""); + } else { + events.add("keyPress \"" + CLIPACTIONRECORD.keyToString(condKeyPress) + "\""); + } + } + String onStr = ""; + for (int i = 0; i < events.size(); i++) { + if (i > 0) { + onStr += ", "; + } + onStr += events.get(i); + } + return "on(" + onStr + ")"; + } + + @Override + public String getActionSourcePrefix() { + return getHeader(false) + "{\r\n"; + } + + @Override + public String getActionSourceSuffix() { + return "}\r\n"; + } + + @Override + public String getExportFileName() { + return getHeader(true); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/types/CLIPACTIONRECORD.java b/trunk/src/com/jpexs/decompiler/flash/types/CLIPACTIONRECORD.java index e42a61b78..5d34b1f6a 100644 --- a/trunk/src/com/jpexs/decompiler/flash/types/CLIPACTIONRECORD.java +++ b/trunk/src/com/jpexs/decompiler/flash/types/CLIPACTIONRECORD.java @@ -22,6 +22,7 @@ import com.jpexs.decompiler.flash.ReReadableInputStream; import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.tags.base.ASMSource; +import com.jpexs.decompiler.flash.tags.base.Exportable; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; @@ -35,8 +36,50 @@ import java.util.logging.Logger; * * @author JPEXS */ -public class CLIPACTIONRECORD implements ASMSource { +public class CLIPACTIONRECORD implements ASMSource, Exportable { + public static String keyToString(int key) { + if ((key < CLIPACTIONRECORD.KEYNAMES.length) && (key > 0) && (CLIPACTIONRECORD.KEYNAMES[key] != null)) { + return CLIPACTIONRECORD.KEYNAMES[key]; + } else { + return "" + (char) key; + } + } + public static final String KEYNAMES[] = { + null, + "", + "", + "", + "", + "", + "", + null, + "", + null, + null, + null, + null, + "", + "", + "", + "", + "", + "", + "", + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + "" + }; private long pos; private long hdrPos; @@ -82,7 +125,7 @@ public class CLIPACTIONRECORD implements ASMSource { */ @Override public String toString() { - return "CLIPACTIONRECORD"; + return eventFlags.getHeader(keyCode, false); } /** @@ -160,4 +203,19 @@ public class CLIPACTIONRECORD implements ASMSource { public void removeDisassemblyListener(DisassemblyListener listener) { listeners.remove(listener); } + + @Override + public String getActionSourcePrefix() { + return eventFlags.getHeader(keyCode, false) + "{\r\n"; + } + + @Override + public String getActionSourceSuffix() { + return "}\r\n"; + } + + @Override + public String getExportFileName() { + return eventFlags.getHeader(keyCode, true); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/types/CLIPEVENTFLAGS.java b/trunk/src/com/jpexs/decompiler/flash/types/CLIPEVENTFLAGS.java index ce81bfbff..99703122f 100644 --- a/trunk/src/com/jpexs/decompiler/flash/types/CLIPEVENTFLAGS.java +++ b/trunk/src/com/jpexs/decompiler/flash/types/CLIPEVENTFLAGS.java @@ -16,6 +16,10 @@ */ package com.jpexs.decompiler.flash.types; +import com.jpexs.decompiler.flash.helpers.Helper; +import java.util.ArrayList; +import java.util.List; + /** * Specifies one or more sprite events to which an event handler applies. * @@ -100,72 +104,75 @@ public class CLIPEVENTFLAGS { */ public boolean clipEventDragOut = false; - /** - * Returns a string representation of the object - * - * @return a string representation of the object. - */ - @Override - public String toString() { + public String getHeader(int key, boolean asFileName) { String ret = ""; + List onList = new ArrayList<>(); if (clipEventKeyUp) { - ret += "onClipEvent(keyUp)"; + ret = "onClipEvent(keyUp)"; } if (clipEventKeyDown) { - ret += "onClipEvent(keyDown)"; + ret = "onClipEvent(keyDown)"; } if (clipEventMouseUp) { - ret += "onClipEvent(mouseUp)"; + ret = "onClipEvent(mouseUp)"; } if (clipEventMouseDown) { - ret += "onClipEvent(mouseDown)"; + ret = "onClipEvent(mouseDown)"; } if (clipEventMouseMove) { - ret += "onClipEvent(mouseMove)"; + ret = "onClipEvent(mouseMove)"; } if (clipEventUnload) { - ret += "onClipEvent(unload)"; + ret = "onClipEvent(unload)"; } if (clipEventEnterFrame) { - ret += "onClipEvent(enterFrame)"; + ret = "onClipEvent(enterFrame)"; } if (clipEventLoad) { - ret += "onClipEvent(load)"; - } - if (clipEventDragOver) { - ret += "on(dragOver)"; - } - if (clipEventRollOut) { - ret += "on(rollOut)"; - } - if (clipEventRollOver) { - ret += "on(rollOver)"; - } - if (clipEventReleaseOutside) { - ret += "on(releaseOutside)"; - } - if (clipEventRelease) { - ret += "on(release)"; - } - if (clipEventPress) { - ret += "on(press)"; - } - if (clipEventInitialize) { - ret += "on(initialize)"; + ret = "onClipEvent(load)"; } if (clipEventData) { - ret += "onClipEvent(data)"; + ret = "onClipEvent(data)"; } - if (clipEventConstruct) { - ret += "on(construct)"; + if (clipEventDragOver) { + onList.add("dragOver"); } - if (clipEventKeyPress) { - ret += "on(keyPress)"; + if (clipEventRollOut) { + onList.add("rollOut"); } - if (clipEventDragOut) { - ret += "on(dragOut)"; + if (clipEventRollOver) { + onList.add("rollOver"); + } + if (clipEventReleaseOutside) { + onList.add("releaseOutside"); + } + if (clipEventRelease) { + onList.add("release"); + } + if (clipEventPress) { + onList.add("press"); + } + if (clipEventInitialize) { + onList.add("initialize"); } + if (clipEventConstruct) { + onList.add("construct"); + } + if (clipEventKeyPress) { + if (asFileName) { + onList.add("keyPress " + Helper.makeFileName(CLIPACTIONRECORD.keyToString(key).replace("<", "").replace(">", "")) + ""); + } else { + onList.add("keyPress \"" + CLIPACTIONRECORD.keyToString(key) + "\""); + } + } + if (clipEventDragOut) { + onList.add("dragOut"); + } + + if (!onList.isEmpty()) { + ret = "on(" + Helper.joinStrings(onList, ",") + ")"; + } return ret.trim(); } diff --git a/trunk/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java b/trunk/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java index 1829801f4..5c8766105 100644 --- a/trunk/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java +++ b/trunk/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java @@ -54,6 +54,8 @@ import com.jpexs.decompiler.flash.tags.base.ShapeTag; import com.jpexs.decompiler.flash.tags.base.TextTag; import com.jpexs.decompiler.flash.types.BUTTONCONDACTION; import com.jpexs.decompiler.flash.types.BUTTONRECORD; +import com.jpexs.decompiler.flash.types.CLIPACTIONRECORD; +import com.jpexs.decompiler.flash.types.CLIPACTIONS; import com.jpexs.decompiler.flash.types.CXFORM; import com.jpexs.decompiler.flash.types.CXFORMWITHALPHA; import com.jpexs.decompiler.flash.types.FILLSTYLE; @@ -1015,7 +1017,7 @@ public class XFLConverter { return ret; } - public static String convertSymbolInstance(String name, MATRIX matrix, CXFORM colorTransform, CXFORMWITHALPHA colorTransformAlpha, boolean cacheAsBitmap, int blendMode, List filters, boolean isVisible, RGBA backgroundColor, CharacterTag tag, HashMap characters, List tags) { + public static String convertSymbolInstance(String name, MATRIX matrix, CXFORM colorTransform, CXFORMWITHALPHA colorTransformAlpha, boolean cacheAsBitmap, int blendMode, List filters, boolean isVisible, RGBA backgroundColor, CLIPACTIONS clipActions, CharacterTag tag, HashMap characters, List tags) { String ret = ""; if (matrix == null) { matrix = new MATRIX(); @@ -1121,91 +1123,25 @@ public class XFLConverter { if (!db2.actions.isEmpty()) { ret += ""; } } + if (clipActions != null) { + ret += ""; + } ret += ""; return ret; } private static String convertActionScript(ASMSource as) { String decompiledASHilighted = com.jpexs.decompiler.flash.action.Action.actionsToSource(as.getActions(SWF.DEFAULT_VERSION), SWF.DEFAULT_VERSION); - return Highlighting.stripHilights(decompiledASHilighted); + return as.getActionSourcePrefix() + Highlighting.stripHilights(decompiledASHilighted) + as.getActionSourceSuffix(); } private static long getTimestamp() { @@ -1312,11 +1248,11 @@ public class XFLConverter { MATRIX matrix = rec.placeMatrix; String recCharStr = ""; if (character instanceof TextTag) { - recCharStr = convertText(null, tags, (TextTag) character, matrix, filters); + recCharStr = convertText(null, tags, (TextTag) character, matrix, filters, null); } else if (character instanceof DefineVideoStreamTag) { - recCharStr = convertVideoInstance(null, matrix, (DefineVideoStreamTag) character); + recCharStr = convertVideoInstance(null, matrix, (DefineVideoStreamTag) character, null); } else { - recCharStr = convertSymbolInstance(null, matrix, null, colorTransformAlpha, false, blendMode, filters, true, null, characters.get(rec.characterId), characters, tags); + recCharStr = convertSymbolInstance(null, matrix, null, colorTransformAlpha, false, blendMode, filters, true, null, null, characters.get(rec.characterId), characters, tags); } int duration = frame - lastFrame; lastFrame = frame; @@ -1783,7 +1719,7 @@ public class XFLConverter { return ret; } - private static String convertVideoInstance(String instanceName, MATRIX matrix, DefineVideoStreamTag video) { + private static String convertVideoInstance(String instanceName, MATRIX matrix, DefineVideoStreamTag video, CLIPACTIONS clipActions) { String ret = " filters = new ArrayList<>(); boolean isVisible = true; RGBA backGroundColor = null; + CLIPACTIONS clipActions = null; int characterId = -1; int ratio = -1; boolean shapeTween = false; @@ -1854,6 +1791,11 @@ public class XFLConverter { if (colorTransFormAlpha2 != null) { colorTransFormAlpha = colorTransFormAlpha2; } + + CLIPACTIONS clipActions2 = po.getClipActions(); + if (clipActions2 != null) { + clipActions = clipActions2; + } if (po.cacheAsBitmap()) { cacheAsBitmap = true; } @@ -1878,6 +1820,7 @@ public class XFLConverter { blendMode = po.getBlendMode(); filters = po.getFilters(); ratio = po.getRatio(); + clipActions = po.getClipActions(); } @@ -1900,6 +1843,7 @@ public class XFLConverter { isVisible = true; backGroundColor = null; characterId = -1; + clipActions = null; } } if (t instanceof FrameLabelTag) { @@ -1927,11 +1871,11 @@ public class XFLConverter { } else { shapeTween = false; if (character instanceof TextTag) { - elements += convertText(instanceName, tags, (TextTag) character, matrix, filters); + elements += convertText(instanceName, tags, (TextTag) character, matrix, filters, clipActions); } else if (character instanceof DefineVideoStreamTag) { - elements += convertVideoInstance(instanceName, matrix, (DefineVideoStreamTag) character); + elements += convertVideoInstance(instanceName, matrix, (DefineVideoStreamTag) character, clipActions); } else { - elements += convertSymbolInstance(instanceName, matrix, colorTransForm, colorTransFormAlpha, cacheAsBitmap, blendMode, filters, isVisible, backGroundColor, character, characters, tags); + elements += convertSymbolInstance(instanceName, matrix, colorTransForm, colorTransFormAlpha, cacheAsBitmap, blendMode, filters, isVisible, backGroundColor, clipActions, character, characters, tags); } } } @@ -2201,7 +2145,7 @@ public class XFLConverter { return ret; } - public static String convertText(String instanceName, List tags, TextTag tag, MATRIX matrix, List filters) { + public static String convertText(String instanceName, List tags, TextTag tag, MATRIX matrix, List filters, CLIPACTIONS clipActions) { String ret = ""; if (matrix == null) { matrix = new MATRIX();