diff --git a/bin/.gitignore b/bin/.gitignore index c525beb..925b114 100644 --- a/bin/.gitignore +++ b/bin/.gitignore @@ -1,3 +1,2 @@ /application/ -/cloudControllerInstances/ -/datatypes/ +/resources/ diff --git a/bin/application/MainWindowController$1.class b/bin/application/MainWindowController$1.class index 7b865db..b945f90 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 6fe2cbd..7af7784 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 f09d400..f83b0a5 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 b859565..6d345d8 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 726d5ba..2e2e389 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 cc3370b..368fbc1 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 043b0c5..340ef4e 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 8b976eb..d591a99 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 32e7dd9..2fb460e 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 db94d8f..e66cce6 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 67e5f67..adc1094 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 5c267b9..4fc774c 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 5ca76d7..00cae42 100644 Binary files a/bin/application/MainWindowController.class and b/bin/application/MainWindowController.class differ diff --git a/src/application/MainWindowController.java b/src/application/MainWindowController.java index eadbe70..cfac03f 100644 --- a/src/application/MainWindowController.java +++ b/src/application/MainWindowController.java @@ -78,18 +78,22 @@ import javafx.fxml.FXML; import javafx.geometry.Insets; import javafx.scene.control.Alert; import javafx.scene.control.Alert.AlertType; +import javafx.scene.control.Button; +import javafx.scene.control.ButtonBar.ButtonData; import javafx.scene.control.ButtonType; import javafx.scene.control.ContextMenu; +import javafx.scene.control.Dialog; import javafx.scene.control.Label; import javafx.scene.control.MenuItem; import javafx.scene.control.ScrollPane; -import javafx.scene.control.TextInputDialog; +import javafx.scene.control.TextField; import javafx.scene.control.TreeItem; import javafx.scene.image.Image; import javafx.scene.image.ImageView; import javafx.scene.input.MouseButton; import javafx.scene.input.MouseEvent; import javafx.scene.layout.AnchorPane; +import javafx.scene.layout.GridPane; import javafx.scene.layout.HBox; import javafx.scene.layout.StackPane; import javafx.scene.layout.VBox; @@ -321,6 +325,8 @@ public class MainWindowController { fullscreenToggleBtn.setSelected(isFullscreen()); cloudSyncToggleBtn.setSelected(isCloudSync()); edit.setDisable(true); + updateBtn.setDisable(true); + autoUpdateToggleBtn.setDisable(true); applyColor(); //initialize courseTable @@ -903,106 +909,183 @@ public class MainWindowController { @FXML void addBtnAction(ActionEvent event){ - boolean exit = false; String romPath = null; String coverPath = null; String coverName = null; String title = null; String titleID = null; File pictureCache; + + //TESTING + + Dialog dialog = new Dialog<>(); + dialog.setTitle("add Dialog"); + dialog.setHeaderText("Look, a Custom Login Dialog"); + + // Set the icon (must be included in the project). +// dialog.setGraphic(new ImageView(this.getClass().getResource("login.png").toString())); + + // 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"); + + Button selectPathBtn = new Button("select .rpx file"); + Button selectCoverBtn = new Button("select .rpx file"); + + 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()){ + romPath = romPathTF.getText(); + coverPath = gameCoverTF.getText(); + 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); + } + + + // END TESTING - TextInputDialog titleDialog = new TextInputDialog(); - titleDialog.setTitle("cemu_UI"); - titleDialog.setHeaderText("add new Game"); - titleDialog.setContentText("Please enter the name of the game you want to add:"); - titleDialog.initOwner(main.primaryStage); - - Optional titleResult = titleDialog.showAndWait(); - if (titleResult.isPresent()){ - title = titleResult.get(); - }else{ - exit = true; - } - - if(exit == false){ - TextInputDialog titleIDDialog = new TextInputDialog(); - titleIDDialog.setTitle("cemu_UI"); - titleIDDialog.setHeaderText("add new Game"); - titleIDDialog.setContentText("Please enter the title-ID (12345678-12345678) \nof the game you want to add:"); - titleIDDialog.initOwner(main.primaryStage); - - Optional titleIDResult = titleIDDialog.showAndWait(); - if (titleIDResult.isPresent()){ - titleID = titleIDResult.get(); - }else{ - exit = true; - } - } - - if(exit == false){ - Alert romAlert = new Alert(AlertType.CONFIRMATION); //new alert with file-chooser - romAlert.setTitle("cemu_UI"); - romAlert.setHeaderText("add new Game"); - romAlert.setContentText("Please select the .rpx file from the game you want to add."); - romAlert.initOwner(main.primaryStage); - - Optional result = romAlert.showAndWait(); - if (result.get() == ButtonType.OK){ - FileChooser directoryChooser = new FileChooser(); - File selectedDirectory = directoryChooser.showOpenDialog(main.primaryStage); - romPath = selectedDirectory.getAbsolutePath(); - } else { - exit = true; - } - } - - if(exit == false){ - Alert coverAlert = new Alert(AlertType.CONFIRMATION); //new alert with file-chooser - coverAlert.setTitle("cemu_UI"); - coverAlert.setHeaderText("add new Game"); - coverAlert.setContentText("Please select the cover for the game you want to add."); - coverAlert.initOwner(main.primaryStage); - - Optional coverResult = coverAlert.showAndWait(); - if (coverResult.get() == ButtonType.OK){ - FileChooser directoryChooser = new FileChooser(); - File selectedDirectory = directoryChooser.showOpenDialog(main.primaryStage); - coverPath = selectedDirectory.getAbsolutePath(); - } else { - exit = true; - } - } +// TextInputDialog titleDialog = new TextInputDialog(); +// titleDialog.setTitle("cemu_UI"); +// titleDialog.setHeaderText("add new Game"); +// titleDialog.setContentText("Please enter the name of the game you want to add:"); +// titleDialog.initOwner(main.primaryStage); +// +// Optional titleResult = titleDialog.showAndWait(); +// if (titleResult.isPresent()){ +// title = titleResult.get(); +// }else{ +// exit = true; +// } +// +// if(exit == false){ +// TextInputDialog titleIDDialog = new TextInputDialog(); +// titleIDDialog.setTitle("cemu_UI"); +// titleIDDialog.setHeaderText("add new Game"); +// titleIDDialog.setContentText("Please enter the title-ID (12345678-12345678) \nof the game you want to add:"); +// titleIDDialog.initOwner(main.primaryStage); +// +// Optional titleIDResult = titleIDDialog.showAndWait(); +// if (titleIDResult.isPresent()){ +// titleID = titleIDResult.get(); +// }else{ +// exit = true; +// } +// } +// +// if(exit == false){ +// Alert romAlert = new Alert(AlertType.CONFIRMATION); //new alert with file-chooser +// romAlert.setTitle("cemu_UI"); +// romAlert.setHeaderText("add new Game"); +// romAlert.setContentText("Please select the .rpx file from the game you want to add."); +// romAlert.initOwner(main.primaryStage); +// +// Optional result = romAlert.showAndWait(); +// if (result.get() == ButtonType.OK){ +// FileChooser directoryChooser = new FileChooser(); +// File selectedDirectory = directoryChooser.showOpenDialog(main.primaryStage); +// romPath = selectedDirectory.getAbsolutePath(); +// } else { +// exit = true; +// } +// } +// +// if(exit == false){ +// Alert coverAlert = new Alert(AlertType.CONFIRMATION); //new alert with file-chooser +// coverAlert.setTitle("cemu_UI"); +// coverAlert.setHeaderText("add new Game"); +// coverAlert.setContentText("Please select the cover for the game you want to add."); +// coverAlert.initOwner(main.primaryStage); +// +// Optional coverResult = coverAlert.showAndWait(); +// if (coverResult.get() == ButtonType.OK){ +// FileChooser directoryChooser = new FileChooser(); +// File selectedDirectory = directoryChooser.showOpenDialog(main.primaryStage); +// coverPath = selectedDirectory.getAbsolutePath(); +// } else { +// exit = true; +// } +// } /** - * if exit == true then don't add a rom + * FIXME if statement is useless at the moment * else convert the cover to .png add copy it into the picture cache * then add the rom to the local_roms database */ - if(exit){ + if (romPath == "" || coverPath == "" || title == "" || titleID == "") { LOGGER.info("No parameter set!"); - }else{ + } else { coverName = new File(coverPath).getName(); try { - if(System.getProperty("os.name").equals("Linux")){ + if (System.getProperty("os.name").equals("Linux")) { pictureCache = pictureCacheLinux; - }else{ + } else { pictureCache = pictureCacheWin; } - BufferedImage originalImage = ImageIO.read(new File(coverPath));//load cover + 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); ImageIO.write(resizeImagePNG, "png", new File(pictureCache+"\\"+coverName)); //save image to pictureCache coverPath = pictureCache+"\\"+coverName; } catch (IOException e) { - LOGGER.error("Ops something went wrong!", e); + LOGGER.error("Ops something went wrong! Error while resizing cover.", e); } try { dbController.addRom(title, coverPath, romPath, titleID, "", "", "", "0"); dbController.loadSingleRom(titleID); } catch (SQLException e) { - LOGGER.error("Oops, something went wrong! Error during adding a game.", e); + LOGGER.error("Oops, something went wrong! Error while adding a game.", e); } } } @@ -1272,8 +1355,10 @@ public class MainWindowController { private void generatePosition() { int xPosHelperMax; - //FIXME somehow the window width is set to 8, if we can find a way to get always the real window with - //(at the beginning we have to use prefWidth after resizing Width) we can remove this + /**FIXME somehow the window width is set to 8, if we can find a way to get always the real window with + * PRIORITY_HIGH check if we can use main.pane.getWidth()!! + *(at the beginning we have to use prefWidth after resizing Width) we can remove this + */ if (mainAnchorPane.getWidth() < 10) { xPosHelperMax = (int) Math.floor((mainAnchorPane.getPrefWidth() - 36) / 217); } else { @@ -1290,7 +1375,7 @@ public class MainWindowController { xPosHelper++; } -// System.out.println("Breit: " + mainAnchorPane.getPrefWidth()); +// System.out.println("Breit: " + main.pane.getWidth()); // System.out.println("Breit2: " + mainAnchorPane.getWidth()); // System.out.println("xPosHelper: " + xPosHelper); // System.out.println("yPos: " + yPos);