mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-17 10:41:54 +00:00
#845 If frame consist 2 DoAction then it imports only first one: fixed
This commit is contained in:
@@ -122,7 +122,7 @@ public class AS2ScriptExporter {
|
||||
Path.createDirectorySafe(new File(outdir));
|
||||
}
|
||||
|
||||
String f = outdir + name + exportSettings.getFileExtension();
|
||||
String f = Path.combine(outdir, name) + exportSettings.getFileExtension();
|
||||
if (evl != null) {
|
||||
evl.handleExportingEvent("script", currentIndex, count, f);
|
||||
}
|
||||
|
||||
@@ -23,6 +23,9 @@ import com.jpexs.helpers.Helper;
|
||||
import com.jpexs.helpers.Path;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
@@ -36,16 +39,39 @@ public class ScriptImporter {
|
||||
private static final Logger logger = Logger.getLogger(ScriptImporter.class.getName());
|
||||
|
||||
public void importScripts(String scriptsFolder, Map<String, ASMSource> asms) {
|
||||
if (!scriptsFolder.endsWith(File.separator)) {
|
||||
scriptsFolder += File.separator;
|
||||
}
|
||||
|
||||
Map<String, List<String>> existingNamesMap = new HashMap<>();
|
||||
|
||||
for (String key : asms.keySet()) {
|
||||
String fileName = Path.combine(scriptsFolder, key) + ".as";
|
||||
ASMSource asm = asms.get(key);
|
||||
String currentOutDir = scriptsFolder + key + File.separator;
|
||||
currentOutDir = new File(currentOutDir).getParentFile().toString() + File.separator;
|
||||
|
||||
List<String> existingNames = existingNamesMap.get(currentOutDir);
|
||||
if (existingNames == null) {
|
||||
existingNames = new ArrayList<>();
|
||||
existingNamesMap.put(currentOutDir, existingNames);
|
||||
}
|
||||
|
||||
String name = Helper.makeFileName(asm.getExportFileName());
|
||||
int i = 1;
|
||||
String baseName = name;
|
||||
while (existingNames.contains(name)) {
|
||||
i++;
|
||||
name = baseName + "_" + i;
|
||||
}
|
||||
existingNames.add(name);
|
||||
|
||||
String fileName = Path.combine(currentOutDir, name) + ".as";
|
||||
if (new File(fileName).exists()) {
|
||||
ASMSource src = asms.get(key);
|
||||
String as = Helper.readTextFile(fileName);
|
||||
|
||||
com.jpexs.decompiler.flash.action.parser.script.ActionScriptParser par = new com.jpexs.decompiler.flash.action.parser.script.ActionScriptParser(src.getSwf().version);
|
||||
com.jpexs.decompiler.flash.action.parser.script.ActionScriptParser par = new com.jpexs.decompiler.flash.action.parser.script.ActionScriptParser(asm.getSwf().version);
|
||||
try {
|
||||
src.setActions(par.actionsFromString(as));
|
||||
asm.setActions(par.actionsFromString(as));
|
||||
} catch (ActionParseException ex) {
|
||||
logger.log(Level.SEVERE, "%error% on line %line%, file: %file%".replace("%error%", ex.text).replace("%line%", Long.toString(ex.line)).replace("%file%", fileName), ex);
|
||||
} catch (CompilationException ex) {
|
||||
@@ -54,7 +80,7 @@ public class ScriptImporter {
|
||||
logger.log(Level.SEVERE, "error during script import, file: %file%".replace("%file%", fileName), ex);
|
||||
}
|
||||
|
||||
src.setModified();
|
||||
asm.setModified();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user