#1260, #1438 AS1/2 direct editing on(xxx), onClipEvent(xxx) handlers

This commit is contained in:
Jindra Petřík
2021-02-24 19:55:59 +01:00
parent d4a5e03462
commit 03f033035f
16 changed files with 295 additions and 39 deletions
@@ -3561,7 +3561,7 @@ public class CommandLineArgumentParser {
private static void replaceAS2(String as, ASMSource src) throws IOException, InterruptedException {
System.out.println("Replace AS1/2");
System.out.println("Warning: This feature is EXPERIMENTAL");
ActionScript2Parser par = new ActionScript2Parser(src.getSwf());
ActionScript2Parser par = new ActionScript2Parser(src.getSwf(), src);
try {
src.setActions(par.actionsFromString(as));
} catch (ActionParseException ex) {
@@ -31,6 +31,8 @@ import com.jpexs.decompiler.flash.tags.Tag;
import com.jpexs.decompiler.flash.tags.base.ASMSource;
import com.jpexs.decompiler.flash.types.ARGB;
import com.jpexs.decompiler.flash.types.BasicType;
import com.jpexs.decompiler.flash.types.CLIPACTIONRECORD;
import com.jpexs.decompiler.flash.types.CLIPACTIONS;
import com.jpexs.decompiler.flash.types.RGB;
import com.jpexs.decompiler.flash.types.RGBA;
import com.jpexs.decompiler.flash.types.annotations.Conditional;
@@ -1168,12 +1170,19 @@ public class GenericTagTreePanel extends GenericTagPanel {
return;
}
ReflectionTools.addToField(obj, field, index, true, cls);
try {
Object v = ReflectionTools.getValue(obj, field, index);
if (v instanceof ASMSource) {
ASMSource asv = (ASMSource) v;
asv.setSourceTag(editedTag);
}
//Hack to set CLIPACTIONRECORD parent
if ((obj instanceof CLIPACTIONS) && (v instanceof CLIPACTIONRECORD)) {
((CLIPACTIONRECORD) v).setParentClipActions((CLIPACTIONS) obj);
}
} catch (IllegalArgumentException | IllegalAccessException ex) {
//ignore
}
@@ -930,21 +930,10 @@ public class ActionPanel extends JPanel implements SearchListener<ActionSearchRe
View.checkAccess();
if (src != null) {
int lastLine = decompiledEditor.getLine();
int prefLines = src.getPrefixLineCount();
if (val) {
String newText = src.removePrefixAndSuffix(lastDecompiled.text);
setDecompiledText(src.getScriptName(), newText);
if (lastLine > -1) {
if (lastLine - prefLines >= 0) {
decompiledEditor.gotoLine(lastLine - prefLines + 1);
}
}
setDecompiledText(src.getScriptName(), lastDecompiled.text);
} else {
setDecompiledText(src.getScriptName(), lastDecompiled.text);
if (lastLine > -1) {
decompiledEditor.gotoLine(lastLine + prefLines + 1);
}
}
}
@@ -1071,7 +1060,7 @@ public class ActionPanel extends JPanel implements SearchListener<ActionSearchRe
private void saveDecompiledButtonActionPerformed(ActionEvent evt) {
try {
ActionScript2Parser par = new ActionScript2Parser(mainPanel.getCurrentSwf());
ActionScript2Parser par = new ActionScript2Parser(mainPanel.getCurrentSwf(), src);
src.setActions(par.actionsFromString(decompiledEditor.getText()));
SWF.uncache(src);
src.setModified();