mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-05-30 09:16:14 +00:00
Added: #2427 Commandline export with use of imported SWFs (importAssets tag)
This commit is contained in:
@@ -27,6 +27,7 @@ import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.SWFCompression;
|
||||
import com.jpexs.decompiler.flash.SearchMode;
|
||||
import com.jpexs.decompiler.flash.SwfOpenException;
|
||||
import com.jpexs.decompiler.flash.UrlResolver;
|
||||
import com.jpexs.decompiler.flash.ValueTooLargeException;
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.ABCInputStream;
|
||||
@@ -228,6 +229,7 @@ import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
@@ -494,7 +496,9 @@ public class CommandLineArgumentParser {
|
||||
}
|
||||
|
||||
AbortRetryIgnoreHandler handler = null;
|
||||
UrlResolver urlResolver = new ConsoleUrlResolver(false, false, false, new HashMap<>());
|
||||
Map<String, String> format = new HashMap<>();
|
||||
Map<String, String> changedImports = new LinkedHashMap<>();
|
||||
double zoom = 1;
|
||||
String charset = Charset.defaultCharset().name();
|
||||
boolean cliMode = false;
|
||||
@@ -598,6 +602,12 @@ public class CommandLineArgumentParser {
|
||||
}
|
||||
Configuration._debugMode.set(true);
|
||||
break;
|
||||
case "-importassets":
|
||||
urlResolver = parseImportAssets(args, changedImports);
|
||||
break;
|
||||
case "-changeimport":
|
||||
parseChangeImport(args, changedImports);
|
||||
break;
|
||||
default:
|
||||
break OUTER;
|
||||
}
|
||||
@@ -658,7 +668,7 @@ public class CommandLineArgumentParser {
|
||||
} else if (command.equals("proxy")) {
|
||||
parseProxy(args);
|
||||
} else if (command.equals("export")) {
|
||||
parseExport(selectionClasses, selection, selectionIds, args, handler, traceLevel, format, zoom, charset, exportEmbed, resampleWav, transparentBackground);
|
||||
parseExport(selectionClasses, selection, selectionIds, args, handler, traceLevel, format, zoom, charset, exportEmbed, resampleWav, transparentBackground, urlResolver);
|
||||
System.exit(0);
|
||||
} else if (command.equals("compress")) {
|
||||
parseCompress(args);
|
||||
@@ -1731,6 +1741,43 @@ public class CommandLineArgumentParser {
|
||||
System.err.println("Process affinity setting is only available on Windows platform.");
|
||||
}
|
||||
}
|
||||
|
||||
private static void parseChangeImport(Stack<String> args, Map<String, String> changedImports) {
|
||||
if (args.size() < 2) {
|
||||
System.err.println("source and target of import expected");
|
||||
badArguments("changeimport");
|
||||
}
|
||||
changedImports.put(args.pop(), args.pop());
|
||||
}
|
||||
|
||||
private static UrlResolver parseImportAssets(Stack<String> args, Map<String, String> changedImports) {
|
||||
if (args.isEmpty()) {
|
||||
System.err.println("importassets options expected");
|
||||
badArguments("importassets");
|
||||
}
|
||||
String impOptionsStr = args.pop();
|
||||
String[] impOptionsArr = impOptionsStr.split(",", -1);
|
||||
boolean doResolve = false;
|
||||
boolean doAsk = false;
|
||||
boolean localOnly = false;
|
||||
for (String impOption:impOptionsArr) {
|
||||
switch (impOption) {
|
||||
case "yes":
|
||||
doResolve = true;
|
||||
break;
|
||||
case "ask":
|
||||
doAsk = true;
|
||||
break;
|
||||
case "local":
|
||||
localOnly = true;
|
||||
break;
|
||||
default:
|
||||
System.err.println("incorrect importassets option: " + impOption);
|
||||
badArguments("importassets");
|
||||
}
|
||||
}
|
||||
return new ConsoleUrlResolver(doResolve, doAsk, localOnly, changedImports);
|
||||
}
|
||||
|
||||
private static void parsePriority(Stack<String> args) {
|
||||
if (Platform.isWindows()) {
|
||||
@@ -1930,7 +1977,7 @@ public class CommandLineArgumentParser {
|
||||
|
||||
}
|
||||
|
||||
private static void parseExport(List<String> selectionClasses, Selection selection, Selection selectionIds, Stack<String> args, AbortRetryIgnoreHandler handler, Level traceLevel, Map<String, String> formats, double zoom, String charset, boolean exportEmbed, boolean resampleWav, boolean transparentBackground) {
|
||||
private static void parseExport(List<String> selectionClasses, Selection selection, Selection selectionIds, Stack<String> args, AbortRetryIgnoreHandler handler, Level traceLevel, Map<String, String> formats, double zoom, String charset, boolean exportEmbed, boolean resampleWav, boolean transparentBackground, UrlResolver urlResolver) {
|
||||
if (args.size() < 3) {
|
||||
badArguments("export");
|
||||
}
|
||||
@@ -2021,11 +2068,11 @@ public class CommandLineArgumentParser {
|
||||
startTimeSwf = System.currentTimeMillis();
|
||||
System.out.println("Start exporting " + inFile.getName());
|
||||
}
|
||||
|
||||
|
||||
OpenableSourceInfo sourceInfo = new OpenableSourceInfo(null, inFile.getAbsolutePath(), inFile.getName());
|
||||
SWF swf;
|
||||
try {
|
||||
swf = new SWF(new BufferedInputStream(new StdInAwareFileInputStream(inFile)), sourceInfo.getFile(), sourceInfo.getFileTitle(), null, Configuration.parallelSpeedUp.get(), false, true, charset);
|
||||
swf = new SWF(new BufferedInputStream(new StdInAwareFileInputStream(inFile)), sourceInfo.getFile(), sourceInfo.getFileTitle(), null, Configuration.parallelSpeedUp.get(), false, true, urlResolver, charset);
|
||||
} catch (FileNotFoundException | SwfOpenException ex) {
|
||||
// FileNotFoundException when anti virus software blocks to open the file
|
||||
logger.log(Level.SEVERE, "Failed to open swf: " + inFile.getName(), ex);
|
||||
|
||||
Reference in New Issue
Block a user