Changed Default package as separate folder

This commit is contained in:
Jindra Petřík
2022-11-19 23:28:59 +01:00
parent 4f3bbe732b
commit 351c86206b
6 changed files with 46 additions and 13 deletions

View File

@@ -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));

View File

@@ -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 = <default package>

View File

@@ -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 = <v\u00fdchoz\u00ed bal\u00ed\u010dek>

View File

@@ -41,14 +41,23 @@ public class AS2Package implements TreeItem {
public Map<String, ASMSource> 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;

View File

@@ -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);
}