Added Label that flex compiler is used (when it's enabled in settings)

Fixed #2111 Flex AS3 editation - use SWF dependencies defined in GUI
Fixed SWF dependencies label was not updated on startup
This commit is contained in:
Jindra Petřík
2023-12-30 18:06:08 +01:00
parent 123a740d22
commit 4125e94ca3
19 changed files with 141 additions and 49 deletions
+3
View File
@@ -8,6 +8,7 @@ All notable changes to this project will be documented in this file.
- Updated portugese-brasil translation - Updated portugese-brasil translation
- AS3 Debugging - export/import ByteArray variable data - AS3 Debugging - export/import ByteArray variable data
- [#2123] FLA export - show some progress info - [#2123] FLA export - show some progress info
- Label that flex compiler is used (when it's enabled in settings)
### Fixed ### Fixed
- [#2021], [#2000] Caret position in editors when using tabs and / or unicode - [#2021], [#2000] Caret position in editors when using tabs and / or unicode
@@ -23,6 +24,8 @@ All notable changes to this project will be documented in this file.
- [#2123] FLA export - IndexOutOfBounds in shape fixer - [#2123] FLA export - IndexOutOfBounds in shape fixer
- [#2123] FLA export - morphshapes fixer - [#2123] FLA export - morphshapes fixer
- [#2111] AS3 direct editation - access class in class initializer - [#2111] AS3 direct editation - access class in class initializer
- [#2111] Flex AS3 editation - use SWF dependencies defined in GUI
- SWF dependencies label was not updated on startup
### Removed ### Removed
- [#2123] FLA export - Using shape fixer for morphshapes (needs something better) - [#2123] FLA export - Using shape fixer for morphshapes (needs something better)
@@ -1855,8 +1855,8 @@ public class ABC implements Openable {
method_info.remove(index); method_info.remove(index);
} }
public boolean replaceScriptPack(As3ScriptReplacerInterface replacer, ScriptPack pack, String as) throws As3ScriptReplaceException, IOException, InterruptedException { public boolean replaceScriptPack(As3ScriptReplacerInterface replacer, ScriptPack pack, String as, List<SWF> dependencies) throws As3ScriptReplaceException, IOException, InterruptedException {
replacer.replaceScript(pack, as); replacer.replaceScript(pack, as, dependencies);
((Tag) parentTag).setModified(true); ((Tag) parentTag).setModified(true);
return pack.isSimple; return pack.isSimple;
} }
@@ -66,6 +66,8 @@ public final class Configuration {
public static final Level logLevel; public static final Level logLevel;
public static boolean showStat; public static boolean showStat;
public static final String ABC_DEPS_SEPARATOR = "{*sep*}";
@ConfigurationDefaultBoolean(true) @ConfigurationDefaultBoolean(true)
@ConfigurationCategory("ui") @ConfigurationCategory("ui")
@@ -255,8 +255,6 @@ public class SwfToSwcExporter {
printDelay("swc.recompile2", t3, t4); printDelay("swc.recompile2", t3, t4);
} catch (Exception ex) { } catch (Exception ex) {
ex.printStackTrace();
System.exit(0);
throw new RuntimeException(ex); throw new RuntimeException(ex);
} }
@@ -24,6 +24,8 @@ import com.jpexs.decompiler.flash.abc.types.ScriptInfo;
import com.jpexs.decompiler.flash.abc.types.traits.Trait; import com.jpexs.decompiler.flash.abc.types.traits.Trait;
import com.jpexs.decompiler.flash.abc.types.traits.TraitClass; import com.jpexs.decompiler.flash.abc.types.traits.TraitClass;
import com.jpexs.decompiler.flash.configuration.Configuration; import com.jpexs.decompiler.flash.configuration.Configuration;
import com.jpexs.decompiler.flash.configuration.CustomConfigurationKeys;
import com.jpexs.decompiler.flash.configuration.SwfSpecificCustomConfiguration;
import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode;
import com.jpexs.decompiler.flash.exporters.script.AS3ScriptExporter; import com.jpexs.decompiler.flash.exporters.script.AS3ScriptExporter;
import com.jpexs.decompiler.flash.exporters.settings.ScriptExportSettings; import com.jpexs.decompiler.flash.exporters.settings.ScriptExportSettings;
@@ -43,6 +45,7 @@ import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Files; import java.nio.file.Files;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@@ -56,6 +59,7 @@ public class MxmlcAs3ScriptReplacer extends MxmlcRunner implements As3ScriptRepl
private File tempDir; private File tempDir;
private File pkgDir; private File pkgDir;
private File swcFile; private File swcFile;
private List<File> dependenciesSwcFiles = new ArrayList<>();
public MxmlcAs3ScriptReplacer(String flexSdkPath) { public MxmlcAs3ScriptReplacer(String flexSdkPath) {
super(flexSdkPath); super(flexSdkPath);
@@ -115,13 +119,13 @@ public class MxmlcAs3ScriptReplacer extends MxmlcRunner implements As3ScriptRepl
} }
@Override @Override
public synchronized void replaceScript(ScriptPack pack, String text) throws As3ScriptReplaceException, IOException, InterruptedException { public synchronized void replaceScript(ScriptPack pack, String text, List<SWF> dependencies) throws As3ScriptReplaceException, IOException, InterruptedException {
if (!pack.isSimple) { if (!pack.isSimple) {
throw new IOException("Cannot compile such file"); //Alchemy, etc. TODO: handle better throw new IOException("Cannot compile such file"); //Alchemy, etc. TODO: handle better
} }
if (!isInited(pack)) { if (!isInited(pack)) {
initReplacement(pack); initReplacement(pack, dependencies);
} }
File scriptFileToCompile = new File(pkgDir, pack.getClassPath().className + ".as"); File scriptFileToCompile = new File(pkgDir, pack.getClassPath().className + ".as");
@@ -131,7 +135,21 @@ public class MxmlcAs3ScriptReplacer extends MxmlcRunner implements As3ScriptRepl
try { try {
//Compile it (and subclasses stubs) //Compile it (and subclasses stubs)
mxmlc("-strict=false", "-include-inheritance-dependencies-only", "-warnings=false", "-library-path", swcFile.getAbsolutePath(), "-source-path", tempDir.getAbsolutePath(), "-output", compiledSwfFile.getAbsolutePath(), "-debug=true", scriptFileToCompile.getAbsolutePath()); List<String> args = new ArrayList<>(Arrays.asList("-strict=false",
"-include-inheritance-dependencies-only",
"-warnings=false",
"-library-path", swcFile.getAbsolutePath()));
for (File depSwcFile : dependenciesSwcFiles) {
args.add("-library-path");
args.add(depSwcFile.getAbsolutePath());
}
args.addAll(Arrays.asList("-source-path", tempDir.getAbsolutePath(),
"-output", compiledSwfFile.getAbsolutePath(),
"-debug=true",
scriptFileToCompile.getAbsolutePath()));
mxmlc(args);
} catch (MxmlcException ex1) { } catch (MxmlcException ex1) {
//String compiledFilePath = scriptFileToCompile.getAbsolutePath(); //String compiledFilePath = scriptFileToCompile.getAbsolutePath();
Pattern errPattern = Pattern.compile("^" + Pattern.quote(tempDir.getAbsolutePath()) + "(?<file>.*)\\((?<line>[0-9]+)\\): col: (?<col>[0-9]+) (?<message>.*)$"); Pattern errPattern = Pattern.compile("^" + Pattern.quote(tempDir.getAbsolutePath()) + "(?<file>.*)\\((?<line>[0-9]+)\\): col: (?<col>[0-9]+) (?<message>.*)$");
@@ -149,7 +167,13 @@ public class MxmlcAs3ScriptReplacer extends MxmlcRunner implements As3ScriptRepl
errorItems.add(new As3ScriptReplaceExceptionItem(errFile, errMsg, errLine, errCol)); errorItems.add(new As3ScriptReplaceExceptionItem(errFile, errMsg, errLine, errCol));
} }
} }
throw new As3ScriptReplaceException(errorItems); As3ScriptReplaceException ex;
if (errorItems.isEmpty()) {
ex = new As3ScriptReplaceException(err);
} else {
ex = new As3ScriptReplaceException(errorItems);
}
throw ex;
} }
try (FileInputStream fis = new FileInputStream(compiledSwfFile)) { try (FileInputStream fis = new FileInputStream(compiledSwfFile)) {
@@ -248,7 +272,7 @@ public class MxmlcAs3ScriptReplacer extends MxmlcRunner implements As3ScriptRepl
} }
@Override @Override
public synchronized void initReplacement(ScriptPack pack) { public synchronized void initReplacement(ScriptPack pack, List<SWF> dependencies) {
if (tempDir != null) { if (tempDir != null) {
deinitReplacement(pack); deinitReplacement(pack);
} }
@@ -262,11 +286,11 @@ public class MxmlcAs3ScriptReplacer extends MxmlcRunner implements As3ScriptRepl
} }
pkgDir.mkdirs(); pkgDir.mkdirs();
swcFile = new File(pkgDir, "out.swc"); swcFile = new File(tempDir, "out.swc");
//Make copy without the old script //Make copy without the old script
Openable openable = pack.getOpenable(); Openable openable = pack.getOpenable();
SWF swf = (openable instanceof SWF) ? (SWF) openable : ((ABC) openable).getSwf(); SWF swf = (openable instanceof SWF) ? (SWF) openable : ((ABC) openable).getSwf();
SWF swfCopy = recompileSWF(swf); SWF swfCopy = recompileSWF(swf);
List<ABC> modAbcs = new ArrayList<>(); List<ABC> modAbcs = new ArrayList<>();
@@ -309,7 +333,15 @@ public class MxmlcAs3ScriptReplacer extends MxmlcRunner implements As3ScriptRepl
//Flex then uses the code already present in the SWC, no need to decompile it (hurray!) //Flex then uses the code already present in the SWC, no need to decompile it (hurray!)
SwfToSwcExporter swcExport = new SwfToSwcExporter(); SwfToSwcExporter swcExport = new SwfToSwcExporter();
swcExport.exportSwf(swfCopy, swcFile, true); swcExport.exportSwf(swfCopy, swcFile, true);
dependenciesSwcFiles = new ArrayList<>();
int i = 0;
for (SWF depSwf : dependencies) {
i++;
File depSwcFile = new File(tempDir, "dep" + i + ".swc");
swcExport.exportSwf(depSwf, depSwcFile, false);
dependenciesSwcFiles.add(depSwcFile);
}
} catch (IOException iex) { } catch (IOException iex) {
//ignore //ignore
} catch (InterruptedException ex) { } catch (InterruptedException ex) {
@@ -20,6 +20,7 @@ import com.jpexs.helpers.Helper;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.util.List;
public class MxmlcRunner { public class MxmlcRunner {
@@ -51,10 +52,12 @@ public class MxmlcRunner {
return null; return null;
} }
public void mxmlc(String... arguments) throws MxmlcException, InterruptedException, IOException { public void mxmlc(List<String> arguments) throws MxmlcException, InterruptedException, IOException {
String[] runArgs = new String[arguments.length + 1]; String[] runArgs = new String[arguments.size() + 1];
runArgs[0] = getMxmlcPath(flexSdkPath); runArgs[0] = getMxmlcPath(flexSdkPath);
System.arraycopy(arguments, 0, runArgs, 1, arguments.length); for (int i = 0; i < arguments.size(); i++) {
runArgs[i + 1] = arguments.get(i);
}
//System.out.println("" + String.join(" ", runArgs)); //System.out.println("" + String.join(" ", runArgs));
Process proc = null; Process proc = null;
try { try {
@@ -37,11 +37,11 @@ public class AS3ScriptImporter {
private static final Logger logger = Logger.getLogger(AS3ScriptImporter.class.getName()); private static final Logger logger = Logger.getLogger(AS3ScriptImporter.class.getName());
public int importScripts(As3ScriptReplacerInterface scriptReplacer, String scriptsFolder, List<ScriptPack> packs) throws InterruptedException { public int importScripts(As3ScriptReplacerInterface scriptReplacer, String scriptsFolder, List<ScriptPack> packs, List<SWF> dependencies) throws InterruptedException {
return importScripts(scriptReplacer, scriptsFolder, packs, null); return importScripts(scriptReplacer, scriptsFolder, packs, null, dependencies);
} }
public int importScripts(As3ScriptReplacerInterface scriptReplacer, String scriptsFolder, List<ScriptPack> packs, ScriptImporterProgressListener listener) throws InterruptedException { public int importScripts(As3ScriptReplacerInterface scriptReplacer, String scriptsFolder, List<ScriptPack> packs, ScriptImporterProgressListener listener, List<SWF> dependencies) throws InterruptedException {
if (!scriptsFolder.endsWith(File.separator)) { if (!scriptsFolder.endsWith(File.separator)) {
scriptsFolder += File.separator; scriptsFolder += File.separator;
} }
@@ -64,7 +64,7 @@ public class AS3ScriptImporter {
String txt = Helper.readTextFile(fileName); String txt = Helper.readTextFile(fileName);
try { try {
pack.abc.replaceScriptPack(scriptReplacer, pack, txt); pack.abc.replaceScriptPack(scriptReplacer, pack, txt, dependencies);
} catch (As3ScriptReplaceException asre) { } catch (As3ScriptReplaceException asre) {
for (As3ScriptReplaceExceptionItem item : asre.getExceptionItems()) { for (As3ScriptReplaceExceptionItem item : asre.getExceptionItems()) {
logger.log(Level.SEVERE, "%error% on line %line%, column %col%, file: %file%".replace("%error%", item.getMessage()).replace("%line%", Long.toString(item.getLine())).replace("%file%", fileName).replace("%col%", "" + item.getCol())); logger.log(Level.SEVERE, "%error% on line %line%, column %col%, file: %file%".replace("%error%", item.getMessage()).replace("%line%", Long.toString(item.getLine())).replace("%file%", fileName).replace("%col%", "" + item.getCol()));
@@ -27,12 +27,25 @@ public class As3ScriptReplaceException extends Exception {
private List<As3ScriptReplaceExceptionItem> exceptionItems; private List<As3ScriptReplaceExceptionItem> exceptionItems;
public As3ScriptReplaceException(String message) {
super(message);
}
public As3ScriptReplaceException(List<As3ScriptReplaceExceptionItem> exceptionItems) { public As3ScriptReplaceException(List<As3ScriptReplaceExceptionItem> exceptionItems) {
super("Script replace exception");
this.exceptionItems = exceptionItems; this.exceptionItems = exceptionItems;
} }
public As3ScriptReplaceException(As3ScriptReplaceExceptionItem exceptionItem) {
this.exceptionItems = new ArrayList<>();
this.exceptionItems.add(exceptionItem);
}
@Override @Override
public String getMessage() { public String getMessage() {
if (exceptionItems.isEmpty()) {
return super.getMessage();
}
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
for (As3ScriptReplaceExceptionItem item : exceptionItems) { for (As3ScriptReplaceExceptionItem item : exceptionItems) {
sb.append(item.toString()).append("\r\n"); sb.append(item.toString()).append("\r\n");
@@ -43,15 +56,9 @@ public class As3ScriptReplaceException extends Exception {
@Override @Override
public String getLocalizedMessage() { public String getLocalizedMessage() {
return getMessage(); return getMessage();
} }
public As3ScriptReplaceException(As3ScriptReplaceExceptionItem exceptionItem) {
this.exceptionItems = new ArrayList<>();
this.exceptionItems.add(exceptionItem);
}
public List<As3ScriptReplaceExceptionItem> getExceptionItems() { public List<As3ScriptReplaceExceptionItem> getExceptionItems() {
return exceptionItems; return exceptionItems;
} }
} }
@@ -16,16 +16,18 @@
*/ */
package com.jpexs.decompiler.flash.importers; package com.jpexs.decompiler.flash.importers;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.abc.ScriptPack; import com.jpexs.decompiler.flash.abc.ScriptPack;
import java.io.IOException; import java.io.IOException;
import java.util.List;
public interface As3ScriptReplacerInterface { public interface As3ScriptReplacerInterface {
public boolean isAvailable(); public boolean isAvailable();
public void initReplacement(ScriptPack pack); public void initReplacement(ScriptPack pack, List<SWF> dependencies);
public void replaceScript(ScriptPack pack, String text) throws As3ScriptReplaceException, IOException, InterruptedException; public void replaceScript(ScriptPack pack, String text, List<SWF> dependencies) throws As3ScriptReplaceException, IOException, InterruptedException;
public void deinitReplacement(ScriptPack pack); public void deinitReplacement(ScriptPack pack);
} }
@@ -41,7 +41,7 @@ public class FFDecAs3ScriptReplacer implements As3ScriptReplacerInterface {
} }
@Override @Override
public void replaceScript(ScriptPack pack, String text) throws As3ScriptReplaceException, IOException, InterruptedException { public void replaceScript(ScriptPack pack, String text, List<SWF> dependencies) throws As3ScriptReplaceException, IOException, InterruptedException {
ABC abc = pack.abc; ABC abc = pack.abc;
SWF swf = pack.abc.getSwf(); SWF swf = pack.abc.getSwf();
String scriptName = pack.getPathScriptName() + ".as"; String scriptName = pack.getPathScriptName() + ".as";
@@ -103,7 +103,7 @@ public class FFDecAs3ScriptReplacer implements As3ScriptReplacerInterface {
} }
@Override @Override
public void initReplacement(ScriptPack pack) { public void initReplacement(ScriptPack pack, List<SWF> dependencies) {
//empty //empty
} }
@@ -93,7 +93,7 @@ public class DirectEditingTest extends FileTestBase {
try { try {
en.toSource(swf.getAbcIndex(), htw, abc.script_info.get(s).traits.traits, new ConvertData(), ScriptExportMode.AS, false, false); en.toSource(swf.getAbcIndex(), htw, abc.script_info.get(s).traits.traits, new ConvertData(), ScriptExportMode.AS, false, false);
String original = htw.toString(); String original = htw.toString();
abc.replaceScriptPack(As3ScriptReplacerFactory.createFFDec() /*TODO: test the otherone*/, en, original); abc.replaceScriptPack(As3ScriptReplacerFactory.createFFDec() /*TODO: test the otherone*/, en, original, new ArrayList<>());
} catch (As3ScriptReplaceException ex) { } catch (As3ScriptReplaceException ex) {
fail("Exception during decompilation - file: " + filePath + " class: " + classPathString + " msg:" + ex.getMessage(), ex); fail("Exception during decompilation - file: " + filePath + " class: " + classPathString + " msg:" + ex.getMessage(), ex);
} catch (Exception ex) { } catch (Exception ex) {
@@ -56,7 +56,7 @@ public class As3ScriptReplacerTest {
classNames.add("classes.TestClass1"); classNames.add("classes.TestClass1");
List<ScriptPack> packs = swf.getScriptPacksByClassNames(classNames); List<ScriptPack> packs = swf.getScriptPacksByClassNames(classNames);
for (ScriptPack sp : packs) { for (ScriptPack sp : packs) {
replacer.replaceScript(sp, replacement); replacer.replaceScript(sp, replacement, new ArrayList<>());
return; return;
} }
} }
@@ -4240,7 +4240,7 @@ public class CommandLineArgumentParser {
} }
}; };
new AS2ScriptImporter().importScripts(scriptsFolder, swf.getASMs(true), listener); new AS2ScriptImporter().importScripts(scriptsFolder, swf.getASMs(true), listener);
new AS3ScriptImporter().importScripts(As3ScriptReplacerFactory.createByConfig(air), scriptsFolder, swf.getAS3Packs(), listener); new AS3ScriptImporter().importScripts(As3ScriptReplacerFactory.createByConfig(air), scriptsFolder, swf.getAS3Packs(), listener, Main.getDependencies(swf));
try { try {
try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(outFile))) { try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(outFile))) {
@@ -4395,7 +4395,7 @@ public class CommandLineArgumentParser {
} }
try { try {
pack.abc.replaceScriptPack(scriptReplacer, pack, as); pack.abc.replaceScriptPack(scriptReplacer, pack, as, Main.getDependencies(pack.abc.getSwf()));
} catch (As3ScriptReplaceException asre) { } catch (As3ScriptReplaceException asre) {
for (As3ScriptReplaceExceptionItem item : asre.getExceptionItems()) { for (As3ScriptReplaceExceptionItem item : asre.getExceptionItems()) {
String r = "%error% on line %line%, column %col%, file: %file%".replace("%error%", "" + item.getMessage()); String r = "%error% on line %line%, column %col%, file: %file%".replace("%error%", "" + item.getMessage());
+23 -1
View File
@@ -1634,7 +1634,7 @@ public class Main {
if (conf != null) { if (conf != null) {
String abcDependencies = conf.getCustomData(CustomConfigurationKeys.KEY_ABC_DEPENDENCIES, ""); String abcDependencies = conf.getCustomData(CustomConfigurationKeys.KEY_ABC_DEPENDENCIES, "");
if (!abcDependencies.isEmpty()) { if (!abcDependencies.isEmpty()) {
String[] parts = (abcDependencies + LinkDialog.ABC_DEPS_SEPARATOR).split(Pattern.quote(LinkDialog.ABC_DEPS_SEPARATOR)); String[] parts = (abcDependencies + Configuration.ABC_DEPS_SEPARATOR).split(Pattern.quote(Configuration.ABC_DEPS_SEPARATOR));
List<String> preselectedNames = new ArrayList<>(); List<String> preselectedNames = new ArrayList<>();
for (String part : parts) { for (String part : parts) {
if (!part.isEmpty()) { if (!part.isEmpty()) {
@@ -1642,6 +1642,9 @@ public class Main {
} }
} }
swf.setAbcIndexDependencies(namesToSwfs(preselectedNames)); swf.setAbcIndexDependencies(namesToSwfs(preselectedNames));
if (mainFrame != null && mainFrame.getPanel() != null && mainFrame.getPanel().getABCPanel() != null) {
mainFrame.getPanel().getABCPanel().updateLinksLabel();
}
} }
} }
} }
@@ -3245,4 +3248,23 @@ public class Main {
throw new RuntimeException("Problems with creating the log files"); throw new RuntimeException("Problems with creating the log files");
} }
} }
public static List<SWF> getDependencies(SWF swf) {
SwfSpecificCustomConfiguration conf = Configuration.getSwfSpecificCustomConfiguration(swf.getShortPathTitle());
List<SWF> dependencies = new ArrayList<>();
if (conf != null) {
String abcDependencies = conf.getCustomData(CustomConfigurationKeys.KEY_ABC_DEPENDENCIES, "");
if (!abcDependencies.isEmpty()) {
String[] parts = (abcDependencies + Configuration.ABC_DEPS_SEPARATOR).split(Pattern.quote(Configuration.ABC_DEPS_SEPARATOR));
List<String> preselectedNames = new ArrayList<>();
for (String part : parts) {
if (!part.isEmpty()) {
preselectedNames.add(part);
}
}
dependencies = Main.namesToSwfs(preselectedNames);
}
}
return dependencies;
}
} }
@@ -3858,7 +3858,8 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
@Override @Override
public void scriptImportError() { public void scriptImportError() {
} }
} },
Main.getDependencies(swf)
); );
if (countAs3 > 0) { if (countAs3 > 0) {
@@ -112,6 +112,7 @@ import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import java.util.regex.Pattern;
import javax.swing.AbstractAction; import javax.swing.AbstractAction;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.BoxLayout; import javax.swing.BoxLayout;
@@ -188,6 +189,8 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener<Scr
private final DebugPanel debugPanel; private final DebugPanel debugPanel;
private final JLabel experimentalLabel = new JLabel(AppStrings.translate("action.edit.experimental")); private final JLabel experimentalLabel = new JLabel(AppStrings.translate("action.edit.experimental"));
private final JLabel flexLabel = new JLabel(AppStrings.translate("action.edit.flex"));
private final JLabel infoNotEditableLabel; private final JLabel infoNotEditableLabel;
@@ -244,7 +247,7 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener<Scr
libraryComboBox.setSelectedIndex(SWF.LIBRARY_AIR); libraryComboBox.setSelectedIndex(SWF.LIBRARY_AIR);
} else { } else {
libraryComboBox.setSelectedIndex(SWF.LIBRARY_FLASH); libraryComboBox.setSelectedIndex(SWF.LIBRARY_FLASH);
} }
this.abc = abc; this.abc = abc;
setDecompiledEditMode(false); setDecompiledEditMode(false);
navigator.setAbc(abc); navigator.setAbc(abc);
@@ -1037,10 +1040,17 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener<Scr
decButtonsPan.setBorder(new BevelBorder(BevelBorder.RAISED)); decButtonsPan.setBorder(new BevelBorder(BevelBorder.RAISED));
decButtonsPan.add(editDecompiledButton); decButtonsPan.add(editDecompiledButton);
decButtonsPan.add(experimentalLabel); decButtonsPan.add(experimentalLabel);
decButtonsPan.add(flexLabel);
decButtonsPan.add(infoNotEditableLabel); decButtonsPan.add(infoNotEditableLabel);
decButtonsPan.add(saveDecompiledButton); decButtonsPan.add(saveDecompiledButton);
decButtonsPan.add(cancelDecompiledButton); decButtonsPan.add(cancelDecompiledButton);
if (Configuration.useFlexAs3Compiler.get()) {
experimentalLabel.setVisible(false);
} else {
flexLabel.setVisible(false);
}
infoNotEditableLabel.setVisible(false); infoNotEditableLabel.setVisible(false);
editDecompiledButton.setMargin(new Insets(3, 3, 3, 10)); editDecompiledButton.setMargin(new Insets(3, 3, 3, 10));
@@ -1355,7 +1365,7 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener<Scr
updateLinksLabel(); updateLinksLabel();
} }
private void updateLinksLabel() { public void updateLinksLabel() {
SWF swf = getSwf(); SWF swf = getSwf();
if (swf == null) { if (swf == null) {
linksLabel.setText(""); linksLabel.setText("");
@@ -1583,7 +1593,11 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener<Scr
saveDecompiledButton.setVisible(val); saveDecompiledButton.setVisible(val);
saveDecompiledButton.setEnabled(false); saveDecompiledButton.setEnabled(false);
editDecompiledButton.setVisible(!val); editDecompiledButton.setVisible(!val);
experimentalLabel.setVisible(!val);
boolean useFlex = Configuration.useFlexAs3Compiler.get();
experimentalLabel.setVisible(!useFlex && !val);
flexLabel.setVisible(useFlex && !val);
cancelDecompiledButton.setVisible(val); cancelDecompiledButton.setVisible(val);
decompiledTextArea.getCaret().setVisible(true); decompiledTextArea.getCaret().setVisible(true);
@@ -1610,7 +1624,7 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener<Scr
SwingWorker initReplaceWorker = new SwingWorker() { SwingWorker initReplaceWorker = new SwingWorker() {
@Override @Override
protected Object doInBackground() throws Exception { protected Object doInBackground() throws Exception {
scriptReplacer.initReplacement(pack); scriptReplacer.initReplacement(pack, Main.getDependencies(pack.abc.getSwf()));
return null; return null;
} }
}; };
@@ -1636,6 +1650,8 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener<Scr
return (TreeItem) scriptsPath.getLastPathComponent(); return (TreeItem) scriptsPath.getLastPathComponent();
} }
private void saveDecompiled(boolean refreshTree) { private void saveDecompiled(boolean refreshTree) {
final ABC localAbc = abc; final ABC localAbc = abc;
int oldIndex = pack.scriptIndex; int oldIndex = pack.scriptIndex;
@@ -1646,7 +1662,9 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener<Scr
TreeItem scriptNode = getScriptNodeForPack(pack); TreeItem scriptNode = getScriptNodeForPack(pack);
String as = decompiledTextArea.getText(); String as = decompiledTextArea.getText();
localAbc.replaceScriptPack(scriptReplacer, pack, as);
localAbc.replaceScriptPack(scriptReplacer, pack, as, Main.getDependencies(pack.abc.getSwf()));
scriptReplacer.deinitReplacement(pack); scriptReplacer.deinitReplacement(pack);
lastDecompiled = as; lastDecompiled = as;
setDecompiledEditMode(false); setDecompiledEditMode(false);
@@ -2013,7 +2031,9 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener<Scr
public void setCompound(boolean value) { public void setCompound(boolean value) {
infoNotEditableLabel.setVisible(value); infoNotEditableLabel.setVisible(value);
experimentalLabel.setVisible(!value); boolean useFlex = Configuration.useFlexAs3Compiler.get();
experimentalLabel.setVisible(!useFlex && !value);
flexLabel.setVisible(useFlex && !value);
editDecompiledButton.setEnabled(!value); editDecompiledButton.setEnabled(!value);
} }
} }
@@ -52,9 +52,7 @@ import javax.swing.border.BevelBorder;
* *
* @author JPEXS * @author JPEXS
*/ */
public class LinkDialog extends JDialog { public class LinkDialog extends JDialog {
public static final String ABC_DEPS_SEPARATOR = "{*sep*}";
private MainPanel mainPanel; private MainPanel mainPanel;
@@ -122,7 +120,7 @@ public class LinkDialog extends JDialog {
if (conf != null) { if (conf != null) {
String abcDependencies = conf.getCustomData(CustomConfigurationKeys.KEY_ABC_DEPENDENCIES, ""); String abcDependencies = conf.getCustomData(CustomConfigurationKeys.KEY_ABC_DEPENDENCIES, "");
if (!abcDependencies.isEmpty()) { if (!abcDependencies.isEmpty()) {
String[] parts = (abcDependencies + ABC_DEPS_SEPARATOR).split(Pattern.quote(ABC_DEPS_SEPARATOR)); String[] parts = (abcDependencies + Configuration.ABC_DEPS_SEPARATOR).split(Pattern.quote(Configuration.ABC_DEPS_SEPARATOR));
List<String> preselectedNames = new ArrayList<>(); List<String> preselectedNames = new ArrayList<>();
for (String part : parts) { for (String part : parts) {
if (!part.isEmpty()) { if (!part.isEmpty()) {
@@ -145,7 +143,7 @@ public class LinkDialog extends JDialog {
Map<String, SWF> map = getSelectedSwfs(); Map<String, SWF> map = getSelectedSwfs();
SwfSpecificCustomConfiguration conf = Configuration.getOrCreateSwfSpecificCustomConfiguration(swf.getShortPathTitle()); SwfSpecificCustomConfiguration conf = Configuration.getOrCreateSwfSpecificCustomConfiguration(swf.getShortPathTitle());
String oldValue = conf.getCustomData(CustomConfigurationKeys.KEY_ABC_DEPENDENCIES, ""); String oldValue = conf.getCustomData(CustomConfigurationKeys.KEY_ABC_DEPENDENCIES, "");
String newValue = String.join(ABC_DEPS_SEPARATOR, map.keySet()); String newValue = String.join(Configuration.ABC_DEPS_SEPARATOR, map.keySet());
conf.setCustomData(CustomConfigurationKeys.KEY_ABC_DEPENDENCIES, newValue); conf.setCustomData(CustomConfigurationKeys.KEY_ABC_DEPENDENCIES, newValue);
List<SWF> swfs = new ArrayList<>(map.values()); List<SWF> swfs = new ArrayList<>(map.values());
if (!Objects.equals(oldValue, newValue) || force) { if (!Objects.equals(oldValue, newValue) || force) {
@@ -1234,4 +1234,6 @@ clipboard.clear.frame = Clear the frame clipboard
debug.export = Export %name% debug.export = Export %name%
debug.export.bytearray = Export byte array data... debug.export.bytearray = Export byte array data...
debug.import = Import to %name% debug.import = Import to %name%
debug.import.bytearray = Import byte array data... debug.import.bytearray = Import byte array data...
action.edit.flex = (Flex compiler)
@@ -1211,4 +1211,6 @@ clipboard.clear.frame = Vy\u010distit sn\u00edmkovou schr\u00e1nku
debug.export = Exportovat %name% debug.export = Exportovat %name%
debug.export.bytearray = Exportovat byte array data... debug.export.bytearray = Exportovat byte array data...
debug.import = Importovat do %name% debug.import = Importovat do %name%
debug.import.bytearray = Importovat byte array data... debug.import.bytearray = Importovat byte array data...
action.edit.flex = (kompil\u00e1tor Flex)