reworked startup process

* cemu is showing a loading screen while loading the roms
* jackson core 2.9.3 -> 2.9.4
This commit is contained in:
Jannik 2018-01-31 17:01:47 +01:00
parent f331fb57a4
commit 84b5eaedcd
4 changed files with 46 additions and 33 deletions

View File

@ -107,7 +107,7 @@
<dependency> <dependency>
<groupId>com.google.apis</groupId> <groupId>com.google.apis</groupId>
<artifactId>google-api-services-drive</artifactId> <artifactId>google-api-services-drive</artifactId>
<version>v3-rev87-1.23.0</version> <version>v3-rev99-1.23.0</version>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/com.google.http-client/google-http-client --> <!-- https://mvnrepository.com/artifact/com.google.http-client/google-http-client -->
@ -150,7 +150,7 @@
<dependency> <dependency>
<groupId>com.fasterxml.jackson.core</groupId> <groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId> <artifactId>jackson-core</artifactId>
<version>2.9.3</version> <version>2.9.4</version>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api --> <!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api -->

View File

@ -177,8 +177,7 @@ public class Main extends Application {
if(mainWindowController.isCloudSync()) { if(mainWindowController.isCloudSync()) {
cloudController.initializeConnection(mainWindowController.getCloudService(), mainWindowController.getCemuPath()); cloudController.initializeConnection(mainWindowController.getCloudService(), mainWindowController.getCemuPath());
cloudController.sync(mainWindowController.getCloudService(), mainWindowController.getCemuPath(), directory.getPath()); cloudController.sync(mainWindowController.getCloudService(), mainWindowController.getCemuPath(), directory.getPath());
} }
mainWindowController.addUIData();
scene = new Scene(pane); // create new scene, append pane to scene scene = new Scene(pane); // create new scene, append pane to scene
scene.getStylesheets().add(Main.class.getResource("/css/MainWindows.css").toExternalForm()); scene.getStylesheets().add(Main.class.getResource("/css/MainWindows.css").toExternalForm());

View File

@ -864,26 +864,7 @@ public class MainWindowController {
@FXML @FXML
void reloadRomsBtnAction() throws IOException { void reloadRomsBtnAction() throws IOException {
reloadRoms();
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();
} }
@FXML @FXML
@ -1314,6 +1295,35 @@ public class MainWindowController {
games.add(uiROMElement); 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 // add all games saved in games(ArrayList) to gamesAnchorPane
void addUIData() { void addUIData() {
for (int i = 0; i < games.size(); i++) { for (int i = 0; i < games.size(); i++) {

View File

@ -67,13 +67,11 @@ public class DBController {
* load all games * load all games
*/ */
public void init(){ public void init(){
LOGGER.info("<==========starting loading sql==========>"); LOGGER.info("<========== starting loading sql ==========>");
loadRomDatabase(); loadRomDatabase();
loadGamesDatabase(); loadGamesDatabase();
createRomDatabase(); createRomDatabase();
loadAllGames(); LOGGER.info("<========== finished loading sql ==========>");
checkRemoveEntry();
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); LOGGER.error("error while loading ROMs from ROM database, local_roms table", e);
} }
if (entries.size() == 0) { 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{ 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(); Statement stmt = connection.createStatement();
stmt.executeUpdate("insert into local_roms values ('"+title+"','"+coverPath+"','"+romPath+"','"+titleID+"'," 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"); LOGGER.info("added \""+title+"\" to ROM database");
} }
// remove a game from the database
public void removeGame(String titleID) throws SQLException{ public void removeGame(String titleID) throws SQLException{
Statement stmt = connection.createStatement(); Statement stmt = connection.createStatement();
stmt.executeUpdate("delete from local_roms where titleID = '"+titleID+"'"); stmt.executeUpdate("delete from local_roms where titleID = '"+titleID+"'");
@ -171,8 +172,8 @@ public class DBController {
LOGGER.info("removed \""+titleID+"\" from ROM database"); LOGGER.info("removed \""+titleID+"\" from ROM database");
} }
//load all ROMs on startup to the mainWindowController //load all ROMs to the mainWindowController
void loadAllGames(){ public void loadAllGames(){
LOGGER.info("loading all games on startup into the mainWindowController ..."); LOGGER.info("loading all games on startup into the mainWindowController ...");
try { try {
Statement stmt = connection.createStatement(); 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){ public void loadSingleGame(String titleID){
LOGGER.info("loading a single game (ID: "+titleID+") into the mainWindowController ..."); LOGGER.info("loading a single game (ID: "+titleID+") into the mainWindowController ...");
try { try {
@ -223,6 +224,7 @@ public class DBController {
try { try {
Statement stmt = connectionGames.createStatement(); Statement stmt = connectionGames.createStatement();
List<File> files = (List<File>) FileUtils.listFiles(dir, extensions, true); List<File> files = (List<File>) FileUtils.listFiles(dir, extensions, true);
LOGGER.info("<============================== start loading ROM Directory ==============================>");
LOGGER.info("Getting all .rpx files in " + dir.getCanonicalPath()+" including those in subdirectories"); LOGGER.info("Getting all .rpx files in " + dir.getCanonicalPath()+" including those in subdirectories");
// for all files in dir get the app.xml // for all files in dir get the app.xml
for (File file : files) { for (File file : files) {
@ -253,6 +255,7 @@ public class DBController {
} }
} }
} }
LOGGER.info("<============================= finished loading ROM Directory ============================>");
} catch (IOException | SQLException | ParserConfigurationException | SAXException e) { } catch (IOException | SQLException | ParserConfigurationException | SAXException e) {
LOGGER.error("error while loading ROMs from directory", e); LOGGER.error("error while loading ROMs from directory", e);
} }
@ -268,6 +271,7 @@ public class DBController {
return check; return check;
} }
@SuppressWarnings("unused")
private void checkRemoveEntry() { private void checkRemoveEntry() {
/** /**
* TODO needs to be implemented! * TODO needs to be implemented!