diff --git a/pom.xml b/pom.xml index 26b7d6d..31e3b8e 100644 --- a/pom.xml +++ b/pom.xml @@ -26,7 +26,7 @@ com.jfoenix jfoenix - 9.0.1 + 9.0.2 diff --git a/src/main/java/com/cemu_UI/application/Main.java b/src/main/java/com/cemu_UI/application/Main.java index 5a21bb2..590cf47 100644 --- a/src/main/java/com/cemu_UI/application/Main.java +++ b/src/main/java/com/cemu_UI/application/Main.java @@ -116,7 +116,7 @@ public class Main extends Application { } // startup checks - // check if client_secret.jason is present + // check if client_secret.json is present if (Main.class.getResourceAsStream("/client_secret.json") == null) { LOGGER.error("client_secret is missing!!!!!"); @@ -142,11 +142,11 @@ public class Main extends Application { mainWindowController.setLastLocalSync(0); mainWindowController.setxPosHelper(0); mainWindowController.saveSettings(); - Runtime.getRuntime().exec("java -jar cemu_UI.jar"); //start again (preventing Bugs) + Runtime.getRuntime().exec("java -jar cemu_UI.jar"); //TODO check if this really is needed start again (preventing Bugs) System.exit(0); //finishes itself } - if (pictureCache.exists() != true) { + if (!pictureCache.exists()) { pictureCache.mkdir(); } @@ -341,7 +341,19 @@ public class Main extends Application { return directory; } - public void setDirectory(File directory) { - this.directory = directory; + public File getConfigFile() { + return configFile; + } + + public File getGamesDBFile() { + return gamesDBFile; + } + + public File getReference_gamesFile() { + return reference_gamesFile; + } + + public File getPictureCache() { + return pictureCache; } } diff --git a/src/main/java/com/cemu_UI/application/MainWindowController.java b/src/main/java/com/cemu_UI/application/MainWindowController.java index aade0e3..04813d3 100644 --- a/src/main/java/com/cemu_UI/application/MainWindowController.java +++ b/src/main/java/com/cemu_UI/application/MainWindowController.java @@ -302,12 +302,6 @@ public class MainWindowController { private double windowWidth; private double windowHeight; private DirectoryChooser directoryChooser = new DirectoryChooser(); - private File dirWin = new File(System.getProperty("user.home") + "/Documents/cemu_UI"); - private File dirLinux = new File(System.getProperty("user.home") + "/cemu_UI"); - private File configFileWin = new File(dirWin + "/config.xml"); - private File configFileLinux = new File(dirLinux + "/config.xml"); - private File pictureCacheWin = new File(dirWin + "/picture_cache"); - private File pictureCacheLinux = new File(dirLinux + "/picture_cache"); private ObservableList branches = FXCollections.observableArrayList("stable", "beta"); private ObservableList languages = FXCollections.observableArrayList("English (en_US)", "Deutsch (de_DE)"); private ObservableList smmIDs = FXCollections.observableArrayList("fe31b7f2", "44fc5929"); // TODO add more IDs @@ -376,7 +370,7 @@ public class MainWindowController { public void setMain(Main m) { this.main = m; - dbController = new DBController(this); + dbController = new DBController(main, this); smmdbAPIController = new SmmdbAPIController(); } @@ -911,7 +905,7 @@ public class MainWindowController { @FXML void lastTimePlayedBtnAction(ActionEvent event) { - + System.out.println(lastTimePlayedBtn.getWidth()); } @FXML @@ -1134,15 +1128,9 @@ public class MainWindowController { errorDialog.show(); } else { - File pictureCache; + File pictureCache = main.getPictureCache(); String coverName = new File(coverPath).getName(); try { - if (System.getProperty("os.name").equals("Linux")) { - pictureCache = getPictureCacheLinux(); - } else { - pictureCache = getPictureCacheWin(); - } - 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); @@ -1651,7 +1639,7 @@ public class MainWindowController { public void saveSettings(){ LOGGER.info("saving Settings ..."); - OutputStream outputStream; //new output-stream + try { props.setProperty("cemuPath", getCemuPath()); props.setProperty("romPath", getRomDirectoryPath()); @@ -1670,11 +1658,7 @@ public class MainWindowController { props.setProperty("lastLocalSync", String.valueOf(getLastLocalSync())); props.setProperty("windowWidth", String.valueOf(mainAnchorPane.getWidth())); props.setProperty("windowHeight", String.valueOf(mainAnchorPane.getHeight())); - if(System.getProperty("os.name").equals("Linux")){ - outputStream = new FileOutputStream(configFileLinux); - }else{ - outputStream = new FileOutputStream(configFileWin); - } + OutputStream outputStream = new FileOutputStream(main.getConfigFile()); //new output-stream props.storeToXML(outputStream, "cemu_UI settings"); //write new .xml outputStream.close(); LOGGER.info("saving Settings done!"); @@ -1689,13 +1673,8 @@ public class MainWindowController { */ private void loadSettings(){ LOGGER.info("loading settings ..."); - InputStream inputStream; try { - if(System.getProperty("os.name").equals("Linux")){ - inputStream = new FileInputStream(configFileLinux); - }else{ - inputStream = new FileInputStream(configFileWin); - } + InputStream inputStream = new FileInputStream(main.getConfigFile()); props.loadFromXML(inputStream); //new input-stream from .xml try { @@ -1894,22 +1873,6 @@ public class MainWindowController { this.color = color; } - public File getPictureCacheLinux() { - return pictureCacheLinux; - } - - public void setPictureCacheLinux(File pictureCacheLinux) { - this.pictureCacheLinux = pictureCacheLinux; - } - - public File getPictureCacheWin() { - return pictureCacheWin; - } - - public void setPictureCacheWin(File pictureCacheWin) { - this.pictureCacheWin = pictureCacheWin; - } - public int getxPos() { return xPos; } diff --git a/src/main/java/com/cemu_UI/controller/DBController.java b/src/main/java/com/cemu_UI/controller/DBController.java index f73c554..9b9c390 100644 --- a/src/main/java/com/cemu_UI/controller/DBController.java +++ b/src/main/java/com/cemu_UI/controller/DBController.java @@ -45,14 +45,17 @@ import org.apache.logging.log4j.Logger; import org.w3c.dom.Document; import org.xml.sax.SAXException; +import com.cemu_UI.application.Main; import com.cemu_UI.application.MainWindowController; public class DBController { - public DBController(MainWindowController mwc) { - mainWindowController = mwc; + public DBController(Main main, MainWindowController mainWindowController) { + this.main = main; + this.mainWindowController = mainWindowController; } + private Main main; private MainWindowController mainWindowController; private ArrayList entries = new ArrayList<>(); private String DB_PATH_localRoms; @@ -98,16 +101,10 @@ 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 rework paths + * games.db contains a reverence list to for the automatic detection mode */ private void loadGamesDatabase() { - if (System.getProperty("os.name").equals("Linux")) { - DB_PATH_games = System.getProperty("user.home") + "/cemu_UI/reference_games.db"; - } else { - DB_PATH_games = System.getProperty("user.home") + "\\Documents\\cemu_UI" + "\\" + "reference_games.db"; - } + DB_PATH_games = main.getReference_gamesFile().getAbsolutePath(); try { // create a database connection connectionGames = DriverManager.getConnection("jdbc:sqlite:" + DB_PATH_games); @@ -213,15 +210,8 @@ public class DBController { File dir = new File(directory); File appFile; String[] extensions = new String[] { "rpx", "jsp" }; - File pictureCache; - String coverPath; - - if(System.getProperty("os.name").equals("Linux")){ - pictureCache = mainWindowController.getPictureCacheLinux(); - }else{ - pictureCache = mainWindowController.getPictureCacheWin(); - } - + File pictureCache = main.getPictureCache(); + String coverPath; try { Statement stmt = connectionGames.createStatement(); List files = (List) FileUtils.listFiles(dir, extensions, true); diff --git a/src/main/resources/fxml/MainWindow.fxml b/src/main/resources/fxml/MainWindow.fxml index a17ba18..c9dde2c 100644 --- a/src/main/resources/fxml/MainWindow.fxml +++ b/src/main/resources/fxml/MainWindow.fxml @@ -213,14 +213,14 @@ - + - +