Added AS3 - Show Embed tag over asset classes (readonly)

Added AS3 - Checkbox for exporting assets embedded using `Embed` (-exportembed in commandline)
Added FLA export - AS3 - Using `Embed` tag for DefineBinaryData, images not extending BitmapData
This commit is contained in:
Jindra Petřík
2023-09-24 19:38:42 +02:00
parent ef9e80cb21
commit 4eabf89291
22 changed files with 479 additions and 48 deletions

View File

@@ -450,6 +450,12 @@ public class CommandLineArgumentParser {
out.println(" DO NOT PUT space between comma (,) and next class.");
}
if (filter == null || filter.equals("exportembed")) {
out.println(" " + (cnt++) + ") -exportembed");
out.println(" ...Allows exporting embedded assets via [Embed tag]");
out.println(" Use in combination with -export -format script:as");
}
if (filter == null || filter.equals("dumpswf")) {
out.println(" " + (cnt++) + ") -dumpSWF <infile>");
out.println(" ...dumps list of SWF tags to console");
@@ -864,6 +870,7 @@ public class CommandLineArgumentParser {
String charset = Charset.defaultCharset().name();
boolean cliMode = false;
boolean air = false;
boolean exportEmbed = false;
Selection selection = new Selection();
Selection selectionIds = new Selection();
List<String> selectionClasses = null;
@@ -893,6 +900,9 @@ public class CommandLineArgumentParser {
case "-selectclass":
selectionClasses = parseSelectClass(args);
break;
case "-exportembed":
exportEmbed = true;
break;
case "-zoom":
zoom = parseZoom(args);
break;
@@ -1004,7 +1014,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);
parseExport(selectionClasses, selection, selectionIds, args, handler, traceLevel, format, zoom, charset, exportEmbed);
System.exit(0);
} else if (command.equals("compress")) {
parseCompress(args);
@@ -2250,7 +2260,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) {
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) {
if (args.size() < 3) {
badArguments("export");
}
@@ -2514,7 +2524,7 @@ public class CommandLineArgumentParser {
singleScriptFile = false;
}
ScriptExportSettings scriptExportSettings = new ScriptExportSettings(enumFromStr(formats.get("script"), ScriptExportMode.class), singleScriptFile, false);
ScriptExportSettings scriptExportSettings = new ScriptExportSettings(enumFromStr(formats.get("script"), ScriptExportMode.class), singleScriptFile, false, exportEmbed, false);
boolean exportAllScript = exportAll || exportFormats.contains("script");
boolean exportAs2Script = exportAllScript || exportFormats.contains("script_as2");
boolean exportAs3Script = exportAllScript || exportFormats.contains("script_as3");

View File

@@ -16,6 +16,7 @@
*/
package com.jpexs.decompiler.flash.gui;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.abc.ScriptPack;
import com.jpexs.decompiler.flash.configuration.Configuration;
import com.jpexs.decompiler.flash.exporters.modes.BinaryDataExportMode;
@@ -46,8 +47,10 @@ import com.jpexs.decompiler.flash.tags.base.ShapeTag;
import com.jpexs.decompiler.flash.tags.base.SoundTag;
import com.jpexs.decompiler.flash.tags.base.SymbolClassTypeTag;
import com.jpexs.decompiler.flash.tags.base.TextTag;
import com.jpexs.decompiler.flash.timeline.AS3Package;
import com.jpexs.decompiler.flash.timeline.Frame;
import com.jpexs.decompiler.flash.timeline.TagScript;
import com.jpexs.decompiler.flash.treeitems.AS3ClassTreeItem;
import com.jpexs.decompiler.flash.treeitems.TreeItem;
import java.awt.BorderLayout;
import java.awt.Container;
@@ -144,6 +147,8 @@ public class ExportDialog extends AppDialog {
private JTextField zoomTextField = new JTextField();
private JCheckBox embedCheckBox;
public <E> E getValue(Class<E> option) {
for (int i = 0; i < optionClasses.length; i++) {
if (option == optionClasses[i]) {
@@ -165,6 +170,10 @@ public class ExportDialog extends AppDialog {
return false;
}
public boolean isEmbedEnabled() {
return embedCheckBox.isSelected();
}
public double getZoom() {
return Double.parseDouble(zoomTextField.getText()) / 100;
}
@@ -318,6 +327,36 @@ public class ExportDialog extends AppDialog {
top += combos[i].getHeight();
}
embedCheckBox = new JCheckBox(translate("embed"));
boolean hasAs3 = false;
if (exportables == null) {
hasAs3 = true; //??
} else {
for (TreeItem ti : exportables) {
if (ti instanceof AS3ClassTreeItem) {
hasAs3 = true;
break;
}
}
}
int w = 10 + labWidth + 10 + checkBoxWidth + 10 + comboWidth + 10;
if (hasAs3 && Arrays.asList(optionClasses).contains(ScriptExportMode.class)) {
top += 2;
embedCheckBox.setBounds(10, top, embedCheckBox.getPreferredSize().width, embedCheckBox.getPreferredSize().height);
comboPanel.add(embedCheckBox);
top += embedCheckBox.getHeight();
if (embedCheckBox.getWidth() + 10 > w) {
w = embedCheckBox.getWidth() + 10;
}
if (Configuration.lastExportEnableEmbed.get()) {
embedCheckBox.setSelected(true);
}
}
int zoomWidth = 50;
if (zoomable) {
top += 2;
@@ -333,7 +372,7 @@ public class ExportDialog extends AppDialog {
top += zoomTextField.getHeight();
}
Dimension dim = new Dimension(10 + labWidth + 10 + checkBoxWidth + 10 + comboWidth + 10, top + 10);
Dimension dim = new Dimension(w, top + 10);
comboPanel.setMinimumSize(dim);
comboPanel.setPreferredSize(dim);
cnt.add(comboPanel, BorderLayout.CENTER);

View File

@@ -2065,7 +2065,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
singleScriptFile = false;
}
ScriptExportSettings scriptExportSettings = new ScriptExportSettings(export.getValue(ScriptExportMode.class), singleScriptFile, false);
ScriptExportSettings scriptExportSettings = new ScriptExportSettings(export.getValue(ScriptExportMode.class), singleScriptFile, false, export.isEmbedEnabled(), false);
String singleFileName = Path.combine(scriptsFolder, openable.getShortFileName() + scriptExportSettings.getFileExtension());
try (FileTextWriter writer = scriptExportSettings.singleFile ? new FileTextWriter(Configuration.getCodeFormatting(), new FileOutputStream(singleFileName)) : null) {
scriptExportSettings.singleFileWriter = writer;
@@ -2172,7 +2172,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
singleScriptFile = false;
}
ScriptExportSettings scriptExportSettings = new ScriptExportSettings(export.getValue(ScriptExportMode.class), singleScriptFile, false);
ScriptExportSettings scriptExportSettings = new ScriptExportSettings(export.getValue(ScriptExportMode.class), singleScriptFile, false, export.isEmbedEnabled(), false);
String singleFileName = Path.combine(scriptsFolder, swf.getShortFileName() + scriptExportSettings.getFileExtension());
try (FileTextWriter writer = scriptExportSettings.singleFile ? new FileTextWriter(Configuration.getCodeFormatting(), new FileOutputStream(singleFileName)) : null) {
scriptExportSettings.singleFileWriter = writer;
@@ -2289,7 +2289,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
singleScriptFile = false;
}
ScriptExportSettings scriptExportSettings = new ScriptExportSettings(exportMode, singleScriptFile, false);
ScriptExportSettings scriptExportSettings = new ScriptExportSettings(exportMode, singleScriptFile, false, export.isEmbedEnabled(), false);
String singleFileName = Path.combine(scriptsFolder, swf.getShortFileName() + scriptExportSettings.getFileExtension());
try (FileTextWriter writer = scriptExportSettings.singleFile ? new FileTextWriter(Configuration.getCodeFormatting(), new FileOutputStream(singleFileName)) : null) {
scriptExportSettings.singleFileWriter = writer;

View File

@@ -694,3 +694,8 @@ config.description.maxCachedNum = Maximum number of cached items before older it
config.name.warning.cannotencrypt = Warn when cannot save encrypted
config.description.warning.cannotencrypt = Show warning when cannot save SWF file which was encrypted using HARMAN Air encryption.
#after 18.5.0
config.name.lastExportEnableEmbed = Last setting of export embedded assets
config.description.lastExportEnableEmbed = Last setting of exporting embedded assets via [Embed] metadata.

View File

@@ -684,3 +684,7 @@ config.description.maxCachedNum = Maxim\u00e1ln\u00ed po\u010det cachovan\u00fdc
config.name.warning.cannotencrypt = Varovat kdy\u017e nelze ulo\u017eit za\u0161ifrovan\u00e9
config.description.warning.cannotencrypt = Zobrazit varov\u00e1n\u00ed kdy\u017e nelze ulo\u017eit SWF soubor kter\u00fd byl \u0161ifrov\u00e1n pomoc\u00ed HARMAN Air \u0161ifrov\u00e1n\u00ed.
#after 18.5.0
config.name.lastExportEnableEmbed = Posledn\u00ed nastaven\u00ed exportu vlo\u017een\u00fdch zdroj\u016f
config.description.lastExportEnableEmbed = Posledn\u00ed nastaven\u00ed exportov\u00e1n\u00ed vlo\u017een\u00fdch zdroj\u016f skrze [Embed] metadata.

View File

@@ -105,3 +105,5 @@ images.png_gif_jpeg_alpha = PNG/GIF/JPEG+alpha
#after 18.5.0
fonts4 = DefineFont4
fonts4.cff = CFF
embed = Export embedded assets via [Embed]

View File

@@ -45,7 +45,7 @@ scripts.pcode = P-k\u00f3d
scripts.pcode_hex = P-k\u00f3d s hex
scripts.hex = Hex
scripts.constants = Konstanty
scripts.as_method_stubs = Konstanty
scripts.as_method_stubs = Z\u00e1klady ActionScript metod
scripts.pcode_graphviz = P-k\u00f3d GraphViz
binaryData = Bin\u00e1rn\u00ed data
@@ -99,4 +99,6 @@ symbolclass = Mapov\u00e1n\u00ed symbol\u016f na t\u0159\u00eddy
symbolclass.csv = CSV
#after 18.0.0
images.png_gif_jpeg_alpha = PNG/GIF/JPEG+alpha
images.png_gif_jpeg_alpha = PNG/GIF/JPEG+alpha
embed = Exportovat vlo\u017een\u00e9 zdroje skrze [Embed]