diff --git a/bin/application/MainWindowController$1.class b/bin/application/MainWindowController$1.class index 2b64862..a54e453 100644 Binary files a/bin/application/MainWindowController$1.class and b/bin/application/MainWindowController$1.class differ diff --git a/bin/application/MainWindowController$10.class b/bin/application/MainWindowController$10.class index 75d243b..bec5184 100644 Binary files a/bin/application/MainWindowController$10.class and b/bin/application/MainWindowController$10.class differ diff --git a/bin/application/MainWindowController$11.class b/bin/application/MainWindowController$11.class index f9edae0..38c45ae 100644 Binary files a/bin/application/MainWindowController$11.class and b/bin/application/MainWindowController$11.class differ diff --git a/bin/application/MainWindowController$12.class b/bin/application/MainWindowController$12.class index 4583258..8b48f41 100644 Binary files a/bin/application/MainWindowController$12.class and b/bin/application/MainWindowController$12.class differ diff --git a/bin/application/MainWindowController$2.class b/bin/application/MainWindowController$2.class index 8ad358a..39ba3c0 100644 Binary files a/bin/application/MainWindowController$2.class and b/bin/application/MainWindowController$2.class differ diff --git a/bin/application/MainWindowController$3.class b/bin/application/MainWindowController$3.class index 69261b1..fe84c5d 100644 Binary files a/bin/application/MainWindowController$3.class and b/bin/application/MainWindowController$3.class differ diff --git a/bin/application/MainWindowController$4.class b/bin/application/MainWindowController$4.class index ccc034a..91c78f2 100644 Binary files a/bin/application/MainWindowController$4.class and b/bin/application/MainWindowController$4.class differ diff --git a/bin/application/MainWindowController$5.class b/bin/application/MainWindowController$5.class index a4ee54d..980952b 100644 Binary files a/bin/application/MainWindowController$5.class and b/bin/application/MainWindowController$5.class differ diff --git a/bin/application/MainWindowController$6.class b/bin/application/MainWindowController$6.class index f1b268b..a5f5cd5 100644 Binary files a/bin/application/MainWindowController$6.class and b/bin/application/MainWindowController$6.class differ diff --git a/bin/application/MainWindowController$7.class b/bin/application/MainWindowController$7.class index cd9ba87..a3c4853 100644 Binary files a/bin/application/MainWindowController$7.class and b/bin/application/MainWindowController$7.class differ diff --git a/bin/application/MainWindowController$8.class b/bin/application/MainWindowController$8.class index 5cbc121..f3d2a00 100644 Binary files a/bin/application/MainWindowController$8.class and b/bin/application/MainWindowController$8.class differ diff --git a/bin/application/MainWindowController$9.class b/bin/application/MainWindowController$9.class index 808809e..f631160 100644 Binary files a/bin/application/MainWindowController$9.class and b/bin/application/MainWindowController$9.class differ diff --git a/bin/application/MainWindowController.class b/bin/application/MainWindowController.class index 48f09c4..79884c6 100644 Binary files a/bin/application/MainWindowController.class and b/bin/application/MainWindowController.class differ diff --git a/bin/application/dbController.class b/bin/application/dbController.class index 9c1975a..3d0c55b 100644 Binary files a/bin/application/dbController.class and b/bin/application/dbController.class differ diff --git a/src/application/MainWindowController.java b/src/application/MainWindowController.java index ceb16bc..49b1182 100644 --- a/src/application/MainWindowController.java +++ b/src/application/MainWindowController.java @@ -325,7 +325,6 @@ public class MainWindowController { colorPicker.setValue(Color.valueOf(getColor())); fullscreenToggleBtn.setSelected(isFullscreen()); cloudSyncToggleBtn.setSelected(isCloudSync()); - edit.setDisable(true); updateBtn.setDisable(true); // TODO autoUpdateToggleBtn.setDisable(true); // TODO applyColor(); @@ -401,7 +400,88 @@ public class MainWindowController { alert.initOwner(main.primaryStage); alert.showAndWait(); }else{ - //TODO show edit window + String[] gameInfo = dbController.getGameInfo(selectedGameTitleID); + + //new Dialog + Dialog dialog = new Dialog<>(); + dialog.setTitle("edit game"); + dialog.setHeaderText("You can edit the tile and rom/cover path."); + + // Set the button types. + ButtonType okayBtn = new ButtonType("Okay", ButtonData.OK_DONE); + dialog.getDialogPane().getButtonTypes().addAll(okayBtn, ButtonType.CANCEL); + + // Create gameTitle, titleID, gamePath and gameCover TextFields and Labels and two Btn for filechooser + GridPane grid = new GridPane(); + grid.setHgap(10); + grid.setVgap(10); + grid.setPadding(new Insets(20, 150, 10, 10)); + + TextField gameTitleTF = new TextField(); + gameTitleTF.setPromptText("game tile"); + TextField titleIDTF = new TextField(); + titleIDTF.setPromptText("title ID"); + TextField romPathTF = new TextField(); + romPathTF.setPromptText("ROM path"); + TextField gameCoverTF = new TextField(); + gameCoverTF.setPromptText("cover path"); + + gameTitleTF.setText(gameInfo[0]); + titleIDTF.setText(gameInfo[3]); + romPathTF.setText(gameInfo[2]); + gameCoverTF.setText(gameInfo[1]); + + titleIDTF.setEditable(false); + + Button selectPathBtn = new Button("select .rpx file"); + Button selectCoverBtn = new Button("select cover file"); + + selectPathBtn.setPrefWidth(110); + selectCoverBtn.setPrefWidth(110); + + selectPathBtn.setOnAction(new EventHandler() { + @Override + public void handle(ActionEvent event) { + FileChooser romDirectoryChooser = new FileChooser(); + File romDirectory = romDirectoryChooser.showOpenDialog(main.primaryStage); + romPathTF.setText(romDirectory.getAbsolutePath()); + } + }); + + selectCoverBtn.setOnAction(new EventHandler() { + @Override + public void handle(ActionEvent event) { + FileChooser coverDirectoryChooser = new FileChooser(); + File coverDirectory = coverDirectoryChooser.showOpenDialog(main.primaryStage); + gameCoverTF.setText(coverDirectory.getAbsolutePath()); + } + }); + + grid.add(new Label("game title:"), 0, 0); + grid.add(gameTitleTF, 1, 0); + grid.add(new Label("title id:"), 0, 1); + grid.add(titleIDTF, 1, 1); + grid.add(new Label("ROM path:"), 0, 2); + grid.add(romPathTF, 1, 2); + grid.add(selectPathBtn, 2, 2); + grid.add(new Label("cover path:"), 0, 3); + grid.add(gameCoverTF, 1, 3); + grid.add(selectCoverBtn, 2, 3); + + dialog.getDialogPane().setContent(grid); + + Optional result2 = dialog.showAndWait(); + if (result2.isPresent()){ + + dbController.setGameInfo(gameTitleTF.getText(), gameInfo[3], romPathTF.getText(), gameCoverTF.getText()); + games.remove(selectedUIDataIndex); + dbController.loadSingleRom(gameInfo[3]); + refreshUIData(); + + LOGGER.info("successfully edited \"" + gameInfo[0] + "\", new name is \"" + gameTitleTF.getText() + "\""); + } + + } } }); @@ -941,6 +1021,7 @@ public class MainWindowController { String titleID = null; File pictureCache; + //new Dialog Dialog dialog = new Dialog<>(); dialog.setTitle("add a new game"); dialog.setHeaderText("add a new game manually to cemu UI"); @@ -967,6 +1048,9 @@ public class MainWindowController { Button selectPathBtn = new Button("select .rpx file"); Button selectCoverBtn = new Button("select cover file"); + selectPathBtn.setPrefWidth(110); + selectCoverBtn.setPrefWidth(110); + selectPathBtn.setOnAction(new EventHandler() { @Override public void handle(ActionEvent event) { @@ -1005,19 +1089,18 @@ public class MainWindowController { title = gameTitleTF.getText(); titleID = titleIDTF.getText(); - System.out.println("Game title: " + title); - System.out.println("Title ID: " + titleID); - System.out.println("ROM path: " + romPath); - System.out.println("Game cover: " + coverPath); + LOGGER.info("Add new Game \"" + title + "\", title-ID: " + titleID); } /** - * FIXME if statement is useless at the moment - * else convert the cover to .png add copy it into the picture cache + * if one parameter is 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 */ - if (romPath == "" || coverPath == "" || title == "" || titleID == "") { + System.out.println(romPath.length()); + if (romPath.length() == 0 || coverPath.length() == 0 || title.length() == 0 || titleID.length() == 0) { LOGGER.info("No parameter set!"); + // TODO show a message that explains the error } else { coverName = new File(coverPath).getName(); try { diff --git a/src/application/dbController.java b/src/application/dbController.java index e535a91..8dc647d 100644 --- a/src/application/dbController.java +++ b/src/application/dbController.java @@ -136,7 +136,8 @@ public class dbController { void addRom(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+"','"+productCode+"','"+region+"','"+lastPlayed+"','"+timePlayed+"')"); + stmt.executeUpdate("insert into local_roms values ('"+title+"','"+coverPath+"','"+romPath+"','"+titleID+"'," + + "'"+productCode+"','"+region+"','"+lastPlayed+"','"+timePlayed+"')"); connection.commit(); stmt.close(); LOGGER.info("added \""+title+"\" to ROM database"); @@ -197,9 +198,9 @@ public class dbController { } try { - Statement stmt = connectionGames.createStatement(); - LOGGER.info("Getting all .rpx files in " + dir.getCanonicalPath()+" including those in subdirectories"); + Statement stmt = connectionGames.createStatement(); List files = (List) FileUtils.listFiles(dir, extensions, true); + LOGGER.info("Getting all .rpx files in " + dir.getCanonicalPath()+" including those in subdirectories"); for (File file : files) { if(System.getProperty("os.name").equals("Linux")){ appFile = new File(file.getParent()+"/app.xml"); @@ -266,6 +267,44 @@ public class dbController { return resizedImage; } + /** + * getting info for a game with titleID + * @param titleID Title-ID of the Game + * @return title, coverPath, romPath, titleID (in this order) + */ + String[] getGameInfo(String titleID){ + String[] gameInfo = new String[4]; + LOGGER.info("getting game info for titleID: "+titleID+" ..."); + try { + Statement stmt = connection.createStatement(); + ResultSet rs = stmt.executeQuery("SELECT * FROM local_roms where titleID = '"+titleID+"'"); + while (rs.next()) { + gameInfo[0] = rs.getString(1);// title + gameInfo[1] = rs.getString(2);// coverPath + gameInfo[2] = rs.getString(3);// romPath + gameInfo[3] = rs.getString(4);// titleID + } + stmt.close(); + rs.close(); + }catch (Exception e){ + LOGGER.error("error while getting game info", e); + } + return gameInfo; + } + + void setGameInfo(String title, String titleID, String romPath, String coverPath){ + LOGGER.info("setting game info for titleID: "+titleID+" ..."); + try { + Statement stmt = connection.createStatement(); + stmt.executeUpdate("UPDATE local_roms SET title = '" + title + "', coverPath = '" + coverPath + "'," + + " romPath = '" + romPath + "' WHERE titleID = '"+titleID+"';"); + connection.commit(); + stmt.close(); + }catch (Exception e){ + LOGGER.error("error while setting game info", e); + } + } + void setLastPlayed(String titleID){ try{ Statement stmt = connection.createStatement(); @@ -317,5 +356,5 @@ public class dbController { return timePlayed; } - + }