diff --git a/pom.xml b/pom.xml
index 82f3c3e..ef8430d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -107,7 +107,7 @@
com.google.apis
google-api-services-drive
- v3-rev87-1.23.0
+ v3-rev99-1.23.0
@@ -150,7 +150,7 @@
com.fasterxml.jackson.core
jackson-core
- 2.9.3
+ 2.9.4
diff --git a/src/main/java/com/cemu_UI/application/Main.java b/src/main/java/com/cemu_UI/application/Main.java
index c27dff4..dcbb68d 100644
--- a/src/main/java/com/cemu_UI/application/Main.java
+++ b/src/main/java/com/cemu_UI/application/Main.java
@@ -177,8 +177,7 @@ public class Main extends Application {
if(mainWindowController.isCloudSync()) {
cloudController.initializeConnection(mainWindowController.getCloudService(), mainWindowController.getCemuPath());
cloudController.sync(mainWindowController.getCloudService(), mainWindowController.getCemuPath(), directory.getPath());
- }
- mainWindowController.addUIData();
+ }
scene = new Scene(pane); // create new scene, append pane to scene
scene.getStylesheets().add(Main.class.getResource("/css/MainWindows.css").toExternalForm());
diff --git a/src/main/java/com/cemu_UI/application/MainWindowController.java b/src/main/java/com/cemu_UI/application/MainWindowController.java
index 150a2d0..3a594cf 100644
--- a/src/main/java/com/cemu_UI/application/MainWindowController.java
+++ b/src/main/java/com/cemu_UI/application/MainWindowController.java
@@ -864,26 +864,7 @@ public class MainWindowController {
@FXML
void reloadRomsBtnAction() throws IOException {
-
- JFXSpinner spinner = new JFXSpinner();
- spinner.setPrefSize(30, 30);
- spinner.setStyle(" -fx-background-color: #f4f4f4;");
- main.getPane().getChildren().add(spinner);
- AnchorPane.setTopAnchor(spinner, (main.getPane().getHeight()-spinner.getPrefHeight())/2);
- AnchorPane.setLeftAnchor(spinner, (main.getPane().getWidth()-spinner.getPrefWidth())/2);
-
- Thread thread = new Thread(new Runnable() {
- @Override
- public void run() {
- dbController.loadRomDirectory(getRomDirectoryPath()); // reload the rom directory
-
- Platform.runLater(() -> {
- refreshUIData(); // refresh the list of games displayed on screen
- main.getPane().getChildren().remove(spinner);
- });
- }
- });
- thread.start();
+ reloadRoms();
}
@FXML
@@ -1314,6 +1295,35 @@ public class MainWindowController {
games.add(uiROMElement);
}
+ public void reloadRoms() {
+ JFXSpinner spinner = new JFXSpinner();
+ spinner.setPrefSize(30, 30);
+ spinner.setStyle(" -fx-background-color: #f4f4f4;");
+ AnchorPane.setTopAnchor(spinner, (main.getPane().getPrefHeight()-spinner.getPrefHeight())/2);
+ AnchorPane.setLeftAnchor(spinner, (main.getPane().getPrefWidth()-spinner.getPrefWidth())/2);
+
+ Thread thread = new Thread(new Runnable() {
+ @Override
+ public void run() {
+ Platform.runLater(() -> {
+ //remove all games form gamesAnchorPane
+ gamesAnchorPane.getChildren().removeAll(gamesAnchorPane.getChildren());
+ main.getPane().getChildren().add(spinner); // add spinner to pane
+ });
+
+ dbController.loadRomDirectory(getRomDirectoryPath()); // reload the ROM directory
+ games.removeAll(games); // remove all games from the mwc game list
+ dbController.loadAllGames(); // load all games from the database to the mwc
+
+ Platform.runLater(() -> {
+ refreshUIData(); // refresh the list of games displayed on screen
+ main.getPane().getChildren().remove(spinner);
+ });
+ }
+ });
+ thread.start();
+ }
+
// add all games saved in games(ArrayList) to gamesAnchorPane
void addUIData() {
for (int i = 0; i < games.size(); i++) {
diff --git a/src/main/java/com/cemu_UI/controller/DBController.java b/src/main/java/com/cemu_UI/controller/DBController.java
index 52e9c9e..56de353 100644
--- a/src/main/java/com/cemu_UI/controller/DBController.java
+++ b/src/main/java/com/cemu_UI/controller/DBController.java
@@ -67,13 +67,11 @@ public class DBController {
* load all games
*/
public void init(){
- LOGGER.info("<==========starting loading sql==========>");
+ LOGGER.info("<========== starting loading sql ==========>");
loadRomDatabase();
loadGamesDatabase();
createRomDatabase();
- loadAllGames();
- checkRemoveEntry();
- LOGGER.info("<==========finished loading sql==========>");
+ LOGGER.info("<========== finished loading sql ==========>");
}
/**
@@ -149,11 +147,13 @@ public class DBController {
LOGGER.error("error while loading ROMs from ROM database, local_roms table", e);
}
if (entries.size() == 0) {
- loadRomDirectory(mainWindowController.getRomDirectoryPath());
+ mainWindowController.reloadRoms();
+ } else {
+ loadAllGames();
}
}
- // add a Ggame to the database
+ // add a game to the database
public void addGame(String title, String coverPath, String romPath, String titleID, String productCode, String region, String lastPlayed, String timePlayed) throws SQLException{
Statement stmt = connection.createStatement();
stmt.executeUpdate("insert into local_roms values ('"+title+"','"+coverPath+"','"+romPath+"','"+titleID+"',"
@@ -163,6 +163,7 @@ public class DBController {
LOGGER.info("added \""+title+"\" to ROM database");
}
+ // remove a game from the database
public void removeGame(String titleID) throws SQLException{
Statement stmt = connection.createStatement();
stmt.executeUpdate("delete from local_roms where titleID = '"+titleID+"'");
@@ -171,8 +172,8 @@ public class DBController {
LOGGER.info("removed \""+titleID+"\" from ROM database");
}
- //load all ROMs on startup to the mainWindowController
- void loadAllGames(){
+ //load all ROMs to the mainWindowController
+ public void loadAllGames(){
LOGGER.info("loading all games on startup into the mainWindowController ...");
try {
Statement stmt = connection.createStatement();
@@ -187,7 +188,7 @@ public class DBController {
}
}
- //load one single ROM after manual adding into the mainWindowController
+ //load a single ROM to the mainWindowController
public void loadSingleGame(String titleID){
LOGGER.info("loading a single game (ID: "+titleID+") into the mainWindowController ...");
try {
@@ -223,6 +224,7 @@ public class DBController {
try {
Statement stmt = connectionGames.createStatement();
List files = (List) FileUtils.listFiles(dir, extensions, true);
+ LOGGER.info("<============================== start loading ROM Directory ==============================>");
LOGGER.info("Getting all .rpx files in " + dir.getCanonicalPath()+" including those in subdirectories");
// for all files in dir get the app.xml
for (File file : files) {
@@ -253,6 +255,7 @@ public class DBController {
}
}
}
+ LOGGER.info("<============================= finished loading ROM Directory ============================>");
} catch (IOException | SQLException | ParserConfigurationException | SAXException e) {
LOGGER.error("error while loading ROMs from directory", e);
}
@@ -268,6 +271,7 @@ public class DBController {
return check;
}
+ @SuppressWarnings("unused")
private void checkRemoveEntry() {
/**
* TODO needs to be implemented!