mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-07-17 20:38:08 +00:00
Add Symbol-Class export support for commandline
This commit is contained in:
@@ -15,8 +15,11 @@
|
||||
* License along with this library.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.exporters;
|
||||
|
||||
import com.jpexs.decompiler.flash.AbortRetryIgnoreHandler;
|
||||
import com.jpexs.decompiler.flash.EventListener;
|
||||
import com.jpexs.decompiler.flash.ReadOnlyTagList;
|
||||
import com.jpexs.decompiler.flash.RetryTask;
|
||||
import com.jpexs.decompiler.flash.exporters.settings.SymbolClassExportSettings;
|
||||
import com.jpexs.decompiler.flash.tags.ExportAssetsTag;
|
||||
import com.jpexs.decompiler.flash.tags.SymbolClassTag;
|
||||
@@ -39,7 +42,7 @@ public class SymbolClassExporter {
|
||||
public class SymbolClassExporter {
|
||||
|
||||
public static final String SYMBOL_CLASS_EXPORT_FILENAME = "symbols.csv";
|
||||
|
||||
|
||||
public List<File> exportNames(AbortRetryIgnoreHandler handler, final String outdir, ReadOnlyTagList tags, SymbolClassExportSettings settings, EventListener evl) throws IOException, InterruptedException {
|
||||
List<File> ret = new ArrayList<>();
|
||||
int count = 0;
|
||||
@@ -56,21 +59,23 @@ public class SymbolClassExporter {
|
||||
File foutdir = new File(outdir);
|
||||
Path.createDirectorySafe(foutdir);
|
||||
|
||||
final File file = new File(outdir + File.separator + SYMBOL_CLASS_EXPORT_FILENAME);
|
||||
try (Writer writer = new BufferedWriter(new Utf8OutputStreamWriter(new FileOutputStream(file)))) {
|
||||
for (Tag t : tags) {
|
||||
if (t instanceof ExportAssetsTag) {
|
||||
ExportAssetsTag eat = (ExportAssetsTag) t;
|
||||
for (int i = 0; i < eat.tags.size(); i++) {
|
||||
writer.append(eat.tags.get(i) + ";" + eat.names.get(i) + Helper.newLine);
|
||||
}
|
||||
} else if (t instanceof SymbolClassTag) {
|
||||
SymbolClassTag sct = (SymbolClassTag) t;
|
||||
for (int i = 0; i < sct.tags.size(); i++) {
|
||||
final File file = new File(outdir + File.separator + SYMBOL_CLASS_EXPORT_FILENAME);
|
||||
new RetryTask(() -> {
|
||||
try (Writer writer = new BufferedWriter(new Utf8OutputStreamWriter(new FileOutputStream(file)))) {
|
||||
for (Tag t : tags) {
|
||||
if (t instanceof ExportAssetsTag) {
|
||||
ExportAssetsTag eat = (ExportAssetsTag) t;
|
||||
for (int i = 0; i < eat.tags.size(); i++) {
|
||||
writer.append(eat.tags.get(i) + ";" + eat.names.get(i) + Helper.newLine);
|
||||
}
|
||||
} else if (t instanceof SymbolClassTag) {
|
||||
SymbolClassTag sct = (SymbolClassTag) t;
|
||||
for (int i = 0; i < sct.tags.size(); i++) {
|
||||
writer.append(sct.tags.get(i) + ";" + sct.names.get(i) + Helper.newLine);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}, handler).run();
|
||||
|
||||
ret.add(file);
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2022 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.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.exporters.settings;
|
||||
|
||||
import com.jpexs.decompiler.flash.exporters.modes.SymbolClassExportMode;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Dofera
|
||||
*/
|
||||
public class SymbolClassExportSettings {
|
||||
|
||||
public static final String EXPORT_FOLDER_NAME = "symbolClass";
|
||||
|
||||
public SymbolClassExportMode mode;
|
||||
|
||||
public SymbolClassExportSettings(SymbolClassExportMode mode) {
|
||||
this.mode = mode;
|
||||
}
|
||||
}
|
||||
@@ -60,6 +60,7 @@ import com.jpexs.decompiler.flash.exporters.MorphShapeExporter;
|
||||
import com.jpexs.decompiler.flash.exporters.MovieExporter;
|
||||
import com.jpexs.decompiler.flash.exporters.ShapeExporter;
|
||||
import com.jpexs.decompiler.flash.exporters.SoundExporter;
|
||||
import com.jpexs.decompiler.flash.exporters.SymbolClassExporter;
|
||||
import com.jpexs.decompiler.flash.exporters.TextExporter;
|
||||
import com.jpexs.decompiler.flash.exporters.amf.amf3.Amf3Exporter;
|
||||
import com.jpexs.decompiler.flash.exporters.commonshape.Matrix;
|
||||
@@ -74,6 +75,7 @@ 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.SpriteExportMode;
|
||||
import com.jpexs.decompiler.flash.exporters.modes.SymbolClassExportMode;
|
||||
import com.jpexs.decompiler.flash.exporters.modes.TextExportMode;
|
||||
import com.jpexs.decompiler.flash.exporters.script.LinkReportExporter;
|
||||
import com.jpexs.decompiler.flash.exporters.settings.BinaryDataExportSettings;
|
||||
@@ -87,6 +89,7 @@ import com.jpexs.decompiler.flash.exporters.settings.ScriptExportSettings;
|
||||
import com.jpexs.decompiler.flash.exporters.settings.ShapeExportSettings;
|
||||
import com.jpexs.decompiler.flash.exporters.settings.SoundExportSettings;
|
||||
import com.jpexs.decompiler.flash.exporters.settings.SpriteExportSettings;
|
||||
import com.jpexs.decompiler.flash.exporters.settings.SymbolClassExportSettings;
|
||||
import com.jpexs.decompiler.flash.exporters.settings.TextExportSettings;
|
||||
import com.jpexs.decompiler.flash.exporters.swf.SwfToSwcExporter;
|
||||
import com.jpexs.decompiler.flash.exporters.swf.SwfXmlExporter;
|
||||
@@ -339,6 +342,7 @@ public class CommandLineArgumentParser {
|
||||
out.println(" button - Buttons (Default format: PNG)");
|
||||
out.println(" sound - Sounds (Default format: MP3/WAV/FLV only sound)");
|
||||
out.println(" binaryData - Binary data (Default format: Raw data)");
|
||||
out.println(" symbolClass - Symbol-Class mapping (Default format: CSV)");
|
||||
out.println(" text - Texts (Default format: Plain text)");
|
||||
out.println(" all - Every resource (but not FLA and XFL)");
|
||||
out.println(" fla - Everything to FLA compressed format");
|
||||
@@ -2109,6 +2113,7 @@ public class CommandLineArgumentParser {
|
||||
"button",
|
||||
"sound",
|
||||
"binarydata",
|
||||
"symbolclass",
|
||||
"text",
|
||||
"all",
|
||||
"fla",
|
||||
@@ -2288,6 +2293,11 @@ public class CommandLineArgumentParser {
|
||||
new BinaryDataExporter().exportBinaryData(handler, outDir + (multipleExportTypes ? File.separator + BinaryDataExportSettings.EXPORT_FOLDER_NAME : ""), new ReadOnlyTagList(extags), new BinaryDataExportSettings(enumFromStr(formats.get("binarydata"), BinaryDataExportMode.class)), evl);
|
||||
}
|
||||
|
||||
if (exportAll || exportFormats.contains("symbolclass")) {
|
||||
System.out.println("Exporting symbolClass...");
|
||||
new SymbolClassExporter().exportNames(handler, outDir + (multipleExportTypes ? File.separator + SymbolClassExportSettings.EXPORT_FOLDER_NAME : ""), new ReadOnlyTagList(extags), new SymbolClassExportSettings(enumFromStr(formats.get("symbolclass"), SymbolClassExportMode.class)), evl);
|
||||
}
|
||||
|
||||
if (exportAll || exportFormats.contains("text")) {
|
||||
System.out.println("Exporting texts...");
|
||||
Boolean singleTextFile = parseBooleanConfigValue(formats.get("singletext"));
|
||||
|
||||
@@ -73,6 +73,7 @@ import com.jpexs.decompiler.flash.exporters.settings.ScriptExportSettings;
|
||||
import com.jpexs.decompiler.flash.exporters.settings.ShapeExportSettings;
|
||||
import com.jpexs.decompiler.flash.exporters.settings.SoundExportSettings;
|
||||
import com.jpexs.decompiler.flash.exporters.settings.SpriteExportSettings;
|
||||
import com.jpexs.decompiler.flash.exporters.settings.SymbolClassExportSettings;
|
||||
import com.jpexs.decompiler.flash.exporters.settings.TextExportSettings;
|
||||
import com.jpexs.decompiler.flash.exporters.swf.SwfJavaExporter;
|
||||
import com.jpexs.decompiler.flash.exporters.swf.SwfXmlExporter;
|
||||
@@ -1383,7 +1384,8 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
}
|
||||
|
||||
if (export.isOptionEnabled(SymbolClassExportMode.class)) {
|
||||
ret.addAll(new SymbolClassExporter().exportNames(selFile2, new ReadOnlyTagList(symbolNames), evl));
|
||||
ret.addAll(new SymbolClassExporter().exportNames(handler, selFile2 + File.separator + SymbolClassExportSettings.EXPORT_FOLDER_NAME, new ReadOnlyTagList(symbolNames),
|
||||
new SymbolClassExportSettings(export.getValue(SymbolClassExportMode.class)), evl));
|
||||
}
|
||||
|
||||
FrameExporter frameExporter = new FrameExporter();
|
||||
@@ -1495,7 +1497,8 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
}
|
||||
|
||||
if (export.isOptionEnabled(SymbolClassExportMode.class)) {
|
||||
new SymbolClassExporter().exportNames(selFile, swf.getTags(), evl);
|
||||
new SymbolClassExporter().exportNames(handler, Path.combine(selFile, SymbolClassExportSettings.EXPORT_FOLDER_NAME), swf.getTags(),
|
||||
new SymbolClassExportSettings(export.getValue(SymbolClassExportMode.class)), evl);
|
||||
}
|
||||
|
||||
FrameExporter frameExporter = new FrameExporter();
|
||||
@@ -1603,7 +1606,8 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
|
||||
if (export.isOptionEnabled(SymbolClassExportMode.class)) {
|
||||
for (SymbolClassExportMode exportMode : SymbolClassExportMode.values()) {
|
||||
new SymbolClassExporter().exportNames(selFile, swf.getTags(), evl);
|
||||
new SymbolClassExporter().exportNames(handler, Path.combine(selFile, SymbolClassExportSettings.EXPORT_FOLDER_NAME, exportMode.name()), swf.getTags(),
|
||||
new SymbolClassExportSettings(exportMode), evl);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user