mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-22 13:16:14 +00:00
single file script export setting added to ScriptExportSettings class
This commit is contained in:
@@ -65,6 +65,7 @@ import com.jpexs.decompiler.flash.exporters.commonshape.Matrix;
|
||||
import com.jpexs.decompiler.flash.exporters.commonshape.SVGExporter;
|
||||
import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode;
|
||||
import com.jpexs.decompiler.flash.exporters.script.AS2ScriptExporter;
|
||||
import com.jpexs.decompiler.flash.exporters.settings.ScriptExportSettings;
|
||||
import com.jpexs.decompiler.flash.helpers.HighlightedText;
|
||||
import com.jpexs.decompiler.flash.helpers.HighlightedTextWriter;
|
||||
import com.jpexs.decompiler.flash.helpers.ImageHelper;
|
||||
@@ -1131,7 +1132,7 @@ public final class SWF implements SWFContainerItem, Timelined {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean exportAS3Class(String className, String outdir, ScriptExportMode exportMode, boolean parallel, EventListener evl) throws Exception {
|
||||
public boolean exportAS3Class(String className, String outdir, ScriptExportSettings exportSettings, boolean parallel, EventListener evl) throws Exception {
|
||||
boolean exported = false;
|
||||
|
||||
List<ABCContainerTag> abcList = getAbcList();
|
||||
@@ -1146,7 +1147,7 @@ public final class SWF implements SWFContainerItem, Timelined {
|
||||
}
|
||||
String eventData = cnt + scr.getPath() + " ...";
|
||||
evl.handleExportingEvent("tag", i + 1, abcList.size(), eventData);
|
||||
scr.export(outdir, exportMode, parallel);
|
||||
scr.export(outdir, exportSettings, parallel);
|
||||
evl.handleExportedEvent("tag", i + 1, abcList.size(), eventData);
|
||||
exported = true;
|
||||
}
|
||||
@@ -1193,7 +1194,7 @@ public final class SWF implements SWFContainerItem, Timelined {
|
||||
|
||||
String directory;
|
||||
|
||||
ScriptExportMode exportMode;
|
||||
ScriptExportSettings exportSettings;
|
||||
|
||||
ClassPath path;
|
||||
|
||||
@@ -1211,10 +1212,10 @@ public final class SWF implements SWFContainerItem, Timelined {
|
||||
|
||||
EventListener eventListener;
|
||||
|
||||
public ExportPackTask(AbortRetryIgnoreHandler handler, AtomicInteger index, int count, ClassPath path, ScriptPack pack, String directory, ScriptExportMode exportMode, boolean parallel, EventListener evl) {
|
||||
public ExportPackTask(AbortRetryIgnoreHandler handler, AtomicInteger index, int count, ClassPath path, ScriptPack pack, String directory, ScriptExportSettings exportSettings, boolean parallel, EventListener evl) {
|
||||
this.pack = pack;
|
||||
this.directory = directory;
|
||||
this.exportMode = exportMode;
|
||||
this.exportSettings = exportSettings;
|
||||
this.path = path;
|
||||
this.index = index;
|
||||
this.count = count;
|
||||
@@ -1229,7 +1230,7 @@ public final class SWF implements SWFContainerItem, Timelined {
|
||||
@Override
|
||||
public void run() throws IOException {
|
||||
startTime = System.currentTimeMillis();
|
||||
this.result = pack.export(directory, exportMode, parallel);
|
||||
this.result = pack.export(directory, exportSettings, parallel);
|
||||
stopTime = System.currentTimeMillis();
|
||||
}
|
||||
};
|
||||
@@ -1250,7 +1251,7 @@ public final class SWF implements SWFContainerItem, Timelined {
|
||||
}
|
||||
}
|
||||
|
||||
private List<File> exportActionScript2(AbortRetryIgnoreHandler handler, String outdir, ScriptExportMode exportMode, boolean parallel, EventListener evl) throws IOException {
|
||||
private List<File> exportActionScript2(AbortRetryIgnoreHandler handler, String outdir, ScriptExportSettings exportSettings, boolean parallel, EventListener evl) throws IOException {
|
||||
List<File> ret = new ArrayList<>();
|
||||
|
||||
if (!outdir.endsWith(File.separator)) {
|
||||
@@ -1258,11 +1259,11 @@ public final class SWF implements SWFContainerItem, Timelined {
|
||||
}
|
||||
outdir += "scripts" + File.separator;
|
||||
|
||||
ret.addAll(new AS2ScriptExporter().exportAS2ScriptsTimeout(handler, outdir, getASMs(true), exportMode, evl));
|
||||
ret.addAll(new AS2ScriptExporter().exportAS2ScriptsTimeout(handler, outdir, getASMs(true), exportSettings, evl));
|
||||
return ret;
|
||||
}
|
||||
|
||||
private List<File> exportActionScript3(final AbortRetryIgnoreHandler handler, final String outdir, final ScriptExportMode exportMode, final boolean parallel, final EventListener evl) {
|
||||
private List<File> exportActionScript3(final AbortRetryIgnoreHandler handler, final String outdir, final ScriptExportSettings exportSettings, final boolean parallel, final EventListener evl) {
|
||||
final AtomicInteger cnt = new AtomicInteger(1);
|
||||
|
||||
final List<File> ret = new ArrayList<>();
|
||||
@@ -1274,7 +1275,7 @@ public final class SWF implements SWFContainerItem, Timelined {
|
||||
@Override
|
||||
public Void call() throws Exception {
|
||||
for (ScriptPack item : packs) {
|
||||
ExportPackTask task = new ExportPackTask(handler, cnt, packs.size(), item.getClassPath(), item, outdir, exportMode, parallel, evl);
|
||||
ExportPackTask task = new ExportPackTask(handler, cnt, packs.size(), item.getClassPath(), item, outdir, exportSettings, parallel, evl);
|
||||
ret.add(task.call());
|
||||
}
|
||||
return null;
|
||||
@@ -1289,7 +1290,7 @@ public final class SWF implements SWFContainerItem, Timelined {
|
||||
ExecutorService executor = Executors.newFixedThreadPool(Configuration.getParallelThreadCount());
|
||||
List<Future<File>> futureResults = new ArrayList<>();
|
||||
for (ScriptPack item : packs) {
|
||||
Future<File> future = executor.submit(new ExportPackTask(handler, cnt, packs.size(), item.getClassPath(), item, outdir, exportMode, parallel, evl));
|
||||
Future<File> future = executor.submit(new ExportPackTask(handler, cnt, packs.size(), item.getClassPath(), item, outdir, exportSettings, parallel, evl));
|
||||
futureResults.add(future);
|
||||
}
|
||||
|
||||
@@ -1343,13 +1344,13 @@ public final class SWF implements SWFContainerItem, Timelined {
|
||||
return evl;
|
||||
}
|
||||
|
||||
public List<File> exportActionScript(AbortRetryIgnoreHandler handler, String outdir, ScriptExportMode exportMode, boolean parallel, EventListener evl) throws IOException {
|
||||
public List<File> exportActionScript(AbortRetryIgnoreHandler handler, String outdir, ScriptExportSettings exportSettings, boolean parallel, EventListener evl) throws IOException {
|
||||
List<File> ret = new ArrayList<>();
|
||||
|
||||
if (isAS3()) {
|
||||
ret.addAll(exportActionScript3(handler, outdir, exportMode, parallel, evl));
|
||||
ret.addAll(exportActionScript3(handler, outdir, exportSettings, parallel, evl));
|
||||
} else {
|
||||
ret.addAll(exportActionScript2(handler, outdir, exportMode, parallel, evl));
|
||||
ret.addAll(exportActionScript2(handler, outdir, exportSettings, parallel, evl));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.jpexs.decompiler.flash.abc.types.Namespace;
|
||||
import com.jpexs.decompiler.flash.abc.types.traits.Trait;
|
||||
import com.jpexs.decompiler.flash.configuration.Configuration;
|
||||
import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode;
|
||||
import com.jpexs.decompiler.flash.exporters.settings.ScriptExportSettings;
|
||||
import com.jpexs.decompiler.flash.helpers.FileTextWriter;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.flash.helpers.NulWriter;
|
||||
@@ -186,7 +187,7 @@ public class ScriptPack extends AS3ClassTreeItem {
|
||||
appendTo(writer, traits, exportMode, parallel);
|
||||
}
|
||||
|
||||
public File export(String directory, ScriptExportMode exportMode, boolean parallel) throws IOException {
|
||||
public File export(String directory, ScriptExportSettings exportSettings, boolean parallel) throws IOException {
|
||||
String scriptName = getPathScriptName();
|
||||
String packageName = getPathPackage();
|
||||
File outDir = new File(directory + File.separatorChar + "scripts" + File.separatorChar + makeDirPath(packageName));
|
||||
@@ -202,14 +203,14 @@ public class ScriptPack extends AS3ClassTreeItem {
|
||||
File file = new File(fileName);
|
||||
try (FileTextWriter writer = new FileTextWriter(Configuration.getCodeFormatting(), new FileOutputStream(file))) {
|
||||
try {
|
||||
toSource(writer, abc.script_info.get(scriptIndex).traits.traits, exportMode, parallel);
|
||||
toSource(writer, abc.script_info.get(scriptIndex).traits.traits, exportSettings.mode, parallel);
|
||||
} catch (InterruptedException ex) {
|
||||
Logger.getLogger(ScriptPack.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
} catch (FileNotFoundException ex) {
|
||||
Logger.getLogger(ScriptPack.class.getName()).log(Level.SEVERE, "The file path is probably too long", ex);
|
||||
}
|
||||
|
||||
|
||||
return file;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.jpexs.decompiler.flash.EventListener;
|
||||
import com.jpexs.decompiler.flash.action.Action;
|
||||
import com.jpexs.decompiler.flash.configuration.Configuration;
|
||||
import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode;
|
||||
import com.jpexs.decompiler.flash.exporters.settings.ScriptExportSettings;
|
||||
import com.jpexs.decompiler.flash.helpers.FileTextWriter;
|
||||
import com.jpexs.decompiler.flash.tags.base.ASMSource;
|
||||
import com.jpexs.decompiler.graph.TranslateException;
|
||||
@@ -49,13 +50,13 @@ public class AS2ScriptExporter {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(AS2ScriptExporter.class.getName());
|
||||
|
||||
public List<File> exportAS2ScriptsTimeout(final AbortRetryIgnoreHandler handler, final String outdir, final Map<String, ASMSource> asms, final ScriptExportMode exportMode, final EventListener evl) throws IOException {
|
||||
public List<File> exportAS2ScriptsTimeout(final AbortRetryIgnoreHandler handler, final String outdir, final Map<String, ASMSource> asms, final ScriptExportSettings exportSettings, final EventListener evl) throws IOException {
|
||||
try {
|
||||
List<File> result = CancellableWorker.call(new Callable<List<File>>() {
|
||||
|
||||
@Override
|
||||
public List<File> call() throws Exception {
|
||||
return exportAS2Scripts(handler, outdir, asms, exportMode, evl);
|
||||
return exportAS2Scripts(handler, outdir, asms, exportSettings, evl);
|
||||
}
|
||||
}, Configuration.exportTimeout.get(), TimeUnit.SECONDS);
|
||||
return result;
|
||||
@@ -67,7 +68,7 @@ public class AS2ScriptExporter {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
private List<File> exportAS2Scripts(AbortRetryIgnoreHandler handler, String outdir, Map<String, ASMSource> asms, ScriptExportMode exportMode, EventListener evl) throws IOException {
|
||||
private List<File> exportAS2Scripts(AbortRetryIgnoreHandler handler, String outdir, Map<String, ASMSource> asms, ScriptExportSettings exportSettings, EventListener evl) throws IOException {
|
||||
List<File> ret = new ArrayList<>();
|
||||
if (!outdir.endsWith(File.separator)) {
|
||||
outdir += File.separator;
|
||||
@@ -95,7 +96,7 @@ public class AS2ScriptExporter {
|
||||
}
|
||||
existingNames.add(name);
|
||||
|
||||
File f = exportAS2Script(handler, currentOutDir, asm, exportMode, evl, cnt, asms.size(), name);
|
||||
File f = exportAS2Script(handler, currentOutDir, asm, exportSettings, evl, cnt, asms.size(), name);
|
||||
if (f != null) {
|
||||
ret.add(f);
|
||||
}
|
||||
@@ -104,7 +105,7 @@ public class AS2ScriptExporter {
|
||||
return ret;
|
||||
}
|
||||
|
||||
private File exportAS2Script(AbortRetryIgnoreHandler handler, String outdir, ASMSource asm, ScriptExportMode exportMode, EventListener evl, AtomicInteger index, int count, String name) throws IOException {
|
||||
private File exportAS2Script(AbortRetryIgnoreHandler handler, String outdir, ASMSource asm, ScriptExportSettings exportSettings, EventListener evl, AtomicInteger index, int count, String name) throws IOException {
|
||||
boolean retry;
|
||||
do {
|
||||
retry = false;
|
||||
@@ -129,6 +130,7 @@ public class AS2ScriptExporter {
|
||||
|
||||
File file = new File(f);
|
||||
try (FileTextWriter writer = new FileTextWriter(Configuration.getCodeFormatting(), new FileOutputStream(f))) {
|
||||
ScriptExportMode exportMode = exportSettings.mode;
|
||||
if (exportMode == ScriptExportMode.HEX) {
|
||||
asm.getActionSourcePrefix(writer);
|
||||
asm.getActionBytesAsHex(writer);
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
|
||||
*
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.
|
||||
* License along with this library.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.exporters.settings;
|
||||
|
||||
import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode;
|
||||
@@ -25,7 +26,10 @@ public class ScriptExportSettings {
|
||||
|
||||
public ScriptExportMode mode;
|
||||
|
||||
|
||||
public boolean singleFile;
|
||||
|
||||
public ScriptExportSettings(ScriptExportMode mode, boolean singleFile) {
|
||||
this.mode = mode;
|
||||
this.singleFile = singleFile;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ import com.jpexs.decompiler.flash.exporters.commonshape.Matrix;
|
||||
import com.jpexs.decompiler.flash.exporters.modes.MovieExportMode;
|
||||
import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode;
|
||||
import com.jpexs.decompiler.flash.exporters.modes.SoundExportMode;
|
||||
import com.jpexs.decompiler.flash.exporters.settings.ScriptExportSettings;
|
||||
import com.jpexs.decompiler.flash.helpers.HighlightedTextWriter;
|
||||
import com.jpexs.decompiler.flash.helpers.ImageHelper;
|
||||
import com.jpexs.decompiler.flash.tags.CSMTextSettingsTag;
|
||||
@@ -3041,7 +3042,8 @@ public class XFLConverter {
|
||||
}
|
||||
if (useAS3) {
|
||||
try {
|
||||
swf.exportActionScript(handler, outDir.getAbsolutePath(), ScriptExportMode.AS, parallel, null);
|
||||
ScriptExportSettings scriptExportSettings = new ScriptExportSettings(ScriptExportMode.AS, false);
|
||||
swf.exportActionScript(handler, outDir.getAbsolutePath(), scriptExportSettings, parallel, null);
|
||||
} catch (Exception ex) {
|
||||
Logger.getLogger(XFLConverter.class.getName()).log(Level.SEVERE, "Error during ActionScript3 export", ex);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user