Added #2119 Bulk imported assets can also match filenames based on assigned classname, not just character id prefix

This commit is contained in:
Jindra Petřík
2023-11-17 20:11:02 +01:00
parent cd45c637f5
commit ac479eb098
6 changed files with 78 additions and 1 deletions

View File

@@ -10,6 +10,7 @@ All notable changes to this project will be documented in this file.
- [#2123] FLA export - show some progress info
- Label that flex compiler is used (when it's enabled in settings)
- [#2119] Option to export assets with names like their assigned classes via SymbolClass, without character id
- [#2119] Bulk imported assets can also match filenames based on assigned classname, not just character id prefix
### Fixed
- [#2021], [#2000] Caret position in editors when using tabs and / or unicode

View File

@@ -235,15 +235,32 @@ public class ImageImporter extends TagImporter {
}
List<File> existingFilesForImageTag = new ArrayList<>();
List<File> existingAlphaFilesForImageTag = new ArrayList<>();
List<String> classNameExpectedFileNames = new ArrayList<>();
for (String className : imageTag.getClassNames()) {
classNameExpectedFileNames.add(Helper.makeFileName(className));
}
for (File f : allFiles) {
for (File f : allFiles) {
if (f.getName().startsWith("" + characterId + ".") || f.getName().startsWith("" + characterId + "_")) {
existingFilesForImageTag.add(f);
} else {
String nameNoExt = f.getName();
if (nameNoExt.contains(".")) {
nameNoExt = nameNoExt.substring(0, nameNoExt.lastIndexOf("."));
}
if (classNameExpectedFileNames.contains(nameNoExt)) {
existingFilesForImageTag.add(f);
}
}
}
for (File f : alphaFiles) {
if (f.getName().startsWith("" + characterId + ".") || f.getName().startsWith("" + characterId + "_")) {
existingAlphaFilesForImageTag.add(f);
} else {
String nameNoExt = f.getName().substring(0, f.getName().length() - ".alpha.png".length());
if (classNameExpectedFileNames.contains(nameNoExt)) {
existingAlphaFilesForImageTag.add(f);
}
}
}
existingFilesForImageTag.sort(new Comparator<File>() {

View File

@@ -77,9 +77,23 @@ public class MovieImporter {
if (tag instanceof DefineVideoStreamTag) {
DefineVideoStreamTag movieTag = (DefineVideoStreamTag) tag;
List<File> existingFilesForMovieTag = new ArrayList<>();
List<String> classNameExpectedFileNames = new ArrayList<>();
for (String className : movieTag.getClassNames()) {
classNameExpectedFileNames.add(Helper.makeFileName(className));
}
for (File f : allFiles) {
if (f.getName().startsWith("" + characterId + ".") || f.getName().startsWith("" + characterId + "_")) {
existingFilesForMovieTag.add(f);
} else {
String nameNoExt = f.getName();
if (nameNoExt.contains(".")) {
nameNoExt = nameNoExt.substring(0, nameNoExt.lastIndexOf("."));
}
if (classNameExpectedFileNames.contains(nameNoExt)) {
existingFilesForMovieTag.add(f);
}
}
}
existingFilesForMovieTag.sort(new Comparator<File>() {

View File

@@ -215,9 +215,23 @@ public class ShapeImporter {
if (tag instanceof ShapeTag) {
ShapeTag shapeTag = (ShapeTag) tag;
List<File> existingFilesForShapeTag = new ArrayList<>();
List<String> classNameExpectedFileNames = new ArrayList<>();
for (String className : shapeTag.getClassNames()) {
classNameExpectedFileNames.add(Helper.makeFileName(className));
}
for (File f : allFiles) {
if (f.getName().startsWith("" + characterId + ".") || f.getName().startsWith("" + characterId + "_")) {
existingFilesForShapeTag.add(f);
} else {
String nameNoExt = f.getName();
if (nameNoExt.contains(".")) {
nameNoExt = nameNoExt.substring(0, nameNoExt.lastIndexOf("."));
}
if (classNameExpectedFileNames.contains(nameNoExt)) {
existingFilesForShapeTag.add(f);
}
}
}
existingFilesForShapeTag.sort(new Comparator<File>() {

View File

@@ -515,9 +515,25 @@ public class SoundImporter {
for (SoundTag tag : soundTags) {
int characterId = tag.getCharacterId();
List<File> existingFilesForSoundTag = new ArrayList<>();
List<String> classNameExpectedFileNames = new ArrayList<>();
if (tag instanceof CharacterTag) {
for (String className : ((CharacterTag) tag).getClassNames()) {
classNameExpectedFileNames.add(Helper.makeFileName(className));
}
}
for (File f : allFiles) {
if (f.getName().startsWith("" + characterId + ".") || f.getName().startsWith("" + characterId + "_")) {
existingFilesForSoundTag.add(f);
} else {
String nameNoExt = f.getName();
if (nameNoExt.contains(".")) {
nameNoExt = nameNoExt.substring(0, nameNoExt.lastIndexOf("."));
}
if (classNameExpectedFileNames.contains(nameNoExt)) {
existingFilesForSoundTag.add(f);
}
}
}
existingFilesForSoundTag.sort(new Comparator<File>() {

View File

@@ -27,6 +27,7 @@ import com.jpexs.decompiler.flash.tags.Tag;
import com.jpexs.decompiler.flash.tags.base.CharacterIdTag;
import com.jpexs.decompiler.flash.tags.base.CharacterTag;
import com.jpexs.decompiler.flash.tags.base.PlaceObjectTypeTag;
import com.jpexs.helpers.Helper;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.File;
@@ -173,9 +174,23 @@ public class SpriteImporter {
if (tag instanceof DefineSpriteTag) {
DefineSpriteTag spriteTag = (DefineSpriteTag) tag;
List<File> existingFilesForSpriteTag = new ArrayList<>();
List<String> classNameExpectedFileNames = new ArrayList<>();
for (String className : spriteTag.getClassNames()) {
classNameExpectedFileNames.add(Helper.makeFileName(className));
}
for (File f : allFiles) {
if (f.getName().startsWith("" + characterId + ".") || f.getName().startsWith("" + characterId + "_")) {
existingFilesForSpriteTag.add(f);
} else {
String nameNoExt = f.getName();
if (nameNoExt.contains(".")) {
nameNoExt = nameNoExt.substring(0, nameNoExt.lastIndexOf("."));
}
if (classNameExpectedFileNames.contains(nameNoExt)) {
existingFilesForSpriteTag.add(f);
}
}
}
existingFilesForSpriteTag.sort(new Comparator<File>() {