From b910d873fb2e662e02f6af17284b662cda4ab23a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Sun, 21 Jan 2024 12:45:52 +0100 Subject: [PATCH] replace command --- .../decompiler/flash/cli/commands/Export.java | 5 +- .../decompiler/flash/cli/commands/Main.java | 3 +- .../flash/cli/commands/Replace.java | 109 ++++++++++++++++++ .../cli/commands/types/ReplaceFormat.java | 9 ++ 4 files changed, 121 insertions(+), 5 deletions(-) create mode 100644 libsrc/ffdec_cli/src/com/jpexs/decompiler/flash/cli/commands/Replace.java create mode 100644 libsrc/ffdec_cli/src/com/jpexs/decompiler/flash/cli/commands/types/ReplaceFormat.java diff --git a/libsrc/ffdec_cli/src/com/jpexs/decompiler/flash/cli/commands/Export.java b/libsrc/ffdec_cli/src/com/jpexs/decompiler/flash/cli/commands/Export.java index a260b3aaa..490ff8c6c 100644 --- a/libsrc/ffdec_cli/src/com/jpexs/decompiler/flash/cli/commands/Export.java +++ b/libsrc/ffdec_cli/src/com/jpexs/decompiler/flash/cli/commands/Export.java @@ -179,9 +179,6 @@ public class Export implements Runnable { @Override public void run() { - System.out.println("exporting...ok"); - for(String c : classes) { - System.out.println("class " + c); - } + } } diff --git a/libsrc/ffdec_cli/src/com/jpexs/decompiler/flash/cli/commands/Main.java b/libsrc/ffdec_cli/src/com/jpexs/decompiler/flash/cli/commands/Main.java index fa0dcbebf..b02ff9bfe 100644 --- a/libsrc/ffdec_cli/src/com/jpexs/decompiler/flash/cli/commands/Main.java +++ b/libsrc/ffdec_cli/src/com/jpexs/decompiler/flash/cli/commands/Main.java @@ -45,7 +45,8 @@ import picocli.CommandLine.ScopeType; Decrypt.class, Swf2Xml.class, Xml2Swf.class, - FlashPaper2Pdf.class + FlashPaper2Pdf.class, + Replace.class }, descriptionHeading = "%n@|bold,underline Description|@:%n", optionListHeading = "%n@|bold,underline Options|@:%n", diff --git a/libsrc/ffdec_cli/src/com/jpexs/decompiler/flash/cli/commands/Replace.java b/libsrc/ffdec_cli/src/com/jpexs/decompiler/flash/cli/commands/Replace.java new file mode 100644 index 000000000..5d9f63b8c --- /dev/null +++ b/libsrc/ffdec_cli/src/com/jpexs/decompiler/flash/cli/commands/Replace.java @@ -0,0 +1,109 @@ +package com.jpexs.decompiler.flash.cli.commands; + +import com.jpexs.decompiler.flash.cli.VersionProvider; +import com.jpexs.decompiler.flash.cli.commands.types.CompressionKind; +import com.jpexs.decompiler.flash.cli.commands.types.ReplaceFormat; +import java.util.List; +import picocli.CommandLine; +import picocli.CommandLine.Command; +import picocli.CommandLine.Option; +import picocli.CommandLine.Parameters; +import picocli.CommandLine.ParentCommand; +import picocli.CommandLine.ArgGroup; + +/** + * + * @author JPEXS + */ +@Command( + name = "replace", + mixinStandardHelpOptions = true, + versionProvider = VersionProvider.class, + header = "Replace the data of the specified items", + optionListHeading = "%n@|bold,underline Options|@:%n", + parameterListHeading = "%n@|bold,underline Parameters|@:%n", + synopsisHeading = "@|bold,underline Usage|@:", + footerHeading = "%n@|bold,underline Examples|@:%n", + footer = { + "ffdec-cli replace --character-id=27 --update-bounds --data-file=char27.svg --character-id=43 --data-file=char43.jpg --format=lossless2 input.swf output.swf", + "ffdec-cli replace --character-id=12 --data-file=data.bin input.swf output.swf", + }, + sortSynopsis = false +) +public class Replace implements Runnable { + @Parameters( + index = "0", + paramLabel = "IN_FILE", + description = "Input file" + ) + String inFile; + + @Parameters( + index = "1", + paramLabel = "OUT_FILE", + description = "Output file" + ) + String outFile; + + @ArgGroup(exclusive = false, multiplicity = "1..*") + List items; + + static class Item { + + @ArgGroup(exclusive = true, multiplicity = "1", order = 0) + CharacterIdOrScriptName characterIdOrScriptName; + + @Option( + names = "--update-bounds", + description = "Update shape bounds (no fill)", + order = 1 + ) + boolean updateShapeBounds; + + @Option( + names = "--format", + description = { + "Input format for images or shapes.", + "@|bold Enum values|@: ${COMPLETION-CANDIDATES}" + }, + order = 2 + ) + ReplaceFormat format = null; + + @Option( + names = "--body-id", + description = "Method body index if the imported entity is an AS3 P-Code", + order = 3 + ) + Integer bodyIndex = null; + + @Option( + names = {"--data-file"}, + description = "Imported data file", + required = true, + order = 4 + ) + String dataFile; + } + + static class CharacterIdOrScriptName { + @Option( + names = "--character-id", + description = "Character id. -1 for main timeline sound stream.", + required = true + ) + int characterId; + + @Option( + names = "--script-name", + description = "Name of the script", + required = true + ) + String scriptName; + } + + @Override + public void run() { + + } +} diff --git a/libsrc/ffdec_cli/src/com/jpexs/decompiler/flash/cli/commands/types/ReplaceFormat.java b/libsrc/ffdec_cli/src/com/jpexs/decompiler/flash/cli/commands/types/ReplaceFormat.java new file mode 100644 index 000000000..bbdca8279 --- /dev/null +++ b/libsrc/ffdec_cli/src/com/jpexs/decompiler/flash/cli/commands/types/ReplaceFormat.java @@ -0,0 +1,9 @@ +package com.jpexs.decompiler.flash.cli.commands.types; + +/** + * + * @author JPEXS + */ +public enum ReplaceFormat { + lossless, lossless2, jpeg2, jpeg3, jpeg4 +}