fixed a few bugs

* games.db -> reference_games.db
* fix picture cache path under linux
This commit is contained in:
Jannik 2017-12-12 12:02:28 +01:00
parent 9ccb7e6b42
commit a3a7d415c7
3 changed files with 21 additions and 12 deletions

View File

@ -71,6 +71,7 @@ public class Main extends Application {
private File directory;
private File configFile;
private File gamesDBFile;
private File reference_gamesFile;
private File pictureCache;
private static Logger LOGGER;
@ -106,11 +107,13 @@ public class Main extends Application {
directory = new File(dirLinux);
configFile = new File(dirLinux + "/config.xml");
gamesDBFile = new File(dirLinux + "/games.db");
reference_gamesFile = new File(dirLinux + "/reference_games.db");
pictureCache= new File(dirLinux+"/picture_cache");
} else {
directory = new File(dirWin);
configFile = new File(dirWin + "/config.xml");
gamesDBFile = new File(dirWin + "/games.db");
reference_gamesFile = new File(dirWin + "/reference_games.db");
pictureCache= new File(dirWin+"/picture_cache");
}
@ -147,12 +150,16 @@ public class Main extends Application {
pictureCache.mkdir();
}
if (gamesDBFile.exists() != true) {
if (!reference_gamesFile.exists()) {
if (gamesDBFile.exists()) {
gamesDBFile.delete();
}
try {
LOGGER.info("downloading games.db... ");
LOGGER.info("downloading ReferenceGameList.db... ");
URL website = new URL(gamesDBdownloadURL);
ReadableByteChannel rbc = Channels.newChannel(website.openStream());
FileOutputStream fos = new FileOutputStream(gamesDBFile);
FileOutputStream fos = new FileOutputStream(reference_gamesFile);
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
fos.close();
LOGGER.info("finished downloading games.db");
@ -161,6 +168,9 @@ public class Main extends Application {
}
}
// loading settings and initialize UI, dbController.main() loads all databases
mainWindowController.init();
mainWindowController.dbController.init();

View File

@ -1103,14 +1103,11 @@ public class MainWindowController {
* and add them to the database and the UI
*/
public void addBtnReturn(String title, String coverPath, String romPath, String titleID) {
File pictureCache;
/**
* if one parameter dosen't contain any value do not add the game
* else convert the cover to .png add copy it into the picture cache,
* then add the rom to the local_roms database
*/
System.out.println(romPath.length());
if (romPath.length() == 0 || coverPath.length() == 0 || title.length() == 0 || titleID.length() == 0) {
LOGGER.info("No parameter set!");
@ -1121,7 +1118,8 @@ public class MainWindowController {
JFXInfoDialog errorDialog = new JFXInfoDialog(headingTextError, bodyTextError, dialogBtnStyle, 350, 170, main.getPane());
errorDialog.show();
} else {
} else {
File pictureCache;
String coverName = new File(coverPath).getName();
try {
if (System.getProperty("os.name").equals("Linux")) {
@ -1133,8 +1131,8 @@ public class MainWindowController {
BufferedImage originalImage = ImageIO.read(new File(coverPath)); //load cover
int type = originalImage.getType() == 0 ? BufferedImage.TYPE_INT_ARGB : originalImage.getType();
BufferedImage resizeImagePNG = resizeImage(originalImage, type, 400, 600);
ImageIO.write(resizeImagePNG, "png", new File(pictureCache+"\\"+coverName)); //save image to pictureCache
coverPath = pictureCache+"\\"+coverName;
coverPath = pictureCache + "/" + coverName;
ImageIO.write(resizeImagePNG, "png", new File(coverPath)); //save image to pictureCache
} catch (IOException e) {
LOGGER.error("Ops something went wrong! Error while resizing cover.", e);
}

View File

@ -102,13 +102,13 @@ public class DBController {
* set the path to the localRoms.db file and initialize the connection
*
* games.dbcontains a reverence list to for the automatic detection mode
* TODO this should be called ReferenceGameList the games table should be called reference_games
* TODO rework paths
*/
private void loadGamesDatabase() {
if (System.getProperty("os.name").equals("Linux")) {
DB_PATH_games = System.getProperty("user.home") + "/cemu_UI/games.db";
DB_PATH_games = System.getProperty("user.home") + "/cemu_UI/reference_games.db";
} else {
DB_PATH_games = System.getProperty("user.home") + "\\Documents\\cemu_UI" + "\\" + "games.db";
DB_PATH_games = System.getProperty("user.home") + "\\Documents\\cemu_UI" + "\\" + "reference_games.db";
}
try {
// create a database connection
@ -247,6 +247,7 @@ public class DBController {
BufferedImage originalImage = ImageIO.read(new URL(rs.getString(6)));//change path to where file is located
int type = originalImage.getType() == 0 ? BufferedImage.TYPE_INT_ARGB : originalImage.getType();
BufferedImage resizeImagePNG = resizeImage(originalImage, type, 400, 600);
// TODO rework paths
if(System.getProperty("os.name").equals("Linux")) {
ImageIO.write(resizeImagePNG, "png", new File(pictureCache+"/"+rs.getString(3)+".png")); //change path where you want it saved
coverPath = pictureCache+"/"+rs.getString(3)+".png";