From b1c5f9d0c6a942e8e7a227dd79a0df99c2a6ec13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Sun, 13 Apr 2025 14:13:27 +0200 Subject: [PATCH] Checkstyle fix --- .../decompiler/flash/FlashPlayerVersion.java | 204 +++---- .../decompiler/flash/abc/ScriptPack.java | 1 - .../decompiler/flash/abc/avm2/AVM2Code.java | 102 ++-- .../flash/abc/avm2/fastavm2/FastAVM2List.java | 2 +- .../other/floatsupport/ConvertF4Ins.java | 8 +- .../avm2/model/TraitSlotConstAVM2Item.java | 35 +- .../abc/avm2/parser/pcode/ASM3Parser.java | 122 ++-- .../parser/script/AVM2SourceGenerator.java | 155 +++-- .../parser/script/ActionScript3Parser.java | 118 ++-- .../abc/avm2/parser/script/IndexAVM2Item.java | 1 - .../avm2/parser/script/PropertyAVM2Item.java | 12 +- .../flash/abc/types/traits/Trait.java | 2 +- .../flash/abc/types/traits/TraitClass.java | 70 +-- .../flash/abc/types/traits/Traits.java | 14 +- .../multinames/MethodMultinameUsage.java | 5 +- .../flash/abc/usages/simple/ABCWalker.java | 15 + .../jpexs/decompiler/flash/action/Action.java | 75 ++- .../action/fastactionlist/FastActionList.java | 4 +- .../action/model/FSCommand2ActionItem.java | 1 - .../action/model/FSCommandActionItem.java | 10 +- .../parser/script/ActionScript2Parser.java | 13 +- .../parser/script/ActionSourceGenerator.java | 42 +- .../flash/action/swf4/ActionGetURL2.java | 52 +- .../flash/amf/amf0/Amf0InputStream.java | 46 +- .../flash/amf/amf0/Amf0OutputStream.java | 48 +- .../flash/amf/amf0/types/BasicType.java | 2 +- .../flash/amf/amf0/types/DateType.java | 3 +- .../flash/amf/amf0/types/XmlDocumentType.java | 2 +- .../decompiler/flash/amf/amf3/Amf3Value.java | 2 +- .../exporters/amf/amf0/Amf0Exporter.java | 48 +- .../exporters/amf/amf3/Amf3Exporter.java | 55 +- .../swf/SwfFlashDevelopExporter.java | 48 +- .../swf/SwfIntelliJIdeaExporter.java | 19 +- .../exporters/swf/SwfVsCodeExporter.java | 538 +++++++++--------- .../flash/harman/HarmanBinaryDataEncrypt.java | 23 +- .../flash/harman/HarmanSwfEncrypt.java | 8 +- .../importers/amf/amf0/Amf0Importer.java | 2 +- .../importers/amf/amf3/Amf3Importer.java | 32 +- .../jpexs/decompiler/flash/sol/LsoTag.java | 22 +- .../jpexs/decompiler/flash/sol/SolFile.java | 34 +- .../decompiler/flash/timeline/Timeline.java | 39 +- .../decompiler/flash/types/FILLSTYLE.java | 12 +- .../flash/types/LINESTYLEARRAY.java | 9 +- .../decompiler/flash/types/MORPHGRADIENT.java | 19 +- .../flash/xfl/BinDataOutputStream.java | 12 +- .../flash/xfl/ImageBinDataGenerator.java | 18 +- .../flash/xfl/LosslessImageBinDataReader.java | 13 +- .../decompiler/flash/xfl/XFLConverter.java | 45 +- .../src/com/jpexs/decompiler/graph/Graph.java | 40 +- .../com/jpexs/helpers/CancellableWorker.java | 125 ++-- .../console/CommandLineArgumentParser.java | 16 +- .../flash/console/ConsoleUrlResolver.java | 18 +- .../easygui/CharacterTagTransferHandler.java | 44 +- .../decompiler/flash/easygui/EasyPanel.java | 23 +- .../flash/easygui/EasySwfPanel.java | 145 +++-- .../flash/easygui/LibraryTreeTable.java | 60 +- .../flash/easygui/TimelineBodyPanel.java | 95 ++-- .../flash/easygui/TimelineTimePanel.java | 6 +- .../decompiler/flash/easygui/UndoManager.java | 42 +- .../properties/AbstractPropertyField.java | 125 ++-- .../properties/DottedUnderlineLabel.java | 60 ++ .../properties/FloatPropertyField.java | 20 +- .../easygui/properties/JTriStateCheckBox.java | 25 +- .../easygui/properties/TextPropertyField.java | 14 +- .../panels/AbstractPropertiesPanel.java | 20 +- .../panels/DocumentPropertiesPanel.java | 9 - .../panels/InstancePropertiesPanel.java | 306 +++++----- .../gui/ConvertPlaceObjectTypeDialog.java | 39 +- .../flash/gui/ConvertShapeTypeDialog.java | 39 +- .../decompiler/flash/gui/ImagePanel.java | 314 +++++----- src/com/jpexs/decompiler/flash/gui/Main.java | 56 +- .../decompiler/flash/gui/MainFrameRibbon.java | 4 +- .../jpexs/decompiler/flash/gui/MainPanel.java | 51 +- .../decompiler/flash/gui/ScrollablePanel.java | 10 +- .../decompiler/flash/gui/TimelinedMaker.java | 10 +- .../decompiler/flash/gui/TransformPanel.java | 3 +- .../gui/colordialog/MainSwatchPanel.java | 327 +++++++++++ .../gui/colordialog/MyRecentSwatchPanel.java | 19 +- .../gui/colordialog/MySwatchChooserPanel.java | 415 +++----------- .../flash/gui/colordialog/MySwatchPanel.java | 36 +- .../generictageditors/Amf3ValueEditor.java | 2 +- .../flash/gui/player/PlayerControls.java | 24 +- .../gui/soleditor/SharedObjectsStorage.java | 26 +- .../flash/gui/soleditor/SolEditorFrame.java | 2 +- .../flash/gui/tagtree/TagTreeContextMenu.java | 94 ++- 85 files changed, 2486 insertions(+), 2340 deletions(-) create mode 100644 src/com/jpexs/decompiler/flash/easygui/properties/DottedUnderlineLabel.java create mode 100644 src/com/jpexs/decompiler/flash/gui/colordialog/MainSwatchPanel.java diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/FlashPlayerVersion.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/FlashPlayerVersion.java index 285358eef..79faa590b 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/FlashPlayerVersion.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/FlashPlayerVersion.java @@ -21,112 +21,116 @@ import java.util.Map; /** * Converts Flash player version to SWF version and vice versa. + * * @author JPEXS */ public class FlashPlayerVersion { + private static final Map flashPlayerToSwfVersion = new HashMap<>(); private static final Map airToSwfVersion = new HashMap<>(); private static final Map swfVersionToFlashPlayer = new HashMap<>(); private static final Map swfVersionToAir = new HashMap<>(); + static { - flashPlayerToSwfVersion.put("9.0", 9); //9.0.115.0 - flashPlayerToSwfVersion.put("10.0", 10); - flashPlayerToSwfVersion.put("10.1", 10); - flashPlayerToSwfVersion.put("10.2", 11); - flashPlayerToSwfVersion.put("10.3", 12); - flashPlayerToSwfVersion.put("11.0", 13); - flashPlayerToSwfVersion.put("11.1", 14); - flashPlayerToSwfVersion.put("11.2", 15); - flashPlayerToSwfVersion.put("11.3", 16); - flashPlayerToSwfVersion.put("11.4", 17); - flashPlayerToSwfVersion.put("11.5", 18); - flashPlayerToSwfVersion.put("11.6", 19); - flashPlayerToSwfVersion.put("11.7", 20); - flashPlayerToSwfVersion.put("11.8", 21); - flashPlayerToSwfVersion.put("11.9", 22); - flashPlayerToSwfVersion.put("12.0", 23); - flashPlayerToSwfVersion.put("13.0", 24); - flashPlayerToSwfVersion.put("14.0", 25); - flashPlayerToSwfVersion.put("15.0", 26); - flashPlayerToSwfVersion.put("16.0", 27); - flashPlayerToSwfVersion.put("17.0", 28); - flashPlayerToSwfVersion.put("18.0", 29); - flashPlayerToSwfVersion.put("19.0", 30); - flashPlayerToSwfVersion.put("20.0", 31); - flashPlayerToSwfVersion.put("21.0", 32); - flashPlayerToSwfVersion.put("22.0", 33); - flashPlayerToSwfVersion.put("23.0", 34); - flashPlayerToSwfVersion.put("24.0", 35); - flashPlayerToSwfVersion.put("25.0", 36); - flashPlayerToSwfVersion.put("26.0", 37); - flashPlayerToSwfVersion.put("27.0", 38); - flashPlayerToSwfVersion.put("28.0", 39); - flashPlayerToSwfVersion.put("29.0", 40); - flashPlayerToSwfVersion.put("30.0", 41); - flashPlayerToSwfVersion.put("31.0", 42); - flashPlayerToSwfVersion.put("32.0", 43); - flashPlayerToSwfVersion.put("33.0", 44); - flashPlayerToSwfVersion.put("33.1", 44); - flashPlayerToSwfVersion.put("50.0", 50); - flashPlayerToSwfVersion.put("51.0", 51); - - airToSwfVersion.put("1.5", 10); - airToSwfVersion.put("2.0", 10); - airToSwfVersion.put("2.6", 11); - airToSwfVersion.put("2.7", 12); - airToSwfVersion.put("3.0", 13); - airToSwfVersion.put("3.1", 14); - airToSwfVersion.put("3.2", 15); - airToSwfVersion.put("3.3", 16); - airToSwfVersion.put("3.4", 17); - airToSwfVersion.put("3.5", 18); - airToSwfVersion.put("3.6", 19); - airToSwfVersion.put("3.7", 20); - airToSwfVersion.put("3.8", 21); - airToSwfVersion.put("3.9", 22); - airToSwfVersion.put("4.0", 23); - airToSwfVersion.put("13.0", 24); - airToSwfVersion.put("14.0", 25); - airToSwfVersion.put("15.0", 26); - airToSwfVersion.put("16.0", 27); - airToSwfVersion.put("17.0", 28); - airToSwfVersion.put("18.0", 29); - airToSwfVersion.put("19.0", 30); - airToSwfVersion.put("20.0", 31); - airToSwfVersion.put("21.0", 32); - airToSwfVersion.put("22.0", 33); - airToSwfVersion.put("23.0", 34); - airToSwfVersion.put("24.0", 35); - airToSwfVersion.put("25.0", 36); - airToSwfVersion.put("26.0", 37); - airToSwfVersion.put("27.0", 38); - airToSwfVersion.put("28.0", 39); - airToSwfVersion.put("29.0", 40); - airToSwfVersion.put("30.0", 41); - airToSwfVersion.put("31.0", 42); - airToSwfVersion.put("32.0", 43); - airToSwfVersion.put("33.0", 44); - airToSwfVersion.put("33.1", 44); - airToSwfVersion.put("50.0", 50); - airToSwfVersion.put("51.0", 51); - - for (String flashPlayer : flashPlayerToSwfVersion.keySet()) { - int swfVersion = flashPlayerToSwfVersion.get(flashPlayer); - if (!swfVersionToFlashPlayer.containsKey(swfVersion)) { - swfVersionToFlashPlayer.put(swfVersion, flashPlayer); - } - } - - for (String air : airToSwfVersion.keySet()) { - int swfVersion = airToSwfVersion.get(air); - if (!swfVersionToAir.containsKey(swfVersion)) { - swfVersionToAir.put(swfVersion, air); - } - } + flashPlayerToSwfVersion.put("9.0", 9); //9.0.115.0 + flashPlayerToSwfVersion.put("10.0", 10); + flashPlayerToSwfVersion.put("10.1", 10); + flashPlayerToSwfVersion.put("10.2", 11); + flashPlayerToSwfVersion.put("10.3", 12); + flashPlayerToSwfVersion.put("11.0", 13); + flashPlayerToSwfVersion.put("11.1", 14); + flashPlayerToSwfVersion.put("11.2", 15); + flashPlayerToSwfVersion.put("11.3", 16); + flashPlayerToSwfVersion.put("11.4", 17); + flashPlayerToSwfVersion.put("11.5", 18); + flashPlayerToSwfVersion.put("11.6", 19); + flashPlayerToSwfVersion.put("11.7", 20); + flashPlayerToSwfVersion.put("11.8", 21); + flashPlayerToSwfVersion.put("11.9", 22); + flashPlayerToSwfVersion.put("12.0", 23); + flashPlayerToSwfVersion.put("13.0", 24); + flashPlayerToSwfVersion.put("14.0", 25); + flashPlayerToSwfVersion.put("15.0", 26); + flashPlayerToSwfVersion.put("16.0", 27); + flashPlayerToSwfVersion.put("17.0", 28); + flashPlayerToSwfVersion.put("18.0", 29); + flashPlayerToSwfVersion.put("19.0", 30); + flashPlayerToSwfVersion.put("20.0", 31); + flashPlayerToSwfVersion.put("21.0", 32); + flashPlayerToSwfVersion.put("22.0", 33); + flashPlayerToSwfVersion.put("23.0", 34); + flashPlayerToSwfVersion.put("24.0", 35); + flashPlayerToSwfVersion.put("25.0", 36); + flashPlayerToSwfVersion.put("26.0", 37); + flashPlayerToSwfVersion.put("27.0", 38); + flashPlayerToSwfVersion.put("28.0", 39); + flashPlayerToSwfVersion.put("29.0", 40); + flashPlayerToSwfVersion.put("30.0", 41); + flashPlayerToSwfVersion.put("31.0", 42); + flashPlayerToSwfVersion.put("32.0", 43); + flashPlayerToSwfVersion.put("33.0", 44); + flashPlayerToSwfVersion.put("33.1", 44); + flashPlayerToSwfVersion.put("50.0", 50); + flashPlayerToSwfVersion.put("51.0", 51); + + airToSwfVersion.put("1.5", 10); + airToSwfVersion.put("2.0", 10); + airToSwfVersion.put("2.6", 11); + airToSwfVersion.put("2.7", 12); + airToSwfVersion.put("3.0", 13); + airToSwfVersion.put("3.1", 14); + airToSwfVersion.put("3.2", 15); + airToSwfVersion.put("3.3", 16); + airToSwfVersion.put("3.4", 17); + airToSwfVersion.put("3.5", 18); + airToSwfVersion.put("3.6", 19); + airToSwfVersion.put("3.7", 20); + airToSwfVersion.put("3.8", 21); + airToSwfVersion.put("3.9", 22); + airToSwfVersion.put("4.0", 23); + airToSwfVersion.put("13.0", 24); + airToSwfVersion.put("14.0", 25); + airToSwfVersion.put("15.0", 26); + airToSwfVersion.put("16.0", 27); + airToSwfVersion.put("17.0", 28); + airToSwfVersion.put("18.0", 29); + airToSwfVersion.put("19.0", 30); + airToSwfVersion.put("20.0", 31); + airToSwfVersion.put("21.0", 32); + airToSwfVersion.put("22.0", 33); + airToSwfVersion.put("23.0", 34); + airToSwfVersion.put("24.0", 35); + airToSwfVersion.put("25.0", 36); + airToSwfVersion.put("26.0", 37); + airToSwfVersion.put("27.0", 38); + airToSwfVersion.put("28.0", 39); + airToSwfVersion.put("29.0", 40); + airToSwfVersion.put("30.0", 41); + airToSwfVersion.put("31.0", 42); + airToSwfVersion.put("32.0", 43); + airToSwfVersion.put("33.0", 44); + airToSwfVersion.put("33.1", 44); + airToSwfVersion.put("50.0", 50); + airToSwfVersion.put("51.0", 51); + + for (String flashPlayer : flashPlayerToSwfVersion.keySet()) { + int swfVersion = flashPlayerToSwfVersion.get(flashPlayer); + if (!swfVersionToFlashPlayer.containsKey(swfVersion)) { + swfVersionToFlashPlayer.put(swfVersion, flashPlayer); + } + } + + for (String air : airToSwfVersion.keySet()) { + int swfVersion = airToSwfVersion.get(air); + if (!swfVersionToAir.containsKey(swfVersion)) { + swfVersionToAir.put(swfVersion, air); + } + } } - + /** * Gets Flash player version by SWF version + * * @param swfVersion SWF version * @return Flash player version or null if not found */ @@ -136,9 +140,10 @@ public class FlashPlayerVersion { } return swfVersionToFlashPlayer.get(swfVersion); } - + /** * Gets SWF version by Flash player version. + * * @param flashPlayerVersion Flash player version * @return SWF version or -1 if not found */ @@ -148,10 +153,10 @@ public class FlashPlayerVersion { } return flashPlayerToSwfVersion.get(flashPlayerVersion); } - - + /** * Gets Air version by SWF version + * * @param swfVersion SWF version * @return Air version or null if not found */ @@ -161,9 +166,10 @@ public class FlashPlayerVersion { } return swfVersionToFlashPlayer.get(swfVersion); } - + /** * Gets SWF version by Air version. + * * @param air Air version * @return SWF version or -1 if not found */ diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ScriptPack.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ScriptPack.java index 8ab3e7ae4..b41283f77 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ScriptPack.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ScriptPack.java @@ -463,7 +463,6 @@ public class ScriptPack extends AS3ClassTreeItem { /** * Converts the script pack to source. * - * @param swfVersion SWF version * @param abcIndex Abc indexing * @param writer Writer * @param traits Traits diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java index d50f4193f..b0e079905 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java @@ -2566,17 +2566,15 @@ public class AVM2Code implements Cloneable { list = AVM2Graph.translateViaGraph(swfVersion, spe.getData(), callStack, abcIndex, path, this, abc, body, isStatic, scriptIndex, classIndex, localRegs, scopeStack, localRegNames, localRegTypes, fullyQualifiedNames, staticOperation, localRegAssignmentIps, thisHasDefaultToPrimitive); } if (initTraits != null) { - - + Map initClassMultinames = new LinkedHashMap<>(); - if (initializerType == GraphTextWriter.TRAIT_SCRIPT_INITIALIZER) { + if (initializerType == GraphTextWriter.TRAIT_SCRIPT_INITIALIZER) { for (int c : initTraitClasses) { initClassMultinames.put(abc.instance_info.get(c).name_index, abc.class_info.get(c).static_traits); } } initClassMultinames.put(-1, initTraits); - - + loopi: for (int i = 0; i < list.size(); i++) { GraphTargetItem ti = list.get(i); @@ -2604,16 +2602,16 @@ public class AVM2Code implements Cloneable { } } } - + /* TODO: All this requires a better care for instance attributes, for example using the assigned values only when it is referenced by const. - */ + */ if ((ti instanceof InitPropertyAVM2Item) || (ti instanceof SetPropertyAVM2Item)) { int multinameIndex = 0; GraphTargetItem value = null; GraphTargetItem obj = null; - if (ti instanceof InitPropertyAVM2Item) { + if (ti instanceof InitPropertyAVM2Item) { multinameIndex = ((InitPropertyAVM2Item) ti).propertyName.multinameIndex; value = ((InitPropertyAVM2Item) ti).value; obj = ((InitPropertyAVM2Item) ti).object; @@ -2624,7 +2622,7 @@ public class AVM2Code implements Cloneable { obj = ((SetPropertyAVM2Item) ti).object; } Multiname m = abc.constants.getMultiname(multinameIndex); - + Multiname om = null; if (obj instanceof GetPropertyAVM2Item) { om = abc.constants.getMultiname(((FullMultinameAVM2Item) ((GetPropertyAVM2Item) obj).propertyName).multinameIndex); @@ -2632,7 +2630,7 @@ public class AVM2Code implements Cloneable { if (obj instanceof GetLexAVM2Item) { om = ((GetLexAVM2Item) obj).propertyName; } - + for (int classMultiname : initClassMultinames.keySet()) { Traits ts = initClassMultinames.get(classMultiname); Multiname cm = classMultiname == -1 ? null : abc.constants.getMultiname(classMultiname); @@ -2642,55 +2640,55 @@ public class AVM2Code implements Cloneable { if (tm != null && tm.equals(m) && (classMultiname == -1 || Objects.equals(om, cm))) { if ((t instanceof TraitSlotConst)) { //if (((TraitSlotConst) t).isConst() || initializerType == GraphTextWriter.TRAIT_CLASS_INITIALIZER || initializerType == GraphTextWriter.TRAIT_SCRIPT_INITIALIZER) - { - TraitSlotConst tsc = (TraitSlotConst) t; - if (value != null && !convertData.assignedValues.containsKey(tsc)) { + //{ + TraitSlotConst tsc = (TraitSlotConst) t; + if (value != null && !convertData.assignedValues.containsKey(tsc)) { - if (!isStatic) { - Set subItems = value.getAllSubItemsRecursively(); - subItems.add(value); - List laterMultinames = new ArrayList<>(); - for (int k = j + 1; k < initTraits.traits.size(); k++) { - int tMultinameIndex = initTraits.traits.get(k).name_index; - if (tMultinameIndex > 0) { - Multiname tMultiname = abc.constants.getMultiname(tMultinameIndex); - laterMultinames.add(tMultiname); - } + if (!isStatic) { + Set subItems = value.getAllSubItemsRecursively(); + subItems.add(value); + List laterMultinames = new ArrayList<>(); + for (int k = j + 1; k < initTraits.traits.size(); k++) { + int tMultinameIndex = initTraits.traits.get(k).name_index; + if (tMultinameIndex > 0) { + Multiname tMultiname = abc.constants.getMultiname(tMultinameIndex); + laterMultinames.add(tMultiname); } - for (GraphTargetItem item : subItems) { + } + for (GraphTargetItem item : subItems) { - //if later slot is referenced, we must add it in constructor instead of direct assignment - if (item instanceof GetPropertyAVM2Item) { - Multiname multiName = abc.constants.getMultiname(((FullMultinameAVM2Item) ((GetPropertyAVM2Item) item).propertyName).multinameIndex); - if (laterMultinames.contains(multiName)) { - continue loopi; - } - } - if (item instanceof GetLexAVM2Item) { - Multiname multiName = ((GetLexAVM2Item) item).propertyName; - if (laterMultinames.contains(multiName)) { - continue loopi; - } - } - - if (item instanceof LocalRegAVM2Item) { //it is surely in constructor block, not in slot/const + //if later slot is referenced, we must add it in constructor instead of direct assignment + if (item instanceof GetPropertyAVM2Item) { + Multiname multiName = abc.constants.getMultiname(((FullMultinameAVM2Item) ((GetPropertyAVM2Item) item).propertyName).multinameIndex); + if (laterMultinames.contains(multiName)) { continue loopi; } - } + } + if (item instanceof GetLexAVM2Item) { + Multiname multiName = ((GetLexAVM2Item) item).propertyName; + if (laterMultinames.contains(multiName)) { + continue loopi; + } + } + + if (item instanceof LocalRegAVM2Item) { //it is surely in constructor block, not in slot/const + continue loopi; + } } - if (value instanceof NewFunctionAVM2Item) { - NewFunctionAVM2Item f = (NewFunctionAVM2Item) value; - f.functionName = tsc.getName(abc).getName(abc.constants, fullyQualifiedNames, true, true); - } - AssignedValue av = new AssignedValue(classMultiname == -1 ? ti : null, value, initializerType, methodIndex); - convertData.assignedValues.put(tsc, av); - if (!isStatic) { - list.remove(i); - i--; - } - continue loopi; } + if (value instanceof NewFunctionAVM2Item) { + NewFunctionAVM2Item f = (NewFunctionAVM2Item) value; + f.functionName = tsc.getName(abc).getName(abc.constants, fullyQualifiedNames, true, true); + } + AssignedValue av = new AssignedValue(classMultiname == -1 ? ti : null, value, initializerType, methodIndex); + convertData.assignedValues.put(tsc, av); + if (!isStatic) { + list.remove(i); + i--; + } + continue loopi; } + //} break; } } @@ -2728,7 +2726,7 @@ public class AVM2Code implements Cloneable { } } - + if (initializerType == GraphTextWriter.TRAIT_CLASS_INITIALIZER || initializerType == GraphTextWriter.TRAIT_SCRIPT_INITIALIZER) { Map commandToAssigned = new IdentityHashMap<>(); Map commandToTrait = new IdentityHashMap<>(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/fastavm2/FastAVM2List.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/fastavm2/FastAVM2List.java index 54fb87bbf..643b82dd1 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/fastavm2/FastAVM2List.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/fastavm2/FastAVM2List.java @@ -700,7 +700,7 @@ public class FastAVM2List implements Collection { /** * Converts to array. * - * @param the array into which the elements of this collection are to be + * @param a the array into which the elements of this collection are to be * stored, if it is big enough; otherwise, a new array of the same runtime * type is allocated for this purpose. * @param Type diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/floatsupport/ConvertF4Ins.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/floatsupport/ConvertF4Ins.java index 0903d2ede..7fbc5f0b3 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/floatsupport/ConvertF4Ins.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/floatsupport/ConvertF4Ins.java @@ -39,7 +39,7 @@ import java.util.List; * * @author JPEXS */ -public class ConvertF4Ins extends InstructionDefinition implements CoerceOrConvertTypeIns{ +public class ConvertF4Ins extends InstructionDefinition implements CoerceOrConvertTypeIns { /** * Constructor @@ -65,7 +65,7 @@ public class ConvertF4Ins extends InstructionDefinition implements CoerceOrConve lda.operandStack.push(new Float4(f, f, f, f)); return true; } - + @Override public int getStackPopCount(AVM2Instruction ins, ABC abc) { return 1; @@ -75,12 +75,12 @@ public class ConvertF4Ins extends InstructionDefinition implements CoerceOrConve public int getStackPushCount(AVM2Instruction ins, ABC abc) { return 1; } - + @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { stack.push(new ConvertAVM2Item(ins, localData.lineStartInstruction, stack.pop(), getTargetType(localData.getConstants(), ins))); } - + @Override public GraphTargetItem getTargetType(AVM2ConstantPool constants, AVM2Instruction ins) { return new TypeItem("float4"); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/TraitSlotConstAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/TraitSlotConstAVM2Item.java index c36bc41fd..7b7fca1e3 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/TraitSlotConstAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/TraitSlotConstAVM2Item.java @@ -41,7 +41,6 @@ public class TraitSlotConstAVM2Item extends AVM2Item { private final int methodIndex; private final int traitIndex; - /** * * @param instruction @@ -58,7 +57,7 @@ public class TraitSlotConstAVM2Item extends AVM2Item { public TraitSlotConstAVM2Item( GraphSourceItem instruction, GraphSourceItem lineStartIns, - TraitSlotConst trait, + TraitSlotConst trait, GraphTargetItem assignedValue, boolean isStatic, int scriptIndex, @@ -66,7 +65,7 @@ public class TraitSlotConstAVM2Item extends AVM2Item { int initializer, int methodIndex, int traitIndex - ) { + ) { super(instruction, lineStartIns, PRECEDENCE_PRIMARY); this.trait = trait; this.assignedValue = assignedValue; @@ -80,28 +79,28 @@ public class TraitSlotConstAVM2Item extends AVM2Item { @Override public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException { - + writer.endMethod(); writer.endTrait(); - + int h = traitIndex; if (initializer != GraphTextWriter.TRAIT_SCRIPT_INITIALIZER) { - h = localData.abc.getGlobalTraitId(TraitType.METHOD , isStatic, classIndex, traitIndex); + h = localData.abc.getGlobalTraitId(TraitType.METHOD, isStatic, classIndex, traitIndex); } writer.startTrait(h); ConvertData cd = new ConvertData(); cd.assignedValues.put(trait, new AssignedValue(null, assignedValue, initializer, methodIndex)); - boolean insideInterface = classIndex > -1 ? localData.abc.instance_info.get(classIndex).isInterface() : false; + boolean insideInterface = classIndex > -1 ? localData.abc.instance_info.get(classIndex).isInterface() : false; trait.toString( localData.swfVersion, localData.abcIndex, DottedChain.EMPTY /*??*/, - null, + null, cd, - "trait " + trait.getName(localData.abc), - localData.abc, - isStatic, - localData.exportMode, + "trait " + trait.getName(localData.abc), + localData.abc, + isStatic, + localData.exportMode, scriptIndex, classIndex, writer, @@ -110,9 +109,9 @@ public class TraitSlotConstAVM2Item extends AVM2Item { insideInterface ); writer.endTrait(); - + writer.startTrait(initializer); - writer.startMethod(methodIndex, null); + writer.startMethod(methodIndex, null); return writer; } @@ -124,17 +123,17 @@ public class TraitSlotConstAVM2Item extends AVM2Item { @Override public GraphTargetItem returnType() { return null; - } + } @Override public boolean needsSemicolon() { return false; - } + } @Override public boolean hasSingleNewLineAround() { return true; - } + } @Override public boolean handlesNewLine() { @@ -143,5 +142,5 @@ public class TraitSlotConstAVM2Item extends AVM2Item { public TraitSlotConst getTrait() { return trait; - } + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/pcode/ASM3Parser.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/pcode/ASM3Parser.java index 21e6255b1..36f6695d8 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/pcode/ASM3Parser.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/pcode/ASM3Parser.java @@ -134,23 +134,28 @@ public class ASM3Parser { } } + private static void expected(ParsedSymbol s, int type, String expStr, int line) throws IOException, AVM2ParseException { + if (s.type != type) { + throw new AVM2ParseException(expStr + " expected", line); + } + } + private static int getInteger(ParsedSymbol s, int line) throws AVM2ParseException { return getInteger(s, line, false); } + private static int getInteger(ParsedSymbol s, int line, boolean orNull) throws AVM2ParseException { - + String expected = "integer" + (orNull ? " or null" : "") + " expected"; if (s.type != ParsedSymbol.TYPE_NUMBER) { throw new AVM2ParseException(expected, line); } String nval = (String) s.value; - if ( - nval.endsWith("d") - || nval.endsWith("m") + if (nval.endsWith("d") + || nval.endsWith("m") || nval.contains("e") || nval.contains("E") - || nval.contains(".") - ) { + || nval.contains(".")) { throw new AVM2ParseException(expected, line); } if (nval.endsWith("i") || nval.endsWith("u")) { @@ -158,21 +163,19 @@ public class ASM3Parser { } return Integer.parseInt(nval); } - + private static long getUInteger(ParsedSymbol s, int line, boolean orNull) throws AVM2ParseException { - + String expected = "unsigned integer" + (orNull ? " or null" : "") + " expected"; if (s.type != ParsedSymbol.TYPE_NUMBER) { throw new AVM2ParseException(expected, line); } String nval = (String) s.value; - if ( - nval.endsWith("d") - || nval.endsWith("m") + if (nval.endsWith("d") + || nval.endsWith("m") || nval.contains("e") || nval.contains("E") - || nval.contains(".") - ) { + || nval.contains(".")) { throw new AVM2ParseException(expected, line); } if (nval.endsWith("i") || nval.endsWith("u")) { @@ -184,51 +187,44 @@ public class ASM3Parser { } return result; } - - + private static float getFloat(ParsedSymbol s, int line, boolean orNull) throws AVM2ParseException { String expected = "float" + (orNull ? " or null" : "") + " expected"; if (s.type != ParsedSymbol.TYPE_NUMBER) { throw new AVM2ParseException(expected, line); } - + String nval = (String) s.value; - if ( - nval.endsWith("d") - || nval.endsWith("m") - ) { + if (nval.endsWith("d") + || nval.endsWith("m")) { throw new AVM2ParseException(expected, line); } - - - if ( - nval.endsWith("i") + + if (nval.endsWith("i") || nval.endsWith("u") - || nval.endsWith("f") - ) { + || nval.endsWith("f")) { nval = nval.substring(0, nval.length() - 1); } - + return Float.parseFloat(nval); } - + private static Decimal128 getDecimal(ParsedSymbol s, int line, boolean orNull) throws AVM2ParseException { String expected = "decimal" + (orNull ? " or null" : "") + " expected"; if (s.type != ParsedSymbol.TYPE_NUMBER) { throw new AVM2ParseException(expected, line); } String nval = (String) s.value; - - if ( - nval.endsWith("i") + + if (nval.endsWith("i") || nval.endsWith("u") || nval.endsWith("d") - || nval.endsWith("m") - ) { + || nval.endsWith("m")) { nval = nval.substring(0, nval.length() - 1); } return new Decimal128(nval); } + private static double getDouble(ParsedSymbol s, int line, boolean orNull) throws AVM2ParseException { String expected = "double" + (orNull ? " or null" : "") + " expected"; if (s.type != ParsedSymbol.TYPE_NUMBER) { @@ -242,13 +238,7 @@ public class ASM3Parser { nval = nval.substring(0, nval.length() - 1); } return Double.parseDouble(nval); - } - - private static void expected(ParsedSymbol s, int type, String expStr, int line) throws IOException, AVM2ParseException { - if (s.type != type) { - throw new AVM2ParseException(expStr + " expected", line); - } - } + } private static void parseTraitParams(ABC abc, Flasm3Lexer lexer, Trait t) throws IOException, AVM2ParseException { ParsedSymbol symb; @@ -331,6 +321,7 @@ public class ASM3Parser { /** * Parses a class. + * * @param abc ABC * @param reader Reader * @param constants Constant pool @@ -454,6 +445,7 @@ public class ASM3Parser { /** * Parses a slot or const. + * * @param abc ABC * @param reader Reader * @param constants Constant pool @@ -467,7 +459,6 @@ public class ASM3Parser { return parseSlotConst(abc, lexer, constants, tsc); } - private static int parseNumberContext(Flasm3Lexer lexer) throws AVM2ParseException, IOException { ParsedSymbol s = lexer.lex(); expected(s, ParsedSymbol.TYPE_KEYWORD_NUMBERCONTEXT, "NumberContext", lexer.yyline()); @@ -493,7 +484,7 @@ public class ASM3Parser { default: throw new AVM2ParseException("Usage expected - one of: Number, decimal, double, int or uint", lexer.yyline()); } - int rounding = NumberContext.ROUND_HALF_UP; + int rounding = NumberContext.ROUND_HALF_UP; int precision = 34; if (usage == NumberContext.USE_NUMBER || usage == NumberContext.USE_DECIMAL) { expected(ParsedSymbol.TYPE_COMMA, ",", lexer); @@ -521,7 +512,7 @@ public class ASM3Parser { rounding = NumberContext.ROUND_FLOOR; break; default: - throw new AVM2ParseException("Rounding expected - one of: CEILING, UP, HALF_UP, HALF_EVEN, HALF_DOWN, DOWN, FLOOR", lexer.yyline()); + throw new AVM2ParseException("Rounding expected - one of: CEILING, UP, HALF_UP, HALF_EVEN, HALF_DOWN, DOWN, FLOOR", lexer.yyline()); } s = lexer.lex(); if (s.type == ParsedSymbol.TYPE_COMMA) { @@ -537,7 +528,7 @@ public class ASM3Parser { expected(ParsedSymbol.TYPE_PARENT_CLOSE, ")", lexer); return new NumberContext(usage, precision, rounding).toParam(); } - + private static int parseNamespaceSet(AVM2ConstantPool constants, Flasm3Lexer lexer) throws AVM2ParseException, IOException { List namespaceList = new ArrayList<>(); ParsedSymbol s = lexer.lex(); @@ -545,7 +536,7 @@ public class ASM3Parser { if (s.type == ParsedSymbol.TYPE_KEYWORD_UNKNOWN) { expected(ParsedSymbol.TYPE_PARENT_OPEN, "(", lexer); s = lexer.lex(); - int index = (int)getUInteger(s, lexer.yyline(), false); + int index = (int) getUInteger(s, lexer.yyline(), false); expected(ParsedSymbol.TYPE_PARENT_CLOSE, ")", lexer); return index; } @@ -591,7 +582,7 @@ public class ASM3Parser { case ParsedSymbol.TYPE_KEYWORD_UNKNOWN: expected(ParsedSymbol.TYPE_PARENT_OPEN, "(", lexer); ParsedSymbol s = lexer.lex(); - int unkId = (int)getUInteger(s, kind, false); + int unkId = (int) getUInteger(s, kind, false); expected(ParsedSymbol.TYPE_PARENT_CLOSE, ")", lexer); return unkId; case ParsedSymbol.TYPE_KEYWORD_NULL: @@ -656,7 +647,7 @@ public class ASM3Parser { case ParsedSymbol.TYPE_KEYWORD_UNKNOWN: expected(ParsedSymbol.TYPE_PARENT_OPEN, "(", lexer); s = lexer.lex(); - int unkId = (int)getUInteger(s, kind, false); + int unkId = (int) getUInteger(s, kind, false); expected(ParsedSymbol.TYPE_PARENT_CLOSE, ")", lexer); return unkId; case ParsedSymbol.TYPE_KEYWORD_NULL: @@ -788,6 +779,7 @@ public class ASM3Parser { /** * Parses value. + * * @param constants Constant pool * @param lexer Lexer * @return Value kind @@ -834,7 +826,7 @@ public class ASM3Parser { value_index = constants.getDoubleId(getDouble(value, lexer.yyline(), true), true); } expected(ParsedSymbol.TYPE_PARENT_CLOSE, ")", lexer); - break; + break; case ParsedSymbol.TYPE_KEYWORD_FLOAT: value_kind = ValueKind.CONSTANT_DecimalOrFloat; expected(ParsedSymbol.TYPE_PARENT_OPEN, "(", lexer); @@ -858,16 +850,16 @@ public class ASM3Parser { value = lexer.lex(); float f2 = getFloat(value, lexer.yyline(), true); expected(ParsedSymbol.TYPE_COMMA, ",", lexer); - value = lexer.lex(); + value = lexer.lex(); float f3 = getFloat(value, lexer.yyline(), true); expected(ParsedSymbol.TYPE_COMMA, ",", lexer); - value = lexer.lex(); + value = lexer.lex(); float f4 = getFloat(value, lexer.yyline(), true); Float4 fval = new Float4(f1, f2, f3, f4); value_index = constants.getFloat4Id(fval, true); } expected(ParsedSymbol.TYPE_PARENT_CLOSE, ")", lexer); - break; + break; case ParsedSymbol.TYPE_NUMBER: String nval = (String) type.value; if (nval.endsWith("m")) { @@ -884,14 +876,14 @@ public class ASM3Parser { value_index = constants.getDoubleId(Double.parseDouble(nval), true); break; } - + if (nval.endsWith("u")) { nval = nval.substring(0, nval.length() - 1); } if (nval.endsWith("i")) { nval = nval.substring(0, nval.length() - 1); - } - + } + value_kind = ValueKind.CONSTANT_Int; value_index = constants.getIntId(Integer.parseInt(nval), true); break; @@ -996,6 +988,7 @@ public class ASM3Parser { /** * Parses code. + * * @param abc ABC * @param reader Reader * @param trait Trait @@ -1012,6 +1005,7 @@ public class ASM3Parser { /** * Parses code. + * * @param abc ABC * @param reader Reader * @param trait Trait @@ -1094,7 +1088,7 @@ public class ASM3Parser { parseTraitParams(abc, lexer, trait); expected(ParsedSymbol.TYPE_KEYWORD_DISPID, "dispid", lexer); symb = lexer.lex(); - tm.disp_id = (int)getUInteger(symb, lexer.yyline(), false); + tm.disp_id = (int) getUInteger(symb, lexer.yyline(), false); break; case ParsedSymbol.TYPE_KEYWORD_FUNCTION: @@ -1141,25 +1135,25 @@ public class ASM3Parser { if (symb.type == ParsedSymbol.TYPE_KEYWORD_MAXSTACK) { symb = lexer.lex(); - body.max_stack = (int)getUInteger(symb, lexer.yyline(), false); + body.max_stack = (int) getUInteger(symb, lexer.yyline(), false); continue; } if (symb.type == ParsedSymbol.TYPE_KEYWORD_LOCALCOUNT) { symb = lexer.lex(); - body.max_regs = (int)getUInteger(symb, lexer.yyline(), false); + body.max_regs = (int) getUInteger(symb, lexer.yyline(), false); continue; } if (symb.type == ParsedSymbol.TYPE_KEYWORD_INITSCOPEDEPTH) { symb = lexer.lex(); - body.init_scope_depth = (int)getUInteger(symb, lexer.yyline(), false); + body.init_scope_depth = (int) getUInteger(symb, lexer.yyline(), false); continue; } if (symb.type == ParsedSymbol.TYPE_KEYWORD_MAXSCOPEDEPTH) { symb = lexer.lex(); - body.max_scope_depth = (int)getUInteger(symb, lexer.yyline(), false); + body.max_scope_depth = (int) getUInteger(symb, lexer.yyline(), false); continue; } @@ -1317,7 +1311,7 @@ public class ASM3Parser { if (parsedOperand.type == ParsedSymbol.TYPE_KEYWORD_UNKNOWN) { expected(ParsedSymbol.TYPE_PARENT_OPEN, "(", lexer); ParsedSymbol indexSymb = lexer.lex(); - int unkIndex = (int)getUInteger(indexSymb, lexer.yyline(), false); + int unkIndex = (int) getUInteger(indexSymb, lexer.yyline(), false); expected(ParsedSymbol.TYPE_PARENT_CLOSE, ")", lexer); operandsList.add(unkIndex); continue; @@ -1354,7 +1348,7 @@ public class ASM3Parser { if (parsedOperand.type == ParsedSymbol.TYPE_KEYWORD_NULL) { operandsList.add(0); - } else { + } else { int intVal = getInteger(parsedOperand, lexer.yyline(), true); int iid = constants.getIntId(intVal, false); if (iid == -1) { @@ -1402,7 +1396,7 @@ public class ASM3Parser { case AVM2Code.DAT_DECIMAL_INDEX: if (parsedOperand.type == ParsedSymbol.TYPE_KEYWORD_NULL) { operandsList.add(0); - } else{ + } else { Decimal128 decimalVal = getDecimal(parsedOperand, lexer.yyline(), true); int did = constants.getDecimalId(decimalVal, false); if (did == -1) { @@ -1504,7 +1498,7 @@ public class ASM3Parser { operandsList.add(0); } } else if (parsedOperand.type == ParsedSymbol.TYPE_NUMBER) { //old syntax - int patCount = (int)getUInteger(parsedOperand, lexer.yyline(), false); + int patCount = (int) getUInteger(parsedOperand, lexer.yyline(), false); operandsList.add(patCount); for (int c = 0; c <= patCount; c++) { @@ -1547,7 +1541,7 @@ public class ASM3Parser { break; default: if (parsedOperand.type == ParsedSymbol.TYPE_NUMBER) { - int val = getInteger(parsedOperand, lexer.yyline()); + int val = getInteger(parsedOperand, lexer.yyline()); operandsList.add(val); } else { throw new AVM2ParseException("Integer expected", lexer.yyline()); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/AVM2SourceGenerator.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/AVM2SourceGenerator.java index 0ad419d71..6affadcd2 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/AVM2SourceGenerator.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/AVM2SourceGenerator.java @@ -164,6 +164,7 @@ public class AVM2SourceGenerator implements SourceGenerator { /** * Generate a new unique id + * * @return Unique id */ public String uniqId() { @@ -173,6 +174,7 @@ public class AVM2SourceGenerator implements SourceGenerator { /** * Resolve type. + * * @param localData Local data * @param item Item * @param abcIndex ABC indexing @@ -220,7 +222,7 @@ public class AVM2SourceGenerator implements SourceGenerator { } } }*/ - + ABC abc = abcIndex.getSelectedAbc(); AVM2ConstantPool constants = abc.constants; AbcIndexing.ClassIndex ci = abcIndex.findClass(new TypeItem(dname), abc, localData != null ? localData.scriptIndex : null); @@ -306,6 +308,7 @@ public class AVM2SourceGenerator implements SourceGenerator { /** * Converts list of source items to list of instructions + * * @param items List of source items * @return List of instructions */ @@ -362,10 +365,9 @@ public class AVM2SourceGenerator implements SourceGenerator { } AVM2Instruction ajmp = null; if (onFalse != null) { - if (onTrueCmds.isEmpty() || - !((onTrueCmds.get(onTrueCmds.size() - 1) instanceof ContinueItem) - || (onTrueCmds.get(onTrueCmds.size() - 1) instanceof BreakItem)) - ) { + if (onTrueCmds.isEmpty() + || !((onTrueCmds.get(onTrueCmds.size() - 1) instanceof ContinueItem) + || (onTrueCmds.get(onTrueCmds.size() - 1) instanceof BreakItem))) { ajmp = ins(AVM2Instructions.Jump, 0); onTrue.add(ajmp); } @@ -420,6 +422,7 @@ public class AVM2SourceGenerator implements SourceGenerator { /** * Generate for (each) in loop. + * * @param localData Local data * @param loop Loop * @param collection Collection @@ -510,6 +513,7 @@ public class AVM2SourceGenerator implements SourceGenerator { /** * Gets register variables. + * * @param localData Local data * @return Register variables */ @@ -519,6 +523,7 @@ public class AVM2SourceGenerator implements SourceGenerator { /** * Sets register variables. + * * @param localData Local data * @param value Value */ @@ -528,6 +533,7 @@ public class AVM2SourceGenerator implements SourceGenerator { /** * Sets in function. + * * @param localData Local data * @param value Value */ @@ -537,6 +543,7 @@ public class AVM2SourceGenerator implements SourceGenerator { /** * Gets in function. + * * @param localData Local data * @return In function */ @@ -546,6 +553,7 @@ public class AVM2SourceGenerator implements SourceGenerator { /** * Checks if in method. + * * @param localData Local data * @return True if in method */ @@ -555,6 +563,7 @@ public class AVM2SourceGenerator implements SourceGenerator { /** * Sets in method. + * * @param localData Local data * @param value Value */ @@ -564,6 +573,7 @@ public class AVM2SourceGenerator implements SourceGenerator { /** * Gets for in level. + * * @param localData Local data * @return For in level */ @@ -573,6 +583,7 @@ public class AVM2SourceGenerator implements SourceGenerator { /** * Sets for in level. + * * @param localData Local data * @param value Value */ @@ -582,6 +593,7 @@ public class AVM2SourceGenerator implements SourceGenerator { /** * Gets temp register. + * * @param localData Local data * @return Temp register */ @@ -599,6 +611,7 @@ public class AVM2SourceGenerator implements SourceGenerator { /** * Constructor. + * * @param abc ABC */ public AVM2SourceGenerator(AbcIndexing abc) { @@ -608,9 +621,9 @@ public class AVM2SourceGenerator implements SourceGenerator { /*public ABC getABC() { return abc; }*/ - /** * Generate class. + * * @param importedClasses Imported classes * @param cinitVariables Cinit variables * @param cinitNeedsActivation Cinit needs activation @@ -638,14 +651,13 @@ public class AVM2SourceGenerator implements SourceGenerator { public void generateClass(List importedClasses, List cinitVariables, boolean cinitNeedsActivation, List cinit, List openedNamespaces, int namespace, int initScope, DottedChain pkg, ClassInfo classInfo, InstanceInfo instanceInfo, SourceGeneratorLocalData localData, boolean isInterface, String baseClassName, String superName, GraphTargetItem extendsVal, List implementsStr, GraphTargetItem iinit, List iinitVariables, boolean iinitNeedsActivation, List commands, Reference class_index) throws AVM2ParseException, CompilationException { List traitItems = new ArrayList<>(); for (GraphTargetItem it : commands) { - if ((it instanceof SlotAVM2Item) + if ((it instanceof SlotAVM2Item) || (it instanceof ConstAVM2Item) || (it instanceof ClassAVM2Item) || (it instanceof InterfaceAVM2Item) || (it instanceof MethodAVM2Item) || (it instanceof GetterAVM2Item) - || (it instanceof SetterAVM2Item) - ) { + || (it instanceof SetterAVM2Item)) { traitItems.add(it); } } @@ -657,8 +669,7 @@ public class AVM2SourceGenerator implements SourceGenerator { extendsVal = new TypeItem(DottedChain.OBJECT); } ParsedSymbol s = null; - - + if (Configuration.handleSkinPartsAutomatically.get()) { Map skinParts = new HashMap<>(); @@ -796,7 +807,6 @@ public class AVM2SourceGenerator implements SourceGenerator { int cinit_index = method(null, true, str(""), false, false, false, new ArrayList<>(), pkg, cinitNeedsActivation, cinitVariables, initScope + (implementsStr.isEmpty() ? 0 : 1), false, 0, isInterface ? null : baseClassName, superName, false, localData, new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), commands, TypeItem.UNBOUNDED); MethodBody cinitBody = abcIndex.getSelectedAbc().findBody(cinit_index); - for (int i = 0; i < cinitVariables.size(); i++) { AssignableAVM2Item an = cinitVariables.get(i); if (an instanceof UnresolvedAVM2Item) { @@ -815,7 +825,7 @@ public class AVM2SourceGenerator implements SourceGenerator { } } } - + //List cinitcode = new ArrayList<>(); List initcode = new ArrayList<>(); for (GraphTargetItem ti : commands) { @@ -850,16 +860,15 @@ public class AVM2SourceGenerator implements SourceGenerator { cinitcode.addAll(toInsList(val.toSource(localData, this))); cinitcode.add(ins(isConst ? AVM2Instructions.InitProperty : AVM2Instructions.SetProperty, traitName(ns, tname))); } - */ + */ if (!isStatic && val != null) { //do not init basic values, that can be stored in trait - if (!(val instanceof IntegerValueAVM2Item) + if (!(val instanceof IntegerValueAVM2Item) && !(val instanceof DoubleValueAVM2Item) - && !(val instanceof StringAVM2Item) - && !(val instanceof BooleanAVM2Item) - && !(val instanceof NullAVM2Item) - && !(val instanceof UndefinedAVM2Item) - ) { + && !(val instanceof StringAVM2Item) + && !(val instanceof BooleanAVM2Item) + && !(val instanceof NullAVM2Item) + && !(val instanceof UndefinedAVM2Item)) { val = handleAndOrCoerce(val, type); initcode.add(ins(AVM2Instructions.GetLocal0)); localData.isStatic = false; @@ -895,6 +904,7 @@ public class AVM2SourceGenerator implements SourceGenerator { /** * Generates class. + * * @param namespace Namespace * @param ci Class info * @param ii Instance info @@ -955,6 +965,7 @@ public class AVM2SourceGenerator implements SourceGenerator { /** * Gets trait name. + * * @param namespace Namespace * @param var Variable * @return Multiname index @@ -965,6 +976,7 @@ public class AVM2SourceGenerator implements SourceGenerator { /** * Gets type name. + * * @param localData Local data * @param type Type * @return Multiname index @@ -1000,6 +1012,7 @@ public class AVM2SourceGenerator implements SourceGenerator { /** * Gets identifier from name. + * * @param name Name * @return Identifier */ @@ -1012,6 +1025,7 @@ public class AVM2SourceGenerator implements SourceGenerator { /** * Gets namespace. + * * @param nsKind Namespace kind * @param name Name * @return Namespace index @@ -1022,6 +1036,7 @@ public class AVM2SourceGenerator implements SourceGenerator { /** * Gets string + * * @param name Name * @return String index */ @@ -1031,6 +1046,7 @@ public class AVM2SourceGenerator implements SourceGenerator { /** * Gets property name. + * * @param name Name * @return Multiname index */ @@ -1044,6 +1060,7 @@ public class AVM2SourceGenerator implements SourceGenerator { /** * Gets free register. + * * @param localData Local data * @return Register */ @@ -1058,6 +1075,7 @@ public class AVM2SourceGenerator implements SourceGenerator { /** * Kills register. + * * @param localData Local data * @param i Register * @return True if register was killed @@ -1096,7 +1114,8 @@ public class AVM2SourceGenerator implements SourceGenerator { newlocalData.returnType = retType; localData = newlocalData; - localData.activationReg = 0; int[] param_types = new int[paramTypes.size()]; + localData.activationReg = 0; + int[] param_types = new int[paramTypes.size()]; ValueKind[] optional = new ValueKind[paramValues.size()]; //int[] param_names = new int[paramNames.size()]; for (int i = 0; i < paramTypes.size(); i++) { @@ -1114,10 +1133,12 @@ public class AVM2SourceGenerator implements SourceGenerator { MethodInfo mi = new MethodInfo(param_types, constructor ? 0 : typeName(localData, retType), name_index, 0, optional, new int[0]/*no param_names*/); return abcIndex.getSelectedAbc().addMethodInfo(mi); } - + /** * Gets method. - * @param replaceMethodIndex Which method info to replace. Null = create new. + * + * @param replaceMethodIndex Which method info to replace. Null = create + * new. * @param isStatic Is static * @param name_index Name index * @param subMethod Sub method @@ -1273,11 +1294,11 @@ public class AVM2SourceGenerator implements SourceGenerator { if ((round == 1) && (m.matches())) { String regIndexStr = m.group(1); int regIndex = Integer.parseInt(regIndexStr); - - boolean alreadyExistsWithDifferentName = regIndex < registerNames.size() + + boolean alreadyExistsWithDifferentName = regIndex < registerNames.size() && !registerNames.get(regIndex).equals(UNUSED) && !registerNames.get(regIndex).equals(varName); - + if (alreadyExistsWithDifferentName) { addNew = true; } else { @@ -1293,7 +1314,7 @@ public class AVM2SourceGenerator implements SourceGenerator { } else if (round == 2 && !m.matches()) { //in second round the rest addNew = true; } - if (addNew) { + if (addNew) { //search for some unused indices first: int newRegIndex = -1; for (int j = 0; j < registerNames.size(); j++) { @@ -1442,11 +1463,11 @@ public class AVM2SourceGenerator implements SourceGenerator { } MethodInfo mi = new MethodInfo(param_types, constructor ? 0 : typeName(localData, retType), name_index, 0, optional, new int[0]/*no param_names*/); - + if (replaceMethodIndex != null) { mi = abcIndex.getSelectedAbc().method_info.get(replaceMethodIndex); } - + if (hasArguments) { mi.setFlagNeed_Arguments(); } @@ -1633,6 +1654,7 @@ public class AVM2SourceGenerator implements SourceGenerator { /** * Gets value kind. + * * @param ns Namespace * @param type Type * @param val Value @@ -1707,6 +1729,7 @@ public class AVM2SourceGenerator implements SourceGenerator { /** * Generates traits phase 2. + * * @param importedClasses Imported classes * @param pkg Package * @param items Items @@ -1766,6 +1789,7 @@ public class AVM2SourceGenerator implements SourceGenerator { /** * Generates traits phase 3. + * * @param items Items * @param traits Traits * @param localData Local data @@ -1839,6 +1863,7 @@ public class AVM2SourceGenerator implements SourceGenerator { /** * Gets super interface name. + * * @param localData Local data * @param un Unresolved item * @return Multiname index @@ -1861,6 +1886,7 @@ public class AVM2SourceGenerator implements SourceGenerator { /** * Generates metadata + * * @param metadata Metadata * @param abc ABC * @return Metadata indices @@ -1893,6 +1919,7 @@ public class AVM2SourceGenerator implements SourceGenerator { /** * Generates traits phase 4. + * * @param importedClasses Imported classes * @param openedNamespaces Opened namespaces * @param methodInitScope Method init scope @@ -2005,14 +2032,14 @@ public class AVM2SourceGenerator implements SourceGenerator { ((TraitFunction) traits[k]).method_info = methodHeader(false, methodName(false/*?*/, localData.pkg, fai.functionName, fai.pkg, null, null, ""), false, isInterface, fai.isNative, new ArrayList<>(), localData.pkg, fai.needsActivation, fai.subvariables, methodInitScope, fai.hasRest, fai.line, className, superName, false, localData, fai.paramTypes, fai.paramNames, fai.paramValues, fai.body, fai.retType); } } - + abcIndex.refreshSelected(); - + for (int k = 0; k < items.size(); k++) { GraphTargetItem item = items.get(k); if (traits[k] == null) { continue; - } + } if ((item instanceof MethodAVM2Item) || (item instanceof GetterAVM2Item) || (item instanceof SetterAVM2Item)) { MethodAVM2Item mai = (MethodAVM2Item) item; if (!isScriptTraits && mai.isStatic() != generateStatic) { @@ -2081,6 +2108,7 @@ public class AVM2SourceGenerator implements SourceGenerator { /** * Generates traits phase 1. + * * @param importedClasses Imported classes * @param openedNamespaces Opened namespaces * @param className Class name @@ -2247,6 +2275,7 @@ public class AVM2SourceGenerator implements SourceGenerator { /** * Generates script info. + * * @param sinitVariables Script initializer variables * @param sinitNeedsActivation Script initializer needs activation * @param importedClasses Imported classes @@ -2263,14 +2292,13 @@ public class AVM2SourceGenerator implements SourceGenerator { public void generateScriptInfo(List sinitVariables, boolean sinitNeedsActivation, List importedClasses, List openedNamespaces, int scriptIndex, ScriptInfo scriptInfo, List> allOpenedNamespaces, SourceGeneratorLocalData localData, List commands, int classPos) throws AVM2ParseException, CompilationException { List traitsList = new ArrayList<>(); for (GraphTargetItem it : commands) { - if ((it instanceof SlotAVM2Item) + if ((it instanceof SlotAVM2Item) || (it instanceof ConstAVM2Item) || (it instanceof ClassAVM2Item) || (it instanceof InterfaceAVM2Item) || (it instanceof MethodAVM2Item) || (it instanceof GetterAVM2Item) - || (it instanceof SetterAVM2Item) - ) { + || (it instanceof SetterAVM2Item)) { traitsList.add(it); } } @@ -2289,18 +2317,17 @@ public class AVM2SourceGenerator implements SourceGenerator { MethodBody mb; //= new MethodBody(abc, new Traits(), new byte[0], new ABCException[0]); //mb.method_info = abc.addMethodInfo(mi); - // mb.setCode(new AVM2Code()); - + // mb.setCode(new AVM2Code()); + localData.importedClasses = importedClasses; localData.openedNamespaces = openedNamespaces; int sinit_index = method(null, true, str(""), false, false, false, new ArrayList<>(), null, sinitNeedsActivation, sinitVariables, 0, false, 0, null, null, false, localData, new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), commands, TypeItem.UNBOUNDED); mb = abcIndex.getSelectedAbc().findBody(sinit_index); - List mbCode = mb.getCode().code; /*mbCode.add(ins(AVM2Instructions.GetLocal0)); mbCode.add(ins(AVM2Instructions.PushScope)); -*/ + */ int traitScope = 1; String documentClassStr = localData.documentClass; @@ -2366,13 +2393,13 @@ public class AVM2SourceGenerator implements SourceGenerator { } mbCode.addAll(2, sinitcode); //after getlocal0 pushscope - + //abc.addMethodBody(mb); scriptInfo.init_index = mb.method_info; localData.pkg = DottedChain.EMPTY; //localData.registerVars.put("this", 0); - generateTraitsPhase4(new ArrayList<>(), new ArrayList<>(), 1/*??*/, false, null, null, true, localData, traitsList, scriptInfo.traits, traitArr, initScopes, class_index, true); - + generateTraitsPhase4(new ArrayList<>(), new ArrayList<>(), 1/*??*/, false, null, null, true, localData, traitsList, scriptInfo.traits, traitArr, initScopes, class_index, true); + mb.markOffsets(); mb.autoFillStats(abc, 1, false); @@ -2380,6 +2407,7 @@ public class AVM2SourceGenerator implements SourceGenerator { /** * Parent names add names. + * * @param abc ABC * @param name_index Name index * @param indices Indices @@ -2410,6 +2438,7 @@ public class AVM2SourceGenerator implements SourceGenerator { /** * Gets trait return type. + * * @param abc ABC * @param t Trait * @return Trait return type @@ -2443,6 +2472,7 @@ public class AVM2SourceGenerator implements SourceGenerator { /** * Searches prototype chain. + * * @param namespaceSuffix Namespace suffix * @param otherNs Other namespaces * @param privateNs Private namespace @@ -2517,6 +2547,7 @@ public class AVM2SourceGenerator implements SourceGenerator { /** * Parent names. + * * @param abc ABC * @param name_index Name index * @param indices Indices @@ -2548,6 +2579,7 @@ public class AVM2SourceGenerator implements SourceGenerator { /** * Generates GetDescendants. + * * @param localData Local data * @param item Item * @return Source items @@ -2604,6 +2636,7 @@ public class AVM2SourceGenerator implements SourceGenerator { /** * Generates XMLFilter. + * * @param localData Local data * @param item Item * @return Source items @@ -2672,7 +2705,7 @@ public class AVM2SourceGenerator implements SourceGenerator { ret.addAll(AssignableAVM2Item.killTemp(localData, this, Arrays.asList(xmlListReg))); return ret; } - + @Override public List generate(SourceGeneratorLocalData localData, IfItem item) throws CompilationException { return generateIf(localData, item.expression, item.onTrue, item.onFalse, false); @@ -2684,18 +2717,18 @@ public class AVM2SourceGenerator implements SourceGenerator { ret.add(ins(AVM2Instructions.PushNull)); AVM2Instruction ifEq = ins(AVM2Instructions.IfEq, 0); ret.add(ifEq); - - List onNotNull = GraphTargetItem.toSourceMerge(localData, this, item.leftSide); + + List onNotNull = GraphTargetItem.toSourceMerge(localData, this, item.leftSide); AVM2Instruction jump = ins(AVM2Instructions.Jump, 0); onNotNull.add(jump); ifEq.operands[0] = insToBytes(toInsList(onNotNull)).length; - + List onNull = GraphTargetItem.toSourceMerge(localData, this, item.rightSide); jump.operands[0] = insToBytes(toInsList(onNull)).length; - + ret.addAll(onNotNull); ret.addAll(onNull); - + return ret; } @@ -2742,6 +2775,7 @@ public class AVM2SourceGenerator implements SourceGenerator { /** * Generates for each in loop. + * * @param localData Local data * @param item Loop item * @return Source items @@ -2753,6 +2787,7 @@ public class AVM2SourceGenerator implements SourceGenerator { /** * Generates for in loop. + * * @param localData Local data * @param item Loop item * @return Source items @@ -2799,6 +2834,7 @@ public class AVM2SourceGenerator implements SourceGenerator { /** * Generates with statement. + * * @param localData Local data * @param item Item * @return Source items @@ -2934,7 +2970,7 @@ public class AVM2SourceGenerator implements SourceGenerator { forwardJump.operands[0] = insToBytes(bodies).length; ret.addAll(bodies); ret.addAll(cases); - ret.add(lookupOp); + ret.add(lookupOp); fixSwitch(toInsList(ret), insToBytes(toInsList(ret)).length, item.loop.id); return ret; } @@ -2999,6 +3035,7 @@ public class AVM2SourceGenerator implements SourceGenerator { /** * Generates function. + * * @param localData Local data * @param item Item * @return Source items @@ -3028,6 +3065,7 @@ public class AVM2SourceGenerator implements SourceGenerator { /** * Generates try-catch-finally. + * * @param localData Local data * @param item Item * @return Source items @@ -3393,6 +3431,7 @@ public class AVM2SourceGenerator implements SourceGenerator { /** * Generates return value. + * * @param localData Local data * @param item Item * @return Source items @@ -3432,6 +3471,7 @@ public class AVM2SourceGenerator implements SourceGenerator { /** * Generates return void. + * * @param localData Local data * @param item Item * @return Source items @@ -3465,6 +3505,7 @@ public class AVM2SourceGenerator implements SourceGenerator { /** * Generates throw. + * * @param localData Local data * @param item Item * @return Source items @@ -3537,11 +3578,13 @@ public class AVM2SourceGenerator implements SourceGenerator { List ret = new ArrayList<>(); return ret; } - + /** - * For some strange reasons, && and || operators must have coerced both sides - * when there is specific type expected. - * @param item Item to check. If it's && or ||, it will be handled, otherwise ignored + * For some strange reasons, && and || operators must have coerced + * both sides when there is specific type expected. + * + * @param item Item to check. If it's && or ||, it will be handled, + * otherwise ignored * @param type Coerced type * @return Original value or coerced item */ @@ -3549,14 +3592,14 @@ public class AVM2SourceGenerator implements SourceGenerator { if (type == null) { return item; } - if ((item instanceof OrItem)||(item instanceof AndItem)) { + if ((item instanceof OrItem) || (item instanceof AndItem)) { BinaryOpItem bo = (BinaryOpItem) item; - if ((bo.leftSide instanceof OrItem)||(bo.leftSide instanceof AndItem)) { + if ((bo.leftSide instanceof OrItem) || (bo.leftSide instanceof AndItem)) { bo.leftSide = handleAndOrCoerce(bo.leftSide, type); } else { bo.leftSide = new CoerceAVM2Item(null, null, bo.leftSide, type); } - if ((bo.rightSide instanceof OrItem)||(bo.rightSide instanceof AndItem)) { + if ((bo.rightSide instanceof OrItem) || (bo.rightSide instanceof AndItem)) { bo.rightSide = handleAndOrCoerce(bo.rightSide, type); } else { bo.rightSide = new CoerceAVM2Item(null, null, bo.rightSide, type); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ActionScript3Parser.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ActionScript3Parser.java index d6e0841fe..fa8361abb 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ActionScript3Parser.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ActionScript3Parser.java @@ -657,7 +657,7 @@ public class ActionScript3Parser { openedNamespaces.add(privateNs); openedNamespaces.add(protectedNs); openedNamespaces.add(staticProtectedNs); - + Stack cinitLoops = new Stack<>(); Map cinitLoopLabels = new HashMap<>(); HashMap cinitRegisterVars = new HashMap<>(); @@ -686,15 +686,15 @@ public class ActionScript3Parser { }*/ List>> metadata = parseMetadata(); //s = lex(); - - ParsedSymbol s = lex(); + + ParsedSymbol s = lex(); while (s.isType(SymbolType.NATIVE, SymbolType.STATIC, SymbolType.PUBLIC, SymbolType.PRIVATE, SymbolType.PROTECTED, SymbolType.OVERRIDE, SymbolType.FINAL, SymbolType.DYNAMIC, SymbolGroup.IDENTIFIER, SymbolType.INTERNAL, SymbolType.PREPROCESSOR)) { if (s.type == SymbolType.FINAL) { if (isFinal) { throw new AVM2ParseException("Only one final keyword allowed", lexer.yyline()); } preSymbols.add(s); - isFinal = true; + isFinal = true; } else if (s.type == SymbolType.OVERRIDE) { if (isOverride) { throw new AVM2ParseException("Only one override keyword allowed", lexer.yyline()); @@ -723,7 +723,7 @@ public class ActionScript3Parser { preSymbols.add(s); isNative = true; } else if (s.group == SymbolGroup.IDENTIFIER) { - customNs = s.value.toString(); + customNs = s.value.toString(); if (isInterface) { throw new AVM2ParseException("Namespace attributes are not permitted on interface methods", lexer.yyline()); } @@ -767,14 +767,14 @@ public class ActionScript3Parser { s = lex(); expected(s, lexer.yyline(), SymbolType.PARENT_OPEN); preSymbols.add(s); - s = lex(); + s = lex(); expected(s, lexer.yyline(), SymbolType.STRING); - preSymbols.add(s); + preSymbols.add(s); namespace = new NamespaceItem((String) s.value, Namespace.KIND_NAMESPACE); s = lex(); expected(s, lexer.yyline(), SymbolType.PARENT_CLOSE); - preSymbols.add(s); - + preSymbols.add(s); + } else { lexer.pushback(s); } @@ -971,7 +971,7 @@ public class ActionScript3Parser { for (int i = preSymbols.size() - 1; i >= 0; i--) { lexer.pushback(preSymbols.get(i)); } - + GraphTargetItem cmd = command(allOpenedNamespaces, null, publicNs, cinitNeedsActivation, importedClasses, openedNamespaces, cinitLoops, cinitLoopLabels, cinitRegisterVars, true, false, 0, false, cinitVariables, abc); if (cmd != null) { traits.add(cmd); @@ -988,28 +988,28 @@ public class ActionScript3Parser { List> allOpenedNamespaces, int scriptIndex, String scriptName, - List traits, - Reference numberUsageRef, - Reference numberRoundingRef, + List traits, + Reference numberUsageRef, + Reference numberRoundingRef, Reference numberPrecisionRef, ABC abc, Reference sinitNeedsActivation, - List sinitVariables - ) throws AVM2ParseException, IOException, CompilationException, InterruptedException { + List sinitVariables + ) throws AVM2ParseException, IOException, CompilationException, InterruptedException { Stack sinitLoops = new Stack<>(); Map sinitLoopLabels = new HashMap<>(); - + HashMap sinitRegisterVars = new HashMap<>(); while (scriptTraitsBlock( importedClasses, openedNamespaces, - allOpenedNamespaces, + allOpenedNamespaces, scriptIndex, - scriptName, - traits, + scriptName, + traits, numberUsageRef, - numberRoundingRef, + numberRoundingRef, numberPrecisionRef, abc, sinitNeedsActivation, @@ -1017,7 +1017,7 @@ public class ActionScript3Parser { sinitLoopLabels, sinitRegisterVars, sinitVariables - )) { + )) { //empty } } @@ -1029,7 +1029,7 @@ public class ActionScript3Parser { int scriptIndex, String scriptName, List traits, - Reference numberUsageRef, + Reference numberUsageRef, Reference numberRoundingRef, Reference numberPrecisionRef, ABC abc, @@ -1037,8 +1037,8 @@ public class ActionScript3Parser { Stack sinitLoops, Map sinitLoopLabels, HashMap sinitRegisterVars, - List sinitVariables - ) throws AVM2ParseException, IOException, CompilationException, InterruptedException { + List sinitVariables + ) throws AVM2ParseException, IOException, CompilationException, InterruptedException { ParsedSymbol s; boolean inPackage = false; s = lex(); @@ -1105,7 +1105,7 @@ public class ActionScript3Parser { throw new AVM2ParseException("Only one final keyword allowed", lexer.yyline()); } isFinal = true; - preSymbols.add(s); + preSymbols.add(s); } if (s.type == SymbolType.PUBLIC) { if (!inPackage) { @@ -1153,16 +1153,16 @@ public class ActionScript3Parser { expected(s, lexer.yyline(), SymbolGroup.IDENTIFIER); subNameStr = s.value.toString(); s = lex(); - + boolean nullable = true; - + if (s.type == SymbolType.NOT) { s = lex(); nullable = false; } else if (s.type == SymbolType.TERNAR) { s = lex(); } - + if (!isInterface) { if (s.type == SymbolType.EXTENDS) { @@ -1297,11 +1297,11 @@ public class ActionScript3Parser { break; default: lexer.pushback(s); - + for (int i = preSymbols.size() - 1; i >= 0; i--) { lexer.pushback(preSymbols.get(i)); } - + if (parseImportsUsages(importedClasses, openedNamespaces, numberUsageRef, numberPrecisionRef, numberRoundingRef, abc)) { break; } @@ -1309,7 +1309,7 @@ public class ActionScript3Parser { if (cmd != null) { traits.add(cmd); isEmpty = false; - } else { + } else { break looptrait; } } @@ -2465,7 +2465,7 @@ public class ActionScript3Parser { break; case PLUS: - GraphTargetItem nump = expressionPrimary(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, false, registerVars, inFunction, inMethod, true, variables, abc); + GraphTargetItem nump = expressionPrimary(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, false, registerVars, inFunction, inMethod, true, variables, abc); if (abc.hasFloatSupport()) { ret = new UnPlusAVM2Item(null, null, nump); } else { @@ -2480,7 +2480,7 @@ public class ActionScript3Parser { ret = new IntegerValueAVM2Item(null, null, -(Integer) s.value); } else if (s.isType(SymbolType.DECIMAL)) { ret = new DecimalValueAVM2Item(null, null, ((Decimal128) s.value).multiply(Decimal128.NEG1)); - } else if (s.isType(SymbolType.FLOAT)) { + } else if (s.isType(SymbolType.FLOAT)) { ret = new FloatValueAVM2Item(null, null, -(Float) s.value); } else { lexer.pushback(s); @@ -2586,7 +2586,7 @@ public class ActionScript3Parser { case DOUBLE: ret = new DoubleValueAVM2Item(null, null, (Double) s.value); allowMemberOrCall = true; // 5.2.toString(); - break; + break; case DECIMAL: if (!abc.hasDecimalSupport()) { throw new AVM2ParseException("The ABC has no decimal support", lexer.yyline()); @@ -2604,11 +2604,11 @@ public class ActionScript3Parser { case FLOAT4: if (!abc.hasFloat4Support()) { //parse again as method call - lexer.yypushbackstr(lexer.yytext().substring("float4".length())); + lexer.yypushbackstr(lexer.yytext().substring("float4".length())); lexer.pushback(new ParsedSymbol(SymbolGroup.IDENTIFIER, SymbolType.IDENTIFIER, "float4")); - ret = name(allOpenedNamespaces, thisType, pkg, needsActivation, false, openedNamespaces, registerVars, inFunction, inMethod, variables, importedClasses, abc); + ret = name(allOpenedNamespaces, thisType, pkg, needsActivation, false, openedNamespaces, registerVars, inFunction, inMethod, variables, importedClasses, abc); } else { - ret = new Float4ValueAVM2Item(null, null, (Float4) s.value); + ret = new Float4ValueAVM2Item(null, null, (Float4) s.value); } allowMemberOrCall = true; break; @@ -2723,11 +2723,11 @@ public class ActionScript3Parser { private boolean parseImportsUsages(List importedClasses, List openedNamespaces, Reference numberUsageRef, Reference numberPrecisionRef, Reference numberRoundingRef, ABC abc) throws IOException, AVM2ParseException, InterruptedException { boolean isEmpty = true; - ParsedSymbol s; + ParsedSymbol s; s = lex(); while (s.isType(SymbolType.IMPORT, SymbolType.USE)) { - + if (s.isType(SymbolType.IMPORT)) { isEmpty = false; s = lex(); @@ -2757,7 +2757,7 @@ public class ActionScript3Parser { } else { importedClasses.add(fullName); } - expected(s, lexer.yyline(), SymbolType.SEMICOLON); + expected(s, lexer.yyline(), SymbolType.SEMICOLON); } else if (s.isType(SymbolType.USE)) { isEmpty = false; do { @@ -2785,7 +2785,7 @@ public class ActionScript3Parser { if (!abc.hasDecimalSupport()) { throw new AVM2ParseException("Invalid use kind", lexer.yyline()); } - + expected(s, lexer.yyline(), SymbolType.IDENTIFIER); String pragmaItemName = (String) s.value; switch (pragmaItemName) { @@ -2848,9 +2848,9 @@ public class ActionScript3Parser { default: throw new AVM2ParseException("Invalid use kind", lexer.yyline()); } - } + } s = lex(); - }while(s.isType(SymbolType.COMMA)); + } while (s.isType(SymbolType.COMMA)); expected(s, lexer.yyline(), SymbolType.SEMICOLON); } /*boolean isUse = s.type == SymbolType.USE; @@ -2858,7 +2858,7 @@ public class ActionScript3Parser { expectedType(SymbolType.NAMESPACE); }*/ - + s = lex(); } lexer.pushback(s); @@ -2869,13 +2869,13 @@ public class ActionScript3Parser { List importedClasses, List openedNamespaces, List> allOpenedNamespaces, - int scriptIndex, - String fileName, + int scriptIndex, + String fileName, Reference numberContextRef, ABC abc, Reference sinitNeedsActivation, List sinitVariables - ) throws IOException, AVM2ParseException, CompilationException, InterruptedException { + ) throws IOException, AVM2ParseException, CompilationException, InterruptedException { //int scriptPrivateNs; if (fileName.contains("/")) { @@ -2889,7 +2889,7 @@ public class ActionScript3Parser { Reference numberRoundingRef = new Reference<>(NumberContext.ROUND_HALF_EVEN); Reference numberPrecisionRef = new Reference<>(34); scriptTraits(importedClasses, openedNamespaces, allOpenedNamespaces, scriptIndex, fileName, items, numberUsageRef, numberRoundingRef, numberPrecisionRef, abc, sinitNeedsActivation, sinitVariables); - + NumberContext nc = new NumberContext(numberUsageRef.getVal(), numberPrecisionRef.getVal(), numberRoundingRef.getVal()); if (!nc.isDefault()) { numberContextRef.setVal(nc.toParam()); @@ -2899,6 +2899,7 @@ public class ActionScript3Parser { /** * Converts string to script traits. + * * @param importedClasses Imported classes * @param openedNamespaces Opened namespaces * @param allOpenedNamespaces All opened namespaces @@ -2918,15 +2919,15 @@ public class ActionScript3Parser { public List scriptTraitsFromString( List importedClasses, List openedNamespaces, - List> allOpenedNamespaces, - String str, - String fileName, - int scriptIndex, - Reference numberContextRef, + List> allOpenedNamespaces, + String str, + String fileName, + int scriptIndex, + Reference numberContextRef, ABC abc, Reference sinitNeedsActivation, List sinitVariables - ) throws AVM2ParseException, IOException, CompilationException, InterruptedException { + ) throws AVM2ParseException, IOException, CompilationException, InterruptedException { lexer = new ActionScriptLexer(str); List ret = parseScript(importedClasses, openedNamespaces, allOpenedNamespaces, scriptIndex, fileName, numberContextRef, abc, sinitNeedsActivation, sinitVariables); @@ -2938,6 +2939,7 @@ public class ActionScript3Parser { /** * Adds script from tree. + * * @param sinitVariables Script initializer variables * @param sinitNeedsActivation Script initializer needs activation * @param importedClasses Imported classes @@ -2972,6 +2974,7 @@ public class ActionScript3Parser { /** * Adds script. + * * @param s Source code * @param fileName File name * @param classPos Class position @@ -2996,6 +2999,7 @@ public class ActionScript3Parser { /** * Constructor. + * * @param abcIndex ABC index * @throws IOException On I/O error * @throws InterruptedException On interrupt @@ -3008,6 +3012,7 @@ public class ActionScript3Parser { /** * Compiles AS3 source code. + * * @param src Source code * @param abc ABC * @param abcIndex ABC index @@ -3027,7 +3032,7 @@ public class ActionScript3Parser { ActionScript3Parser parser = new ActionScript3Parser(abcIndex); boolean success = false; ABC originalAbc = ((ABCContainerTag) ((Tag) abc.parentTag).cloneTag()).getABC(); - Set modifiedScripts = new HashSet<>(); + Set modifiedScripts = new HashSet<>(); for (int i = 0; i < abc.script_info.size(); i++) { if (abc.script_info.get(i).isModified()) { modifiedScripts.add(i); @@ -3047,7 +3052,7 @@ public class ActionScript3Parser { abc.script_info = originalAbc.script_info; abc.bodies = originalAbc.bodies; abc.resetMethodIndexing(); - + for (int i = 0; i < abc.script_info.size(); i++) { if (modifiedScripts.contains(i)) { abc.script_info.get(i).setModified(true); @@ -3059,6 +3064,7 @@ public class ActionScript3Parser { /** * Compiles AS3 source code. + * * @param swf SWF * @param srcFile Source file * @param destFile Target file diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/IndexAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/IndexAVM2Item.java index b7fb760e7..beae25788 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/IndexAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/IndexAVM2Item.java @@ -19,7 +19,6 @@ package com.jpexs.decompiler.flash.abc.avm2.parser.script; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions; -import static com.jpexs.decompiler.flash.abc.avm2.model.AVM2Item.ins; import com.jpexs.decompiler.flash.abc.types.Multiname; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.graph.CompilationException; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/PropertyAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/PropertyAVM2Item.java index 27adfaa47..bcc804cf9 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/PropertyAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/PropertyAVM2Item.java @@ -545,7 +545,12 @@ public class PropertyAVM2Item extends AssignableAVM2Item { return result; } } - + + @Override + public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException { + return toSource(localData, generator, true); + } + private int getBytesLen(List code) { int len = 0; for (GraphSourceItem instruction : code) { @@ -555,10 +560,7 @@ public class PropertyAVM2Item extends AssignableAVM2Item { return len; } - @Override - public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException { - return toSource(localData, generator, true); - } + @Override public List toSourceIgnoreReturnValue(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/Trait.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/Trait.java index d3ac7ff56..afdea0df5 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/Trait.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/Trait.java @@ -356,7 +356,7 @@ public abstract class Trait implements Cloneable, Serializable { /** * Writes imports. * - * @param trait Trait + * @param traits Traits * @param methodIndex Method index * @param abcIndex ABC indexing * @param scriptIndex Script index diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java index a5510c924..b01a04c02 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java @@ -80,7 +80,7 @@ public class TraitClass extends Trait implements TraitWithSlot { /** * Frame trait names */ - private final List frameTraitNames = new ArrayList<>(); + private final List frameTraitNames = new ArrayList<>(); /** * Deletes this trait. @@ -147,13 +147,13 @@ public class TraitClass extends Trait implements TraitWithSlot { //instance initializer DependencyParser.parseDependenciesFromMethodInfo(abcIndex, null, scriptIndex, class_info, false, customNamespace, abc, instanceInfo.iinit_index, dependencies, packageName, fullyQualifiedNames, new ArrayList<>(), uses, numberContextRef); } - + @Override public GraphTextWriter toStringHeader(int swfVersion, Trait parent, DottedChain packageName, ConvertData convertData, String path, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, GraphTextWriter writer, List fullyQualifiedNames, boolean parallel, boolean insideInterface) { abc.instance_info.get(class_info).getClassHeaderStr(convertData.assetsDir, writer, abc, fullyQualifiedNames, false, false /*??*/); return writer; } - + @Override public void convertHeader(int swfVersion, Trait parent, ConvertData convertData, String path, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, NulWriter writer, List fullyQualifiedNames, boolean parallel) { } @@ -198,13 +198,13 @@ public class TraitClass extends Trait implements TraitWithSlot { Multiname instanceInfoMultiname = instanceInfo.getName(abc.constants); //DottedChain packageName = instanceInfoMultiname.getNamespace(abc.constants).getName(abc.constants); //assume not null name - - Reference first = new Reference<>(true); - + + Reference first = new Reference<>(true); + String instanceInfoName = instanceInfoMultiname.getName(abc.constants, fullyQualifiedNames, false, true); getMetaData(this, convertData, abc, writer); - + boolean allowEmbed = true; if (convertData.exportEmbedFlaMode) { @@ -235,7 +235,7 @@ public class TraitClass extends Trait implements TraitWithSlot { } } } - + //class header instanceInfo.getClassHeaderStr(convertData.assetsDir, writer, abc, fullyQualifiedNames, false, allowEmbed); writer.endTrait(); @@ -243,7 +243,7 @@ public class TraitClass extends Trait implements TraitWithSlot { writer.startClass(class_info); first.setVal(true); - + //static variables & constants ClassInfo classInfo = abc.class_info.get(class_info); classInfo.static_traits.toString(swfVersion, packageName, first, abcIndex, new Class[]{TraitSlotConst.class}, this, convertData, path + "/" + instanceInfoName, abc, true, exportMode, false, scriptIndex, class_info, writer, fullyQualifiedNames, parallel, new ArrayList<>(), isInterface); @@ -257,7 +257,7 @@ public class TraitClass extends Trait implements TraitWithSlot { if (!classInitializerIsEmpty) { //writer.startBlock(); if (!first.getVal()) { - writer.newLine(); + writer.newLine(); } first.setVal(false); List callStack = new ArrayList<>(); @@ -287,7 +287,7 @@ public class TraitClass extends Trait implements TraitWithSlot { ignoredInstanceVariableNames.add("__lastFrameAcc"); ignoredInstanceVariableNames.add("__lastFrameTab"); } - + //instance variables instanceInfo.instance_traits.toString(swfVersion, packageName, first, abcIndex, new Class[]{TraitSlotConst.class}, this, convertData, path + "/" + instanceInfoName, abc, false, exportMode, false, scriptIndex, class_info, writer, fullyQualifiedNames, parallel, ignoredInstanceVariableNames, isInterface); @@ -297,7 +297,7 @@ public class TraitClass extends Trait implements TraitWithSlot { Multiname m = abc.constants.getMultiname(instanceInfo.name_index); if (!first.getVal()) { - writer.newLine(); + writer.newLine(); } first.setVal(false); writer.startTrait(GraphTextWriter.TRAIT_INSTANCE_INITIALIZER); @@ -328,18 +328,18 @@ public class TraitClass extends Trait implements TraitWithSlot { List ignoredInstanceTraitNames = new ArrayList<>(); if (convertData.ignoreFrameScripts) { - ignoredInstanceTraitNames.addAll(frameTraitNames); + ignoredInstanceTraitNames.addAll(frameTraitNames); } - if (convertData.ignoreAccessibility) { + if (convertData.ignoreAccessibility) { for (Trait t : instanceInfo.instance_traits.traits) { - String traitName = t.getName(abc).getName(abc.constants, new ArrayList<>(), true, false); ; + String traitName = t.getName(abc).getName(abc.constants, new ArrayList<>(), true, false);; if (traitName.startsWith("__setAcc_") || traitName.startsWith("__setTab_")) { ignoredInstanceTraitNames.add(traitName); } - } + } } - + //instance methods instanceInfo.instance_traits.toString(swfVersion, packageName, first, abcIndex, new Class[]{TraitClass.class, TraitFunction.class, TraitMethodGetterSetter.class}, this, convertData, path + "/" + instanceInfoName, abc, false, exportMode, false, scriptIndex, class_info, writer, fullyQualifiedNames, parallel, ignoredInstanceTraitNames, isInterface); @@ -351,7 +351,7 @@ public class TraitClass extends Trait implements TraitWithSlot { writer.newLine(); return writer; } - + @Override public void convert(int swfVersion, AbcIndexing abcIndex, Trait parent, ConvertData convertData, String path, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, NulWriter writer, List fullyQualifiedNames, boolean parallel, ScopeStack scopeStack) throws InterruptedException { @@ -432,7 +432,7 @@ public class TraitClass extends Trait implements TraitWithSlot { if (ti instanceof CallPropertyAVM2Item) { CallPropertyAVM2Item callProp = (CallPropertyAVM2Item) ti; if (callProp.propertyName instanceof FullMultinameAVM2Item) { - FullMultinameAVM2Item propName = (FullMultinameAVM2Item) callProp.propertyName; + FullMultinameAVM2Item propName = (FullMultinameAVM2Item) callProp.propertyName; if ("addFrameScript".equals(propName.resolvedMultinameName)) { for (int i = 0; i < callProp.arguments.size(); i += 2) { if (callProp.arguments.get(i) instanceof IntegerValueAVM2Item) { @@ -453,14 +453,10 @@ public class TraitClass extends Trait implements TraitWithSlot { } constructorBody.convertedItems.remove(j); j--; - } else if ( - propName.resolvedMultinameName != null - && ( - propName.resolvedMultinameName.startsWith("__setAcc_") - || propName.resolvedMultinameName.startsWith("__setTab_") - ) - && callProp.arguments.isEmpty() - ) { + } else if (propName.resolvedMultinameName != null + && (propName.resolvedMultinameName.startsWith("__setAcc_") + || propName.resolvedMultinameName.startsWith("__setTab_")) + && callProp.arguments.isEmpty()) { //accessibilityTraitNames.add(propName.resolvedMultinameName); constructorBody.convertedItems.remove(j); j--; @@ -470,14 +466,14 @@ public class TraitClass extends Trait implements TraitWithSlot { } } } - + if (convertData.ignoreAccessibility) { if (constructorBody.convertedItems != null) { for (int j = 0; j < constructorBody.convertedItems.size(); j++) { GraphTargetItem ti = constructorBody.convertedItems.get(j); if (ti instanceof CallPropertyAVM2Item) { CallPropertyAVM2Item callProp = (CallPropertyAVM2Item) ti; - + if (callProp.propertyName instanceof FullMultinameAVM2Item) { FullMultinameAVM2Item propName = (FullMultinameAVM2Item) callProp.propertyName; if ("addEventListener".equals(propName.resolvedMultinameName)) { @@ -505,21 +501,17 @@ public class TraitClass extends Trait implements TraitWithSlot { } fm = (FullMultinameAVM2Item) gp.propertyName; if (!("__setAcc_handler".equals(fm.resolvedMultinameName) - || "__setTab_handler".equals(fm.resolvedMultinameName))) { + || "__setTab_handler".equals(fm.resolvedMultinameName))) { continue; } constructorBody.convertedItems.remove(j); j--; } - - if ( - propName.resolvedMultinameName != null - && ( - propName.resolvedMultinameName.startsWith("__setAcc_") - || propName.resolvedMultinameName.startsWith("__setTab_") - ) - && callProp.arguments.isEmpty() - ) { + + if (propName.resolvedMultinameName != null + && (propName.resolvedMultinameName.startsWith("__setAcc_") + || propName.resolvedMultinameName.startsWith("__setTab_")) + && callProp.arguments.isEmpty()) { //accessibilityTraitNames.add(propName.resolvedMultinameName); constructorBody.convertedItems.remove(j); j--; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/Traits.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/Traits.java index 24eb223f8..8a41d27f6 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/Traits.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/Traits.java @@ -313,9 +313,9 @@ public class Traits implements Cloneable, Serializable { * @return Writer * @throws InterruptedException On interrupt */ - public GraphTextWriter toString(int swfVersion, DottedChain packageName, Reference first, AbcIndexing abcIndex, Class[] traitTypes, Trait parent, ConvertData convertData, String path, ABC abc, boolean isStatic, ScriptExportMode exportMode, boolean makePackages, int scriptIndex, int classIndex, GraphTextWriter writer, List fullyQualifiedNames, boolean parallel, List ignoredTraitNames, boolean insideInterface) throws InterruptedException { + public GraphTextWriter toString(int swfVersion, DottedChain packageName, Reference first, AbcIndexing abcIndex, Class[] traitTypes, Trait parent, ConvertData convertData, String path, ABC abc, boolean isStatic, ScriptExportMode exportMode, boolean makePackages, int scriptIndex, int classIndex, GraphTextWriter writer, List fullyQualifiedNames, boolean parallel, List ignoredTraitNames, boolean insideInterface) throws InterruptedException { List ordered = traits; - + for (Trait trait : ordered) { int t = traits.indexOf(trait); if (traitTypes != null) { @@ -336,23 +336,23 @@ public class Traits implements Cloneable, Serializable { if (ignoredTraitNames.contains(trait.getName(abc).getName(abc.constants, new ArrayList<>(), false, false))) { continue; } - + if ((trait instanceof TraitSlotConst) && convertData.assignedValues.containsKey((TraitSlotConst) trait) && isStatic) { continue; } - + if (!first.getVal()) { - writer.newLine(); + writer.newLine(); } first.setVal(false); - int h = abc.getGlobalTraitId(TraitType.METHOD , isStatic, classIndex, t); + int h = abc.getGlobalTraitId(TraitType.METHOD, isStatic, classIndex, t); writer.startTrait(h); if (makePackages) { trait.toStringPackaged(swfVersion, abcIndex, parent, convertData, path, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel, insideInterface); } else { trait.toString(swfVersion, abcIndex, packageName, parent, convertData, path, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel, insideInterface); } - writer.endTrait(); + writer.endTrait(); } return writer; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/multinames/MethodMultinameUsage.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/multinames/MethodMultinameUsage.java index 3992d24c5..0aa2ec993 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/multinames/MethodMultinameUsage.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/multinames/MethodMultinameUsage.java @@ -38,6 +38,7 @@ public abstract class MethodMultinameUsage extends TraitMultinameUsage { /** * Constructor. + * * @param abc ABC * @param multinameIndex Multiname index * @param scriptIndex Script index @@ -55,6 +56,7 @@ public abstract class MethodMultinameUsage extends TraitMultinameUsage { /** * Is initializer. + * * @return Is initializer */ public boolean isInitializer() { @@ -102,7 +104,7 @@ public abstract class MethodMultinameUsage extends TraitMultinameUsage { if (traitsType == TRAITS_TYPE_CLASS) { ((TraitMethodGetterSetter) abc.class_info.get(classIndex).static_traits.traits.get(parentTraitIndex)).toStringHeader(-1, null, DottedChain.EMPTY /*??*/, convertData, "", abc, traitsType == TRAITS_TYPE_CLASS, ScriptExportMode.AS, -1/*FIXME*/, classIndex, writer, new ArrayList<>(), false, insideInterface); } else { - ((TraitMethodGetterSetter) abc.instance_info.get(classIndex).instance_traits.traits.get(parentTraitIndex)).toStringHeader(-1, null, DottedChain.EMPTY /*??*/,convertData, "", abc, traitsType == TRAITS_TYPE_CLASS, ScriptExportMode.AS, -1/*FIXME*/, classIndex, writer, new ArrayList<>(), false, insideInterface); + ((TraitMethodGetterSetter) abc.instance_info.get(classIndex).instance_traits.traits.get(parentTraitIndex)).toStringHeader(-1, null, DottedChain.EMPTY /*??*/, convertData, "", abc, traitsType == TRAITS_TYPE_CLASS, ScriptExportMode.AS, -1/*FIXME*/, classIndex, writer, new ArrayList<>(), false, insideInterface); } writer.appendNoHilight(" "); } @@ -142,6 +144,7 @@ public abstract class MethodMultinameUsage extends TraitMultinameUsage { /** * Is static. + * * @return Is static */ public boolean isStatic() { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/simple/ABCWalker.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/simple/ABCWalker.java index 2f5f34b30..fb6cfe406 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/simple/ABCWalker.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/simple/ABCWalker.java @@ -65,8 +65,10 @@ public abstract class ABCWalker { */ public ABCWalker() { } + /** * Walks ABC + * * @param abc ABC * @param walkOrphanItems Walk orphan items */ @@ -99,6 +101,7 @@ public abstract class ABCWalker { /** * Optional handle class + * * @param handledClasses Handled classes * @param handledMethodBodies Handled method bodies * @param handledMethodInfos Handled method infos @@ -126,6 +129,7 @@ public abstract class ABCWalker { /** * Optional handle method info. + * * @param handledMethodBodies Handled method bodies * @param handledMethodInfos Handled method infos * @param abc ABC @@ -161,6 +165,7 @@ public abstract class ABCWalker { /** * Optional handle method body. + * * @param handledMethodBodies Handled method bodies * @param handledMethodInfos Handled method infos * @param abc ABC @@ -192,6 +197,7 @@ public abstract class ABCWalker { /** * Walk traits. + * * @param abc ABC * @param traits Traits * @param scriptIndex Script index @@ -250,6 +256,7 @@ public abstract class ABCWalker { /** * Handle method info. + * * @param abc ABC * @param index Index * @param scriptIndex Script index @@ -266,6 +273,7 @@ public abstract class ABCWalker { /** * Handle method body. + * * @param abc ABC * @param index Index * @param scriptIndex Script index @@ -280,6 +288,7 @@ public abstract class ABCWalker { /** * Handle class. + * * @param abc ABC * @param index Index * @param scriptIndex Script index @@ -292,6 +301,7 @@ public abstract class ABCWalker { /** * Handle script. + * * @param abc ABC * @param index Index */ @@ -301,6 +311,7 @@ public abstract class ABCWalker { /** * Handle trait slot const. + * * @param abc ABC * @param trait Trait * @param scriptIndex Script index @@ -318,6 +329,7 @@ public abstract class ABCWalker { /** * Handle trait method getter setter. + * * @param abc ABC * @param trait Trait * @param scriptIndex Script index @@ -332,6 +344,7 @@ public abstract class ABCWalker { /** * Handle trait function. + * * @param abc ABC * @param trait Trait * @param scriptIndex Script index @@ -346,6 +359,7 @@ public abstract class ABCWalker { /** * Handle trait class. + * * @param abc ABC * @param trait Trait * @param scriptIndex Script index @@ -357,6 +371,7 @@ public abstract class ABCWalker { /** * Handle metadata info. + * * @param abc ABC * @param index Index * @param trait Trait diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/Action.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/Action.java index 8fbda4eae..4685404a8 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/Action.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/Action.java @@ -728,50 +728,49 @@ public abstract class Action implements GraphSourceItem { } } else { //if (!(a instanceof ActionNop)) { - String add = ""; + String add = ""; //Flash player 4 does not allow more than 1 item in ActionPush, so I commented this out /*if ((a instanceof ActionPush) && lastPush) { writer.appendNoHilight(", "); ((ActionPush) a).paramsToStringReplaced(list, importantOffsets, exportMode, writer); } else - */ - { - if (lastPush) { - writer.newLine(); - //lastPush = false; - } + { */ + if (lastPush) { + writer.newLine(); + //lastPush = false; + } - writer.append("", offset, a.getFileOffset()); + writer.append("", offset, a.getFileOffset()); - int fixBranch = -1; - if (a instanceof ActionIf) { - ActionIf aif = (ActionIf) a; - if (aif.jumpUsed && !aif.ignoreUsed) { - fixBranch = 0; - } - if (!aif.jumpUsed && aif.ignoreUsed) { - fixBranch = 1; - } + int fixBranch = -1; + if (a instanceof ActionIf) { + ActionIf aif = (ActionIf) a; + if (aif.jumpUsed && !aif.ignoreUsed) { + fixBranch = 0; } - - if (fixBranch > -1) { - writer.appendNoHilight("FFDec_DeobfuscatePop"); - if (fixBranch == 0) { //jump - writer.newLine(); - writer.appendNoHilight("Jump loc"); - writer.appendNoHilight(Helper.formatAddress(((ActionIf) a).getTargetAddress())); - } else { - //nojump, ignore - } - } else { - a.getASMSourceReplaced(list, importantOffsets, exportMode, writer); - } - writer.appendNoHilight(a.isIgnored() ? "; ignored" : ""); - writer.appendNoHilight(add); - if (!(a instanceof ActionPush)) { - writer.newLine(); + if (!aif.jumpUsed && aif.ignoreUsed) { + fixBranch = 1; } } + + if (fixBranch > -1) { + writer.appendNoHilight("FFDec_DeobfuscatePop"); + if (fixBranch == 0) { //jump + writer.newLine(); + writer.appendNoHilight("Jump loc"); + writer.appendNoHilight(Helper.formatAddress(((ActionIf) a).getTargetAddress())); + } else { + //nojump, ignore + } + } else { + a.getASMSourceReplaced(list, importantOffsets, exportMode, writer); + } + writer.appendNoHilight(a.isIgnored() ? "; ignored" : ""); + writer.appendNoHilight(add); + if (!(a instanceof ActionPush)) { + writer.newLine(); + } + //} lastPush = a instanceof ActionPush; //} } @@ -985,8 +984,7 @@ public abstract class Action implements GraphSourceItem { public List call() throws Exception { int staticOperation = 0; boolean insideDoInitAction = (asm instanceof DoInitActionTag); - List - tree = actionsToTree(uninitializedClassTraits, insideDoInitAction, false, new HashMap<>(), new HashMap<>(), new HashMap<>(), actions, version, staticOperation, path, charset); + List tree = actionsToTree(uninitializedClassTraits, insideDoInitAction, false, new HashMap<>(), new HashMap<>(), new HashMap<>(), actions, version, staticOperation, path, charset); SWFDecompilerPlugin.fireActionTreeCreated(tree, swf); for (ActionTreeOperation treeOperation : treeOperations) { treeOperation.run(tree); @@ -1055,6 +1053,7 @@ public abstract class Action implements GraphSourceItem { /** * Converts list of actions to List of treeItems. + * * @param uninitializedClassTraits Uninitialized class traits * @param insideDoInitAction Inside DoInitAction? * @param insideFunction Inside function? @@ -1237,7 +1236,7 @@ public abstract class Action implements GraphSourceItem { loopip: while (ip <= end) { - long addr = ip2adr(actions, ip); + long addr = ip2adr(actions, ip); if (ip > end) { break; } @@ -1248,7 +1247,7 @@ public abstract class Action implements GraphSourceItem { if (Configuration.simplifyExpressions.get()) { stack.simplify(); } - Action action = actions.get(ip); + Action action = actions.get(ip); if (action.isIgnored()) { ip++; continue; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/fastactionlist/FastActionList.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/fastactionlist/FastActionList.java index 523531c4d..918bf7ccb 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/fastactionlist/FastActionList.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/fastactionlist/FastActionList.java @@ -705,7 +705,7 @@ public class FastActionList implements Collection { } modified = false; ActionItem item = firstItem2; - do { + do { ActionItem next = item.next; //ActionItem alternativeNext = null; Action action = item.action; @@ -880,7 +880,7 @@ public class FastActionList implements Collection { /** * Converts the list to an array. * - * @param the array into which the elements of this collection are to be + * @param a the array into which the elements of this collection are to be * stored, if it is big enough; otherwise, a new array of the same runtime * type is allocated for this purpose. * @param Type diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/FSCommand2ActionItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/FSCommand2ActionItem.java index c977629aa..b878b6655 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/FSCommand2ActionItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/FSCommand2ActionItem.java @@ -54,7 +54,6 @@ public class FSCommand2ActionItem extends ActionItem { * * @param instruction Instruction * @param lineStartIns Line start instruction - * @param command Command * @param arguments Arguments */ public FSCommand2ActionItem(GraphSourceItem instruction, GraphSourceItem lineStartIns, List arguments) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/FSCommandActionItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/FSCommandActionItem.java index 153513488..b603c108e 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/FSCommandActionItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/FSCommandActionItem.java @@ -17,7 +17,6 @@ package com.jpexs.decompiler.flash.action.model; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; -import com.jpexs.decompiler.flash.action.model.operations.AddActionItem; import com.jpexs.decompiler.flash.action.model.operations.StringAddActionItem; import com.jpexs.decompiler.flash.action.parser.script.ActionSourceGenerator; import com.jpexs.decompiler.flash.action.swf3.ActionGetURL; @@ -49,6 +48,7 @@ public class FSCommandActionItem extends ActionItem { * Parameter */ private final GraphTargetItem parameter; + /** * Constructor. * @@ -89,10 +89,12 @@ public class FSCommandActionItem extends ActionItem { private List toSource(SourceGeneratorLocalData localData, SourceGenerator generator, boolean needsReturn) throws CompilationException { ActionSourceGenerator asGenerator = (ActionSourceGenerator) generator; String charset = asGenerator.getCharset(); - if ((command instanceof DirectValueActionItem) + if ((command instanceof DirectValueActionItem) && ((DirectValueActionItem) command).isString() - && (parameter == null || - ((parameter instanceof DirectValueActionItem) && ((DirectValueActionItem) parameter).isString()))) { + && ( + parameter == null + || ((parameter instanceof DirectValueActionItem) && ((DirectValueActionItem) parameter).isString()) + )) { return toSourceMerge(localData, generator, new ActionGetURL("FSCommand:" + ((DirectValueActionItem) command).getAsString(), parameter == null ? "" : ((DirectValueActionItem) parameter).getAsString(), charset)); } return toSourceMerge(localData, generator, new StringAddActionItem(null, null, asGenerator.pushConstTargetItem("FSCommand:"), command), parameter == null ? asGenerator.pushConstTargetItem("") : parameter, new ActionGetURL2(1/*GET*/, false, false, charset), needsReturn ? new ActionPush(new Object[]{Undefined.INSTANCE, Undefined.INSTANCE}, charset) : null); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/parser/script/ActionScript2Parser.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/parser/script/ActionScript2Parser.java index b7c95fe10..12400209e 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/parser/script/ActionScript2Parser.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/parser/script/ActionScript2Parser.java @@ -126,7 +126,6 @@ import com.jpexs.decompiler.flash.action.model.operations.StringNeActionItem; import com.jpexs.decompiler.flash.action.model.operations.SubtractActionItem; import com.jpexs.decompiler.flash.action.model.operations.URShiftActionItem; import com.jpexs.decompiler.flash.action.parser.ActionParseException; -import static com.jpexs.decompiler.flash.action.parser.script.SymbolType.FSCOMMAND; import com.jpexs.decompiler.flash.action.swf4.ActionIf; import com.jpexs.decompiler.flash.action.swf4.ActionPush; import com.jpexs.decompiler.flash.action.swf4.ConstantIndex; @@ -253,6 +252,7 @@ public class ActionScript2Parser { /** * Constructor + * * @param swf Swf * @param targetSource Target source */ @@ -269,6 +269,7 @@ public class ActionScript2Parser { /** * Parse SWF classes + * * @param swf SWF */ private void parseSwfClasses(SWF swf) { @@ -598,7 +599,7 @@ public class ActionScript2Parser { s = lex(); GraphTargetItem parameter = null; if (s.isType(SymbolType.COMMA)) { - parameter = expression(inFunction, inMethod, inTellTarget, true, variables, functions, false, hasEval); + parameter = expression(inFunction, inMethod, inTellTarget, true, variables, functions, false, hasEval); } else { lexer.pushback(s); } @@ -1408,7 +1409,7 @@ public class ActionScript2Parser { } return new EmptyCommand(); case DIRECTIVE: - switch((String)s.value) { + switch ((String) s.value) { case "strict": ret = new StrictModeActionItem(null, null, 1); break; @@ -2147,12 +2148,12 @@ public class ActionScript2Parser { } private DirectValueActionItem pushConst(String s) throws IOException, ActionParseException { - + //ActionConstantPool was introduced in SWF 5 if (swfVersion < 5) { return new DirectValueActionItem(null, null, 0, s, constantPool); } - + int index = constantPool.indexOf(s); if (index == -1) { if (ActionConstantPool.calculateSize(constantPool) + ActionConstantPool.calculateSize(s) <= 0xffff) { @@ -2175,6 +2176,7 @@ public class ActionScript2Parser { /** * Convert a string to a high-level model. + * * @param str The string to convert * @param constantPool The constant pool to use * @return The high-level model @@ -2481,6 +2483,7 @@ public class ActionScript2Parser { /** * Converts a string to a list of actions. + * * @param s The string to convert * @param charset Charset * @return List of actions diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/parser/script/ActionSourceGenerator.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/parser/script/ActionSourceGenerator.java index d5bb3425c..222563b84 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/parser/script/ActionSourceGenerator.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/parser/script/ActionSourceGenerator.java @@ -94,6 +94,7 @@ public class ActionSourceGenerator implements SourceGenerator { /** * Constructor. + * * @param swfVersion SWF version * @param constantPool Constant pool * @param charset Charset @@ -106,6 +107,7 @@ public class ActionSourceGenerator implements SourceGenerator { /** * Generates unique ID. + * * @return Unique ID */ public String uniqId() { @@ -115,6 +117,7 @@ public class ActionSourceGenerator implements SourceGenerator { /** * Gets charset. + * * @return Charset */ public String getCharset() { @@ -131,22 +134,23 @@ public class ActionSourceGenerator implements SourceGenerator { /** * Converts list of GraphSourceItem to list of Action. + * * @param items List of GraphSourceItem * @return List of Action */ public List toActionList(List items) { items = groupPushes(items); List ret = new ArrayList<>(); - for (GraphSourceItem s : items) { + for (GraphSourceItem s : items) { if (s instanceof Action) { - ret.add((Action) s); + ret.add((Action) s); } - } + } return ret; } - + private List groupPushes(List items) { - + //TODO: This should take in account important offsets (jumps) //And not group Pushes over different parts of code /*Like: @@ -157,9 +161,7 @@ public class ActionSourceGenerator implements SourceGenerator { Push "C" Should not be grouped to Push "A","B","C" - */ - - + */ return items; //Commented out for now... /*if (swfVersion <= 4) { @@ -223,10 +225,9 @@ public class ActionSourceGenerator implements SourceGenerator { ifaif.setJumpOffset(onTrueLen); ActionJump ajmp = null; if (onFalse != null) { - if (onTrueCmds.isEmpty() || - !((onTrueCmds.get(onTrueCmds.size() - 1) instanceof ContinueItem) - || (onTrueCmds.get(onTrueCmds.size() - 1) instanceof BreakItem)) - ) { + if (onTrueCmds.isEmpty() + || !((onTrueCmds.get(onTrueCmds.size() - 1) instanceof ContinueItem) + || (onTrueCmds.get(onTrueCmds.size() - 1) instanceof BreakItem))) { ajmp = new ActionJump(0, charset); ret.add(ajmp); onTrueLen += ajmp.getTotalActionLength(); @@ -266,6 +267,7 @@ public class ActionSourceGenerator implements SourceGenerator { /** * Gets register variables. + * * @param localData Local data * @return Register variables */ @@ -275,6 +277,7 @@ public class ActionSourceGenerator implements SourceGenerator { /** * Sets register variables. + * * @param localData Local data * @param value Register variables */ @@ -284,6 +287,7 @@ public class ActionSourceGenerator implements SourceGenerator { /** * Sets in function. + * * @param localData Local data * @param value Value */ @@ -293,6 +297,7 @@ public class ActionSourceGenerator implements SourceGenerator { /** * Gets in function. + * * @param localData Local data * @return Value */ @@ -302,6 +307,7 @@ public class ActionSourceGenerator implements SourceGenerator { /** * Checks if in method. + * * @param localData Local data * @return True if in method */ @@ -311,6 +317,7 @@ public class ActionSourceGenerator implements SourceGenerator { /** * Sets in method. + * * @param localData Local data * @param value Value */ @@ -320,6 +327,7 @@ public class ActionSourceGenerator implements SourceGenerator { /** * Gets for in level. + * * @param localData Local data * @return For in level */ @@ -329,6 +337,7 @@ public class ActionSourceGenerator implements SourceGenerator { /** * Sets for in level. + * * @param localData Local data * @param value Value */ @@ -338,6 +347,7 @@ public class ActionSourceGenerator implements SourceGenerator { /** * Gets temp register. + * * @param localData Local data * @return Temp register */ @@ -354,6 +364,7 @@ public class ActionSourceGenerator implements SourceGenerator { /** * Releases temp register. + * * @param localData Local data * @param tmp Temp register */ @@ -467,6 +478,7 @@ public class ActionSourceGenerator implements SourceGenerator { /** * Gets SWF version. + * * @return SWF version */ public int getSwfVersion() { @@ -475,6 +487,7 @@ public class ActionSourceGenerator implements SourceGenerator { /** * Gets constant pool. + * * @return Constant pool */ public List getConstantPool() { @@ -483,6 +496,7 @@ public class ActionSourceGenerator implements SourceGenerator { /** * Gets Push constant item. + * * @param s Constant * @return Push constant item */ @@ -497,6 +511,7 @@ public class ActionSourceGenerator implements SourceGenerator { /** * Gets Push constant action. + * * @param s Constant * @return Push constant action */ @@ -518,6 +533,7 @@ public class ActionSourceGenerator implements SourceGenerator { /** * Generates traits. + * * @param localData Local data * @param isInterface Is interface * @param name Name @@ -1028,7 +1044,7 @@ public class ActionSourceGenerator implements SourceGenerator { for (GraphTargetItem item : commands) { ret.addAll(item.toSourceIgnoreReturnValue(localData, this)); } - ret = groupPushes(ret); + ret = groupPushes(ret); return ret; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionGetURL2.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionGetURL2.java index 6ebee4f2b..6b04f9081 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionGetURL2.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionGetURL2.java @@ -93,6 +93,7 @@ public class ActionGetURL2 extends Action { /** * Constructor + * * @param sendVarsMethod Send variables method * @param loadVariablesFlag Load variables flag * @param loadTargetFlag Load target flag @@ -107,6 +108,7 @@ public class ActionGetURL2 extends Action { /** * Constructor + * * @param actionLength Action length * @param sis SWF input stream * @param charset Charset @@ -145,6 +147,7 @@ public class ActionGetURL2 extends Action { /** * Constructor + * * @param lexer Lexer * @param charset Charset * @throws IOException On I/O error @@ -219,10 +222,7 @@ public class ActionGetURL2 extends Action { } } } - - - - + if (loadVariablesFlag) { if (num != null) { output.add(new LoadVariablesNumActionItem(this, lineStartAction, urlString, num, sendVarsMethod)); @@ -244,7 +244,7 @@ public class ActionGetURL2 extends Action { boolean doPrintAsBitmap = false; boolean doFSCommand = false; boolean doUnload = false; - + if (urlString.isCompileTime() && (urlString.getResult() instanceof String)) { String urlStr = (String) urlString.getResult(); if ("".equals(urlStr)) { @@ -260,30 +260,30 @@ public class ActionGetURL2 extends Action { doFSCommand = true; } } else if (urlString instanceof StringAddActionItem) { - StringAddActionItem sa = (StringAddActionItem) urlString; - if (sa.leftSide.isCompileTime()) { - Object res = sa.leftSide.getResult(); - if (res instanceof String) { - String urlStr = (String) res; - switch (urlStr) { - case printPrefix: - printType = sa.rightSide; - doPrint = true; - urlString = null; - break; - case printAsBitmapPrefix: - printType = sa.rightSide; - doPrintAsBitmap = true; - urlString = null; - break; - case fscommandPrefix: - urlString = sa.rightSide; - doFSCommand = true; - break; - } + StringAddActionItem sa = (StringAddActionItem) urlString; + if (sa.leftSide.isCompileTime()) { + Object res = sa.leftSide.getResult(); + if (res instanceof String) { + String urlStr = (String) res; + switch (urlStr) { + case printPrefix: + printType = sa.rightSide; + doPrint = true; + urlString = null; + break; + case printAsBitmapPrefix: + printType = sa.rightSide; + doPrintAsBitmap = true; + urlString = null; + break; + case fscommandPrefix: + urlString = sa.rightSide; + doFSCommand = true; + break; } } } + } if (num != null) { if (doUnload) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/amf/amf0/Amf0InputStream.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/amf/amf0/Amf0InputStream.java index 156ebb097..8d928546d 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/amf/amf0/Amf0InputStream.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/amf/amf0/Amf0InputStream.java @@ -279,6 +279,7 @@ public class Amf0InputStream extends InputStream { /** * Reads UTF-8 value + * * @param name Name * @return UTF-8 value * @throws IOException On I/O error @@ -294,6 +295,7 @@ public class Amf0InputStream extends InputStream { /** * Reads UTF-8-long value + * * @param name Name * @return UTF-8-long value * @throws IOException On I/O error @@ -314,13 +316,15 @@ public class Amf0InputStream extends InputStream { populateComplexObjects(value, complexObjects); return resolveReferences(value, complexObjects); } - + /** * Reads AMF0 value + * * @param name Name * @return AMF0 value * @throws IOException On I/O error - * @throws NoSerializerExistsException When reading is switched to AMF3 and no serializer found for an object + * @throws NoSerializerExistsException When reading is switched to AMF3 and + * no serializer found for an object */ public Object readValue(String name) throws IOException, NoSerializerExistsException { newDumpLevel(name, "value-type"); @@ -328,7 +332,7 @@ public class Amf0InputStream extends InputStream { int marker = readInternal(); //System.err.println("marker " + Integer.toHexString(marker)); switch (marker) { - case Marker.NUMBER: + case Marker.NUMBER: result = readDouble("DOUBLE"); break; case Marker.BOOLEAN: @@ -352,7 +356,7 @@ public class Amf0InputStream extends InputStream { break; } object.properties.put(propName, val); - } + } result = object; break; case Marker.MOVIECLIP: @@ -370,7 +374,7 @@ public class Amf0InputStream extends InputStream { int associativeCount = (int) readU32("associative-count"); EcmaArrayType ea = new EcmaArrayType(); for (int a = 0; a < associativeCount; a++) { - String eaKey = readUtf8("key"); + String eaKey = readUtf8("key"); Object eaVal = readValue("value"); ea.denseValues.put(eaKey, eaVal); } @@ -413,7 +417,7 @@ public class Amf0InputStream extends InputStream { typedObject.className = className; while (true) { - propName = readUtf8("propertyName"); + propName = readUtf8("propertyName"); val = readValue("propertyValue"); if (propName.equals("")) { break; @@ -424,28 +428,28 @@ public class Amf0InputStream extends InputStream { break; case Marker.AVMPLUS_OBJECT: Amf3InputStream amf3 = new Amf3InputStream(is); - result = amf3.readValue("avm-plus-object"); + result = amf3.readValue("avm-plus-object"); break; default: throw new IllegalArgumentException("Unsupported type"); } - + /*if (result != null) { System.err.println("Read: " + Amf0Exporter.amfToString(result, 0, "\r\n", new ArrayList<>(), new HashMap<>(), new HashMap<>())); }*/ endDumpLevel(); return result; } - - public void resolveMapReferences(Map map) { + + public void resolveMapReferences(Map map) { List complexObjects = new ArrayList<>(); - populateComplexObjects((List)new ArrayList<>(map.values()), complexObjects); - + populateComplexObjects((List) new ArrayList<>(map.values()), complexObjects); + for (String key : map.keySet()) { - map.put(key, resolveReferences(map.get(key), complexObjects)); - } + map.put(key, resolveReferences(map.get(key), complexObjects)); + } } - + public Object resolveReferences(Object value, List complexObjects) { if (value instanceof ReferenceType) { ReferenceType rt = (ReferenceType) value; @@ -454,19 +458,19 @@ public class Amf0InputStream extends InputStream { if (value instanceof ObjectType) { ObjectType ot = (ObjectType) value; for (String key : ot.properties.keySet()) { - ot.properties.put(key, resolveReferences(ot.properties.get(key), complexObjects)); + ot.properties.put(key, resolveReferences(ot.properties.get(key), complexObjects)); } } if (value instanceof TypedObjectType) { TypedObjectType tot = (TypedObjectType) value; for (String key : tot.properties.keySet()) { - tot.properties.put(key, resolveReferences(tot.properties.get(key), complexObjects)); + tot.properties.put(key, resolveReferences(tot.properties.get(key), complexObjects)); } } if (value instanceof EcmaArrayType) { EcmaArrayType eat = (EcmaArrayType) value; for (String key : eat.denseValues.keySet()) { - eat.denseValues.put(key, resolveReferences(eat.denseValues.get(key), complexObjects)); + eat.denseValues.put(key, resolveReferences(eat.denseValues.get(key), complexObjects)); } for (String key : eat.associativeValues.keySet()) { eat.associativeValues.put(key, resolveReferences(eat.associativeValues.get(key), complexObjects)); @@ -480,13 +484,13 @@ public class Amf0InputStream extends InputStream { } return value; } - + public void populateComplexObjects(List values, List result) { for (Object value : values) { populateComplexObjects(value, result); } } - + public void populateComplexObjects(Object value, List result) { if (result.contains(value)) { return; @@ -502,5 +506,5 @@ public class Amf0InputStream extends InputStream { @Override public long skip(long n) throws IOException { return is.skip(n); - } + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/amf/amf0/Amf0OutputStream.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/amf/amf0/Amf0OutputStream.java index bdc3d0e6a..45d12a8d7 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/amf/amf0/Amf0OutputStream.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/amf/amf0/Amf0OutputStream.java @@ -35,17 +35,19 @@ import java.util.List; public class Amf0OutputStream extends OutputStream { private final OutputStream os; + /** * Constructor. * * @param os Output stream */ public Amf0OutputStream(OutputStream os) { - this.os = os; + this.os = os; } - + /** * Writes U8 (unsigned 8-bit integer). + * * @param v Value * @throws IOException On I/O error */ @@ -55,6 +57,7 @@ public class Amf0OutputStream extends OutputStream { /** * Writes U16 (unsigned 16-bit integer). + * * @param v Value * @throws IOException On I/O error */ @@ -64,9 +67,10 @@ public class Amf0OutputStream extends OutputStream { write(b1); write(b2); } - + /** * Writes S16 (signed 16-bit integer). + * * @param v Value * @throws IOException On I/O error */ @@ -76,9 +80,10 @@ public class Amf0OutputStream extends OutputStream { write(b1); write(b2); } - + /** * Writes U32 (unsigned 32-bit integer). + * * @param v Value * @throws IOException On I/O error */ @@ -96,15 +101,17 @@ public class Amf0OutputStream extends OutputStream { /** * Writes double. + * * @param v Value * @throws IOException On I/O error */ public void writeDouble(double v) throws IOException { writeLong(Double.doubleToLongBits(v)); } - + /** * Writes long. + * * @param value Value * @throws IOException On I/O error */ @@ -123,13 +130,14 @@ public class Amf0OutputStream extends OutputStream { /** * Writes bytes. + * * @param data Data * @throws IOException On I/O error */ public void writeBytes(byte[] data) throws IOException { os.write(data); } - + @Override public void write(int v) throws IOException { os.write(v); @@ -144,41 +152,41 @@ public class Amf0OutputStream extends OutputStream { public void write(byte[] b, int off, int len) throws IOException { os.write(b, off, len); } - + public void writeUtf8(String value) throws IOException { byte[] data = value.getBytes("UTF-8"); writeU16(data.length); - writeBytes(data); + writeBytes(data); } - + public void writeUtf8Long(String value) throws IOException { byte[] data = value.getBytes("UTF-8"); writeU32(data.length); - writeBytes(data); + writeBytes(data); } - + public void writeObjectProperty(String name, Object value, List complexObjectsList) throws IOException { writeUtf8(name); writeValue(value, complexObjectsList); } - + public void writeUtf8Empty() throws IOException { writeU16(0); } - + public void writeValue(Object value, List complexObjectsList) throws IOException { - + if (value instanceof ComplexObject) { int index = complexObjectsList.indexOf(value); if (index != -1 && index <= 65535) { write(Marker.REFERENCE); - writeU16(index); + writeU16(index); return; } else { complexObjectsList.add(value); } } - + if (value instanceof Double) { write(Marker.NUMBER); writeDouble((Double) value); @@ -198,7 +206,7 @@ public class Amf0OutputStream extends OutputStream { write(Marker.OBJECT); ObjectType ot = (ObjectType) value; for (String key : ot.properties.keySet()) { - writeObjectProperty(key, ot.properties.get(key), complexObjectsList); + writeObjectProperty(key, ot.properties.get(key), complexObjectsList); } writeUtf8Empty(); write(Marker.OBJECT_END); @@ -211,7 +219,7 @@ public class Amf0OutputStream extends OutputStream { EcmaArrayType ea = (EcmaArrayType) value; writeU32(ea.denseValues.size()); for (String key : ea.denseValues.keySet()) { - writeObjectProperty(key, ea.denseValues.get(key), complexObjectsList); + writeObjectProperty(key, ea.denseValues.get(key), complexObjectsList); } for (String key : ea.associativeValues.keySet()) { writeObjectProperty(key, ea.associativeValues.get(key), complexObjectsList); @@ -239,14 +247,14 @@ public class Amf0OutputStream extends OutputStream { TypedObjectType tot = (TypedObjectType) value; writeUtf8(tot.className); for (String key : tot.properties.keySet()) { - writeObjectProperty(key, tot.properties.get(key), complexObjectsList); + writeObjectProperty(key, tot.properties.get(key), complexObjectsList); } writeUtf8Empty(); write(Marker.OBJECT_END); } else { throw new IllegalArgumentException("Unsupported value type for serialization"); } - + //TODO: Switching to AMF3 when necessary } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/amf/amf0/types/BasicType.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/amf/amf0/types/BasicType.java index db9c44d99..0eba44ac7 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/amf/amf0/types/BasicType.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/amf/amf0/types/BasicType.java @@ -16,7 +16,7 @@ */ package com.jpexs.decompiler.flash.amf.amf0.types; -import com.jpexs.decompiler.flash.amf.amf3.types.*; +import com.jpexs.decompiler.flash.amf.amf3.types.Amf3ValueType; /** * Basic AMF0 types. diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/amf/amf0/types/DateType.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/amf/amf0/types/DateType.java index 41e1c6967..467baf63a 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/amf/amf0/types/DateType.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/amf/amf0/types/DateType.java @@ -16,8 +16,7 @@ */ package com.jpexs.decompiler.flash.amf.amf0.types; -import com.jpexs.decompiler.flash.amf.amf3.types.*; -import com.jpexs.decompiler.flash.exporters.amf.amf3.Amf3Exporter; +import com.jpexs.decompiler.flash.amf.amf3.types.Amf3ValueType; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/amf/amf0/types/XmlDocumentType.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/amf/amf0/types/XmlDocumentType.java index afe73b235..711c21188 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/amf/amf0/types/XmlDocumentType.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/amf/amf0/types/XmlDocumentType.java @@ -16,7 +16,7 @@ */ package com.jpexs.decompiler.flash.amf.amf0.types; -import com.jpexs.decompiler.flash.amf.amf3.types.*; +import com.jpexs.decompiler.flash.amf.amf3.types.Amf3ValueType; import java.util.ArrayList; import java.util.List; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/amf/amf3/Amf3Value.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/amf/amf3/Amf3Value.java index 45097f67e..58b2d9cbd 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/amf/amf3/Amf3Value.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/amf/amf3/Amf3Value.java @@ -19,8 +19,8 @@ package com.jpexs.decompiler.flash.amf.amf3; import com.jpexs.decompiler.flash.amf.amf3.types.Amf3ValueType; import com.jpexs.decompiler.flash.amf.amf3.types.BasicType; import com.jpexs.decompiler.flash.exporters.amf.amf3.Amf3Exporter; -import com.jpexs.decompiler.flash.importers.amf.amf3.Amf3Importer; import com.jpexs.decompiler.flash.importers.amf.AmfParseException; +import com.jpexs.decompiler.flash.importers.amf.amf3.Amf3Importer; import com.jpexs.decompiler.flash.types.annotations.Multiline; import com.jpexs.decompiler.flash.types.annotations.SWFField; import java.io.IOException; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/amf/amf0/Amf0Exporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/amf/amf0/Amf0Exporter.java index 0c3adfae7..2a9c96b9e 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/amf/amf0/Amf0Exporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/amf/amf0/Amf0Exporter.java @@ -18,11 +18,14 @@ package com.jpexs.decompiler.flash.exporters.amf.amf0; import com.jpexs.decompiler.flash.amf.amf0.types.ArrayType; import com.jpexs.decompiler.flash.amf.amf0.types.BasicType; +import com.jpexs.decompiler.flash.amf.amf0.types.ComplexObject; import com.jpexs.decompiler.flash.amf.amf0.types.DateType; import com.jpexs.decompiler.flash.amf.amf0.types.EcmaArrayType; import com.jpexs.decompiler.flash.amf.amf0.types.ObjectType; +import com.jpexs.decompiler.flash.amf.amf0.types.ReferenceType; import com.jpexs.decompiler.flash.amf.amf0.types.TypedObjectType; import com.jpexs.decompiler.flash.amf.amf0.types.XmlDocumentType; +import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.helpers.Helper; import java.text.SimpleDateFormat; import java.util.ArrayList; @@ -30,9 +33,6 @@ import java.util.Arrays; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import com.jpexs.decompiler.flash.amf.amf0.types.ComplexObject; -import com.jpexs.decompiler.flash.amf.amf0.types.ReferenceType; -import com.jpexs.decompiler.flash.ecma.EcmaScript; /** * AMF0 exporter. @@ -43,23 +43,23 @@ public class Amf0Exporter { public static String amfMapToString( Map map, - int level, + int level, String newLine - ) { + ) { List processedObjects = new ArrayList<>(); Map referenceCount = new LinkedHashMap<>(); Map objectAlias = new LinkedHashMap<>(); - + List objectList = new ArrayList<>(); - for (String key: map.keySet()) { + for (String key : map.keySet()) { Object val = map.get(key); populateObjects(val, referenceCount, objectList, objectAlias); } - + StringBuilder sb = new StringBuilder(); sb.append("{").append(newLine); boolean first = true; - for (String key: map.keySet()) { + for (String key : map.keySet()) { if (!first) { sb.append(",").append(newLine); } @@ -71,7 +71,7 @@ public class Amf0Exporter { sb.append(indent(level)).append("}"); return sb.toString(); } - + private static String referenceToString(String objectAlias, int level, String newLine) { StringBuilder sb = new StringBuilder(); sb.append("{").append(newLine); @@ -80,15 +80,15 @@ public class Amf0Exporter { sb.append(indent(level)).append("}"); return sb.toString(); } - + public static String amfToString( Object value, - int level, + int level, String newLine, List processedObjects, Map referenceCount, Map objectAlias - ) { + ) { String addId = ""; if (referenceCount.containsKey(value)) { Integer refCount = referenceCount.get(value); @@ -100,12 +100,12 @@ public class Amf0Exporter { } processedObjects.add(value); } - + if (value instanceof ReferenceType) { ReferenceType rt = (ReferenceType) value; return referenceToString("obj" + rt.referenceIndex, level, newLine); } - + if (value == BasicType.UNDEFINED) { StringBuilder sb = new StringBuilder(); sb.append("{").append(newLine); @@ -113,7 +113,7 @@ public class Amf0Exporter { sb.append(indent(level)).append("}"); return sb.toString(); } - + if (value instanceof Double) { return EcmaScript.toString(value); } @@ -153,7 +153,7 @@ public class Amf0Exporter { StringBuilder sb = new StringBuilder(); sb.append("{").append(newLine); sb.append(indent(level + 1)).append("\"type\": \"Array\",").append(newLine); - sb.append(addId); + sb.append(addId); sb.append(indent(level + 1)).append("\"values\": [").append(newLine); boolean first = true; for (Object val : at.values) { @@ -174,7 +174,7 @@ public class Amf0Exporter { StringBuilder sb = new StringBuilder(); sb.append("{").append(newLine); sb.append(indent(level + 1)).append("\"type\": \"TypedObject\",").append(newLine); - sb.append(addId); + sb.append(addId); sb.append(indent(level + 1)).append("\"className\": \"").append(Helper.escapeActionScriptString(tot.className)).append("\",").append(newLine); membersToString("members", sb, tot.properties, level + 1, newLine, processedObjects, referenceCount, objectAlias); sb.append(newLine); @@ -194,7 +194,7 @@ public class Amf0Exporter { sb.append(indent(level + 1)).append("\"type\": \"Date\",").append(newLine); sb.append(addId); sb.append(indent(level + 1)).append("\"value\": \"").append(sdf.format(dt.toDate())).append("\",").append(newLine); - sb.append(indent(level + 1)).append("\"timezone\": ").append(dt.getTimezone()).append(newLine); + sb.append(indent(level + 1)).append("\"timezone\": ").append(dt.getTimezone()).append(newLine); sb.append(indent(level)).append("}"); return sb.toString(); } @@ -209,7 +209,7 @@ public class Amf0Exporter { sb.append(indent(level)).append("}"); return sb.toString(); } - + return "unknown"; } @@ -217,7 +217,7 @@ public class Amf0Exporter { String membersLabel, StringBuilder sb, Map members, - int level, + int level, String newLine, List processedObjects, Map referenceCount, @@ -244,7 +244,7 @@ public class Amf0Exporter { } return na; } - + /** * Populates all object instances and their references and generates aliases * @@ -268,12 +268,12 @@ public class Amf0Exporter { if (prevRef == 0) { if (object instanceof ComplexObject) { objectAlias.put(object, "obj" + objectList.size()); - objectList.add(object); + objectList.add(object); List subvalues = ((ComplexObject) object).getSubValues(); for (Object o : subvalues) { populateObjects(o, referenceCount, objectList, objectAlias); } - } + } } } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/amf/amf3/Amf3Exporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/amf/amf3/Amf3Exporter.java index c515af71a..bbbc41951 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/amf/amf3/Amf3Exporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/amf/amf3/Amf3Exporter.java @@ -41,7 +41,6 @@ import java.util.Map; */ public class Amf3Exporter { - /** * Constructor. */ @@ -116,30 +115,6 @@ public class Amf3Exporter { return amfToString(indentStr, newLine, new ArrayList<>(), 0, amfValue, refCount, objectAlias); } - public static String amfMapToString(Map map, String indentStr, String newLine, int level) { - Map refCount = new HashMap<>(); - List objectList = new ArrayList<>(); - Map objectAlias = new HashMap<>(); - for (Object val : map.values()) { - populateObjects(val, refCount, objectList, objectAlias); - } - List processedObjects = new ArrayList<>(); - StringBuilder sb = new StringBuilder(); - sb.append("{").append(newLine); - boolean first = true; - for (String key: map.keySet()) { - if (!first) { - sb.append(", ").append(newLine); - } - first = false; - sb.append(indent(level + 1)).append("\"").append(Helper.escapeActionScriptString(key)).append("\": "); - sb.append(amfToString(indentStr, newLine, processedObjects, level + 1, map.get(key), refCount, objectAlias)); - } - sb.append(newLine); - sb.append(indent(level)).append("}"); - return sb.toString(); - } - /** * Processes one level of object and converts it to string * @@ -157,7 +132,7 @@ public class Amf3Exporter { if (((List) Arrays.asList(Long.class, Double.class, Boolean.class)).contains(object.getClass())) { return EcmaScript.toString(object); } - + StringBuilder ret = new StringBuilder(); if (object == BasicType.UNDEFINED) { @@ -166,13 +141,11 @@ public class Amf3Exporter { ret.append(indent(level)).append("}"); return ret.toString(); } - + if (object instanceof BasicType) { return object.toString(); } - - Integer refCount = referenceCount.get(object); if (refCount > 1 && processedObjects.contains(object)) { ret.append("{").append(newLine); @@ -365,4 +338,28 @@ public class Amf3Exporter { return ret.toString(); } + + public static String amfMapToString(Map map, String indentStr, String newLine, int level) { + Map refCount = new HashMap<>(); + List objectList = new ArrayList<>(); + Map objectAlias = new HashMap<>(); + for (Object val : map.values()) { + populateObjects(val, refCount, objectList, objectAlias); + } + List processedObjects = new ArrayList<>(); + StringBuilder sb = new StringBuilder(); + sb.append("{").append(newLine); + boolean first = true; + for (String key : map.keySet()) { + if (!first) { + sb.append(", ").append(newLine); + } + first = false; + sb.append(indent(level + 1)).append("\"").append(Helper.escapeActionScriptString(key)).append("\": "); + sb.append(amfToString(indentStr, newLine, processedObjects, level + 1, map.get(key), refCount, objectAlias)); + } + sb.append(newLine); + sb.append(indent(level)).append("}"); + return sb.toString(); + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/swf/SwfFlashDevelopExporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/swf/SwfFlashDevelopExporter.java index b5d305865..a5efab033 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/swf/SwfFlashDevelopExporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/swf/SwfFlashDevelopExporter.java @@ -291,30 +291,30 @@ public class SwfFlashDevelopExporter { if (air) { String applicationXml = " \n" + "\n" - + " \n" - + " " + simpleNameNoSpaces + " \n" - + " 1.0 \n" - + " " + simpleNameNoSpaces + " \n" - + " \n" - + " " + simpleName + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " " + simpleName + " \n" - + " " + simpleNameNoSpaces + ".swf \n" - + " standard \n" - + " false \n" - + " true \n" - + " true \n" - + " true \n" - + " true \n" - + " \n" - + " \n" - + " \n" + + "\t\n" + + "\t" + simpleNameNoSpaces + " \n" + + "\t1.0 \n" + + "\t" + simpleNameNoSpaces + " \n" + + "\t\n" + + "\t" + simpleName + " \n" + + "\t \n" + + "\t \n" + + "\t\n" + + "\t \n" + + "\t\t" + simpleName + " \n" + + "\t\t" + simpleNameNoSpaces + ".swf \n" + + "\t\tstandard \n" + + "\t\tfalse \n" + + "\t\ttrue \n" + + "\t\ttrue \n" + + "\t\ttrue \n" + + "\t\ttrue \n" + + "\t \n" + + "\t\n" + + "\t\n" + ""; try (FileOutputStream fos = new FileOutputStream(outFile.toPath().getParent().resolve("application.xml").toFile())) { fos.write(Utf8Helper.getBytes(applicationXml)); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/swf/SwfIntelliJIdeaExporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/swf/SwfIntelliJIdeaExporter.java index ace057639..14740fb31 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/swf/SwfIntelliJIdeaExporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/swf/SwfIntelliJIdeaExporter.java @@ -62,24 +62,23 @@ public class SwfIntelliJIdeaExporter { if (!swf.isAS3()) { return false; } - + //Cannot export if it has something on main timeline for (Tag t : swf.getTags()) { - if ( - (t instanceof PlaceObjectTypeTag) + if ((t instanceof PlaceObjectTypeTag) || (t instanceof SoundStreamBlockTag) || (t instanceof VideoFrameTag) || (t instanceof StartSoundTag) - || (t instanceof StartSound2Tag) - ) { + || (t instanceof StartSound2Tag)) { return false; } } return true; } - + /** * Exports SWF to IntelliJ IDEA project. + * * @param swf SWF to export * @param outDir Output directory * @param handler Handler for abort, retry, ignore @@ -91,6 +90,7 @@ public class SwfIntelliJIdeaExporter { /** * Exports SWF to IntelliJ IDEA project. + * * @param swf SWF to export * @param outDir Output directory * @param handler Handler for abort, retry, ignore @@ -101,7 +101,7 @@ public class SwfIntelliJIdeaExporter { if (!swf.isAS3()) { throw new IllegalArgumentException("SWF must be AS3"); } - + if (!canExportSwf(swf)) { throw new IllegalArgumentException("SWF must not contain main timeline"); } @@ -136,14 +136,13 @@ public class SwfIntelliJIdeaExporter { } String flashPlayerVersion = FlashPlayerVersion.getFlashPlayerBySwfVersion(swf.version); - - + String imlData = "\n" + "\n" + " \n" + " \n" + " \n" - + " \n" + + " \n" + " \n" + " \n" + " \n" diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/swf/SwfVsCodeExporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/swf/SwfVsCodeExporter.java index 898a9a25d..ba30b047b 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/swf/SwfVsCodeExporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/swf/SwfVsCodeExporter.java @@ -120,296 +120,296 @@ public class SwfVsCodeExporter { String[] airVersions = airVersion.split("\\."); project = "{\n" - + " \"config\": \"air\",\n" - + " \"compilerOptions\": {\n" - + " \"source-path\": [\n" - + " \"src\"\n" - + " ],\n" - + " \"library-path\": [\n" - + " \"libs\"\n" - + " ],\n" - + " \"output\": \"bin/"+simpleNameNoSpaces+".swf\",\n" - + " \"default-background-color\": \"" + (bgColorTag == null ? "#FFFFFF" : bgColorTag.backgroundColor.toHexRGB()) + "\",\n" - + " \"default-frame-rate\": " + doubleToString(swf.frameRate) + ",\n" - + " \"default-size\": {\n" - + " \"width\": " + doubleToString(swf.displayRect.getWidth() / SWF.unitDivisor) + ",\n" - + " \"height\": " + doubleToString(swf.displayRect.getWidth() / SWF.unitDivisor) + "\n" - + " },\n" - + " \"swf-version\": " + swf.version + "\n" + + "\t\"config\": \"air\",\n" + + "\t\"compilerOptions\": {\n" + + "\t\t\"source-path\": [\n" + + "\t\t\t\"src\"\n" + + "\t\t],\n" + + "\t\t\"library-path\": [\n" + + "\t\t\t\"libs\"\n" + + "\t\t],\n" + + "\t\t\"output\": \"bin/" + simpleNameNoSpaces + ".swf\",\n" + + "\t\t\"default-background-color\": \"" + (bgColorTag == null ? "#FFFFFF" : bgColorTag.backgroundColor.toHexRGB()) + "\",\n" + + "\t\t\"default-frame-rate\": " + doubleToString(swf.frameRate) + ",\n" + + "\t\t\"default-size\": {\n" + + "\t\t\t\"width\": " + doubleToString(swf.displayRect.getWidth() / SWF.unitDivisor) + ",\n" + + "\t\t\t\"height\": " + doubleToString(swf.displayRect.getWidth() / SWF.unitDivisor) + "\n" + + "\t\t},\n" + + "\t\t\"swf-version\": " + swf.version + "\n" // - + " },\n" - + " \"application\": \"src/"+simpleNameNoSpaces+"-app.xml\",\n" - + " \"mainClass\": \"" + documentClass +"\"\n" + + "\t},\n" + + "\t\"application\": \"src/" + simpleNameNoSpaces + "-app.xml\",\n" + + "\t\"mainClass\": \"" + documentClass + "\"\n" + "}"; try (FileOutputStream fos = new FileOutputStream(outDir.toPath().resolve("asconfig.json").toFile())) { fos.write(Utf8Helper.getBytes(project)); } - + File vscodeDir = outDir.toPath().resolve(".vscode").toFile(); vscodeDir.mkdirs(); - - String launch = "{\n" + -" \"version\": \"0.2.0\",\n" + -" \"configurations\": [\n" + -" {\n" + -" \"type\": \"swf\",\n" + -" \"request\": \"launch\",\n" + -" \"name\": \"Launch SWF\"\n" + -" }\n" + -" ]\n" + -"}"; + + String launch = "{\n" + + "\t\"version\": \"0.2.0\",\n" + + "\t\"configurations\": [\n" + + "\t\t{\n" + + "\t\t\t\"type\": \"swf\",\n" + + "\t\t\t\"request\": \"launch\",\n" + + "\t\t\t\"name\": \"Launch SWF\"\n" + + "\t\t}\n" + + "\t]\n" + + "}"; try (FileOutputStream fos = new FileOutputStream(vscodeDir.toPath().resolve("launch.json").toFile())) { fos.write(Utf8Helper.getBytes(launch)); } - - String settings = "{\n" + -" \"as3mxml.sdk.framework\": \"c:\\\\flex\"\n" + -"}"; + + String settings = "{\n" + + "\t\"as3mxml.sdk.framework\": \"c:\\\\flex\"\n" + + "}"; try (FileOutputStream fos = new FileOutputStream(vscodeDir.toPath().resolve("settings.json").toFile())) { fos.write(Utf8Helper.getBytes(settings)); } - - String app = "\n" + -"\n" + -"\n" + -"\n" + -"\n" + -" \n" + -" test-flex\n" + -"\n" + -" \n" + -" "+simpleNameNoSpaces+"\n" + -"\n" + -" \n" + -" \n" + -" \n" + -" \n" + -" 1.0.0\n" + -" \n" + -" \n" + -" \n" + -"\n" + -" \n" + -" \n" + -"\n" + -" \n" + -" \n" + -"\n" + -" \n" + -" \n" + -"\n" + -" \n" + -" \n" + -" \n" + -" \n" + -" " + simpleNameNoSpaces + ".swf\n" + -" \n" + -" \n" + -" \n" + -"\n" + -" \n" + -" \n" + -"\n" + -" \n" + -" \n" + -"\n" + -" \n" + -" true\n" + -"\n" + -" \n" + -" \n" + -"\n" + -" \n" + -" \n" + -"\n" + -" \n" + -" \n" + -"\n" + -" \n" + -" \n" + -"\n" + -" \n" + -" \n" + -"\n" + -" \n" + -" \n" + -"\n" + -" \n" + -" \n" + -"\n" + -" \n" + -" \n" + -"\n" + -" \n" + -" \n" + -"\n" + -" \n" + -"\n" + -" \n" + -"\n" + -" \n" + -"\n" + -" \n" + -"\n" + -" \n" + -"\n" + -" \n" + -"\n" + -" \n" + -"\n" + -" \n" + -"\n" + -" \n" + -" \n" + -" \n" + -"\n" + -" \n" + -" \n" + -" \n" + -" \n" + -" \n" + -" \n" + -"\n" + -" \n" + -" \n" + -"\n" + -" \n" + -" \n" + -"\n" + -" \n" + -" \n" + -"\n" + -" \n" + -" \n" + -" \n" + -" \n" + -" \n" + -"\n" + -" \n" + -" \n" + -"\n" + -" \n" + -" \n" + -"\n" + -" \n" + -" \n" + -"\n" + -" \n" + -" \n" + -" \n" + -" \n" + -" \n" + -" \n" + -" \n" + -" \n" + -" \n" + -" \n" + -" \n" + -" \n" + -" \n" + -" \n" + -"\n" + -" \n" + -" \n" + -" \n" + -" \n" + -" \n" + -" \n" + -" \n" + -" \n" + -" \n" + -"\n" + -" \n" + -" \n" + -" \n" + -" \n" + -" \n" + -" \n" + -" \n" + -"\n" + -""; - + + String app = "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\t\n" + + "\ttest-flex\n" + + "\n" + + "\t\n" + + "\t" + simpleNameNoSpaces + "\n" + + "\n" + + "\t\n" + + "\t\n" + + "\t\n" + + "\t\n" + + "\t1.0.0\n" + + "\t\t \n" + + "\t\n" + + "\t\n" + + "\n" + + "\t\n" + + "\t\n" + + "\n" + + "\t\n" + + "\t\n" + + "\n" + + "\t\n" + + "\t\n" + + "\n" + + "\t\n" + + "\t\n" + + "\t\t\n" + + "\t\t\n" + + "\t\t" + simpleNameNoSpaces + ".swf\n" + + "\t\t\n" + + "\t\t\n" + + "\t\t\n" + + "\n" + + "\t\t\n" + + "\t\t\n" + + "\n" + + "\t\t\n" + + "\t\t\n" + + "\n" + + "\t\t\n" + + "\t\ttrue\n" + + "\n" + + "\t\t\n" + + "\t\t\n" + + "\n" + + "\t\t\n" + + "\t\t\n" + + "\n" + + "\t\t\n" + + "\t\t\n" + + "\n" + + "\t\t\n" + + "\t\t\n" + + "\n" + + "\t\t\n" + + "\t\t\n" + + "\n" + + "\t\t\n" + + "\t\t\n" + + "\n" + + "\t\t\n" + + "\t\t\n" + + "\n" + + "\t\t\n" + + "\t\t\n" + + "\n" + + "\t\t\n" + + "\t\t\n" + + "\n" + + " \n" + + "\n" + + " \n" + + "\n" + + " \n" + + "\n" + + " \n" + + "\n" + + " \n" + + "\n" + + " \n" + + "\n" + + " \n" + + "\n" + + " \n" + + "\n" + + "\t\t\n" + + "\t\t\n" + + "\t\n" + + "\n" + + "\t\n" + + "\t\n" + + "\t\n" + + "\t\n" + + "\t\n" + + "\t\n" + + "\n" + + "\t\n" + + "\t\n" + + "\n" + + "\t\n" + + "\t\n" + + "\n" + + "\t\n" + + "\t\n" + + "\n" + + "\t\n" + + "\t\n" + + "\t\n" + + "\t\n" + + "\t\n" + + "\n" + + "\t\n" + + "\t\n" + + "\n" + + "\t\t\n" + + "\t\t\n" + + "\n" + + "\t\t\t\n" + + "\t\t\t\n" + + "\n" + + "\t\t\t\n" + + "\t\t\t\n" + + "\t\t\t\n" + + "\t\t\t\n" + + "\t\t\t\n" + + "\t\t\t\n" + + "\t\t\t\n" + + "\t\t\t\n" + + "\t\t\t\n" + + "\t\t\t\n" + + "\t\t\t\n" + + "\t\t\t\n" + + "\t\t\n" + + "\t\n" + + "\n" + + " \n" + + "\t\n" + + "\t\t\n" + + "\t\t\n" + + " \n" + + "\t\t\n" + + "\t\n" + + "\t\n" + + "\t\n" + + "\n" + + "\t\n" + + " \n" + + " \n" + + "\t \n" + + " \n" + + " \n" + + "\t\n" + + "\n" + + ""; + File srcDir = outDir.toPath().resolve("src").toFile(); srcDir.mkdirs(); - + try (FileOutputStream fos = new FileOutputStream(srcDir.toPath().resolve(simpleNameNoSpaces + "-app.xml").toFile())) { fos.write(Utf8Helper.getBytes(app)); } - + File libsDir = outDir.toPath().resolve("libs").toFile(); libsDir.mkdirs(); - + boolean parallel = Configuration.parallelSpeedUp.get(); ScriptExportSettings scriptExportSettings = new ScriptExportSettings(ScriptExportMode.AS, false, false, true, false, false, "/_assets/", Configuration.linkAllClasses.get(), false); swf.exportActionScript(handler, srcDir.getAbsolutePath(), scriptExportSettings, parallel, eventListener); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/harman/HarmanBinaryDataEncrypt.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/harman/HarmanBinaryDataEncrypt.java index 424e073d5..474d82beb 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/harman/HarmanBinaryDataEncrypt.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/harman/HarmanBinaryDataEncrypt.java @@ -46,23 +46,24 @@ public class HarmanBinaryDataEncrypt { /** * Encrypts data. + * * @param data Data to encrypt * @param key Key * @return Encrypted data */ public static byte[] encrypt(byte[] data, String key) { - + byte[] customKey = null; - + if (key != null) { customKey = new byte[16]; int keyLen = key.length(); - for(int i = 0; i < 16; ++i) { - customKey[i] = (byte)key.charAt(i % keyLen); + for (int i = 0; i < 16; ++i) { + customKey[i] = (byte) key.charAt(i % keyLen); } } - + byte[] result; try { SecureRandom random = new SecureRandom(); @@ -165,6 +166,7 @@ public class HarmanBinaryDataEncrypt { /** * Decrypts data. + * * @param data Encrypted data * @param key * @return Decrypted data @@ -173,18 +175,18 @@ public class HarmanBinaryDataEncrypt { if (data.length < 32) { return null; } - + byte[] customKey = null; - + if (key != null) { customKey = new byte[16]; int keyLen = key.length(); - for(int i = 0; i < 16; ++i) { - customKey[i] = (byte)key.charAt(i % keyLen); + for (int i = 0; i < 16; ++i) { + customKey[i] = (byte) key.charAt(i % keyLen); } } - + long encryptedLen = data.length; long encryptedLenXorHash = unpack(data, 0); long decryptedLenXorRandom1 = unpack(data, 4); @@ -224,6 +226,7 @@ public class HarmanBinaryDataEncrypt { /** * Test encryption/decryption. + * * @param args Command line arguments * @throws IOException On I/O error */ diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/harman/HarmanSwfEncrypt.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/harman/HarmanSwfEncrypt.java index 2cc8a6884..11f95f763 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/harman/HarmanSwfEncrypt.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/harman/HarmanSwfEncrypt.java @@ -42,7 +42,6 @@ import javax.crypto.spec.SecretKeySpec; */ public class HarmanSwfEncrypt { - private static final String GLOBAL_KEY = "Adobe AIR SDK (c) 2021 HARMAN Internation Industries Incorporated"; /** @@ -107,6 +106,7 @@ public class HarmanSwfEncrypt { /** * Encrypts data. + * * @param data Data to encrypt * @return Encrypted data * @throws IOException On I/O error @@ -123,6 +123,7 @@ public class HarmanSwfEncrypt { /** * Encrypts data. + * * @param is Data to encrypt * @return Encrypted data * @throws IOException On I/O error @@ -142,6 +143,7 @@ public class HarmanSwfEncrypt { /** * Encrypts data. + * * @param is Data to encrypt * @param header Header * @return Encrypted data @@ -216,6 +218,7 @@ public class HarmanSwfEncrypt { /** * Decrypts data. + * * @param data Data to decrypt * @return Decrypted data * @throws IOException On I/O error @@ -232,6 +235,7 @@ public class HarmanSwfEncrypt { /** * Decrypts data. + * * @param is Data to decrypt * @return Decrypted data * @throws IOException On I/O error @@ -255,6 +259,7 @@ public class HarmanSwfEncrypt { /** * Decrypts data. + * * @param is Data to decrypt * @param header Header * @return Decrypted data @@ -324,6 +329,7 @@ public class HarmanSwfEncrypt { /** * Encrypts/decrypts data. + * * @param args Command line arguments * @throws Exception On error */ diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/importers/amf/amf0/Amf0Importer.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/importers/amf/amf0/Amf0Importer.java index 8bd2453b4..f45fd1745 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/importers/amf/amf0/Amf0Importer.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/importers/amf/amf0/Amf0Importer.java @@ -23,9 +23,9 @@ import com.jpexs.decompiler.flash.amf.amf0.types.EcmaArrayType; import com.jpexs.decompiler.flash.amf.amf0.types.ObjectType; import com.jpexs.decompiler.flash.amf.amf0.types.TypedObjectType; import com.jpexs.decompiler.flash.amf.amf0.types.XmlDocumentType; -import com.jpexs.decompiler.flash.importers.amf.ParsedSymbol; import com.jpexs.decompiler.flash.importers.amf.AmfLexer; import com.jpexs.decompiler.flash.importers.amf.AmfParseException; +import com.jpexs.decompiler.flash.importers.amf.ParsedSymbol; import com.jpexs.decompiler.flash.importers.amf.SymbolType; import java.io.IOException; import java.io.StringReader; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/importers/amf/amf3/Amf3Importer.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/importers/amf/amf3/Amf3Importer.java index 9a93b4140..ccf63cb4d 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/importers/amf/amf3/Amf3Importer.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/importers/amf/amf3/Amf3Importer.java @@ -16,9 +16,6 @@ */ package com.jpexs.decompiler.flash.importers.amf.amf3; -import com.jpexs.decompiler.flash.importers.amf.AmfLexer; -import com.jpexs.decompiler.flash.importers.amf.AmfParseException; -import com.jpexs.decompiler.flash.importers.amf.SymbolType; import com.jpexs.decompiler.flash.amf.amf3.ListMap; import com.jpexs.decompiler.flash.amf.amf3.Traits; import com.jpexs.decompiler.flash.amf.amf3.types.ArrayType; @@ -33,7 +30,10 @@ import com.jpexs.decompiler.flash.amf.amf3.types.VectorObjectType; import com.jpexs.decompiler.flash.amf.amf3.types.VectorUIntType; import com.jpexs.decompiler.flash.amf.amf3.types.XmlDocType; import com.jpexs.decompiler.flash.amf.amf3.types.XmlType; +import com.jpexs.decompiler.flash.importers.amf.AmfLexer; +import com.jpexs.decompiler.flash.importers.amf.AmfParseException; import com.jpexs.decompiler.flash.importers.amf.ParsedSymbol; +import com.jpexs.decompiler.flash.importers.amf.SymbolType; import com.jpexs.helpers.Helper; import java.io.IOException; import java.io.StringReader; @@ -451,7 +451,7 @@ public class Amf3Importer { JsObject entryJso = (JsObject) entry; entryJso.resolve("key", objectTable, true); entryJso.resolve("value", objectTable, true); - + Object key = entryJso.get("key"); Object value = entryJso.get("value"); entries.put(key, value); @@ -484,8 +484,8 @@ public class Amf3Importer { } } return resultObject; - } - + } + private Map map(Map objectTable) throws IOException, AmfParseException { Map result = new LinkedHashMap<>(); expectedType(SymbolType.CURLY_OPEN); @@ -499,12 +499,12 @@ public class Amf3Importer { expectedType(SymbolType.COLON); result.put(key, value(objectTable)); s = lex(); - } while(s.type == SymbolType.COMMA); - + } while (s.type == SymbolType.COMMA); + expected(s, lexer.yyline(), SymbolType.CURLY_CLOSE); return result; } - + private Object value(Map objectTable) throws IOException, AmfParseException { ParsedSymbol s = lex(); switch (s.type) { @@ -613,7 +613,7 @@ public class Amf3Importer { * @param val AMF3 string * @return Object * @throws IOException On I/O error - * @throws AmfParseException On parse error + * @throws AmfParseException On parse error */ public Object stringToAmf(String val) throws IOException, AmfParseException { lexer = new AmfLexer(new StringReader(val)); @@ -624,30 +624,30 @@ public class Amf3Importer { Object resultNoRef = replaceReferences(resultResolved, objectsTable); return resultNoRef; } - + /** * Convert AMF3 map string to object * * @param val AMF3 string * @return Object * @throws IOException On I/O error - * @throws AmfParseException On parse error + * @throws AmfParseException On parse error */ public Map stringToAmfMap(String val) throws IOException, AmfParseException { lexer = new AmfLexer(new StringReader(val)); Map objectsTable = new LinkedHashMap<>(); List references = new ArrayList<>(); Map result = map(objectsTable); - for (String key: result.keySet()) { + for (String key : result.keySet()) { Object resultResolved = resolveObjects(result.get(key), objectsTable, true); result.put(key, resultResolved); } - - for (String key: result.keySet()) { + + for (String key : result.keySet()) { Object resultNoRef = replaceReferences(result.get(key), objectsTable); result.put(key, resultNoRef); } - + return result; } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/sol/LsoTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/sol/LsoTag.java index 01cc4397a..d01163d08 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/sol/LsoTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/sol/LsoTag.java @@ -41,7 +41,7 @@ import java.util.logging.Logger; public class LsoTag extends Tag { public static final int ID = 2; - + public String fileName; public int amfVersion; public Map amfValues = new LinkedHashMap<>(); @@ -49,7 +49,7 @@ public class LsoTag extends Tag { public LsoTag(byte[] data, boolean forceWriteAsLong) { super(ID, "DefineLso", data, forceWriteAsLong); } - + public LsoTag(String fileName, int amfVersion, Map amfValues) { super(ID, "DefineLso", new byte[0], true); this.fileName = fileName; @@ -81,7 +81,7 @@ public class LsoTag extends Tag { while (ais.available() > 0) { String varName = ais.readUtf8("varName"); try { - Object varValue = ais.readValue("varValue"); + Object varValue = ais.readValue("varValue"); amfValues.put(varName, varValue); } catch (NoSerializerExistsException ex) { throw new IllegalArgumentException("Serializer for class " + ex.getClassName() + " not found"); @@ -89,7 +89,7 @@ public class LsoTag extends Tag { ais.read(); //ending byte } ais.resolveMapReferences(amfValues); - } + } if (amfVersion == 3) { Amf3InputStream ais = new Amf3InputStream(new MemoryInputStream(amfData)); @@ -114,18 +114,18 @@ public class LsoTag extends Tag { @Override public void writeData(OutputStream os) throws IOException { Amf0OutputStream aos = new Amf0OutputStream(os); - aos.write(new byte[] {'T', 'C', 'S', 'O'}); - aos.write(new byte[] {0x00,0x04,0x00,0x00,0x00,0x00}); + aos.write(new byte[]{'T', 'C', 'S', 'O'}); + aos.write(new byte[]{0x00, 0x04, 0x00, 0x00, 0x00, 0x00}); byte[] fileNameData = fileName.getBytes("UTF-8"); aos.writeU16(fileNameData.length); aos.write(fileNameData); aos.writeU32(amfVersion); - + if (amfVersion == 0) { List complexObjects = new ArrayList<>(); - for(String key: amfValues.keySet()) { + for (String key : amfValues.keySet()) { aos.writeUtf8(key); - aos.writeValue(amfValues.get(key), complexObjects); + aos.writeValue(amfValues.get(key), complexObjects); aos.write(0); } } @@ -134,7 +134,7 @@ public class LsoTag extends Tag { List stringTable = new ArrayList<>(); List traitTable = new ArrayList<>(); List objectTable = new ArrayList<>(); - for(String key: amfValues.keySet()) { + for (String key : amfValues.keySet()) { try { a3os.writeUtf8Vr(key, stringTable); a3os.writeValue(amfValues.get(key), new HashMap<>(), stringTable, traitTable, objectTable); @@ -144,6 +144,6 @@ public class LsoTag extends Tag { aos.write(0); } } - + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/sol/SolFile.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/sol/SolFile.java index 5d6320a8c..7f8f1fd7a 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/sol/SolFile.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/sol/SolFile.java @@ -20,9 +20,9 @@ import com.jpexs.decompiler.flash.EndOfStreamException; import com.jpexs.decompiler.flash.amf.amf0.Amf0OutputStream; import com.jpexs.decompiler.flash.exporters.amf.amf0.Amf0Exporter; import com.jpexs.decompiler.flash.exporters.amf.amf3.Amf3Exporter; +import com.jpexs.decompiler.flash.importers.amf.AmfParseException; import com.jpexs.decompiler.flash.importers.amf.amf0.Amf0Importer; import com.jpexs.decompiler.flash.importers.amf.amf3.Amf3Importer; -import com.jpexs.decompiler.flash.importers.amf.AmfParseException; import java.io.ByteArrayOutputStream; import java.io.DataInputStream; import java.io.EOFException; @@ -46,24 +46,24 @@ public class SolFile { private DataInputStream is; private long pos = 0; - + private List tags = new ArrayList<>(); - + public SolFile(InputStream is) throws IOException { this.is = new DataInputStream(is); readTags(); } - + public SolFile(String fileName, int amfVersion, Map amfValues) { tags.add(new LsoTag(fileName, amfVersion, amfValues)); } - + public void writeTo(OutputStream os) throws IOException { - for (Tag t: tags) { + for (Tag t : tags) { writeTag(os, t); } } - + private void readTags() throws IOException { while (is.available() > 0) { Tag t = readTag(); @@ -112,10 +112,10 @@ public class SolFile { is.skip(count); pos += count; } - - private void writeTag(OutputStream os, Tag t) throws IOException{ + + private void writeTag(OutputStream os, Tag t) throws IOException { Amf0OutputStream aos = new Amf0OutputStream(os); - + ByteArrayOutputStream baos = new ByteArrayOutputStream(); t.writeData(baos); int contentLength = baos.size(); @@ -137,7 +137,7 @@ public class SolFile { contentLength = (int) readUI32(); writeAsLong = true; } - int tagType = tagTypeAndLength >> 6; + int tagType = tagTypeAndLength >> 6; byte[] data = readBytes(contentLength); switch (tagType) { @@ -153,8 +153,8 @@ public class SolFile { public List getTags() { return tags; } - - private LsoTag getLsoTag() throws IOException { + + private LsoTag getLsoTag() throws IOException { for (Tag t : getTags()) { if (t instanceof LsoTag) { return (LsoTag) t; @@ -162,7 +162,7 @@ public class SolFile { } return null; } - + public int getAmfVersion() throws IOException { LsoTag lsoTag = getLsoTag(); if (lsoTag == null) { @@ -170,7 +170,7 @@ public class SolFile { } return lsoTag.amfVersion; } - + public String getFileName() throws IOException { LsoTag lsoTag = getLsoTag(); if (lsoTag == null) { @@ -178,14 +178,14 @@ public class SolFile { } return lsoTag.fileName; } - + public Map getAmfValues() throws IOException { LsoTag lsoTag = getLsoTag(); if (lsoTag == null) { return new HashMap<>(); } return lsoTag.amfValues; - } + } public static void main(String[] args) throws FileNotFoundException, IOException { SolFile sol0 = new SolFile(new FileInputStream("testdata/sharedobjects/data/amf0test.sol")); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/Timeline.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/Timeline.java index a6b362bff..f8581687c 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/Timeline.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/Timeline.java @@ -1088,7 +1088,7 @@ public class Timeline { double y = filter.getDeltaY(); deltaXMax = Math.max(x, deltaXMax); deltaYMax = Math.max(y, deltaYMax); - } + } rect.xMin -= deltaXMax * unzoom * SWF.unitDivisor; rect.xMax += deltaXMax * unzoom * SWF.unitDivisor; rect.yMin -= deltaYMax * unzoom * SWF.unitDivisor; @@ -1096,9 +1096,9 @@ public class Timeline { viewRect2.xMin -= deltaXMax * SWF.unitDivisor; viewRect2.xMax += deltaXMax * SWF.unitDivisor; viewRect2.yMin -= deltaYMax * SWF.unitDivisor; - viewRect2.yMax += deltaYMax * SWF.unitDivisor; + viewRect2.yMax += deltaYMax * SWF.unitDivisor; } - + drawMatrix.translate(rect.xMin, rect.yMin); drawMatrix.translateX /= SWF.unitDivisor; drawMatrix.translateY /= SWF.unitDivisor; @@ -1111,7 +1111,6 @@ public class Timeline { int deltaY = (int) Math.ceil(rect.yMin / SWF.unitDivisor); newWidth = Math.min(image.getWidth() - deltaX, newWidth); newHeight = Math.min(image.getHeight() - deltaY, newHeight); - if (newWidth <= 0 || newHeight <= 0) { return; @@ -1190,17 +1189,17 @@ public class Timeline { } else { // todo: show one time warning } - + if (cacheAsBitmap && layer.backGroundColor != null && (blendMode <= 1 || (filters != null && !filters.isEmpty()))) { Graphics2D g2 = (Graphics2D) img.getGraphics(); g2.setComposite(AlphaComposite.DstOver); Color bgColor = layer.backGroundColor.toColor(); - g2.setColor(bgColor); + g2.setColor(bgColor); g2.fillRect((int) Math.round(deltaXMax * unzoom), - (int) Math.round(deltaYMax * unzoom), - (int) Math.round(rect.getWidth() / SWF.unitDivisor - 2 * deltaXMax * unzoom), - (int) Math.round(rect.getHeight()/ SWF.unitDivisor - 2 * deltaYMax * unzoom) - ); + (int) Math.round(deltaYMax * unzoom), + (int) Math.round(rect.getWidth() / SWF.unitDivisor - 2 * deltaXMax * unzoom), + (int) Math.round(rect.getHeight() / SWF.unitDivisor - 2 * deltaYMax * unzoom) + ); } if (filters != null) { @@ -1213,7 +1212,7 @@ public class Timeline { img = colorTransForm.apply(img); } } - + if (!sameImage && cacheAsBitmap && renderContext.displayObjectCache != null) { renderContext.clearPlaceObjectCache(layer.placeObjectTag); renderContext.displayObjectCache.put(new DisplayObjectCacheKey(layer.placeObjectTag, unzoom, viewRect), img); @@ -1315,20 +1314,20 @@ public class Timeline { g.setTransform(drawMatrix.toTransform()); if ((blendMode > 1 || (filters != null && !filters.isEmpty())) && mergedColorTransform != null) { - img = mergedColorTransform.apply(img); + img = mergedColorTransform.apply(img); } - + if (blendMode > 1 && (filters == null || filters.isEmpty()) && cacheAsBitmap && layer.backGroundColor != null) { Graphics2D g2 = (Graphics2D) img.getGraphics(); g2.setComposite(AlphaComposite.DstOver); Color bgColor = layer.backGroundColor.toColor(); g2.setColor(bgColor); g2.fillRect((int) Math.round(deltaXMax * unzoom), - (int) Math.round(deltaYMax * unzoom), - (int) Math.round(rect.getWidth() / SWF.unitDivisor - 2 * deltaXMax * unzoom), - (int) Math.round(rect.getHeight()/ SWF.unitDivisor - 2 * deltaYMax * unzoom) + (int) Math.round(deltaYMax * unzoom), + (int) Math.round(rect.getWidth() / SWF.unitDivisor - 2 * deltaXMax * unzoom), + (int) Math.round(rect.getHeight() / SWF.unitDivisor - 2 * deltaYMax * unzoom) ); - } + } if (!((blendMode == 11 || blendMode == 12) && parentBlendMode <= 1)) { //alpha and erase modes require parent blendmode not normal g.drawImage(img.getBufferedImage(), 0, 0, null); @@ -1386,7 +1385,7 @@ public class Timeline { int maxDepth = getMaxDepth(); int clipCount = 0; - for (int i = 0; i <= maxDepth; i++) { + for (int i = 0; i <= maxDepth; i++) { boolean clipChanged = clipCount != clips.size(); for (int c = 0; c < clips.size(); c++) { if (clips.get(c).depth < i) { @@ -1449,11 +1448,11 @@ public class Timeline { if (drawMode != DRAW_MODE_ALL && drawMode != DRAW_MODE_SHAPES && (character instanceof ShapeTag)) { continue; } - + if (ignoreDepths.contains(i)) { continue; } - + if (character instanceof DrawableTag) { RECT scalingRect = null; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/FILLSTYLE.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/FILLSTYLE.java index 3a6d4a53a..6fb563b21 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/FILLSTYLE.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/FILLSTYLE.java @@ -203,6 +203,7 @@ public class FILLSTYLE implements NeedsCharacters, FieldChangeObserver, Serializ /** * Checks if fill style has bitmap + * * @return True if fill style has bitmap */ public boolean hasBitmap() { @@ -218,6 +219,7 @@ public class FILLSTYLE implements NeedsCharacters, FieldChangeObserver, Serializ /** * Checks if fill style has gradient + * * @return True if fill style has gradient */ public boolean hasGradient() { @@ -232,6 +234,7 @@ public class FILLSTYLE implements NeedsCharacters, FieldChangeObserver, Serializ /** * Checks whether fill style is compatible with other fill style + * * @param otherFillStyle Other fill style * @param swf SWF * @return True if fill styles are compatible @@ -264,6 +267,7 @@ public class FILLSTYLE implements NeedsCharacters, FieldChangeObserver, Serializ /** * Converts fill style to morph fill style + * * @return Morph fill style */ public MORPHFILLSTYLE toMorphStyle() { @@ -289,6 +293,7 @@ public class FILLSTYLE implements NeedsCharacters, FieldChangeObserver, Serializ /** * Converts fill style to morph fill style + * * @param endFillStyle End fill style * @param swf SWF * @return Morph fill style @@ -376,10 +381,9 @@ public class FILLSTYLE implements NeedsCharacters, FieldChangeObserver, Serializ result.color = new RGBA(color); } } - if (fillStyleType == LINEAR_GRADIENT + if (fillStyleType == LINEAR_GRADIENT || fillStyleType == RADIAL_GRADIENT - || fillStyleType == FOCAL_RADIAL_GRADIENT - ) { + || fillStyleType == FOCAL_RADIAL_GRADIENT) { result.gradient = result.gradient.toShapeNum(targetShapeNum); } if (fillStyleType == FOCAL_RADIAL_GRADIENT && targetShapeNum < 4) { @@ -387,7 +391,7 @@ public class FILLSTYLE implements NeedsCharacters, FieldChangeObserver, Serializ } return result; } - + public int getMinShapeNum() { int shapeNum = 1; if (fillStyleType == SOLID) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/LINESTYLEARRAY.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/LINESTYLEARRAY.java index 8d23b6917..3ac93a865 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/LINESTYLEARRAY.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/LINESTYLEARRAY.java @@ -51,7 +51,7 @@ public class LINESTYLEARRAY implements NeedsCharacters, Serializable { public int getMinShapeNum(int sourceShapeNum) { int result = 1; - if (sourceShapeNum >= 4) { + if (sourceShapeNum >= 4) { for (LINESTYLE2 ls : lineStyles2) { int sn = ls.getMinShapeNum(); if (sn > result) { @@ -68,7 +68,7 @@ public class LINESTYLEARRAY implements NeedsCharacters, Serializable { } return result; } - + public LINESTYLEARRAY toShapeNum(int sourceShapeNum, int targetShapeNum) { if (sourceShapeNum == targetShapeNum) { return Helper.deepCopy(this); @@ -80,7 +80,7 @@ public class LINESTYLEARRAY implements NeedsCharacters, Serializable { result.lineStyles2[i] = lineStyles[i].toLineStyle2(); } } else { - result.lineStyles = new LINESTYLE[sourceShapeNum >=4 ? lineStyles2.length : lineStyles.length]; + result.lineStyles = new LINESTYLE[sourceShapeNum >= 4 ? lineStyles2.length : lineStyles.length]; if (sourceShapeNum >= 4) { for (int i = 0; i < lineStyles2.length; i++) { result.lineStyles[i] = lineStyles2[i].toLineStyle1(targetShapeNum); @@ -100,7 +100,7 @@ public class LINESTYLEARRAY implements NeedsCharacters, Serializable { } return result; } - + @Override public void getNeededCharacters(Set needed, SWF swf) { if (lineStyles != null) { @@ -150,6 +150,7 @@ public class LINESTYLEARRAY implements NeedsCharacters, Serializable { /** * Converts to MORPHLINESTYLEARRAY + * * @return MORPHLINESTYLEARRAY */ public MORPHLINESTYLEARRAY toMorphLineStyleArray() { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/MORPHGRADIENT.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/MORPHGRADIENT.java index 66e0e4622..d9bc917ab 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/MORPHGRADIENT.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/MORPHGRADIENT.java @@ -16,11 +16,6 @@ */ package com.jpexs.decompiler.flash.types; -import static com.jpexs.decompiler.flash.types.GRADIENT.INTERPOLATION_LINEAR_RGB_MODE; -import static com.jpexs.decompiler.flash.types.GRADIENT.INTERPOLATION_RGB_MODE; -import static com.jpexs.decompiler.flash.types.GRADIENT.SPREAD_PAD_MODE; -import static com.jpexs.decompiler.flash.types.GRADIENT.SPREAD_REFLECT_MODE; -import static com.jpexs.decompiler.flash.types.GRADIENT.SPREAD_REPEAT_MODE; import com.jpexs.decompiler.flash.types.annotations.EnumValue; import com.jpexs.decompiler.flash.types.annotations.SWFType; import java.io.Serializable; @@ -36,17 +31,17 @@ public class MORPHGRADIENT implements Serializable { * Spread mode. See GRADIENT.SPREAD_* constants */ @SWFType(value = BasicType.UB, count = 2) - @EnumValue(value = SPREAD_PAD_MODE, text = "Pad") - @EnumValue(value = SPREAD_REFLECT_MODE, text = "Reflect") - @EnumValue(value = SPREAD_REPEAT_MODE, text = "Repeat") + @EnumValue(value = GRADIENT.SPREAD_PAD_MODE, text = "Pad") + @EnumValue(value = GRADIENT.SPREAD_REFLECT_MODE, text = "Reflect") + @EnumValue(value = GRADIENT.SPREAD_REPEAT_MODE, text = "Repeat") public int spreadMode; /** * Interpolation mode. See GRADIENT.INTERPOLATION_* constants */ @SWFType(value = BasicType.UB, count = 2) - @EnumValue(value = INTERPOLATION_RGB_MODE, text = "Normal RGB") - @EnumValue(value = INTERPOLATION_LINEAR_RGB_MODE, text = "Linear RGB") + @EnumValue(value = GRADIENT.INTERPOLATION_RGB_MODE, text = "Normal RGB") + @EnumValue(value = GRADIENT.INTERPOLATION_LINEAR_RGB_MODE, text = "Linear RGB") public int interpolationMode; /** @@ -56,6 +51,7 @@ public class MORPHGRADIENT implements Serializable { /** * Morphs two colors at given ratio. + * * @param c1 Color 1 * @param c2 Color 2 * @param ratio Ratio @@ -83,6 +79,7 @@ public class MORPHGRADIENT implements Serializable { /** * Gets gradient at given ratio. + * * @param ratio Ratio * @return Gradient */ @@ -103,6 +100,7 @@ public class MORPHGRADIENT implements Serializable { /** * Gets start gradient. + * * @return Start gradient */ public GRADIENT getStartGradient() { @@ -118,6 +116,7 @@ public class MORPHGRADIENT implements Serializable { /** * Gets end gradient. + * * @return End gradient */ public GRADIENT getEndGradient() { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/BinDataOutputStream.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/BinDataOutputStream.java index c6d336700..3ec1bbc6a 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/BinDataOutputStream.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/BinDataOutputStream.java @@ -41,12 +41,7 @@ public class BinDataOutputStream extends OutputStream { os.write(i); } } - - public void writeUI16(int value) throws IOException { - write(value & 0xFF); - write((value >> 8) & 0xFF); - } - + @Override public void write(byte[] b) throws IOException { os.write(b); @@ -57,6 +52,11 @@ public class BinDataOutputStream extends OutputStream { os.write(b, off, len); } + public void writeUI16(int value) throws IOException { + write(value & 0xFF); + write((value >> 8) & 0xFF); + } + public void writeUI32(long value) throws IOException { write((int) (value & 0xFF)); write((int) ((value >> 8) & 0xFF)); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/ImageBinDataGenerator.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/ImageBinDataGenerator.java index fbcc8ef87..d6d32fde4 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/ImageBinDataGenerator.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/ImageBinDataGenerator.java @@ -30,12 +30,14 @@ import javax.imageio.ImageIO; /** * Generates bin/*.dat file for images. + * * @author JPEXS */ public class ImageBinDataGenerator { /** * Generates data + * * @param is Input stream * @param os Output stream * @param format Image format @@ -65,7 +67,7 @@ public class ImageBinDataGenerator { w.writeUI32(0); w.writeUI32(20 * bimg.getWidth()); - w.writeUI32(0); + w.writeUI32(0); w.writeUI32(20 * bimg.getHeight()); w.write(0x01); //has transparency @@ -81,19 +83,19 @@ public class ImageBinDataGenerator { int b = (rgba >> 16) & 0xFF; int g = (rgba >> 8) & 0xFF; int r = rgba & 0xFF; - + //some weird premultiplication if (a != 255) { - r = (int)Math.floor(r * a / 256f); - g = (int)Math.floor(g * a / 256f); - b = (int)Math.floor(b * a / 256f); + r = (int) Math.floor(r * a / 256f); + g = (int) Math.floor(g * a / 256f); + b = (int) Math.floor(b * a / 256f); } - + //also weird, but this way it works... if (a != 0 && a != 255) { a = a + 1; - } - + } + def.write(a); def.write(b); def.write(g); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/LosslessImageBinDataReader.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/LosslessImageBinDataReader.java index 581f35f87..6fb19272e 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/LosslessImageBinDataReader.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/LosslessImageBinDataReader.java @@ -29,6 +29,7 @@ import javax.imageio.ImageIO; /** * Reads bin/*.dat file of lossless images and produces BufferedImage + * * @author JPEXS */ public class LosslessImageBinDataReader { @@ -87,14 +88,14 @@ public class LosslessImageBinDataReader { int b = data[pos++] & 0xFF; int g = data[pos++] & 0xFF; int r = data[pos++] & 0xFF; - + if (a != 0 && a != 255) { a = a - 1; - - r = (int)Math.floor(r * 256f / a); - g = (int)Math.floor(g * 256f / a); - b = (int)Math.floor(b * 256f / a); - } + + r = (int) Math.floor(r * 256f / a); + g = (int) Math.floor(g * 256f / a); + b = (int) Math.floor(b * 256f / a); + } int rgba = r + (g << 8) + (b << 16) + (a << 24); img.setRGB(x, y, rgba); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java index e7aa8df19..88aaad139 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java @@ -2914,12 +2914,14 @@ public class XFLConverter { return ret; } - private static class AccessibilityBag { + private List items = new ArrayList<>(); + public void add(AccessibilityItem item) { items.add(item); } + public Map getAttributes(String instanceName, int frame) { Map ret = new LinkedHashMap<>(); for (AccessibilityItem item : items) { @@ -2942,10 +2944,11 @@ public class XFLConverter { sb.append(item.toString()); } return sb.toString(); - } + } } - + private static class AccessibilityItem { + int startFrame; int endFrame; String instanceName; @@ -2955,19 +2958,18 @@ public class XFLConverter { public AccessibilityItem(String instanceName, String attributeKey, String attributeValue) { this(instanceName, attributeKey, attributeValue, 1, Integer.MAX_VALUE); } - + public AccessibilityItem(String instanceName, String attributeKey, String attributeValue, int frame) { this(instanceName, attributeKey, attributeValue, frame, frame); } - + public AccessibilityItem(String instanceName, String attributeKey, String attributeValue, int startFrame, int endFrame) { this.startFrame = startFrame; this.endFrame = endFrame; this.instanceName = instanceName; this.attributeKey = attributeKey; this.attributeValue = attributeValue; - } - + } public boolean contains(String instanceName, int frame) { if (!Objects.equals(instanceName, this.instanceName)) { @@ -2978,7 +2980,7 @@ public class XFLConverter { @Override public String toString() { - return "[instance: " + instanceName+" key: \"" + attributeKey+"\" value: \"" + attributeValue +"\" frames: " + startFrame + " to " + (endFrame == Integer.MAX_VALUE ? "end" : endFrame) + "]"; + return "[instance: " + instanceName + " key: \"" + attributeKey + "\" value: \"" + attributeValue + "\" frames: " + startFrame + " to " + (endFrame == Integer.MAX_VALUE ? "end" : endFrame) + "]"; } @Override @@ -3019,10 +3021,7 @@ public class XFLConverter { return Objects.equals(this.attributeValue, other.attributeValue); } - } - - private static AccessibilityBag getAccessibilityFromPack(AbcIndexing abcIndex, ScriptPack pack) { int swfVersion = -1; @@ -3089,7 +3088,7 @@ public class XFLConverter { TraitMethodGetterSetter tm = (TraitMethodGetterSetter) t; if (abc.method_info.get(tm.method_info).param_types.length != 1) { continue; - } + } MethodBody traitBody = abc.findBody(tm.method_info); List traitCallStack = new ArrayList<>(); traitCallStack.add(traitBody); @@ -3112,8 +3111,8 @@ public class XFLConverter { || propName.resolvedMultinameName.startsWith("__setTab_")) && callProp.arguments.size() == 1) { frameRangeAccessibilityTraitNames.add(propName.resolvedMultinameName); - } - } + } + } } if (frameTraitNames.contains(traitName)) { TraitMethodGetterSetter tm = (TraitMethodGetterSetter) t; @@ -3144,7 +3143,7 @@ public class XFLConverter { for (Trait t : instanceInfo.instance_traits.traits) { if (t instanceof TraitMethodGetterSetter) { - String traitName = t.getName(abc).getName(abc.constants, new ArrayList<>(), true, false); + String traitName = t.getName(abc).getName(abc.constants, new ArrayList<>(), true, false); if (frameAccessibilityTraitNames.contains(traitName)) { TraitMethodGetterSetter tm = (TraitMethodGetterSetter) t; MethodBody traitBody = abc.findBody(tm.method_info); @@ -3246,7 +3245,7 @@ public class XFLConverter { } } } - + if (frameRangeAccessibilityTraitNames.contains(traitName)) { TraitMethodGetterSetter tm = (TraitMethodGetterSetter) t; MethodBody traitBody = abc.findBody(tm.method_info); @@ -3351,21 +3350,21 @@ public class XFLConverter { } } } - + } } } } } } - } + } } } } } } } - + for (Trait t : instanceInfo.instance_traits.traits) { if (allFramesAccessibilityTraitNames.contains(t.getName(abc).getName(abc.constants, new ArrayList<>(), true, false))) { if (t instanceof TraitMethodGetterSetter) { @@ -3440,7 +3439,7 @@ public class XFLConverter { if (setProp.value instanceof FalseItem) { val = invert ? "true" : "false"; } - ret.add(new AccessibilityItem(parentParentProp.resolvedMultinameName, acProp, val)); + ret.add(new AccessibilityItem(parentParentProp.resolvedMultinameName, acProp, val)); } } } @@ -3548,8 +3547,8 @@ public class XFLConverter { callStack.add(frameBody); frameBody.convert(swfVersion, callStack, abcIndex, new ConvertData(), "??", ScriptExportMode.AS, false, methodIndex, pack.scriptIndex, classIndex, abc, methodTrait, new ScopeStack(), 0, new NulWriter(), new ArrayList<>(), new Traits(), true, new HashSet<>(), new ArrayList<>()); - - if (frameBody.convertedItems != null) { + + if (frameBody.convertedItems != null) { for (int i = 0; i < frameBody.convertedItems.size(); i++) { GraphTargetItem ti = frameBody.convertedItems.get(i); if (ti instanceof CallPropertyAVM2Item) { @@ -3567,7 +3566,7 @@ public class XFLConverter { } } } - + StringBuilderTextWriter writer = new StringBuilderTextWriter(Configuration.getCodeFormatting(), scriptBuilder); frameBody.toString(swfVersion, callStack, abcIndex, "??", ScriptExportMode.AS, abc, methodTrait, writer, new ArrayList<>(), new HashSet<>()); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/Graph.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/Graph.java index 63cca1569..ac6e923cb 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/Graph.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/Graph.java @@ -96,7 +96,7 @@ public class Graph { * Exceptions in the graph */ private final List exceptions; - + /** * Debug flag to print all parts */ @@ -2692,6 +2692,19 @@ public class Graph { } return true; } + + + /** + * Gets if expression from stack. Can be overridden for custom handling + * + * @param localData Local data + * @param stack Stack + * @param output Output + * @return Expression + */ + protected GraphTargetItem getIfExpression(BaseLocalData localData, TranslateStack stack, List output) { + return stack.pop(); + } /** * Walks graph parts and converts them to target items. @@ -2717,18 +2730,6 @@ public class Graph { protected final List printGraph(List foundGotos, Map> partCodes, Map partCodePos, Set visited, BaseLocalData localData, TranslateStack stack, Set allParts, GraphPart parent, GraphPart part, List stopPart, List stopPartKind, List loops, List throwStates, int staticOperation, String path) throws InterruptedException { return printGraph(foundGotos, partCodes, partCodePos, visited, localData, stack, allParts, parent, part, stopPart, stopPartKind, loops, throwStates, null, staticOperation, path, 0); } - - /** - * Gets if expression from stack. - * Can be overridden for custom handling - * @param localData Local data - * @param stack Stack - * @param output Output - * @return Expression - */ - protected GraphTargetItem getIfExpression(BaseLocalData localData, TranslateStack stack, List output) { - return stack.pop(); - } /** * Walks graph parts and converts them to target items. @@ -2964,7 +2965,7 @@ public class Graph { List stopPartKind2 = new ArrayList<>(stopPartKind); stopPartKind2.add(StopPartKind.OTHER); Set subVisited = new HashSet<>(); - + /* * Save loop phases to be able to walk precontinue block again. */ @@ -3003,8 +3004,8 @@ public class Graph { } if (currentLoop.loopPreContinue == null) { precontinueCommands.clear(); - - /** + + /* * Restore loop phases */ for (int i = 0; i < loopPhases.size(); i++) { @@ -3352,7 +3353,7 @@ public class Graph { } else { ternarOnFalse = filteredOnFalse.get(0).value; } - TernarOpItem top = new TernarOpItem(null, localData.lineStartInstruction, expr.invert(null), ternarOnTrue, ternarOnFalse); + TernarOpItem top = new TernarOpItem(null, localData.lineStartInstruction, expr.invert(null), ternarOnTrue, ternarOnFalse); stack.push(handleTernar(top, localData)); } else { boolean isIf = true; @@ -3887,7 +3888,7 @@ public class Graph { if (ti.hasSingleNewLineAround() && !lastNewLine) { writer.newLine(); } - ti.toStringSemicoloned(writer, localData); + ti.toStringSemicoloned(writer, localData); if (!ti.handlesNewLine()) { writer.newLine(); } @@ -4293,9 +4294,10 @@ public class Graph { protected boolean partIsSwitch(GraphPart part) { return false; } - + /** * Replaces ternar with custom value + * * @param ternar Ternar * @param localData Local data * @return Custom item diff --git a/libsrc/ffdec_lib/src/com/jpexs/helpers/CancellableWorker.java b/libsrc/ffdec_lib/src/com/jpexs/helpers/CancellableWorker.java index 6a4fae283..ad7c4a6c5 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/helpers/CancellableWorker.java +++ b/libsrc/ffdec_lib/src/com/jpexs/helpers/CancellableWorker.java @@ -31,14 +31,13 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import java.util.logging.Level; import java.util.logging.Logger; - /*private static final Map threadWorkers = Collections.synchronizedMap(new WeakHashMap<>()); + +/*private static final Map threadWorkers = Collections.synchronizedMap(new WeakHashMap<>()); private static final Map parentThreadWorkers = Collections.synchronizedMap(new WeakHashMap<>()); private static final Map threadToParentThread = Collections.synchronizedMap(new WeakHashMap<>()); - */ - - + */ /** * Cancellable worker. @@ -55,57 +54,55 @@ public abstract class CancellableWorker implements RunnableFuture { private FutureTask future; private List subWorkers = Collections.synchronizedList(new ArrayList<>()); - - private static final Map thread2Worker = Collections.synchronizedMap(new WeakHashMap<>()); - + + private static final Map thread2Worker = Collections.synchronizedMap(new WeakHashMap<>()); + private Thread parentThread; - + private Thread thread; - + private String name; - + private CancellableWorker parentWorker; - + private boolean canceled = false; - + private List cancelListeners = new ArrayList<>(); public Thread getThread() { return thread; - } - + } + public static void assignThreadToWorker(Thread t, CancellableWorker w) { if (w == null) { return; } thread2Worker.put(t, w); } - + public static CancellableWorker getCurrent() { Thread t = Thread.currentThread(); - + CancellableWorker w = thread2Worker.get(t); return w; } - + public void addCancelListener(Runnable listener) { cancelListeners.add(listener); } - + public void removeCancelListener(Runnable listener) { cancelListeners.remove(listener); } - - + public static boolean isInterrupted() { Thread t = Thread.currentThread(); if (t.isInterrupted()) { return true; } - - - CancellableWorker w = thread2Worker.get(t); - if (w != null) { + + CancellableWorker w = thread2Worker.get(t); + if (w != null) { while (w != null) { t = w.thread; if (t != null && t.isInterrupted()) { @@ -115,26 +112,27 @@ public abstract class CancellableWorker implements RunnableFuture { return true; } w = w.parentWorker; - } + } } return false; } - + /** * Constructor. + * * @param name Identifier of action */ public CancellableWorker(String name) { super(); - this.name = name; + this.name = name; Callable callable = new Callable() { @Override public T call() throws Exception { - thread = Thread.currentThread(); + thread = Thread.currentThread(); thread2Worker.put(thread, CancellableWorker.this); if (isInterrupted()) { throw new InterruptedException(); - } + } return doInBackground(); } }; @@ -149,6 +147,7 @@ public abstract class CancellableWorker implements RunnableFuture { /** * Do in background. + * * @return Result * @throws Exception On error */ @@ -188,25 +187,24 @@ public abstract class CancellableWorker implements RunnableFuture { } @Override - public final boolean cancel(boolean mayInterruptIfRunning) { + public final boolean cancel(boolean mayInterruptIfRunning) { canceled = true; boolean r = future.cancel(mayInterruptIfRunning); List sw = new ArrayList<>(subWorkers); for (CancellableWorker w : sw) { w.cancel(mayInterruptIfRunning); - } - - if (r) { - - List cls = new ArrayList<>(cancelListeners); - + } + + if (r) { + + List cls = new ArrayList<>(cancelListeners); + for (Runnable listener : cls) { listener.run(); } - - + workerCancelled(); - } + } return r; } @@ -234,17 +232,15 @@ public abstract class CancellableWorker implements RunnableFuture { @Override public final T get(long timeout, TimeUnit unit) throws InterruptedException, - ExecutionException, TimeoutException { + ExecutionException, TimeoutException { return future.get(timeout, unit); } @Override public String toString() { - return "[CancellableWorker \"" + name + "\" on thread " + thread +", subworkers: " + subWorkers.size() + ", " + (canceled ? " canceled" : "") + ", " + (parentWorker != null ? "HASPARENT" : "NOPARENT"); + return "[CancellableWorker \"" + name + "\" on thread " + thread + ", subworkers: " + subWorkers.size() + ", " + (canceled ? " canceled" : "") + ", " + (parentWorker != null ? "HASPARENT" : "NOPARENT"); } - - private void workerDone() { if (thread != null && thread2Worker.get(thread) == this) { //thread2Worker.remove(thread); @@ -255,6 +251,7 @@ public abstract class CancellableWorker implements RunnableFuture { /** * Calls a callable with a timeout. + * * @param name Name * @param c Callable * @param timeout Timeout @@ -265,7 +262,7 @@ public abstract class CancellableWorker implements RunnableFuture { * @throws ExecutionException On execution error * @throws TimeoutException On timeout */ - public static T call(String name, final Callable c, long timeout, TimeUnit timeUnit) throws InterruptedException, ExecutionException, TimeoutException { + public static T call(String name, final Callable c, long timeout, TimeUnit timeUnit) throws InterruptedException, ExecutionException, TimeoutException { CancellableWorker worker = new CancellableWorker(name) { @Override @@ -279,7 +276,7 @@ public abstract class CancellableWorker implements RunnableFuture { } finally { worker.cancel(true); } - } + } /** * Cancels all background threads. @@ -295,7 +292,7 @@ public abstract class CancellableWorker implements RunnableFuture { } } } - + public static void cancelThread(Thread t) { List ws = new ArrayList<>(workers); for (CancellableWorker w : ws) { @@ -304,7 +301,7 @@ public abstract class CancellableWorker implements RunnableFuture { w.cancel(true); } } - } + } } /** @@ -316,7 +313,7 @@ public abstract class CancellableWorker implements RunnableFuture { w.free(); } } - + @SuppressWarnings("unchecked") private void printTree(List out) { out.add("worker " + name + " on thread " + thread); @@ -324,32 +321,32 @@ public abstract class CancellableWorker implements RunnableFuture { for (CancellableWorker sw : sws) { List subout = new ArrayList<>(); sw.printTree(subout); - for (String s:subout) { + for (String s : subout) { out.add("-" + s); } } } - + + public void printTree() { + System.err.println("======================="); + List out = new ArrayList<>(); + printTree(out); + for (String s : out) { + System.err.println(s); + } + System.err.println("/======================="); + } + public static void printAllWorkers() { List aw = new ArrayList<>(workers); - + System.err.println("====ALL WORKERS ===="); for (CancellableWorker w : aw) { System.err.println("" + w); } System.err.println("/===================="); } - - public void printTree() { - System.err.println("======================="); - List out = new ArrayList<>(); - printTree(out); - for (String s:out) { - System.err.println(s); - } - System.err.println("/======================="); - } - + public void startWorkerMonitor() { Thread monit = new Thread() { @Override @@ -364,8 +361,8 @@ public abstract class CancellableWorker implements RunnableFuture { return; } } - } + } }; - monit.start(); + monit.start(); } } diff --git a/src/com/jpexs/decompiler/flash/console/CommandLineArgumentParser.java b/src/com/jpexs/decompiler/flash/console/CommandLineArgumentParser.java index d0e243f55..f4c1c1ec9 100644 --- a/src/com/jpexs/decompiler/flash/console/CommandLineArgumentParser.java +++ b/src/com/jpexs/decompiler/flash/console/CommandLineArgumentParser.java @@ -132,8 +132,8 @@ import com.jpexs.decompiler.flash.importers.SpriteImporter; import com.jpexs.decompiler.flash.importers.SwfXmlImporter; import com.jpexs.decompiler.flash.importers.SymbolClassImporter; import com.jpexs.decompiler.flash.importers.TextImporter; -import com.jpexs.decompiler.flash.importers.amf.amf3.Amf3Importer; import com.jpexs.decompiler.flash.importers.amf.AmfParseException; +import com.jpexs.decompiler.flash.importers.amf.amf3.Amf3Importer; import com.jpexs.decompiler.flash.importers.svg.SvgImporter; import com.jpexs.decompiler.flash.tags.ABCContainerTag; import com.jpexs.decompiler.flash.tags.DefineBinaryDataTag; @@ -361,7 +361,7 @@ public class CommandLineArgumentParser { if (filter == null) { out.println(PREFIX + "myfile.swf"); exampleFound = true; - } + } if (filter == null || filter.equals("export") || filter.equals("format") || filter.equals("selectclass") || filter.equals("onerror")) { out.println(PREFIX + "-export script \"C:\\decompiled\" myfile.swf"); @@ -1741,7 +1741,7 @@ public class CommandLineArgumentParser { System.err.println("Process affinity setting is only available on Windows platform."); } } - + private static void parseChangeImport(Stack args, Map changedImports) { if (args.size() < 2) { System.err.println("source and target of import expected"); @@ -1749,7 +1749,7 @@ public class CommandLineArgumentParser { } changedImports.put(args.pop(), args.pop()); } - + private static UrlResolver parseImportAssets(Stack args, Map changedImports) { if (args.isEmpty()) { System.err.println("importassets options expected"); @@ -1760,7 +1760,7 @@ public class CommandLineArgumentParser { boolean doResolve = false; boolean doAsk = false; boolean localOnly = false; - for (String impOption:impOptionsArr) { + for (String impOption : impOptionsArr) { switch (impOption) { case "yes": doResolve = true; @@ -2068,7 +2068,7 @@ 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 { @@ -2247,7 +2247,7 @@ public class CommandLineArgumentParser { boolean exportAs3Script = exportAllScript || exportFormats.contains("script_as3"); if (exportAs2Script || exportAs3Script) { System.out.println("Exporting scripts..."); - + String scriptsFolder = Path.combine(outDir, ScriptExportSettings.EXPORT_FOLDER_NAME); Path.createDirectorySafe(new File(scriptsFolder)); String singleFileName = Path.combine(scriptsFolder, swf.getShortFileName() + scriptExportSettings.getFileExtension()); @@ -3516,7 +3516,7 @@ public class CommandLineArgumentParser { if (format == null) { format = "html"; } - + if (!format.equals("html")) { badArguments("doc"); } diff --git a/src/com/jpexs/decompiler/flash/console/ConsoleUrlResolver.java b/src/com/jpexs/decompiler/flash/console/ConsoleUrlResolver.java index cf73bb2fd..322cc1cd9 100644 --- a/src/com/jpexs/decompiler/flash/console/ConsoleUrlResolver.java +++ b/src/com/jpexs/decompiler/flash/console/ConsoleUrlResolver.java @@ -32,6 +32,7 @@ import java.util.Scanner; /** * Console Url resolver + * * @author JPEXS */ public class ConsoleUrlResolver implements UrlResolver { @@ -42,7 +43,7 @@ public class ConsoleUrlResolver implements UrlResolver { private boolean ignoredInfoPrinted = false; private Character toAll = null; - + private Map importSources = new HashMap<>(); /** @@ -64,14 +65,14 @@ public class ConsoleUrlResolver implements UrlResolver { Character choice = toAll; String currentUrl = url; - + if (importSources.containsKey(url)) { currentUrl = importSources.get(url); if (currentUrl.isEmpty()) { return null; } choice = 'y'; - } else { + } else { if (choice == null && doResolve) { choice = 'y'; } @@ -86,9 +87,8 @@ public class ConsoleUrlResolver implements UrlResolver { choice = ask(url); } } - - - while(choice != 'n') { + + while (choice != 'n') { if (choice == 'c') { System.out.println("Enter new location instead (empty to cancel):"); Scanner sc = new Scanner(System.in); @@ -115,7 +115,7 @@ public class ConsoleUrlResolver implements UrlResolver { File swf = new File(new File(basePath).getParentFile(), currentUrl); if (swf.exists()) { try { - SWF ret = open(new FileInputStream(swf), swf.getAbsolutePath(), swf.getName()); + SWF ret = open(new FileInputStream(swf), swf.getAbsolutePath(), swf.getName()); return ret; } catch (Exception ex) { //ignore @@ -144,10 +144,10 @@ public class ConsoleUrlResolver implements UrlResolver { } return null; } - + private SWF open(InputStream is, String file, String fileTitle) throws Exception { OpenableSourceInfo sourceInfo = new OpenableSourceInfo(is, file, fileTitle); - return new SWF(new BufferedInputStream(is), sourceInfo.getFile(), sourceInfo.getFileTitle(), null, Configuration.parallelSpeedUp.get(), false, true, this, null /*??*/); + return new SWF(new BufferedInputStream(is), sourceInfo.getFile(), sourceInfo.getFileTitle(), null, Configuration.parallelSpeedUp.get(), false, true, this, null /*??*/); } private String prompt() { diff --git a/src/com/jpexs/decompiler/flash/easygui/CharacterTagTransferHandler.java b/src/com/jpexs/decompiler/flash/easygui/CharacterTagTransferHandler.java index e0029111a..646573de4 100644 --- a/src/com/jpexs/decompiler/flash/easygui/CharacterTagTransferHandler.java +++ b/src/com/jpexs/decompiler/flash/easygui/CharacterTagTransferHandler.java @@ -17,7 +17,6 @@ package com.jpexs.decompiler.flash.easygui; import com.jpexs.decompiler.flash.tags.DefineSpriteTag; -import com.jpexs.decompiler.flash.tags.Tag; import com.jpexs.decompiler.flash.tags.base.ButtonTag; import com.jpexs.decompiler.flash.tags.base.CharacterTag; import com.jpexs.decompiler.flash.tags.base.ShapeTag; @@ -32,29 +31,30 @@ import javax.swing.tree.DefaultMutableTreeNode; * * @author JPEXS */ - class CharacterTagTransferHandler extends TransferHandler { +class CharacterTagTransferHandler extends TransferHandler { - @Override - protected Transferable createTransferable(JComponent c) { - JTreeTable table = (JTreeTable) c; - int selectedRow = table.getSelectedRow(); + @Override + protected Transferable createTransferable(JComponent c) { + JTreeTable table = (JTreeTable) c; + int selectedRow = table.getSelectedRow(); - if (selectedRow >= 0) { - DefaultMutableTreeNode mn = (DefaultMutableTreeNode) table.getModel().getValueAt(selectedRow, 0); - Object o = mn.getUserObject(); - if ((o instanceof DefineSpriteTag) - || (o instanceof ShapeTag) - || (o instanceof TextTag) - || (o instanceof ButtonTag) - ) { - return new CharacterTagTransferable((CharacterTag) o); - } + if (selectedRow >= 0) { + DefaultMutableTreeNode mn = (DefaultMutableTreeNode) table.getModel().getValueAt(selectedRow, 0); + Object o = mn.getUserObject(); + if ( + (o instanceof DefineSpriteTag) + || (o instanceof ShapeTag) + || (o instanceof TextTag) + || (o instanceof ButtonTag) + ) { + return new CharacterTagTransferable((CharacterTag) o); } - return null; - } - - @Override - public int getSourceActions(JComponent c) { - return COPY; } + return null; } + + @Override + public int getSourceActions(JComponent c) { + return COPY; + } +} diff --git a/src/com/jpexs/decompiler/flash/easygui/EasyPanel.java b/src/com/jpexs/decompiler/flash/easygui/EasyPanel.java index 72a3eec27..ceedb9ca7 100644 --- a/src/com/jpexs/decompiler/flash/easygui/EasyPanel.java +++ b/src/com/jpexs/decompiler/flash/easygui/EasyPanel.java @@ -29,15 +29,16 @@ import javax.swing.JPanel; * @author JPEXS */ public class EasyPanel extends JPanel { - + /** - * TODO: switch to true when Easy mode is released. - * I think it's not production ready yet. + * TODO: switch to true when Easy mode is released. I think it's not + * production ready yet. */ public static final boolean EASY_AVAILABLE = true; - + private TabSwitcher tabSwitcher; private EasySwfPanel easySwfPanel; + public EasyPanel(MainPanel mainPanel) { easySwfPanel = new EasySwfPanel(mainPanel); tabSwitcher = new TabSwitcher<>(easySwfPanel); @@ -47,30 +48,30 @@ public class EasyPanel extends JPanel { @Override public void tabSwitched(SWF value) { easySwfPanel.setTimelined(value); - } + } }); } - + public void setSwfs(List swfs) { tabSwitcher.clear(); for (SWF swf : swfs) { tabSwitcher.addTab(swf, swf.getShortPathTitle(), View.getIcon("flash16")); - } + } easySwfPanel.clearUndos(); } - + public void setSwf(SWF swf) { tabSwitcher.setValue(swf); } - + public void setNoSwf() { easySwfPanel.setTimelined(null); } - + public SWF getSwf() { return tabSwitcher.getSelectedValue(); } - + public void dispose() { setSwfs(new ArrayList<>()); easySwfPanel.dispose(); diff --git a/src/com/jpexs/decompiler/flash/easygui/EasySwfPanel.java b/src/com/jpexs/decompiler/flash/easygui/EasySwfPanel.java index e42352488..12cb577fe 100644 --- a/src/com/jpexs/decompiler/flash/easygui/EasySwfPanel.java +++ b/src/com/jpexs/decompiler/flash/easygui/EasySwfPanel.java @@ -100,7 +100,7 @@ public class EasySwfPanel extends JPanel { private JLabel timelineLabel; private JButton closeTimelineButton; private JPanel propertiesPanel; - + private static final String PROPERTIES_DOCUMENT = "Document"; private static final String PROPERTIES_INSTANCE = "Instance"; private DocumentPropertiesPanel documentPropertiesPanel; @@ -115,7 +115,7 @@ public class EasySwfPanel extends JPanel { stagePanel.setShowAllDepthLevelsInfo(false); stagePanel.setSelectionMode(true); stagePanel.setMultiSelect(true); - + stagePanel.addEventListener(new MediaDisplayListener() { @Override public void mediaDisplayStateChanged(MediaDisplay source) { @@ -124,9 +124,9 @@ public class EasySwfPanel extends JPanel { @Override public void run() { setTimelined(stagePanel.getTimelined(), false); - } + } }); - + } } @@ -136,9 +136,9 @@ public class EasySwfPanel extends JPanel { @Override public void statusChanged(String status) { - } + } }); - + stagePanel.addPlaceObjectSelectedListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -160,24 +160,24 @@ public class EasySwfPanel extends JPanel { final RegistrationPointPosition regPointPos = stagePanel.getRegistrationPointPosition(); final List fpreviousMatrices = new ArrayList<>(); + - { - List dss = getSelectedDepthStates(); - for (DepthState ds : dss) { - if (ds == null) { - fpreviousMatrices.add(null); - } else { - fpreviousMatrices.add(ds.matrix); - } + List dss = getSelectedDepthStates(); + for (DepthState ds : dss) { + if (ds == null) { + fpreviousMatrices.add(null); + } else { + fpreviousMatrices.add(ds.matrix); } } + final boolean transformEnabled = transformEnabled(); undoManager.doOperation(new DoableOperation() { private final List wasModified = new ArrayList<>(); Timelined timelined = stagePanel.getTimelined(); - + @Override public void doOperation() { if (timelined != EasySwfPanel.this.timelined) { @@ -187,13 +187,13 @@ public class EasySwfPanel extends JPanel { for (int i = 0; i < depths.size(); i++) { int depth = depths.get(i); DepthState ds = stagePanel.getTimelined().getTimeline().getFrame(frame).layers.get(depth); - wasModified.add(ds.placeObjectTag.isModified()); - + wasModified.add(ds.placeObjectTag.isModified()); + Matrix contMat = newMatrix.concatenate(new Matrix(fpreviousMatrices.get(i))); - + ds.placeObjectTag.setMatrix(contMat.toMATRIX()); ds.placeObjectTag.setPlaceFlagHasMatrix(newMatrix != null); - ds.placeObjectTag.setModified(true); + ds.placeObjectTag.setModified(true); } timelined.resetTimeline(); stagePanel.repaint(); @@ -260,24 +260,23 @@ public class EasySwfPanel extends JPanel { if ((tag instanceof DefineSpriteTag) || (tag instanceof ShapeTag) || (tag instanceof TextTag) - || (tag instanceof ButtonTag) - ) { + || (tag instanceof ButtonTag)) { undoManager.doOperation(new TimelinedTagListDoableOperation(EasySwfPanel.this, stagePanel.getTimelined()) { - + private List swfTags; - + @Override public void doOperation() { super.doOperation(); CharacterTag ch = (CharacterTag) tag; int maxDepth = timelined.getTimeline().getMaxDepth(); int newDepth = maxDepth + 1; - + if (timelined.getSwf() != timelined) { swfTags = timelined.getSwf().getTags().toArrayList(); } - + ShowFrameTag showFrameTag = timelined.getTimeline().getFrame(fframe).showFrameTag; PlaceObject2Tag place = new PlaceObject2Tag(timelined.getSwf()); place.depth = newDepth; @@ -290,21 +289,20 @@ public class EasySwfPanel extends JPanel { timelined.addTag(place); } else { timelined.addTag(timelined.indexOfTag(showFrameTag), place); - + RemoveObject2Tag remove = new RemoveObject2Tag(timelined.getSwf()); remove.depth = newDepth; - timelined.addTag(timelined.indexOfTag(showFrameTag) + 1, remove); + timelined.addTag(timelined.indexOfTag(showFrameTag) + 1, remove); } - - + DefineBeforeUsageFixer fixer = new DefineBeforeUsageFixer(); boolean tagOrderChanged = fixer.fixDefineBeforeUsage(timelined.getSwf()); if (!tagOrderChanged) { swfTags = null; } - + timelined.resetTimeline(); - stagePanel.repaint(); + stagePanel.repaint(); timelinePanel.refresh(); timelinePanel.setDepth(newDepth); } @@ -313,7 +311,7 @@ public class EasySwfPanel extends JPanel { public void undoOperation() { super.undoOperation(); timelined.resetTimeline(); - + //Tag order changed, put the original tags back if (swfTags != null) { SWF swf = timelined.getSwf(); @@ -322,11 +320,11 @@ public class EasySwfPanel extends JPanel { for (int i = 0; i < size; i++) { swf.removeTag(0); } - for (int i = 0; i < swfTags.size(); i++) { + for (int i = 0; i < swfTags.size(); i++) { swf.addTag(swfTags.get(i)); } swf.resetTimeline(); - } + } stagePanel.repaint(); timelinePanel.refresh(); timelinePanel.setFrame(fframe, fdepths); @@ -354,8 +352,6 @@ public class EasySwfPanel extends JPanel { JPanel topPanel = new JPanel(new BorderLayout()); - - undoButton = new JButton(View.getIcon("rotateanticlockwise16")); //undoButton.setToolTipText("Undo"); undoButton.setMargin(new Insets(5, 5, 5, 5)); @@ -380,7 +376,7 @@ public class EasySwfPanel extends JPanel { redoButton.setEnabled(false); undoButton.setToolTipText(EasyStrings.translate("undo.cannot")); redoButton.setToolTipText(EasyStrings.translate("redo.cannot")); - + Runnable undoChangeListener = new Runnable() { @Override public void run() { @@ -390,7 +386,6 @@ public class EasySwfPanel extends JPanel { undoManager.addChangeListener(undoChangeListener); - JPanel toolbarPanel = new JPanel(new BorderLayout()); JPanel leftToolbar = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); leftToolbar.add(undoButton); @@ -400,31 +395,31 @@ public class EasySwfPanel extends JPanel { leftToolbar.add(timelineLabel); leftToolbar.add(Box.createHorizontalStrut(5)); closeTimelineButton = new JButton(View.getIcon("cancel16")); - closeTimelineButton.setMargin(new Insets(5, 5, 5, 5)); + closeTimelineButton.setMargin(new Insets(5, 5, 5, 5)); leftToolbar.add(closeTimelineButton); closeTimelineButton.setToolTipText(EasyStrings.translate("timeline.item.cancel")); closeTimelineButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setTimelined(timelined.getSwf()); - } + } }); - + toolbarPanel.add(leftToolbar, BorderLayout.WEST); - + ZoomPanel zoomPanel = new ZoomPanel(stagePanel); toolbarPanel.add(zoomPanel, BorderLayout.EAST); - + topPanel.add(toolbarPanel, BorderLayout.NORTH); topPanel.add(stagePanel, BorderLayout.CENTER); timelinePanel = new TimelinePanel(this, undoManager); - + timelinePanel.addChangeListener(new Runnable() { @Override public void run() { stagePanel.repaint(); - } + } }); timelinePanel.addFrameSelectionListener(new FrameSelectionListener() { @Override @@ -435,12 +430,12 @@ public class EasySwfPanel extends JPanel { if (transformEnabled()) { stagePanel.freeTransformDepths(depths); } - + transformPanel.setVisible(!depths.isEmpty()); updatePropertiesPanel(); } }); - + verticalSplitPane = new JPersistentSplitPane(JSplitPane.VERTICAL_SPLIT, topPanel, timelinePanel, Configuration.guiSplitPaneEasyVerticalDividerLocationPercent); libraryTreeTable = new LibraryTreeTable(this); @@ -457,17 +452,15 @@ public class EasySwfPanel extends JPanel { libraryPreviewPanel.setPreferredSize(new Dimension(200, 200)); rightTabbedPane = new JTabbedPane(); - - + propertiesPanel = new JPanel(); documentPropertiesPanel = new DocumentPropertiesPanel(undoManager); propertiesPanel.setLayout(new CardLayout()); - + instancePropertiesPanel = new InstancePropertiesPanel(this, undoManager); propertiesPanel.add(documentPropertiesPanel, PROPERTIES_DOCUMENT); propertiesPanel.add(instancePropertiesPanel, PROPERTIES_INSTANCE); - - + rightTabbedPane.addTab(EasyStrings.translate("properties"), propertiesPanel); rightTabbedPane.addTab(EasyStrings.translate("library"), libraryPanel); @@ -482,12 +475,12 @@ public class EasySwfPanel extends JPanel { public void stateChanged(ChangeEvent e) { if (stagePanel.getTimelined() == null) { return; - } + } List depths = stagePanel.getSelectedDepths(); if (stagePanel.getFrame() >= stagePanel.getTimelined().getFrameCount()) { depths.clear(); } - if (!depths.isEmpty()) { + if (!depths.isEmpty()) { Frame frame = stagePanel.getTimelined().getTimeline().getFrame(stagePanel.getFrame()); if (frame == null) { depths.clear(); @@ -498,7 +491,7 @@ public class EasySwfPanel extends JPanel { depths.remove(i); i--; } - } + } } } transformPanel.setVisible(!depths.isEmpty()); @@ -552,17 +545,18 @@ public class EasySwfPanel extends JPanel { return; } instancePropertiesPanel.update(); - cl.show(propertiesPanel, PROPERTIES_INSTANCE); + cl.show(propertiesPanel, PROPERTIES_INSTANCE); } - + private boolean transformEnabled() { return rightTabbedPane.getSelectedIndex() == 2; } - - public void setTimelined(Timelined timelined) { + + public void setTimelined(Timelined timelined) { setTimelined(timelined, true); } - private void setTimelined(Timelined timelined, boolean updateStage) { + + private void setTimelined(Timelined timelined, boolean updateStage) { if (this.timelined == timelined) { return; } @@ -589,7 +583,7 @@ public class EasySwfPanel extends JPanel { stagePanel.pause(); stagePanel.gotoFrame(0); } - timelinePanel.setTimelined(timelined); + timelinePanel.setTimelined(timelined); if (timelined instanceof SWF) { timelineLabel.setText(EasyStrings.translate("timeline.main")); closeTimelineButton.setVisible(false); @@ -606,16 +600,16 @@ public class EasySwfPanel extends JPanel { public Openable getOpenable() { return timelined.getSwf(); } - + public void clearUndos() { undoManager.clear(); } - + private void updateUndos() { undoButton.setEnabled(timelined != null && undoManager.canUndo(timelined.getSwf())); redoButton.setEnabled(timelined != null && undoManager.canRedo(timelined.getSwf())); if (timelined != null && undoManager.canUndo(timelined.getSwf())) { - undoButton.setToolTipText(EasyStrings.translate("undo").replace("%action%",undoManager.getUndoName(timelined.getSwf()))); + undoButton.setToolTipText(EasyStrings.translate("undo").replace("%action%", undoManager.getUndoName(timelined.getSwf()))); } else { undoButton.setToolTipText(EasyStrings.translate("undo.cannot")); } @@ -629,28 +623,28 @@ public class EasySwfPanel extends JPanel { } Main.getMainFrame().getPanel().updateUiWithCurrentOpenable(); } - + public void dispose() { setTimelined(null); undoManager.clear(); } - + public List getDepths() { return stagePanel.getSelectedDepths(); } - + public int getFrame() { return stagePanel.getFrame(); } public ImagePanel getStagePanel() { return stagePanel; - } - + } + public SWF getSwf() { return timelined == null ? null : timelined.getSwf(); } - + public List getSelectedDepthStates() { if (timelined == null) { return null; @@ -663,6 +657,7 @@ public class EasySwfPanel extends JPanel { } return ret; } + public List getSelectedPlaceTags() { List dss = getSelectedDepthStates(); if (dss == null) { @@ -675,15 +670,15 @@ public class EasySwfPanel extends JPanel { } else { ret.add(ds.placeObjectTag); } - } + } return ret; } public Timelined getTimelined() { return timelined; - } - + } + public void setFrame(int frame, List depths) { timelinePanel.setFrame(frame, depths); - } -} \ No newline at end of file + } +} diff --git a/src/com/jpexs/decompiler/flash/easygui/LibraryTreeTable.java b/src/com/jpexs/decompiler/flash/easygui/LibraryTreeTable.java index ec858fdb9..543ecbad2 100644 --- a/src/com/jpexs/decompiler/flash/easygui/LibraryTreeTable.java +++ b/src/com/jpexs/decompiler/flash/easygui/LibraryTreeTable.java @@ -56,15 +56,15 @@ public class LibraryTreeTable extends JTreeTable { private final EasySwfPanel easySwfPanel; private SWF swf; - + public LibraryTreeTable(EasySwfPanel easySwfPanel) { - super(new LibraryTreeTableModel(null)); + super(new LibraryTreeTableModel(null)); getTree().setCellRenderer(new LibraryTreeCellRenderer()); getTree().setRootVisible(false); getTree().setShowsRootHandles(true); addKeyListener(new KeyAdapter() { @Override - public void keyPressed(KeyEvent e) { + public void keyPressed(KeyEvent e) { int selectedRow = getSelectedRow(); JTree tree = getTree(); @@ -72,7 +72,7 @@ public class LibraryTreeTable extends JTreeTable { TreePath path = tree.getPathForRow(selectedRow); if (path != null && tree.isExpanded(path)) { tree.collapsePath(path); - + int parentRow = tree.getRowForPath(path); changeSelection(parentRow, 0, false, false); } else if (path != null) { @@ -106,16 +106,16 @@ public class LibraryTreeTable extends JTreeTable { setDragEnabled(true); setSelectionMode(ListSelectionModel.SINGLE_SELECTION); setUI(new BasicTableUI()); - + setRowHeight(18); getTree().setRowHeight(18); - + if (View.isOceanic()) { setBackground(Color.WHITE); getTree().setBackground(Color.WHITE); } this.easySwfPanel = easySwfPanel; - + addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { @@ -130,11 +130,11 @@ public class LibraryTreeTable extends JTreeTable { easySwfPanel.setTimelined((Timelined) obj); } } - } + } }); - + } - + public void setSwf(SWF swf) { if (swf == this.swf) { return; @@ -142,13 +142,12 @@ public class LibraryTreeTable extends JTreeTable { this.swf = swf; setTreeTableModel(new LibraryTreeTableModel(swf)); } - - + private static class LibraryTreeCellRenderer extends DefaultTreeCellRenderer { @Override public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) { - JLabel label = (JLabel) super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus); + JLabel label = (JLabel) super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus); if (!leaf) { if (expanded) { label.setIcon(View.getIcon("folderopen16")); @@ -161,7 +160,7 @@ public class LibraryTreeTable extends JTreeTable { Object object = node.getUserObject(); if (object instanceof ImageTag) { ImageTag it = (ImageTag) object; - label.setIcon(View.getIcon("image16")); + label.setIcon(View.getIcon("image16")); } if (object instanceof ShapeTag) { ShapeTag st = (ShapeTag) object; @@ -209,16 +208,16 @@ public class LibraryTreeTable extends JTreeTable { label.setOpaque(true); } return label; - } + } } - + private static class LibraryTreeTableModel implements TreeTableModel { private DefaultMutableTreeNode root; public LibraryTreeTableModel(SWF swf) { DefaultMutableTreeNode root = new DefaultMutableTreeNode("SWF"); - + DefaultMutableTreeNode imagesNode = new DefaultMutableTreeNode(EasyStrings.translate("library.folder.images")); DefaultMutableTreeNode graphicsNode = new DefaultMutableTreeNode(EasyStrings.translate("library.folder.graphics")); DefaultMutableTreeNode shapeTweensNode = new DefaultMutableTreeNode(EasyStrings.translate("library.folder.shapeTweens")); @@ -229,10 +228,9 @@ public class LibraryTreeTable extends JTreeTable { DefaultMutableTreeNode soundsNode = new DefaultMutableTreeNode(EasyStrings.translate("library.folder.sounds")); DefaultMutableTreeNode videosNode = new DefaultMutableTreeNode(EasyStrings.translate("library.folder.videos")); - this.root = root; - - if (swf == null) { + + if (swf == null) { return; } for (Tag t : swf.getTags()) { @@ -257,13 +255,13 @@ public class LibraryTreeTable extends JTreeTable { } if (t instanceof ButtonTag) { buttonsNode.add(node); - } + } if (t instanceof SoundTag) { soundsNode.add(node); } if (t instanceof DefineVideoStreamTag) { videosNode.add(node); - } + } } if (!imagesNode.isLeaf()) { @@ -292,11 +290,9 @@ public class LibraryTreeTable extends JTreeTable { } if (!videosNode.isLeaf()) { root.add(videosNode); - } + } } - - - + @Override public int getColumnCount() { return 2; @@ -318,11 +314,11 @@ public class LibraryTreeTable extends JTreeTable { public Class getColumnClass(int column) { switch (column) { case 0: - return TreeTableModel.class; + return TreeTableModel.class; default: return String.class; } - + } @Override @@ -332,7 +328,7 @@ public class LibraryTreeTable extends JTreeTable { switch (column) { case 0: return node; - case 1: + case 1: if (o instanceof CharacterTag) { CharacterTag ct = (CharacterTag) o; if (!ct.getClassNames().isEmpty()) { @@ -359,7 +355,7 @@ public class LibraryTreeTable extends JTreeTable { @Override public void setValueAt(Object value, Object node, int column) { - + } @Override @@ -389,7 +385,7 @@ public class LibraryTreeTable extends JTreeTable { @Override public int getIndexOfChild(Object parent, Object child) { - return ((DefaultMutableTreeNode) parent).getIndex((DefaultMutableTreeNode)child); + return ((DefaultMutableTreeNode) parent).getIndex((DefaultMutableTreeNode) child); } @Override @@ -399,6 +395,6 @@ public class LibraryTreeTable extends JTreeTable { @Override public void removeTreeModelListener(TreeModelListener l) { } - + } } diff --git a/src/com/jpexs/decompiler/flash/easygui/TimelineBodyPanel.java b/src/com/jpexs/decompiler/flash/easygui/TimelineBodyPanel.java index 8a98c9fe4..d9f4f25b7 100644 --- a/src/com/jpexs/decompiler/flash/easygui/TimelineBodyPanel.java +++ b/src/com/jpexs/decompiler/flash/easygui/TimelineBodyPanel.java @@ -119,7 +119,6 @@ public class TimelineBodyPanel extends JPanel implements MouseListener, KeyListe private int depth = 0; private int endDepth = 0;*/ - private final UndoManager undoManager; private boolean ctrlDown = false; @@ -390,19 +389,17 @@ public class TimelineBodyPanel extends JPanel implements MouseListener, KeyListe /*if (cursor != null && cursor.contains(frame, depth) && !cursor.contains(frame + num_frames, depth)) {//frame <= cursor.x && (frame + num_frames) > cursor.x && depth == cursor.y) { selected = true; }*/ - for (int n = frame + 1; n < frame + num_frames; n++) { g.setColor(getSelectedColor()); if (cursor.contains(new Point(n, depth))) { g.fillRect(n * frameWidth + 1, depth * frameHeight + 1, frameWidth, frameHeight); } } - + /*if (selected) { g.setColor(getSelectedColor()); g.fillRect(cursor.x * frameWidth + 1, depth * frameHeight + 1, (cursor.width * frameWidth) - 1, frameHeight - 1); }*/ - boolean isTween = blockType == BlockType.MOTION_TWEEN || blockType == BlockType.SHAPE_TWEEN; g.setColor(KEY_COLOR); @@ -468,11 +465,11 @@ public class TimelineBodyPanel extends JPanel implements MouseListener, KeyListe public void depthSelect(int depth) { frameSelect(getFirstFrame(), Arrays.asList(depth)); } - + public void depthsSelect(List depths) { frameSelect(getFirstFrame(), depths); } - + public int getFirstFrame() { if (cursor.isEmpty()) { return 0; @@ -487,7 +484,6 @@ public class TimelineBodyPanel extends JPanel implements MouseListener, KeyListe return cursor.iterator().next().y; } - public void rectSelect(int frame, int depth, int endFrame, int endDepth) { int x1 = Math.min(frame, endFrame); int x2 = Math.max(frame, endFrame); @@ -504,7 +500,7 @@ public class TimelineBodyPanel extends JPanel implements MouseListener, KeyListe } cursor.clear(); cursor.addAll(newCursor); - + /*cursor = new Rectangle( x1, y1, @@ -523,11 +519,11 @@ public class TimelineBodyPanel extends JPanel implements MouseListener, KeyListe fireFrameSelected(frame, depths); } - public void frameSelect(int frame, int depth) { + public void frameSelect(int frame, int depth) { frameSelect(frame, Arrays.asList(depth)); } - - public void frameSelect(int frame, List depths) { + + public void frameSelect(int frame, List depths) { /*if (cursor != null && cursor.width == 1 && cursor.height == 1 && (cursor.contains(frame, depth) || (depth == -1 && cursor.contains(frame, cursor.y)))) { return; } @@ -535,27 +531,26 @@ public class TimelineBodyPanel extends JPanel implements MouseListener, KeyListe depth = cursor.y; }*/ //rectSelect(frame, depth, frame, depth); - + Set newCursor = new LinkedHashSet<>(); - + for (int d : depths) { newCursor.add(new Point(frame, d)); } if (depths.isEmpty()) { newCursor.add(new Point(frame, 0)); } - + cursor.clear(); cursor.addAll(newCursor); - + repaint(); - + /* this.frame = frame; this.depth = depths.isEmpty() ? 0 : depths.get(0); this.endFrame = frame; - */ - + */ fireFrameSelected(frame, depths); } @@ -585,7 +580,7 @@ public class TimelineBodyPanel extends JPanel implements MouseListener, KeyListe } else if (ctrlDown) { int frame = getFirstFrame(); if (cursor.contains(p)) { - cursor.remove(p); + cursor.remove(p); } else { cursor.add(p); } @@ -594,8 +589,8 @@ public class TimelineBodyPanel extends JPanel implements MouseListener, KeyListe if (t.x == frame) { newDepths.add(t.y); } - } - + } + repaint(); fireFrameSelected(frame, newDepths); } else { @@ -610,7 +605,7 @@ public class TimelineBodyPanel extends JPanel implements MouseListener, KeyListe int frame = getFirstFrame(); int depth = getFirstDepth(); - + Frame fr = timeline.getFrame(frame); DepthState ds = fr == null ? null : fr.layers.get(depth); boolean thisEmpty = ds == null || ds.getCharacter() == null; @@ -676,7 +671,7 @@ public class TimelineBodyPanel extends JPanel implements MouseListener, KeyListe } private Set getBackOrderedCursor() { - Set orderedCursor = new TreeSet<>(new Comparator() { + Set orderedCursor = new TreeSet<>(new Comparator() { @Override public int compare(Point o1, Point o2) { int dx = o2.x - o1.x; //later frames first @@ -684,14 +679,14 @@ public class TimelineBodyPanel extends JPanel implements MouseListener, KeyListe return dx; } return o1.y - o2.y; - } + } }); orderedCursor.addAll(cursor); return orderedCursor; } - - private void removeFrame(ActionEvent e) { - + + private void removeFrame(ActionEvent e) { + Set orderedCursor = getBackOrderedCursor(); undoManager.doOperation(new TimelinedTagListDoableOperation(swfPanel, timeline.timelined) { @@ -703,7 +698,7 @@ public class TimelineBodyPanel extends JPanel implements MouseListener, KeyListe for (Point p : orderedCursor) { int nf = p.x; - int nd = p.y; + int nd = p.y; int f = timelined.getFrameCount(); List lastFrameDepthTags = new ArrayList<>(); @@ -786,7 +781,7 @@ public class TimelineBodyPanel extends JPanel implements MouseListener, KeyListe timelined.addTag(lt); } } - } + } timelined.resetTimeline(); @@ -878,7 +873,7 @@ public class TimelineBodyPanel extends JPanel implements MouseListener, KeyListe //timelined.addTag(pos++, rm); timelined.addTag(pos++, place); - } + } timelined.resetTimeline(); timeline = timelined.getTimeline(); @@ -911,11 +906,10 @@ public class TimelineBodyPanel extends JPanel implements MouseListener, KeyListe @Override public void doOperation() { super.doOperation(); - Timelined timelined = timeline.timelined; - - + Timelined timelined = timeline.timelined; + DepthState ds = null; - + if (fframe >= timelined.getFrameCount()) { int lastFrame = timelined.getFrameCount() - 1; for (int d = 1; d <= timeline.maxDepth; d++) { @@ -924,10 +918,10 @@ public class TimelineBodyPanel extends JPanel implements MouseListener, KeyListe RemoveTag rt = new RemoveObject2Tag(timelined.getSwf()); rt.setTimelined(timelined); rt.setDepth(d); - timelined.addTag(rt); + timelined.addTag(rt); } } - + for (int f = timelined.getFrameCount(); f <= fframe; f++) { ShowFrameTag sf = new ShowFrameTag(timelined.getSwf()); sf.setTimelined(timelined); @@ -936,8 +930,7 @@ public class TimelineBodyPanel extends JPanel implements MouseListener, KeyListe } timelined.resetTimeline(); } - - + for (int f = fframe - 1; f >= 0; f--) { ds = timeline.getDepthState(f, fdepth); if (ds != null && ds.getCharacter() != null) { @@ -996,14 +989,13 @@ public class TimelineBodyPanel extends JPanel implements MouseListener, KeyListe super.doOperation(); DepthState ds; Timelined timelined = timeline.timelined; - //for (int nf = 0; nf < fendFrame - fframe + 1; nf++) { // for (int nd = fdepth; nd <= fendDepth; nd++) for (Point p : orderedCursor) { int nf = p.x; int nd = p.y; - + if (nf >= timelined.getFrameCount()) { ReadOnlyTagList tags = timelined.getTags(); @@ -1022,8 +1014,8 @@ public class TimelineBodyPanel extends JPanel implements MouseListener, KeyListe break; } } - } - + } + int lastFrame = timelined.getFrameCount() - 1; //Add removeTag to other layers for (int d = 1; d <= timeline.maxDepth; d++) { @@ -1035,7 +1027,7 @@ public class TimelineBodyPanel extends JPanel implements MouseListener, KeyListe RemoveTag rt = new RemoveObject2Tag(timelined.getSwf()); rt.setTimelined(timelined); rt.setDepth(d); - timelined.addTag(rt); + timelined.addTag(rt); } } @@ -1047,8 +1039,7 @@ public class TimelineBodyPanel extends JPanel implements MouseListener, KeyListe } timelined.resetTimeline(); continue; - } - + } boolean somethingAfter = false; for (int f = nf + 1; f < timeline.getFrameCount(); f++) { @@ -1063,7 +1054,7 @@ public class TimelineBodyPanel extends JPanel implements MouseListener, KeyListe for (int f = nf; f >= 0; f--) { ds = timeline.getDepthState(f, nd); boolean empty = ds == null || ds.getCharacter() == null; - if (!empty || somethingAfter) { + if (!empty || somethingAfter) { int moveFrameCount = somethingAfter ? 1 : nf - f; for (int mf = 0; mf < moveFrameCount; mf++) { int pos = timelined.indexOfTag(timeline.getFrame(f).showFrameTag); @@ -1121,7 +1112,7 @@ public class TimelineBodyPanel extends JPanel implements MouseListener, KeyListe f2++; } } - + if ((!removeOnly && !lastFrameDepthTags.isEmpty()) || !endsWithRemove) { //Add removeTag to other layers for (int d = 1; d <= timeline.maxDepth; d++) { @@ -1142,11 +1133,11 @@ public class TimelineBodyPanel extends JPanel implements MouseListener, KeyListe timelined.addTag(sf); timelined.setFrameCount(timelined.getFrameCount() + 1); } - } + } break; } } - } + } timelined.resetTimeline(); timelined.setFrameCount(timelined.getTimeline().getFrameCount()); @@ -1192,8 +1183,8 @@ public class TimelineBodyPanel extends JPanel implements MouseListener, KeyListe } @Override - public void keyPressed(KeyEvent e) { - Point firstCursorItem = cursor.isEmpty() ? new Point(1,1) : cursor.iterator().next(); + public void keyPressed(KeyEvent e) { + Point firstCursorItem = cursor.isEmpty() ? new Point(1, 1) : cursor.iterator().next(); switch (e.getKeyCode()) { case 37: //left if (firstCursorItem.x > 0) { @@ -1246,5 +1237,5 @@ public class TimelineBodyPanel extends JPanel implements MouseListener, KeyListe public void setTimeline(Timeline timeline) { this.timeline = timeline; refresh(); - } + } } diff --git a/src/com/jpexs/decompiler/flash/easygui/TimelineTimePanel.java b/src/com/jpexs/decompiler/flash/easygui/TimelineTimePanel.java index 58fdf42b4..a0c3f2506 100644 --- a/src/com/jpexs/decompiler/flash/easygui/TimelineTimePanel.java +++ b/src/com/jpexs/decompiler/flash/easygui/TimelineTimePanel.java @@ -16,8 +16,6 @@ */ package com.jpexs.decompiler.flash.easygui; -import static com.jpexs.decompiler.flash.easygui.TimelineDepthPanel.FONT_SIZE; -import static com.jpexs.decompiler.flash.easygui.TimelineDepthPanel.PADDING; import com.jpexs.decompiler.flash.timeline.Timeline; import java.awt.Color; import java.awt.Dimension; @@ -61,9 +59,9 @@ public class TimelineTimePanel extends JPanel implements MouseListener { public void setTimeline(Timeline timeline) { int maxDepth = timeline == null ? 0 : timeline.getMaxDepth(); String maxDepthStr = Integer.toString(maxDepth); - setFont(getFont().deriveFont(FONT_SIZE)); + setFont(getFont().deriveFont(TimelineDepthPanel.FONT_SIZE)); int maxDepthW = getFontMetrics(getFont()).stringWidth(maxDepthStr); - leftPos = maxDepthW + 2 * PADDING; + leftPos = maxDepthW + 2 * TimelineDepthPanel.PADDING; } diff --git a/src/com/jpexs/decompiler/flash/easygui/UndoManager.java b/src/com/jpexs/decompiler/flash/easygui/UndoManager.java index 191d360a2..d997c8067 100644 --- a/src/com/jpexs/decompiler/flash/easygui/UndoManager.java +++ b/src/com/jpexs/decompiler/flash/easygui/UndoManager.java @@ -27,62 +27,63 @@ import java.util.WeakHashMap; * @author JPEXS */ public class UndoManager { + private final Map historyPosMap = new WeakHashMap<>(); private final Map> historyMap = new WeakHashMap<>(); - + private final List changeListeners = new ArrayList<>(); - + public void addChangeListener(Runnable listener) { changeListeners.add(listener); } - + public void removeChangeListener(Runnable listener) { changeListeners.remove(listener); } - + private void fireChange() { for (Runnable listener : changeListeners) { listener.run(); } } - + public void doOperation(DoableOperation doableOperation, SWF swf) { if (!historyMap.containsKey(swf)) { historyMap.put(swf, new ArrayList<>()); } if (!historyPosMap.containsKey(swf)) { historyPosMap.put(swf, 0); - } - + } + int historyPos = historyPosMap.get(swf); - + List history = historyMap.get(swf); - + //drop redos - while(history.size() > historyPos) { + while (history.size() > historyPos) { history.remove(historyPos); } - - historyMap.get(swf).add(doableOperation); + + historyMap.get(swf).add(doableOperation); historyPosMap.put(swf, historyPosMap.get(swf) + 1); doableOperation.doOperation(); fireChange(); } - + public boolean canUndo(SWF swf) { if (!historyPosMap.containsKey(swf)) { return false; } return historyPosMap.get(swf) > 0; } - + public String getUndoName(SWF swf) { if (!canUndo(swf)) { return null; } return historyMap.get(swf).get(historyPosMap.get(swf) - 1).getDescription(); - } - + } + public void undo(SWF swf) { if (!canUndo(swf)) { return; @@ -91,7 +92,7 @@ public class UndoManager { historyMap.get(swf).get(historyPosMap.get(swf)).undoOperation(); fireChange(); } - + public void redo(SWF swf) { if (!canRedo(swf)) { return; @@ -100,26 +101,27 @@ public class UndoManager { historyPosMap.put(swf, historyPosMap.get(swf) + 1); fireChange(); } - + public String getRedoName(SWF swf) { if (!canRedo(swf)) { return null; } return historyMap.get(swf).get(historyPosMap.get(swf)).getDescription(); } - + public boolean canRedo(SWF swf) { if (!historyMap.containsKey(swf)) { return false; } return historyMap.get(swf).size() > historyPosMap.get(swf); } - + public void clear() { historyMap.clear(); historyPosMap.clear(); fireChange(); } + public void clear(SWF swf) { if (!historyMap.containsKey(swf)) { return; diff --git a/src/com/jpexs/decompiler/flash/easygui/properties/AbstractPropertyField.java b/src/com/jpexs/decompiler/flash/easygui/properties/AbstractPropertyField.java index b1ef01af4..7ada8ca5e 100644 --- a/src/com/jpexs/decompiler/flash/easygui/properties/AbstractPropertyField.java +++ b/src/com/jpexs/decompiler/flash/easygui/properties/AbstractPropertyField.java @@ -17,14 +17,8 @@ package com.jpexs.decompiler.flash.easygui.properties; import java.awt.AWTEvent; -import java.awt.BasicStroke; import java.awt.CardLayout; import java.awt.Cursor; -import java.awt.Font; -import java.awt.FontMetrics; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.Stroke; import java.awt.Toolkit; import java.awt.event.AWTEventListener; import java.awt.event.FocusAdapter; @@ -33,7 +27,6 @@ import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -import java.awt.geom.Line2D; import java.util.ArrayList; import java.util.List; import java.util.Set; @@ -49,71 +42,72 @@ import javax.swing.event.ChangeListener; * @author JPEXS */ public abstract class AbstractPropertyField extends JPanel { + private static final String CARD_READ = "Read"; private static final String CARD_WRITE = "Write"; - + protected JLabel readLabel; protected JTextField writeField; - + private final List> validations = new ArrayList<>(); private final List changeListeners = new ArrayList<>(); - + private AWTEventListener aeListener; - + private boolean undetermined = false; private boolean editing = false; - + public void addValidation(PropertyValidationInterface validation) { validations.add(validation); } - + public void removeValidation(PropertyValidationInterface validation) { validations.remove(validation); } - + public void addChangeListener(ChangeListener changeListener) { changeListeners.add(changeListener); } - + public void removeChangeListener(ChangeListener changeListener) { changeListeners.remove(changeListener); } - + private void fireChange() { for (ChangeListener listener : changeListeners) { listener.stateChanged(new ChangeEvent(this)); } } - - @SuppressWarnings("unchecked") + + @SuppressWarnings("unchecked") public AbstractPropertyField(String text) { setLayout(new CardLayout()); - readLabel = new DottedUnderlineLabel(text); - + readLabel = new DottedUnderlineLabel(text); + readLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); writeField = new JTextField(text); add(readLabel, CARD_READ); add(writeField, CARD_WRITE); - + readLabel.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { - if (e.getClickCount() == 1) { - ((CardLayout)AbstractPropertyField.this.getLayout()).show(AbstractPropertyField.this, CARD_WRITE); + if (e.getClickCount() == 1) { + ((CardLayout) AbstractPropertyField.this.getLayout()).show(AbstractPropertyField.this, CARD_WRITE); writeField.requestFocus(); writeField.selectAll(); - + Toolkit.getDefaultToolkit().addAWTEventListener(aeListener, AWTEvent.MOUSE_EVENT_MASK); editing = true; } - } + } }); - + writeField.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { finishEdit(); - } + } }); writeField.addKeyListener(new KeyAdapter() { @Override @@ -121,14 +115,14 @@ public abstract class AbstractPropertyField extends JPanel { if (e.getKeyCode() == KeyEvent.VK_ENTER) { e.consume(); finishEdit(); - } + } if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { e.consume(); cancelEdit(); } } - }); - + }); + aeListener = new AWTEventListener() { @Override public void eventDispatched(AWTEvent event) { @@ -142,33 +136,33 @@ public abstract class AbstractPropertyField extends JPanel { } } }; - - + } - + protected abstract E textToValue(String text); + protected abstract String valueToText(E value); - + private synchronized void finishEdit() { if (!editing) { return; } - + String textBefore = readLabel.getText(); String textAfter = writeField.getText(); - + if (textBefore.equals(textAfter)) { cancelEdit(); return; } - + Toolkit.getDefaultToolkit().removeAWTEventListener(aeListener); - + boolean ok = true; E value = textToValue(textAfter); if (value == null) { ok = false; - } else { + } else { for (PropertyValidationInterface validation : validations) { if (!validation.validate(value)) { ok = false; @@ -176,42 +170,43 @@ public abstract class AbstractPropertyField extends JPanel { } } } - + if (!ok) { cancelEdit(); return; } undetermined = false; readLabel.setText(valueToText(value)); - ((CardLayout)AbstractPropertyField.this.getLayout()).show(AbstractPropertyField.this, CARD_READ); - editing = false; + ((CardLayout) AbstractPropertyField.this.getLayout()).show(AbstractPropertyField.this, CARD_READ); + editing = false; fireChange(); } - + private void cancelEdit() { if (!editing) { return; } - Toolkit.getDefaultToolkit().removeAWTEventListener(aeListener); + Toolkit.getDefaultToolkit().removeAWTEventListener(aeListener); if (undetermined) { writeField.setText(""); } else { writeField.setText(readLabel.getText()); } - ((CardLayout)AbstractPropertyField.this.getLayout()).show(AbstractPropertyField.this, CARD_READ); + ((CardLayout) AbstractPropertyField.this.getLayout()).show(AbstractPropertyField.this, CARD_READ); editing = false; } - - public E getValue() { + + public E getValue() { if (undetermined) { return null; } return textToValue(writeField.getText()); } - + public void setValue(Set value) { setValue(value, false); } + public void setValue(Set value, boolean silent) { if (value.size() != 1) { setValue((E) null, silent); @@ -219,11 +214,11 @@ public abstract class AbstractPropertyField extends JPanel { setValue(value.iterator().next(), silent); } } - + public void setValue(E value) { setValue(value, false); } - + public void setValue(E value, boolean silent) { if (value == null) { readLabel.setText("-"); @@ -241,34 +236,4 @@ public abstract class AbstractPropertyField extends JPanel { fireChange(); } } -} - -class DottedUnderlineLabel extends JLabel { - - public DottedUnderlineLabel(String text) { - super(text); - } - - @Override - protected void paintComponent(Graphics g) { - super.paintComponent(g); - Graphics2D g2d = (Graphics2D) g; - Font font = getFont(); - FontMetrics metrics = getFontMetrics(font); - String text = getText(); - - int x = 0; - int y = metrics.getAscent(); - - g2d.setPaint(getForeground()); - - int textWidth = metrics.stringWidth(text); - int underlineY = y + 6; - - float[] dash = {1f, 1f}; - Stroke dotted = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 1f, dash, 0f); - g2d.setStroke(dotted); - - g2d.draw(new Line2D.Float(x, underlineY, x + textWidth, underlineY)); - } } \ No newline at end of file diff --git a/src/com/jpexs/decompiler/flash/easygui/properties/DottedUnderlineLabel.java b/src/com/jpexs/decompiler/flash/easygui/properties/DottedUnderlineLabel.java new file mode 100644 index 000000000..3bb449296 --- /dev/null +++ b/src/com/jpexs/decompiler/flash/easygui/properties/DottedUnderlineLabel.java @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2025 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 . + */ +package com.jpexs.decompiler.flash.easygui.properties; + +import java.awt.BasicStroke; +import java.awt.Font; +import java.awt.FontMetrics; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Stroke; +import java.awt.geom.Line2D; +import javax.swing.JLabel; + +/** + * + * @author JPEXS + */ +class DottedUnderlineLabel extends JLabel { + + public DottedUnderlineLabel(String text) { + super(text); + } + + @Override + protected void paintComponent(Graphics g) { + super.paintComponent(g); + Graphics2D g2d = (Graphics2D) g; + Font font = getFont(); + FontMetrics metrics = getFontMetrics(font); + String text = getText(); + + int x = 0; + int y = metrics.getAscent(); + + g2d.setPaint(getForeground()); + + int textWidth = metrics.stringWidth(text); + int underlineY = y + 6; + + float[] dash = {1f, 1f}; + Stroke dotted = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 1f, dash, 0f); + g2d.setStroke(dotted); + + g2d.draw(new Line2D.Float(x, underlineY, x + textWidth, underlineY)); + } +} diff --git a/src/com/jpexs/decompiler/flash/easygui/properties/FloatPropertyField.java b/src/com/jpexs/decompiler/flash/easygui/properties/FloatPropertyField.java index f1cc6c0a9..76a9a4492 100644 --- a/src/com/jpexs/decompiler/flash/easygui/properties/FloatPropertyField.java +++ b/src/com/jpexs/decompiler/flash/easygui/properties/FloatPropertyField.java @@ -21,20 +21,20 @@ package com.jpexs.decompiler.flash.easygui.properties; * @author JPEXS */ public class FloatPropertyField extends AbstractPropertyField { - + private PropertyValidationInterface minValidation = null; private PropertyValidationInterface maxValidation = null; - + public FloatPropertyField(float value, float min, float max) { super("" + value); setMin(min); setMax(max); } - + public FloatPropertyField(float value) { - super("" + value); + super("" + value); } - + public void setMax(float max) { if (maxValidation != null) { removeValidation(maxValidation); @@ -43,11 +43,11 @@ public class FloatPropertyField extends AbstractPropertyField { @Override public boolean validate(Float value) { return value <= max; - } + } }; addValidation(maxValidation); } - + public void setMin(float min) { if (minValidation != null) { removeValidation(minValidation); @@ -56,16 +56,16 @@ public class FloatPropertyField extends AbstractPropertyField { @Override public boolean validate(Float value) { return value >= min; - } + } }; addValidation(minValidation); } @Override protected Float textToValue(String text) { - try{ + try { return Float.parseFloat(text); - }catch(NumberFormatException nfe){ + } catch (NumberFormatException nfe) { return null; } } diff --git a/src/com/jpexs/decompiler/flash/easygui/properties/JTriStateCheckBox.java b/src/com/jpexs/decompiler/flash/easygui/properties/JTriStateCheckBox.java index 45340d400..f486f851c 100644 --- a/src/com/jpexs/decompiler/flash/easygui/properties/JTriStateCheckBox.java +++ b/src/com/jpexs/decompiler/flash/easygui/properties/JTriStateCheckBox.java @@ -16,18 +16,19 @@ */ package com.jpexs.decompiler.flash.easygui.properties; +import com.jpexs.decompiler.flash.configuration.Configuration; +import java.awt.Graphics; +import java.awt.event.ActionEvent; +import javax.swing.JCheckBox; + /** * * @author JPEXS */ -import com.jpexs.decompiler.flash.configuration.Configuration; -import javax.swing.*; -import java.awt.*; -import java.awt.event.*; public class JTriStateCheckBox extends JCheckBox { - final static boolean MID_AS_SELECTED = true; //consider mid-state as selected ? + private static final boolean MID_AS_SELECTED = true; //consider mid-state as selected ? public JTriStateCheckBox() { this(""); @@ -44,8 +45,6 @@ public class JTriStateCheckBox extends JCheckBox { super.fireActionPerformed(event); } - - public JTriStateCheckBox(String text, int sel) { /* tri-state checkbox has 3 selection states: * 0 unselected @@ -57,6 +56,7 @@ public class JTriStateCheckBox extends JCheckBox { switch (sel) { case 2: setSelected(true); + //fallthrough case 1: case 0: putClientProperty("SelectionState", sel); @@ -100,8 +100,6 @@ public class JTriStateCheckBox extends JCheckBox { super.setSelected(b); putClientProperty("SelectionState", b ? 2 : 0); } - - @Override protected void paintComponent(Graphics g) { @@ -109,10 +107,11 @@ public class JTriStateCheckBox extends JCheckBox { if (getSelectionState() == 1) { int w = 12; if (Configuration.useRibbonInterface.get()) { - /*SubstanceColorScheme baseMarkColorScheme = SubstanceColorSchemeUtilities - .getColorScheme(this, ColorSchemeAssociationKind.MARK, - ComponentState.getState(this)); - + /* + SubstanceColorScheme baseMarkColorScheme = SubstanceColorSchemeUtilities + .getColorScheme(this, ColorSchemeAssociationKind.MARK, + ComponentState.getState(this)); + g.setColor(baseMarkColorScheme.getSelectionForegroundColor());*/ w = 14; } else { diff --git a/src/com/jpexs/decompiler/flash/easygui/properties/TextPropertyField.java b/src/com/jpexs/decompiler/flash/easygui/properties/TextPropertyField.java index b4746a470..f3da5c613 100644 --- a/src/com/jpexs/decompiler/flash/easygui/properties/TextPropertyField.java +++ b/src/com/jpexs/decompiler/flash/easygui/properties/TextPropertyField.java @@ -20,18 +20,18 @@ package com.jpexs.decompiler.flash.easygui.properties; * * @author JPEXS */ -public class TextPropertyField extends AbstractPropertyField { - +public class TextPropertyField extends AbstractPropertyField { + public TextPropertyField(String text, int maxLength) { super(text); - + writeField.setColumns(maxLength); - - addValidation(new PropertyValidationInterface(){ + + addValidation(new PropertyValidationInterface() { @Override public boolean validate(String value) { return value.length() <= maxLength; - } + } }); } @@ -44,5 +44,5 @@ public class TextPropertyField extends AbstractPropertyField { protected String valueToText(String value) { return value; } - + } diff --git a/src/com/jpexs/decompiler/flash/easygui/properties/panels/AbstractPropertiesPanel.java b/src/com/jpexs/decompiler/flash/easygui/properties/panels/AbstractPropertiesPanel.java index 88d2a003c..4b097c985 100644 --- a/src/com/jpexs/decompiler/flash/easygui/properties/panels/AbstractPropertiesPanel.java +++ b/src/com/jpexs/decompiler/flash/easygui/properties/panels/AbstractPropertiesPanel.java @@ -41,24 +41,24 @@ import javax.swing.border.BevelBorder; * @author JPEXS */ public abstract class AbstractPropertiesPanel extends JPanel { - + protected String titleIdentifier; - + private final Map cardContents = new LinkedHashMap<>(); private final Map cardPlusMinusLabels = new LinkedHashMap<>(); - + private static final char PLUS_CHAR = '\u2BC8'; private static final char MINUS_CHAR = '\u2BC6'; - + public AbstractPropertiesPanel(String titleIdentifier) { - this.titleIdentifier = titleIdentifier; + this.titleIdentifier = titleIdentifier; } - + protected String formatPropertyName(String id) { - String item = EasyStrings.translate("property."+titleIdentifier+"." + id); + String item = EasyStrings.translate("property." + titleIdentifier + "." + id); return EasyStrings.translate("property.label").replace("%item%", item); } - + protected JPanel makeCard(String id, String icon, JPanel contents) { JPanel cardPanel = new JPanel(); @@ -118,9 +118,7 @@ public abstract class AbstractPropertiesPanel extends JPanel { plusMinusLabel.setText("" + PLUS_CHAR); } } - - - + protected void addToGrid(GridBagLayout layout, Container parent, Component component, int x, int y) { addToGrid(layout, parent, component, x, y, 1, 1); } diff --git a/src/com/jpexs/decompiler/flash/easygui/properties/panels/DocumentPropertiesPanel.java b/src/com/jpexs/decompiler/flash/easygui/properties/panels/DocumentPropertiesPanel.java index 72ebcc802..6ec9ac9df 100644 --- a/src/com/jpexs/decompiler/flash/easygui/properties/panels/DocumentPropertiesPanel.java +++ b/src/com/jpexs/decompiler/flash/easygui/properties/panels/DocumentPropertiesPanel.java @@ -18,11 +18,7 @@ package com.jpexs.decompiler.flash.easygui.properties.panels; import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.SWFCompression; -import static com.jpexs.decompiler.flash.SWFCompression.LZMA; -import static com.jpexs.decompiler.flash.SWFCompression.NONE; -import static com.jpexs.decompiler.flash.SWFCompression.ZLIB; import com.jpexs.decompiler.flash.easygui.ChangeDoableOperation; -import com.jpexs.decompiler.flash.easygui.DoableOperation; import com.jpexs.decompiler.flash.easygui.EasyStrings; import com.jpexs.decompiler.flash.easygui.UndoManager; import com.jpexs.decompiler.flash.easygui.properties.FloatPropertyField; @@ -32,17 +28,12 @@ import com.jpexs.decompiler.flash.gui.ComboBoxItem; import com.jpexs.decompiler.flash.gui.View; import java.awt.BorderLayout; import java.awt.Color; -import java.awt.Component; -import java.awt.Container; import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; -import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; import java.util.ArrayList; import java.util.List; import javax.swing.BorderFactory; diff --git a/src/com/jpexs/decompiler/flash/easygui/properties/panels/InstancePropertiesPanel.java b/src/com/jpexs/decompiler/flash/easygui/properties/panels/InstancePropertiesPanel.java index 8c329c3b1..3f47ce176 100644 --- a/src/com/jpexs/decompiler/flash/easygui/properties/panels/InstancePropertiesPanel.java +++ b/src/com/jpexs/decompiler/flash/easygui/properties/panels/InstancePropertiesPanel.java @@ -22,23 +22,30 @@ import com.jpexs.decompiler.flash.easygui.EasyTagNameResolver; import com.jpexs.decompiler.flash.easygui.UndoManager; import com.jpexs.decompiler.flash.easygui.properties.FloatPropertyField; import com.jpexs.decompiler.flash.easygui.properties.IntegerPropertyField; +import com.jpexs.decompiler.flash.easygui.properties.JTriStateCheckBox; +import com.jpexs.decompiler.flash.easygui.properties.PropertyChangeDoableOperation; import com.jpexs.decompiler.flash.easygui.properties.PropertyValidationInterface; import com.jpexs.decompiler.flash.exporters.commonshape.Matrix; import com.jpexs.decompiler.flash.gui.BoundsChangeListener; import com.jpexs.decompiler.flash.gui.RegistrationPointPosition; +import com.jpexs.decompiler.flash.gui.ViewMessages; import com.jpexs.decompiler.flash.tags.base.PlaceObjectTypeTag; import com.jpexs.decompiler.flash.tags.converters.PlaceObjectTypeConverter; import com.jpexs.decompiler.flash.timeline.DepthState; import com.jpexs.decompiler.flash.timeline.Timelined; import com.jpexs.decompiler.flash.types.CXFORMWITHALPHA; import com.jpexs.decompiler.flash.types.ColorTransform; +import com.jpexs.decompiler.flash.types.RGBA; import java.awt.BorderLayout; +import java.awt.Color; import java.awt.Dimension; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import java.util.ArrayList; @@ -47,22 +54,14 @@ import java.util.List; import java.util.Set; import javax.swing.BorderFactory; import javax.swing.BoxLayout; +import javax.swing.DefaultComboBoxModel; import javax.swing.JComboBox; import javax.swing.JLabel; import javax.swing.JPanel; +import javax.swing.SwingUtilities; import javax.swing.border.BevelBorder; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; -import com.jpexs.decompiler.flash.easygui.properties.JTriStateCheckBox; -import com.jpexs.decompiler.flash.easygui.properties.PropertyChangeDoableOperation; -import com.jpexs.decompiler.flash.gui.ViewMessages; -import com.jpexs.decompiler.flash.types.RGBA; -import java.awt.Color; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.util.Arrays; -import javax.swing.DefaultComboBoxModel; -import javax.swing.SwingUtilities; /** * @@ -74,7 +73,7 @@ public class InstancePropertiesPanel extends AbstractPropertiesPanel { private final FloatPropertyField yPropertyField = new FloatPropertyField(0, -8192, 8192); private final FloatPropertyField wPropertyField = new FloatPropertyField(0, -8192, 8192); private final FloatPropertyField hPropertyField = new FloatPropertyField(0, -8192, 8192); - + private final IntegerPropertyField alphaPercentPropertyField = new IntegerPropertyField(100, -100, 100); private final IntegerPropertyField redPercentPropertyField = new IntegerPropertyField(100, -100, 100); private final IntegerPropertyField greenPercentPropertyField = new IntegerPropertyField(100, -100, 100); @@ -86,21 +85,20 @@ public class InstancePropertiesPanel extends AbstractPropertiesPanel { private final EasySwfPanel swfPanel; private final JPanel propertiesPanel; - + private Rectangle2D lastBounds = null; - + private JLabel instanceLabel; - + private final JTriStateCheckBox visibleCheckBox = new JTriStateCheckBox(); private final JComboBox blendingComboBox = new JComboBox<>(); private final JTriStateCheckBox cacheAsBitmapCheckBox = new JTriStateCheckBox(); private final JComboBox backgroundComboBox = new JComboBox<>(); private final JPanel backgroundColorPanel = new JPanel(); private final JLabel backgroundColorLabel = new JLabel(); - + private boolean updating = false; - - + public InstancePropertiesPanel(EasySwfPanel swfPanel, UndoManager undoManager) { super("instance"); setLayout(new BorderLayout()); @@ -108,11 +106,11 @@ public class InstancePropertiesPanel extends AbstractPropertiesPanel { instanceLabel = new JLabel(EasyStrings.translate("properties.instance.none")); instanceLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 0)); add(instanceLabel, BorderLayout.NORTH); - + GridBagLayout gridBag; GridBagConstraints gbc; - - JPanel positionSizePanel = new JPanel(); + + JPanel positionSizePanel = new JPanel(); gridBag = new GridBagLayout(); positionSizePanel.setLayout(gridBag); gbc = new GridBagConstraints(); @@ -126,34 +124,34 @@ public class InstancePropertiesPanel extends AbstractPropertiesPanel { gbc.anchor = GridBagConstraints.WEST; positionSizePanel.add(xPropertyField, gbc); gbc.gridx++; - gbc.anchor = GridBagConstraints.EAST; + gbc.anchor = GridBagConstraints.EAST; positionSizePanel.add(new JLabel(formatPropertyName("positionSize.y")), gbc); gbc.gridx++; gbc.anchor = GridBagConstraints.WEST; positionSizePanel.add(yPropertyField, gbc); gbc.gridy++; gbc.gridx = 0; - gbc.anchor = GridBagConstraints.EAST; + gbc.anchor = GridBagConstraints.EAST; positionSizePanel.add(new JLabel(formatPropertyName("positionSize.width")), gbc); gbc.gridx++; - gbc.anchor = GridBagConstraints.WEST; + gbc.anchor = GridBagConstraints.WEST; positionSizePanel.add(wPropertyField, gbc); gbc.gridx++; - gbc.anchor = GridBagConstraints.EAST; + gbc.anchor = GridBagConstraints.EAST; positionSizePanel.add(new JLabel(formatPropertyName("positionSize.height")), gbc); gbc.gridx++; gbc.anchor = GridBagConstraints.WEST; - positionSizePanel.add(hPropertyField, gbc); - + positionSizePanel.add(hPropertyField, gbc); + gbc.gridx++; gbc.gridy = 0; gbc.gridheight = 2; gbc.weightx = 1; gbc.fill = GridBagConstraints.HORIZONTAL; positionSizePanel.add(new JPanel(), gbc); - - JPanel colorEffectPanel = new JPanel(); - + + JPanel colorEffectPanel = new JPanel(); + gridBag = new GridBagLayout(); colorEffectPanel.setLayout(gridBag); @@ -174,7 +172,7 @@ public class InstancePropertiesPanel extends AbstractPropertiesPanel { gbc.gridx = 0; gbc.gridy++; - gbc.anchor = GridBagConstraints.EAST; + gbc.anchor = GridBagConstraints.EAST; colorEffectPanel.add(new JLabel(formatPropertyName("colorEffect.red")), gbc); gbc.anchor = GridBagConstraints.WEST; gbc.gridx++; @@ -186,7 +184,7 @@ public class InstancePropertiesPanel extends AbstractPropertiesPanel { gbc.gridx = 0; gbc.gridy++; - gbc.anchor = GridBagConstraints.EAST; + gbc.anchor = GridBagConstraints.EAST; colorEffectPanel.add(new JLabel(formatPropertyName("colorEffect.green")), gbc); gbc.anchor = GridBagConstraints.WEST; gbc.gridx++; @@ -198,7 +196,7 @@ public class InstancePropertiesPanel extends AbstractPropertiesPanel { gbc.gridx = 0; gbc.gridy++; - gbc.anchor = GridBagConstraints.EAST; + gbc.anchor = GridBagConstraints.EAST; colorEffectPanel.add(new JLabel(formatPropertyName("colorEffect.blue")), gbc); gbc.anchor = GridBagConstraints.WEST; gbc.gridx++; @@ -207,7 +205,7 @@ public class InstancePropertiesPanel extends AbstractPropertiesPanel { colorEffectPanel.add(new JLabel("% \u00D7 B + "), gbc); gbc.gridx++; colorEffectPanel.add(blueAddPropertyField, gbc); - + gbc.gridx++; gbc.gridy = 0; gbc.gridheight = 4; @@ -215,35 +213,31 @@ public class InstancePropertiesPanel extends AbstractPropertiesPanel { gbc.fill = GridBagConstraints.HORIZONTAL; colorEffectPanel.add(new JPanel(), gbc); - JPanel displayPanel = new JPanel(); gridBag = new GridBagLayout(); - displayPanel.setLayout(gridBag); - gbc = new GridBagConstraints(); - - gbc.insets = new Insets(3, 3, 3, 3); - + displayPanel.setLayout(gridBag); + gbc = new GridBagConstraints(); + + gbc.insets = new Insets(3, 3, 3, 3); + gbc.gridx = 0; gbc.gridy = 0; - gbc.gridwidth = 1; + gbc.gridwidth = 1; gbc.anchor = GridBagConstraints.EAST; displayPanel.add(new JLabel(formatPropertyName("display.visible")), gbc); - - + gbc.gridx++; - gbc.gridwidth = 2; + gbc.gridwidth = 2; gbc.anchor = GridBagConstraints.WEST; - - + displayPanel.add(visibleCheckBox, gbc); - + gbc.gridy++; gbc.gridx = 0; - gbc.gridwidth = 1; - gbc.anchor = GridBagConstraints.EAST; + gbc.gridwidth = 1; + gbc.anchor = GridBagConstraints.EAST; displayPanel.add(new JLabel(formatPropertyName("display.blending")), gbc); - - + blendingComboBox.addItem(EasyStrings.translate("property.instance.display.blending.normal")); blendingComboBox.addItem(EasyStrings.translate("property.instance.display.blending.layer")); blendingComboBox.addItem(EasyStrings.translate("property.instance.display.blending.multiply")); @@ -258,42 +252,40 @@ public class InstancePropertiesPanel extends AbstractPropertiesPanel { blendingComboBox.addItem(EasyStrings.translate("property.instance.display.blending.erase")); blendingComboBox.addItem(EasyStrings.translate("property.instance.display.blending.overlay")); blendingComboBox.addItem(EasyStrings.translate("property.instance.display.blending.hardlight")); - + gbc.gridx++; gbc.anchor = GridBagConstraints.WEST; - gbc.gridwidth = 2; + gbc.gridwidth = 2; displayPanel.add(blendingComboBox, gbc); - + gbc.gridy++; - + gbc.gridx = 0; - gbc.gridwidth = 1; + gbc.gridwidth = 1; gbc.anchor = GridBagConstraints.EAST; displayPanel.add(new JLabel(formatPropertyName("display.cacheAsBitmap")), gbc); - + gbc.gridx++; - gbc.gridwidth = 2; - gbc.anchor = GridBagConstraints.WEST; - + gbc.gridwidth = 2; + gbc.anchor = GridBagConstraints.WEST; + displayPanel.add(cacheAsBitmapCheckBox, gbc); - + backgroundComboBox.addItem(EasyStrings.translate("property.instance.display.cacheAsBitmap.transparent")); backgroundComboBox.addItem(EasyStrings.translate("property.instance.display.cacheAsBitmap.opaque")); - - + backgroundColorPanel.setLayout(new BorderLayout()); backgroundColorPanel.add(backgroundColorLabel, BorderLayout.CENTER); backgroundColorPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED)); - backgroundColorPanel.setPreferredSize(new Dimension(16,16)); - - - gbc.gridy++; + backgroundColorPanel.setPreferredSize(new Dimension(16, 16)); + + gbc.gridy++; gbc.gridx = 1; - gbc.gridwidth = 1; + gbc.gridwidth = 1; displayPanel.add(backgroundComboBox, gbc); - gbc.gridx++; + gbc.gridx++; displayPanel.add(backgroundColorPanel, gbc); - + cacheAsBitmapCheckBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -303,28 +295,28 @@ public class InstancePropertiesPanel extends AbstractPropertiesPanel { backgroundComboBox.setVisible(cacheAsBitmapCheckBox.isSelected()); backgroundColorPanel.setVisible(cacheAsBitmapCheckBox.isSelected() && backgroundComboBox.getSelectedIndex() == backgroundComboBox.getItemCount() - 1); revalidate(); - } + } }); - + backgroundComboBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (updating) { return; } - backgroundColorPanel.setVisible(backgroundComboBox.getSelectedIndex() == backgroundComboBox.getItemCount() - 1); + backgroundColorPanel.setVisible(backgroundComboBox.getSelectedIndex() == backgroundComboBox.getItemCount() - 1); revalidate(); } }); - + gbc.gridy++; - gbc.gridx=0; - gbc.gridwidth=3; + gbc.gridx = 0; + gbc.gridwidth = 3; gbc.weightx = 0; gbc.weighty = 1; gbc.fill = GridBagConstraints.VERTICAL; displayPanel.add(new JPanel(), gbc); - + gbc.gridx = 3; gbc.gridy = 0; gbc.gridheight = 4; @@ -332,20 +324,18 @@ public class InstancePropertiesPanel extends AbstractPropertiesPanel { gbc.weightx = 1; gbc.fill = GridBagConstraints.HORIZONTAL; displayPanel.add(new JPanel(), gbc); - - - + propertiesPanel = new JPanel(); propertiesPanel.setLayout(new BoxLayout(propertiesPanel, BoxLayout.Y_AXIS)); - + propertiesPanel.add(makeCard("positionSize", null, positionSizePanel)); - + setCardOpened("positionSize", true); - + propertiesPanel.add(makeCard("colorEffect", null, colorEffectPanel)); - + propertiesPanel.add(makeCard("display", null, displayPanel)); - + this.swfPanel = swfPanel; alphaPercentPropertyField.addChangeListener(new ChangeListener() { @@ -353,6 +343,7 @@ public class InstancePropertiesPanel extends AbstractPropertiesPanel { public void stateChanged(ChangeEvent e) { undoManager.doOperation(new ColorEffectChangeDoableOperation("alpha") { int value = alphaPercentPropertyField.getValue(); + @Override public void doColorEffectOperation(CXFORMWITHALPHA colorTransform) { colorTransform.alphaMultTerm = Math.round(value * 256 / 100f); @@ -364,8 +355,9 @@ public class InstancePropertiesPanel extends AbstractPropertiesPanel { alphaAddPropertyField.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { - undoManager.doOperation(new ColorEffectChangeDoableOperation("alpha") { - int value = alphaAddPropertyField.getValue(); + undoManager.doOperation(new ColorEffectChangeDoableOperation("alpha") { + int value = alphaAddPropertyField.getValue(); + @Override public void doColorEffectOperation(CXFORMWITHALPHA colorTransform) { colorTransform.alphaAddTerm = value; @@ -380,6 +372,7 @@ public class InstancePropertiesPanel extends AbstractPropertiesPanel { public void stateChanged(ChangeEvent e) { undoManager.doOperation(new ColorEffectChangeDoableOperation("red") { int value = redPercentPropertyField.getValue(); + @Override public void doColorEffectOperation(CXFORMWITHALPHA colorTransform) { colorTransform.redMultTerm = Math.round(value * 256 / 100f); @@ -393,6 +386,7 @@ public class InstancePropertiesPanel extends AbstractPropertiesPanel { public void stateChanged(ChangeEvent e) { undoManager.doOperation(new ColorEffectChangeDoableOperation("red") { int value = redAddPropertyField.getValue(); + @Override public void doColorEffectOperation(CXFORMWITHALPHA colorTransform) { colorTransform.redAddTerm = value; @@ -407,6 +401,7 @@ public class InstancePropertiesPanel extends AbstractPropertiesPanel { public void stateChanged(ChangeEvent e) { undoManager.doOperation(new ColorEffectChangeDoableOperation("green") { int value = greenPercentPropertyField.getValue(); + @Override public void doColorEffectOperation(CXFORMWITHALPHA colorTransform) { colorTransform.greenMultTerm = Math.round(value * 256 / 100f); @@ -420,6 +415,7 @@ public class InstancePropertiesPanel extends AbstractPropertiesPanel { public void stateChanged(ChangeEvent e) { undoManager.doOperation(new ColorEffectChangeDoableOperation("green") { int value = greenAddPropertyField.getValue(); + @Override public void doColorEffectOperation(CXFORMWITHALPHA colorTransform) { colorTransform.greenAddTerm = value; @@ -434,6 +430,7 @@ public class InstancePropertiesPanel extends AbstractPropertiesPanel { public void stateChanged(ChangeEvent e) { undoManager.doOperation(new ColorEffectChangeDoableOperation("blue") { int value = bluePercentPropertyField.getValue(); + @Override public void doColorEffectOperation(CXFORMWITHALPHA colorTransform) { colorTransform.blueMultTerm = Math.round(value * 256 / 100f); @@ -447,6 +444,7 @@ public class InstancePropertiesPanel extends AbstractPropertiesPanel { public void stateChanged(ChangeEvent e) { undoManager.doOperation(new ColorEffectChangeDoableOperation("blue") { int value = blueAddPropertyField.getValue(); + @Override public void doColorEffectOperation(CXFORMWITHALPHA colorTransform) { colorTransform.blueAddTerm = value; @@ -455,7 +453,7 @@ public class InstancePropertiesPanel extends AbstractPropertiesPanel { }, swfPanel.getSwf()); } }); - + xPropertyField.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { @@ -465,7 +463,7 @@ public class InstancePropertiesPanel extends AbstractPropertiesPanel { swfPanel.getStagePanel().applyTransformMatrix(Matrix.getTranslateInstance(xDelta, 0)); } }); - + yPropertyField.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { @@ -475,17 +473,17 @@ public class InstancePropertiesPanel extends AbstractPropertiesPanel { swfPanel.getStagePanel().applyTransformMatrix(Matrix.getTranslateInstance(0, yDelta)); } }); - + PropertyValidationInterface nonZeroFloatValidation = new PropertyValidationInterface() { @Override public boolean validate(Float value) { return value != 0f; - } + } }; - + wPropertyField.addChangeListener(new ChangeListener() { @Override - public void stateChanged(ChangeEvent e) { + public void stateChanged(ChangeEvent e) { double wBefore = lastBounds.getWidth(); if (wBefore == 0) { return; @@ -500,10 +498,10 @@ public class InstancePropertiesPanel extends AbstractPropertiesPanel { } }); wPropertyField.addValidation(nonZeroFloatValidation); - + hPropertyField.addChangeListener(new ChangeListener() { @Override - public void stateChanged(ChangeEvent e) { + public void stateChanged(ChangeEvent e) { double hBefore = lastBounds.getHeight(); if (hBefore == 0) { return; @@ -518,7 +516,7 @@ public class InstancePropertiesPanel extends AbstractPropertiesPanel { } }); hPropertyField.addValidation(nonZeroFloatValidation); - + visibleCheckBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -527,14 +525,15 @@ public class InstancePropertiesPanel extends AbstractPropertiesPanel { } undoManager.doOperation(new PlaceChangeDoableOperation("instance.display.visible", 3) { int visible = visibleCheckBox.isSelected() ? 1 : 0; + @Override public void doPlaceOperation(PlaceObjectTypeTag placeObject, DepthState depthState) { placeObject.setVisible(visible); - } + } }, swfPanel.getSwf()); - } + } }); - + blendingComboBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -543,14 +542,15 @@ public class InstancePropertiesPanel extends AbstractPropertiesPanel { } undoManager.doOperation(new PlaceChangeDoableOperation("instance.display.blending", 3) { int blendMode = blendingComboBox.getSelectedIndex() + 1; + @Override public void doPlaceOperation(PlaceObjectTypeTag placeObject, DepthState depthState) { placeObject.setBlendMode(blendMode); } }, swfPanel.getSwf()); - } + } }); - + cacheAsBitmapCheckBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -559,6 +559,7 @@ public class InstancePropertiesPanel extends AbstractPropertiesPanel { } undoManager.doOperation(new PlaceChangeDoableOperation("instance.display.cacheAsBitmap", 3) { int bitmapCache = cacheAsBitmapCheckBox.isSelected() ? 1 : 0; + @Override public void doPlaceOperation(PlaceObjectTypeTag placeObject, DepthState depthState) { placeObject.setBitmapCache(bitmapCache); @@ -567,11 +568,11 @@ public class InstancePropertiesPanel extends AbstractPropertiesPanel { placeObject.setBackgroundColor(null); placeObject.setPlaceFlagOpaqueBackground(false); } - } + } }, swfPanel.getSwf()); - } + } }); - + backgroundComboBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -581,19 +582,20 @@ public class InstancePropertiesPanel extends AbstractPropertiesPanel { boolean isOpaque = backgroundComboBox.getSelectedIndex() == backgroundComboBox.getItemCount() - 1; undoManager.doOperation(new PlaceChangeDoableOperation("instance.display.cacheAsBitmap", 3) { RGBA color = isOpaque ? new RGBA(backgroundColorPanel.getBackground()) : null; + @Override - public void doPlaceOperation(PlaceObjectTypeTag placeObject, DepthState depthState) { + public void doPlaceOperation(PlaceObjectTypeTag placeObject, DepthState depthState) { if (color != null) { backgroundColorLabel.setText(""); placeObject.setBackgroundColor(color); } else { placeObject.setPlaceFlagOpaqueBackground(false); } - } + } }, swfPanel.getSwf()); - } + } }); - + backgroundColorPanel.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { @@ -602,21 +604,22 @@ public class InstancePropertiesPanel extends AbstractPropertiesPanel { if (newColor != null) { backgroundColorPanel.setBackground(newColor); backgroundColorLabel.setText(""); - + undoManager.doOperation(new PlaceChangeDoableOperation("instance.display.cacheAsBitmap", 3) { RGBA color = new RGBA(newColor); + @Override - public void doPlaceOperation(PlaceObjectTypeTag placeObject, DepthState depthState) { + public void doPlaceOperation(PlaceObjectTypeTag placeObject, DepthState depthState) { placeObject.setBackgroundColor(color); - } + } }, swfPanel.getSwf()); } } - } + } }); - + add(propertiesPanel, BorderLayout.CENTER); - + swfPanel.getStagePanel().addBoundsChangeListener(new BoundsChangeListener() { @Override public void boundsChanged(Rectangle2D newBounds, Point2D registrationPoint, RegistrationPointPosition registrationPointPosition) { @@ -625,7 +628,7 @@ public class InstancePropertiesPanel extends AbstractPropertiesPanel { yPropertyField.setValue(twipToPixelValue(newBounds.getY()), true); wPropertyField.setValue(twipToPixelValue(newBounds.getWidth()), true); hPropertyField.setValue(twipToPixelValue(newBounds.getHeight()), true); - } + } }); } @@ -636,7 +639,7 @@ public class InstancePropertiesPanel extends AbstractPropertiesPanel { ret = ret / 20; return ret; } - + public void update() { updating = true; List dss = swfPanel.getSelectedDepthStates(); @@ -646,7 +649,7 @@ public class InstancePropertiesPanel extends AbstractPropertiesPanel { return; } propertiesPanel.setVisible(true); - + if (dss.size() == 1) { EasyTagNameResolver resolver = new EasyTagNameResolver(); DepthState ds = dss.get(0); @@ -658,9 +661,8 @@ public class InstancePropertiesPanel extends AbstractPropertiesPanel { } else { instanceLabel.setText(EasyStrings.translate("properties.instance.multiple").replace("%count%", "" + dss.size())); } - + //swfPanel.getStagePanel().get - Set alphaPercent = new HashSet<>(); Set alphaAdd = new HashSet<>(); Set redPercent = new HashSet<>(); @@ -673,7 +675,7 @@ public class InstancePropertiesPanel extends AbstractPropertiesPanel { Set blendMode = new HashSet<>(); Set cacheAsBitmap = new HashSet<>(); Set backgroundColor = new HashSet<>(); - + for (DepthState ds : dss) { if (ds == null) { continue; @@ -707,12 +709,11 @@ public class InstancePropertiesPanel extends AbstractPropertiesPanel { cacheAsBitmap.add(ds.cacheAsBitmap); backgroundColor.add(ds.backGroundColor); } - + if (visible.size() == 0) { return; } - - + alphaPercentPropertyField.setValue(alphaPercent, true); alphaAddPropertyField.setValue(alphaAdd, true); redPercentPropertyField.setValue(redPercent, true); @@ -721,15 +722,14 @@ public class InstancePropertiesPanel extends AbstractPropertiesPanel { greenAddPropertyField.setValue(greenAdd, true); bluePercentPropertyField.setValue(bluePercent, true); blueAddPropertyField.setValue(blueAdd, true); - - + if (visible.size() > 1) { visibleCheckBox.setSelectionState(1); } else { visibleCheckBox.setSelected(visible.iterator().next()); - } - - DefaultComboBoxModel model = (DefaultComboBoxModel) blendingComboBox.getModel(); + } + + DefaultComboBoxModel model = (DefaultComboBoxModel) blendingComboBox.getModel(); if (blendMode.size() > 1) { if (!model.getElementAt(0).equals("")) { model.insertElementAt("", 0); @@ -738,9 +738,9 @@ public class InstancePropertiesPanel extends AbstractPropertiesPanel { } else { if (model.getElementAt(0).equals("")) { model.removeElementAt(0); - } + } int bm = blendMode.iterator().next(); - + bm--; blendingComboBox.setSelectedIndex(bm); } @@ -749,13 +749,12 @@ public class InstancePropertiesPanel extends AbstractPropertiesPanel { } else { cacheAsBitmapCheckBox.setSelected(cacheAsBitmap.iterator().next()); } - + backgroundComboBox.setVisible(cacheAsBitmapCheckBox.getSelectionState() == 2); - - + DefaultComboBoxModel backgroundModel = (DefaultComboBoxModel) backgroundComboBox.getModel(); if (backgroundColor.size() > 1) { - + if (backgroundColor.contains(null)) { if (backgroundModel.getSize() == 2) { backgroundModel.insertElementAt("", 0); @@ -767,12 +766,12 @@ public class InstancePropertiesPanel extends AbstractPropertiesPanel { backgroundModel.removeElementAt(0); } backgroundComboBox.setSelectedIndex(1); - + backgroundColorPanel.setVisible(true); backgroundColorLabel.setText("--"); backgroundColorPanel.setBackground(Color.WHITE); backgroundColorPanel.setOpaque(true); - } + } } else { if (backgroundModel.getSize() == 3) { backgroundModel.removeElementAt(0); @@ -780,19 +779,18 @@ public class InstancePropertiesPanel extends AbstractPropertiesPanel { RGBA bgColor = backgroundColor.iterator().next(); backgroundComboBox.setSelectedIndex(bgColor == null ? 0 : 1); backgroundColorLabel.setText(""); - + if (bgColor == null) { backgroundColorPanel.setVisible(false); } else { backgroundColorPanel.setVisible(true); backgroundColorPanel.setBackground(bgColor.toColor()); backgroundColorPanel.setOpaque(true); - } - - + } + } updating = false; - revalidate(); + revalidate(); } abstract class PlaceChangeDoableOperation extends PropertyChangeDoableOperation { @@ -803,21 +801,19 @@ public class InstancePropertiesPanel extends AbstractPropertiesPanel { List depthStatesBefore = swfPanel.getSelectedDepthStates(); List placeObjectsBefore = swfPanel.getSelectedPlaceTags(); List placeObjectsAfter = new ArrayList<>(); - + private final boolean timelinedModifiedBefore = swfPanel.getTimelined().isModified(); - + private final Timelined timelined = swfPanel.getTimelined(); - - - + public PlaceChangeDoableOperation(String propertyIdentifier, int minPlace) { super(propertyIdentifier); - + for (int i = 0; i < fdepths.size(); i++) { PlaceObjectTypeTag placeObjectBefore = placeObjectsBefore.get(i); int convNum = placeObjectBefore.getPlaceObjectNum() < minPlace ? minPlace : placeObjectBefore.getPlaceObjectNum(); PlaceObjectTypeConverter conv = new PlaceObjectTypeConverter(); - PlaceObjectTypeTag placeObjectAfter = conv.convertTagType(placeObjectBefore, timelined.getSwf(), convNum, false); + PlaceObjectTypeTag placeObjectAfter = conv.convertTagType(placeObjectBefore, timelined.getSwf(), convNum, false); placeObjectsAfter.add(placeObjectAfter); } } @@ -826,20 +822,20 @@ public class InstancePropertiesPanel extends AbstractPropertiesPanel { public final void doOperation() { swfPanel.getStagePanel().gotoFrame(fframe + 1); swfPanel.getStagePanel().selectDepths(fdepths); - + for (int i = 0; i < fdepths.size(); i++) { PlaceObjectTypeTag placeObjectBefore = placeObjectsBefore.get(i); PlaceObjectTypeTag placeObjectAfter = placeObjectsAfter.get(i); - + int index = timelined.indexOfTag(placeObjectBefore); timelined.removeTag(index); timelined.addTag(index, placeObjectAfter); timelined.setModified(true); - DepthState depthStateBefore = depthStatesBefore.get(i); + DepthState depthStateBefore = depthStatesBefore.get(i); doPlaceOperation(placeObjectAfter, depthStateBefore); } - - timelined.resetTimeline(); + + timelined.resetTimeline(); update(); } @@ -849,7 +845,7 @@ public class InstancePropertiesPanel extends AbstractPropertiesPanel { swfPanel.getStagePanel().selectDepths(fdepths); for (int i = 0; i < placeObjectsAfter.size(); i++) { PlaceObjectTypeTag placeObjectAfter = placeObjectsAfter.get(i); - PlaceObjectTypeTag placeObjectBefore = placeObjectsBefore.get(i); + PlaceObjectTypeTag placeObjectBefore = placeObjectsBefore.get(i); int index = timelined.indexOfTag(placeObjectAfter); timelined.removeTag(index); timelined.addTag(index, placeObjectBefore); @@ -858,7 +854,7 @@ public class InstancePropertiesPanel extends AbstractPropertiesPanel { timelined.setModified(false); } timelined.resetTimeline(); - + update(); } @@ -874,7 +870,7 @@ public class InstancePropertiesPanel extends AbstractPropertiesPanel { } @Override - public final void doPlaceOperation(PlaceObjectTypeTag placeObject, DepthState depthState) { + public final void doPlaceOperation(PlaceObjectTypeTag placeObject, DepthState depthState) { colorTransformAfter = depthState.colorTransForm == null ? new CXFORMWITHALPHA() : new CXFORMWITHALPHA(depthState.colorTransForm); doColorEffectOperation(colorTransformAfter); placeObject.setColorTransform(colorTransformAfter); diff --git a/src/com/jpexs/decompiler/flash/gui/ConvertPlaceObjectTypeDialog.java b/src/com/jpexs/decompiler/flash/gui/ConvertPlaceObjectTypeDialog.java index 4844b8660..d64bbc0d4 100644 --- a/src/com/jpexs/decompiler/flash/gui/ConvertPlaceObjectTypeDialog.java +++ b/src/com/jpexs/decompiler/flash/gui/ConvertPlaceObjectTypeDialog.java @@ -37,20 +37,20 @@ import javax.swing.JRadioButton; * @author JPEXS */ public class ConvertPlaceObjectTypeDialog extends AppDialog { - + private List radios = new ArrayList<>(); - + private int result = 0; - + public ConvertPlaceObjectTypeDialog(Window owner, int currentPlaceObjectNum, int min) { super(owner); setTitle(translate("dialog.title")); JPanel radioPanel = new JPanel(); radioPanel.setLayout(new BoxLayout(radioPanel, BoxLayout.Y_AXIS)); ButtonGroup radioGroup = new ButtonGroup(); - + JButton okButton = new JButton(translate("button.ok")); - + for (int i = 1; i <= 4; i++) { String text = "PlaceObject" + (i > 1 ? "" + i : ""); if (i == min) { @@ -63,39 +63,38 @@ public class ConvertPlaceObjectTypeDialog extends AppDialog { radio.setSelected(true); } final int fi = i; - radio.addActionListener(new ActionListener(){ + radio.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { okButton.setEnabled(fi != currentPlaceObjectNum); - } + } }); - radioPanel.add(radio); + radioPanel.add(radio); radioGroup.add(radio); - radios.add(radio); + radios.add(radio); } - - Container cnt = getContentPane(); + + Container cnt = getContentPane(); cnt.setLayout(new BorderLayout()); - + cnt.add(radioPanel, BorderLayout.CENTER); - + JPanel buttonsPanel = new JPanel(new FlowLayout()); - okButton.setEnabled(false); okButton.addActionListener(this::okButtonActionPerformed); JButton cancelButton = new JButton(translate("button.cancel")); cancelButton.addActionListener(this::cancelButtonActionPerformed); buttonsPanel.add(okButton); buttonsPanel.add(cancelButton); - + cnt.add(buttonsPanel, BorderLayout.SOUTH); pack(); View.centerScreen(this); View.setWindowIcon(this, "placeobject"); setModal(true); } - + private void okButtonActionPerformed(ActionEvent evt) { result = 0; for (int i = 0; i < radios.size(); i++) { @@ -106,16 +105,16 @@ public class ConvertPlaceObjectTypeDialog extends AppDialog { } setVisible(false); } - + private void cancelButtonActionPerformed(ActionEvent evt) { setVisible(false); } public int getResult() { return result; - } - - public int showDialog() { + } + + public int showDialog() { setVisible(true); return result; } diff --git a/src/com/jpexs/decompiler/flash/gui/ConvertShapeTypeDialog.java b/src/com/jpexs/decompiler/flash/gui/ConvertShapeTypeDialog.java index 1939bb5d5..df17b3a0b 100644 --- a/src/com/jpexs/decompiler/flash/gui/ConvertShapeTypeDialog.java +++ b/src/com/jpexs/decompiler/flash/gui/ConvertShapeTypeDialog.java @@ -36,20 +36,20 @@ import javax.swing.JRadioButton; * @author JPEXS */ public class ConvertShapeTypeDialog extends AppDialog { - + private List radios = new ArrayList<>(); - + private int result = 0; - + public ConvertShapeTypeDialog(Window owner, int currentShapeNum, int minForced, int min) { super(owner); setTitle(translate("dialog.title")); JPanel radioPanel = new JPanel(); radioPanel.setLayout(new BoxLayout(radioPanel, BoxLayout.Y_AXIS)); ButtonGroup radioGroup = new ButtonGroup(); - + JButton okButton = new JButton(translate("button.ok")); - + for (int i = 1; i <= 4; i++) { String text = "DefineShape" + (i > 1 ? "" + i : ""); if (i < minForced) { @@ -68,39 +68,38 @@ public class ConvertShapeTypeDialog extends AppDialog { radio.setSelected(true); } final int fi = i; - radio.addActionListener(new ActionListener(){ + radio.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { okButton.setEnabled(fi != currentShapeNum); - } + } }); - radioPanel.add(radio); + radioPanel.add(radio); radioGroup.add(radio); - radios.add(radio); + radios.add(radio); } - - Container cnt = getContentPane(); + + Container cnt = getContentPane(); cnt.setLayout(new BorderLayout()); - + cnt.add(radioPanel, BorderLayout.CENTER); - + JPanel buttonsPanel = new JPanel(new FlowLayout()); - okButton.setEnabled(false); okButton.addActionListener(this::okButtonActionPerformed); JButton cancelButton = new JButton(translate("button.cancel")); cancelButton.addActionListener(this::cancelButtonActionPerformed); buttonsPanel.add(okButton); buttonsPanel.add(cancelButton); - + cnt.add(buttonsPanel, BorderLayout.SOUTH); pack(); View.centerScreen(this); View.setWindowIcon(this, "shape"); setModal(true); } - + private void okButtonActionPerformed(ActionEvent evt) { result = 0; for (int i = 0; i < radios.size(); i++) { @@ -111,16 +110,16 @@ public class ConvertShapeTypeDialog extends AppDialog { } setVisible(false); } - + private void cancelButtonActionPerformed(ActionEvent evt) { setVisible(false); } public int getResult() { return result; - } - - public int showDialog() { + } + + public int showDialog() { setVisible(true); return result; } diff --git a/src/com/jpexs/decompiler/flash/gui/ImagePanel.java b/src/com/jpexs/decompiler/flash/gui/ImagePanel.java index a95fb2b01..1dd2cdf2e 100644 --- a/src/com/jpexs/decompiler/flash/gui/ImagePanel.java +++ b/src/com/jpexs/decompiler/flash/gui/ImagePanel.java @@ -132,9 +132,8 @@ import org.pushingpixels.substance.api.SubstanceSkin; */ public final class ImagePanel extends JPanel implements MediaDisplay { - private static final int MAX_SOUND_CHANNELS = 8; //TODO: Maybe add to Advanced settings - + private static final Logger logger = Logger.getLogger(ImagePanel.class.getName()); private final List listeners = new ArrayList<>(); @@ -182,7 +181,6 @@ public final class ImagePanel extends JPanel implements MediaDisplay { private int time = 0; //private int selectedDepth = -1; - //private int freeTransformDepth = -1; private boolean doFreeTransform = false; @@ -208,10 +206,10 @@ public final class ImagePanel extends JPanel implements MediaDisplay { private Point2D registrationPoint = null; private Point2D registrationPointUpdated = null; - + private int mode = Cursor.DEFAULT_CURSOR; private Rectangle2D bounds; - + private Matrix transform; private AffineTransform transformUpdated; @@ -262,7 +260,7 @@ public final class ImagePanel extends JPanel implements MediaDisplay { private boolean autoPlayed = false; private boolean frozen = false; - + private boolean frozenButtons = false; private boolean muted = false; @@ -308,57 +306,57 @@ public final class ImagePanel extends JPanel implements MediaDisplay { private List showPoints2 = new ArrayList<>(); private int displayedFrame = 0; - + private JPanel topPanel; - + private TagNameResolverInterface tagNameResolver = new DefaultTagNameResolver(); - + private boolean showAllDepthLevelsInfo = true; - + private boolean selectionMode = false; - + private boolean transformSelectionMode = false; - + private boolean multiSelect = false; - + private boolean inMoving = false; - + private List selectedDepths = new ArrayList<>(); - + private final List parentFrames = new ArrayList<>(); - + private final List parentDepths = new ArrayList<>(); private final List parentTimelineds = new ArrayList<>(); public void setFrozenButtons(boolean frozenButtons) { this.frozenButtons = frozenButtons; - } - + } + public boolean isMultiSelect() { return multiSelect; - } - + } + public void setMultiSelect(boolean multiSelect) { this.multiSelect = multiSelect; - } - + } + public void setSelectionMode(boolean selectionMode) { this.selectionMode = selectionMode; - } - + } + public void setTransformSelectionMode(boolean transformSelectionMode) { this.transformSelectionMode = transformSelectionMode; - } + } public void setTagNameResolver(TagNameResolverInterface tagNameResolver) { this.tagNameResolver = tagNameResolver; - } + } public void setShowAllDepthLevelsInfo(boolean showAllDepthLevelsInfo) { this.showAllDepthLevelsInfo = showAllDepthLevelsInfo; - } - + } + public void setTopPanelVisible(boolean visible) { topPanel.setVisible(visible); } @@ -391,17 +389,17 @@ public final class ImagePanel extends JPanel implements MediaDisplay { private List boundsChangeListeners = new ArrayList<>(); private List pointUpdateListeners = new ArrayList<>(); - + private List transformChangeListeners = new ArrayList<>(); public void addTransformChangeListener(Runnable listener) { transformChangeListeners.add(listener); } - + public void removeTransformChangeListener(Runnable listener) { transformChangeListeners.remove(listener); } - + public void addPointUpdateListener(PointUpdateListener listener) { pointUpdateListeners.add(listener); } @@ -415,7 +413,7 @@ public final class ImagePanel extends JPanel implements MediaDisplay { listener.pointsUpdated(points); } } - + private void fireTransformChanged() { for (Runnable listener : transformChangeListeners) { listener.run(); @@ -639,8 +637,9 @@ public final class ImagePanel extends JPanel implements MediaDisplay { } selectDepths(depths); } + public synchronized void selectDepths(List depths) { - + depths = new ArrayList<>(depths); for (int i = 0; i < depths.size(); i++) { int depth = depths.get(i); @@ -650,11 +649,11 @@ public final class ImagePanel extends JPanel implements MediaDisplay { i--; } } - + transformUpdated = null; registrationPointUpdated = null; transform = null; - + selectedDepths = new ArrayList<>(depths); doFreeTransform = false; @@ -667,27 +666,23 @@ public final class ImagePanel extends JPanel implements MediaDisplay { public List getSelectedDepths() { return new ArrayList<>(selectedDepths); - } - - public synchronized int getFrame() { - return frame; - } + } private void calculateFreeOrSelectionTransform() { if (!(doFreeTransform || selectionMode)) { return; } if (selectedDepths.isEmpty()) { - return; + return; } - + DepthState ds = null; Timeline timeline = timelined.getTimeline(); - + if (timeline.getFrameCount() <= frame) { return; } - + if (selectedDepths.size() == 1) { ds = timeline.getFrame(frame).layers.get(selectedDepths.get(0)); } @@ -712,10 +707,10 @@ public final class ImagePanel extends JPanel implements MediaDisplay { } } } else {*/ - transform = new Matrix(); - Rectangle2D transformBounds = getTransformBounds(); - registrationPointPosition = RegistrationPointPosition.CENTER; - fireBoundsChange(transformBounds, new Point2D.Double(transformBounds.getCenterX(), transformBounds.getCenterY()), registrationPointPosition); + transform = new Matrix(); + Rectangle2D transformBounds = getTransformBounds(); + registrationPointPosition = RegistrationPointPosition.CENTER; + fireBoundsChange(transformBounds, new Point2D.Double(transformBounds.getCenterX(), transformBounds.getCenterY()), registrationPointPosition); //} } @@ -726,7 +721,7 @@ public final class ImagePanel extends JPanel implements MediaDisplay { } freeTransformDepths(depths); } - + public synchronized void freeTransformDepths(List depths) { selectedDepths = new ArrayList<>(depths); doFreeTransform = !depths.isEmpty(); @@ -739,7 +734,7 @@ public final class ImagePanel extends JPanel implements MediaDisplay { redraw(); iconPanel.requestFocusInWindow(); } - + private void centerImage() { Timelined tim = timelined; if (tim == null) { @@ -1184,14 +1179,14 @@ public final class ImagePanel extends JPanel implements MediaDisplay { MouseInputAdapter mouseInputAdapter = new MouseInputAdapter() { @Override public void mouseClicked(MouseEvent e) { - - if (e.getClickCount() == 2 && selectionMode && !transformSelectionMode) { - + + if (e.getClickCount() == 2 && selectionMode && !transformSelectionMode) { + DepthState ds = depthStateUnderCursor; if (ds != null) { CharacterTag cht = ds.getCharacter(); if (cht instanceof Timelined) { - synchronized(lock) { + synchronized (lock) { parentTimelineds.add(timelined); parentDepths.add(ds.depth); parentFrames.add(ds.frame.frame); @@ -1202,10 +1197,10 @@ public final class ImagePanel extends JPanel implements MediaDisplay { fireMediaDisplayStateChanged(); } } - + return; } - + if (shiftDown) { List newSelectedPoints = new ArrayList<>(pointsUnderCursor); for (int i : selectedPoints) { @@ -1220,10 +1215,10 @@ public final class ImagePanel extends JPanel implements MediaDisplay { selectedPoints = new ArrayList<>(pointsUnderCursor); } calculatePointsXY(); - + if (altDown || selectionMode) { if (depthStateUnderCursor != null) { - + List newSelectedDepths = new ArrayList<>(); if (ctrlDown) { newSelectedDepths.addAll(selectedDepths); @@ -1241,7 +1236,7 @@ public final class ImagePanel extends JPanel implements MediaDisplay { freeTransformDepths(newSelectedDepths); firePlaceObjectSelected(); } - } else if ((altDown && !selectionMode) || selectionMode){ + } else if ((altDown && !selectionMode) || selectionMode) { selectDepths(newSelectedDepths); firePlaceObjectSelected(); } @@ -1256,27 +1251,27 @@ public final class ImagePanel extends JPanel implements MediaDisplay { selectDepths(new ArrayList<>()); firePlaceObjectSelected(); } - } + } } - } - + } + @Override public void mousePressed(MouseEvent e) { - if (SwingUtilities.isLeftMouseButton(e)) { - + if (SwingUtilities.isLeftMouseButton(e)) { + if (altDown || selectionMode) { if (depthStateUnderCursor != null && selectedDepths.contains(depthStateUnderCursor.depth)) { inMoving = selectionMode; - calculateFreeOrSelectionTransform(); + calculateFreeOrSelectionTransform(); } if (!selectionMode) { return; - } + } } - + mouseMoved(e); //to correctly calculate mode, because mouseMoved event is not called during dragging - setDragStart(e.getPoint()); - + setDragStart(e.getPoint()); + if (!shiftDown) { boolean selectedUnderCursor = false; for (int p : pointsUnderCursor) { @@ -1351,7 +1346,7 @@ public final class ImagePanel extends JPanel implements MediaDisplay { } updateScrollBarMinMax(); } - + if (dragStart != null && !inMoving && multiSelect) { Rectangle2D selectionRect = getSelectionRect(); if (selectionRect != null) { @@ -1431,7 +1426,7 @@ public final class ImagePanel extends JPanel implements MediaDisplay { registrationPointPosition = null; } } - + calcRect(); //do not put this inside synchronized block, it cause deadlock fireBoundsChange(getTransformBounds(), registrationPoint, registrationPointPosition); fireTransformChanged(); @@ -1451,7 +1446,7 @@ public final class ImagePanel extends JPanel implements MediaDisplay { @Override public void mouseDragged(MouseEvent e) { List points = hilightedPoints; - + if (dragStart != null && multiSelect && !inMoving && mode == Cursor.DEFAULT_CURSOR) { selectionEnd = e.getPoint(); repaint(); @@ -1533,21 +1528,21 @@ public final class ImagePanel extends JPanel implements MediaDisplay { repaint(); return; } - + //move in selection mode if (dragStart != null && selectionMode && !doFreeTransform) { if (transform == null) { return; - } + } Matrix parentMatrix = getParentMatrix(); - + Point2D mouseTransPoint = toTransformPoint(new Point2D.Double(e.getX(), e.getY())); double ex = mouseTransPoint.getX(); double ey = mouseTransPoint.getY(); Point2D dragStartTransPoint = toTransformPoint(dragStart); double dsx = dragStartTransPoint.getX(); double dsy = dragStartTransPoint.getY(); - + double deltaX = ex - dsx; double deltaY = ey - dsy; @@ -1556,7 +1551,7 @@ public final class ImagePanel extends JPanel implements MediaDisplay { t.translate(deltaX, deltaY); t.concatenate(parentMatrix.inverse().toTransform()); newTransform.preConcatenate(t); - + Point2D newRegistrationPoint = new Matrix(t).preConcatenate(parentMatrix.inverse()).concatenate(parentMatrix).transform(registrationPoint); transformUpdated = newTransform; @@ -1570,10 +1565,10 @@ public final class ImagePanel extends JPanel implements MediaDisplay { return; } - Matrix parentMatrix = getParentMatrix(); + Matrix parentMatrix = getParentMatrix(); Point2D mouseTransPoint = toTransformPoint(new Point2D.Double(e.getX(), e.getY())); //mouseTransPoint = parentMatrix.inverse().transform(mouseTransPoint); - + double ex = mouseTransPoint.getX(); double ey = mouseTransPoint.getY(); Point2D dragStartTransPoint = toTransformPoint(dragStart); @@ -1608,7 +1603,7 @@ public final class ImagePanel extends JPanel implements MediaDisplay { AffineTransform newTransform = new AffineTransform(transform.toTransform()); AffineTransform t = new AffineTransform(); Point2D bStart = parentMatrix.transform(new Point2D.Double(bounds.getX(), bounds.getY())); - + t.translate(bStart.getX(), bStart.getY()); t.shear(shearX, 0); t.translate(-bStart.getX(), -bStart.getY()); @@ -1627,7 +1622,7 @@ public final class ImagePanel extends JPanel implements MediaDisplay { AffineTransform newTransform = new AffineTransform(transform.toTransform()); AffineTransform t = new AffineTransform(); - Point2D bStart = parentMatrix.transform(new Point2D.Double(bounds.getX(), bounds.getY())); + Point2D bStart = parentMatrix.transform(new Point2D.Double(bounds.getX(), bounds.getY())); t.translate(bStart.getX(), bStart.getY()); t.shear(0, shearY); t.translate(-bStart.getX(), -bStart.getY()); @@ -1646,7 +1641,7 @@ public final class ImagePanel extends JPanel implements MediaDisplay { AffineTransform newTransform = new AffineTransform(transform.toTransform()); AffineTransform t = new AffineTransform(); - Point2D bStart = parentMatrix.transform(new Point2D.Double(bounds.getX(), bounds.getY())); + Point2D bStart = parentMatrix.transform(new Point2D.Double(bounds.getX(), bounds.getY())); t.translate(bStart.getX(), bStart.getY()); t.shear(0, shearY); t.translate(-bStart.getX(), -bStart.getY()); @@ -1838,7 +1833,7 @@ public final class ImagePanel extends JPanel implements MediaDisplay { t.translate(deltaX, deltaY); t.concatenate(parentMatrix.inverse().toTransform()); newTransform.preConcatenate(t); - + Point2D newRegistrationPoint = new Matrix(t).preConcatenate(parentMatrix.inverse()).concatenate(parentMatrix).transform(registrationPoint); transformUpdated = newTransform; @@ -1858,7 +1853,7 @@ public final class ImagePanel extends JPanel implements MediaDisplay { newTransform.preConcatenate(t); Point2D newRegistrationPoint = new Matrix(t).preConcatenate(parentMatrix.inverse()).concatenate(parentMatrix).transform(registrationPoint); - + transformUpdated = newTransform; registrationPointUpdated = newRegistrationPoint; repaint(); @@ -2274,8 +2269,7 @@ public final class ImagePanel extends JPanel implements MediaDisplay { private void calcRect(Zoom z) { synchronized (ImagePanel.this) { - - + Timelined topTimelined = getTopTimelined(); if (_img != null || topTimelined != null) { //int w1 = (int) (_img.getWidth() * (lowQuality ? LQ_FACTOR : 1)); @@ -2337,7 +2331,7 @@ public final class ImagePanel extends JPanel implements MediaDisplay { if (h < h2 && w < w2) { offsetPoint.setLocation(iconPanel.getWidth() / 2 - w / 2 - dx, iconPanel.getHeight() / 2 - h / 2 - dy); updateScrollBars(); - } + } } else { boolean doMove = h > h2 || w > w2; if (zoom.fit) { @@ -2670,8 +2664,8 @@ public final class ImagePanel extends JPanel implements MediaDisplay { @Override public void run() { drawFrame(thisTimer, true); - } - }, 0); + } + }, 0); } } } @@ -2804,14 +2798,7 @@ public final class ImagePanel extends JPanel implements MediaDisplay { @Override public synchronized void zoom(Zoom zoom) { zoom(zoom, false, false); - } - - public void zoomFit() { - Zoom z = new Zoom(); - z.value = 1.0; - z.fit = true; - zoom(z, false, true); - } + } private synchronized void zoom(Zoom zoom, boolean useCursor, boolean forced) { if (!zoomAvailable) { @@ -2839,8 +2826,8 @@ public final class ImagePanel extends JPanel implements MediaDisplay { int dx = (int) (((cursorTransAfter.getX() - cursorTransBefore.getX()) * zoomDouble) / SWF.unitDivisor); int dy = (int) (((cursorTransAfter.getY() - cursorTransBefore.getY()) * zoomDouble) / SWF.unitDivisor); - - offsetPoint.setLocation(offsetPoint.getX() + dx, offsetPoint.getY() + dy); + + offsetPoint.setLocation(offsetPoint.getX() + dx, offsetPoint.getY() + dy); updateScrollBars(); @@ -2861,6 +2848,13 @@ public final class ImagePanel extends JPanel implements MediaDisplay { } } + public void zoomFit() { + Zoom z = new Zoom(); + z.value = 1.0; + z.fit = true; + zoom(z, false, true); + } + @Override public synchronized BufferedImage printScreen() { return iconPanel.getLastImage(); @@ -2874,7 +2868,7 @@ public final class ImagePanel extends JPanel implements MediaDisplay { double h1 = bounds.getHeight() / SWF.unitDivisor; double w2 = iconPanel.getWidth(); - double h2 = iconPanel.getHeight(); + double h2 = iconPanel.getHeight(); double w; double h; @@ -2971,7 +2965,7 @@ public final class ImagePanel extends JPanel implements MediaDisplay { this.timelined = drawable; this.parentTimelineds.clear(); this.parentFrames.clear(); - this.parentDepths.clear(); + this.parentDepths.clear(); centerImage(); this.swf = swf; zoomAvailable = allowZoom; @@ -3195,7 +3189,7 @@ public final class ImagePanel extends JPanel implements MediaDisplay { } fireMediaDisplayStateChanged(); } - + public Matrix getParentMatrix() { synchronized (lock) { Matrix parentMatrix = new Matrix(); @@ -3205,13 +3199,17 @@ public final class ImagePanel extends JPanel implements MediaDisplay { parentMatrix = parentMatrix.concatenate(new Matrix(parentDepthState.matrix)); } return parentMatrix; - } + } } + public synchronized int getFrame() { + return frame; + } + private static SerializableImage getFrame(Rectangle realRect, RECT rect, ExportRectangle viewRect, SWF swf, int frame, int time, Timelined drawable, RenderContext renderContext, List selectedDepths, boolean doFreeTransform, double zoom, Reference registrationPointRef, Reference boundsRef, Matrix transform, Matrix temporaryMatrix, Matrix newMatrix, boolean selectionMode, List parentTimelineds, List parentDepths, List parentFrames, Matrix parentMatrix - ) { + ) { Timeline timeline = drawable.getTimeline(); SerializableImage img; @@ -3232,24 +3230,24 @@ public final class ImagePanel extends JPanel implements MediaDisplay { m.scale(zoom); Matrix fullM = m.clone(); - + for (int i = 0; i < selectedDepths.size(); i++) { if (newMatrix != null) { DepthState ds = timeline.getFrame(frame).layers.get(selectedDepths.get(i)); if (ds != null) { ds.temporaryMatrix = newMatrix.concatenate(new Matrix(ds.matrix)).toMATRIX(); - } + } } - } + } Frame fr = timeline.getFrame(frame); - + Frame bgFr = timeline.getFrame(frame); - + if (!parentTimelineds.isEmpty()) { bgFr = parentTimelineds.get(0).getTimeline().getFrame(parentFrames.get(0)); } - + if (bgFr == null || fr == null) { return image; } @@ -3258,36 +3256,35 @@ public final class ImagePanel extends JPanel implements MediaDisplay { Graphics2D g = (Graphics2D) image.getBufferedImage().getGraphics(); g.setPaint(backgroundColor.toColor()); g.fillRect(realRect.x, realRect.y, realRect.width, realRect.height); - } - - + } + parentMatrix = new Matrix(); List ignoreDepths = new ArrayList<>(); for (int i = 0; i < parentTimelineds.size(); i++) { - Timelined parentTimelined = parentTimelineds.get(i); + Timelined parentTimelined = parentTimelineds.get(i); DepthState parentDepthState = parentTimelineds.get(i).getTimeline().getDepthState(parentFrames.get(i), parentDepths.get(i)); - + ignoreDepths.add(parentDepthState.depth); parentTimelined.getTimeline().toImage(parentFrames.get(i), 0, new RenderContext(), image, image, false, parentMatrix.preConcatenate(m), new Matrix(), parentMatrix.preConcatenate(m), null, zoom, true, viewRect, parentMatrix.preConcatenate(m), true, Timeline.DRAW_MODE_ALL, 0, !Configuration.disableBitmapSmoothing.get(), ignoreDepths); parentMatrix = parentMatrix.concatenate(new Matrix(parentDepthState.matrix)); - ignoreDepths.clear(); + ignoreDepths.clear(); } - + if (!parentTimelineds.isEmpty()) { Graphics2D g = (Graphics2D) image.getBufferedImage().getGraphics(); g.setPaint(new Color(255, 255, 255, 128)); g.fillRect(realRect.x, realRect.y, realRect.width, realRect.height); } - + timeline.toImage(frame, time, renderContext, image, image, false, parentMatrix.preConcatenate(m), new Matrix(), parentMatrix.preConcatenate(m), null, zoom, true, viewRect, parentMatrix.preConcatenate(m), true, Timeline.DRAW_MODE_ALL, 0, !Configuration.disableBitmapSmoothing.get(), ignoreDepths); Graphics2D gg = (Graphics2D) image.getGraphics(); gg.setStroke(new BasicStroke(3)); gg.setPaint(Color.green); - gg.setTransform(AffineTransform.getTranslateInstance(0, 0)); - + gg.setTransform(AffineTransform.getTranslateInstance(0, 0)); + if (!doFreeTransform) { for (int selectedDepth : selectedDepths) { DepthState ds = null; @@ -3343,11 +3340,11 @@ public final class ImagePanel extends JPanel implements MediaDisplay { int dframe = time % drawableFrameCount; //Matrix finalMatrix = Matrix.getScaleInstance(1 / SWF.unitDivisor).concatenate(m).concatenate(new Matrix(ds.matrix)); - + Matrix transform2 = transform; - + transform2 = transform.concatenate(new Matrix(ds.matrix)); - + Shape outline = dt.getOutline(true, dframe, time, ds.ratio, renderContext, transform2, true, viewRect, zoom); if (temporaryMatrix != null) { @@ -3371,29 +3368,29 @@ public final class ImagePanel extends JPanel implements MediaDisplay { } if (totalBounds == null) { - totalBounds = new Rectangle(0,0,1,1); + totalBounds = new Rectangle(0, 0, 1, 1); } - + boundsRef.setVal(totalBounds); gg.setStroke(new BasicStroke(1)); gg.setPaint(Color.black); if (doFreeTransform) { gg.draw(totalBounds); - drawHandles(gg, totalBounds); + drawHandles(gg, totalBounds); Point2D regPoint = registrationPointRef.getVal(); if (regPoint == null) { regPoint = new Point2D.Double(totalBounds.getCenterX(), totalBounds.getCenterY()); } drawRegistrationPoint(gg, regPoint); } - + if (timeline != null && timeline.getFrameCount() > frame) { for (int i = 0; i < selectedDepths.size(); i++) { int selectedDepth = selectedDepths.get(i); DepthState ds = timeline.getDepthState(frame, selectedDepth); if (ds != null) { ds.temporaryMatrix = null; - } + } } } img = image; @@ -3628,7 +3625,7 @@ public final class ImagePanel extends JPanel implements MediaDisplay { RECT rect = getTopTimelined().getRect(); synchronized (ImagePanel.this) { - synchronized (lock) { + synchronized (lock) { _viewRect = getViewRect(); } } @@ -3656,18 +3653,18 @@ public final class ImagePanel extends JPanel implements MediaDisplay { realRect.x += offsetPoint.getX(); realRect.y += offsetPoint.getY(); - Point2D rawRegistrationPoint = registrationPoint == null ? null : toImagePoint(registrationPoint); + Point2D rawRegistrationPoint = registrationPoint == null ? null : toImagePoint(registrationPoint); Reference registrationPointRef = new Reference<>(rawRegistrationPoint); if (!autoPlayed) { img = getImagePlay(); } else if (_viewRect.getHeight() < 0 || _viewRect.getWidth() < 0) { img = new SerializableImage(1, 1, BufferedImage.TYPE_4BYTE_ABGR); } else { - img = getFrame(realRect, rect, _viewRect, swf, frame, frozen ? 0 : time, timelined, renderContext, selectedDepths, doFreeTransform, zoomDouble, registrationPointRef, boundsRef, trans2, tempTrans2 == null ? null : new Matrix(tempTrans2), transform, selectionMode, parentTimelineds, parentDepths, parentFrames, getParentMatrix()); + img = getFrame(realRect, rect, _viewRect, swf, frame, frozen ? 0 : time, timelined, renderContext, selectedDepths, doFreeTransform, zoomDouble, registrationPointRef, boundsRef, trans2, tempTrans2 == null ? null : new Matrix(tempTrans2), transform, selectionMode, parentTimelineds, parentDepths, parentFrames, getParentMatrix()); } synchronized (ImagePanel.this) { - synchronized (lock) { + synchronized (lock) { Rectangle2D newBounds = getTransformBounds(); if (newBounds != null) { @@ -3678,9 +3675,9 @@ public final class ImagePanel extends JPanel implements MediaDisplay { newBounds.getCenterY()); } } - } + } } - + sw.stop(); if (sw.getElapsedMilliseconds() > 100) { if (Configuration.showSlowRenderingWarning.get()) { @@ -3764,7 +3761,7 @@ public final class ImagePanel extends JPanel implements MediaDisplay { first = false; CharacterTag c = ds.getCharacter(); - + ret.append(tagNameResolver.getTagName(c)); if (ds.depth > -1) { ret.append(" "); @@ -3864,7 +3861,7 @@ public final class ImagePanel extends JPanel implements MediaDisplay { } } - drawReady = true; + drawReady = true; } } synchronized (delayObject) { @@ -3888,15 +3885,15 @@ public final class ImagePanel extends JPanel implements MediaDisplay { } } } - + if (soundInfo.syncStop) { return; - } + } } - + if (soundPlayers.size() > MAX_SOUND_CHANNELS) { return; - } + } } final SoundTagPlayer sp; try { @@ -3904,7 +3901,7 @@ public final class ImagePanel extends JPanel implements MediaDisplay { if (soundInfo != null && soundInfo.hasLoops) { loopCount = Math.max(1, soundInfo.loopCount); } - + sp = new SoundTagPlayer(soundInfo, st, loopCount, false, resample); sp.addEventListener(new MediaDisplayListener() { @Override @@ -4037,7 +4034,7 @@ public final class ImagePanel extends JPanel implements MediaDisplay { long delay = getMsPerFrame(); if (isSingleFrame) { drawFrame(thisTimer, true); - + fireMediaDisplayStateChanged(); } else { //Time before drawing current frame @@ -4165,6 +4162,7 @@ public final class ImagePanel extends JPanel implements MediaDisplay { /** * Goto frame + * * @param frame 1-based frame */ @Override @@ -4174,15 +4172,15 @@ public final class ImagePanel extends JPanel implements MediaDisplay { } Timeline timeline = timelined.getTimeline(); if (frame > timeline.getFrameCount()) { - frame = timeline.getFrameCount(); + frame = timeline.getFrameCount(); } if (frame < 1) { - frame = 1; + frame = 1; } this.autoPlayed = true; this.frame = frame - 1; - this.prevFrame = -1; + this.prevFrame = -1; stopInternal(); redraw(); fireMediaDisplayStateChanged(); @@ -4265,8 +4263,8 @@ public final class ImagePanel extends JPanel implements MediaDisplay { public RegistrationPointPosition getRegistrationPointPosition() { return registrationPointPosition; - } - + } + public void setRegistrationPoint(Point2D registrationPoint) { this.registrationPoint = registrationPoint; this.registrationPointPosition = null; @@ -4300,7 +4298,7 @@ public final class ImagePanel extends JPanel implements MediaDisplay { fireTransformChanged(); } - private Point2D toTransformPoint(Point2D point) { + private Point2D toTransformPoint(Point2D point) { double zoomDouble = zoom.fit ? getZoomToFit() : zoom.value; if (lowQuality) { zoomDouble /= LQ_FACTOR; @@ -4345,12 +4343,12 @@ public final class ImagePanel extends JPanel implements MediaDisplay { Point2D bottomRight = toImagePoint(new Point2D.Double(rect.getMaxX(), rect.getMaxY())); return new Rectangle2D.Double(topLeft.getX(), topLeft.getY(), bottomRight.getX() - topLeft.getX(), bottomRight.getY() - topLeft.getY()); } - + private Point2D toParentPoint(Point2D point) { point = getParentMatrix().transform(point); return point; } - + private Rectangle2D toParentRect(Rectangle2D rect) { Point2D topLeft = toParentPoint(new Point2D.Double(rect.getMinX(), rect.getMinY())); Point2D bottomRight = toParentPoint(new Point2D.Double(rect.getMaxX(), rect.getMaxY())); @@ -4370,16 +4368,16 @@ public final class ImagePanel extends JPanel implements MediaDisplay { if (freeTransformDepth == -1 && selectionMode && transform != null && selectedDepth != -1 && timeline.getFrameCount() > frame) { ds = timeline.getFrame(frame).layers.get(selectedDepth); }*/ - + if (timeline.getFrameCount() <= frame) { - return new Rectangle2D.Double(0,0,1,1); + return new Rectangle2D.Double(0, 0, 1, 1); } - + Matrix newMatrix = getNewMatrix(); - + if (newMatrix == null) { - return new Rectangle2D.Double(0,0,1,1); - } + return new Rectangle2D.Double(0, 0, 1, 1); + } RenderContext renderContext = new RenderContext(); renderContext.displayObjectCache = displayObjectCache; if (cursorPosition != null && !doFreeTransform) { @@ -4438,8 +4436,8 @@ public final class ImagePanel extends JPanel implements MediaDisplay { this.pathPosition = pathPosition; this.closestPoint = closestPoint; } - } - + } + public Timelined getTopTimelined() { synchronized (lock) { if (!parentTimelineds.isEmpty()) { diff --git a/src/com/jpexs/decompiler/flash/gui/Main.java b/src/com/jpexs/decompiler/flash/gui/Main.java index 0eadf3ce7..0dec461b6 100644 --- a/src/com/jpexs/decompiler/flash/gui/Main.java +++ b/src/com/jpexs/decompiler/flash/gui/Main.java @@ -665,7 +665,7 @@ public class Main { private static void deleteCookiesAfterRun(File tempFile) { SharedObjectsStorage.removeChangedListener(tempFile, runCookieListener); - File solDir = SharedObjectsStorage.getSolDirectoryForLocalFile(tempFile); + File solDir = SharedObjectsStorage.getSolDirectoryForLocalFile(tempFile); File origSolDir = runningSWF.getFile() == null ? null : SharedObjectsStorage.getSolDirectoryForLocalFile(new File(runningSWF.getFile())); if (solDir != null) { WatchKey foundKey = null; @@ -674,20 +674,20 @@ public class Main { foundKey = key; break; } - } + } if (foundKey != null) { SharedObjectsStorage.watchedCookieDirectories.remove(foundKey); } - + View.execInEventDispatchLater(new Runnable() { - public void run() { + public void run() { if (solDir.exists()) { - - if (origSolDir != null && origSolDir.exists()) { + + if (origSolDir != null && origSolDir.exists()) { for (File f : origSolDir.listFiles()) { f.delete(); } - + for (File f : solDir.listFiles()) { try { Files.copy(f.toPath(), origSolDir.toPath().resolve(f.getName()), StandardCopyOption.REPLACE_EXISTING, StandardCopyOption.COPY_ATTRIBUTES); @@ -696,12 +696,12 @@ public class Main { } } } - + for (File f : solDir.listFiles()) { f.delete(); } - solDir.delete(); - } + solDir.delete(); + } } }); } @@ -730,7 +730,7 @@ public class Main { } catch (IOException ex) { //ignored } - } + } } runCookieListener = new CookiesChangedListener() { @@ -753,7 +753,7 @@ public class Main { } catch (IOException ex) { //ignored } - } + } } }; SharedObjectsStorage.addChangedListener(tempFile, runCookieListener); @@ -1344,7 +1344,7 @@ public class Main { @Override public boolean accept(File f) { return (f.getName().toLowerCase(Locale.ENGLISH).endsWith(".swf")) - || (f.getName().toLowerCase(Locale.ENGLISH).endsWith(".spl")) + || (f.getName().toLowerCase(Locale.ENGLISH).endsWith(".spl")) || (f.isDirectory()); } @@ -2014,30 +2014,30 @@ public class Main { if (fileName != null) { Configuration.addRecentFile(fileName); SharedObjectsStorage.addChangedListener(new File(fileName), new CookiesChangedListener() { - + Timer timer; - + @Override - public void cookiesChanged(File swfFile, List cookies) { + public void cookiesChanged(File swfFile, List cookies) { if (timer != null) { return; } - + timer = new Timer(); timer.schedule(new TimerTask() { @Override public void run() { - View.execInEventDispatchLater(new Runnable(){ + View.execInEventDispatchLater(new Runnable() { @Override public void run() { getMainFrame().getPanel().refreshTree(); timer = null; - } + } }); - - } + + } }, 500); - + } }); if (watcher != null && Configuration.checkForModifications.get()) { @@ -2151,8 +2151,8 @@ public class Main { FileFilter swfFilter = new FileFilter() { @Override public boolean accept(File f) { - return (f.getName().toLowerCase(Locale.ENGLISH).endsWith(".swf")) - || (f.getName().toLowerCase(Locale.ENGLISH).endsWith(".spl")) + return (f.getName().toLowerCase(Locale.ENGLISH).endsWith(".swf")) + || (f.getName().toLowerCase(Locale.ENGLISH).endsWith(".spl")) || (f.isDirectory()); } @@ -2396,8 +2396,8 @@ public class Main { FileFilter swfFilter = new FileFilter() { @Override public boolean accept(File f) { - return (f.getName().toLowerCase(Locale.ENGLISH).endsWith(".swf")) - || (f.getName().toLowerCase(Locale.ENGLISH).endsWith(".spl")) + return (f.getName().toLowerCase(Locale.ENGLISH).endsWith(".swf")) + || (f.getName().toLowerCase(Locale.ENGLISH).endsWith(".spl")) || (f.isDirectory()); } @@ -2583,10 +2583,10 @@ public class Main { File dir = SharedObjectsStorage.watchedCookieDirectories.get(key); java.nio.file.Path child = dir.toPath().resolve(filename); File fullPath = child.toFile(); - + View.execInEventDispatchLater(new Runnable() { @Override - public void run() { + public void run() { SharedObjectsStorage.watchedDirectoryChanged(fullPath); } }); diff --git a/src/com/jpexs/decompiler/flash/gui/MainFrameRibbon.java b/src/com/jpexs/decompiler/flash/gui/MainFrameRibbon.java index dfd6dd846..7a120f7be 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainFrameRibbon.java +++ b/src/com/jpexs/decompiler/flash/gui/MainFrameRibbon.java @@ -158,11 +158,11 @@ public final class MainFrameRibbon extends AppRibbonFrame { SWF easySwf = panel.getEasyPanel().getSwf(); if (easySwf != null) { - Configuration.lastSessionEasySwf.set(easySwf.getFile()+ "|" + easySwf.getFileTitle()); + Configuration.lastSessionEasySwf.set(easySwf.getFile() + "|" + easySwf.getFileTitle()); } else { Configuration.lastSessionEasySwf.set(""); } - + String pathResources = panel.tagTree.getSelectionPathString(); if (pathResources != null) { Configuration.lastSessionSelection.set(pathResources); diff --git a/src/com/jpexs/decompiler/flash/gui/MainPanel.java b/src/com/jpexs/decompiler/flash/gui/MainPanel.java index bfce7bb8c..d09a9aa3c 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/MainPanel.java @@ -500,7 +500,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se public void replaceItemPin(TreeItem oldItem, TreeItem newItem) { pinsPanel.replaceItem(oldItem, newItem); } - + public void refreshPinnedScriptPacks() { pinsPanel.refreshScriptPacks(); } @@ -1473,7 +1473,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se } } - List> expandedNodes = View.getExpandedNodes(tagTree); + List> expandedNodes = View.getExpandedNodes(tagTree); previewPanel.clear(); openables.set(index, newSwfs); @@ -1482,7 +1482,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se Main.searchResultsStorage.destroySwf(s); } Openable openable = newSwfs.size() > 0 ? newSwfs.get(0) : null; - + easyPanel.setSwfs(new ArrayList<>(getAllSwfs())); if (openable instanceof SWF) { easyPanel.setSwf((SWF) openable); @@ -1505,9 +1505,9 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se previewPanel.clear(); openables.add(newOpenables); - + easyPanel.setSwfs(new ArrayList<>(getAllSwfs())); - + Openable openable = newOpenables.size() > 0 ? newOpenables.get(0) : null; if (openable != null) { updateUi(openable); @@ -1831,7 +1831,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se mainMenu.updateComponents(null); previewPanel.clear(); - dumpPreviewPanel.clear(); + dumpPreviewPanel.clear(); doFilter(); return true; } @@ -1901,14 +1901,12 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se List newFoldersFilter = findPanel.getFolders(); if (isFilterEmpty(oldFilter) && oldFoldersFilter.isEmpty()) { - unfilteredExpandedNodes.clear(); + unfilteredExpandedNodes.clear(); unfilteredExpandedNodes.addAll(View.getExpandedNodes(tree)); } - if ( - oldFilter.trim().equals(newFilter.trim()) - && oldFoldersFilter.equals(newFoldersFilter) - ) { + if (oldFilter.trim().equals(newFilter.trim()) + && oldFoldersFilter.equals(newFoldersFilter)) { return; } @@ -3161,7 +3159,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se } } List items = getSelected(); - + String selected; if (scopeTextTags.isEmpty()) { selected = null; @@ -5043,6 +5041,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se public boolean replace(List items, boolean create) { return replace(items, create, true); } + public boolean replace(List items, boolean create, boolean fill) { if (items.isEmpty()) { return false; @@ -5250,14 +5249,14 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se public void replaceNoFillButtonActionPerformed(List items) { replace(items, false, false); - } + } public boolean replaceNoFill(TreeItem item) { List items = new ArrayList<>(); items.add(item); return replace(items, false, false); } - + private void showSvgImportWarning() { ViewMessages.showMessageDialog(this, AppStrings.translate("message.warning.svgImportExperimental"), AppStrings.translate("message.warning"), JOptionPane.WARNING_MESSAGE, Configuration.warningSvgImport); } @@ -5684,11 +5683,11 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se public boolean showView(int view) { View.checkAccess(); - + if (view == VIEW_EASY && !EasyPanel.EASY_AVAILABLE) { view = VIEW_RESOURCES; - } - + } + setTreeModel(view); switch (view) { case VIEW_DUMP: @@ -5731,8 +5730,8 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se reload(true); updateUiWithCurrentOpenable(); return true; - case VIEW_EASY: - SWF swf = getCurrentSwf(); + case VIEW_EASY: + SWF swf = getCurrentSwf(); pinsPanel.setVisible(false); currentView = view; Configuration.lastView.set(currentView); @@ -5741,7 +5740,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se easyPanel.setSwf(swf); if (!isWelcomeScreen) { showContentPanelCard(EASY_PANEL); - } + } return true; case VIEW_TAGLIST: easyPanel.setNoSwf(); @@ -5978,7 +5977,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se @Override public boolean isModified() { return false; - } + } @Override public ReadOnlyTagList getTags() { @@ -6097,7 +6096,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se if (currentView == VIEW_DUMP) { dumpViewReload(forceReload); return; - } + } /*else if (currentView == VIEW_TAGLIST) { tagListViewReload(forceReload); return; @@ -6109,7 +6108,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se if (treePath != null && tree.getFullModel().treePathExists(treePath)) { treeItem = (TreeItem) treePath.getLastPathComponent(); } - + if (currentView == VIEW_EASY) { if (treeItem != null) { Openable op = treeItem.getOpenable(); @@ -6512,8 +6511,8 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se public void setErrorState(ErrorState errorState) { statusPanel.setErrorState(errorState); - } - + } + private void disposeInner(Container container) { for (Component c : container.getComponents()) { if (c instanceof Container) { @@ -6736,5 +6735,5 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se public EasyPanel getEasyPanel() { return easyPanel; - } + } } diff --git a/src/com/jpexs/decompiler/flash/gui/ScrollablePanel.java b/src/com/jpexs/decompiler/flash/gui/ScrollablePanel.java index bba7e54fc..9ec304235 100644 --- a/src/com/jpexs/decompiler/flash/gui/ScrollablePanel.java +++ b/src/com/jpexs/decompiler/flash/gui/ScrollablePanel.java @@ -33,8 +33,8 @@ import javax.swing.SwingConstants; * customize the scrollable features by using newly provided setter methods so * you don't have to extend this class every time. *

- * Scrollable amounts can be specified as a percentage of the viewport size or as - * an actual pixel value. The amount can be changed for both unit and block + * Scrollable amounts can be specified as a percentage of the viewport size or + * as an actual pixel value. The amount can be changed for both unit and block * scrolling for both horizontal and vertical scrollbars. *

* The Scrollable interface only provides a boolean value for determining @@ -175,13 +175,13 @@ public class ScrollablePanel extends JPanel implements Scrollable, SwingConstant * * @param orientation specify the scrolling orientation. Must be either: * SwingConstants.HORIZONTAL or SwingConstants.VERTICAL. - * @param type - * @param amount a value used with the IncrementType to determine the - * scrollable amount * @param type specify how the amount parameter in the calculation of the * scrollable amount. Valid values are: IncrementType.PERCENT - treat the * amount as a % of the viewport size IncrementType.PIXEL - treat the amount * as the scrollable amount + * @param amount a value used with the IncrementType to determine the + * scrollable amount + */ public void setScrollableBlockIncrement(int orientation, IncrementType type, int amount) { IncrementInfo info = new IncrementInfo(type, amount); diff --git a/src/com/jpexs/decompiler/flash/gui/TimelinedMaker.java b/src/com/jpexs/decompiler/flash/gui/TimelinedMaker.java index 404f158e0..9055e126f 100644 --- a/src/com/jpexs/decompiler/flash/gui/TimelinedMaker.java +++ b/src/com/jpexs/decompiler/flash/gui/TimelinedMaker.java @@ -63,7 +63,7 @@ import java.util.Set; * @author JPEXS */ public class TimelinedMaker { - + public static SWF makeTimelinedImage(ImageTag imageTag) { SWF swf = new SWF(); swf.gfx = imageTag.getSwf().gfx; @@ -191,7 +191,7 @@ public class TimelinedMaker { } return swf; } - + public static Timelined makeTimelined(final Tag tag) { if (tag instanceof ImageTag) { return makeTimelinedImage((ImageTag) tag); @@ -267,7 +267,7 @@ public class TimelinedMaker { timeline.addFrame(f); timeline.fontFrameNum = frame; } else if (tag instanceof SoundTag) { - + //empty } else { Frame f = new Frame(timeline, 0); DepthState ds = new DepthState(tag.getSwf(), f, f); @@ -287,7 +287,7 @@ public class TimelinedMaker { @Override public RECT getRect(Set added) { if (!(tag instanceof BoundedTag)) { - return new RECT(0,1,0,1); + return new RECT(0, 1, 0, 1); } BoundedTag bt = (BoundedTag) tag; if (!added.contains(bt)) { @@ -308,7 +308,7 @@ public class TimelinedMaker { @Override public boolean isModified() { return false; - } + } @Override public ReadOnlyTagList getTags() { diff --git a/src/com/jpexs/decompiler/flash/gui/TransformPanel.java b/src/com/jpexs/decompiler/flash/gui/TransformPanel.java index 4287c095e..72b954980 100644 --- a/src/com/jpexs/decompiler/flash/gui/TransformPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/TransformPanel.java @@ -124,7 +124,7 @@ public class TransformPanel extends JPanel { private Map cardContents = new LinkedHashMap<>(); private Map cardPlusMinusLabels = new LinkedHashMap<>(); - + private static final char PLUS_CHAR = '\u2BC8'; private static final char MINUS_CHAR = '\u2BC6'; @@ -175,6 +175,7 @@ public class TransformPanel extends JPanel { public TransformPanel(ImagePanel imagePanel) { this(imagePanel, true); } + public TransformPanel(ImagePanel imagePanel, boolean headerLabel) { imagePanel.addBoundsChangeListener(new BoundsChangeListener() { diff --git a/src/com/jpexs/decompiler/flash/gui/colordialog/MainSwatchPanel.java b/src/com/jpexs/decompiler/flash/gui/colordialog/MainSwatchPanel.java new file mode 100644 index 000000000..c5bd3db2a --- /dev/null +++ b/src/com/jpexs/decompiler/flash/gui/colordialog/MainSwatchPanel.java @@ -0,0 +1,327 @@ +/* + * Copyright (C) 2025 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 . + */ +package com.jpexs.decompiler.flash.gui.colordialog; + +import java.awt.Color; +import java.awt.Dimension; +import javax.swing.UIManager; + +/** + * + * @author JPEXS + */ +class MainSwatchPanel extends MySwatchPanel { + + protected void initValues() { + swatchSize = UIManager.getDimension("ColorChooser.swatchesSwatchSize", getLocale()); + numSwatches = new Dimension(31, 9); + gap = new Dimension(1, 1); + } + + protected void initColors() { + int[] rawValues = initRawValues(); + int numColors = rawValues.length / 3; + colors = new Color[numColors]; + for (int i = 0; i < numColors; i++) { + colors[i] = new Color(rawValues[(i * 3)], rawValues[(i * 3) + 1], rawValues[(i * 3) + 2]); + } + } + + private int[] initRawValues() { + int[] rawValues = { + 255, 255, 255, // first row. + 204, 255, 255, + 204, 204, 255, + 204, 204, 255, + 204, 204, 255, + 204, 204, 255, + 204, 204, 255, + 204, 204, 255, + 204, 204, 255, + 204, 204, 255, + 204, 204, 255, + 255, 204, 255, + 255, 204, 204, + 255, 204, 204, + 255, 204, 204, + 255, 204, 204, + 255, 204, 204, + 255, 204, 204, + 255, 204, 204, + 255, 204, 204, + 255, 204, 204, + 255, 255, 204, + 204, 255, 204, + 204, 255, 204, + 204, 255, 204, + 204, 255, 204, + 204, 255, 204, + 204, 255, 204, + 204, 255, 204, + 204, 255, 204, + 204, 255, 204, + 204, 204, 204, // second row. + 153, 255, 255, + 153, 204, 255, + 153, 153, 255, + 153, 153, 255, + 153, 153, 255, + 153, 153, 255, + 153, 153, 255, + 153, 153, 255, + 153, 153, 255, + 204, 153, 255, + 255, 153, 255, + 255, 153, 204, + 255, 153, 153, + 255, 153, 153, + 255, 153, 153, + 255, 153, 153, + 255, 153, 153, + 255, 153, 153, + 255, 153, 153, + 255, 204, 153, + 255, 255, 153, + 204, 255, 153, + 153, 255, 153, + 153, 255, 153, + 153, 255, 153, + 153, 255, 153, + 153, 255, 153, + 153, 255, 153, + 153, 255, 153, + 153, 255, 204, + 204, 204, 204, // third row + 102, 255, 255, + 102, 204, 255, + 102, 153, 255, + 102, 102, 255, + 102, 102, 255, + 102, 102, 255, + 102, 102, 255, + 102, 102, 255, + 153, 102, 255, + 204, 102, 255, + 255, 102, 255, + 255, 102, 204, + 255, 102, 153, + 255, 102, 102, + 255, 102, 102, + 255, 102, 102, + 255, 102, 102, + 255, 102, 102, + 255, 153, 102, + 255, 204, 102, + 255, 255, 102, + 204, 255, 102, + 153, 255, 102, + 102, 255, 102, + 102, 255, 102, + 102, 255, 102, + 102, 255, 102, + 102, 255, 102, + 102, 255, 153, + 102, 255, 204, + 153, 153, 153, // fourth row + 51, 255, 255, + 51, 204, 255, + 51, 153, 255, + 51, 102, 255, + 51, 51, 255, + 51, 51, 255, + 51, 51, 255, + 102, 51, 255, + 153, 51, 255, + 204, 51, 255, + 255, 51, 255, + 255, 51, 204, + 255, 51, 153, + 255, 51, 102, + 255, 51, 51, + 255, 51, 51, + 255, 51, 51, + 255, 102, 51, + 255, 153, 51, + 255, 204, 51, + 255, 255, 51, + 204, 255, 51, + 153, 255, 51, + 102, 255, 51, + 51, 255, 51, + 51, 255, 51, + 51, 255, 51, + 51, 255, 102, + 51, 255, 153, + 51, 255, 204, + 153, 153, 153, // Fifth row + 0, 255, 255, + 0, 204, 255, + 0, 153, 255, + 0, 102, 255, + 0, 51, 255, + 0, 0, 255, + 51, 0, 255, + 102, 0, 255, + 153, 0, 255, + 204, 0, 255, + 255, 0, 255, + 255, 0, 204, + 255, 0, 153, + 255, 0, 102, + 255, 0, 51, + 255, 0, 0, + 255, 51, 0, + 255, 102, 0, + 255, 153, 0, + 255, 204, 0, + 255, 255, 0, + 204, 255, 0, + 153, 255, 0, + 102, 255, 0, + 51, 255, 0, + 0, 255, 0, + 0, 255, 51, + 0, 255, 102, + 0, 255, 153, + 0, 255, 204, + 102, 102, 102, // sixth row + 0, 204, 204, + 0, 204, 204, + 0, 153, 204, + 0, 102, 204, + 0, 51, 204, + 0, 0, 204, + 51, 0, 204, + 102, 0, 204, + 153, 0, 204, + 204, 0, 204, + 204, 0, 204, + 204, 0, 204, + 204, 0, 153, + 204, 0, 102, + 204, 0, 51, + 204, 0, 0, + 204, 51, 0, + 204, 102, 0, + 204, 153, 0, + 204, 204, 0, + 204, 204, 0, + 204, 204, 0, + 153, 204, 0, + 102, 204, 0, + 51, 204, 0, + 0, 204, 0, + 0, 204, 51, + 0, 204, 102, + 0, 204, 153, + 0, 204, 204, + 102, 102, 102, // seventh row + 0, 153, 153, + 0, 153, 153, + 0, 153, 153, + 0, 102, 153, + 0, 51, 153, + 0, 0, 153, + 51, 0, 153, + 102, 0, 153, + 153, 0, 153, + 153, 0, 153, + 153, 0, 153, + 153, 0, 153, + 153, 0, 153, + 153, 0, 102, + 153, 0, 51, + 153, 0, 0, + 153, 51, 0, + 153, 102, 0, + 153, 153, 0, + 153, 153, 0, + 153, 153, 0, + 153, 153, 0, + 153, 153, 0, + 102, 153, 0, + 51, 153, 0, + 0, 153, 0, + 0, 153, 51, + 0, 153, 102, + 0, 153, 153, + 0, 153, 153, + 51, 51, 51, // eighth row + 0, 102, 102, + 0, 102, 102, + 0, 102, 102, + 0, 102, 102, + 0, 51, 102, + 0, 0, 102, + 51, 0, 102, + 102, 0, 102, + 102, 0, 102, + 102, 0, 102, + 102, 0, 102, + 102, 0, 102, + 102, 0, 102, + 102, 0, 102, + 102, 0, 51, + 102, 0, 0, + 102, 51, 0, + 102, 102, 0, + 102, 102, 0, + 102, 102, 0, + 102, 102, 0, + 102, 102, 0, + 102, 102, 0, + 102, 102, 0, + 51, 102, 0, + 0, 102, 0, + 0, 102, 51, + 0, 102, 102, + 0, 102, 102, + 0, 102, 102, + 0, 0, 0, // ninth row + 0, 51, 51, + 0, 51, 51, + 0, 51, 51, + 0, 51, 51, + 0, 51, 51, + 0, 0, 51, + 51, 0, 51, + 51, 0, 51, + 51, 0, 51, + 51, 0, 51, + 51, 0, 51, + 51, 0, 51, + 51, 0, 51, + 51, 0, 51, + 51, 0, 51, + 51, 0, 0, + 51, 51, 0, + 51, 51, 0, + 51, 51, 0, + 51, 51, 0, + 51, 51, 0, + 51, 51, 0, + 51, 51, 0, + 51, 51, 0, + 0, 51, 0, + 0, 51, 51, + 0, 51, 51, + 0, 51, 51, + 0, 51, 51, + 51, 51, 51}; + return rawValues; + } +} \ No newline at end of file diff --git a/src/com/jpexs/decompiler/flash/gui/colordialog/MyRecentSwatchPanel.java b/src/com/jpexs/decompiler/flash/gui/colordialog/MyRecentSwatchPanel.java index c2543bac4..22a39ff77 100644 --- a/src/com/jpexs/decompiler/flash/gui/colordialog/MyRecentSwatchPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/colordialog/MyRecentSwatchPanel.java @@ -31,17 +31,19 @@ import javax.swing.UIManager; * @author JPEXS */ class MyRecentSwatchPanel extends MySwatchPanel { + protected void initValues() { swatchSize = UIManager.getDimension("ColorChooser.swatchesRecentSwatchSize", getLocale()); - numSwatches = new Dimension( 5, 7 ); + numSwatches = new Dimension(5, 7); gap = new Dimension(1, 1); } + protected void initColors() { Color defaultRecentColor = UIManager.getColor("ColorChooser.swatchesDefaultRecentColor", getLocale()); int numColors = numSwatches.width * numSwatches.height; colors = new Color[numColors]; String recentColorsStr = Configuration.recentColors.get(); - for (int i = 0; i < numColors ; i++) { + for (int i = 0; i < numColors; i++) { colors[i] = defaultRecentColor; } Pattern hexColorPattern = Pattern.compile("^#(?[a-fA-F0-9]{2})(?[a-fA-F0-9]{2})(?[a-fA-F0-9]{2})(?[a-fA-F0-9]{2})$"); @@ -50,24 +52,25 @@ class MyRecentSwatchPanel extends MySwatchPanel { for (int i = 0; i < colorsHex.length; i++) { Matcher m = hexColorPattern.matcher(colorsHex[i]); if (m.matches()) { - colors[i] = new Color(Integer.parseInt(m.group("r"), 16),Integer.parseInt(m.group("g"), 16),Integer.parseInt(m.group("b"), 16), Integer.parseInt(m.group("a"), 16)); + colors[i] = new Color(Integer.parseInt(m.group("r"), 16), Integer.parseInt(m.group("g"), 16), Integer.parseInt(m.group("b"), 16), Integer.parseInt(m.group("a"), 16)); } } - } + } } + public void setMostRecentColor(Color c) { if (colors[0].equals(c)) { return; } - System.arraycopy( colors, 0, colors, 1, colors.length-1); + System.arraycopy(colors, 0, colors, 1, colors.length - 1); colors[0] = c; - + List colorsAsStr = new ArrayList<>(); for (int i = 0; i < colors.length; i++) { colorsAsStr.add(new RGBA(colors[i]).toHexARGB()); } Configuration.recentColors.set(String.join(",", colorsAsStr)); - + repaint(); - } + } } diff --git a/src/com/jpexs/decompiler/flash/gui/colordialog/MySwatchChooserPanel.java b/src/com/jpexs/decompiler/flash/gui/colordialog/MySwatchChooserPanel.java index 7abbf7741..df840e88d 100644 --- a/src/com/jpexs/decompiler/flash/gui/colordialog/MySwatchChooserPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/colordialog/MySwatchChooserPanel.java @@ -15,108 +15,132 @@ * along with this program. If not, see . */ package com.jpexs.decompiler.flash.gui.colordialog; -import java.awt.*; -import java.awt.event.*; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; import java.io.Serializable; -import javax.accessibility.*; -import javax.swing.*; -import javax.swing.border.*; +import javax.accessibility.AccessibleContext; +import javax.swing.Icon; +import javax.swing.JColorChooser; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.UIManager; +import javax.swing.border.Border; +import javax.swing.border.CompoundBorder; +import javax.swing.border.LineBorder; import javax.swing.colorchooser.AbstractColorChooserPanel; import javax.swing.colorchooser.ColorSelectionModel; + /** - * The standard color swatch chooser. - * Modified Java version + * The standard color swatch chooser. Modified Java version */ public class MySwatchChooserPanel extends AbstractColorChooserPanel { + MySwatchPanel swatchPanel; //RecentSwatchPanel recentSwatchPanel; MouseListener mainSwatchListener; MouseListener recentSwatchListener; private KeyListener mainSwatchKeyListener; private KeyListener recentSwatchKeyListener; + public MySwatchChooserPanel() { super(); setInheritsPopupMenu(true); } - + void setSelectedColor(Color color) { ColorSelectionModel model = getColorSelectionModel(); if (model != null) { model.setSelectedColor(color); } } - + int getInt(Object key, int defaultValue) { Object value = UIManager.get(key, getLocale()); if (value instanceof Integer) { - return ((Integer)value).intValue(); + return ((Integer) value).intValue(); } if (value instanceof String) { try { - return Integer.parseInt((String)value); - } catch (NumberFormatException nfe) {} + return Integer.parseInt((String) value); + } catch (NumberFormatException nfe) { + //ignore + } } return defaultValue; } - + public String getDisplayName() { return UIManager.getString("ColorChooser.swatchesNameText", getLocale()); } + /** - * Provides a hint to the look and feel as to the - * KeyEvent.VK constant that can be used as a mnemonic to - * access the panel. A return value <= 0 indicates there is no mnemonic. - *

- * The return value here is a hint, it is ultimately up to the look - * and feel to honor the return value in some meaningful way. + * Provides a hint to the look and feel as to the KeyEvent.VK + * constant that can be used as a mnemonic to access the panel. A return + * value <= 0 indicates there is no mnemonic.

+ * The return value here is a hint, it is ultimately up to the look and feel + * to honor the return value in some meaningful way. *

* This implementation looks up the value from the default - * ColorChooser.swatchesMnemonic, or if it - * isn't available (or not an Integer) returns -1. - * The lookup for the default is done through the UIManager: + * ColorChooser.swatchesMnemonic, or if it isn't available (or + * not an Integer) returns -1. The lookup for the default is + * done through the UIManager: * UIManager.get("ColorChooser.swatchesMnemonic");. * * @return KeyEvent.VK constant identifying the mnemonic; <= 0 for no - * mnemonic - * @see #getDisplayedMnemonicIndex + * mnemonic @see #getDisplayedMnemonicI + * ndex * @since 1.4 */ public int getMnemonic() { return getInt("ColorChooser.swatchesMnemonic", -1); } + /** * Provides a hint to the look and feel as to the index of the character in * getDisplayName that should be visually identified as the * mnemonic. The look and feel should only use this if * getMnemonic returns a value > 0. *

- * The return value here is a hint, it is ultimately up to the look - * and feel to honor the return value in some meaningful way. For example, - * a look and feel may wish to render each - * AbstractColorChooserPanel in a JTabbedPane, - * and further use this return value to underline a character in - * the getDisplayName. + * The return value here is a hint, it is ultimately up to the look and feel + * to honor the return value in some meaningful way. For example, a look and + * feel may wish to render each AbstractColorChooserPanel in a + * JTabbedPane, and further use this return value to underline + * a character in the getDisplayName. *

* This implementation looks up the value from the default - * ColorChooser.rgbDisplayedMnemonicIndex, or if it - * isn't available (or not an Integer) returns -1. - * The lookup for the default is done through the UIManager: + * ColorChooser.rgbDisplayedMnemonicIndex, or if it isn't + * available (or not an Integer) returns -1. The lookup for the + * default is done through the UIManager: * UIManager.get("ColorChooser.swatchesDisplayedMnemonicIndex");. * - * @return Character index to render mnemonic for; -1 to provide no - * visual identifier for this panel. + * @return Character index to render mnemonic for; -1 to provide no visual + * identifier for this panel. * @see #getMnemonic * @since 1.4 */ public int getDisplayedMnemonicIndex() { return getInt("ColorChooser.swatchesDisplayedMnemonicIndex", -1); } + public Icon getSmallDisplayIcon() { return null; } + public Icon getLargeDisplayIcon() { return null; } + /** * The background color, foreground color, and font are already set to the * defaults from the defaults table before this method is called. @@ -124,14 +148,15 @@ public class MySwatchChooserPanel extends AbstractColorChooserPanel { public void installChooserPanel(JColorChooser enclosingChooser) { super.installChooserPanel(enclosingChooser); } + protected void buildChooser() { String recentStr = UIManager.getString("ColorChooser.swatchesRecentText", getLocale()); GridBagLayout gb = new GridBagLayout(); GridBagConstraints gbc = new GridBagConstraints(); JPanel superHolder = new JPanel(gb); - swatchPanel = new MainSwatchPanel(); + swatchPanel = new MainSwatchPanel(); swatchPanel.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, - getDisplayName()); + getDisplayName()); swatchPanel.setInheritsPopupMenu(true); //recentSwatchPanel = new RecentSwatchPanel(); /*recentSwatchPanel.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, @@ -145,8 +170,8 @@ public class MySwatchChooserPanel extends AbstractColorChooserPanel { //recentSwatchPanel.addMouseListener(recentSwatchListener); //recentSwatchPanel.addKeyListener(recentSwatchKeyListener); JPanel mainHolder = new JPanel(new BorderLayout()); - Border border = new CompoundBorder( new LineBorder(Color.black), - new LineBorder(Color.white) ); + Border border = new CompoundBorder(new LineBorder(Color.black), + new LineBorder(Color.white)); mainHolder.setBorder(border); mainHolder.add(swatchPanel, BorderLayout.CENTER); gbc.anchor = GridBagConstraints.LAST_LINE_START; @@ -157,7 +182,7 @@ public class MySwatchChooserPanel extends AbstractColorChooserPanel { superHolder.add(mainHolder, gbc); gbc.insets = oldInsets; //recentSwatchPanel.setInheritsPopupMenu(true); - JPanel recentHolder = new JPanel( new BorderLayout() ); + JPanel recentHolder = new JPanel(new BorderLayout()); recentHolder.setBorder(border); recentHolder.setInheritsPopupMenu(true); //recentHolder.add(recentSwatchPanel, BorderLayout.CENTER); @@ -174,6 +199,7 @@ public class MySwatchChooserPanel extends AbstractColorChooserPanel { superHolder.setInheritsPopupMenu(true); add(superHolder); } + public void uninstallChooserPanel(JColorChooser enclosingChooser) { super.uninstallChooserPanel(enclosingChooser); swatchPanel.removeMouseListener(mainSwatchListener); @@ -188,9 +214,12 @@ public class MySwatchChooserPanel extends AbstractColorChooserPanel { recentSwatchKeyListener = null; removeAll(); // strip out all the sub-components } + public void updateChooser() { } + private class RecentSwatchKeyListener extends KeyAdapter { + public void keyPressed(KeyEvent e) { if (KeyEvent.VK_SPACE == e.getKeyCode()) { /*Color color = recentSwatchPanel.getSelectedColor(); @@ -198,7 +227,9 @@ public class MySwatchChooserPanel extends AbstractColorChooserPanel { } } } + private class MainSwatchKeyListener extends KeyAdapter { + public void keyPressed(KeyEvent e) { if (KeyEvent.VK_SPACE == e.getKeyCode()) { Color color = swatchPanel.getSelectedColor(); @@ -207,7 +238,9 @@ public class MySwatchChooserPanel extends AbstractColorChooserPanel { } } } + class RecentSwatchListener extends MouseAdapter implements Serializable { + public void mousePressed(MouseEvent e) { if (isEnabled()) { /*Color color = recentSwatchPanel.getColorForLocation(e.getX(), e.getY()); @@ -217,7 +250,9 @@ public class MySwatchChooserPanel extends AbstractColorChooserPanel { } } } + class MainSwatchListener extends MouseAdapter implements Serializable { + public void mousePressed(MouseEvent e) { if (isEnabled()) { Color color = swatchPanel.getColorForLocation(e.getX(), e.getY()); @@ -229,303 +264,3 @@ public class MySwatchChooserPanel extends AbstractColorChooserPanel { } } } - - -class MainSwatchPanel extends MySwatchPanel { - protected void initValues() { - swatchSize = UIManager.getDimension("ColorChooser.swatchesSwatchSize", getLocale()); - numSwatches = new Dimension( 31, 9 ); - gap = new Dimension(1, 1); - } - protected void initColors() { - int[] rawValues = initRawValues(); - int numColors = rawValues.length / 3; - colors = new Color[numColors]; - for (int i = 0; i < numColors ; i++) { - colors[i] = new Color( rawValues[(i*3)], rawValues[(i*3)+1], rawValues[(i*3)+2] ); - } - } - private int[] initRawValues() { - int[] rawValues = { -255, 255, 255, // first row. -204, 255, 255, -204, 204, 255, -204, 204, 255, -204, 204, 255, -204, 204, 255, -204, 204, 255, -204, 204, 255, -204, 204, 255, -204, 204, 255, -204, 204, 255, -255, 204, 255, -255, 204, 204, -255, 204, 204, -255, 204, 204, -255, 204, 204, -255, 204, 204, -255, 204, 204, -255, 204, 204, -255, 204, 204, -255, 204, 204, -255, 255, 204, -204, 255, 204, -204, 255, 204, -204, 255, 204, -204, 255, 204, -204, 255, 204, -204, 255, 204, -204, 255, 204, -204, 255, 204, -204, 255, 204, -204, 204, 204, // second row. -153, 255, 255, -153, 204, 255, -153, 153, 255, -153, 153, 255, -153, 153, 255, -153, 153, 255, -153, 153, 255, -153, 153, 255, -153, 153, 255, -204, 153, 255, -255, 153, 255, -255, 153, 204, -255, 153, 153, -255, 153, 153, -255, 153, 153, -255, 153, 153, -255, 153, 153, -255, 153, 153, -255, 153, 153, -255, 204, 153, -255, 255, 153, -204, 255, 153, -153, 255, 153, -153, 255, 153, -153, 255, 153, -153, 255, 153, -153, 255, 153, -153, 255, 153, -153, 255, 153, -153, 255, 204, -204, 204, 204, // third row -102, 255, 255, -102, 204, 255, -102, 153, 255, -102, 102, 255, -102, 102, 255, -102, 102, 255, -102, 102, 255, -102, 102, 255, -153, 102, 255, -204, 102, 255, -255, 102, 255, -255, 102, 204, -255, 102, 153, -255, 102, 102, -255, 102, 102, -255, 102, 102, -255, 102, 102, -255, 102, 102, -255, 153, 102, -255, 204, 102, -255, 255, 102, -204, 255, 102, -153, 255, 102, -102, 255, 102, -102, 255, 102, -102, 255, 102, -102, 255, 102, -102, 255, 102, -102, 255, 153, -102, 255, 204, -153, 153, 153, // fourth row -51, 255, 255, -51, 204, 255, -51, 153, 255, -51, 102, 255, -51, 51, 255, -51, 51, 255, -51, 51, 255, -102, 51, 255, -153, 51, 255, -204, 51, 255, -255, 51, 255, -255, 51, 204, -255, 51, 153, -255, 51, 102, -255, 51, 51, -255, 51, 51, -255, 51, 51, -255, 102, 51, -255, 153, 51, -255, 204, 51, -255, 255, 51, -204, 255, 51, -153, 255, 51, -102, 255, 51, -51, 255, 51, -51, 255, 51, -51, 255, 51, -51, 255, 102, -51, 255, 153, -51, 255, 204, -153, 153, 153, // Fifth row -0, 255, 255, -0, 204, 255, -0, 153, 255, -0, 102, 255, -0, 51, 255, -0, 0, 255, -51, 0, 255, -102, 0, 255, -153, 0, 255, -204, 0, 255, -255, 0, 255, -255, 0, 204, -255, 0, 153, -255, 0, 102, -255, 0, 51, -255, 0 , 0, -255, 51, 0, -255, 102, 0, -255, 153, 0, -255, 204, 0, -255, 255, 0, -204, 255, 0, -153, 255, 0, -102, 255, 0, -51, 255, 0, -0, 255, 0, -0, 255, 51, -0, 255, 102, -0, 255, 153, -0, 255, 204, -102, 102, 102, // sixth row -0, 204, 204, -0, 204, 204, -0, 153, 204, -0, 102, 204, -0, 51, 204, -0, 0, 204, -51, 0, 204, -102, 0, 204, -153, 0, 204, -204, 0, 204, -204, 0, 204, -204, 0, 204, -204, 0, 153, -204, 0, 102, -204, 0, 51, -204, 0, 0, -204, 51, 0, -204, 102, 0, -204, 153, 0, -204, 204, 0, -204, 204, 0, -204, 204, 0, -153, 204, 0, -102, 204, 0, -51, 204, 0, -0, 204, 0, -0, 204, 51, -0, 204, 102, -0, 204, 153, -0, 204, 204, -102, 102, 102, // seventh row -0, 153, 153, -0, 153, 153, -0, 153, 153, -0, 102, 153, -0, 51, 153, -0, 0, 153, -51, 0, 153, -102, 0, 153, -153, 0, 153, -153, 0, 153, -153, 0, 153, -153, 0, 153, -153, 0, 153, -153, 0, 102, -153, 0, 51, -153, 0, 0, -153, 51, 0, -153, 102, 0, -153, 153, 0, -153, 153, 0, -153, 153, 0, -153, 153, 0, -153, 153, 0, -102, 153, 0, -51, 153, 0, -0, 153, 0, -0, 153, 51, -0, 153, 102, -0, 153, 153, -0, 153, 153, -51, 51, 51, // eighth row -0, 102, 102, -0, 102, 102, -0, 102, 102, -0, 102, 102, -0, 51, 102, -0, 0, 102, -51, 0, 102, -102, 0, 102, -102, 0, 102, -102, 0, 102, -102, 0, 102, -102, 0, 102, -102, 0, 102, -102, 0, 102, -102, 0, 51, -102, 0, 0, -102, 51, 0, -102, 102, 0, -102, 102, 0, -102, 102, 0, -102, 102, 0, -102, 102, 0, -102, 102, 0, -102, 102, 0, -51, 102, 0, -0, 102, 0, -0, 102, 51, -0, 102, 102, -0, 102, 102, -0, 102, 102, -0, 0, 0, // ninth row -0, 51, 51, -0, 51, 51, -0, 51, 51, -0, 51, 51, -0, 51, 51, -0, 0, 51, -51, 0, 51, -51, 0, 51, -51, 0, 51, -51, 0, 51, -51, 0, 51, -51, 0, 51, -51, 0, 51, -51, 0, 51, -51, 0, 51, -51, 0, 0, -51, 51, 0, -51, 51, 0, -51, 51, 0, -51, 51, 0, -51, 51, 0, -51, 51, 0, -51, 51, 0, -51, 51, 0, -0, 51, 0, -0, 51, 51, -0, 51, 51, -0, 51, 51, -0, 51, 51, -51, 51, 51 }; - return rawValues; - } -} diff --git a/src/com/jpexs/decompiler/flash/gui/colordialog/MySwatchPanel.java b/src/com/jpexs/decompiler/flash/gui/colordialog/MySwatchPanel.java index ebc03dc1f..eaa9e26c5 100644 --- a/src/com/jpexs/decompiler/flash/gui/colordialog/MySwatchPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/colordialog/MySwatchPanel.java @@ -31,12 +31,14 @@ import javax.swing.JPanel; * @author JPEXS */ class MySwatchPanel extends JPanel { + protected Color[] colors; protected Dimension swatchSize; protected Dimension numSwatches; protected Dimension gap; private int selRow; private int selCol; + public MySwatchPanel() { initValues(); initColors(); @@ -49,6 +51,7 @@ class MySwatchPanel extends JPanel { public void focusGained(FocusEvent e) { repaint(); } + public void focusLost(FocusEvent e) { repaint(); } @@ -103,15 +106,18 @@ class MySwatchPanel extends JPanel { } }); } + public Color getSelectedColor() { return getColorForCell(selCol, selRow); } + protected void initValues() { } + public void paintComponent(Graphics g) { - g.setColor(getBackground()); - g.fillRect(0,0,getWidth(), getHeight()); - for (int row = 0; row < numSwatches.height; row++) { + g.setColor(getBackground()); + g.fillRect(0, 0, getWidth(), getHeight()); + for (int row = 0; row < numSwatches.height; row++) { int y = row * (swatchSize.height + gap.height); for (int column = 0; column < numSwatches.width; column++) { Color c = getColorForCell(column, row); @@ -122,10 +128,10 @@ class MySwatchPanel extends JPanel { } else { x = column * (swatchSize.width + gap.width); } - g.fillRect( x, y, swatchSize.width, swatchSize.height); + g.fillRect(x, y, swatchSize.width, swatchSize.height); g.setColor(Color.black); - g.drawLine( x+swatchSize.width-1, y, x+swatchSize.width-1, y+swatchSize.height-1); - g.drawLine( x, y+swatchSize.height-1, x+swatchSize.width-1, y+swatchSize.height-1); + g.drawLine(x + swatchSize.width - 1, y, x + swatchSize.width - 1, y + swatchSize.height - 1); + g.drawLine(x, y + swatchSize.height - 1, x + swatchSize.width - 1, y + swatchSize.height - 1); if (selRow == row && selCol == column && this.isFocusOwner()) { Color c2 = new Color(c.getRed() < 125 ? 255 : 0, c.getGreen() < 125 ? 255 : 0, @@ -139,19 +145,23 @@ class MySwatchPanel extends JPanel { g.drawLine(x, y + swatchSize.height - 1, x + swatchSize.width - 1, y); } } - } + } } + public Dimension getPreferredSize() { int x = numSwatches.width * (swatchSize.width + gap.width) - 1; int y = numSwatches.height * (swatchSize.height + gap.height) - 1; - return new Dimension( x, y ); + return new Dimension(x, y); } + protected void initColors() { } + public String getToolTipText(MouseEvent e) { Color color = getColorForLocation(e.getX(), e.getY()); - return color.getRed()+", "+ color.getGreen() + ", " + color.getBlue(); + return color.getRed() + ", " + color.getGreen() + ", " + color.getBlue(); } + public void setSelectedColorFromLocation(int x, int y) { if (!this.getComponentOrientation().isLeftToRight()) { selCol = numSwatches.width - x / (swatchSize.width + gap.width) - 1; @@ -161,7 +171,8 @@ class MySwatchPanel extends JPanel { selRow = y / (swatchSize.height + gap.height); repaint(); } - public Color getColorForLocation( int x, int y ) { + + public Color getColorForLocation(int x, int y) { int column; if (!this.getComponentOrientation().isLeftToRight()) { column = numSwatches.width - x / (swatchSize.width + gap.width) - 1; @@ -171,7 +182,8 @@ class MySwatchPanel extends JPanel { int row = y / (swatchSize.height + gap.height); return getColorForCell(column, row); } - private Color getColorForCell( int column, int row) { - return colors[ (row * numSwatches.width) + column ]; // (STEVE) - change data orientation here + + private Color getColorForCell(int column, int row) { + return colors[(row * numSwatches.width) + column]; // (STEVE) - change data orientation here } } diff --git a/src/com/jpexs/decompiler/flash/gui/generictageditors/Amf3ValueEditor.java b/src/com/jpexs/decompiler/flash/gui/generictageditors/Amf3ValueEditor.java index 8004d4161..e90044c5e 100644 --- a/src/com/jpexs/decompiler/flash/gui/generictageditors/Amf3ValueEditor.java +++ b/src/com/jpexs/decompiler/flash/gui/generictageditors/Amf3ValueEditor.java @@ -23,8 +23,8 @@ import com.jpexs.decompiler.flash.gui.FasterScrollPane; import com.jpexs.decompiler.flash.gui.View; import com.jpexs.decompiler.flash.gui.ViewMessages; import com.jpexs.decompiler.flash.gui.editor.LineMarkedEditorPane; -import com.jpexs.decompiler.flash.importers.amf.amf3.Amf3Importer; import com.jpexs.decompiler.flash.importers.amf.AmfParseException; +import com.jpexs.decompiler.flash.importers.amf.amf3.Amf3Importer; import com.jpexs.helpers.Helper; import com.jpexs.helpers.ReflectionTools; import java.awt.BorderLayout; diff --git a/src/com/jpexs/decompiler/flash/gui/player/PlayerControls.java b/src/com/jpexs/decompiler/flash/gui/player/PlayerControls.java index 37118fb3d..543dabbf7 100644 --- a/src/com/jpexs/decompiler/flash/gui/player/PlayerControls.java +++ b/src/com/jpexs/decompiler/flash/gui/player/PlayerControls.java @@ -97,7 +97,6 @@ public class PlayerControls extends JPanel implements MediaDisplayListener { private static final Icon resampleIcon = View.getIcon("resample16"); //private final JLabel percentLabel = new JLabel("100%"); - private final ZoomPanel zoomPanel; private final JPanel graphicControls; @@ -106,12 +105,9 @@ public class PlayerControls extends JPanel implements MediaDisplayListener { private final JPanel frameControls; -// private boolean zoomToFit = false; - -// private double realZoom = 1.0; - + //private boolean zoomToFit = false; + //private double realZoom = 1.0; //private final JButton zoomFitButton; - private final JButton snapshotButton; private final JToggleButton showButton; @@ -134,10 +130,10 @@ public class PlayerControls extends JPanel implements MediaDisplayListener { private static Font notUnderlinedFont = null; - private final int zeroCharacterWidth; - + private final int zeroCharacterWidth; + private JButton selectColorButton; - + static { Font font = new JLabel().getFont(); notUnderlinedFont = font; @@ -166,14 +162,12 @@ public class PlayerControls extends JPanel implements MediaDisplayListener { zoomPanel = new ZoomPanel(display); zoomPanel.setVisible(false); - + snapshotButton = new JButton(View.getIcon("snapshot16")); snapshotButton.addActionListener(this::snapShotButtonActionPerformed); snapshotButton.setToolTipText(AppStrings.translate("button.snapshot.hint")); snapshotButton.setVisible(false); - - graphicButtonsPanel.add(zoomPanel); graphicButtonsPanel.add(selectColorButton); graphicButtonsPanel.add(snapshotButton); @@ -436,7 +430,7 @@ public class PlayerControls extends JPanel implements MediaDisplayListener { } }); - } + } private void pauseButtonActionPerformed(ActionEvent evt) { if (display.isPlaying()) { @@ -521,8 +515,6 @@ public class PlayerControls extends JPanel implements MediaDisplayListener { } } - - private void snapShotButtonActionPerformed(ActionEvent evt) { putImageToClipBoard(display.printScreen()); } @@ -549,8 +541,6 @@ public class PlayerControls extends JPanel implements MediaDisplayListener { Configuration.playFrameSounds.set(!muteButton.isSelected()); } - - @Override public void mediaDisplayStateChanged(MediaDisplay source) { if (display != source) { diff --git a/src/com/jpexs/decompiler/flash/gui/soleditor/SharedObjectsStorage.java b/src/com/jpexs/decompiler/flash/gui/soleditor/SharedObjectsStorage.java index 12dfdeaca..449269efb 100644 --- a/src/com/jpexs/decompiler/flash/gui/soleditor/SharedObjectsStorage.java +++ b/src/com/jpexs/decompiler/flash/gui/soleditor/SharedObjectsStorage.java @@ -43,18 +43,17 @@ import java.util.regex.Pattern; public class SharedObjectsStorage { public static boolean watchingPaused = false; - + public static Map watchedCookieDirectories = new HashMap<>(); - - + private static Map> swfFileToListeners = new LinkedHashMap<>(); - + public static void addChangedListener(File file, CookiesChangedListener listener) { if (!swfFileToListeners.containsKey(file)) { swfFileToListeners.put(file, new ArrayList<>()); } swfFileToListeners.get(file).add(listener); - + File solDir = getSolDirectoryForLocalFile(file); if (solDir == null) { return; @@ -74,7 +73,6 @@ public class SharedObjectsStorage { swfFileToListeners.get(file).remove(listener); } - private static void watchDir(File dir) { try { WatchKey key = dir.toPath().register(Main.getWatcher(), StandardWatchEventKinds.ENTRY_CREATE, StandardWatchEventKinds.ENTRY_DELETE, StandardWatchEventKinds.ENTRY_MODIFY); @@ -82,9 +80,9 @@ public class SharedObjectsStorage { } catch (IOException ex) { //ignored //ex.printStackTrace(); - } + } } - + private enum OSId { WINDOWS, OSX, UNIX } @@ -347,18 +345,18 @@ public class SharedObjectsStorage { return subDirs[0]; } - - public static void watchedDirectoryChanged(File file) { + + public static void watchedDirectoryChanged(File file) { if (watchingPaused) { return; } - + List swfFiles = new ArrayList<>(swfFileToListeners.keySet()); for (File swfFile : swfFiles) { File solDir = getSolDirectoryForLocalFile(swfFile); if (file.equals(solDir) || file.getParentFile().equals(solDir)) { fireChanged(swfFile, getSolFilesForLocalFile(swfFile)); - } else { + } else { if (solDir.exists()) { continue; } @@ -373,13 +371,13 @@ public class SharedObjectsStorage { } } } - + private static void fireChanged(File swfFile, List files) { //System.err.println("- firing changed " + swfFile.getAbsolutePath()); List listeners = swfFileToListeners.get(swfFile); if (listeners != null) { listeners = new ArrayList<>(listeners); - for (CookiesChangedListener l:listeners) { + for (CookiesChangedListener l : listeners) { l.cookiesChanged(swfFile, files); } } diff --git a/src/com/jpexs/decompiler/flash/gui/soleditor/SolEditorFrame.java b/src/com/jpexs/decompiler/flash/gui/soleditor/SolEditorFrame.java index bf731df8c..83f344854 100644 --- a/src/com/jpexs/decompiler/flash/gui/soleditor/SolEditorFrame.java +++ b/src/com/jpexs/decompiler/flash/gui/soleditor/SolEditorFrame.java @@ -25,9 +25,9 @@ import com.jpexs.decompiler.flash.gui.FasterScrollPane; import com.jpexs.decompiler.flash.gui.View; import com.jpexs.decompiler.flash.gui.ViewMessages; import com.jpexs.decompiler.flash.gui.editor.LineMarkedEditorPane; +import com.jpexs.decompiler.flash.importers.amf.AmfParseException; import com.jpexs.decompiler.flash.importers.amf.amf0.Amf0Importer; import com.jpexs.decompiler.flash.importers.amf.amf3.Amf3Importer; -import com.jpexs.decompiler.flash.importers.amf.AmfParseException; import com.jpexs.decompiler.flash.sol.SolFile; import com.jpexs.helpers.Helper; import java.awt.BorderLayout; diff --git a/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeContextMenu.java b/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeContextMenu.java index bc0d11886..6ec230c9d 100644 --- a/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeContextMenu.java +++ b/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeContextMenu.java @@ -184,7 +184,7 @@ public class TagTreeContextMenu extends JPopupMenu { private final MainPanel mainPanel; private JMenuItem gotoDocumentClassMenuItem; - + private JMenuItem configurePathResolvingMenuItem; private JMenuItem setAsLinkageMenuItem; @@ -224,7 +224,7 @@ public class TagTreeContextMenu extends JPopupMenu { private JMenuItem exportFlashDevelopMenuItem; private JMenuItem exportIdeaMenuItem; - + private JMenuItem exportVsCodeMenuItem; private JMenuItem exportSwfXmlMenuItem; @@ -342,9 +342,9 @@ public class TagTreeContextMenu extends JPopupMenu { private JMenuItem replaceWithGifMenuItem; private JMenuItem collectDepthAsSpritesMenuItem; - + private JMenuItem convertShapeTypeMenuItem; - + private JMenuItem convertPlaceObjectTypeMenuItem; private List items = new ArrayList<>(); @@ -405,7 +405,7 @@ public class TagTreeContextMenu extends JPopupMenu { configurePathResolvingMenuItem.setIcon(View.getIcon("settings16")); add(configurePathResolvingMenuItem); - addSeparator(); + addSeparator(); jumpToCharacterMenuItem = new JMenuItem(mainPanel.translate("contextmenu.jumpToCharacter")); jumpToCharacterMenuItem.addActionListener(this::jumpToCharacterActionPerformed); jumpToCharacterMenuItem.setIcon(View.getIcon("jumpto16")); @@ -467,7 +467,7 @@ public class TagTreeContextMenu extends JPopupMenu { exportIdeaMenuItem.addActionListener(this::exportIdeaActionPerformed); exportIdeaMenuItem.setIcon(View.getIcon("exportidea16")); add(exportIdeaMenuItem); - + exportVsCodeMenuItem = new JMenuItem(mainPanel.translate("contextmenu.exportVsCode")); exportVsCodeMenuItem.addActionListener(this::exportVsCodeActionPerformed); exportVsCodeMenuItem.setIcon(View.getIcon("exportvscode16")); @@ -544,19 +544,19 @@ public class TagTreeContextMenu extends JPopupMenu { replaceRefsWithTagMenuItem.addActionListener(this::replaceRefsWithTagActionPerformed); replaceRefsWithTagMenuItem.setIcon(View.getIcon("replacewithtag16")); add(replaceRefsWithTagMenuItem); - + convertShapeTypeMenuItem = new JMenuItem(mainPanel.translate("contextmenu.convertShapeType")); convertShapeTypeMenuItem.addActionListener(this::convertShapeTypeActionPerformed); convertShapeTypeMenuItem.setIcon(View.getIcon("shape16")); add(convertShapeTypeMenuItem); - + convertPlaceObjectTypeMenuItem = new JMenuItem(mainPanel.translate("contextmenu.convertPlaceObjectType")); convertPlaceObjectTypeMenuItem.addActionListener(this::convertPlaceObjectTypeActionPerformed); convertPlaceObjectTypeMenuItem.setIcon(View.getIcon("placeobject16")); add(convertPlaceObjectTypeMenuItem); addSeparator(); - + gotoDocumentClassMenuItem = new JMenuItem(mainPanel.translate("menu.tools.gotoDocumentClass")); gotoDocumentClassMenuItem.addActionListener(this::gotoDocumentClassActionPerformed); gotoDocumentClassMenuItem.setIcon(View.getIcon("gotomainclass16")); @@ -920,7 +920,7 @@ public class TagTreeContextMenu extends JPopupMenu { if (item instanceof Cookie) { if (wasFrame) { return false; - } + } wasNotFrame = true; } else if (item instanceof Tag) { if (wasFrame) { @@ -1089,24 +1089,24 @@ public class TagTreeContextMenu extends JPopupMenu { } tim = fr.timeline.timelined; } - + boolean allSelectedIsShape = true; boolean allSelectedIsPlaceObject = true; - + if (items.isEmpty()) { allSelectedIsShape = false; allSelectedIsPlaceObject = false; } - + for (TreeItem item : items) { - + if (!(item instanceof ShapeTag)) { allSelectedIsShape = false; } if (!(item instanceof PlaceObjectTypeTag)) { allSelectedIsPlaceObject = false; } - + if (item instanceof Tag) { Tag tag = (Tag) item; if (tag.isReadOnly()) { @@ -1424,13 +1424,13 @@ public class TagTreeContextMenu extends JPopupMenu { exportABCMenuItem.setVisible(true); gotoDocumentClassMenuItem.setVisible(true); } - + if (firstItem instanceof ScriptPack) { if (firstItem.getOpenable() instanceof SWF) { gotoDocumentClassMenuItem.setVisible(true); } } - + if (firstItem instanceof SWF) { if (((SWF) firstItem).isAS3()) { gotoDocumentClassMenuItem.setVisible(true); @@ -1455,7 +1455,7 @@ public class TagTreeContextMenu extends JPopupMenu { replaceRefsWithTagMenuItem.setVisible(true); } } - + if (firstItem instanceof DefineSpriteTag) { replaceWithGifMenuItem.setVisible(true); } @@ -1481,7 +1481,7 @@ public class TagTreeContextMenu extends JPopupMenu { addInsideAddAllTags = true; } } - + boolean isCookie = firstItem instanceof Cookie; addTagInsideMenu.removeAll(); @@ -1682,11 +1682,11 @@ public class TagTreeContextMenu extends JPopupMenu { } } } - + if (allSelectedIsShape) { convertShapeTypeMenuItem.setVisible(true); } - + if (allSelectedIsPlaceObject) { convertPlaceObjectTypeMenuItem.setVisible(true); } @@ -2600,7 +2600,7 @@ public class TagTreeContextMenu extends JPopupMenu { mainPanel.refreshTree(swf); } } - + private void convertShapeTypeActionPerformed(ActionEvent evt) { List itemr = getSelectedItems(); if (itemr.isEmpty()) { @@ -2609,25 +2609,24 @@ public class TagTreeContextMenu extends JPopupMenu { int currentShapeNum = 0; int min = 0; int minForced = 0; - + ShapeTypeConverter converter = new ShapeTypeConverter(); - - + if (itemr.size() == 1) { ShapeTag sh = (ShapeTag) itemr.get(0); currentShapeNum = sh.getShapeNum(); min = converter.getMinShapeNum(sh); minForced = converter.getForcedMinShapeNum(sh); - } - + } + ConvertShapeTypeDialog dialog = new ConvertShapeTypeDialog(Main.getDefaultDialogsOwner(), currentShapeNum, minForced, min); - + int shapeNum = dialog.showDialog(); - + if (shapeNum == 0) { return; } - + for (TreeItem item : itemr) { ShapeTag sh = (ShapeTag) item; int newShapeNum = shapeNum; @@ -2640,14 +2639,14 @@ public class TagTreeContextMenu extends JPopupMenu { } converter.convertCharacter(sh.getSwf(), sh.getCharacterId(), newShapeNum); } - + mainPanel.refreshTree(); if (itemr.size() == 1) { ShapeTag sh = (ShapeTag) itemr.get(0); mainPanel.setTagTreeSelectedNode(mainPanel.getCurrentTree(), sh.getSwf().getCharacter(sh.getCharacterId())); - } + } } - + private void convertPlaceObjectTypeActionPerformed(ActionEvent evt) { List itemr = getSelectedItems(); if (itemr.isEmpty()) { @@ -2655,37 +2654,36 @@ public class TagTreeContextMenu extends JPopupMenu { } int currentPlaceObjectNum = 0; int min = 0; - + PlaceObjectTypeConverter converter = new PlaceObjectTypeConverter(); - - + if (itemr.size() == 1) { PlaceObjectTypeTag sh = (PlaceObjectTypeTag) itemr.get(0); currentPlaceObjectNum = sh.getPlaceObjectNum(); min = converter.getMinPlaceNum(sh); - } - + } + ConvertPlaceObjectTypeDialog dialog = new ConvertPlaceObjectTypeDialog(Main.getDefaultDialogsOwner(), currentPlaceObjectNum, min); - + int placeNum = dialog.showDialog(); - + if (placeNum == 0) { return; } - + PlaceObjectTypeTag lastConverted = null; for (TreeItem item : itemr) { PlaceObjectTypeTag pl = (PlaceObjectTypeTag) item; - if (pl.getPlaceObjectNum()== placeNum) { + if (pl.getPlaceObjectNum() == placeNum) { continue; } lastConverted = converter.convertTagType(pl, placeNum); } - + mainPanel.refreshTree(); if (itemr.size() == 1) { mainPanel.setTagTreeSelectedNode(mainPanel.getCurrentTree(), lastConverted); - } + } } private void replaceRefsWithTagActionPerformed(ActionEvent evt) { @@ -2828,7 +2826,7 @@ public class TagTreeContextMenu extends JPopupMenu { item.getOpenable(); mainPanel.gotoDocumentClass((SWF) item.getOpenable()); } - + private void jumpToCharacterActionPerformed(ActionEvent evt) { TreeItem itemj = getCurrentItem(); if (itemj == null || !(itemj instanceof HasCharacterId)) { @@ -2988,7 +2986,7 @@ public class TagTreeContextMenu extends JPopupMenu { } if (!identifier.isEmpty() && !found) { ea.tags.add(ch.getCharacterId()); - ea.names.add(identifier); + ea.names.add(identifier); } ea.setModified(true); if (ea.names.isEmpty()) { @@ -4046,7 +4044,7 @@ public class TagTreeContextMenu extends JPopupMenu { Cookie cookie = (Cookie) item; ((Cookie) item).getSolFile().delete(); } - + if (item instanceof BUTTONRECORD) { ButtonTag button = (ButtonTag) parent; button.getRecords().remove((BUTTONRECORD) item); @@ -5708,7 +5706,7 @@ public class TagTreeContextMenu extends JPopupMenu { SWF swf = (SWF) getCurrentItem().getOpenable(); mainPanel.exportIdea(swf); } - + public void exportVsCodeActionPerformed(ActionEvent evt) { SWF swf = (SWF) getCurrentItem().getOpenable(); mainPanel.exportVsCode(swf);