From 4e4d32dc97395415706661941fdc6e1da58d18fe Mon Sep 17 00:00:00 2001 From: Jannik Date: Sat, 28 Apr 2018 12:24:40 +0200 Subject: [PATCH 1/9] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3c24aac..1a3f92a 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ cemu_UI is a simple, material design graphical frontend for [cemu](http://cemu.i ## Installation Simply download the cemu_UI.jar from [releases](https://github.com/Seil0/cemu_UI/releases), make sure you have the latest version of java 8 oracle jre/jdk installed and open the file. cemu_UI creats a new directory "C:\Users\USERNAME\Documents\cemu_UI", where the database, settings and covers are stored. **first start can take while!** -If you want to use the cloud sync function read the [wiki](https://github.com/Seil0/cemu_UI/wiki#cloud-savegame-syncronisation) carefully! If you have problems using the cloud synchronisation please update to version [075](https://github.com/Seil0/cemu_UI/releases/tag/075). +If you want to use the cloud sync function read the [wiki](https://github.com/Seil0/cemu_UI/wiki#cloud-savegame-syncronisation) carefully! ### [FAQ](https://github.com/Seil0/cemu_UI/wiki#faq) From ea34f10c096fb72fd39a23caaee7798d6393975e Mon Sep 17 00:00:00 2001 From: Jannik Date: Sat, 28 Apr 2018 12:53:01 +0200 Subject: [PATCH 2/9] fixed Hamburger icon has wrong color after color change --- .../java/com/cemu_UI/application/MainWindowController.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/cemu_UI/application/MainWindowController.java b/src/main/java/com/cemu_UI/application/MainWindowController.java index 3a90c41..7d00604 100644 --- a/src/main/java/com/cemu_UI/application/MainWindowController.java +++ b/src/main/java/com/cemu_UI/application/MainWindowController.java @@ -1590,7 +1590,8 @@ private void applyColor() { addBtn.setGraphic(add_circle_white); reloadRomsBtn.setGraphic(cached_white); smmdbBtn.setGraphic(smmdb_white); - + + menuHam.getStyleClass().clear(); menuHam.getStyleClass().add("jfx-hamburgerW"); } else { dialogBtnStyle = btnStyleBlack; @@ -1612,7 +1613,8 @@ private void applyColor() { addBtn.setGraphic(add_circle_black); reloadRomsBtn.setGraphic(cached_black); smmdbBtn.setGraphic(smmdb_black); - + + menuHam.getStyleClass().clear(); menuHam.getStyleClass().add("jfx-hamburgerB"); } From e13c84382fc236d1d9f95e26ce5592400afb5e1e Mon Sep 17 00:00:00 2001 From: Jannik Date: Wed, 30 May 2018 19:41:49 +0200 Subject: [PATCH 3/9] biuld against java 10 --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 78fa8d1..2b01596 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,4 @@ language: java jdk: - oraclejdk9 + - oraclejdk10 From c6a40f89373632e7f5eb75c08109472b442f4d77 Mon Sep 17 00:00:00 2001 From: Jannik Date: Wed, 6 Jun 2018 17:54:22 +0200 Subject: [PATCH 4/9] updated some libs * jfoenix 9.0.3 -> 9.0.4 * sqlite-jdbc 3.21.0.1 -> 3.23.1 * google-api-services-drive v3-rev99-1.23.0 -> v3-rev120-1.23.0 * jackson-core 2.9.4 -> 2.9.5 * maven-shade-plugin 3.1.0 -> 3.1.1 --- pom.xml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pom.xml b/pom.xml index 95157e7..4f3d5c8 100644 --- a/pom.xml +++ b/pom.xml @@ -19,14 +19,14 @@ junit junit - 4.11 + 4.12 test com.jfoenix jfoenix - 9.0.3 + 9.0.4 @@ -38,7 +38,7 @@ org.xerial sqlite-jdbc - 3.21.0.1 + 3.23.1 @@ -107,7 +107,7 @@ com.google.apis google-api-services-drive - v3-rev99-1.23.0 + v3-rev120-1.23.0 @@ -150,7 +150,7 @@ com.fasterxml.jackson.core jackson-core - 2.9.4 + 2.9.5 @@ -195,7 +195,7 @@ org.apache.maven.plugins maven-shade-plugin - 3.1.0 + 3.1.1 package From cc4e73c45d1afb12b8769be62c5673e793dacc0b Mon Sep 17 00:00:00 2001 From: Jannik Date: Tue, 12 Jun 2018 16:01:21 +0200 Subject: [PATCH 5/9] InfoAlert & ProcessBuilder * we use an Alert now to display Info Messages * use ProcessBuilder instead of Runtime.exec() --- .../application/MainWindowController.java | 29 ++--- .../cemu_UI/controller/UpdateController.java | 2 +- .../cemu_UI/uiElements/JFXEditGameDialog.java | 4 +- .../{JFXInfoDialog.java => JFXInfoAlert.java} | 110 +++++++++++------- 4 files changed, 86 insertions(+), 59 deletions(-) rename src/main/java/com/cemu_UI/uiElements/{JFXInfoDialog.java => JFXInfoAlert.java} (51%) diff --git a/src/main/java/com/cemu_UI/application/MainWindowController.java b/src/main/java/com/cemu_UI/application/MainWindowController.java index 7d00604..a675138 100644 --- a/src/main/java/com/cemu_UI/application/MainWindowController.java +++ b/src/main/java/com/cemu_UI/application/MainWindowController.java @@ -60,7 +60,7 @@ import com.cemu_UI.datatypes.SmmdbApiDataType; import com.cemu_UI.datatypes.UIROMDataType; import com.cemu_UI.uiElements.JFXEditGameDialog; -import com.cemu_UI.uiElements.JFXInfoDialog; +import com.cemu_UI.uiElements.JFXInfoAlert; import com.cemu_UI.uiElements.JFXOkayCancelDialog; import com.cemu_UI.uiElements.JFXTextAreaInfoDialog; import com.jfoenix.controls.JFXButton; @@ -810,8 +810,8 @@ public void changed(ObservableValue observable, String oldValu saveSettings(); } else { String bodyText = newValue + ": No such file or directory"; - JFXInfoDialog fileErrorDialog = new JFXInfoDialog("Waring!", bodyText, dialogBtnStyle, 190, 150, main.getPane()); - fileErrorDialog.show(); + JFXInfoAlert fileErrorDialog = new JFXInfoAlert("Waring!", bodyText, dialogBtnStyle, main.getPrimaryStage()); + fileErrorDialog.showAndWait(); LOGGER.warn(newValue + ": No such file or directory"); } } @@ -826,8 +826,8 @@ public void changed(ObservableValue observable, String oldValu reloadRoms(); } else { String bodyText = newValue + ": No such file or directory"; - JFXInfoDialog fileErrorDialog = new JFXInfoDialog("Waring!", bodyText, dialogBtnStyle, 190, 150, main.getPane()); - fileErrorDialog.show(); + JFXInfoAlert fileErrorDialog = new JFXInfoAlert("Waring!", bodyText, dialogBtnStyle, main.getPrimaryStage()); + fileErrorDialog.showAndWait(); LOGGER.warn(newValue + ": No such file or directory"); } } @@ -842,11 +842,12 @@ void detailsSlideoutBtnAction() { } @FXML - void aboutBtnAction() { + private void aboutBtnAction() { String bodyText = "cemu_UI by @Seil0 \nVersion: " + version + " (" + buildNumber + ") \"" + versionName + "\" \n" + aboutBtnBodyText; - JFXInfoDialog aboutDialog = new JFXInfoDialog(aboutBtnHeadingText, bodyText, dialogBtnStyle, 350, 200, main.getPane()); - aboutDialog.show(); + + JFXInfoAlert infoAlert = new JFXInfoAlert(aboutBtnHeadingText, bodyText, dialogBtnStyle, main.getPrimaryStage()); + infoAlert.showAndWait(); } @FXML @@ -1069,9 +1070,9 @@ public void run() { cloudSyncToggleBtn.setSelected(false); // cloud sync init error dialog - JFXInfoDialog cloudSyncErrorDialog = new JFXInfoDialog(cloudSyncErrorHeadingText, - cloudSyncErrorBodyText, dialogBtnStyle, 450, 170, main.getPane()); - cloudSyncErrorDialog.show(); + JFXInfoAlert cloudSyncErrorDialog = new JFXInfoAlert(cloudSyncErrorHeadingText, + cloudSyncErrorBodyText, dialogBtnStyle, main.getPrimaryStage()); + cloudSyncErrorDialog.showAndWait(); } } @@ -1123,9 +1124,9 @@ public void addBtnReturn(String title, String coverPath, String romPath, String LOGGER.info("No parameter set!"); //addGame error dialog - JFXInfoDialog errorDialog = new JFXInfoDialog(addBtnReturnErrorHeadingText, addBtnReturnErrorBodyText, - dialogBtnStyle, 350, 170, main.getPane()); - errorDialog.show(); + JFXInfoAlert errorDialog = new JFXInfoAlert(addBtnReturnErrorHeadingText, addBtnReturnErrorBodyText, + dialogBtnStyle, main.getPrimaryStage()); + errorDialog.showAndWait(); } else { File pictureCache = main.getPictureCache(); diff --git a/src/main/java/com/cemu_UI/controller/UpdateController.java b/src/main/java/com/cemu_UI/controller/UpdateController.java index d214505..03aed13 100644 --- a/src/main/java/com/cemu_UI/controller/UpdateController.java +++ b/src/main/java/com/cemu_UI/controller/UpdateController.java @@ -147,7 +147,7 @@ public void run() { FileUtils.copyInputStreamToFile(pmis, new File("cemu_UI_update.jar")); // download update org.apache.commons.io.FileUtils.copyFile(new File("cemu_UI_update.jar"), new File("cemu_UI.jar")); org.apache.commons.io.FileUtils.deleteQuietly(new File("cemu_UI_update.jar")); // delete update - Runtime.getRuntime().exec("java -jar cemu_UI.jar"); // start again TODO consider ProcessBuilder to execute + new ProcessBuilder("java", "-jar", "cemu_UI.jar").start(); // start the new application System.exit(0); // finishes itself } catch (IOException e) { Platform.runLater(() -> { diff --git a/src/main/java/com/cemu_UI/uiElements/JFXEditGameDialog.java b/src/main/java/com/cemu_UI/uiElements/JFXEditGameDialog.java index 0487b14..78ba990 100644 --- a/src/main/java/com/cemu_UI/uiElements/JFXEditGameDialog.java +++ b/src/main/java/com/cemu_UI/uiElements/JFXEditGameDialog.java @@ -117,8 +117,8 @@ public void handle(ActionEvent event) { // addGame error dialog String headingTextError = mwc.getBundle().getString("editGameDialogHeadingTextError"); String bodyTextError = mwc.getBundle().getString("editGameDialogBodyTextError"); - JFXInfoDialog errorDialog = new JFXInfoDialog(headingTextError, bodyTextError, dialogBtnStyle, 350,170, pane); - errorDialog.show(); + JFXInfoAlert errorDialog = new JFXInfoAlert(headingTextError, bodyTextError, dialogBtnStyle, stage); + errorDialog.showAndWait(); } else { switch (mode) { case 0: diff --git a/src/main/java/com/cemu_UI/uiElements/JFXInfoDialog.java b/src/main/java/com/cemu_UI/uiElements/JFXInfoAlert.java similarity index 51% rename from src/main/java/com/cemu_UI/uiElements/JFXInfoDialog.java rename to src/main/java/com/cemu_UI/uiElements/JFXInfoAlert.java index ee2513a..04399aa 100644 --- a/src/main/java/com/cemu_UI/uiElements/JFXInfoDialog.java +++ b/src/main/java/com/cemu_UI/uiElements/JFXInfoAlert.java @@ -1,7 +1,7 @@ /** - * cemu_UI + * Kellerkinder Framework Alerts * - * Copyright 2017-2018 <@Seil0> + * Copyright 2018 <@Seil0> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,66 +20,92 @@ */ package com.cemu_UI.uiElements; +import com.jfoenix.controls.JFXAlert; import com.jfoenix.controls.JFXButton; -import com.jfoenix.controls.JFXDialog; import com.jfoenix.controls.JFXDialogLayout; import javafx.event.ActionEvent; import javafx.event.EventHandler; -import javafx.scene.layout.AnchorPane; -import javafx.scene.layout.Pane; -import javafx.scene.layout.StackPane; import javafx.scene.text.Text; +import javafx.stage.Stage; -public class JFXInfoDialog { - +public class JFXInfoAlert { + private String headingText; private String bodyText; - private String dialogBtnStyle; - private int dialogWidth; - private int dialogHeight; - private Pane pane; + private String btnStyle; + private Stage stage; /** - * Creates a new JFoenix Dialog to show some information - * @param headingText Heading Text, just the heading - * @param bodyText body Text, all other text belongs here - * @param dialogBtnStyle Style of the okay button - * @param dialogWidth dialog width - * @param dialogHeight dialog height - * @param pane pane to which the dialog belongs + * Creates a new JFoenix Alert to show some information + * @param headerText Heading text of the alert + * @param bodyText Content text of the alert + * @param btnStyle Style of the okay button + * @param stage stage to which the dialog belongs */ - public JFXInfoDialog(String headingText, String bodyText, String dialogBtnStyle, int dialogWidth, int dialogHeight, Pane pane) { - this.headingText = headingText; - this.bodyText = bodyText; - this.dialogBtnStyle = dialogBtnStyle; - this.dialogWidth = dialogWidth; - this.dialogHeight = dialogHeight; - this.pane = pane; + public JFXInfoAlert(String headingText, String bodyText, String btnStyle, Stage stage) { + setHeadingText(headingText); + setBodyText(bodyText); + setBtnStyle(btnStyle); + setStage(stage); } - - public void show() { - JFXDialogLayout content = new JFXDialogLayout(); - content.setHeading(new Text(headingText)); - content.setBody(new Text(bodyText)); - content.setPrefSize(dialogWidth, dialogHeight); - StackPane stackPane = new StackPane(); - stackPane.autosize(); - JFXDialog dialog = new JFXDialog(stackPane, content, JFXDialog.DialogTransition.LEFT, true); + + public JFXInfoAlert() { + // Auto-generated constructor stub + } + + public void showAndWait( ) { + JFXAlert alert = new JFXAlert<>(stage); + JFXButton button = new JFXButton("Okay"); button.setOnAction(new EventHandler() { @Override public void handle(ActionEvent event) { - dialog.close(); + alert.close(); } }); button.setButtonType(com.jfoenix.controls.JFXButton.ButtonType.RAISED); button.setPrefHeight(32); - button.setStyle(dialogBtnStyle); + button.setStyle(btnStyle); + + JFXDialogLayout content = new JFXDialogLayout(); content.setActions(button); - pane.getChildren().add(stackPane); - AnchorPane.setTopAnchor(stackPane, (pane.getHeight() - content.getPrefHeight()) / 2); - AnchorPane.setLeftAnchor(stackPane, (pane.getWidth() - content.getPrefWidth()) / 2); - dialog.show(); + content.setHeading(new Text(headingText)); + content.setBody(new Text(bodyText)); + alert.setContent(content); + alert.showAndWait(); + } + + public String getHeadingText() { + return headingText; + } + + public void setHeadingText(String headingText) { + this.headingText = headingText; + } + + public String getBodyText() { + return bodyText; + } + + public void setBodyText(String bodyText) { + this.bodyText = bodyText; + } + + public String getBtnStyle() { + return btnStyle; + } + + public void setBtnStyle(String btnStyle) { + this.btnStyle = btnStyle; + } + + public Stage getStage() { + return stage; + } + + public void setStage(Stage stage) { + this.stage = stage; } -} + +} \ No newline at end of file From 9b7a85cabec2bcfbb4edccbd72ec3ca487879323 Mon Sep 17 00:00:00 2001 From: Jannik Date: Tue, 12 Jun 2018 16:24:12 +0200 Subject: [PATCH 6/9] code clean up --- .../java/com/cemu_UI/application/Main.java | 104 ++++++++---------- .../application/MainWindowController.java | 86 +++++---------- src/main/resources/fxml/MainWindow.fxml | 2 +- 3 files changed, 72 insertions(+), 120 deletions(-) diff --git a/src/main/java/com/cemu_UI/application/Main.java b/src/main/java/com/cemu_UI/application/Main.java index 6879180..7d922e3 100644 --- a/src/main/java/com/cemu_UI/application/Main.java +++ b/src/main/java/com/cemu_UI/application/Main.java @@ -47,7 +47,6 @@ import javafx.scene.control.Alert.AlertType; import javafx.scene.layout.AnchorPane; - public class Main extends Application { private Stage primaryStage; @@ -63,13 +62,12 @@ public class Main extends Application { private static String javaVers = System.getProperty("java.version"); private static String javaVend= System.getProperty("java.vendor"); private String gamesDBdownloadURL = "https://github.com/Seil0/cemu_UI/raw/master/downloadContent/games.db"; - public String dirWin = userHome + "/Documents/cemu_UI"; // Windows: C:/Users/"User"/Documents/cemu_UI - public String dirLinux = userHome + "/cemu_UI"; // Linux: /home/"User"/cemu_UI - private File directory; - private File configFile; - private File gamesDBFile; - private File reference_gamesFile; - private File pictureCache; + private static String dirCemuUI; + private static File directory; + private static File configFile; + private static File gamesDBFile; + private static File reference_gamesFile; + private static File pictureCache; private static Logger LOGGER; @Override @@ -78,7 +76,10 @@ public void start(Stage primaryStage) { LOGGER.info("OS: " + osName + " " + osVers + " " + osArch); LOGGER.info("Java: " + javaVend + " " + javaVers); LOGGER.info("User: " + userName + " " + userHome); + this.primaryStage = primaryStage; + mainWindowController = new MainWindowController(this); + mainWindow(); initActions(); } catch (Exception e) { @@ -91,28 +92,21 @@ private void mainWindow(){ try { FXMLLoader loader = new FXMLLoader(); loader.setLocation(ClassLoader.getSystemResource("fxml/MainWindow.fxml")); + loader.setController(mainWindowController); pane = (AnchorPane) loader.load(); + primaryStage.setMinWidth(265.00); + primaryStage.setMinHeight(425.00); primaryStage.setTitle("cemu_UI"); -// primaryStage.getIcons().add(new Image(Main.class.getResourceAsStream("/resources/Homeflix_Icon_64x64.png"))); //adds application icon - - mainWindowController = loader.getController(); // Link of FXMLController and controller class - mainWindowController.setMain(this); // call setMain - cloudController = new CloudController(mainWindowController); // call cloudController constructor +// primaryStage.getIcons().add(new Image(Main.class.getResourceAsStream(""))); //adds application icon + primaryStage.setOnCloseRequest(event -> System.exit(1)); - // get OS and the specific paths - if (osName.equals("Linux")) { - directory = new File(dirLinux); - configFile = new File(dirLinux + "/config.xml"); - gamesDBFile = new File(dirLinux + "/games.db"); - reference_gamesFile = new File(dirLinux + "/reference_games.db"); - pictureCache= new File(dirLinux+"/picture_cache"); - } else { - directory = new File(dirWin); - configFile = new File(dirWin + "/config.xml"); - gamesDBFile = new File(dirWin + "/games.db"); - reference_gamesFile = new File(dirWin + "/reference_games.db"); - pictureCache= new File(dirWin+"/picture_cache"); - } + // generate window + scene = new Scene(pane); // create new scene, append pane to scene + scene.getStylesheets().add(Main.class.getResource("/css/MainWindows.css").toExternalForm()); + primaryStage.setScene(scene); // append scene to stage + primaryStage.show(); // show stage + + cloudController = new CloudController(mainWindowController); // call cloudController constructor // startup checks // check if client_secret.json is present @@ -165,14 +159,6 @@ private void mainWindow(){ } } - // generate window - scene = new Scene(pane); // create new scene, append pane to scene - scene.getStylesheets().add(Main.class.getResource("/css/MainWindows.css").toExternalForm()); - primaryStage.setMinWidth(265.00); - primaryStage.setMinHeight(425.00); - primaryStage.setScene(scene); // append scene to stage - primaryStage.show(); // show stage - // init here as it loads the games to the mwc and the gui, therefore the window must exist mainWindowController.init(); mainWindowController.getDbController().init(); @@ -183,9 +169,31 @@ private void mainWindow(){ cloudController.sync(mainWindowController.getCloudService(), mainWindowController.getCemuPath(), directory.getPath()); } - } catch (IOException e) { - e.printStackTrace(); - } + } catch (IOException e) { + e.printStackTrace(); + } + } + + public static void main(String[] args) { + + if (osName.contains("Windows")) { + dirCemuUI = userHome + "/Documents/cemu_UI"; + } else { + dirCemuUI = userHome + "/cemu_UI"; + } + + directory = new File(dirCemuUI); + configFile = new File(dirCemuUI + "/config.xml"); + gamesDBFile = new File(dirCemuUI + "/games.db"); + reference_gamesFile = new File(dirCemuUI + "/reference_games.db"); + pictureCache= new File(dirCemuUI+"/picture_cache"); + + // delete old log file and create new + System.setProperty("logFilename", dirCemuUI + "/app.log"); + File logFile = new File(dirCemuUI + "/app.log"); + logFile.delete(); + LOGGER = LogManager.getLogger(Main.class.getName()); + launch(args); } private void firstStart() { @@ -291,26 +299,6 @@ public void changed(ObservableValue ov, Boolean t, Boolean t1 primaryStage.heightProperty().addListener(heightListener); primaryStage.maximizedProperty().addListener(maximizeListener); } - - public static void main(String[] args) { - // delete old log file and create new - if (osName.equals("Linux")) { - System.setProperty("logFilename", userHome + "/cemu_UI/app.log"); - File logFile = new File(userHome + "/cemu_UI/app.log"); - logFile.delete(); - } else { - System.setProperty("logFilename", userHome + "/Documents/cemu_UI/app.log"); - File logFile = new File(userHome + "/Documents/cemu_UI/app.log"); - logFile.delete(); - } - LOGGER = LogManager.getLogger(Main.class.getName()); - launch(args); - } - - @Override - public void stop() { - System.exit(0); - } public Stage getPrimaryStage() { return primaryStage; diff --git a/src/main/java/com/cemu_UI/application/MainWindowController.java b/src/main/java/com/cemu_UI/application/MainWindowController.java index a675138..b7490c9 100644 --- a/src/main/java/com/cemu_UI/application/MainWindowController.java +++ b/src/main/java/com/cemu_UI/application/MainWindowController.java @@ -111,37 +111,26 @@ public class MainWindowController { @FXML private JFXButton aboutBtn; - @FXML private JFXButton settingsBtn; - @FXML private JFXButton addBtn; - @FXML private JFXButton reloadRomsBtn; - @FXML private JFXButton smmdbBtn; - @FXML private JFXButton cemuTFBtn; - @FXML private JFXButton romTFBtn; - @FXML private JFXButton updateBtn; - @FXML private JFXButton smmdbDownloadBtn; - @FXML private JFXButton playBtn; - @FXML private JFXButton lastTimePlayedBtn; - @FXML JFXButton totalPlaytimeBtn; @@ -150,58 +139,46 @@ public class MainWindowController { @FXML private JFXTextField cemuTextField; - @FXML private JFXTextField romTextField; - @FXML private JFXTextField courseSearchTextFiled; - @FXML private JFXTextField executeCommandTextFiled; - + @FXML private TextFlow smmdbTextFlow; - + @FXML private JFXColorPicker colorPicker; - + @FXML private JFXToggleButton cloudSyncToggleBtn; - @FXML private JFXToggleButton autoUpdateToggleBtn; - @FXML private JFXToggleButton fullscreenToggleBtn; @FXML private ChoiceBox languageChoisBox; - @FXML private ChoiceBox branchChoisBox; @FXML private AnchorPane mainAnchorPane; - @FXML private AnchorPane gamesAnchorPane; - @FXML private AnchorPane settingsAnchorPane; - @FXML private AnchorPane smmdbAnchorPane; @FXML private ScrollPane mainScrollPane; - @FXML private ScrollPane settingsScrollPane; - @FXML private ScrollPane smmdbScrollPane; - @FXML private ScrollPane smmdbImageViewScrollPane; @@ -210,7 +187,6 @@ public class MainWindowController { @FXML private HBox topHBox; - @FXML private HBox bottomHBox; @@ -219,31 +195,22 @@ public class MainWindowController { @FXML private Label helpLbl; - @FXML private Label cemu_UISettingsLbl; - @FXML private Label cemuDirectoryLbl; - @FXML private Label romDirectoryLbl; - @FXML private Label mainColorLbl; - @FXML private Label languageLbl; - @FXML private Label updateLbl; - @FXML private Label branchLbl; - @FXML private Label cemuSettingsLbl; - @FXML private Label licensesLbl; @@ -251,17 +218,14 @@ public class MainWindowController { private JFXTreeTableView courseTreeTable = new JFXTreeTableView(); @FXML - TreeItem root = new TreeItem<>(new CourseTableDataType("", "", 0, 0)); + private TreeItem root = new TreeItem<>(new CourseTableDataType("", "", 0, 0)); @FXML private JFXTreeTableColumn titleColumn = new JFXTreeTableColumn<>("title"); - @FXML private JFXTreeTableColumn idColumn = new JFXTreeTableColumn<>("id"); - @FXML private JFXTreeTableColumn starsColumn = new JFXTreeTableColumn<>("stars"); - @FXML private JFXTreeTableColumn timeColumn = new JFXTreeTableColumn<>("time"); @@ -294,7 +258,7 @@ private enum CloudService { private String selectedGameTitle; private String id; private String version = "0.3.0"; - private String buildNumber = "077"; + private String buildNumber = "079"; private String versionName = "Purple Comet"; private int xPos = -200; private int yPos = 17; @@ -372,8 +336,8 @@ private enum CloudService { private String smmdbDownloadBtnLoading; private String smmdbDownloadBtnDownload; - public void setMain(Main m) { - this.main = m; + public MainWindowController(Main main) { + this.main = main; dbController = new DBController(main, this); smmdbAPIController = new SmmdbAPIController(); } @@ -382,7 +346,7 @@ public void setMain(Main m) { * initialize the MainWindowController * loadSettings, checkAutoUpdate, initUI and initActions */ - void init() { + public void init() { loadSettings(); checkAutoUpdate(); initUI(); @@ -837,7 +801,7 @@ public void changed(ObservableValue observable, String oldValu } @FXML - void detailsSlideoutBtnAction() { + private void detailsSlideoutBtnAction() { playBtnSlideOut(); } @@ -851,7 +815,7 @@ private void aboutBtnAction() { } @FXML - void settingsBtnAction() { + private void settingsBtnAction() { if (smmdbTrue) { smmdbAnchorPane.setVisible(false); smmdbTrue = false; @@ -867,12 +831,12 @@ void settingsBtnAction() { } @FXML - void reloadRomsBtnAction() throws IOException { + private void reloadRomsBtnAction() throws IOException { reloadRoms(); } @FXML - void smmdbBtnAction() { + private void smmdbBtnAction() { // show smmdbAnchorPane if (smmdbTrue) { smmdbAnchorPane.setVisible(false); @@ -911,7 +875,7 @@ public void run() { } @FXML - void playBtnAction() throws InterruptedException, IOException { + private void playBtnAction() throws InterruptedException, IOException { dbController.setLastPlayed(selectedGameTitleID); playGame = new playGame(this, dbController); @@ -919,17 +883,17 @@ void playBtnAction() throws InterruptedException, IOException { } @FXML - void totalPlaytimeBtnAction() { + private void totalPlaytimeBtnAction() { } @FXML - void lastTimePlayedBtnAction() { + private void lastTimePlayedBtnAction() { } @FXML - void cemuTFBtnAction() { + private void cemuTFBtnAction() { File cemuDirectory = directoryChooser.showDialog(main.getPrimaryStage()); if (cemuDirectory != null) { cemuTextField.setText(cemuDirectory.getAbsolutePath()); @@ -937,7 +901,7 @@ void cemuTFBtnAction() { } @FXML - void romTFBtnAction() { + private void romTFBtnAction() { File romDirectory = directoryChooser.showDialog(main.getPrimaryStage()); if (romDirectory != null) { romTextField.setText(romDirectory.getAbsolutePath()); @@ -945,7 +909,7 @@ void romTFBtnAction() { } @FXML - void updateBtnAction() { + private void updateBtnAction() { updateController = new UpdateController(this, buildNumber, useBeta); Thread updateThread = new Thread(updateController); updateThread.setName("Updater"); @@ -953,7 +917,7 @@ void updateBtnAction() { } @FXML - void autoUpdateToggleBtnAction() { + private void autoUpdateToggleBtnAction() { if (isAutoUpdate()) { setAutoUpdate(false); } else { @@ -963,12 +927,12 @@ void autoUpdateToggleBtnAction() { } @FXML - void courseSearchTextFiledAction() { + private void courseSearchTextFiledAction() { // not in use } @FXML - void smmdbDownloadBtnAction() { + private void smmdbDownloadBtnAction() { String downloadUrl = "http://smmdb.ddns.net/api/downloadcourse?id=" + id + "&type=zip"; String downloadFileURL = getCemuPath() + "/" + id + ".zip"; // getCemuPath() + "/" + smmID + "/" + id + ".rar" String outputFile = getCemuPath() + "/"; @@ -1036,7 +1000,7 @@ void smmdbDownloadBtnAction() { } @FXML - void fullscreenToggleBtnAction() { + private void fullscreenToggleBtnAction() { if (fullscreen) { fullscreen = false; } else { @@ -1046,7 +1010,7 @@ void fullscreenToggleBtnAction() { } @FXML - void cloudSyncToggleBtnAction() { + private void cloudSyncToggleBtnAction() { if(cloudSync) { cloudSync = false; } else { @@ -1096,13 +1060,13 @@ public void handle(ActionEvent event){ } @FXML - void colorPickerAction() { + private void colorPickerAction() { editColor(colorPicker.getValue().toString()); applyColor(); } @FXML - void addBtnAction() { + private void addBtnAction() { String headingText = addGameBtnHeadingText; String bodyText = addGameBtnBodyText; JFXEditGameDialog addGameDialog = new JFXEditGameDialog(headingText, bodyText, dialogBtnStyle, 450, 300, 0, diff --git a/src/main/resources/fxml/MainWindow.fxml b/src/main/resources/fxml/MainWindow.fxml index c9dde2c..d7ed28e 100644 --- a/src/main/resources/fxml/MainWindow.fxml +++ b/src/main/resources/fxml/MainWindow.fxml @@ -18,7 +18,7 @@ - + From 41a0becd4f5de3c1d335813aa4bb6b234330880b Mon Sep 17 00:00:00 2001 From: Jannik Date: Wed, 13 Jun 2018 13:49:47 +0200 Subject: [PATCH 7/9] typo --- src/main/resources/locals/cemu_UI-Local_de_DE.properties | 4 ++-- src/main/resources/locals/cemu_UI-Local_en_US.properties | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/resources/locals/cemu_UI-Local_de_DE.properties b/src/main/resources/locals/cemu_UI-Local_de_DE.properties index 598d579..4c89c89 100644 --- a/src/main/resources/locals/cemu_UI-Local_de_DE.properties +++ b/src/main/resources/locals/cemu_UI-Local_de_DE.properties @@ -1,4 +1,4 @@ -#HomeFlix-Local_de_DE.properties geramn Local +#HomeFlix-Local_de_DE.properties DE-Deutsch Local # Buttons aboutBtn = \u00dcber @@ -46,7 +46,7 @@ licensesLblBodyText = cemu_UI ist lizensiert unter der GNU GPL 3.\n\nJFoenix, Ap showLicenses = Lizenzen \u00f6ffnen aboutBtnHeadingText = cemu_UI -aboutBtnBodyText = Diese Programm wurde mit freier Software erstellt\nund ist lizensiert unter der GNU GPL 3.\n\nwww.kellerkinder.xyz +aboutBtnBodyText = Diese Programm wurde mit freier Software erstellt\nund ist lizensiert unter der GNU GPL 3.\n\nwww.mosad.xyz cloudSyncWaringHeadingText = Spielst\u00e4nde über die Cloud syncronisieren (beta) cloudSyncWaringBodyText = WARNING this is a completly WIP cloud save integration,\nit's NOT recomended to use this!!\n\nUse it on your own risk and backup everthing before! diff --git a/src/main/resources/locals/cemu_UI-Local_en_US.properties b/src/main/resources/locals/cemu_UI-Local_en_US.properties index 043d926..4a335a1 100644 --- a/src/main/resources/locals/cemu_UI-Local_en_US.properties +++ b/src/main/resources/locals/cemu_UI-Local_en_US.properties @@ -46,7 +46,7 @@ licensesLblBodyText = cemu_UI is licensed under the terms of GNU GPL 3.\n\nJFoen showLicenses = show licenses aboutBtnHeadingText = cemu_UI -aboutBtnBodyText = This Application is made with free Software\nand licensed under the terms of GNU GPL 3.\n\nwww.kellerkinder.xyz +aboutBtnBodyText = This Application is made with free Software\nand licensed under the terms of GNU GPL 3.\n\nwww.mosad.xyz cloudSyncWaringHeadingText = activate cloud savegame sync (beta) cloudSyncWaringBodyText = WARNING this is a completely WIP cloud save integration,\nit's NOT recommended to use this!!\n\nUse it on your own risk and backup everything before! From 0f3aa108d02e43cff97f18f8ee5d7aa704e0fb28 Mon Sep 17 00:00:00 2001 From: Jannik Date: Fri, 15 Jun 2018 23:53:40 +0200 Subject: [PATCH 8/9] github -> gitea --- .travis.yml | 4 - README.md | 25 +- pom.xml | 220 -- .../java/com/cemu_UI/application/Main.java | 346 --- .../application/MainWindowController.java | 1987 ----------------- .../com/cemu_UI/application/playGame.java | 103 - .../cemu_UI/controller/CloudController.java | 226 -- .../com/cemu_UI/controller/DBController.java | 378 ---- .../controller/SmmdbAPIController.java | 154 -- .../cemu_UI/controller/UpdateController.java | 159 -- .../datatypes/CourseTableDataType.java | 46 - .../cemu_UI/datatypes/SmmdbApiDataType.java | 208 -- .../com/cemu_UI/datatypes/UIROMDataType.java | 126 -- .../cemu_UI/uiElements/JFXEditGameDialog.java | 227 -- .../com/cemu_UI/uiElements/JFXInfoAlert.java | 111 - .../uiElements/JFXOkayCancelDialog.java | 140 -- .../uiElements/JFXTextAreaInfoDialog.java | 97 - .../GoogleDriveController.java | 228 -- src/main/resources/css/MainWindows.css | 118 - src/main/resources/fxml/MainWindow.fxml | 227 -- .../resources/icons/close_black_2048x2048.png | Bin 9502 -> 0 bytes .../icons/ic_add_circle_black_24dp_1x.png | Bin 222 -> 0 bytes .../icons/ic_add_circle_white_24dp_1x.png | Bin 233 -> 0 bytes .../icons/ic_cached_black_24dp_1x.png | Bin 235 -> 0 bytes .../icons/ic_cached_white_24dp_1x.png | Bin 245 -> 0 bytes .../icons/ic_get_app_black_24dp_1x.png | Bin 114 -> 0 bytes .../icons/ic_get_app_white_24dp_1x.png | Bin 116 -> 0 bytes .../resources/icons/ic_info_black_24dp_1x.png | Bin 222 -> 0 bytes .../resources/icons/ic_info_white_24dp_1x.png | Bin 232 -> 0 bytes .../icons/ic_settings_black_24dp_1x.png | Bin 322 -> 0 bytes .../icons/ic_settings_white_24dp_1x.png | Bin 326 -> 0 bytes src/main/resources/licenses/apache2.txt | 201 -- src/main/resources/licenses/gnu_gpl3.txt | 675 ------ src/main/resources/licenses/licenses_show.txt | 822 ------- src/main/resources/licenses/mit.txt | 19 - .../locals/cemu_UI-Local_de_DE.properties | 87 - .../locals/cemu_UI-Local_en_US.properties | 87 - src/main/resources/log4j2.xml | 20 - src/test/main/com/cemu_UI/test/AppTest.java | 40 - 39 files changed, 13 insertions(+), 7068 deletions(-) delete mode 100644 .travis.yml delete mode 100644 pom.xml delete mode 100644 src/main/java/com/cemu_UI/application/Main.java delete mode 100644 src/main/java/com/cemu_UI/application/MainWindowController.java delete mode 100644 src/main/java/com/cemu_UI/application/playGame.java delete mode 100644 src/main/java/com/cemu_UI/controller/CloudController.java delete mode 100644 src/main/java/com/cemu_UI/controller/DBController.java delete mode 100644 src/main/java/com/cemu_UI/controller/SmmdbAPIController.java delete mode 100644 src/main/java/com/cemu_UI/controller/UpdateController.java delete mode 100644 src/main/java/com/cemu_UI/datatypes/CourseTableDataType.java delete mode 100644 src/main/java/com/cemu_UI/datatypes/SmmdbApiDataType.java delete mode 100644 src/main/java/com/cemu_UI/datatypes/UIROMDataType.java delete mode 100644 src/main/java/com/cemu_UI/uiElements/JFXEditGameDialog.java delete mode 100644 src/main/java/com/cemu_UI/uiElements/JFXInfoAlert.java delete mode 100644 src/main/java/com/cemu_UI/uiElements/JFXOkayCancelDialog.java delete mode 100644 src/main/java/com/cemu_UI/uiElements/JFXTextAreaInfoDialog.java delete mode 100644 src/main/java/com/cemu_UI/vendorCloudController/GoogleDriveController.java delete mode 100644 src/main/resources/css/MainWindows.css delete mode 100644 src/main/resources/fxml/MainWindow.fxml delete mode 100644 src/main/resources/icons/close_black_2048x2048.png delete mode 100644 src/main/resources/icons/ic_add_circle_black_24dp_1x.png delete mode 100644 src/main/resources/icons/ic_add_circle_white_24dp_1x.png delete mode 100644 src/main/resources/icons/ic_cached_black_24dp_1x.png delete mode 100644 src/main/resources/icons/ic_cached_white_24dp_1x.png delete mode 100644 src/main/resources/icons/ic_get_app_black_24dp_1x.png delete mode 100644 src/main/resources/icons/ic_get_app_white_24dp_1x.png delete mode 100644 src/main/resources/icons/ic_info_black_24dp_1x.png delete mode 100644 src/main/resources/icons/ic_info_white_24dp_1x.png delete mode 100644 src/main/resources/icons/ic_settings_black_24dp_1x.png delete mode 100644 src/main/resources/icons/ic_settings_white_24dp_1x.png delete mode 100644 src/main/resources/licenses/apache2.txt delete mode 100644 src/main/resources/licenses/gnu_gpl3.txt delete mode 100644 src/main/resources/licenses/licenses_show.txt delete mode 100644 src/main/resources/licenses/mit.txt delete mode 100644 src/main/resources/locals/cemu_UI-Local_de_DE.properties delete mode 100644 src/main/resources/locals/cemu_UI-Local_en_US.properties delete mode 100644 src/main/resources/log4j2.xml delete mode 100644 src/test/main/com/cemu_UI/test/AppTest.java diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 2b01596..0000000 --- a/.travis.yml +++ /dev/null @@ -1,4 +0,0 @@ -language: java -jdk: - - oraclejdk9 - - oraclejdk10 diff --git a/README.md b/README.md index 1a3f92a..c82f84b 100644 --- a/README.md +++ b/README.md @@ -6,14 +6,17 @@ [![HitCount](http://hits.dwyl.io/Seil0/cemu_UI.svg)](http://hits.dwyl.io/Seil0/cemu_UI) [![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg?style=flat-square)](https://www.gnu.org/licenses/gpl-3.0) -cemu_UI is a simple, material design graphical frontend for [cemu](http://cemu.info/), a Wii U emulator. Downloads can be found [here](https://github.com/Seil0/cemu_UI/releases). +cemu_UI is a simple, material design graphical frontend for [cemu](http://cemu.info/), a Wii U emulator. Downloads can be found [here](https://git.mosad.xyz/Seil0/cemu_UI/releases). + +## cemu_UI moved from github to our own gitea instance, for future updates visit https://git.mosad.xyz/Seil0/cemu_UI +Since Microsoft is buying Github i decided to move the projects source to our own gitea instance (https://git.mosad.xyz). This github repo will only contain the readme, wiki and releases page from now on. ## Installation -Simply download the cemu_UI.jar from [releases](https://github.com/Seil0/cemu_UI/releases), make sure you have the latest version of java 8 oracle jre/jdk installed and open the file. cemu_UI creats a new directory "C:\Users\USERNAME\Documents\cemu_UI", where the database, settings and covers are stored. **first start can take while!** +Simply download the cemu_UI.jar from [Releases](https://git.mosad.xyz/Seil0/cemu_UI/releases), make sure you have the latest version of java 8 oracle jre/jdk installed and open the file. cemu_UI creats a new directory "C:\Users\USERNAME\Documents\cemu_UI", where the database, settings and covers are stored. **first start can take while!** -If you want to use the cloud sync function read the [wiki](https://github.com/Seil0/cemu_UI/wiki#cloud-savegame-syncronisation) carefully! +If you want to use the cloud sync function read the [wiki](https://git.mosad.xyz/Seil0/cemu_UI/wiki#cloud-savegame-syncronisation) carefully! -### [FAQ](https://github.com/Seil0/cemu_UI/wiki#faq) +### [FAQ](https://git.mosad.xyz/Seil0/cemu_UI/wiki#faq) ## Features @@ -23,19 +26,17 @@ If you want to use the cloud sync function read the [wiki](https://github.com/Se * add updates and dlcs easier (only adding not downloading!) * automatic rom detection (only .rpx files with a app.xml) * customisable UI -* [sync savegames via google drive](https://github.com/Seil0/cemu_UI/wiki) +* [sync savegames via google drive](https://git.mosad.xyz/Seil0/cemu_UI/wiki) * [smmdb api](https://github.com/Tarnadas/smmdb) integration -## [planed Features](https://github.com/Seil0/cemu_UI/projects/1) (no ETA) +## [planed Features](https://git.mosad.xyz/Seil0/cemu_UI/milestones) * Controller support -### If you have another idea, make a "new issue" with the ![#f03c15](https://placehold.it/15/fbca04/000000?text=+)`idea` lable +### If you have another idea, make a new issue! -### [building from source](https://github.com/Seil0/cemu_UI/wiki/Documantation) +### [building from source](https://git.mosad.xyz/Seil0/cemu_UI/wiki/Documantation) ## Screenshots - -![Screenshot](/downloadContent/cemu_UI4.png) - - + +![Screenshot](https://git.mosad.xyz/Seil0/cemu_UI/raw/branch/master/downloadContent/cemu_UI4.png) diff --git a/pom.xml b/pom.xml deleted file mode 100644 index 4f3d5c8..0000000 --- a/pom.xml +++ /dev/null @@ -1,220 +0,0 @@ - - 4.0.0 - - com - cemu_UI - 0.3.0-SNAPSHOT - jar - cemu_UI - cemu_UI is a simple, material design graphical frontend for cemu, a Wii U emulator - http://www.kellerkinder.xyz - - - UTF-8 - - - - - - junit - junit - 4.12 - test - - - - com.jfoenix - jfoenix - 9.0.4 - - - - com.eclipsesource.minimal-json - minimal-json - 0.9.5 - - - - org.xerial - sqlite-jdbc - 3.23.1 - - - - org.apache.logging.log4j - log4j-api - 2.11.0 - - - - org.apache.logging.log4j - log4j-core - 2.11.0 - - - - commons-io - commons-io - 2.6 - - - - - org.apache.commons - commons-vfs2 - 2.2 - - - - - commons-codec - commons-codec - 1.11 - - - - - io.datafx - flow - 8.0.1 - - - - - - net.lingala.zip4j - zip4j - 1.3.2 - - - - - - commons-logging - commons-logging - 1.1.1 - - - - - com.google.api-client - google-api-client - 1.23.0 - - - - - com.google.apis - google-api-services-drive - v3-rev120-1.23.0 - - - - - com.google.http-client - google-http-client - 1.23.0 - - - - - com.google.http-client - google-http-client-jackson2 - 1.23.0 - - - - - com.google.oauth-client - google-oauth-client - 1.23.0 - - - - - - com.google.oauth-client - google-oauth-client-java6 - 1.23.0 - - - - - com.google.oauth-client - google-oauth-client-jetty - 1.23.0 - - - - - com.fasterxml.jackson.core - jackson-core - 2.9.5 - - - - - javax.servlet - javax.servlet-api - 4.0.0 - provided - - - - - org.mortbay.jetty - jetty - 6.1.26 - - - - - org.mortbay.jetty - jetty-util - 6.1.26 - - - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.7.0 - - 9 - 9 - true - true - - - - - org.apache.maven.plugins - maven-shade-plugin - 3.1.1 - - - package - - shade - - - cemu_UI - true - - - com.cemu_UI.application.Main - - - - - - - - - - diff --git a/src/main/java/com/cemu_UI/application/Main.java b/src/main/java/com/cemu_UI/application/Main.java deleted file mode 100644 index 7d922e3..0000000 --- a/src/main/java/com/cemu_UI/application/Main.java +++ /dev/null @@ -1,346 +0,0 @@ -/** - * cemu_UI - * - * Copyright 2017-2018 <@Seil0> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301, USA. - */ -package com.cemu_UI.application; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.net.URL; -import java.nio.channels.Channels; -import java.nio.channels.ReadableByteChannel; -import java.util.Optional; -import java.util.Timer; -import java.util.TimerTask; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import com.cemu_UI.controller.CloudController; - -import javafx.application.Application; -import javafx.beans.value.ChangeListener; -import javafx.beans.value.ObservableValue; -import javafx.fxml.FXMLLoader; -import javafx.stage.DirectoryChooser; -import javafx.stage.Stage; -import javafx.scene.Scene; -import javafx.scene.control.Alert; -import javafx.scene.control.ButtonType; -import javafx.scene.control.Alert.AlertType; -import javafx.scene.layout.AnchorPane; - -public class Main extends Application { - - private Stage primaryStage; - private MainWindowController mainWindowController; - private CloudController cloudController; - private AnchorPane pane; - private Scene scene; - private static String userHome = System.getProperty("user.home"); - private static String userName = System.getProperty("user.name"); - private static String osName = System.getProperty("os.name"); - private static String osArch = System.getProperty("os.arch"); - private static String osVers = System.getProperty("os.version"); - private static String javaVers = System.getProperty("java.version"); - private static String javaVend= System.getProperty("java.vendor"); - private String gamesDBdownloadURL = "https://github.com/Seil0/cemu_UI/raw/master/downloadContent/games.db"; - private static String dirCemuUI; - private static File directory; - private static File configFile; - private static File gamesDBFile; - private static File reference_gamesFile; - private static File pictureCache; - private static Logger LOGGER; - - @Override - public void start(Stage primaryStage) { - try { - LOGGER.info("OS: " + osName + " " + osVers + " " + osArch); - LOGGER.info("Java: " + javaVend + " " + javaVers); - LOGGER.info("User: " + userName + " " + userHome); - - this.primaryStage = primaryStage; - mainWindowController = new MainWindowController(this); - - mainWindow(); - initActions(); - } catch (Exception e) { - LOGGER.error("ooooops",e); - } - - } - - private void mainWindow(){ - try { - FXMLLoader loader = new FXMLLoader(); - loader.setLocation(ClassLoader.getSystemResource("fxml/MainWindow.fxml")); - loader.setController(mainWindowController); - pane = (AnchorPane) loader.load(); - primaryStage.setMinWidth(265.00); - primaryStage.setMinHeight(425.00); - primaryStage.setTitle("cemu_UI"); -// primaryStage.getIcons().add(new Image(Main.class.getResourceAsStream(""))); //adds application icon - primaryStage.setOnCloseRequest(event -> System.exit(1)); - - // generate window - scene = new Scene(pane); // create new scene, append pane to scene - scene.getStylesheets().add(Main.class.getResource("/css/MainWindows.css").toExternalForm()); - primaryStage.setScene(scene); // append scene to stage - primaryStage.show(); // show stage - - cloudController = new CloudController(mainWindowController); // call cloudController constructor - - // startup checks - // check if client_secret.json is present - if (Main.class.getResourceAsStream("/client_secret.json") == null) { - LOGGER.error("client_secret is missing!!!!!"); - - Alert alert = new Alert(AlertType.ERROR); - alert.setTitle("cemu_UI"); - alert.setHeaderText("Error"); - alert.setContentText("client_secret is missing! Please contact the maintainer. \nIf you compiled cemu_UI by yourself see: \nhttps://github.com/Seil0/cemu_UI/wiki/Documantation"); - alert.showAndWait(); - } - - if (!directory.exists()) { - LOGGER.info("creating cemu_UI directory"); - directory.mkdir(); - pictureCache.mkdir(); - } - - if (!configFile.exists()) { - LOGGER.info("firststart, setting default values"); - firstStart(); - mainWindowController.setColor("00a8cc"); - mainWindowController.setAutoUpdate(false); - mainWindowController.setLanguage("en_US"); - mainWindowController.setLastLocalSync(0); - mainWindowController.setxPosHelper(0); - mainWindowController.saveSettings(); - } - - if (!pictureCache.exists()) { - pictureCache.mkdir(); - } - - - if (!reference_gamesFile.exists()) { - if (gamesDBFile.exists()) { - gamesDBFile.delete(); - } - try { - LOGGER.info("downloading ReferenceGameList.db... "); - URL website = new URL(gamesDBdownloadURL); - ReadableByteChannel rbc = Channels.newChannel(website.openStream()); - FileOutputStream fos = new FileOutputStream(reference_gamesFile); - fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); - fos.close(); - LOGGER.info("finished downloading games.db"); - } catch (Exception e) { - e.printStackTrace(); - } - } - - // init here as it loads the games to the mwc and the gui, therefore the window must exist - mainWindowController.init(); - mainWindowController.getDbController().init(); - - // if cloud sync is activated start sync - if(mainWindowController.isCloudSync()) { - cloudController.initializeConnection(mainWindowController.getCloudService(), mainWindowController.getCemuPath()); - cloudController.sync(mainWindowController.getCloudService(), mainWindowController.getCemuPath(), directory.getPath()); - } - - } catch (IOException e) { - e.printStackTrace(); - } - } - - public static void main(String[] args) { - - if (osName.contains("Windows")) { - dirCemuUI = userHome + "/Documents/cemu_UI"; - } else { - dirCemuUI = userHome + "/cemu_UI"; - } - - directory = new File(dirCemuUI); - configFile = new File(dirCemuUI + "/config.xml"); - gamesDBFile = new File(dirCemuUI + "/games.db"); - reference_gamesFile = new File(dirCemuUI + "/reference_games.db"); - pictureCache= new File(dirCemuUI+"/picture_cache"); - - // delete old log file and create new - System.setProperty("logFilename", dirCemuUI + "/app.log"); - File logFile = new File(dirCemuUI + "/app.log"); - logFile.delete(); - LOGGER = LogManager.getLogger(Main.class.getName()); - launch(args); - } - - private void firstStart() { - Alert alert = new Alert(AlertType.CONFIRMATION); // new alert with file-chooser - alert.setTitle("cemu_UI"); - alert.setHeaderText("cemu installation"); - alert.setContentText("please select your cemu installation"); - - Optional result = alert.showAndWait(); - if (result.get() == ButtonType.OK) { - DirectoryChooser directoryChooser = new DirectoryChooser(); - File selectedDirectory = directoryChooser.showDialog(primaryStage); - mainWindowController.setCemuPath(selectedDirectory.getAbsolutePath()); - - } else { - mainWindowController.setCemuPath(null); - } - - Alert alert2 = new Alert(AlertType.CONFIRMATION); // new alert with file-chooser - alert2.setTitle("cemu_UI"); - alert2.setHeaderText("rom directory"); - alert2.setContentText("please select your rom directory"); - - Optional result2 = alert2.showAndWait(); - if (result2.get() == ButtonType.OK) { - DirectoryChooser directoryChooser = new DirectoryChooser(); - File selectedDirectory = directoryChooser.showDialog(primaryStage); - mainWindowController.setRomDirectoryPath(selectedDirectory.getAbsolutePath()); - } else { - mainWindowController.setRomDirectoryPath(null); - } - } - - private void initActions() { - final ChangeListener widthListener = new ChangeListener() { - - final Timer timer = new Timer(); - TimerTask saveTask = null; // task to execute save operation - final long delayTime = 500; // delay until the window size is saved, if the window is resized earlier it will be killed, default is 500ms - - @Override - public void changed(ObservableValue observable, Number oldValue, final Number newValue) { - int xPosHelperMax = (int) Math.floor((mainWindowController.getMainAnchorPane().getWidth() - 36) / 217); - - // call only if there is enough space for a new row - if (mainWindowController.getOldXPosHelper() != xPosHelperMax) { - mainWindowController.refreshUIData(); - } - - // if saveTask is already running kill it - if (saveTask != null) saveTask.cancel(); - - saveTask = new TimerTask() { - @Override - public void run() { - mainWindowController.saveSettings(); - } - }; - timer.schedule(saveTask, delayTime); - } - }; - - final ChangeListener heightListener = new ChangeListener() { - - final Timer timer = new Timer(); - TimerTask saveTask = null; // task to execute save operation - final long delayTime = 500; // delay until the window size is saved, if the window is resized earlier it will be killed, default is 500ms - - @Override - public void changed(ObservableValue observable, Number oldValue, final Number newValue) { - - if (saveTask != null) saveTask.cancel(); - - saveTask = new TimerTask() { - @Override - public void run() { - mainWindowController.saveSettings(); - } - }; - timer.schedule(saveTask, delayTime); - } - }; - - final ChangeListener maximizeListener = new ChangeListener() { - - @Override - public void changed(ObservableValue ov, Boolean t, Boolean t1) { - primaryStage.setMaximized(false); - - Alert alert = new Alert(AlertType.WARNING); - alert.setTitle("edit"); - alert.setHeaderText("cemu_UI"); - alert.setContentText("maximized Window is not supporte!"); - alert.initOwner(primaryStage); - alert.showAndWait(); - - LOGGER.warn("maximized Window is not supported"); - } - }; - - // add listener to primaryStage - primaryStage.widthProperty().addListener(widthListener); - primaryStage.heightProperty().addListener(heightListener); - primaryStage.maximizedProperty().addListener(maximizeListener); - } - - public Stage getPrimaryStage() { - return primaryStage; - } - - public void setPrimaryStage(Stage primaryStage) { - this.primaryStage = primaryStage; - } - - public CloudController getCloudController() { - return cloudController; - } - - public void setCloudController(CloudController cloudController) { - this.cloudController = cloudController; - } - - public AnchorPane getPane() { - return pane; - } - - public void setPane(AnchorPane pane) { - this.pane = pane; - } - - public File getDirectory() { - return directory; - } - - public File getConfigFile() { - return configFile; - } - - public File getGamesDBFile() { - return gamesDBFile; - } - - public File getReference_gamesFile() { - return reference_gamesFile; - } - - public File getPictureCache() { - return pictureCache; - } -} diff --git a/src/main/java/com/cemu_UI/application/MainWindowController.java b/src/main/java/com/cemu_UI/application/MainWindowController.java deleted file mode 100644 index b7490c9..0000000 --- a/src/main/java/com/cemu_UI/application/MainWindowController.java +++ /dev/null @@ -1,1987 +0,0 @@ -/** - * cemu_UI - * - * Copyright 2017-2018 <@Seil0> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301, USA. - */ -package com.cemu_UI.application; - -import java.awt.Desktop; -import java.awt.Graphics2D; -import java.awt.image.BufferedImage; -import java.io.BufferedReader; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.math.BigInteger; -import java.net.HttpURLConnection; -import java.net.MalformedURLException; -import java.net.URI; -import java.net.URISyntaxException; -import java.net.URL; -import java.sql.SQLException; -import java.time.LocalDate; -import java.time.format.DateTimeFormatter; -import java.util.ArrayList; -import java.util.Locale; -import java.util.Properties; -import java.util.ResourceBundle; - -import javax.imageio.ImageIO; -import javax.swing.ProgressMonitor; -import javax.swing.ProgressMonitorInputStream; - -import org.apache.commons.io.FileUtils; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import com.cemu_UI.controller.DBController; -import com.cemu_UI.controller.SmmdbAPIController; -import com.cemu_UI.controller.UpdateController; -import com.cemu_UI.datatypes.CourseTableDataType; -import com.cemu_UI.datatypes.SmmdbApiDataType; -import com.cemu_UI.datatypes.UIROMDataType; -import com.cemu_UI.uiElements.JFXEditGameDialog; -import com.cemu_UI.uiElements.JFXInfoAlert; -import com.cemu_UI.uiElements.JFXOkayCancelDialog; -import com.cemu_UI.uiElements.JFXTextAreaInfoDialog; -import com.jfoenix.controls.JFXButton; -import com.jfoenix.controls.JFXColorPicker; -import com.jfoenix.controls.JFXHamburger; -import com.jfoenix.controls.JFXSpinner; -import com.jfoenix.controls.JFXTextField; -import com.jfoenix.controls.JFXToggleButton; -import com.jfoenix.controls.JFXTreeTableColumn; -import com.jfoenix.controls.JFXTreeTableView; -import com.jfoenix.transitions.hamburger.HamburgerBackArrowBasicTransition; - -import javafx.animation.TranslateTransition; -import javafx.application.Platform; -import javafx.beans.value.ChangeListener; -import javafx.beans.value.ObservableValue; -import javafx.collections.FXCollections; -import javafx.collections.ObservableList; -import javafx.event.ActionEvent; -import javafx.event.EventHandler; -import javafx.fxml.FXML; -import javafx.geometry.Insets; -import javafx.scene.control.ChoiceBox; -import javafx.scene.control.ContextMenu; -import javafx.scene.control.Label; -import javafx.scene.control.MenuItem; -import javafx.scene.control.ScrollPane; -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.HBox; -import javafx.scene.layout.VBox; -import javafx.scene.paint.Color; -import javafx.scene.paint.Paint; -import javafx.scene.text.Font; -import javafx.scene.text.FontWeight; -import javafx.scene.text.Text; -import javafx.scene.text.TextFlow; -import javafx.stage.DirectoryChooser; -import javafx.util.Duration; -import net.lingala.zip4j.core.ZipFile; -import net.lingala.zip4j.exception.ZipException; - -public class MainWindowController { - - @FXML - private JFXButton aboutBtn; - @FXML - private JFXButton settingsBtn; - @FXML - private JFXButton addBtn; - @FXML - private JFXButton reloadRomsBtn; - @FXML - private JFXButton smmdbBtn; - @FXML - private JFXButton cemuTFBtn; - @FXML - private JFXButton romTFBtn; - @FXML - private JFXButton updateBtn; - @FXML - private JFXButton smmdbDownloadBtn; - @FXML - private JFXButton playBtn; - @FXML - private JFXButton lastTimePlayedBtn; - @FXML - JFXButton totalPlaytimeBtn; - - @FXML - private JFXHamburger menuHam; - - @FXML - private JFXTextField cemuTextField; - @FXML - private JFXTextField romTextField; - @FXML - private JFXTextField courseSearchTextFiled; - @FXML - private JFXTextField executeCommandTextFiled; - - @FXML - private TextFlow smmdbTextFlow; - - @FXML - private JFXColorPicker colorPicker; - - @FXML - private JFXToggleButton cloudSyncToggleBtn; - @FXML - private JFXToggleButton autoUpdateToggleBtn; - @FXML - private JFXToggleButton fullscreenToggleBtn; - - @FXML - private ChoiceBox languageChoisBox; - @FXML - private ChoiceBox branchChoisBox; - - @FXML - private AnchorPane mainAnchorPane; - @FXML - private AnchorPane gamesAnchorPane; - @FXML - private AnchorPane settingsAnchorPane; - @FXML - private AnchorPane smmdbAnchorPane; - - @FXML - private ScrollPane mainScrollPane; - @FXML - private ScrollPane settingsScrollPane; - @FXML - private ScrollPane smmdbScrollPane; - @FXML - private ScrollPane smmdbImageViewScrollPane; - - @FXML - private VBox sideMenuVBox; - - @FXML - private HBox topHBox; - @FXML - private HBox bottomHBox; - - @FXML - private ImageView smmdbImageView; - - @FXML - private Label helpLbl; - @FXML - private Label cemu_UISettingsLbl; - @FXML - private Label cemuDirectoryLbl; - @FXML - private Label romDirectoryLbl; - @FXML - private Label mainColorLbl; - @FXML - private Label languageLbl; - @FXML - private Label updateLbl; - @FXML - private Label branchLbl; - @FXML - private Label cemuSettingsLbl; - @FXML - private Label licensesLbl; - - @FXML - private JFXTreeTableView courseTreeTable = new JFXTreeTableView(); - - @FXML - private TreeItem root = new TreeItem<>(new CourseTableDataType("", "", 0, 0)); - - @FXML - private JFXTreeTableColumn titleColumn = new JFXTreeTableColumn<>("title"); - @FXML - private JFXTreeTableColumn idColumn = new JFXTreeTableColumn<>("id"); - @FXML - private JFXTreeTableColumn starsColumn = new JFXTreeTableColumn<>("stars"); - @FXML - private JFXTreeTableColumn timeColumn = new JFXTreeTableColumn<>("time"); - - @SuppressWarnings("unused") - private enum CloudService { - GoogleDrive, Dropbox - } - - private Main main; - private DBController dbController; - private SmmdbAPIController smmdbAPIController; - private playGame playGame; - private static MainWindowController MWC; - private UpdateController updateController; - private boolean menuTrue = false; - private boolean settingsTrue = false; - private boolean playTrue = false; - private boolean smmdbTrue = false; - private boolean autoUpdate = false; - private boolean useBeta = false; - private boolean fullscreen; - private boolean cloudSync; - private String cloudService = ""; // set cloud provider (at the moment only GoogleDrive, Dropbox is planed) - private String cemuPath; - private String romDirectoryPath; - private String gameExecutePath; - private String color; - private String dialogBtnStyle; - private String selectedGameTitleID; - private String selectedGameTitle; - private String id; - private String version = "0.3.0"; - private String buildNumber = "079"; - private String versionName = "Purple Comet"; - private int xPos = -200; - private int yPos = 17; - private int xPosHelper; - private int oldXPosHelper; - private int selectedUIDataIndex; - private int selected; - private long lastLocalSync; - private double windowWidth; - private double windowHeight; - private DirectoryChooser directoryChooser = new DirectoryChooser(); - private ObservableList branches = FXCollections.observableArrayList("stable", "beta"); - private ObservableList languages = FXCollections.observableArrayList("English (en_US)", "Deutsch (de_DE)"); - private ObservableList smmIDs = FXCollections.observableArrayList("fe31b7f2", "44fc5929"); - private ObservableList games = FXCollections.observableArrayList(); - ObservableList courses = FXCollections.observableArrayList(); - ObservableList filteredCourses = FXCollections.observableArrayList(); - ArrayList courseText = new ArrayList(); - ArrayList nameText = new ArrayList(); - Properties props = new Properties(); - Properties gameProps = new Properties(); - private static final Logger LOGGER = LogManager.getLogger(MainWindowController.class.getName()); - private HamburgerBackArrowBasicTransition burgerTask; - private MenuItem edit = new MenuItem("edit"); - private MenuItem remove = new MenuItem("remove"); - private MenuItem addUpdate = new MenuItem("update"); - private MenuItem addDLC = new MenuItem("add DLC"); - private ContextMenu gameContextMenu = new ContextMenu(edit, remove, addUpdate, addDLC); - private Label lastGameLabel = new Label(); - - private ImageView add_circle_black = new ImageView(new Image("icons/ic_add_circle_black_24dp_1x.png")); - private ImageView info_black = new ImageView(new Image("icons/ic_info_black_24dp_1x.png")); - private ImageView settings_black = new ImageView(new Image("icons/ic_settings_black_24dp_1x.png")); - private ImageView cached_black = new ImageView(new Image("icons/ic_cached_black_24dp_1x.png")); - private ImageView smmdb_black = new ImageView(new Image("icons/ic_get_app_black_24dp_1x.png")); - private ImageView add_circle_white = new ImageView(new Image("icons/ic_add_circle_white_24dp_1x.png")); - private ImageView info_white = new ImageView(new Image("icons/ic_info_white_24dp_1x.png")); - private ImageView settings_white = new ImageView(new Image("icons/ic_settings_white_24dp_1x.png")); - private ImageView cached_white = new ImageView(new Image("icons/ic_cached_white_24dp_1x.png")); - private ImageView smmdb_white = new ImageView(new Image("icons/ic_get_app_white_24dp_1x.png")); - private Image close_black = new Image("icons/close_black_2048x2048.png"); - - // language support - private ResourceBundle bundle; - private String language; - private String editHeadingText; - private String editBodyText; - private String removeHeadingText; - private String removeBodyText; - private String addUpdateHeadingText; - private String addUpdateBodyText; - private String addDLCHeadingText; - private String addDLCBodyText; - private String licensesLblHeadingText; - private String licensesLblBodyText; - private String showLicenses; - private String aboutBtnHeadingText; - private String aboutBtnBodyText; - private String cloudSyncWaringHeadingText; - private String cloudSyncWaringBodyText; - private String cloudSyncErrorHeadingText; - private String cloudSyncErrorBodyText; - private String addGameBtnHeadingText; - private String addGameBtnBodyText; - private String addBtnReturnErrorHeadingText; - private String addBtnReturnErrorBodyText; - private String lastPlayed; - private String today; - private String yesterday; - private String never; - - private String playBtnPlay; - private String playBtnUpdating; - private String playBtnCopyingFiles; - private String smmdbDownloadBtnLoading; - private String smmdbDownloadBtnDownload; - - public MainWindowController(Main main) { - this.main = main; - dbController = new DBController(main, this); - smmdbAPIController = new SmmdbAPIController(); - } - - /** - * initialize the MainWindowController - * loadSettings, checkAutoUpdate, initUI and initActions - */ - public void init() { - loadSettings(); - checkAutoUpdate(); - initUI(); - initActions(); - } - - /** - * initialize all variable UI parameters and elements - */ - private void initUI() { - LOGGER.info("initializing UI ..."); - - if (getWindowWidth() > 100 && getWindowHeight() > 100) { - mainAnchorPane.setPrefSize(getWindowWidth(), getWindowHeight()); - } - - cemuTextField.setText(cemuPath); - romTextField.setText(romDirectoryPath); - colorPicker.setValue(Color.valueOf(getColor())); - fullscreenToggleBtn.setSelected(isFullscreen()); - cloudSyncToggleBtn.setSelected(isCloudSync()); - autoUpdateToggleBtn.setSelected(isAutoUpdate()); - branchChoisBox.setItems(branches); - languageChoisBox.setItems(languages); - bottomHBox.setPickOnBounds(false); - - if (isUseBeta()) { - branchChoisBox.getSelectionModel().select(1); - } else { - branchChoisBox.getSelectionModel().select(0); - } - - applyColor(); - - // initialize courseTable - titleColumn.setPrefWidth(185); - timeColumn.setPrefWidth(112); - starsColumn.setPrefWidth(90); - - courseTreeTable.setRoot(root); - courseTreeTable.setShowRoot(false); - courseTreeTable.setEditable(false); - - titleColumn.setCellValueFactory(cellData -> cellData.getValue().getValue().title); - idColumn.setCellValueFactory(cellData -> cellData.getValue().getValue().id); - starsColumn.setCellValueFactory(cellData -> cellData.getValue().getValue().stars.asObject()); - timeColumn.setCellValueFactory(cellData -> cellData.getValue().getValue().time.asObject()); - - courseTreeTable.getColumns().add(titleColumn); - courseTreeTable.getColumns().add(timeColumn); - courseTreeTable.getColumns().add(starsColumn); - courseTreeTable.getColumns().add(idColumn); - courseTreeTable.getColumns().get(3).setVisible(false); // the idColumn should not bee displayed - - setUILanguage(); - - LOGGER.info("initializing UI done"); - } - - /** - * initialize all actions not initialized by a own method - */ - private void initActions() { - LOGGER.info("initializing Actions ..."); - - MWC = this; - burgerTask = new HamburgerBackArrowBasicTransition(menuHam); - menuHam.addEventHandler(MouseEvent.MOUSE_PRESSED, (e)->{ - if (playTrue) { - playBtnSlideOut(); - } - if (menuTrue) { - sideMenuSlideOut(); - burgerTask.setRate(-1.0); - burgerTask.play(); - menuTrue = false; - } else { - sideMenuSlideIn(); - burgerTask.setRate(1.0); - burgerTask.play(); - menuTrue = true; - } - if (settingsTrue) { - settingsScrollPane.setVisible(false); - saveSettings(); - settingsTrue = false; - } - if (smmdbTrue) { - smmdbAnchorPane.setVisible(false); - smmdbTrue = false; - } - - }); - - 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 = editHeadingText + " \"" + selectedGameTitle + "\""; - JFXEditGameDialog editGameDialog = new JFXEditGameDialog(headingText, editBodyText, dialogBtnStyle, 450, - 300, 1, MWC, main.getPrimaryStage(), main.getPane()); - 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); - } - } - }); - - remove.setOnAction(new EventHandler() { - @Override - public void handle(ActionEvent event) { - try { - LOGGER.info("remove " + selectedGameTitle + "(" + selectedGameTitleID + ")"); - String headingText = removeHeadingText + " \"" + selectedGameTitle + "\""; - String bodyText = removeBodyText + " " + selectedGameTitle + " ?"; - EventHandler okayAction = new EventHandler() { - @Override - public void handle(ActionEvent event) { - try { - games.remove(selectedUIDataIndex); // remove game form games-list - dbController.removeGame(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) { - LOGGER.info("Action canceld by user!"); - } - }; - - JFXOkayCancelDialog removeGameDialog = new JFXOkayCancelDialog(headingText, bodyText, - dialogBtnStyle, 350, 170, okayAction, cancelAction, main.getPane(), bundle); - removeGameDialog.show(); - } catch (Exception e) { - LOGGER.error("error while removing " + selectedGameTitle + "(" + selectedGameTitleID + ")", e); - } - } - }); - - addUpdate.setOnAction(new EventHandler() { - @Override - public void handle(ActionEvent event) { - try { - LOGGER.info("update: " + selectedGameTitleID); - String headingText = addUpdateHeadingText + " \"" + selectedGameTitle + "\""; - EventHandler okayAction = new EventHandler() { - @Override - public void handle(ActionEvent event) { - DirectoryChooser directoryChooser = new DirectoryChooser(); - File selectedDirecroty = directoryChooser.showDialog(main.getPrimaryStage()); - String updatePath = selectedDirecroty.getAbsolutePath(); - String[] parts = selectedGameTitleID.split("-"); // split string into 2 parts at "-" - File srcDir = new File(updatePath); - File 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(playBtnUpdating); - playBtn.setDisable(true); - FileUtils.copyDirectory(srcDir, destDir); - playBtn.setText(playBtnPlay); - playBtn.setDisable(false); - LOGGER.info("copying files done!"); - } catch (IOException e) { - e.printStackTrace(); - } - } - }; - - EventHandler cancelAction = new EventHandler() { - @Override - public void handle(ActionEvent event) { - LOGGER.info("Action canceld by user!"); - } - }; - - JFXOkayCancelDialog updateGameDialog = new JFXOkayCancelDialog(headingText, addUpdateBodyText, - dialogBtnStyle, 350, 170, okayAction, cancelAction, main.getPane(), bundle); - 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 = addDLCHeadingText + " \"" + selectedGameTitle + "\""; - EventHandler okayAction = new EventHandler() { - @Override - public void handle(ActionEvent event) { - DirectoryChooser directoryChooser = new DirectoryChooser(); - File selectedDirecroty = directoryChooser.showDialog(main.getPrimaryStage()); - String dlcPath = selectedDirecroty.getAbsolutePath(); - String[] parts = selectedGameTitleID.split("-"); // split string into 2 parts at "-" - File srcDir = new File(dlcPath); - File 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(playBtnCopyingFiles); - playBtn.setDisable(true); - FileUtils.copyDirectory(srcDir, destDir); - playBtn.setText(playBtnPlay); - playBtn.setDisable(false); - LOGGER.info("copying files done!"); - } catch (IOException e) { - e.printStackTrace(); - } - } - }; - - EventHandler cancelAction = new EventHandler() { - @Override - public void handle(ActionEvent event) { - LOGGER.info("Action canceld by user!"); - } - }; - - JFXOkayCancelDialog addDLCDialog = new JFXOkayCancelDialog(headingText, addDLCBodyText, dialogBtnStyle, - 350, 170, okayAction, cancelAction, main.getPane(), bundle); - 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(); - } - } - }); - - topHBox.addEventHandler(MouseEvent.MOUSE_CLICKED, new EventHandler() { - @Override - public void handle(MouseEvent event) { - if (playTrue) { - playBtnSlideOut(); - } - } - }); - - courseSearchTextFiled.textProperty().addListener(new ChangeListener() { - @Override - public void changed(ObservableValue observable, String oldValue, String newValue) { - - filteredCourses.removeAll(filteredCourses); - root.getChildren().remove(0, root.getChildren().size()); - - for (int i = 0; i < courses.size(); i++) { - if (courses.get(i).getTitle().toLowerCase() - .contains(courseSearchTextFiled.getText().toLowerCase())) { - - // add data from courses to filteredCourses where title contains search input - filteredCourses.add(courses.get(i)); - } - } - - for (int i = 0; i < filteredCourses.size(); i++) { - CourseTableDataType helpCourse = new CourseTableDataType(filteredCourses.get(i).getTitle(), - filteredCourses.get(i).getId(), filteredCourses.get(i).getTime(), - filteredCourses.get(i).getStars()); - - root.getChildren().add(new TreeItem(helpCourse)); // add data to root-node - } - } - }); - - // 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 - - 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 sourceImage = new Image(url.toURI().toString()); - - // scale image to 142px - double scalefactor = 142 / sourceImage.getHeight(); // calculate scaling factor - int nWidth = (int) Math.rint(scalefactor * sourceImage.getWidth()); - int nHeight = (int) Math.rint(scalefactor * sourceImage.getHeight()); - Image scaledImage = new Image(url.toURI().toString(), nWidth, nHeight, false, true); // generate a scaled image - - smmdbImageView.setFitWidth(scaledImage.getWidth()); // set ImageView width to the image width - smmdbImageView.setImage(scaledImage); // set imageview to image - } catch (MalformedURLException | URISyntaxException e) { - LOGGER.warn("There was either a problem or no image!", e); - smmdbImageView.setImage(close_black); - } - addCourseDescription(courses.get(i)); - } - } - } - }); - - helpLbl.setOnMouseClicked(new EventHandler() { - @Override - public void handle(MouseEvent mouseEvent) { - if (mouseEvent.getButton().equals(MouseButton.PRIMARY)) { - Thread thread = new Thread(new Runnable() { - @Override - public void run() { - try { - Desktop.getDesktop().browse(new URI("https://github.com/Seil0/cemu_UI/issues/3")); - } catch (IOException | URISyntaxException e) { - LOGGER.error("An error ocoured while trying to open a Website.", e); - } - } - }); - thread.start(); - } - } - }); - - languageChoisBox.getSelectionModel().selectedIndexProperty().addListener(new ChangeListener() { - @Override - public void changed(ObservableValue ov, Number value, Number new_value) { - String language = languageChoisBox.getItems().get((int) new_value).toString(); - language = language.substring(language.length()-6,language.length()-1); //reading only en_US from English (en_US) - setLanguage(language); - setUILanguage(); - saveSettings(); - } - }); - - 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(); - } - }); - - licensesLbl.setOnMouseClicked(new EventHandler() { - @Override - public void handle(MouseEvent mouseEvent) { - if(mouseEvent.getButton().equals(MouseButton.PRIMARY)){ - - EventHandler okayAction = new EventHandler() { - @Override - public void handle(ActionEvent event) { - // do nothing - } - }; - EventHandler cancelAction = new EventHandler() { - @Override - public void handle(ActionEvent event) { - String headingText = "cemu_UI"; - String bodyText = ""; - - try { - BufferedReader licenseBR = new BufferedReader( - new InputStreamReader(getClass().getResourceAsStream("/licenses/licenses_show.txt"))); - String currentLine; - - while ((currentLine = licenseBR.readLine()) != null) { - bodyText = bodyText + currentLine + "\n"; - } - - licenseBR.close(); - } catch (IOException e) { - LOGGER.error("Cloud not read the license file!", e); - } - - JFXTextAreaInfoDialog licenseDialog = new JFXTextAreaInfoDialog(headingText, bodyText, - dialogBtnStyle, 510, 450, main.getPane()); - licenseDialog.show(); - licenseDialog.getTextArea().setEditable(false); - } - }; - - JFXOkayCancelDialog licenseOverviewDialog = new JFXOkayCancelDialog(licensesLblHeadingText, - licensesLblBodyText, dialogBtnStyle, 350, 275, okayAction, cancelAction, main.getPane(), - bundle); - licenseOverviewDialog.setCancelText(showLicenses); - licenseOverviewDialog.show(); - } - } - }); - - cemuTextField.textProperty().addListener(new ChangeListener() { - @Override - public void changed(ObservableValue observable, String oldValue, String newValue) { - if (new File(newValue).exists()) { - setCemuPath(newValue); - saveSettings(); - } else { - String bodyText = newValue + ": No such file or directory"; - JFXInfoAlert fileErrorDialog = new JFXInfoAlert("Waring!", bodyText, dialogBtnStyle, main.getPrimaryStage()); - fileErrorDialog.showAndWait(); - LOGGER.warn(newValue + ": No such file or directory"); - } - } - }); - - romTextField.textProperty().addListener(new ChangeListener() { - @Override - public void changed(ObservableValue observable, String oldValue, String newValue) { - if (new File(newValue).exists()) { - setRomDirectoryPath(newValue); - saveSettings(); - reloadRoms(); - } else { - String bodyText = newValue + ": No such file or directory"; - JFXInfoAlert fileErrorDialog = new JFXInfoAlert("Waring!", bodyText, dialogBtnStyle, main.getPrimaryStage()); - fileErrorDialog.showAndWait(); - LOGGER.warn(newValue + ": No such file or directory"); - } - } - }); - - LOGGER.info("initializing Actions done!"); - } - - @FXML - private void detailsSlideoutBtnAction() { - playBtnSlideOut(); - } - - @FXML - private void aboutBtnAction() { - String bodyText = "cemu_UI by @Seil0 \nVersion: " + version + " (" + buildNumber + ") \"" + versionName + "\" \n" - + aboutBtnBodyText; - - JFXInfoAlert infoAlert = new JFXInfoAlert(aboutBtnHeadingText, bodyText, dialogBtnStyle, main.getPrimaryStage()); - infoAlert.showAndWait(); - } - - @FXML - private void settingsBtnAction() { - if (smmdbTrue) { - smmdbAnchorPane.setVisible(false); - smmdbTrue = false; - } - if (settingsTrue) { - settingsScrollPane.setVisible(false); - settingsTrue = false; - saveSettings(); - } else { - settingsScrollPane.setVisible(true); - settingsTrue = true; - } - } - - @FXML - private void reloadRomsBtnAction() throws IOException { - reloadRoms(); - } - - @FXML - private void smmdbBtnAction() { - // show smmdbAnchorPane - if (smmdbTrue) { - smmdbAnchorPane.setVisible(false); - smmdbTrue = false; - } else { - smmdbAnchorPane.setVisible(true); - smmdbTrue = true; - - // start query in new thread - Thread thread = new Thread(new Runnable() { - @Override - public void run() { - Platform.runLater(() -> { - smmdbDownloadBtn.setText(smmdbDownloadBtnLoading); - smmdbDownloadBtn.setDisable(true); - root.getChildren().remove(0,root.getChildren().size()); - }); - courses.removeAll(courses); // remove existing courses - courses.addAll(smmdbAPIController.startQuery()); // start query - - // 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()); - - Platform.runLater(() -> { - root.getChildren().add(new TreeItem(helpCourse)); // add data to root-node - smmdbDownloadBtn.setText(smmdbDownloadBtnDownload); - smmdbDownloadBtn.setDisable(false); - }); - } - } - }); - thread.start(); - } - } - - @FXML - private void playBtnAction() throws InterruptedException, IOException { - dbController.setLastPlayed(selectedGameTitleID); - playGame = new playGame(this, dbController); - - playGame.start(); - } - - @FXML - private void totalPlaytimeBtnAction() { - - } - - @FXML - private void lastTimePlayedBtnAction() { - - } - - @FXML - private void cemuTFBtnAction() { - File cemuDirectory = directoryChooser.showDialog(main.getPrimaryStage()); - if (cemuDirectory != null) { - cemuTextField.setText(cemuDirectory.getAbsolutePath()); - } - } - - @FXML - private void romTFBtnAction() { - File romDirectory = directoryChooser.showDialog(main.getPrimaryStage()); - if (romDirectory != null) { - romTextField.setText(romDirectory.getAbsolutePath()); - } - } - - @FXML - private void updateBtnAction() { - updateController = new UpdateController(this, buildNumber, useBeta); - Thread updateThread = new Thread(updateController); - updateThread.setName("Updater"); - updateThread.start(); - } - - @FXML - private void autoUpdateToggleBtnAction() { - if (isAutoUpdate()) { - setAutoUpdate(false); - } else { - setAutoUpdate(true); - } - saveSettings(); - } - - @FXML - private void courseSearchTextFiledAction() { - // not in use - } - - @FXML - private void smmdbDownloadBtnAction() { - String downloadUrl = "http://smmdb.ddns.net/api/downloadcourse?id=" + id + "&type=zip"; - String downloadFileURL = getCemuPath() + "/" + id + ".zip"; // getCemuPath() + "/" + smmID + "/" + id + ".rar" - String outputFile = getCemuPath() + "/"; - - try { - LOGGER.info("beginning download ..."); - HttpURLConnection conn = (HttpURLConnection) new URL(downloadUrl).openConnection(); - ProgressMonitorInputStream pmis = new ProgressMonitorInputStream(null, "Downloading...", conn.getInputStream()); - ProgressMonitor pm = pmis.getProgressMonitor(); - pm.setMillisToDecideToPopup(0); - pm.setMillisToPopup(0); - pm.setMinimum(0); // tell the progress bar that we start at the beginning of the stream - pm.setMaximum(conn.getContentLength()); // tell the progress bar the total number of bytes we are going to read. - FileUtils.copyInputStreamToFile(pmis, new File(downloadFileURL)); // download file + "/mlc01/emulatorSave" - pmis.close(); - LOGGER.info("downloaded successfull"); - - File downloadFile = new File(downloadFileURL); - - String source = downloadFileURL; - String destination = null; - int highestCourseNumber = 0; - String courseName = null; - - for (int i = 0; i < smmIDs.size(); i++) { - File smmDirectory = new File(outputFile + "mlc01/emulatorSave/" + smmIDs.get(i)); - - if (smmDirectory.exists()) { - LOGGER.info("found smm directory: " + smmDirectory.getAbsolutePath()); - File[] courses = smmDirectory.listFiles(File::isDirectory); - - // get all existing courses in smm directory, new name is highest number +1 - for (int j = 0; j < courses.length; j++) { - int courseNumber = Integer.parseInt(courses[j].getName().substring(6)); - if (courseNumber > highestCourseNumber) { - highestCourseNumber = courseNumber; - } - } - - String number = "000" + (highestCourseNumber +1); - courseName = "course" + number.substring(number.length() -3, number.length()); - File courseDirectory = new File(outputFile + "mlc01/emulatorSave/" + smmIDs.get(i) + "/"); - destination = courseDirectory.getPath(); - } - } - - if (destination != null) { - try { - ZipFile zipFile = new ZipFile(source); - zipFile.extractAll(destination); - - // rename zip-file - File course = new File(destination + "/course000"); - course.renameTo( new File(destination + "/" + courseName)); - LOGGER.info("Added new course: " + courseName + ", full path is: " + destination + "/" + courseName); - } catch (ZipException e) { - LOGGER.error("an error occurred during unziping the file!", e); - } - } - - downloadFile.delete(); - } catch (IOException e) { - LOGGER.error("something went wrong during downloading the course", e); - } - } - - @FXML - private void fullscreenToggleBtnAction() { - if (fullscreen) { - fullscreen = false; - } else { - fullscreen = true; - } - saveSettings(); - } - - @FXML - private void cloudSyncToggleBtnAction() { - if(cloudSync) { - cloudSync = false; - } else { - EventHandler okayAction = new EventHandler(){ - @Override - public void handle(ActionEvent event){ - cloudSync = true; - //TODO rework for other cloud services -// CloudService service = CloudService.GoogleDrive; - cloudService = "GoogleDrive"; - - // start cloud sync in new thread - Thread thread = new Thread(new Runnable() { - @Override - public void run() { - - if (main.getCloudController().initializeConnection(getCloudService(), getCemuPath())) { - main.getCloudController().sync(getCloudService(), getCemuPath(), main.getDirectory().getPath()); - saveSettings(); - } else { - cloudSyncToggleBtn.setSelected(false); - - // cloud sync init error dialog - JFXInfoAlert cloudSyncErrorDialog = new JFXInfoAlert(cloudSyncErrorHeadingText, - cloudSyncErrorBodyText, dialogBtnStyle, main.getPrimaryStage()); - cloudSyncErrorDialog.showAndWait(); - } - - } - }); - thread.start(); - } - }; - - EventHandler cancelAction = new EventHandler(){ - @Override - public void handle(ActionEvent event){ - cloudSyncToggleBtn.setSelected(false); - } - }; - - JFXOkayCancelDialog cloudSyncWarningDialog = new JFXOkayCancelDialog(cloudSyncWaringHeadingText, - cloudSyncWaringBodyText, dialogBtnStyle, 419, 140, okayAction, cancelAction, main.getPane(), - bundle); - cloudSyncWarningDialog.show(); - } - } - - @FXML - private void colorPickerAction() { - editColor(colorPicker.getValue().toString()); - applyColor(); - } - - @FXML - private void addBtnAction() { - String headingText = addGameBtnHeadingText; - String bodyText = addGameBtnBodyText; - JFXEditGameDialog addGameDialog = new JFXEditGameDialog(headingText, bodyText, dialogBtnStyle, 450, 300, 0, - this, main.getPrimaryStage(), main.getPane()); - addGameDialog.show(); - } - - /** - * process the returning data from the addGame dialog - * and add them to the database and the UI - */ - public void addBtnReturn(String title, String coverPath, String romPath, String titleID) { - /** - * if one parameter 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.length() == 0 || coverPath.length() == 0 || title.length() == 0 || titleID.length() == 0) { - LOGGER.info("No parameter set!"); - - //addGame error dialog - JFXInfoAlert errorDialog = new JFXInfoAlert(addBtnReturnErrorHeadingText, addBtnReturnErrorBodyText, - dialogBtnStyle, main.getPrimaryStage()); - errorDialog.showAndWait(); - - } else { - File pictureCache = main.getPictureCache(); - String coverName = new File(coverPath).getName(); - try { - 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); - coverPath = pictureCache + "/" + coverName; - ImageIO.write(resizeImagePNG, "png", new File(coverPath)); //save image to pictureCache - } catch (IOException e) { - LOGGER.error("Ops something went wrong! Error while resizing cover.", e); - } - - try { - dbController.addGame(title, coverPath, romPath, titleID, "", "", "", "0"); - dbController.loadSingleGame(titleID); - if (menuTrue) { - sideMenuSlideOut(); - burgerTask.setRate(-1.0); - burgerTask.play(); - menuTrue = false; - } - refreshUIData(); - } catch (SQLException e) { - LOGGER.error("Oops, something went wrong! Error while adding a game.", e); - } - } - } - - public void editBtnReturn(String title, String coverPath, String romPath, String titleID) { - dbController.setGameInfo(title, coverPath, romPath, titleID); - games.remove(selectedUIDataIndex); - dbController.loadSingleGame(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) - * @param title : game title - * @param coverPath : path to cover (cache) - * @param romPath : path to ROM file (.rpx) - * @param titleID : game ID - */ - public void addGame(String title, String coverPath, String romPath, String titleID){ - VBox VBox = new VBox(); - Label gameTitleLabel = new Label(); - JFXButton gameBtn = new JFXButton(); - ImageView imageView = new ImageView(); - Image coverImage = new Image(new File(coverPath).toURI().toString()); - - generatePosition(); - - UIROMDataType uiROMElement = new UIROMDataType(VBox, gameTitleLabel, gameBtn, imageView, titleID, romPath); - - uiROMElement.getLabel().setText(title); - uiROMElement.getLabel().setMaxWidth(200); - uiROMElement.getLabel().setPadding(new Insets(0,0,0,8)); - uiROMElement.getLabel().setFont(Font.font("System", FontWeight.BOLD, 14)); - - // i think we can do this locally and remove the imageView from the data type since it's used as graphic - uiROMElement.getImageView().setImage(coverImage); - uiROMElement.getImageView().setFitHeight(300); - uiROMElement.getImageView().setFitWidth(200); - - uiROMElement.getButton().setGraphic(uiROMElement.getImageView()); - uiROMElement.getButton().setContextMenu(gameContextMenu); - uiROMElement.getButton().setStyle("-fx-effect: dropshadow(three-pass-box, rgba(0,0,0,0.8), 10, 0, 0, 3); "); - uiROMElement.getButton().addEventHandler(MouseEvent.MOUSE_CLICKED, new EventHandler() { - @Override - public void handle(MouseEvent event) { - LOGGER.info("selected: " + title + "; ID: " + titleID); - // getting the selected game index by comparing event.getSource() with games.get(i).getButton() - for (int i = 0; i < games.size(); i++) { - if (games.get(i).getButton() == event.getSource()) { - selectedUIDataIndex = i; - } - } - - gameExecutePath = romPath; - selectedGameTitleID = titleID; - selectedGameTitle = title; - - // underlining selected Label - lastGameLabel.setStyle("-fx-underline: false;"); - games.get(selectedUIDataIndex).getLabel().setStyle("-fx-underline: true;"); - lastGameLabel = games.get(selectedUIDataIndex).getLabel(); - - // setting last played, if lastPlayed is empty game was never played before, else set correct date - if (dbController.getLastPlayed(titleID).equals("") || dbController.getLastPlayed(titleID).equals(null)) { - lastTimePlayedBtn.setText(lastPlayed + never); - totalPlaytimeBtn.setText(dbController.getTotalPlaytime(titleID) + " min"); - } else { - DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd"); - - int tToday = Integer.parseInt(dtf.format(LocalDate.now()).replaceAll("-", "")); - int tYesterday = Integer.parseInt(dtf.format(LocalDate.now().minusDays(1)).replaceAll("-", "")); - int tLastPlayedDay = Integer.parseInt(dbController.getLastPlayed(titleID).replaceAll("-", "")); - - if (tLastPlayedDay == tToday) { - lastTimePlayedBtn.setText(lastPlayed + today); - } else if (tLastPlayedDay == tYesterday) { - lastTimePlayedBtn.setText(lastPlayed + yesterday); - } else { - lastTimePlayedBtn.setText(lastPlayed + dbController.getLastPlayed(titleID)); - } - } - - /** - * setting total playtime, if total playtime > 60 minutes, format is "x hours x - * minutes" (x h x min), else only minutes are showed - */ - if (Integer.parseInt(dbController.getTotalPlaytime(titleID)) > 60) { - int hoursPlayed = (int) Math.floor(Integer.parseInt(dbController.getTotalPlaytime(titleID)) / 60); - int minutesPlayed = Integer.parseInt(dbController.getTotalPlaytime(titleID)) - 60 * hoursPlayed; - totalPlaytimeBtn.setText(hoursPlayed + " h " + minutesPlayed + " min"); - } else { - totalPlaytimeBtn.setText(dbController.getTotalPlaytime(titleID) + " min"); - } - - if (!playTrue) { - playBtnSlideIn(); - } - if (menuTrue) { - sideMenuSlideOut(); - burgerTask.setRate(-1.0); - burgerTask.play(); - menuTrue = false; - } - - } - }); - - uiROMElement.getVBox().setLayoutX(getxPos()); - uiROMElement.getVBox().setLayoutY(getyPos()); - uiROMElement.getVBox().getChildren().addAll(gameTitleLabel,gameBtn); - - // add uiROMElement to games list - games.add(uiROMElement); - } - - /** - * reload all ROMs from the ROM directory - */ - public void reloadRoms() { - JFXSpinner spinner = new JFXSpinner(); - spinner.setPrefSize(30, 30); - 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(); - } - - //remove all games from gamesAnchorPane and add them afterwards - public void refreshUIData() { - //remove all games form gamesAnchorPane - gamesAnchorPane.getChildren().removeAll(gamesAnchorPane.getChildren()); - - //reset position - xPos = -200; - yPos = 17; - xPosHelper = 0; - - //add all games to gamesAnchorPane (UI) - for(int i=0; i< games.size(); i++){ - generatePosition(); - games.get(i).getVBox().setLayoutX(getxPos()); - games.get(i).getVBox().setLayoutY(getyPos()); - gamesAnchorPane.getChildren().add(games.get(i).getVBox()); - } - } - - // set the selected local strings to all needed elements - void setUILanguage(){ - switch(getLanguage()){ - case "en_US": - bundle = ResourceBundle.getBundle("locals.cemu_UI-Local", Locale.US); //us_English - languageChoisBox.getSelectionModel().select(0); - break; - case "de_DE": - bundle = ResourceBundle.getBundle("locals.cemu_UI-Local", Locale.GERMAN); //German - languageChoisBox.getSelectionModel().select(1); - break; - default: - bundle = ResourceBundle.getBundle("locals.cemu_UI-Local", Locale.US); //default local - languageChoisBox.getSelectionModel().select(0); - break; - } - - // Buttons - aboutBtn.setText(bundle.getString("aboutBtn")); - settingsBtn.setText(bundle.getString("settingsBtn")); - addBtn.setText(bundle.getString("addBtn")); - reloadRomsBtn.setText(bundle.getString("reloadRomsBtn")); - smmdbBtn.setText(bundle.getString("smmdbBtn")); - cemuTFBtn.setText(bundle.getString("cemuTFBtn")); - romTFBtn.setText(bundle.getString("romTFBtn")); - updateBtn.setText(bundle.getString("updateBtnCheckNow")); - smmdbDownloadBtn.setText(bundle.getString("smmdbDownloadBtn")); - playBtn.setText(bundle.getString("playBtn")); - cloudSyncToggleBtn.setText(bundle.getString("cloudSyncToggleBtn")); - autoUpdateToggleBtn.setText(bundle.getString("autoUpdateToggleBtn")); - fullscreenToggleBtn.setText(bundle.getString("fullscreenToggleBtn")); - - // Labels - cemu_UISettingsLbl.setText(bundle.getString("cemu_UISettingsLbl")); - cemuDirectoryLbl.setText(bundle.getString("cemuDirectoryLbl")); - romDirectoryLbl.setText(bundle.getString("romDirectoryLbl")); - mainColorLbl.setText(bundle.getString("mainColorLbl")); - languageLbl.setText(bundle.getString("languageLbl")); - updateLbl.setText(bundle.getString("updateLbl")); - branchLbl.setText(bundle.getString("branchLbl")); - cemuSettingsLbl.setText(bundle.getString("cemuSettingsLbl")); - licensesLbl.setText(bundle.getString("licensesLbl")); - - // Columns - titleColumn.setText(bundle.getString("titleColumn")); - idColumn.setText(bundle.getString("idColumn")); - starsColumn.setText(bundle.getString("starsColumn")); - timeColumn.setText(bundle.getString("timeColumn")); - - // Strings - editHeadingText = bundle.getString("editHeadingText"); - editBodyText = bundle.getString("editBodyText"); - removeHeadingText = bundle.getString("removeHeadingText"); - removeBodyText = bundle.getString("removeBodyText"); - addUpdateHeadingText = bundle.getString("addUpdateHeadingText"); - addUpdateBodyText = bundle.getString("addUpdateBodyText"); - addDLCHeadingText = bundle.getString("addDLCHeadingText"); - addDLCBodyText = bundle.getString("addDLCBodyText"); - licensesLblHeadingText = bundle.getString("licensesLblHeadingText"); - licensesLblBodyText = bundle.getString("licensesLblBodyText"); - showLicenses = bundle.getString("showLicenses"); - aboutBtnHeadingText = bundle.getString("aboutBtnHeadingText"); - aboutBtnBodyText = bundle.getString("aboutBtnBodyText"); - cloudSyncWaringHeadingText = bundle.getString("cloudSyncWaringHeadingText"); - cloudSyncWaringBodyText = bundle.getString("cloudSyncWaringBodyText"); - cloudSyncErrorHeadingText = bundle.getString("cloudSyncErrorHeadingText"); - cloudSyncErrorBodyText = bundle.getString("cloudSyncErrorBodyText"); - addGameBtnHeadingText = bundle.getString("addGameBtnHeadingText"); - addGameBtnBodyText = bundle.getString("addGameBtnBodyText"); - addBtnReturnErrorHeadingText = bundle.getString("addBtnReturnErrorHeadingText"); - addBtnReturnErrorBodyText = bundle.getString("addBtnReturnErrorBodyText"); - lastPlayed = bundle.getString("lastPlayed"); - today = bundle.getString("today"); - yesterday = bundle.getString("yesterday"); - never = bundle.getString("never"); - - playBtnPlay = bundle.getString("playBtnPlay"); - playBtnUpdating = bundle.getString("playBtnUpdating"); - playBtnCopyingFiles = bundle.getString("playBtnCopyingFiles"); - smmdbDownloadBtnLoading = bundle.getString("smmdbDownloadBtnLoading"); - smmdbDownloadBtnDownload = bundle.getString("smmdbDownloadBtnDownload"); - } - - // if AutoUpdate, then check for updates - private void checkAutoUpdate() { - - if (isAutoUpdate()) { - try { - LOGGER.info("AutoUpdate: looking for updates on startup ..."); - updateController = new UpdateController(this, buildNumber, useBeta); - Thread updateThread = new Thread(updateController); - updateThread.setName("Updater"); - updateThread.start(); - updateThread.join(); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - } - - private void addCourseDescription(SmmdbApiDataType course) { - String courseTheme; - String gameStyle; - String difficulty; - String autoscroll; - smmdbTextFlow.getChildren().remove(0, smmdbTextFlow.getChildren().size()); - nameText.clear(); - courseText.clear(); - - switch (course.getCourseTheme()) { - case 0: - courseTheme = "Ground"; - break; - case 1: - courseTheme = "Underground"; - break; - case 2: - courseTheme = "Castle"; - break; - case 3: - courseTheme = "Airship"; - break; - case 4: - courseTheme = "Underwater"; - break; - case 5: - courseTheme = "Ghost House"; - break; - default: - courseTheme = "notset"; - break; - } - - switch (course.getGameStyle()) { - case 0: - gameStyle = "SMB"; - break; - case 1: - gameStyle = "SMB3"; - break; - case 2: - gameStyle = "SMW"; - break; - case 3: - gameStyle = "NSMBU"; - break; - default: - gameStyle = "notset"; - break; - } - - switch (course.getDifficulty()) { - case 0: - difficulty = "Easy"; - break; - case 1: - difficulty = "Normal"; - break; - case 2: - difficulty = "Expert"; - break; - case 3: - difficulty = "Super Expert"; - break; - case 4: - difficulty = "Mixed"; - break; - default: - difficulty = "notset"; - break; - } - - switch (course.getAutoScroll()) { - case 0: - autoscroll = "disabled"; - break; - case 1: - autoscroll = "slow"; - break; - case 2: - autoscroll = "medium"; - break; - case 3: - autoscroll = "fast"; - break; - default: - autoscroll = "notset"; - break; - } - - nameText.add(0, new Text("title" + ": ")); - nameText.add(1, new Text("owner" + ": ")); - nameText.add(2, new Text("Course-Theme" + ": ")); - nameText.add(3, new Text("Game-Style" + ": ")); - nameText.add(4, new Text("difficulty" + ": ")); - nameText.add(5, new Text("Auto-Scroll" + ": ")); - nameText.add(6, new Text("Time" + ": ")); - nameText.add(7, new Text("lastmodified" + ": ")); - nameText.add(8, new Text("uploaded" + ": ")); - nameText.add(9, new Text("nintendoid" + ": ")); - - courseText.add(0, new Text(course.getTitle() + "\n")); - courseText.add(1, new Text(course.getOwner() + "\n")); - courseText.add(2, new Text(courseTheme + "\n")); - courseText.add(3, new Text(gameStyle + "\n")); - courseText.add(4, new Text(difficulty + "\n")); - courseText.add(5, new Text(autoscroll + "\n")); - courseText.add(6, new Text(course.getTime() + "\n")); - courseText.add(7, new Text(new java.util.Date((long) course.getLastmodified() * 1000) + "\n")); - courseText.add(8, new Text(new java.util.Date((long) course.getUploaded() * 1000) + "\n")); - courseText.add(9, new Text(course.getNintendoid() + "\n")); - - for (int i = 0; i < nameText.size(); i++) { - nameText.get(i).setFont(Font.font("System", FontWeight.BOLD, 14)); - courseText.get(i).setFont(Font.font("System", 14)); - smmdbTextFlow.getChildren().addAll(nameText.get(i), courseText.get(i)); - } - - } - - /** - * xPosHelper based on window width = -24(Windows)/-36(Linux) - * calculates how many games can be displayed in one row - */ - private void generatePosition() { - int xPosHelperMax = (int) Math.floor((mainAnchorPane.getWidth() - 36) / 217); - - if(xPosHelper == xPosHelperMax){ - oldXPosHelper = xPosHelper; - xPos = 17; - yPos = yPos + 345; - xPosHelper = 1; - }else{ - xPos = xPos + 217; - xPosHelper++; - } - } - - // change the color of all needed GUI elements - private void applyColor() { - String boxStyle = "-fx-background-color: #"+getColor()+";"; - String btnStyleBlack = "-fx-button-type: RAISED; -fx-background-color: #"+getColor()+"; -fx-text-fill: BLACK;"; - String btnStyleWhite = "-fx-button-type: RAISED; -fx-background-color: #"+getColor()+"; -fx-text-fill: WHITE;"; - BigInteger icolor = new BigInteger(getColor(),16); - BigInteger ccolor = new BigInteger("78909cff",16); - - sideMenuVBox.setStyle(boxStyle); - topHBox.setStyle(boxStyle); - cemuTextField.setFocusColor(Color.valueOf(getColor())); - romTextField.setFocusColor(Color.valueOf(getColor())); - - if (icolor.compareTo(ccolor) == -1) { - dialogBtnStyle = btnStyleWhite; - - aboutBtn.setStyle("-fx-text-fill: WHITE;"); - settingsBtn.setStyle("-fx-text-fill: WHITE;"); - addBtn.setStyle("-fx-text-fill: WHITE;"); - reloadRomsBtn.setStyle("-fx-text-fill: WHITE;"); - smmdbBtn.setStyle("-fx-text-fill: WHITE;"); - playBtn.setStyle("-fx-text-fill: WHITE; -fx-font-family: Roboto Medium;"); - cemuTFBtn.setStyle(btnStyleWhite); - romTFBtn.setStyle(btnStyleWhite); - updateBtn.setStyle(btnStyleWhite); - smmdbDownloadBtn.setStyle(btnStyleWhite); - playBtn.setStyle(btnStyleWhite); - - aboutBtn.setGraphic(info_white); - settingsBtn.setGraphic(settings_white); - addBtn.setGraphic(add_circle_white); - reloadRomsBtn.setGraphic(cached_white); - smmdbBtn.setGraphic(smmdb_white); - - menuHam.getStyleClass().clear(); - menuHam.getStyleClass().add("jfx-hamburgerW"); - } else { - dialogBtnStyle = btnStyleBlack; - - aboutBtn.setStyle("-fx-text-fill: BLACK;"); - settingsBtn.setStyle("-fx-text-fill: BLACK;"); - addBtn.setStyle("-fx-text-fill: BLACK;"); - reloadRomsBtn.setStyle("-fx-text-fill: BLACK;"); - smmdbBtn.setStyle("-fx-text-fill: BLACK;"); - playBtn.setStyle("-fx-text-fill: BLACK; -fx-font-family: Roboto Medium;"); - cemuTFBtn.setStyle(btnStyleBlack); - romTFBtn.setStyle(btnStyleBlack); - updateBtn.setStyle(btnStyleBlack); - smmdbDownloadBtn.setStyle(btnStyleBlack); - playBtn.setStyle(btnStyleBlack); - - aboutBtn.setGraphic(info_black); - settingsBtn.setGraphic(settings_black); - addBtn.setGraphic(add_circle_black); - reloadRomsBtn.setGraphic(cached_black); - smmdbBtn.setGraphic(smmdb_black); - - menuHam.getStyleClass().clear(); - menuHam.getStyleClass().add("jfx-hamburgerB"); - } - - for (int i = 0; i < games.size(); i++) { - games.get(i).getButton().setRipplerFill(Paint.valueOf(getColor())); - } - } - - /** - * save settings to the config.xml file - */ - public void saveSettings() { - LOGGER.info("saving Settings ..."); - - try { - props.setProperty("cemuPath", getCemuPath()); - props.setProperty("romPath", getRomDirectoryPath()); - props.setProperty("color", getColor()); - props.setProperty("language", getLanguage()); - props.setProperty("fullscreen", String.valueOf(isFullscreen())); - props.setProperty("cloudSync", String.valueOf(isCloudSync())); - props.setProperty("autoUpdate", String.valueOf(isAutoUpdate())); - props.setProperty("useBeta", String.valueOf(isUseBeta())); - if (getCloudService() == null) { - props.setProperty("cloudService", ""); - } else { - props.setProperty("cloudService", getCloudService()); - } - props.setProperty("folderID", main.getCloudController().getFolderID(getCloudService())); - props.setProperty("lastLocalSync", String.valueOf(getLastLocalSync())); - props.setProperty("windowWidth", String.valueOf(mainAnchorPane.getWidth())); - props.setProperty("windowHeight", String.valueOf(mainAnchorPane.getHeight())); - - OutputStream outputStream = new FileOutputStream(main.getConfigFile()); // new output-stream - props.storeToXML(outputStream, "cemu_UI settings"); // write new .xml - outputStream.close(); - LOGGER.info("saving Settings done!"); - } catch (IOException e) { - LOGGER.error("an error occured", e); - } - } - - /** - * loading saved settings from the config.xml file - * if a value is not present, default is used instead - */ - private void loadSettings() { - LOGGER.info("loading settings ..."); - try { - InputStream inputStream = new FileInputStream(main.getConfigFile()); - props.loadFromXML(inputStream); // new input-stream from .xml - - try { - setCemuPath(props.getProperty("cemuPath")); - } catch (Exception e) { - LOGGER.error("cloud not load cemuPath", e); - setCemuPath(""); - } - - try { - setRomDirectoryPath(props.getProperty("romPath")); - } catch (Exception e) { - LOGGER.error("could not load romPath", e); - setRomDirectoryPath(""); - } - - try { - setColor(props.getProperty("color")); - } catch (Exception e) { - LOGGER.error("could not load color value, setting default instead", e); - setColor("00a8cc"); - } - - if (props.getProperty("language") == null) { - LOGGER.error("cloud not load language, setting default instead"); - setLanguage("en_US"); - } else { - setLanguage(props.getProperty("language")); - } - - try { - setFullscreen(Boolean.parseBoolean(props.getProperty("fullscreen"))); - } catch (Exception e) { - LOGGER.error("could not load fullscreen, setting default instead", e); - setFullscreen(false); - } - - try { - setCloudSync(Boolean.parseBoolean(props.getProperty("cloudSync"))); - } catch (Exception e) { - LOGGER.error("could not load cloudSync, setting default instead", e); - setCloudSync(false); - } - - try { - setAutoUpdate(Boolean.parseBoolean(props.getProperty("autoUpdate"))); - } catch (Exception e) { - LOGGER.error("cloud not load autoUpdate", e); - setAutoUpdate(false); - } - - try { - setUseBeta(Boolean.parseBoolean(props.getProperty("useBeta"))); - } catch (Exception e) { - LOGGER.error("cloud not load autoUpdate", e); - setUseBeta(false); - } - - try { - setCloudService(props.getProperty("cloudService")); - } catch (Exception e) { - LOGGER.error("could not load cloudSync", e); - setCloudService(""); - } - - try { - main.getCloudController().setFolderID(props.getProperty("folderID"), getCloudService()); - } catch (Exception e) { - LOGGER.error("could not load folderID, disable cloud sync. Please contact an developer", e); - setCloudSync(false); - } - - try { - setLastLocalSync(Long.parseLong(props.getProperty("lastLocalSync"))); - } catch (Exception e) { - LOGGER.error("could not load lastSuccessSync, setting default instead", e); - setLastLocalSync(0); - } - - try { - setWindowWidth(Double.parseDouble(props.getProperty("windowWidth"))); - } catch (Exception e) { - LOGGER.error("could not load windowWidth, setting default instead", e); - setWindowWidth(904); - } - - try { - setWindowHeight(Double.parseDouble(props.getProperty("windowHeight"))); - } catch (Exception e) { - LOGGER.error("could not load windowHeight, setting default instead", e); - setWindowHeight(600); - } - - inputStream.close(); - LOGGER.info("loading settings done!"); - } catch (IOException e) { - LOGGER.error("an error occured", e); - } - } - - private void sideMenuSlideIn(){ - sideMenuVBox.setVisible(true); - //slide in in 400ms - TranslateTransition translateTransition = new TranslateTransition(Duration.millis(400), sideMenuVBox); - translateTransition.setFromX(-175); - translateTransition.setToX(0); - translateTransition.play(); - } - - private void sideMenuSlideOut(){ - //slide out in 400ms - TranslateTransition translateTransition = new TranslateTransition(Duration.millis(400), sideMenuVBox); - translateTransition.setFromX(0); - translateTransition.setToX(-175); - translateTransition.play(); - } - - private void playBtnSlideIn(){ - bottomHBox.setVisible(true); - playTrue = true; - - TranslateTransition playBtnTransition = new TranslateTransition(Duration.millis(300), bottomHBox); - playBtnTransition.setFromY(56); - playBtnTransition.setToY(0); - playBtnTransition.play(); - } - - private void playBtnSlideOut(){ - playTrue = false; - TranslateTransition playBtnTransition = new TranslateTransition(Duration.millis(300), bottomHBox); - playBtnTransition.setFromY(0); - playBtnTransition.setToY(56); - playBtnTransition.play(); - } - - private void editColor(String input){ - StringBuilder sb = new StringBuilder(input); - sb.delete(0, 2); - this.color = sb.toString(); - saveSettings(); - } - - @SuppressWarnings("unused") - /** - * @return the main color in hexadecimal format - */ - private String hexToRgb() { - LOGGER.info(getColor()); - int hex = Integer.parseInt(getColor().substring(0, 5), 16); - - int r = (hex & 0xFF0000) >> 16; - int g = (hex & 0xFF00) >> 8; - int b = (hex & 0xFF); - - return r + ", " + g + ", " + b; - } - - /** - * - * @param originalImage original image which size is changed - * @param type type of the original image (PNG,JPEG,...) - * @param imgWidth wanted width - * @param imgHeigth wanted height - * @return the rezised image - */ - private static BufferedImage resizeImage(BufferedImage originalImage, int type, int imgWidth, int imgHeigth) { - BufferedImage resizedImage = new BufferedImage(imgWidth, imgHeigth, type); - Graphics2D g = resizedImage.createGraphics(); - g.drawImage(originalImage, 0, 0, imgWidth, imgHeigth, null); - g.dispose(); - - return resizedImage; - } - - public Main getMain() { - return main; - } - - public DBController getDbController() { - return dbController; - } - - public void setMainAnchorPane(AnchorPane mainAnchorPane) { - this.mainAnchorPane = mainAnchorPane; - } - - public String getCemuPath() { - return cemuPath; - } - - public void setCemuPath(String cemuPath) { - this.cemuPath = cemuPath; - } - - public String getRomDirectoryPath() { - return romDirectoryPath; - } - - public void setRomDirectoryPath(String romDirectoryPath) { - this.romDirectoryPath = romDirectoryPath; - } - - public String getColor() { - return color; - } - - public void setColor(String color) { - this.color = color; - } - - public int getxPos() { - return xPos; - } - - public void setxPos(int xPos) { - this.xPos = xPos; - } - - public int getyPos() { - return yPos; - } - - public void setyPos(int yPos) { - this.yPos = yPos; - } - - public int getxPosHelper() { - return xPosHelper; - } - - public void setxPosHelper(int xPosHelper) { - this.xPosHelper = xPosHelper; - } - - public long getLastLocalSync() { - return lastLocalSync; - } - - public void setLastLocalSync(long lastLocalSync) { - this.lastLocalSync = lastLocalSync; - } - - public boolean isFullscreen() { - return fullscreen; - } - - public void setFullscreen(boolean fullscreen) { - this.fullscreen = fullscreen; - } - - public boolean isCloudSync() { - return cloudSync; - } - - public void setCloudSync(boolean cloudSync) { - this.cloudSync = cloudSync; - } - - public boolean isAutoUpdate() { - return autoUpdate; - } - - public void setAutoUpdate(boolean autoUpdate) { - this.autoUpdate = autoUpdate; - } - - public boolean isUseBeta() { - return useBeta; - } - - public void setUseBeta(boolean useBeta) { - this.useBeta = useBeta; - } - - public String getGameExecutePath() { - return gameExecutePath; - } - - public void setGameExecutePath(String gameExecutePath) { - this.gameExecutePath = gameExecutePath; - } - - public String getSelectedGameTitleID() { - return selectedGameTitleID; - } - - public void setSelectedGameTitleID(String selectedGameTitleID) { - this.selectedGameTitleID = selectedGameTitleID; - } - - public String getCloudService() { - return cloudService; - } - - public void setCloudService(String cloudService) { - this.cloudService = cloudService; - } - - public JFXButton getPlayBtn() { - return playBtn; - } - - public void setPlayBtn(JFXButton playBtn) { - this.playBtn = playBtn; - } - - public double getWindowWidth() { - return windowWidth; - } - - public void setWindowWidth(double windowWidth) { - this.windowWidth = windowWidth; - } - - public double getWindowHeight() { - return windowHeight; - } - - public void setWindowHeight(double windowHeight) { - this.windowHeight = windowHeight; - } - - public int getOldXPosHelper() { - return oldXPosHelper; - } - - public void setOldXPosHelper(int oldXPosHelper) { - this.oldXPosHelper = oldXPosHelper; - } - - public String getLanguage() { - return language; - } - - public void setLanguage(String language) { - this.language = language; - } - - public ResourceBundle getBundle() { - return bundle; - } - - public void setBundle(ResourceBundle bundle) { - this.bundle = bundle; - } - - public AnchorPane getMainAnchorPane() { - return mainAnchorPane; - } - - public JFXButton getUpdateBtn() { - return updateBtn; - } - -} diff --git a/src/main/java/com/cemu_UI/application/playGame.java b/src/main/java/com/cemu_UI/application/playGame.java deleted file mode 100644 index 651504a..0000000 --- a/src/main/java/com/cemu_UI/application/playGame.java +++ /dev/null @@ -1,103 +0,0 @@ -/** - * cemu_UI - * - * Copyright 2017-2018 <@Seil0> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301, USA. - */ -package com.cemu_UI.application; - -import java.io.IOException; -import java.time.Instant; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import com.cemu_UI.controller.DBController; - -import javafx.application.Platform; - -public class playGame extends Thread{ - - private MainWindowController mainWindowController; - private DBController dbController; - private static final Logger LOGGER = LogManager.getLogger(playGame.class.getName()); - - public playGame(MainWindowController m, com.cemu_UI.controller.DBController db) { - mainWindowController = m; - dbController = db; - } - - @Override - public void run() { - String selectedGameTitleID = mainWindowController.getSelectedGameTitleID(); - String cemuBin = mainWindowController.getCemuPath() + "/Cemu.exe"; - String gameExec = "\"" + mainWindowController.getGameExecutePath() + "\""; - long startTime; - long endTime; - int timePlayedNow; - int timePlayed; - Process p; - - Platform.runLater(() -> { - mainWindowController.getMain().getPrimaryStage().setIconified(true); // minimize cemu_UI - }); - startTime = System.currentTimeMillis(); - try { - if (System.getProperty("os.name").equals("Linux")) { - if(mainWindowController.isFullscreen()){ - p = new ProcessBuilder("wine", cemuBin, "-f", "-g", gameExec).start(); - } else { - p = new ProcessBuilder("wine", cemuBin, "-g", gameExec).start(); - } - } else { - if(mainWindowController.isFullscreen()){ - p = new ProcessBuilder(cemuBin, "-f", "-g", gameExec).start(); - } else { - p = new ProcessBuilder(cemuBin, "-g", gameExec).start(); - } - } - - p.waitFor(); // wait until cemu is closed so we can calculate the played time - endTime = System.currentTimeMillis(); - timePlayedNow = (int) Math.floor(((endTime - startTime)/1000/60)); - timePlayed = Integer.parseInt(dbController.getTotalPlaytime(selectedGameTitleID))+timePlayedNow; - - dbController.setTotalPlaytime(Integer.toString(timePlayed), selectedGameTitleID); - Platform.runLater(() -> { - if (Integer.parseInt(dbController.getTotalPlaytime(selectedGameTitleID)) > 60) { - int hoursPlayed = (int) Math.floor(Integer.parseInt(dbController.getTotalPlaytime(selectedGameTitleID)) / 60); - int minutesPlayed = Integer.parseInt(dbController.getTotalPlaytime(selectedGameTitleID)) - 60 * hoursPlayed; - mainWindowController.totalPlaytimeBtn.setText(hoursPlayed + "h " + minutesPlayed + "min"); - } else { - mainWindowController.totalPlaytimeBtn.setText(dbController.getTotalPlaytime(selectedGameTitleID) + " min"); - } - mainWindowController.getMain().getPrimaryStage().setIconified(false); // maximize cemu_UI - }); - - //sync savegame with cloud service - if (mainWindowController.isCloudSync()) { - mainWindowController.setLastLocalSync(Instant.now().getEpochSecond()); - mainWindowController.getMain().getCloudController().sync(mainWindowController.getCloudService(), - mainWindowController.getCemuPath(), mainWindowController.getMain().getDirectory().getPath()); - } - - } catch (IOException | InterruptedException e) { - LOGGER.error(e); - } - } - -} diff --git a/src/main/java/com/cemu_UI/controller/CloudController.java b/src/main/java/com/cemu_UI/controller/CloudController.java deleted file mode 100644 index 6e3f385..0000000 --- a/src/main/java/com/cemu_UI/controller/CloudController.java +++ /dev/null @@ -1,226 +0,0 @@ -/** - * cemu_UI - * - * Copyright 2017-2018 <@Seil0> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301, USA. - */ -package com.cemu_UI.controller; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.time.Instant; -import java.util.zip.ZipEntry; -import java.util.zip.ZipOutputStream; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import com.cemu_UI.application.MainWindowController; -import com.cemu_UI.vendorCloudController.GoogleDriveController; - -import javafx.application.Platform; -import net.lingala.zip4j.core.ZipFile; -import net.lingala.zip4j.exception.ZipException; - -public class CloudController { - - public CloudController(MainWindowController mwc) { - this.mwc = mwc; - } - - private MainWindowController mwc; - private GoogleDriveController googleDriveController = new GoogleDriveController(); - private static final Logger LOGGER = LogManager.getLogger(CloudController.class.getName()); - - public boolean initializeConnection(String cloudService, String cemuDirectory) { - boolean success = false; - LOGGER.info("sartting cloud initialisation ..."); - - if(cloudService.equals("GoogleDrive")) { - LOGGER.info("selected service is Google Drive"); - try { - googleDriveController.main(cemuDirectory); - } catch (IOException e) { - LOGGER.error("error while initialize connection", e); - return success; - } - success = true; - } - - if(cloudService.equals("Dropbox")) { - LOGGER.info("selected service is Dropbox"); - } - LOGGER.info("cloud initialisation done!"); - return success; - } - - /** - * to trigger a new sync set the mwc LastLocalSync to the actual time and call the sync method - * @param cloudService - * @param cemuDirectory - * @param cemu_UIDirectory - */ - public void sync(String cloudService, String cemuDirectory, String cemu_UIDirectory) { - - // running sync in a new thread, instead of blocking the main thread - Thread thread = new Thread(new Runnable() { - @Override - public void run() { - try { - Platform.runLater(() -> { - mwc.getPlayBtn().setDisable(true); - mwc.getPlayBtn().setText("syncing..."); - }); - LOGGER.info("starting synchronization in new thread ..."); - - // zip the saves folder - File zipFile = zipSavegames(cemu_UIDirectory, cemuDirectory); - - // upload the zip - switch (cloudService) { - - // use GoogleDriveController - case "GoogleDrive": - LOGGER.info("using GoogleDriveController"); - long lastCloudSync = googleDriveController.getLastCloudSync(); - - if (!googleDriveController.checkFolder()) { - LOGGER.info("cloud sync folder dosen't exist, creating one!"); - googleDriveController.creatFolder(); - googleDriveController.uploadZipFile(zipFile); - } else if (mwc.getLastLocalSync() > lastCloudSync) { - LOGGER.info("local is new, going to upload zip"); - googleDriveController.uploadZipFile(zipFile); - } else if(mwc.getLastLocalSync() < lastCloudSync) { - LOGGER.info("cloud is new, going to download zip"); - unzipSavegames(cemuDirectory, googleDriveController.downloadZipFile(cemu_UIDirectory)); - mwc.setLastLocalSync(lastCloudSync); - break; - } else { - LOGGER.info("nothing to do"); - break; - } - mwc.setLastLocalSync(Long.parseLong(zipFile.getName().substring(0, zipFile.getName().length()-4))); // set time of last sucessfull sync - break; - - - - case "Dropbox": - - break; - - - default: - LOGGER.warn("no cloud vendor found!"); - break; - } - - zipFile.delete(); // delete zipfile in cem_UI directory - - Platform.runLater(() -> { - mwc.getPlayBtn().setText("play"); - mwc.getPlayBtn().setDisable(false); - mwc.saveSettings(); - }); - - - LOGGER.info("synchronization successful!"); - } catch (Exception e) { - LOGGER.error("There was an error during syncronisation! Please open a new issue on the cemu_UI github page:", e); - } - } - }); - thread.start(); - } - - private File zipSavegames(String cemu_UIDirectory, String cemuDirectory) throws Exception { - long unixTimestamp = Instant.now().getEpochSecond(); - FileOutputStream fos = new FileOutputStream(cemu_UIDirectory + "/" + unixTimestamp + ".zip"); - ZipOutputStream zos = new ZipOutputStream(fos); - addDirToZipArchive(zos, new File(cemuDirectory + "/mlc01/usr/save"), null); - zos.flush(); - fos.flush(); - zos.close(); - fos.close(); - return new File(cemu_UIDirectory + "/" + unixTimestamp + ".zip"); - } - - private static void addDirToZipArchive(ZipOutputStream zos, File fileToZip, String parrentDirectoryName) throws Exception { - if (fileToZip == null || !fileToZip.exists()) { - return; - } - - String zipEntryName = fileToZip.getName(); - if (parrentDirectoryName!=null && !parrentDirectoryName.isEmpty()) { - zipEntryName = parrentDirectoryName + "/" + fileToZip.getName(); - } - - if (fileToZip.isDirectory()) { - for (File file : fileToZip.listFiles()) { - addDirToZipArchive(zos, file, zipEntryName); - } - } else { - byte[] buffer = new byte[1024]; - FileInputStream fis = new FileInputStream(fileToZip); - zos.putNextEntry(new ZipEntry(zipEntryName)); - int length; - while ((length = fis.read(buffer)) > 0) { - zos.write(buffer, 0, length); - } - zos.closeEntry(); - fis.close(); - } - } - - private void unzipSavegames(String cemuDirectory, File outputFile) { - try { - ZipFile zipFile = new ZipFile(outputFile); - zipFile.extractAll(cemuDirectory + "/mlc01/usr"); - outputFile.delete(); - LOGGER.info("unzip successfull"); - } catch (ZipException e) { - LOGGER.error("an error occurred during unziping the file!", e); - } - } - - public String getFolderID(String cloudService) { - String folderID = ""; - if (cloudService != null) { - if (cloudService.equals("GoogleDrive")) { - folderID = googleDriveController.getFolderID(); - } - if (cloudService.equals("Dropbox")) { - - } - } - return folderID; - } - - public void setFolderID(String folderID, String cloudService) { - if (cloudService != null) { - if (cloudService.equals("GoogleDrive")) { - googleDriveController.setFolderID(folderID); - } - if (cloudService.equals("Dropbox")) { - - } - } - } - -} diff --git a/src/main/java/com/cemu_UI/controller/DBController.java b/src/main/java/com/cemu_UI/controller/DBController.java deleted file mode 100644 index e4422c3..0000000 --- a/src/main/java/com/cemu_UI/controller/DBController.java +++ /dev/null @@ -1,378 +0,0 @@ -/** - * cemu_UI - * - * Copyright 2017-2018 <@Seil0> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301, USA. - */ -package com.cemu_UI.controller; - -import java.awt.Graphics2D; -import java.awt.image.BufferedImage; -import java.io.File; -import java.io.IOException; -import java.net.URL; -import java.sql.Connection; -import java.sql.DriverManager; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Statement; -import java.util.ArrayList; -import java.util.List; - -import javax.imageio.ImageIO; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; - -import org.apache.commons.io.FileUtils; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.w3c.dom.Document; -import org.xml.sax.SAXException; - -import com.cemu_UI.application.Main; -import com.cemu_UI.application.MainWindowController; - -public class DBController { - - public DBController(Main main, MainWindowController mainWindowController) { - this.main = main; - this.mainWindowController = mainWindowController; - } - - private Main main; - private MainWindowController mainWindowController; - private ArrayList entries = new ArrayList<>(); - private String DB_PATH_localRoms; - private String DB_PATH_games; - private Connection connection = null; - private Connection connectionGames = null; - private static final Logger LOGGER = LogManager.getLogger(DBController.class.getName()); - - /** - * initialize the sqlite database controller - * load ROM and games database - * load all games - */ - public void init() { - LOGGER.info("<========== starting loading sql ==========>"); - loadRomDatabase(); - loadGamesDatabase(); - createRomDatabase(); - LOGGER.info("<========== finished loading sql ==========>"); - } - - /** - * set the path to the localRoms.db file and initialize the connection - * - * TODO this should be called LocalGames - */ - private void loadRomDatabase() { - if (System.getProperty("os.name").equals("Linux")) { - DB_PATH_localRoms = System.getProperty("user.home") + "/cemu_UI/localRoms.db"; - } else { - DB_PATH_localRoms = System.getProperty("user.home") + "\\Documents\\cemu_UI" + "\\" + "localRoms.db"; - } - try { - // create a database connection - connection = DriverManager.getConnection("jdbc:sqlite:" + DB_PATH_localRoms); - connection.setAutoCommit(false); // AutoCommit to false -> manual commit is active - } catch (SQLException e) { - // if the error message is "out of memory", probably no database file is found - LOGGER.error("error while loading the ROM database", e); - } - LOGGER.info("ROM database loaded successfull"); - } - - /** - * set the path to the localRoms.db file and initialize the connection - * games.db contains a reverence list to for the automatic detection mode - */ - private void loadGamesDatabase() { - DB_PATH_games = main.getReference_gamesFile().getAbsolutePath(); - try { - // create a database connection - connectionGames = DriverManager.getConnection("jdbc:sqlite:" + DB_PATH_games); - connectionGames.setAutoCommit(false); // AutoCommit to false -> manual commit is active - } catch (SQLException e) { - LOGGER.error("error while loading the games database", e); - } - LOGGER.info("games database loaded successfull"); - } - - - /** - * creating the local_roms table in localRoms.db - * if the table has no entries, call loadRomDirectory - * - * TODO the local_roms table should be called local_games - */ - void createRomDatabase() { - try { - Statement stmt = connection.createStatement(); - stmt.executeUpdate("create table if not exists local_roms (title, coverPath, romPath, titleID, productCode, region, lastPlayed, timePlayed)"); - stmt.close(); - connection.commit(); - } catch (SQLException e) { - LOGGER.error("error while creating ROM database", e); - } - - try { - Statement stmt = connection.createStatement(); - ResultSet rs = stmt.executeQuery("SELECT * FROM local_roms"); - while (rs.next()) { - entries.add(rs.getString(2)); - } - stmt.close(); - rs.close(); - } catch (SQLException e) { - LOGGER.error("error while loading ROMs from ROM database, local_roms table", e); - } - if (entries.size() == 0) { - mainWindowController.reloadRoms(); - } else { - loadAllGames(); - mainWindowController.refreshUIData(); - } - } - - // 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+"'," - + "'"+productCode+"','"+region+"','"+lastPlayed+"','"+timePlayed+"')"); - connection.commit(); - stmt.close(); - 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+"'"); - connection.commit(); - stmt.close(); - LOGGER.info("removed \""+titleID+"\" from ROM database"); - } - - //load all ROMs to the mainWindowController - public void loadAllGames(){ - LOGGER.info("loading all games on startup into the mainWindowController ..."); - try { - Statement stmt = connection.createStatement(); - ResultSet rs = stmt.executeQuery("SELECT * FROM local_roms"); - while (rs.next()) { - mainWindowController.addGame(rs.getString(1), rs.getString(2), rs.getString(3), rs.getString(4)); - } - stmt.close(); - rs.close(); - }catch (Exception e){ - LOGGER.error("error while loading all games into the mainWindowController", e); - } - } - - //load a single ROM to the mainWindowController - public void loadSingleGame(String titleID){ - LOGGER.info("loading a single game (ID: "+titleID+") into the mainWindowController ..."); - try { - Statement stmt = connection.createStatement(); - ResultSet rs = stmt.executeQuery("SELECT * FROM local_roms where titleID = '"+titleID+"'"); - while (rs.next()) { - mainWindowController.addGame(rs.getString(1), rs.getString(2), rs.getString(3), rs.getString(4)); - } - stmt.close(); - rs.close(); - }catch (Exception e){ - LOGGER.error("error while loading a single game into the mainWindowController", e); - } - } - - /** - * get all .rpx files from a given directory and add them to the games database if they don't exist there - * @param directory where to search for the .rpx files - */ - public void loadRomDirectory(String directory){ - File dir = new File(directory); - File appFile; - String[] extensions = new String[] { "rpx", "jsp" }; - File pictureCache = main.getPictureCache(); - String coverPath; - try { - Statement stmt = connectionGames.createStatement(); - List files = (List) 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) { - appFile = new File(file.getParent() + "/app.xml"); - DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); - DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); - Document document = documentBuilder.parse(appFile); - String title_ID = document.getElementsByTagName("title_id").item(0).getTextContent(); // get titile_ID from app.xml - title_ID = title_ID.substring(0, 8) + "-" + title_ID.substring(8, title_ID.length()); - LOGGER.info("Name: " + file.getName() + "; Title ID: " + title_ID); - ResultSet rs = stmt.executeQuery("SELECT * FROM games WHERE TitleID = '" + title_ID + "';"); - - // for all elements in the games table check if it's already present, else add it - while (rs.next()) { - if (checkAddEntry(rs.getString(2))) { - LOGGER.info(rs.getString(2) + ": game already in database"); - } else { - LOGGER.info("adding cover to cache ..."); - BufferedImage originalImage = ImageIO.read(new URL(rs.getString(6)));// change path to where file is located - 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 + "/" + rs.getString(3) + ".png")); - coverPath = pictureCache + "/" + rs.getString(3) + ".png"; - LOGGER.info(rs.getString(2) + ": adding ROM"); - addGame(rs.getString(2), coverPath, file.getCanonicalPath(), rs.getString(1), rs.getString(3), - rs.getString(5), "", "0"); - } - } - } - LOGGER.info("<============================= finished loading ROM Directory ============================>"); - } catch (IOException | SQLException | ParserConfigurationException | SAXException e) { - LOGGER.error("error while loading ROMs from directory", e); - } - } - - /** - * check if there is a game with the given name already in the database - * @param title game title - * @return true if the game exists, false if not - * @throws SQLException - */ - private boolean checkAddEntry(String title) throws SQLException{ - Statement stmt = connection.createStatement(); - boolean check = false; - ResultSet rs = stmt.executeQuery("SELECT * FROM local_roms WHERE title = '"+title+"';"); - while (rs.next()) { - check = true; - } - return check; - } - - @SuppressWarnings("unused") - private void checkRemoveEntry() { - /** - * TODO needs to be implemented! - * don't show ROM on the UI, but keep all parameter in case it's showing up again ask if old data should be used - */ - //LOGGER.info("check if entry removed not done yet!"); - } - - private static BufferedImage resizeImage(BufferedImage originalImage, int type, int IMG_WIDTH, int IMG_HEIGHT) { - BufferedImage resizedImage = new BufferedImage(IMG_WIDTH, IMG_HEIGHT, type); - Graphics2D g = resizedImage.createGraphics(); - g.drawImage(originalImage, 0, 0, IMG_WIDTH, IMG_HEIGHT, null); - g.dispose(); - - return resizedImage; - } - - /** - * getting info for a game with titleID - * @param titleID Title-ID of the Game - * @return title, coverPath, romPath, titleID (in this order) - */ - public 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; - } - - public void setGameInfo(String title, String coverPath, String romPath, String titleID){ - 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); - } - } - - public void setLastPlayed(String titleID){ - try{ - Statement stmt = connection.createStatement(); - stmt.executeUpdate("UPDATE local_roms SET lastPlayed=date('now') WHERE titleID = '"+titleID+"';"); - connection.commit(); - stmt.close(); - }catch(SQLException e){ - LOGGER.error("failed to set the last played", e); - } - } - - public String getLastPlayed(String titleID){ - String lastPlayed = null; - try{ - Statement stmt = connection.createStatement(); - ResultSet rs = stmt.executeQuery("SELECT lastPlayed FROM local_roms WHERE titleID = '"+titleID+"';" ); - lastPlayed = rs.getString(1); - stmt.close(); - rs.close(); - }catch(SQLException e){ - LOGGER.error("failed to get the last played", e); - } - return lastPlayed; - } - - public void setTotalPlaytime(String timePlayed, String titleID){ - try{ - Statement stmt = connection.createStatement(); - stmt.executeUpdate("UPDATE local_roms SET timePlayed='"+timePlayed+"' WHERE titleID = '"+titleID+"';"); - connection.commit(); - stmt.close(); - }catch(SQLException e){ - LOGGER.error("failed to set total play time", e); - e.printStackTrace(); - } - } - - public String getTotalPlaytime(String titleID){ - String timePlayed = null; - try{ - Statement stmt = connection.createStatement(); - ResultSet rs = stmt.executeQuery("SELECT timePlayed FROM local_roms WHERE titleID = '"+titleID+"';" ); - timePlayed = rs.getString(1); - stmt.close(); - rs.close(); - }catch(SQLException e){ - LOGGER.error("failed to get total play time", e); - } - return timePlayed; - } - - -} diff --git a/src/main/java/com/cemu_UI/controller/SmmdbAPIController.java b/src/main/java/com/cemu_UI/controller/SmmdbAPIController.java deleted file mode 100644 index d683f83..0000000 --- a/src/main/java/com/cemu_UI/controller/SmmdbAPIController.java +++ /dev/null @@ -1,154 +0,0 @@ -/** - * cemu_UI - * - * Copyright 2017-2018 <@Seil0> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301, USA. - */ -package com.cemu_UI.controller; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.net.URL; -import java.util.ArrayList; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import com.cemu_UI.datatypes.SmmdbApiDataType; -import com.eclipsesource.json.Json; -import com.eclipsesource.json.JsonArray; -import com.eclipsesource.json.JsonValue; - -public class SmmdbAPIController { - - private String URL = "https://smmdb.ddns.net/api/getcourses?format=json"; - private static final Logger LOGGER = LogManager.getLogger(SmmdbAPIController.class.getName()); - - public SmmdbAPIController() { - //Auto-generated constructor stub - } - - /** - * start smmdb api query - * @return a ArryList with all courses found at smmdb - */ - public ArrayList startQuery() { - ArrayList course = new ArrayList<>(); - String output = ""; - - - try { - URL apiUrl = new URL(URL); - BufferedReader ina = new BufferedReader(new InputStreamReader(apiUrl.openStream())); - output = ina.readLine(); - ina.close(); - LOGGER.info("response from " + URL + " was valid"); - LOGGER.info(output); - } catch (IOException e) { - LOGGER.error("error while making api request or reading response"); - LOGGER.error("response from " + URL + " was: " + output, e); - return course; - } - - String apiOutput = "{ \"courses\": " + output + "}"; - JsonArray items = Json.parse(apiOutput).asObject().get("courses").asArray(); - - for (JsonValue item : items) { - int courseTheme, gameStyle, difficulty, lastmodified, uploaded, autoScroll, stars ,time; - String owner, id, nintendoid, title; - - try { - courseTheme = item.asObject().getInt("courseTheme", 9); - } catch (Exception e) { - courseTheme = 9; - } - - try { - gameStyle = item.asObject().getInt("gameStyle", 9); - } catch (Exception e) { - gameStyle = 9; - } - - try { - difficulty = item.asObject().getInt("difficulty", 9); - } catch (Exception e) { - difficulty = 9; - } - - try { - lastmodified = item.asObject().getInt("lastmodified", 9); - } catch (Exception e) { - lastmodified = 9; - } - - try { - uploaded = item.asObject().getInt("uploaded", 9); - } catch (Exception e) { - uploaded = 9; - } - - try { - autoScroll = item.asObject().getInt("autoScroll", 9); - } catch (Exception e) { - autoScroll = 9; - } - - try { - stars = item.asObject().getInt("stars", 9); - } catch (Exception e) { - stars = 9; - } - - try { - time = item.asObject().getInt("time", 9); - } catch (Exception e) { - time = 9; - } - - try { - owner = item.asObject().getString("owner", ""); - } catch (Exception e) { - owner = "notset"; - } - - try { - id = item.asObject().getString("id", ""); - } catch (Exception e) { - id = "notset"; - } - - try { - nintendoid = item.asObject().getString("nintendoid", ""); - } catch (Exception e) { - nintendoid = "notset"; - } - - try { - title = item.asObject().getString("title", "");; - } catch (Exception e) { - title = "notset"; - } - - course.add(new SmmdbApiDataType(courseTheme, gameStyle, difficulty, lastmodified, uploaded, autoScroll, - stars, time, owner, id, nintendoid, title)); - } - - return course; - } - -} diff --git a/src/main/java/com/cemu_UI/controller/UpdateController.java b/src/main/java/com/cemu_UI/controller/UpdateController.java deleted file mode 100644 index 03aed13..0000000 --- a/src/main/java/com/cemu_UI/controller/UpdateController.java +++ /dev/null @@ -1,159 +0,0 @@ -/** - * cemu_UI - * - * Copyright 2017-2018 <@Seil0> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301, USA. - */ -package com.cemu_UI.controller; - -import java.io.BufferedReader; -import java.io.File; -import java.io.IOException; -import java.io.InputStreamReader; -import java.net.HttpURLConnection; -import java.net.URL; - -import javax.swing.ProgressMonitor; -import javax.swing.ProgressMonitorInputStream; - -import org.apache.commons.io.FileUtils; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import com.cemu_UI.application.MainWindowController; -import com.eclipsesource.json.Json; -import com.eclipsesource.json.JsonArray; -import com.eclipsesource.json.JsonObject; -import com.eclipsesource.json.JsonValue; -import javafx.application.Platform; - -public class UpdateController implements Runnable { - - private MainWindowController mainWindowController; - private String buildNumber; - private String apiOutput; - private String updateBuildNumber; // tag_name from Github -// private String updateName; -// private String updateChanges; - private String browserDownloadUrl; // update download link - private String githubApiRelease = "https://api.github.com/repos/Seil0/cemu_UI/releases/latest"; - private String githubApiBeta = "https://api.github.com/repos/Seil0/cemu_UI/releases"; - - private URL githubApiUrl; - private boolean useBeta; - private static final Logger LOGGER = LogManager.getLogger(UpdateController.class.getName()); - - /** - * updater for cemu_UI, checks for Updates and download it - */ - public UpdateController(MainWindowController mwc, String buildNumber, boolean useBeta) { - mainWindowController = mwc; - this.buildNumber = buildNumber; - this.useBeta = useBeta; - } - - @Override - public void run() { - LOGGER.info("beta:" + useBeta + "; checking for updates ..."); - Platform.runLater(() -> { - mainWindowController.getUpdateBtn().setText(mainWindowController.getBundle().getString("updateBtnChecking")); - }); - - try { - - if (useBeta) { - githubApiUrl = new URL(githubApiBeta); - } else { - githubApiUrl = new URL(githubApiRelease); - } - - // URL githubApiUrl = new URL(githubApiRelease); - BufferedReader ina = new BufferedReader(new InputStreamReader(githubApiUrl.openStream())); - apiOutput = ina.readLine(); - ina.close(); - } catch (IOException e) { - Platform.runLater(() -> { - LOGGER.error("could not check update version", e); - }); - } - - if (useBeta) { - JsonArray objectArray = Json.parse("{\"items\": " + apiOutput + "}").asObject().get("items").asArray(); - JsonValue object = objectArray.get(0); - JsonArray objectAssets = object.asObject().get("assets").asArray(); - - updateBuildNumber = object.asObject().getString("tag_name", ""); -// updateName = object.asObject().getString("name", ""); -// updateChanges = object.asObject().getString("body", ""); - - for (JsonValue asset : objectAssets) { - browserDownloadUrl = asset.asObject().getString("browser_download_url", ""); - } - - } else { - JsonObject object = Json.parse(apiOutput).asObject(); - JsonArray objectAssets = Json.parse(apiOutput).asObject().get("assets").asArray(); - - updateBuildNumber = object.getString("tag_name", ""); -// updateName = object.getString("name", ""); -// updateChanges = object.getString("body", ""); - for (JsonValue asset : objectAssets) { - browserDownloadUrl = asset.asObject().getString("browser_download_url", ""); - - } - } - - LOGGER.info("Build: " + buildNumber + ", Update: " + updateBuildNumber); - - // Compares the program BuildNumber with the current BuildNumber if program - // BuildNumber < current BuildNumber then perform a update - int iversion = Integer.parseInt(buildNumber); - int iaktVersion = Integer.parseInt(updateBuildNumber.replace(".", "")); - - if (iversion >= iaktVersion) { - Platform.runLater(() -> { - mainWindowController.getUpdateBtn().setText(mainWindowController.getBundle().getString("updateBtnNoUpdateAvailable")); - }); - LOGGER.info("no update available"); - } else { - Platform.runLater(() -> { - mainWindowController.getUpdateBtn().setText(mainWindowController.getBundle().getString("updateBtnUpdateAvailable")); - }); - LOGGER.info("update available"); - LOGGER.info("download link: " + browserDownloadUrl); - try { - // open new Http connection, ProgressMonitorInputStream for downloading the data - HttpURLConnection connection = (HttpURLConnection) new URL(browserDownloadUrl).openConnection(); - ProgressMonitorInputStream pmis = new ProgressMonitorInputStream(null, "Downloading...", connection.getInputStream()); - ProgressMonitor pm = pmis.getProgressMonitor(); - pm.setMillisToDecideToPopup(0); - pm.setMillisToPopup(0); - pm.setMinimum(0);// set beginning of the progress bar to 0 - pm.setMaximum(connection.getContentLength());// set the end to the file length - FileUtils.copyInputStreamToFile(pmis, new File("cemu_UI_update.jar")); // download update - org.apache.commons.io.FileUtils.copyFile(new File("cemu_UI_update.jar"), new File("cemu_UI.jar")); - org.apache.commons.io.FileUtils.deleteQuietly(new File("cemu_UI_update.jar")); // delete update - new ProcessBuilder("java", "-jar", "cemu_UI.jar").start(); // start the new application - System.exit(0); // finishes itself - } catch (IOException e) { - Platform.runLater(() -> { - LOGGER.info("could not download update files", e); - }); - } - } - } -} diff --git a/src/main/java/com/cemu_UI/datatypes/CourseTableDataType.java b/src/main/java/com/cemu_UI/datatypes/CourseTableDataType.java deleted file mode 100644 index f1f79f1..0000000 --- a/src/main/java/com/cemu_UI/datatypes/CourseTableDataType.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * cemu_UI - * - * Copyright 2017-2018 <@Seil0> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301, USA. - */ -package com.cemu_UI.datatypes; - -import com.jfoenix.controls.datamodels.treetable.RecursiveTreeObject; - -import javafx.beans.property.IntegerProperty; -import javafx.beans.property.SimpleIntegerProperty; -import javafx.beans.property.SimpleStringProperty; -import javafx.beans.property.StringProperty; - -public class CourseTableDataType extends RecursiveTreeObject { - - public final StringProperty title; - public final StringProperty id; - public final IntegerProperty time; - public final IntegerProperty stars; - - /** - * Data type used in the TreeTableview for - */ - public CourseTableDataType(String title, String id, int time, int stars) { - this.title = new SimpleStringProperty(title); - this.id = new SimpleStringProperty(id); - this.time = new SimpleIntegerProperty(time); - this.stars = new SimpleIntegerProperty(stars); - } -} diff --git a/src/main/java/com/cemu_UI/datatypes/SmmdbApiDataType.java b/src/main/java/com/cemu_UI/datatypes/SmmdbApiDataType.java deleted file mode 100644 index 749fa3a..0000000 --- a/src/main/java/com/cemu_UI/datatypes/SmmdbApiDataType.java +++ /dev/null @@ -1,208 +0,0 @@ -/** - * cemu_UI - * - * Copyright 2017-2018 <@Seil0> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301, USA. - */ -package com.cemu_UI.datatypes; - -import javafx.beans.property.IntegerProperty; -import javafx.beans.property.SimpleIntegerProperty; -import javafx.beans.property.SimpleStringProperty; -import javafx.beans.property.StringProperty; - -public class SmmdbApiDataType { - - private final IntegerProperty courseTheme = new SimpleIntegerProperty(); - private final IntegerProperty gameStyle = new SimpleIntegerProperty(); - private final IntegerProperty difficulty = new SimpleIntegerProperty(); - private final IntegerProperty lastmodified = new SimpleIntegerProperty(); - private final IntegerProperty uploaded = new SimpleIntegerProperty(); - private final IntegerProperty autoScroll = new SimpleIntegerProperty(); - private final IntegerProperty stars = new SimpleIntegerProperty(); - private final IntegerProperty time = new SimpleIntegerProperty(); - private final StringProperty owner = new SimpleStringProperty(); - private final StringProperty id = new SimpleStringProperty(); - private final StringProperty nintendoid = new SimpleStringProperty(); - private final StringProperty title = new SimpleStringProperty(); - - /** - * Data type used for the smmdbapi query - */ - public SmmdbApiDataType(final int courseTheme, final int gameStyle, final int difficulty, final int lastmodified, - final int uploaded, final int autoScroll, final int stars, final int time, - final String owner, final String id, final String nintendoid, final String title) { - this.id.set(id); - this.owner.set(owner); - this.courseTheme.set(courseTheme); - this.gameStyle.set(gameStyle); - this.difficulty.set(difficulty); - this.lastmodified.set(lastmodified); - this.uploaded.set(uploaded); - this.autoScroll.set(autoScroll); - this.stars.set(stars); - this.time.set(time); - this.nintendoid.set(nintendoid); - this.title.set(title); - } - - public IntegerProperty courseThemeProperty(){ - return courseTheme; - } - - - public IntegerProperty gameStyleProperty(){ - return gameStyle; - } - - public IntegerProperty difficultyProperty(){ - return difficulty; - } - - public IntegerProperty lastmodifiedProperty(){ - return lastmodified; - } - - public IntegerProperty uploadedProperty(){ - return uploaded; - } - - public IntegerProperty autoScrollProperty(){ - return autoScroll; - } - - public IntegerProperty starsProperty(){ - return stars; - } - - public IntegerProperty timeProperty(){ - return time; - } - - public StringProperty ownerProperty(){ - return owner; - } - - public StringProperty idProperty(){ - return id; - } - - public StringProperty nintendoidProperty(){ - return nintendoid; - } - - public StringProperty titleProperty(){ - return title; - } - - public int getCourseTheme() { - return courseThemeProperty().get(); - } - - public int getGameStyle() { - return gameStyleProperty().get(); - } - - public int getDifficulty() { - return difficultyProperty().get(); - } - - public int getLastmodified() { - return lastmodifiedProperty().get(); - } - - public int getUploaded() { - return uploadedProperty().get(); - } - - public int getAutoScroll() { - return autoScrollProperty().get(); - } - - public int getStars() { - return starsProperty().get(); - } - - public int getTime() { - return timeProperty().get(); - } - - public String getOwner() { - return ownerProperty().get(); - } - - public String getId() { - return idProperty().get(); - } - - public String getNintendoid() { - return nintendoidProperty().get(); - } - - public String getTitle() { - return titleProperty().get(); - } - - public final void setCourseTheme(int courseTheme) { - courseThemeProperty().set(courseTheme); - } - - public final void setGameStyle(int gameStyle) { - gameStyleProperty().set(gameStyle); - } - - public final void setDifficulty(int difficulty) { - difficultyProperty().set(difficulty); - } - - public final void setLastmodified(int lastmodified) { - lastmodifiedProperty().set(lastmodified); - } - - public final void setUploaded(int uploaded) { - uploadedProperty().set(uploaded); - } - - public final void setAutoScroll(int autoScroll) { - autoScrollProperty().set(autoScroll); - } - - public final void setStars(int stars) { - starsProperty().set(stars); - } - - public final void setTime(int time) { - timeProperty().set(time); - } - - public final void setOwner(String owner) { - ownerProperty().set(owner); - } - - public final void setId(String id) { - idProperty().set(id); - } - - public final void setNintendoid(String nintendoid) { - nintendoidProperty().set(nintendoid); - } - - public final void setTitle(String title) { - titleProperty().set(title); - } - -} diff --git a/src/main/java/com/cemu_UI/datatypes/UIROMDataType.java b/src/main/java/com/cemu_UI/datatypes/UIROMDataType.java deleted file mode 100644 index 2a66c6e..0000000 --- a/src/main/java/com/cemu_UI/datatypes/UIROMDataType.java +++ /dev/null @@ -1,126 +0,0 @@ -/** - * cemu_UI - * - * Copyright 2017-2018 <@Seil0> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301, USA. - */ -package com.cemu_UI.datatypes; - -import com.jfoenix.controls.JFXButton; - -import javafx.beans.property.SimpleObjectProperty; -import javafx.beans.property.SimpleStringProperty; -import javafx.beans.property.StringProperty; -import javafx.scene.control.Label; -import javafx.scene.image.ImageView; -import javafx.scene.layout.VBox; - -public class UIROMDataType { - - private final SimpleObjectProperty vBox = new SimpleObjectProperty<>(); - private final SimpleObjectProperty