From fe6ddedab9efd869dba660b132040df231fe800f Mon Sep 17 00:00:00 2001 From: Jannik Date: Fri, 24 Nov 2017 21:36:03 +0100 Subject: [PATCH] code clean up --- .../application/MainWindowController.java | 869 +++++++++--------- 1 file changed, 416 insertions(+), 453 deletions(-) diff --git a/src/main/java/com/cemu_UI/application/MainWindowController.java b/src/main/java/com/cemu_UI/application/MainWindowController.java index 4a6c4f3..845d51f 100644 --- a/src/main/java/com/cemu_UI/application/MainWindowController.java +++ b/src/main/java/com/cemu_UI/application/MainWindowController.java @@ -40,7 +40,6 @@ import java.sql.SQLException; import java.time.LocalDate; import java.time.format.DateTimeFormatter; import java.util.ArrayList; -import java.util.Optional; import java.util.Properties; import javax.imageio.ImageIO; @@ -80,9 +79,6 @@ import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.fxml.FXML; import javafx.geometry.Insets; -import javafx.scene.control.Alert; -import javafx.scene.control.Alert.AlertType; -import javafx.scene.control.ButtonType; import javafx.scene.control.ChoiceBox; import javafx.scene.control.ContextMenu; import javafx.scene.control.Label; @@ -407,125 +403,96 @@ public class MainWindowController { }); edit.setOnAction(new EventHandler() { - @Override - public void handle(ActionEvent event) { - try { - LOGGER.info("edit "+selectedGameTitleID); - String[] gameInfo = dbController.getGameInfo(selectedGameTitleID); - - //new edit dialog - String headingText = "edit a game"; - String bodyText = "You can edit the tile and rom/cover path."; - JFXEditGameDialog editGameDialog = new JFXEditGameDialog(headingText, bodyText, dialogBtnStyle, 350, 300, - 1, MWC, main.primaryStage, main.pane); - editGameDialog.setTitle(gameInfo[0]); - editGameDialog.setCoverPath(gameInfo[1]); - editGameDialog.setRomPath(gameInfo[2]); - editGameDialog.setTitleID(gameInfo[3]); - editGameDialog.show(); + @Override + public void handle(ActionEvent event) { + try { + LOGGER.info("edit " + selectedGameTitleID); + String[] gameInfo = dbController.getGameInfo(selectedGameTitleID); + + // new edit dialog + String headingText = "edit a game"; + String bodyText = "You can edit the tile and rom/cover path."; + JFXEditGameDialog editGameDialog = new JFXEditGameDialog(headingText, bodyText, dialogBtnStyle, 450, + 300, 1, MWC, main.primaryStage, main.pane); + editGameDialog.setTitle(gameInfo[0]); + editGameDialog.setCoverPath(gameInfo[1]); + editGameDialog.setRomPath(gameInfo[2]); + editGameDialog.setTitleID(gameInfo[3]); + editGameDialog.show(); } catch (Exception e) { LOGGER.warn("trying to edit " + selectedGameTitleID + ",which is not a valid type!", e); } - -// if (selectedGameTitleID == null) { -// LOGGER.warn("trying to edit null! null is not valid!"); -// -// String headingText = "edit game"; -// String bodyText = "please select a game, \""+selectedGameTitleID+"\" is not a valid type!"; -// JFXInfoDialog aboutDialog = new JFXInfoDialog(headingText, bodyText, dialogBtnStyle, 350, 170, main.pane); -// aboutDialog.show(); -// } else { -// String[] gameInfo = dbController.getGameInfo(selectedGameTitleID); -// -// //new edit dialog -// String headingText = "edit a game"; -// String bodyText = "You can edit the tile and rom/cover path."; -// JFXEditGameDialog editGameDialog = new JFXEditGameDialog(headingText, bodyText, dialogBtnStyle, 350, 300, -// 1, MWC, main.primaryStage, main.pane); -// editGameDialog.setTitle(gameInfo[0]); -// editGameDialog.setCoverPath(gameInfo[1]); -// editGameDialog.setRomPath(gameInfo[2]); -// editGameDialog.setTitleID(gameInfo[3]); -// editGameDialog.show(); -// } - } + } }); remove.setOnAction(new EventHandler() { @Override - public void handle(ActionEvent event) { - LOGGER.info("remove "+selectedGameTitleID); - if(selectedGameTitleID == null){ - LOGGER.warn("trying to remove null! null is not valid!"); - - String headingText = "remove game"; - String bodyText = "please select a game, \""+selectedGameTitleID+"\" is not a valid type!"; - JFXInfoDialog aboutDialog = new JFXInfoDialog(headingText, bodyText, dialogBtnStyle, 350, 170, main.pane); - aboutDialog.show(); - } - else{ - Alert alert = new Alert(AlertType.CONFIRMATION); - alert.setTitle("remove"); - alert.setHeaderText("cemu_UI"); - alert.setContentText("Are you sure you want to delete "+selectedGameTitle+" ?"); - alert.initOwner(main.primaryStage); - - Optional result = alert.showAndWait(); - if (result.get() == ButtonType.OK){ - try { - // remove game from database - games.remove(selectedUIDataIndex); - dbController.removeRom(selectedGameTitleID); - - // refresh all games at gamesAnchorPane (UI) - refreshUIData(); - } catch (Exception e) { - LOGGER.error("error!",e); + public void handle(ActionEvent event) { + try { + LOGGER.info("remove " + selectedGameTitle + "(" + selectedGameTitleID + ")"); + String headingText = "remove \"" + selectedGameTitle + "\""; + String bodyText = "Are you sure you want to delete " + selectedGameTitle + " ?"; + EventHandler okayAction = new EventHandler() { + @Override + public void handle(ActionEvent event) { + try { + games.remove(selectedUIDataIndex); // remove game form games-list + dbController.removeRom(selectedGameTitleID); // remove game from database + refreshUIData(); // refresh all games at gamesAnchorPane (UI) + } catch (Exception e) { + LOGGER.error("error while removing ROM from database!", e); + } } - } - } + }; + + EventHandler cancelAction = new EventHandler() { + @Override + public void handle(ActionEvent event) { + // do nothing + } + }; + + JFXOkayCancelDialog removeGameDialog = new JFXOkayCancelDialog(headingText, bodyText, + dialogBtnStyle, 350, 170, okayAction, cancelAction, main.pane); + removeGameDialog.show(); + } catch (Exception e) { + LOGGER.error("error while removing " + selectedGameTitle + "(" + selectedGameTitleID + ")", e); + } } }); addUpdate.setOnAction(new EventHandler() { - @Override - public void handle(ActionEvent event) { - LOGGER.info("update: "+selectedGameTitleID); - if (selectedGameTitleID == null) { - LOGGER.warn("trying to update null! null is not valid!"); - String headingText = "update game"; - String bodyText = "please select a game,\n" - + "\""+selectedGameTitleID+"\" is not a valid type!"; - JFXInfoDialog updateGameErrorDialog = new JFXInfoDialog(headingText, bodyText, dialogBtnStyle, 350, 170, main.pane); - updateGameErrorDialog.show(); - } else { + @Override + public void handle(ActionEvent event) { + try { + LOGGER.info("update: " + selectedGameTitleID); String headingText = "update \"" + selectedGameTitle + "\""; - String bodyText = "pleas select the update root directory"; - EventHandler okayAction = new EventHandler(){ - @Override - public void handle(ActionEvent event){ - DirectoryChooser directoryChooser = new DirectoryChooser(); - File selectedDirecroty = directoryChooser.showDialog(main.primaryStage); - String updatePath = selectedDirecroty.getAbsolutePath(); + String bodyText = "pleas select the update root directory"; + EventHandler okayAction = new EventHandler() { + @Override + public void handle(ActionEvent event) { + DirectoryChooser directoryChooser = new DirectoryChooser(); + File selectedDirecroty = directoryChooser.showDialog(main.primaryStage); + String updatePath = selectedDirecroty.getAbsolutePath(); String[] parts = selectedGameTitleID.split("-"); // split string into 2 parts at "-" - - File srcDir = new File(updatePath); - File destDir; - if (System.getProperty("os.name").equals("Linux")) { - destDir = new File(cemuPath+"/mlc01/usr/title/"+parts[0]+"/"+parts[1]); - } else { - destDir = new File(cemuPath+"\\mlc01\\usr\\title\\"+parts[0]+"\\"+parts[1]); - } - - // if directory doesn't exist create it - if (destDir.exists() != true) { - destDir.mkdir(); - } + File srcDir = new File(updatePath); + File destDir; - try { - LOGGER.info("copying the content of " + updatePath + " to " + destDir.toString()); - playBtn.setText("updating..."); - playBtn.setDisable(true); + if (System.getProperty("os.name").equals("Linux")) { + destDir = new File(cemuPath + "/mlc01/usr/title/" + parts[0] + "/" + parts[1]); + } else { + destDir = new File(cemuPath + "\\mlc01\\usr\\title\\" + parts[0] + "\\" + parts[1]); + } + + // if directory doesn't exist create it + if (destDir.exists() != true) { + destDir.mkdir(); + } + + try { + LOGGER.info("copying the content of " + updatePath + " to " + destDir.toString()); + playBtn.setText("updating..."); + playBtn.setDisable(true); FileUtils.copyDirectory(srcDir, destDir); // TODO progress indicator playBtn.setText("play"); playBtn.setDisable(false); @@ -533,153 +500,151 @@ public class MainWindowController { } catch (IOException e) { e.printStackTrace(); } - } - }; - - EventHandler cancelAction = new EventHandler() { - @Override - public void handle(ActionEvent event) { - } }; - - JFXOkayCancelDialog updateGameDialog = new JFXOkayCancelDialog(headingText, bodyText, - dialogBtnStyle, 350, 170, okayAction, cancelAction, main.pane); - updateGameDialog.show(); - } - } - }); - - addDLC.setOnAction(new EventHandler() { - @Override - public void handle(ActionEvent event) { - LOGGER.info("add DLC: "+selectedGameTitleID); - - if (selectedGameTitleID == null) { - LOGGER.warn("trying to add a dlc to null! null is not valid!"); - String headingText = "add DLC"; - String bodyText = "please select a game,\n" - + "\"" + selectedGameTitleID + "\" is not a valid type!"; - JFXInfoDialog addDLCErrorDialog = new JFXInfoDialog(headingText, bodyText, dialogBtnStyle, 350, 170, main.pane); - addDLCErrorDialog.show(); - } else { - String headingText = "add a DLC to \"" + selectedGameTitle + "\""; - String bodyText = "pleas select the DLC root directory"; - EventHandler okayAction = new EventHandler(){ - @Override - public void handle(ActionEvent event){ - DirectoryChooser directoryChooser = new DirectoryChooser(); - File selectedDirecroty = directoryChooser.showDialog(main.primaryStage); - String dlcPath = selectedDirecroty.getAbsolutePath(); - String[] parts = selectedGameTitleID.split("-"); // split string into 2 parts at "-" - File srcDir = new File(dlcPath); - File destDir; - if (System.getProperty("os.name").equals("Linux")) { - destDir = new File(cemuPath+"/mlc01/usr/title/"+parts[0]+"/"+parts[1]+"/aoc"); - } else { - destDir = new File(cemuPath+"\\mlc01\\usr\\title\\"+parts[0]+"\\"+parts[1]+"\\aoc"); - } - - // if directory doesn't exist create it - if (destDir.exists() != true) { - destDir.mkdir(); - } - try { - LOGGER.info("copying the content of " + dlcPath + " to " + destDir.toString()); - playBtn.setText("copying files..."); - playBtn.setDisable(true); - FileUtils.copyDirectory(srcDir, destDir); // TODO progress indicator - playBtn.setText("play"); - playBtn.setDisable(false); - LOGGER.info("copying files done!"); - } catch (IOException e) { - e.printStackTrace(); - } - } - }; - EventHandler cancelAction = new EventHandler() { @Override public void handle(ActionEvent event) { - + // do nothing } }; - - JFXOkayCancelDialog addDLCDialog = new JFXOkayCancelDialog(headingText, bodyText, + + JFXOkayCancelDialog updateGameDialog = new JFXOkayCancelDialog(headingText, bodyText, dialogBtnStyle, 350, 170, okayAction, cancelAction, main.pane); + updateGameDialog.show(); + } catch (Exception e) { + LOGGER.warn("trying to update " + selectedGameTitleID + ",which is not a valid type!", e); + } + } + }); + + addDLC.setOnAction(new EventHandler() { + @Override + public void handle(ActionEvent event) { + try { + LOGGER.info("add DLC: " + selectedGameTitleID); + String headingText = "add a DLC to \"" + selectedGameTitle + "\""; + String bodyText = "pleas select the DLC root directory"; + EventHandler okayAction = new EventHandler() { + @Override + public void handle(ActionEvent event) { + DirectoryChooser directoryChooser = new DirectoryChooser(); + File selectedDirecroty = directoryChooser.showDialog(main.primaryStage); + String dlcPath = selectedDirecroty.getAbsolutePath(); + String[] parts = selectedGameTitleID.split("-"); // split string into 2 parts at "-" + File srcDir = new File(dlcPath); + File destDir; + if (System.getProperty("os.name").equals("Linux")) { + destDir = new File(cemuPath + "/mlc01/usr/title/" + parts[0] + "/" + parts[1] + "/aoc"); + } else { + destDir = new File( + cemuPath + "\\mlc01\\usr\\title\\" + parts[0] + "\\" + parts[1] + "\\aoc"); + } + + // if directory doesn't exist create it + if (destDir.exists() != true) { + destDir.mkdir(); + } + + try { + LOGGER.info("copying the content of " + dlcPath + " to " + destDir.toString()); + playBtn.setText("copying files..."); + playBtn.setDisable(true); + FileUtils.copyDirectory(srcDir, destDir); // TODO progress indicator + playBtn.setText("play"); + playBtn.setDisable(false); + LOGGER.info("copying files done!"); + } catch (IOException e) { + e.printStackTrace(); + } + } + }; + + EventHandler cancelAction = new EventHandler() { + @Override + public void handle(ActionEvent event) { + // do nothing + } + }; + + JFXOkayCancelDialog addDLCDialog = new JFXOkayCancelDialog(headingText, bodyText, dialogBtnStyle, + 350, 170, okayAction, cancelAction, main.pane); addDLCDialog.show(); - } - } + } catch (Exception e) { + LOGGER.warn("trying to add a dlc to " + selectedGameTitleID + ",which is not a valid type!", e); + } + } }); gamesAnchorPane.addEventHandler(MouseEvent.MOUSE_CLICKED, new EventHandler() { - @Override - public void handle(MouseEvent event) { - if (playTrue) { - playBtnSlideOut(); + @Override + public void handle(MouseEvent event) { + if (playTrue) { + playBtnSlideOut(); } - } + } }); topHBox.addEventHandler(MouseEvent.MOUSE_CLICKED, new EventHandler() { - @Override - public void handle(MouseEvent event) { - if (playTrue) { - playBtnSlideOut(); + @Override + public void handle(MouseEvent event) { + if (playTrue) { + playBtnSlideOut(); } - } + } }); // Change-listener for TreeTable - courseTreeTable.getSelectionModel().selectedItemProperty().addListener(new ChangeListener() { - @Override - public void changed(ObservableValue observable, Object oldVal, Object newVal){ - selected = courseTreeTable.getSelectionModel().getSelectedIndex(); //get selected item - - // FIXME if a item is selected and you change the sorting,you can't select a new item - id = idColumn.getCellData(selected); // get name of selected item + courseTreeTable.getSelectionModel().selectedItemProperty().addListener(new ChangeListener() { + @Override + public void changed(ObservableValue observable, Object oldVal, Object newVal) { + selected = courseTreeTable.getSelectionModel().getSelectedIndex(); // get selected item - for (int i = 0; i < courses.size(); i++) { - if (courses.get(i).getId() == id) { - try { - URL url = new URL("https://smmdb.ddns.net/courseimg/" + id + "_full?v=1"); - Image image = new Image(url.toURI().toString()); - smmdbImageView.setImage(image); - } catch (MalformedURLException | URISyntaxException e) { - e.printStackTrace(); - smmdbImageView.setImage(close_black); - } - addCourseDescription(courses.get(i)); + // FIXME if a item is selected and you change the sorting,you can't select a new + // item + id = idColumn.getCellData(selected); // get name of selected item + + for (int i = 0; i < courses.size(); i++) { + if (courses.get(i).getId() == id) { + try { + URL url = new URL("https://smmdb.ddns.net/courseimg/" + id + "_full?v=1"); + Image image = new Image(url.toURI().toString()); + smmdbImageView.setImage(image); + } catch (MalformedURLException | URISyntaxException e) { + e.printStackTrace(); + smmdbImageView.setImage(close_black); } - } + addCourseDescription(courses.get(i)); + } } - }); + } + }); helpLbl.setOnMouseClicked(new EventHandler() { - @Override - public void handle(MouseEvent mouseEvent) { - if(mouseEvent.getButton().equals(MouseButton.PRIMARY)){ - try { + @Override + public void handle(MouseEvent mouseEvent) { + if (mouseEvent.getButton().equals(MouseButton.PRIMARY)) { + try { Desktop.getDesktop().browse(new URI("https://github.com/Seil0/cemu_UI/issues/3")); } catch (IOException | URISyntaxException e) { e.printStackTrace(); } - } - } + } + } }); - - branchChoisBox.getSelectionModel().selectedIndexProperty().addListener(new ChangeListener() { - @Override - public void changed(ObservableValue ov, Number value, Number new_value) { - if (branchChoisBox.getItems().get((int) new_value).toString() == "beta") { + + branchChoisBox.getSelectionModel().selectedIndexProperty().addListener(new ChangeListener() { + @Override + public void changed(ObservableValue ov, Number value, Number new_value) { + if (branchChoisBox.getItems().get((int) new_value).toString() == "beta") { setUseBeta(true); } else { setUseBeta(false); } - saveSettings(); - } - }); + saveSettings(); + } + }); licensesLbl.setOnMouseClicked(new EventHandler() { @Override @@ -703,13 +668,13 @@ public class MainWindowController { LOGGER.info("initializing Actions done!"); } - @FXML - void detailsSlideoutBtnAction(ActionEvent event){ - playBtnSlideOut(); - } + @FXML + void detailsSlideoutBtnAction(ActionEvent event) { + playBtnSlideOut(); + } @FXML - void aboutBtnAction(){ + void aboutBtnAction() { String headingText = "cemu_UI"; String bodyText = "cemu_UI by @Seil0 \nVersion: " + version + " (" + buildNumber + ") \"" + versionName + "\" \n" + "This Application is made with free Software\n" @@ -719,127 +684,128 @@ public class MainWindowController { aboutDialog.show(); } - @FXML - void settingsBtnAction(ActionEvent event) { - if (smmdbTrue) { - smmdbAnchorPane.setVisible(false); - smmdbTrue = false; - } - if (settingsTrue) { - settingsScrollPane.setVisible(false); - settingsTrue = false; - saveSettings(); - } else { - settingsScrollPane.setVisible(true); - settingsTrue = true; - } - } + @FXML + void settingsBtnAction(ActionEvent event) { + if (smmdbTrue) { + smmdbAnchorPane.setVisible(false); + smmdbTrue = false; + } + if (settingsTrue) { + settingsScrollPane.setVisible(false); + settingsTrue = false; + saveSettings(); + } else { + settingsScrollPane.setVisible(true); + settingsTrue = true; + } + } - @FXML - void reloadRomsBtnAction() throws IOException{ - reloadRomsBtn.setText("reloading..."); - dbController.loadRomDirectory(getRomPath()); // TODO own thread - Runtime.getRuntime().exec("java -jar cemu_UI.jar"); // start again (preventing Bugs) - System.exit(0); // finishes itself - } + @FXML + void reloadRomsBtnAction() throws IOException { + reloadRomsBtn.setText("reloading..."); + dbController.loadRomDirectory(getRomPath()); // TODO own thread + Runtime.getRuntime().exec("java -jar cemu_UI.jar"); // start again (preventing Bugs) + System.exit(0); // finishes itself + } - @FXML - void smmdbBtnAction() { - // show smmdbAnchorPane - if (smmdbTrue) { - smmdbAnchorPane.setVisible(false); - smmdbTrue = false; - } else { - smmdbAnchorPane.setVisible(true); - smmdbTrue = true; - + @FXML + void smmdbBtnAction() { + // show smmdbAnchorPane + if (smmdbTrue) { + smmdbAnchorPane.setVisible(false); + smmdbTrue = false; + } else { + smmdbAnchorPane.setVisible(true); + smmdbTrue = true; + // start query - courses.removeAll(courses); - courses.addAll(smmdbAPIController.startQuery()); - - // add query response to courseTreeTable - for(int i = 0; i < courses.size(); i++){ - CourseTableDataType helpCourse = new CourseTableDataType(courses.get(i).getTitle(), courses.get(i).getId(), - courses.get(i).getTime(), courses.get(i).getStars()); - - root.getChildren().add(new TreeItem(helpCourse)); // add data to root-node - } - } - } + courses.removeAll(courses); + courses.addAll(smmdbAPIController.startQuery()); + + // add query response to courseTreeTable + for (int i = 0; i < courses.size(); i++) { + CourseTableDataType helpCourse = new CourseTableDataType(courses.get(i).getTitle(), + courses.get(i).getId(), courses.get(i).getTime(), courses.get(i).getStars()); + + root.getChildren().add(new TreeItem(helpCourse)); // add data to root-node + } + } + } - @FXML - void playBtnAction(ActionEvent event) throws InterruptedException, IOException{ - dbController.setLastPlayed(selectedGameTitleID); - playGame = new playGame(this,dbController); - - playGame.start(); - } + @FXML + void playBtnAction(ActionEvent event) throws InterruptedException, IOException { + dbController.setLastPlayed(selectedGameTitleID); + playGame = new playGame(this, dbController); + + playGame.start(); + } + + @FXML + void totalPlaytimeBtnAction(ActionEvent event) { + + } + + @FXML + void lastTimePlayedBtnAction(ActionEvent event) { + + } - @FXML - void totalPlaytimeBtnAction(ActionEvent event){ - - } - - @FXML - void lastTimePlayedBtnAction(ActionEvent event){ - - } - - @FXML - void cemuTFBtnAction(ActionEvent event) { - File cemuDirectory = directoryChooser.showDialog(main.primaryStage); - if(cemuDirectory == null){ - LOGGER.info("No Directory selected"); - }else{ - setCemuPath(cemuDirectory.getAbsolutePath()); - saveSettings(); - cemuTextField.setText(getCemuPath()); + @FXML + void cemuTFBtnAction(ActionEvent event) { + File cemuDirectory = directoryChooser.showDialog(main.primaryStage); + if (cemuDirectory == null) { + LOGGER.info("No Directory selected"); + } else { + setCemuPath(cemuDirectory.getAbsolutePath()); + saveSettings(); + cemuTextField.setText(getCemuPath()); try { - Runtime.getRuntime().exec("java -jar cemu_UI.jar"); // start again - System.exit(0); //finishes itself + Runtime.getRuntime().exec("java -jar cemu_UI.jar"); // start again + System.exit(0); // finishes itself } catch (IOException e) { LOGGER.error("an error occurred", e); } - } - } + } + } - @FXML - void romTFBtnAction(ActionEvent event) { - File romDirectory = directoryChooser.showDialog(main.primaryStage); - if(romDirectory == null){ - LOGGER.info("No Directory selected"); - }else{ - setRomPath(romDirectory.getAbsolutePath()); - saveSettings(); - cemuTextField.setText(getCemuPath()); + @FXML + void romTFBtnAction(ActionEvent event) { + File romDirectory = directoryChooser.showDialog(main.primaryStage); + if (romDirectory == null) { + LOGGER.info("No Directory selected"); + } else { + setRomPath(romDirectory.getAbsolutePath()); + saveSettings(); + cemuTextField.setText(getCemuPath()); try { - Runtime.getRuntime().exec("java -jar cemu_UI.jar"); // start again - System.exit(0); // finishes itself + Runtime.getRuntime().exec("java -jar cemu_UI.jar"); // start again + System.exit(0); // finishes itself } catch (IOException e) { LOGGER.error("an error occurred", e); } - } - } + } + } - @FXML - void updateBtnAction(ActionEvent event) { - updateController = new UpdateController(this, buildNumber, useBeta); + @FXML + void updateBtnAction(ActionEvent event) { + updateController = new UpdateController(this, buildNumber, useBeta); Thread updateThread = new Thread(updateController); updateThread.setName("Updater"); - updateThread.start(); + updateThread.start(); + } + + @FXML + void autoUpdateToggleBtnAction(ActionEvent event) { + if (isAutoUpdate()) { + setAutoUpdate(false); + } else { + setAutoUpdate(true); + } + saveSettings(); } @FXML - void autoUpdateToggleBtnAction(ActionEvent event) { - if(isAutoUpdate()){ - setAutoUpdate(false); - }else{ - setAutoUpdate(true); - } - saveSettings(); } - - @FXML - void smmdbDownloadBtnAction(ActionEvent event){ + void smmdbDownloadBtnAction(ActionEvent event) { String downloadUrl = "http://smmdb.ddns.net/api/downloadcourse?id=" + id + "&type=zip"; String downloadFileURL = getCemuPath() + "/" + id + ".zip"; // getCemuPath() + "/" + smmID + "/" + id + ".rar" String outputFile = getCemuPath() + "/"; @@ -903,30 +869,30 @@ public class MainWindowController { } } - @FXML - void cemuTextFieldAction(ActionEvent event){ - setCemuPath(cemuTextField.getText()); + @FXML + void cemuTextFieldAction(ActionEvent event) { + setCemuPath(cemuTextField.getText()); saveSettings(); - } + } - @FXML - void romTextFieldAction(ActionEvent event){ - setRomPath(romTextField.getText()); + @FXML + void romTextFieldAction(ActionEvent event) { + setRomPath(romTextField.getText()); saveSettings(); - } + } + + @FXML + void fullscreenToggleBtnAction(ActionEvent event) { + if (fullscreen) { + fullscreen = false; + } else { + fullscreen = true; + } + saveSettings(); + } @FXML - void fullscreenToggleBtnAction(ActionEvent event){ - if(fullscreen){ - fullscreen = false; - }else{ - fullscreen = true; - } - saveSettings(); - } - - @FXML - void cloudSyncToggleBtnAction(ActionEvent event){ + void cloudSyncToggleBtnAction(ActionEvent event) { if(cloudSync) { cloudSync = false; } else { @@ -971,20 +937,20 @@ public class MainWindowController { } } - @FXML - void colorPickerAction(ActionEvent event){ - editColor(colorPicker.getValue().toString()); - applyColor(); - } + @FXML + void colorPickerAction(ActionEvent event) { + editColor(colorPicker.getValue().toString()); + applyColor(); + } - @FXML - void addBtnAction(ActionEvent event){ - String headingText = "add a new game to cemu_UI"; - String bodyText = ""; - JFXEditGameDialog addGameDialog = new JFXEditGameDialog(headingText, bodyText, dialogBtnStyle, 450, 300, - 0, this, main.primaryStage, main.pane); + @FXML + void addBtnAction(ActionEvent event) { + String headingText = "add a new game to cemu_UI"; + String bodyText = ""; + JFXEditGameDialog addGameDialog = new JFXEditGameDialog(headingText, bodyText, dialogBtnStyle, 450, 300, 0, + this, main.primaryStage, main.pane); addGameDialog.show(); - } + } /** * process the returning data from the addGame dialog @@ -1027,10 +993,10 @@ public class MainWindowController { LOGGER.error("Ops something went wrong! Error while resizing cover.", e); } - try { + try { dbController.addRom(title, coverPath, romPath, titleID, "", "", "", "0"); dbController.loadSingleRom(titleID); - if (menuTrue) { + if (menuTrue) { sideMenuSlideOut(); burgerTask.setRate(-1.0); burgerTask.play(); @@ -1043,14 +1009,14 @@ public class MainWindowController { } } - public void editBtnReturn(String title, String coverPath, String romPath, String titleID) { + public void editBtnReturn(String title, String coverPath, String romPath, String titleID) { dbController.setGameInfo(title, coverPath, romPath, titleID); games.remove(selectedUIDataIndex); dbController.loadSingleRom(titleID); refreshUIData(); - + LOGGER.info("successfully edited " + titleID + ", new name is \"" + title + "\""); - } + } /** * add game to games (ArrayList) and initialize all needed actions (start, time stamps, titleID) @@ -1156,12 +1122,12 @@ public class MainWindowController { games.add(uiROMElement); } - //add all games saved in games(ArrayList) to gamesAnchorPane - void addUIData() { - for(int i=0; i