Browse Source

reworked startup process

* cemu is showing a loading screen while loading the roms
* jackson core 2.9.3 -> 2.9.4
pull/18/head
Jannik 4 years ago
parent
commit
84b5eaedcd
  1. 4
      pom.xml
  2. 3
      src/main/java/com/cemu_UI/application/Main.java
  3. 50
      src/main/java/com/cemu_UI/application/MainWindowController.java
  4. 22
      src/main/java/com/cemu_UI/controller/DBController.java

4
pom.xml

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

3
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());

50
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++) {

22
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<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");
// 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!

Loading…
Cancel
Save

Du besuchst diese Seite mit einem veralteten IPv4-Internetzugang. Möglicherweise treten in Zukunft Probleme mit der Erreichbarkeit und Performance auf. Bitte frage deinen Internetanbieter oder Netzwerkadministrator nach IPv6-Unterstützung.
You are visiting this site with an outdated IPv4 internet access. You may experience problems with accessibility and performance in the future. Please ask your ISP or network administrator for IPv6 support.
Weitere Infos | More Information
Klicke zum schließen | Click to close