diff --git a/src/main/java/se/lantz/manager/ImportManager.java b/src/main/java/se/lantz/manager/ImportManager.java index a3b7ae8..514b982 100644 --- a/src/main/java/se/lantz/manager/ImportManager.java +++ b/src/main/java/se/lantz/manager/ImportManager.java @@ -268,6 +268,26 @@ public class ImportManager { description_it = ""; } + +// //Don't allow same screen file for both entries +// if (screen1file.equals(screen2file)) +// { +// if (screen1file.endsWith("-01.png")) +// { +// screen1file = ""; +// } +// else +// { +// screen2file = ""; +// } +// } +// //Special handling of screens which may have wrong name or missing entry (screen 1 might be named 01.png, +// //handle that as screen2 instead to get names set correctly) +// if (screen1file.endsWith("-01.png") && screen2file.isEmpty()) +// { +// screen2file = screen1file; +// screen1file = ""; +// } // Construct a data row List list = Arrays.asList(title, diff --git a/src/main/java/se/lantz/model/InfoModel.java b/src/main/java/se/lantz/model/InfoModel.java index a242e61..015197c 100644 --- a/src/main/java/se/lantz/model/InfoModel.java +++ b/src/main/java/se/lantz/model/InfoModel.java @@ -343,7 +343,7 @@ public class InfoModel extends AbstractModel public boolean updateFileNames() { - if (isNewGame() || isTitleChanged()) + if (isNewGame() || isTitleChanged() || isWrongScreenNames()) { //Keep track of the old names, used when renaming files when saving oldCoverFile = getCoverFile(); @@ -386,6 +386,17 @@ public class InfoModel extends AbstractModel return !titleInDb.isEmpty() && !titleInDb.equalsIgnoreCase(title); } + public boolean isWrongScreenNames() + { + //Must have names ending with -00.png and -01.png + return (!getScreens1File().isEmpty() && !getScreens1File().endsWith("-00.png")) || ((!getScreens2File().isEmpty() && !getScreens2File().endsWith("-01.png"))); + } + + public boolean isAnyScreenRenamed() + { + return !oldScreens1File.isEmpty() || !oldScreens2File.isEmpty(); + } + public void resetImagesAndOldFileNames() { diff --git a/src/main/java/se/lantz/util/FileManager.java b/src/main/java/se/lantz/util/FileManager.java index ec1108b..3b3cf28 100644 --- a/src/main/java/se/lantz/util/FileManager.java +++ b/src/main/java/se/lantz/util/FileManager.java @@ -65,7 +65,7 @@ public class FileManager public void saveFiles() { //Check if title is different that in db, then rename existing files! - if (infoModel.isTitleChanged()) + if (infoModel.isTitleChanged() || infoModel.isAnyScreenRenamed()) { //Rename existing covers and screens and game file renameFiles(); @@ -109,6 +109,10 @@ public class FileManager { try { + if (screen1FileName.isEmpty()) + { + screen1FileName = generateFileNameFromTitle(infoModel.getTitle()) + "-00.png"; + } File outputfile = new File(SCREENS + screen1FileName); //Scale if not the right size screen1 = scaleImageTo320x200(screen1); @@ -124,6 +128,10 @@ public class FileManager { try { + if (screen2FileName.isEmpty()) + { + screen2FileName = generateFileNameFromTitle(infoModel.getTitle()) + "-01.png"; + } File outputfile = new File(SCREENS + screen2FileName); //Scale if not the right size screen2 = scaleImageTo320x200(screen2);