diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java index 8d2c59c33..e2ab216df 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java @@ -1964,7 +1964,11 @@ public final class SWF implements SWFContainerItem, Timelined { } else if (treeItem instanceof AS2Package) { AS2Package as2Package = (AS2Package) treeItem; for (TreeItem subItem : as2Package.subPackages.values()) { - getASMs(exportFileNames, subItem, nodesToExport, exportAll, asmsToExport, path + File.separator + getASMPath(exportFileNames, subItem)); + if ((subItem instanceof AS2Package) && ((AS2Package)subItem).isDefaultPackage()) { + getASMs(exportFileNames, subItem, nodesToExport, exportAll, asmsToExport, path); + } else { + getASMs(exportFileNames, subItem, nodesToExport, exportAll, asmsToExport, path + File.separator + getASMPath(exportFileNames, subItem)); + } } for (TreeItem subItem : as2Package.scripts.values()) { getASMs(exportFileNames, subItem, nodesToExport, exportAll, asmsToExport, path + File.separator + getASMPath(exportFileNames, subItem)); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/locales/AppResources.properties b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/locales/AppResources.properties index 6fd45c58d..cb2691875 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/locales/AppResources.properties +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/locales/AppResources.properties @@ -40,3 +40,5 @@ fontNotFound = Font with id=%fontId% was not found. trait.scriptinitializer = script initializer trait.instanceinitializer = instance initializer trait.classinitializer = class initializer + +package.default = \ No newline at end of file diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/locales/AppResources_cs.properties b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/locales/AppResources_cs.properties index e4353f3ff..8ad225582 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/locales/AppResources_cs.properties +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/locales/AppResources_cs.properties @@ -38,3 +38,5 @@ fontNotFound = P\u00edsmo s id=%fontId% nebylo nalezeno. trait.scriptinitializer = inicializ\u00e1tor skriptu trait.instanceinitializer = inicializ\u00e1tor instance trait.classinitializer = inicializ\u00e1tor t\u0159\u00eddy + +package.default = \ No newline at end of file diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/AS2Package.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/AS2Package.java index 0387b2274..276470010 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/AS2Package.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/AS2Package.java @@ -41,14 +41,23 @@ public class AS2Package implements TreeItem { public Map scripts = new TreeMap<>(); private boolean flat; + + private boolean defaultPackage; - public AS2Package(String name, AS2Package parent, SWF swf, boolean flat) { + public AS2Package(String name, AS2Package parent, SWF swf, boolean flat, boolean defaultPackage) { this.name = name; this.parent = parent; this.swf = swf; this.flat = flat; + this.defaultPackage = defaultPackage; } + public boolean isDefaultPackage() { + return defaultPackage; + } + + + @Override public SWF getSwf() { return swf; 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 95041af14..74edefc3e 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 @@ -16,6 +16,7 @@ */ package com.jpexs.decompiler.flash.timeline; +import com.jpexs.decompiler.flash.AppResources; import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.TagRemoveListener; import com.jpexs.decompiler.flash.configuration.Configuration; @@ -192,7 +193,7 @@ public class Timeline { this.displayRect = displayRect; this.frameRate = swf.frameRate; this.timelined = timelined; - as2RootPackage = new AS2Package(null, null, swf, false); + as2RootPackage = new AS2Package(null, null, swf, false, false); } public final int getMaxDepth() { @@ -257,7 +258,7 @@ public class Timeline { this.displayRect = displayRect; this.frameRate = swf.frameRate; this.timelined = timelined; - as2RootPackage = new AS2Package(null, null, swf, false); + as2RootPackage = new AS2Package(null, null, swf, false, false); } public int getFrameWithLabel(String label) { @@ -478,38 +479,52 @@ public class Timeline { } String[] pathParts = path.contains(".") ? path.split("\\.") : new String[]{path}; - AS2Package pkg = as2RootPackage; + AS2Package pkg = as2RootPackage; + + boolean isNamedPackages = "__Packages".equals(pathParts[0]); + for (int pos = 0; pos < pathParts.length - 1; pos++) { - if (Configuration.flattenASPackages.get()) { - boolean isNamedPackages = "__Packages".equals(pathParts[0]); - + if (Configuration.flattenASPackages.get()) { if (isNamedPackages && pos == 0) { //nothing - } else { + } else { + String fullPath; if (isNamedPackages) { fullPath = path.substring(pathParts[0].length() + 1, path.length() - pathParts[pathParts.length - 1].length() - 1); } else { fullPath = path.substring(0, path.length() - pathParts[pathParts.length - 1].length() - 1); } + AS2Package subPkg = pkg.subPackages.get(fullPath); if (subPkg == null) { - subPkg = new AS2Package(fullPath, pkg, swf, true); + subPkg = new AS2Package(fullPath, pkg, swf, true, false); pkg.subPackages.put(fullPath, subPkg); } pkg = subPkg; break; } - } + } + String pathPart = pathParts[pos]; AS2Package subPkg = pkg.subPackages.get(pathPart); if (subPkg == null) { - subPkg = new AS2Package(pathPart, pkg, swf, false); + subPkg = new AS2Package(pathPart, pkg, swf, false, false); pkg.subPackages.put(pathPart, subPkg); } pkg = subPkg; } + + if (Configuration.flattenASPackages.get() && ((pathParts.length == 2 && isNamedPackages) || pathParts.length == 1)) { + String fullPath = AppResources.translate("package.default"); + AS2Package subPkg = pkg.subPackages.get(fullPath); + if (subPkg == null) { + subPkg = new AS2Package(fullPath, pkg, swf, true, true); + pkg.subPackages.put(fullPath, subPkg); + } + pkg = subPkg; + } pkg.scripts.put(pathParts[pathParts.length - 1], asm); } diff --git a/src/com/jpexs/decompiler/flash/gui/abc/ClassesListTreeModel.java b/src/com/jpexs/decompiler/flash/gui/abc/ClassesListTreeModel.java index 78bd30c6f..00f05e8ba 100644 --- a/src/com/jpexs/decompiler/flash/gui/abc/ClassesListTreeModel.java +++ b/src/com/jpexs/decompiler/flash/gui/abc/ClassesListTreeModel.java @@ -16,6 +16,7 @@ */ package com.jpexs.decompiler.flash.gui.abc; +import com.jpexs.decompiler.flash.AppResources; import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.abc.ScriptPack; import com.jpexs.decompiler.flash.abc.types.traits.Trait; @@ -117,7 +118,7 @@ public class ClassesListTreeModel extends AS3ClassTreeItem implements TreeModel if (flat) { String fullName = packageStr.toPrintableString(true); if (fullName.length() == 0) { - return root; + fullName = AppResources.translate("package.default"); } AS3Package pkg = root.getSubPackage(fullName); if (pkg == null) {