fix: Bug #4 Problems loading and saving second screen
If a tsg file that is imported only contains one screen entry problems can occur. Adds more checks to rename screens if they have wrong name when saving.
This commit is contained in:
parent
ee5c191a10
commit
71ba40d933
|
@ -269,6 +269,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<String> list = Arrays.asList(title,
|
||||
year,
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue