single file text export

This commit is contained in:
Honfika
2014-04-20 13:16:08 +02:00
parent 931635a7b5
commit e4f275130b
16 changed files with 554 additions and 120 deletions
+91 -56
View File
@@ -57,16 +57,23 @@ import com.jpexs.decompiler.flash.exporters.Matrix;
import com.jpexs.decompiler.flash.exporters.PathExporter;
import com.jpexs.decompiler.flash.exporters.SVGExporter;
import com.jpexs.decompiler.flash.exporters.SVGExporterContext;
import com.jpexs.decompiler.flash.exporters.modes.BinaryDataExportMode;
import com.jpexs.decompiler.flash.exporters.modes.FontExportMode;
import com.jpexs.decompiler.flash.exporters.modes.FramesExportMode;
import com.jpexs.decompiler.flash.exporters.modes.ImageExportMode;
import com.jpexs.decompiler.flash.exporters.modes.MorphshapeExportMode;
import com.jpexs.decompiler.flash.exporters.modes.MovieExportMode;
import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode;
import com.jpexs.decompiler.flash.exporters.modes.ShapeExportMode;
import com.jpexs.decompiler.flash.exporters.modes.SoundExportMode;
import com.jpexs.decompiler.flash.exporters.modes.TextExportMode;
import com.jpexs.decompiler.flash.exporters.settings.BinaryDataExportSettings;
import com.jpexs.decompiler.flash.exporters.settings.FontExportSettings;
import com.jpexs.decompiler.flash.exporters.settings.FramesExportSettings;
import com.jpexs.decompiler.flash.exporters.settings.ImageExportSettings;
import com.jpexs.decompiler.flash.exporters.settings.MorphShapeExportSettings;
import com.jpexs.decompiler.flash.exporters.settings.MovieExportSettings;
import com.jpexs.decompiler.flash.exporters.settings.ShapeExportSettings;
import com.jpexs.decompiler.flash.exporters.settings.SoundExportSettings;
import com.jpexs.decompiler.flash.exporters.settings.TextExportSettings;
import com.jpexs.decompiler.flash.flv.AUDIODATA;
import com.jpexs.decompiler.flash.flv.FLVOutputStream;
import com.jpexs.decompiler.flash.flv.FLVTAG;
@@ -1266,12 +1273,12 @@ public final class SWF implements TreeItem, Timelined {
}
}
public void exportMovies(AbortRetryIgnoreHandler handler, String outdir, MovieExportMode mode) throws IOException {
exportMovies(handler, outdir, tags, mode);
public void exportMovies(AbortRetryIgnoreHandler handler, String outdir, MovieExportSettings settings) throws IOException {
exportMovies(handler, outdir, tags, settings);
}
public void exportSounds(AbortRetryIgnoreHandler handler, String outdir, SoundExportMode mode) throws IOException {
exportSounds(handler, outdir, tags, mode);
public void exportSounds(AbortRetryIgnoreHandler handler, String outdir, SoundExportSettings settings) throws IOException {
exportSounds(handler, outdir, tags, settings);
}
public byte[] exportSound(SoundTag t, SoundExportMode mode) throws IOException {
@@ -1280,11 +1287,11 @@ public final class SWF implements TreeItem, Timelined {
return baos.toByteArray();
}
public void exportFonts(AbortRetryIgnoreHandler handler, String outdir, FontExportMode mode) throws IOException {
exportFonts(handler, outdir, tags, mode);
public void exportFonts(AbortRetryIgnoreHandler handler, String outdir, FontExportSettings settings) throws IOException {
exportFonts(handler, outdir, tags, settings);
}
public List<File> exportFonts(AbortRetryIgnoreHandler handler, String outdir, List<Tag> tags, final FontExportMode mode) throws IOException {
public List<File> exportFonts(AbortRetryIgnoreHandler handler, String outdir, List<Tag> tags, final FontExportSettings settings) throws IOException {
List<File> ret = new ArrayList<>();
if (tags.isEmpty()) {
return ret;
@@ -1306,7 +1313,7 @@ public final class SWF implements TreeItem, Timelined {
new RetryTask(new RunnableIOEx() {
@Override
public void run() throws IOException {
exportFont(st, mode, file);
exportFont(st, settings.mode, file);
}
}, handler).run();
@@ -1513,7 +1520,7 @@ public final class SWF implements TreeItem, Timelined {
}
}
public List<File> exportFrames(AbortRetryIgnoreHandler handler, String outdir, int containerId, List<Integer> frames, final FramesExportMode mode) throws IOException {
public List<File> exportFrames(AbortRetryIgnoreHandler handler, String outdir, int containerId, List<Integer> frames, final FramesExportSettings settings) throws IOException {
final List<File> ret = new ArrayList<>();
if (tags.isEmpty()) {
return ret;
@@ -1546,7 +1553,7 @@ public final class SWF implements TreeItem, Timelined {
final List<Integer> fframes = frames;
Color backgroundColor = null;
if (mode == FramesExportMode.AVI) {
if (settings.mode == FramesExportMode.AVI) {
for (Tag t : tags) {
if (t instanceof SetBackgroundColorTag) {
SetBackgroundColorTag sb = (SetBackgroundColorTag) t;
@@ -1555,7 +1562,7 @@ public final class SWF implements TreeItem, Timelined {
}
}
if (mode == FramesExportMode.SVG) {
if (settings.mode == FramesExportMode.SVG) {
for (int i = 0; i < frames.size(); i++) {
final int fi = i;
final Timeline ftim = tim;
@@ -1579,7 +1586,7 @@ public final class SWF implements TreeItem, Timelined {
for (int frame : frames) {
frameImages.add(frameToImageGet(tim, frame, 0, null, 0, tim.displayRect, new Matrix(), new ColorTransform(), backgroundColor).getBufferedImage());
}
switch (mode) {
switch (settings.mode) {
case GIF:
new RetryTask(new RunnableIOEx() {
@Override
@@ -1618,7 +1625,7 @@ public final class SWF implements TreeItem, Timelined {
return ret;
}
public List<File> exportSounds(AbortRetryIgnoreHandler handler, String outdir, List<Tag> tags, final SoundExportMode mode) throws IOException {
public List<File> exportSounds(AbortRetryIgnoreHandler handler, String outdir, List<Tag> tags, final SoundExportSettings settings) throws IOException {
List<File> ret = new ArrayList<>();
if (tags.isEmpty()) {
return ret;
@@ -1645,17 +1652,17 @@ public final class SWF implements TreeItem, Timelined {
SoundFormat fmt = st.getSoundFormat();
switch (fmt.getNativeExportFormat()) {
case SoundFormat.EXPORT_MP3:
if (mode.hasMP3()) {
if (settings.mode.hasMP3()) {
ext = "mp3";
}
break;
case SoundFormat.EXPORT_FLV:
if (mode.hasFlv()) {
if (settings.mode.hasFlv()) {
ext = "flv";
}
break;
}
if (mode == SoundExportMode.FLV) {
if (settings.mode == SoundExportMode.FLV) {
ext = "flv";
}
@@ -1665,7 +1672,7 @@ public final class SWF implements TreeItem, Timelined {
@Override
public void run() throws IOException {
try (OutputStream os = new BufferedOutputStream(new FileOutputStream(file))) {
exportSound(os, st, mode);
exportSound(os, st, settings.mode);
}
}
}, handler).run();
@@ -1769,7 +1776,7 @@ public final class SWF implements TreeItem, Timelined {
return fos.toByteArray();
}
public List<File> exportMovies(AbortRetryIgnoreHandler handler, String outdir, List<Tag> tags, final MovieExportMode mode) throws IOException {
public List<File> exportMovies(AbortRetryIgnoreHandler handler, String outdir, List<Tag> tags, final MovieExportSettings settings) throws IOException {
List<File> ret = new ArrayList<>();
if (tags.isEmpty()) {
return ret;
@@ -1790,7 +1797,7 @@ public final class SWF implements TreeItem, Timelined {
@Override
public void run() throws IOException {
try (FileOutputStream fos = new FileOutputStream(file)) {
fos.write(exportMovie(videoStream, mode));
fos.write(exportMovie(videoStream, settings.mode));
}
}
}, handler).run();
@@ -1800,7 +1807,7 @@ public final class SWF implements TreeItem, Timelined {
return ret;
}
public List<File> exportTexts(AbortRetryIgnoreHandler handler, String outdir, List<Tag> tags, final TextExportMode mode) throws IOException {
public List<File> exportTexts(AbortRetryIgnoreHandler handler, String outdir, List<Tag> tags, final TextExportSettings settings) throws IOException {
List<File> ret = new ArrayList<>();
if (tags.isEmpty()) {
return ret;
@@ -1813,32 +1820,60 @@ public final class SWF implements TreeItem, Timelined {
}
}
}
for (final Tag t : tags) {
if (t instanceof TextTag) {
final File file = new File(outdir + File.separator + ((TextTag) t).getCharacterId() + ".txt");
new RetryTask(new RunnableIOEx() {
@Override
public void run() throws IOException {
try (FileOutputStream fos = new FileOutputStream(file)) {
if (mode == TextExportMode.FORMATTED) {
fos.write(Utf8Helper.getBytes(((TextTag) t).getFormattedText()));
} else {
fos.write(Utf8Helper.getBytes(((TextTag) t).getText()));
if (settings.singleFile) {
final File file = new File(outdir + File.separator +
(settings.mode == TextExportMode.FORMATTED ? "textsformatted.txt" : "textsplain.txt"));
final String nl = System.getProperty("line.separator");
try (FileOutputStream fos = new FileOutputStream(file)) {
for (final Tag t : tags) {
if (t instanceof TextTag) {
final TextTag textTag = (TextTag) t;
new RetryTask(new RunnableIOEx() {
@Override
public void run() throws IOException {
fos.write(Utf8Helper.getBytes("ID: " + textTag.getCharacterId() + nl));
if (settings.mode == TextExportMode.FORMATTED) {
fos.write(Utf8Helper.getBytes(textTag.getFormattedText()));
} else {
fos.write(Utf8Helper.getBytes(textTag.getText()));
}
fos.write(Utf8Helper.getBytes(nl + Configuration.textExportSingleFileSeparator.get() + nl));
}
}, handler).run();
}
}
}
ret.add(file);
} else {
for (Tag t : tags) {
if (t instanceof TextTag) {
final TextTag textTag = (TextTag) t;
final File file = new File(outdir + File.separator + textTag.getCharacterId() + ".txt");
new RetryTask(new RunnableIOEx() {
@Override
public void run() throws IOException {
try (FileOutputStream fos = new FileOutputStream(file)) {
if (settings.mode == TextExportMode.FORMATTED) {
fos.write(Utf8Helper.getBytes(textTag.getFormattedText()));
} else {
fos.write(Utf8Helper.getBytes(textTag.getText()));
}
}
}
}
}, handler).run();
ret.add(file);
}, handler).run();
ret.add(file);
}
}
}
return ret;
}
public void exportTexts(AbortRetryIgnoreHandler handler, String outdir, TextExportMode mode) throws IOException {
exportTexts(handler, outdir, tags, mode);
public void exportTexts(AbortRetryIgnoreHandler handler, String outdir, TextExportSettings settings) throws IOException {
exportTexts(handler, outdir, tags, settings);
}
public static List<File> exportShapes(AbortRetryIgnoreHandler handler, final String outdir, List<Tag> tags, final ShapeExportMode mode) throws IOException {
public static List<File> exportShapes(AbortRetryIgnoreHandler handler, final String outdir, List<Tag> tags, final ShapeExportSettings settings) throws IOException {
List<File> ret = new ArrayList<>();
if (tags.isEmpty()) {
return ret;
@@ -1859,7 +1894,7 @@ public final class SWF implements TreeItem, Timelined {
characterID = ((CharacterTag) t).getCharacterId();
}
String ext = "svg";
if (mode == ShapeExportMode.PNG) {
if (settings.mode == ShapeExportMode.PNG) {
ext = "png";
}
@@ -1869,7 +1904,7 @@ public final class SWF implements TreeItem, Timelined {
@Override
public void run() throws IOException {
ShapeTag st = (ShapeTag) t;
switch (mode) {
switch (settings.mode) {
case SVG:
try (FileOutputStream fos = new FileOutputStream(file)) {
fos.write(Utf8Helper.getBytes(st.toSVG(new SVGExporterContext(outdir, "assets_" + fcharacterID), -2, new CXFORMWITHALPHA(), 0)));
@@ -1897,7 +1932,7 @@ public final class SWF implements TreeItem, Timelined {
}
//TODO: implement morphshape export. How to handle 65536 frames?
public static List<File> exportMorphShapes(AbortRetryIgnoreHandler handler, final String outdir, List<Tag> tags, final MorphshapeExportMode mode) throws IOException {
public static List<File> exportMorphShapes(AbortRetryIgnoreHandler handler, final String outdir, List<Tag> tags, final MorphShapeExportSettings settings) throws IOException {
List<File> ret = new ArrayList<>();
if (tags.isEmpty()) {
return ret;
@@ -1925,7 +1960,7 @@ public final class SWF implements TreeItem, Timelined {
@Override
public void run() throws IOException {
MorphShapeTag mst = (MorphShapeTag) t;
switch (mode) {
switch (settings.mode) {
case SVG:
try (FileOutputStream fos = new FileOutputStream(file)) {
fos.write(Utf8Helper.getBytes(mst.toSVG(new SVGExporterContext(outdir, "assets_" + fcharacterID), -2, new CXFORMWITHALPHA(), 0)));
@@ -1941,7 +1976,7 @@ public final class SWF implements TreeItem, Timelined {
return ret;
}
public static List<File> exportBinaryData(AbortRetryIgnoreHandler handler, String outdir, List<Tag> tags, BinaryDataExportMode mode) throws IOException {
public static List<File> exportBinaryData(AbortRetryIgnoreHandler handler, String outdir, List<Tag> tags, BinaryDataExportSettings settings) throws IOException {
List<File> ret = new ArrayList<>();
if (tags.isEmpty()) {
return ret;
@@ -1973,7 +2008,7 @@ public final class SWF implements TreeItem, Timelined {
return ret;
}
public List<File> exportImages(AbortRetryIgnoreHandler handler, String outdir, List<Tag> tags, final ImageExportMode mode) throws IOException {
public List<File> exportImages(AbortRetryIgnoreHandler handler, String outdir, List<Tag> tags, final ImageExportSettings settings) throws IOException {
List<File> ret = new ArrayList<>();
if (tags.isEmpty()) {
return ret;
@@ -1990,10 +2025,10 @@ public final class SWF implements TreeItem, Timelined {
if (t instanceof ImageTag) {
String fileFormat = ((ImageTag) t).getImageFormat().toUpperCase(Locale.ENGLISH);
if (mode == ImageExportMode.PNG) {
if (settings.mode == ImageExportMode.PNG) {
fileFormat = "png";
}
if (mode == ImageExportMode.JPEG) {
if (settings.mode == ImageExportMode.JPEG) {
fileFormat = "jpg";
}
@@ -2013,21 +2048,22 @@ public final class SWF implements TreeItem, Timelined {
return ret;
}
public void exportImages(AbortRetryIgnoreHandler handler, String outdir, ImageExportMode mode) throws IOException {
exportImages(handler, outdir, tags, mode);
public void exportImages(AbortRetryIgnoreHandler handler, String outdir, ImageExportSettings settings) throws IOException {
exportImages(handler, outdir, tags, settings);
}
public void exportShapes(AbortRetryIgnoreHandler handler, String outdir, ShapeExportMode mode) throws IOException {
exportShapes(handler, outdir, tags, mode);
public void exportShapes(AbortRetryIgnoreHandler handler, String outdir, ShapeExportSettings settings) throws IOException {
exportShapes(handler, outdir, tags, settings);
}
public void exportMorphShapes(AbortRetryIgnoreHandler handler, String outdir, MorphshapeExportMode mode) throws IOException {
exportMorphShapes(handler, outdir, tags, mode);
public void exportMorphShapes(AbortRetryIgnoreHandler handler, String outdir, MorphShapeExportSettings settings) throws IOException {
exportMorphShapes(handler, outdir, tags, settings);
}
public void exportBinaryData(AbortRetryIgnoreHandler handler, String outdir, BinaryDataExportMode mode) throws IOException {
exportBinaryData(handler, outdir, tags, mode);
public void exportBinaryData(AbortRetryIgnoreHandler handler, String outdir, BinaryDataExportSettings settings) throws IOException {
exportBinaryData(handler, outdir, tags, settings);
}
private final HashMap<String, String> deobfuscated = new HashMap<>();
private List<MyEntry<DirectValueActionItem, ConstantPool>> allVariableNames = new ArrayList<>();
private List<GraphSourceItem> allFunctions = new ArrayList<>();
@@ -2675,7 +2711,6 @@ public final class SWF implements TreeItem, Timelined {
exporter.addImage(mat, boundRect, assetPath);
// TODO: if (layer.clipDepth > -1)...
// TODO: g.setTransform(trans);
}
}
return exporter.getSVG();
@@ -253,6 +253,12 @@ public class Configuration {
@ConfigurationName("export.formats")
public static final ConfigurationItem<String> lastSelectedExportFormats = null;
@ConfigurationDefaultBoolean(false)
public static final ConfigurationItem<Boolean> textExportSingleFile = null;
@ConfigurationDefaultString("--- SEPARATOR ---")
public static final ConfigurationItem<String> textExportSingleFileSeparator = null;
@ConfigurationDefaultBoolean(true)
@ConfigurationName("warning.experimental.as12edit")
public static final ConfigurationItem<Boolean> warningExperimentalAS12Edit = null;
@@ -36,6 +36,14 @@ import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode;
import com.jpexs.decompiler.flash.exporters.modes.ShapeExportMode;
import com.jpexs.decompiler.flash.exporters.modes.SoundExportMode;
import com.jpexs.decompiler.flash.exporters.modes.TextExportMode;
import com.jpexs.decompiler.flash.exporters.settings.BinaryDataExportSettings;
import com.jpexs.decompiler.flash.exporters.settings.FontExportSettings;
import com.jpexs.decompiler.flash.exporters.settings.FramesExportSettings;
import com.jpexs.decompiler.flash.exporters.settings.ImageExportSettings;
import com.jpexs.decompiler.flash.exporters.settings.MovieExportSettings;
import com.jpexs.decompiler.flash.exporters.settings.ShapeExportSettings;
import com.jpexs.decompiler.flash.exporters.settings.SoundExportSettings;
import com.jpexs.decompiler.flash.exporters.settings.TextExportSettings;
import com.jpexs.decompiler.flash.gui.Main;
import com.jpexs.decompiler.flash.xfl.FLAVersion;
import com.jpexs.helpers.Helper;
@@ -613,7 +621,7 @@ public class CommandLineArgumentParser {
case "all_as":
case "all_pcode":
case "all_pcodehex":
case "all_hex":
case "all_hex": {
ScriptExportMode allExportMode = ScriptExportMode.AS;
if (!exportFormat.equals("all")) {
allExportMode = strToExportFormat(exportFormat.substring("all_".length() - 1));
@@ -621,38 +629,48 @@ public class CommandLineArgumentParser {
allExportMode = strToExportFormat(formats.get("script"));
}
System.out.println("Exporting images...");
exfile.exportImages(handler, outDir.getAbsolutePath() + File.separator + "images", ImageExportMode.PNG_JPEG);
exfile.exportImages(handler, outDir.getAbsolutePath() + File.separator + "images", new ImageExportSettings(ImageExportMode.PNG_JPEG));
System.out.println("Exporting shapes...");
exfile.exportShapes(handler, outDir.getAbsolutePath() + File.separator + "shapes", ShapeExportMode.SVG);
exfile.exportShapes(handler, outDir.getAbsolutePath() + File.separator + "shapes", new ShapeExportSettings(ShapeExportMode.SVG));
System.out.println("Exporting scripts...");
exfile.exportActionScript(handler, outDir.getAbsolutePath() + File.separator + "scripts", allExportMode, Configuration.parallelSpeedUp.get());
System.out.println("Exporting movies...");
exfile.exportMovies(handler, outDir.getAbsolutePath() + File.separator + "movies", MovieExportMode.FLV);
exfile.exportMovies(handler, outDir.getAbsolutePath() + File.separator + "movies", new MovieExportSettings(MovieExportMode.FLV));
System.out.println("Exporting sounds...");
exfile.exportSounds(handler, outDir.getAbsolutePath() + File.separator + "sounds", SoundExportMode.MP3_WAV_FLV);
exfile.exportSounds(handler, outDir.getAbsolutePath() + File.separator + "sounds", new SoundExportSettings(SoundExportMode.MP3_WAV_FLV));
System.out.println("Exporting binaryData...");
exfile.exportBinaryData(handler, outDir.getAbsolutePath() + File.separator + "binaryData", BinaryDataExportMode.RAW);
exfile.exportBinaryData(handler, outDir.getAbsolutePath() + File.separator + "binaryData", new BinaryDataExportSettings(BinaryDataExportMode.RAW));
System.out.println("Exporting texts...");
String allTextFormat = formats.get("text");
if (allTextFormat == null) {
allTextFormat = "formatted";
}
exfile.exportTexts(handler, outDir.getAbsolutePath() + File.separator + "texts", allTextFormat.equals("formatted") ? TextExportMode.FORMATTED : TextExportMode.PLAIN);
break;
case "image":
Boolean singleTextFile = parseBooleanConfigValue(formats.get("singletext"));
if (singleTextFile == null) {
singleTextFile = Configuration.textExportSingleFile.get();
}
exfile.exportTexts(handler, outDir.getAbsolutePath() + File.separator + "texts",
new TextExportSettings(allTextFormat.equals("formatted") ? TextExportMode.FORMATTED : TextExportMode.PLAIN, singleTextFile));
}
break;
case "image": {
System.out.println("Exporting images...");
exfile.exportImages(handler, outDir.getAbsolutePath() + (exportFormats.length > 1 ? File.separator + "images" : ""), enumFromStr(formats.get("image"), ImageExportMode.class));
break;
case "shape":
exfile.exportImages(handler, outDir.getAbsolutePath() + (exportFormats.length > 1 ? File.separator + "images" : ""),
new ImageExportSettings(enumFromStr(formats.get("image"), ImageExportMode.class)));
}
break;
case "shape": {
System.out.println("Exporting shapes...");
exfile.exportShapes(handler, outDir.getAbsolutePath() + (exportFormats.length > 1 ? File.separator + "shapes" : ""), enumFromStr(formats.get("shape"), ShapeExportMode.class));
break;
exfile.exportShapes(handler, outDir.getAbsolutePath() + (exportFormats.length > 1 ? File.separator + "shapes" : ""),
new ShapeExportSettings(enumFromStr(formats.get("shape"), ShapeExportMode.class)));
}
break;
case "script":
case "as":
case "pcode":
case "pcodehex":
case "hex":
case "hex": {
System.out.println("Exporting scripts...");
boolean parallel = Configuration.parallelSpeedUp.get();
if (as3classes.isEmpty()) {
@@ -665,51 +683,76 @@ public class CommandLineArgumentParser {
} else {
exportOK = exportOK && exfile.exportActionScript(handler, outDir.getAbsolutePath(), enumFromStr(formats.get("script"), ScriptExportMode.class), parallel) != null;
}
break;
case "movie":
}
break;
case "movie": {
System.out.println("Exporting movies...");
exfile.exportMovies(handler, outDir.getAbsolutePath() + (exportFormats.length > 1 ? File.separator + "movies" : ""), enumFromStr(formats.get("movie"), MovieExportMode.class));
break;
case "font":
exfile.exportMovies(handler, outDir.getAbsolutePath() + (exportFormats.length > 1 ? File.separator + "movies" : ""),
new MovieExportSettings(enumFromStr(formats.get("movie"), MovieExportMode.class)));
}
break;
case "font": {
System.out.println("Exporting fonts...");
exfile.exportFonts(handler, outDir.getAbsolutePath() + (exportFormats.length > 1 ? File.separator + "fonts" : ""), enumFromStr(formats.get("font"), FontExportMode.class));
break;
case "frame":
exfile.exportFonts(handler, outDir.getAbsolutePath() + (exportFormats.length > 1 ? File.separator + "fonts" : ""),
new FontExportSettings(enumFromStr(formats.get("font"), FontExportMode.class)));
}
break;
case "frame": {
System.out.println("Exporting frames...");
exfile.exportFrames(handler, outDir.getAbsolutePath() + (exportFormats.length > 1 ? File.separator + "frames" : ""), 0, null, enumFromStr(formats.get("frame"), FramesExportMode.class));
break;
case "sound":
exfile.exportFrames(handler, outDir.getAbsolutePath() + (exportFormats.length > 1 ? File.separator + "frames" : ""), 0, null,
new FramesExportSettings(enumFromStr(formats.get("frame"), FramesExportMode.class)));
}
break;
case "sound": {
System.out.println("Exporting sounds...");
exfile.exportSounds(handler, outDir.getAbsolutePath() + (exportFormats.length > 1 ? File.separator + "sounds" : ""), enumFromStr(formats.get("sound"), SoundExportMode.class));
break;
case "binarydata":
exfile.exportSounds(handler, outDir.getAbsolutePath() + (exportFormats.length > 1 ? File.separator + "sounds" : ""),
new SoundExportSettings(enumFromStr(formats.get("sound"), SoundExportMode.class)));
}
break;
case "binarydata": {
System.out.println("Exporting binaryData...");
exfile.exportBinaryData(handler, outDir.getAbsolutePath() + (exportFormats.length > 1 ? File.separator + "binaryData" : ""), enumFromStr(formats.get("binarydata"), BinaryDataExportMode.class));
break;
case "text":
exfile.exportBinaryData(handler, outDir.getAbsolutePath() + (exportFormats.length > 1 ? File.separator + "binaryData" : ""),
new BinaryDataExportSettings(enumFromStr(formats.get("binarydata"), BinaryDataExportMode.class)));
}
break;
case "text": {
System.out.println("Exporting texts...");
exfile.exportTexts(handler, outDir.getAbsolutePath() + (exportFormats.length > 1 ? File.separator + "texts" : ""), enumFromStr(formats.get("text"), TextExportMode.class));
break;
case "textplain":
Boolean singleTextFile = parseBooleanConfigValue(formats.get("singletext"));
if (singleTextFile == null) {
singleTextFile = Configuration.textExportSingleFile.get();
}
exfile.exportTexts(handler, outDir.getAbsolutePath() + (exportFormats.length > 1 ? File.separator + "texts" : ""),
new TextExportSettings(enumFromStr(formats.get("text"), TextExportMode.class), singleTextFile));
}
break;
case "textplain": {
System.out.println("Exporting texts...");
exfile.exportTexts(handler, outDir.getAbsolutePath() + (exportFormats.length > 1 ? File.separator + "texts" : ""), TextExportMode.PLAIN);
break;
case "fla":
Boolean singleTextFile = parseBooleanConfigValue(formats.get("singletext"));
if (singleTextFile == null) {
singleTextFile = Configuration.textExportSingleFile.get();
}
exfile.exportTexts(handler, outDir.getAbsolutePath() + (exportFormats.length > 1 ? File.separator + "texts" : ""),
new TextExportSettings(TextExportMode.PLAIN, singleTextFile));
}
break;
case "fla": {
System.out.println("Exporting FLA...");
FLAVersion flaVersion = FLAVersion.fromString(formats.get("fla"));
if (flaVersion == null) {
flaVersion = FLAVersion.CS6; //Defaults to CS6
}
exfile.exportFla(handler, outDir.getAbsolutePath() + (exportFormats.length > 1 ? File.separator + "fla" : ""), inFile.getName(), ApplicationInfo.APPLICATION_NAME, ApplicationInfo.applicationVerName, ApplicationInfo.version, Configuration.parallelSpeedUp.get(), flaVersion);
break;
case "xfl":
}
break;
case "xfl": {
System.out.println("Exporting XFL...");
FLAVersion xflVersion = FLAVersion.fromString(formats.get("xfl"));
if (xflVersion == null) {
xflVersion = FLAVersion.CS6; //Defaults to CS6
}
exfile.exportXfl(handler, outDir.getAbsolutePath() + (exportFormats.length > 1 ? File.separator + "xfl" : ""), inFile.getName(), ApplicationInfo.APPLICATION_NAME, ApplicationInfo.applicationVerName, ApplicationInfo.version, Configuration.parallelSpeedUp.get(), xflVersion);
break;
}
break;
default:
exportOK = false;
}
@@ -20,7 +20,7 @@ package com.jpexs.decompiler.flash.exporters.modes;
*
* @author JPEXS
*/
public enum MorphshapeExportMode {
public enum MorphShapeExportMode {
//TODO: implement other morphshape export modes
SVG
@@ -0,0 +1,32 @@
/*
* Copyright (C) 2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.exporters.settings;
import com.jpexs.decompiler.flash.exporters.modes.BinaryDataExportMode;
/**
*
* @author JPEXS
*/
public class BinaryDataExportSettings {
public BinaryDataExportMode mode;
public BinaryDataExportSettings(BinaryDataExportMode mode) {
this.mode = mode;
}
}
@@ -0,0 +1,32 @@
/*
* Copyright (C) 2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.exporters.settings;
import com.jpexs.decompiler.flash.exporters.modes.FontExportMode;
/**
*
* @author JPEXS
*/
public class FontExportSettings {
public FontExportMode mode;
public FontExportSettings(FontExportMode mode) {
this.mode = mode;
}
}
@@ -0,0 +1,32 @@
/*
* Copyright (C) 2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.exporters.settings;
import com.jpexs.decompiler.flash.exporters.modes.FramesExportMode;
/**
*
* @author JPEXS
*/
public class FramesExportSettings {
public FramesExportMode mode;
public FramesExportSettings(FramesExportMode mode) {
this.mode = mode;
}
}
@@ -0,0 +1,32 @@
/*
* Copyright (C) 2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.exporters.settings;
import com.jpexs.decompiler.flash.exporters.modes.ImageExportMode;
/**
*
* @author JPEXS
*/
public class ImageExportSettings {
public ImageExportMode mode;
public ImageExportSettings(ImageExportMode mode) {
this.mode = mode;
}
}
@@ -0,0 +1,32 @@
/*
* Copyright (C) 2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.exporters.settings;
import com.jpexs.decompiler.flash.exporters.modes.MorphShapeExportMode;
/**
*
* @author JPEXS
*/
public class MorphShapeExportSettings {
public MorphShapeExportMode mode;
public MorphShapeExportSettings(MorphShapeExportMode mode) {
this.mode = mode;
}
}
@@ -0,0 +1,32 @@
/*
* Copyright (C) 2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.exporters.settings;
import com.jpexs.decompiler.flash.exporters.modes.MovieExportMode;
/**
*
* @author JPEXS
*/
public class MovieExportSettings {
public MovieExportMode mode;
public MovieExportSettings(MovieExportMode mode) {
this.mode = mode;
}
}
@@ -0,0 +1,32 @@
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.exporters.settings;
import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode;
/**
*
* @author JPEXS
*/
public class ScriptExportSettings {
public ScriptExportMode mode;
public ScriptExportSettings(ScriptExportMode mode) {
this.mode = mode;
}
}
@@ -0,0 +1,32 @@
/*
* Copyright (C) 2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.exporters.settings;
import com.jpexs.decompiler.flash.exporters.modes.ShapeExportMode;
/**
*
* @author JPEXS
*/
public class ShapeExportSettings {
public ShapeExportMode mode;
public ShapeExportSettings(ShapeExportMode mode) {
this.mode = mode;
}
}
@@ -0,0 +1,32 @@
/*
* Copyright (C) 2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.exporters.settings;
import com.jpexs.decompiler.flash.exporters.modes.SoundExportMode;
/**
*
* @author JPEXS
*/
public class SoundExportSettings {
public SoundExportMode mode;
public SoundExportSettings(SoundExportMode mode) {
this.mode = mode;
}
}
@@ -0,0 +1,34 @@
/*
* Copyright (C) 2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.exporters.settings;
import com.jpexs.decompiler.flash.exporters.modes.TextExportMode;
/**
*
* @author JPEXS
*/
public class TextExportSettings {
public TextExportMode mode;
public boolean singleFile;
public TextExportSettings(TextExportMode mode, boolean singleFile) {
this.mode = mode;
this.singleFile = singleFile;
}
}
@@ -22,7 +22,7 @@ import com.jpexs.decompiler.flash.exporters.modes.BinaryDataExportMode;
import com.jpexs.decompiler.flash.exporters.modes.FontExportMode;
import com.jpexs.decompiler.flash.exporters.modes.FramesExportMode;
import com.jpexs.decompiler.flash.exporters.modes.ImageExportMode;
import com.jpexs.decompiler.flash.exporters.modes.MorphshapeExportMode;
import com.jpexs.decompiler.flash.exporters.modes.MorphShapeExportMode;
import com.jpexs.decompiler.flash.exporters.modes.MovieExportMode;
import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode;
import com.jpexs.decompiler.flash.exporters.modes.ShapeExportMode;
@@ -99,7 +99,7 @@ public class ExportDialog extends AppDialog {
BinaryDataExportMode.class,
FramesExportMode.class,
FontExportMode.class,
MorphshapeExportMode.class
MorphShapeExportMode.class
};
private final JComboBox[] combos;
@@ -30,12 +30,21 @@ import com.jpexs.decompiler.flash.exporters.modes.BinaryDataExportMode;
import com.jpexs.decompiler.flash.exporters.modes.FontExportMode;
import com.jpexs.decompiler.flash.exporters.modes.FramesExportMode;
import com.jpexs.decompiler.flash.exporters.modes.ImageExportMode;
import com.jpexs.decompiler.flash.exporters.modes.MorphshapeExportMode;
import com.jpexs.decompiler.flash.exporters.modes.MorphShapeExportMode;
import com.jpexs.decompiler.flash.exporters.modes.MovieExportMode;
import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode;
import com.jpexs.decompiler.flash.exporters.modes.ShapeExportMode;
import com.jpexs.decompiler.flash.exporters.modes.SoundExportMode;
import com.jpexs.decompiler.flash.exporters.modes.TextExportMode;
import com.jpexs.decompiler.flash.exporters.settings.BinaryDataExportSettings;
import com.jpexs.decompiler.flash.exporters.settings.FontExportSettings;
import com.jpexs.decompiler.flash.exporters.settings.FramesExportSettings;
import com.jpexs.decompiler.flash.exporters.settings.ImageExportSettings;
import com.jpexs.decompiler.flash.exporters.settings.MorphShapeExportSettings;
import com.jpexs.decompiler.flash.exporters.settings.MovieExportSettings;
import com.jpexs.decompiler.flash.exporters.settings.ShapeExportSettings;
import com.jpexs.decompiler.flash.exporters.settings.SoundExportSettings;
import com.jpexs.decompiler.flash.exporters.settings.TextExportSettings;
import com.jpexs.decompiler.flash.gui.abc.ABCPanel;
import com.jpexs.decompiler.flash.gui.abc.ClassesListTreeModel;
import com.jpexs.decompiler.flash.gui.abc.DeobfuscationDialog;
@@ -1262,17 +1271,26 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
}
final ScriptExportMode scriptMode = export.getValue(ScriptExportMode.class);
ret.addAll(swf.exportImages(handler, selFile + File.separator + "images", images, export.getValue(ImageExportMode.class)));
ret.addAll(SWF.exportShapes(handler, selFile + File.separator + "shapes", shapes, export.getValue(ShapeExportMode.class)));
ret.addAll(SWF.exportMorphShapes(handler, selFile + File.separator + "morphshapes", morphshapes, export.getValue(MorphshapeExportMode.class)));
ret.addAll(swf.exportTexts(handler, selFile + File.separator + "texts", texts, export.getValue(TextExportMode.class)));
ret.addAll(swf.exportMovies(handler, selFile + File.separator + "movies", movies, export.getValue(MovieExportMode.class)));
ret.addAll(swf.exportSounds(handler, selFile + File.separator + "sounds", sounds, export.getValue(SoundExportMode.class)));
ret.addAll(SWF.exportBinaryData(handler, selFile + File.separator + "binaryData", binaryData, export.getValue(BinaryDataExportMode.class)));
ret.addAll(swf.exportFonts(handler, selFile + File.separator + "fonts", fonts, export.getValue(FontExportMode.class)));
ret.addAll(swf.exportImages(handler, selFile + File.separator + "images", images,
new ImageExportSettings(export.getValue(ImageExportMode.class))));
ret.addAll(SWF.exportShapes(handler, selFile + File.separator + "shapes", shapes,
new ShapeExportSettings(export.getValue(ShapeExportMode.class))));
ret.addAll(SWF.exportMorphShapes(handler, selFile + File.separator + "morphshapes", morphshapes,
new MorphShapeExportSettings(export.getValue(MorphShapeExportMode.class))));
ret.addAll(swf.exportTexts(handler, selFile + File.separator + "texts", texts,
new TextExportSettings(export.getValue(TextExportMode.class), Configuration.textExportSingleFile.get())));
ret.addAll(swf.exportMovies(handler, selFile + File.separator + "movies", movies,
new MovieExportSettings(export.getValue(MovieExportMode.class))));
ret.addAll(swf.exportSounds(handler, selFile + File.separator + "sounds", sounds,
new SoundExportSettings(export.getValue(SoundExportMode.class))));
ret.addAll(SWF.exportBinaryData(handler, selFile + File.separator + "binaryData", binaryData,
new BinaryDataExportSettings(export.getValue(BinaryDataExportMode.class))));
ret.addAll(swf.exportFonts(handler, selFile + File.separator + "fonts", fonts,
new FontExportSettings(export.getValue(FontExportMode.class))));
for (Entry<Integer, List<Integer>> entry : frames.entrySet()) {
ret.addAll(swf.exportFrames(handler, selFile + File.separator + "frames", entry.getKey(), entry.getValue(), export.getValue(FramesExportMode.class)));
ret.addAll(swf.exportFrames(handler, selFile + File.separator + "frames", entry.getKey(), entry.getValue(),
new FramesExportSettings(export.getValue(FramesExportMode.class))));
}
List<ABCContainerTag> abcList = swf.abcList;
if (abcPanel != null) {
@@ -1671,18 +1689,28 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
if (onlySel) {
exportSelection(errorHandler, selFile, export);
} else {
swf.exportImages(errorHandler, selFile + File.separator + "images", export.getValue(ImageExportMode.class));
swf.exportShapes(errorHandler, selFile + File.separator + "shapes", export.getValue(ShapeExportMode.class));
swf.exportMorphShapes(errorHandler, selFile + File.separator + "morphshapes", export.getValue(MorphshapeExportMode.class));
swf.exportTexts(errorHandler, selFile + File.separator + "texts", export.getValue(TextExportMode.class));
swf.exportMovies(errorHandler, selFile + File.separator + "movies", export.getValue(MovieExportMode.class));
swf.exportSounds(errorHandler, selFile + File.separator + "sounds", export.getValue(SoundExportMode.class));
swf.exportBinaryData(errorHandler, selFile + File.separator + "binaryData", export.getValue(BinaryDataExportMode.class));
swf.exportFonts(errorHandler, selFile + File.separator + "fonts", export.getValue(FontExportMode.class));
swf.exportFrames(errorHandler, selFile + File.separator + "frames", 0, null, export.getValue(FramesExportMode.class));
swf.exportImages(errorHandler, selFile + File.separator + "images",
new ImageExportSettings(export.getValue(ImageExportMode.class)));
swf.exportShapes(errorHandler, selFile + File.separator + "shapes",
new ShapeExportSettings(export.getValue(ShapeExportMode.class)));
swf.exportMorphShapes(errorHandler, selFile + File.separator + "morphshapes",
new MorphShapeExportSettings(export.getValue(MorphShapeExportMode.class)));
swf.exportTexts(errorHandler, selFile + File.separator + "texts",
new TextExportSettings(export.getValue(TextExportMode.class), Configuration.textExportSingleFile.get()));
swf.exportMovies(errorHandler, selFile + File.separator + "movies",
new MovieExportSettings(export.getValue(MovieExportMode.class)));
swf.exportSounds(errorHandler, selFile + File.separator + "sounds",
new SoundExportSettings(export.getValue(SoundExportMode.class)));
swf.exportBinaryData(errorHandler, selFile + File.separator + "binaryData",
new BinaryDataExportSettings(export.getValue(BinaryDataExportMode.class)));
swf.exportFonts(errorHandler, selFile + File.separator + "fonts",
new FontExportSettings(export.getValue(FontExportMode.class)));
swf.exportFrames(errorHandler, selFile + File.separator + "frames", 0, null,
new FramesExportSettings(export.getValue(FramesExportMode.class)));
for (CharacterTag c : swf.characters.values()) {
if (c instanceof DefineSpriteTag) {
swf.exportFrames(errorHandler, selFile + File.separator + "frames", c.getCharacterId(), null, export.getValue(FramesExportMode.class));
swf.exportFrames(errorHandler, selFile + File.separator + "frames", c.getCharacterId(), null,
new FramesExportSettings(export.getValue(FramesExportMode.class)));
}
}
swf.exportActionScript(errorHandler, selFile, exportMode, Configuration.parallelSpeedUp.get());