diff --git a/src/main/java/com/cemu_UI/application/Main.java b/src/main/java/com/cemu_UI/application/Main.java index fd81aa9..5425d79 100644 --- a/src/main/java/com/cemu_UI/application/Main.java +++ b/src/main/java/com/cemu_UI/application/Main.java @@ -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(); diff --git a/src/main/java/com/cemu_UI/application/MainWindowController.java b/src/main/java/com/cemu_UI/application/MainWindowController.java index 31332a9..4b78766 100644 --- a/src/main/java/com/cemu_UI/application/MainWindowController.java +++ b/src/main/java/com/cemu_UI/application/MainWindowController.java @@ -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); } diff --git a/src/main/java/com/cemu_UI/controller/DBController.java b/src/main/java/com/cemu_UI/controller/DBController.java index a84ba1e..22c1039 100644 --- a/src/main/java/com/cemu_UI/controller/DBController.java +++ b/src/main/java/com/cemu_UI/controller/DBController.java @@ -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";