chrore: some cleanup
This commit is contained in:
parent
5701af4394
commit
254d0e263e
|
@ -294,7 +294,7 @@ public class SaveStatePanel extends JPanel
|
||||||
if (!filename.isEmpty())
|
if (!filename.isEmpty())
|
||||||
{
|
{
|
||||||
String fileName = model.getInfoModel().getGamesFile();
|
String fileName = model.getInfoModel().getGamesFile();
|
||||||
System.out.println(fileName.toString());
|
logger.debug(fileName.toString());
|
||||||
|
|
||||||
Path saveFolderPath = new File("./saves/" + fileName).toPath();
|
Path saveFolderPath = new File("./saves/" + fileName).toPath();
|
||||||
File imagefile = saveFolderPath.resolve(filename).toFile();
|
File imagefile = saveFolderPath.resolve(filename).toFile();
|
||||||
|
|
|
@ -20,6 +20,8 @@ import java.util.stream.Stream;
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
|
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import se.lantz.model.MainViewModel;
|
import se.lantz.model.MainViewModel;
|
||||||
import se.lantz.model.SavedStatesModel;
|
import se.lantz.model.SavedStatesModel;
|
||||||
|
@ -28,6 +30,8 @@ import se.lantz.util.FileManager;
|
||||||
|
|
||||||
public class SavedStatesManager
|
public class SavedStatesManager
|
||||||
{
|
{
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(SavedStatesManager.class);
|
||||||
|
|
||||||
public static final String SAVES = "./saves/";
|
public static final String SAVES = "./saves/";
|
||||||
|
|
||||||
private static final String MTA0 = "0.mta";
|
private static final String MTA0 = "0.mta";
|
||||||
|
@ -58,7 +62,7 @@ public class SavedStatesManager
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Map holding available saved states with fileName (subfolder) as key and number of saved states available as value
|
* Map holding available saved states with fileName (subfolder) as key and number of saved states available as value
|
||||||
* (1-4).
|
* (0-4).
|
||||||
*/
|
*/
|
||||||
private Map<String, Integer> savedStatesMap = new HashMap<>();
|
private Map<String, Integer> savedStatesMap = new HashMap<>();
|
||||||
|
|
||||||
|
@ -136,7 +140,6 @@ public class SavedStatesManager
|
||||||
savedStatesModel.resetProperties();
|
savedStatesModel.resetProperties();
|
||||||
//Read from state directory, update model
|
//Read from state directory, update model
|
||||||
String fileName = model.getInfoModel().getGamesFile();
|
String fileName = model.getInfoModel().getGamesFile();
|
||||||
System.out.println(fileName.toString());
|
|
||||||
if (!fileName.isEmpty())
|
if (!fileName.isEmpty())
|
||||||
{
|
{
|
||||||
//Check if folder is available
|
//Check if folder is available
|
||||||
|
@ -191,9 +194,9 @@ public class SavedStatesManager
|
||||||
byte[] timeArray = new byte[] { fileContent[0], fileContent[1], fileContent[2], fileContent[3] };
|
byte[] timeArray = new byte[] { fileContent[0], fileContent[1], fileContent[2], fileContent[3] };
|
||||||
//The value seems to be in milliseconds
|
//The value seems to be in milliseconds
|
||||||
int milliSeconds = ByteBuffer.wrap(timeArray).order(java.nio.ByteOrder.LITTLE_ENDIAN).getInt();
|
int milliSeconds = ByteBuffer.wrap(timeArray).order(java.nio.ByteOrder.LITTLE_ENDIAN).getInt();
|
||||||
System.out.println("24 bit value Little endian x= " + milliSeconds);
|
logger.debug("24 bit value Little endian x= " + milliSeconds);
|
||||||
returnValue = convertSecondToHHMMString(milliSeconds);// LocalTime.MIN.plusSeconds(seconds).toString();
|
returnValue = convertSecondToHHMMString(milliSeconds);
|
||||||
System.out.println("Converted string = " + returnValue);
|
logger.debug("Converted string = " + returnValue);
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
|
@ -423,7 +426,7 @@ public class SavedStatesManager
|
||||||
{
|
{
|
||||||
return noFilesCopied;
|
return noFilesCopied;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void readSavedStatesAndUpdateMap()
|
private void readSavedStatesAndUpdateMap()
|
||||||
{
|
{
|
||||||
savedStatesMap.clear();
|
savedStatesMap.clear();
|
||||||
|
@ -439,31 +442,31 @@ public class SavedStatesManager
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Check which files are available
|
//Check which files are available
|
||||||
Path save1 = sourcePath.resolve(MTA0);
|
Path save1 = sourcePath.resolve(MTA0);
|
||||||
Path save2 = sourcePath.resolve(MTA1);
|
Path save2 = sourcePath.resolve(MTA1);
|
||||||
Path save3 = sourcePath.resolve(MTA2);
|
Path save3 = sourcePath.resolve(MTA2);
|
||||||
Path save4 = sourcePath.resolve(MTA3);
|
Path save4 = sourcePath.resolve(MTA3);
|
||||||
int noSavesAvailable = 0;
|
int savesAvailable = 0;
|
||||||
if (save1.toFile().exists())
|
if (save1.toFile().exists())
|
||||||
{
|
{
|
||||||
noSavesAvailable++;
|
savesAvailable++;
|
||||||
}
|
}
|
||||||
if (save2.toFile().exists())
|
if (save2.toFile().exists())
|
||||||
{
|
{
|
||||||
noSavesAvailable++;
|
savesAvailable++;
|
||||||
}
|
}
|
||||||
if (save3.toFile().exists())
|
if (save3.toFile().exists())
|
||||||
{
|
{
|
||||||
noSavesAvailable++;
|
savesAvailable++;
|
||||||
}
|
}
|
||||||
if (save4.toFile().exists())
|
if (save4.toFile().exists())
|
||||||
{
|
{
|
||||||
noSavesAvailable++;
|
savesAvailable++;
|
||||||
}
|
}
|
||||||
//Add to map
|
//Add to map
|
||||||
savedStatesMap.put(sourcePath.toFile().getName(), noSavesAvailable);
|
savedStatesMap.put(sourcePath.toFile().getName(), savesAvailable);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@ -476,7 +479,7 @@ public class SavedStatesManager
|
||||||
ExceptionHandler.handleException(e1, "Could not construct savedStates Map");
|
ExceptionHandler.handleException(e1, "Could not construct savedStates Map");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getNumberOfSavedStatesForGame(String gameFileName)
|
public int getNumberOfSavedStatesForGame(String gameFileName)
|
||||||
{
|
{
|
||||||
return savedStatesMap.get(gameFileName) != null ? savedStatesMap.get(gameFileName) : 0;
|
return savedStatesMap.get(gameFileName) != null ? savedStatesMap.get(gameFileName) : 0;
|
||||||
|
|
|
@ -7,6 +7,7 @@ import org.jsoup.Jsoup;
|
||||||
|
|
||||||
public class DescriptionTranslater
|
public class DescriptionTranslater
|
||||||
{
|
{
|
||||||
|
//Just for testing
|
||||||
public static void main(String[] args)
|
public static void main(String[] args)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
Loading…
Reference in New Issue