diff --git a/bin/.gitignore b/bin/.gitignore index 9a0bb19..25b00bb 100644 --- a/bin/.gitignore +++ b/bin/.gitignore @@ -2,3 +2,4 @@ /cloudControllerInstances/ /datatypes/ /UIElements/ +/EventHandlers/ diff --git a/bin/application/MainWindowController$1.class b/bin/application/MainWindowController$1.class index 1fa8041..4b4825e 100644 Binary files a/bin/application/MainWindowController$1.class and b/bin/application/MainWindowController$1.class differ diff --git a/bin/application/MainWindowController$10.class b/bin/application/MainWindowController$10.class index 9973eec..4954a84 100644 Binary files a/bin/application/MainWindowController$10.class and b/bin/application/MainWindowController$10.class differ diff --git a/bin/application/MainWindowController$11.class b/bin/application/MainWindowController$11.class index 2215b8d..8813356 100644 Binary files a/bin/application/MainWindowController$11.class and b/bin/application/MainWindowController$11.class differ diff --git a/bin/application/MainWindowController$12.class b/bin/application/MainWindowController$12.class index 1f4bf2b..ec49e0b 100644 Binary files a/bin/application/MainWindowController$12.class and b/bin/application/MainWindowController$12.class differ diff --git a/bin/application/MainWindowController$2.class b/bin/application/MainWindowController$2.class index 7fddedc..775e11a 100644 Binary files a/bin/application/MainWindowController$2.class and b/bin/application/MainWindowController$2.class differ diff --git a/bin/application/MainWindowController$3.class b/bin/application/MainWindowController$3.class index d21053b..9e71ba9 100644 Binary files a/bin/application/MainWindowController$3.class and b/bin/application/MainWindowController$3.class differ diff --git a/bin/application/MainWindowController$4.class b/bin/application/MainWindowController$4.class index 0a34b68..65c0504 100644 Binary files a/bin/application/MainWindowController$4.class and b/bin/application/MainWindowController$4.class differ diff --git a/bin/application/MainWindowController$5.class b/bin/application/MainWindowController$5.class index b4cf2e5..566f2f6 100644 Binary files a/bin/application/MainWindowController$5.class and b/bin/application/MainWindowController$5.class differ diff --git a/bin/application/MainWindowController$6.class b/bin/application/MainWindowController$6.class index 1a5b672..744f32d 100644 Binary files a/bin/application/MainWindowController$6.class and b/bin/application/MainWindowController$6.class differ diff --git a/bin/application/MainWindowController$7.class b/bin/application/MainWindowController$7.class index b669139..a6ea230 100644 Binary files a/bin/application/MainWindowController$7.class and b/bin/application/MainWindowController$7.class differ diff --git a/bin/application/MainWindowController$8.class b/bin/application/MainWindowController$8.class index 0344e7a..ad1e31a 100644 Binary files a/bin/application/MainWindowController$8.class and b/bin/application/MainWindowController$8.class differ diff --git a/bin/application/MainWindowController$9.class b/bin/application/MainWindowController$9.class index 3ec4eb1..a817652 100644 Binary files a/bin/application/MainWindowController$9.class and b/bin/application/MainWindowController$9.class differ diff --git a/bin/application/MainWindowController.class b/bin/application/MainWindowController.class index 70ce78f..c563bdb 100644 Binary files a/bin/application/MainWindowController.class and b/bin/application/MainWindowController.class differ diff --git a/src/UIElements/JFXInfoDialog.java b/src/UIElements/JFXInfoDialog.java index 619dc0c..a458b31 100644 --- a/src/UIElements/JFXInfoDialog.java +++ b/src/UIElements/JFXInfoDialog.java @@ -1,3 +1,24 @@ +/** + * cemu_UI + * + * Copyright 2017 <@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 UIElements; import com.jfoenix.controls.JFXButton; @@ -17,15 +38,24 @@ public class JFXInfoDialog { private String bodyText; private String dialogBtnStyle; private int dialogWidth; - private int dialogHeigh; + private int dialogHeight; private Pane pane; - public JFXInfoDialog(String headingText, String bodyText, String dialogBtnStyle, int dialogWidth, int dialogHeigh, Pane pane) { + /** + * 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 + */ + 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.dialogHeigh = dialogHeigh; + this.dialogHeight = dialogHeight; this.pane = pane; } @@ -33,7 +63,7 @@ public class JFXInfoDialog { JFXDialogLayout content = new JFXDialogLayout(); content.setHeading(new Text(headingText)); content.setBody(new Text(bodyText)); - content.setPrefSize(dialogWidth, dialogHeigh); + content.setPrefSize(dialogWidth, dialogHeight); StackPane stackPane = new StackPane(); stackPane.autosize(); JFXDialog dialog = new JFXDialog(stackPane, content, JFXDialog.DialogTransition.LEFT, true); diff --git a/src/UIElements/JFXOkayCancelDialog.java b/src/UIElements/JFXOkayCancelDialog.java new file mode 100644 index 0000000..7a5c281 --- /dev/null +++ b/src/UIElements/JFXOkayCancelDialog.java @@ -0,0 +1,105 @@ +/** + * cemu_UI + * + * Copyright 2017 <@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 UIElements; + +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.control.Label; +import javafx.scene.layout.AnchorPane; +import javafx.scene.layout.Pane; +import javafx.scene.layout.StackPane; +import javafx.scene.text.Text; + +public class JFXOkayCancelDialog { + + private String headingText; + private String bodyText; + private String dialogBtnStyle; + private int dialogWidth; + private int dialogHeight; + private EventHandler okayAction; + private EventHandler cancelAction; + private Pane pane; + + /** + * Creates a new JFoenix Dialog to show some information with okay and cancel option + * @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 okayAction action which is performed if the okay button is clicked + * @param cancelAction action which is performed if the cancel button is clicked + * @param pane pane to which the dialog belongs + */ + public JFXOkayCancelDialog(String headingText, String bodyText, String dialogBtnStyle, int dialogWidth, + int dialogHeight, EventHandler okayAction, EventHandler cancelAction, Pane pane) { + this.headingText = headingText; + this.bodyText = bodyText; + this.dialogBtnStyle = dialogBtnStyle; + this.dialogWidth = dialogWidth; + this.dialogHeight = dialogHeight; + this.okayAction = okayAction; + this.cancelAction = cancelAction; + this.pane = pane; + } + + public void show() { + JFXDialogLayout content= new JFXDialogLayout(); + content.setHeading(new Text(headingText)); + content.setBody(new Text(bodyText)); + StackPane stackPane = new StackPane(); + stackPane.autosize(); + JFXDialog dialog = new JFXDialog(stackPane, content, JFXDialog.DialogTransition.LEFT, true); + JFXButton okayBtn = new JFXButton("Okay"); + okayBtn.addEventHandler(ActionEvent.ACTION, okayAction); + okayBtn.addEventHandler(ActionEvent.ACTION, (e)-> { + dialog.close(); + }); + okayBtn.setButtonType(com.jfoenix.controls.JFXButton.ButtonType.RAISED); + okayBtn.setPrefHeight(32); + okayBtn.setStyle(dialogBtnStyle); + JFXButton cancelBtn = new JFXButton("Cancel"); + cancelBtn.addEventHandler(ActionEvent.ACTION, cancelAction); + cancelBtn.addEventHandler(ActionEvent.ACTION, (e)-> { + dialog.close(); + }); + cancelBtn.setButtonType(com.jfoenix.controls.JFXButton.ButtonType.RAISED); + cancelBtn.setPrefHeight(32); + cancelBtn.setStyle(dialogBtnStyle); + Label placeholder = new Label(); + placeholder.setPrefSize(15, 10); + content.setActions(cancelBtn, placeholder, okayBtn); + content.setPrefSize(dialogWidth, dialogHeight); + pane.getChildren().add(stackPane); + AnchorPane.setTopAnchor(stackPane, (pane.getHeight()-content.getPrefHeight())/2); + AnchorPane.setLeftAnchor(stackPane, (pane.getWidth()-content.getPrefWidth())/2); + dialog.show(); + } + +} + diff --git a/src/application/MainWindowController.java b/src/application/MainWindowController.java index 1d55d73..6dce3a0 100644 --- a/src/application/MainWindowController.java +++ b/src/application/MainWindowController.java @@ -53,8 +53,6 @@ import org.apache.logging.log4j.Logger; import com.jfoenix.controls.JFXButton; import com.jfoenix.controls.JFXColorPicker; -import com.jfoenix.controls.JFXDialog; -import com.jfoenix.controls.JFXDialogLayout; import com.jfoenix.controls.JFXHamburger; import com.jfoenix.controls.JFXTextField; import com.jfoenix.controls.JFXToggleButton; @@ -63,6 +61,7 @@ import com.jfoenix.controls.JFXTreeTableView; import com.jfoenix.transitions.hamburger.HamburgerBackArrowBasicTransition; import UIElements.JFXInfoDialog; +import UIElements.JFXOkayCancelDialog; import datatypes.CourseTableDataType; import datatypes.SmmdbApiDataType; import datatypes.UIROMDataType; @@ -97,7 +96,6 @@ import javafx.scene.input.MouseEvent; import javafx.scene.layout.AnchorPane; import javafx.scene.layout.GridPane; import javafx.scene.layout.HBox; -import javafx.scene.layout.StackPane; import javafx.scene.layout.VBox; import javafx.scene.paint.Color; import javafx.scene.paint.Paint; @@ -953,78 +951,45 @@ public class MainWindowController { if(cloudSync) { cloudSync = false; } else { + //TODO this new dialog needs testing! - JFXDialogLayout content= new JFXDialogLayout(); - content.setHeading(new Text("activate cloud savegame sync (beta)")); - content.setBody(new Text("You just activate the cloud savegame sync function of cemu_UI, \nwhich is currently in beta. Are you sure you want to do this?")); - StackPane stackPane = new StackPane(); - stackPane.autosize(); - JFXDialog betaDialog = new JFXDialog(stackPane, content, JFXDialog.DialogTransition.LEFT, true); - JFXButton okayBtn = new JFXButton("Okay"); - okayBtn.setOnAction(new EventHandler(){ - @Override - public void handle(ActionEvent event){ - cloudSync = true; - //TODO rework for other cloud services - cloudService = "GoogleDrive"; - if (main.cloudController.initializeConnection(getCloudService(), getCemuPath())) { - main.cloudController.sync(getCloudService(), getCemuPath()); - saveSettings(); - } else { - cloudSyncToggleBtn.setSelected(false); - - //cloud sync init error dialog - JFXDialogLayout content= new JFXDialogLayout(); - content.setHeading(new Text("Error while initializing cloud sync!")); - content.setBody(new Text("There was some truble initializing the cloud sync." - + "\nPlease upload the app.log (which can be found in the cemu_UI directory)" - + "\nto \"https://github.com/Seil0/cemu_UI/issues\" so we can fix this.")); - content.setPrefSize(450, 170); - StackPane stackPane = new StackPane(); - stackPane.autosize(); - JFXDialog dialog =new JFXDialog(stackPane, content, JFXDialog.DialogTransition.LEFT, true); - JFXButton button=new JFXButton("Okay"); - button.setOnAction(new EventHandler(){ - @Override - public void handle(ActionEvent event){ - dialog.close(); - } - }); - button.setButtonType(com.jfoenix.controls.JFXButton.ButtonType.RAISED); - button.setPrefHeight(32); - button.setStyle(dialogBtnStyle); - content.setActions(button); - main.pane.getChildren().add(stackPane); - AnchorPane.setTopAnchor(stackPane, (main.pane.getHeight()-content.getPrefHeight())/2); - AnchorPane.setLeftAnchor(stackPane, (main.pane.getWidth()-content.getPrefWidth())/2); - dialog.show(); - } - - betaDialog.close(); - } - }); - JFXButton cancelBtn = new JFXButton("Cancel"); - cancelBtn.setOnAction(new EventHandler(){ - @Override - public void handle(ActionEvent event){ - cloudSyncToggleBtn.setSelected(false); - betaDialog.close(); - } - }); - Label placeholder = new Label(); - placeholder.setPrefSize(15, 10); - okayBtn.setButtonType(com.jfoenix.controls.JFXButton.ButtonType.RAISED); - cancelBtn.setButtonType(com.jfoenix.controls.JFXButton.ButtonType.RAISED); - okayBtn.setPrefHeight(32); - cancelBtn.setPrefHeight(32); - okayBtn.setStyle(dialogBtnStyle); - cancelBtn.setStyle(dialogBtnStyle); - content.setActions(cancelBtn, placeholder, okayBtn); - content.setPrefSize(419, 140); - main.pane.getChildren().add(stackPane); - AnchorPane.setTopAnchor(stackPane, (main.pane.getHeight()-content.getPrefHeight())/2); - AnchorPane.setLeftAnchor(stackPane, (main.pane.getWidth()-content.getPrefWidth())/2); - betaDialog.show(); + String headingText = "activate cloud savegame sync (beta)"; + String bodyText = "You just activate the cloud savegame sync function of cemu_UI, " + + "\nwhich is currently in beta. Are you sure you want to do this?"; + + EventHandler okayAction = new EventHandler(){ + @Override + public void handle(ActionEvent event){ + cloudSync = true; + //TODO rework for other cloud services + cloudService = "GoogleDrive"; + if (main.cloudController.initializeConnection(getCloudService(), getCemuPath())) { + main.cloudController.sync(getCloudService(), getCemuPath()); + saveSettings(); + } else { + cloudSyncToggleBtn.setSelected(false); + + //cloud sync init error dialog + String headingText = "Error while initializing cloud sync!"; + String bodyText = "There was some truble adding your game." + + "\nPlease upload the app.log (which can be found in the cemu_UI directory)" + + "\nto \"https://github.com/Seil0/cemu_UI/issues\" so we can fix this."; + JFXInfoDialog cloudSyncErrorDialog = new JFXInfoDialog(headingText, bodyText, dialogBtnStyle, 450, 170, main.pane); + cloudSyncErrorDialog.show(); + } + } + }; + + EventHandler cancelAction = new EventHandler(){ + @Override + public void handle(ActionEvent event){ + cloudSyncToggleBtn.setSelected(false); + } + }; + + JFXOkayCancelDialog cloudSyncErrorDialog = new JFXOkayCancelDialog(headingText, bodyText, dialogBtnStyle, + 419, 140, okayAction, cancelAction, main.pane); + cloudSyncErrorDialog.show(); } } @@ -1124,30 +1089,11 @@ public class MainWindowController { LOGGER.info("No parameter set!"); //addGame error dialog - JFXDialogLayout content= new JFXDialogLayout(); - content.setHeading(new Text("Error while adding a new Game!")); - content.setBody(new Text("There was some truble adding your game." - + "\nOne of the needed values was empty, please try again to add your game.")); - content.setPrefSize(450, 170); - StackPane stackPane = new StackPane(); - stackPane.autosize(); - JFXDialog errorDialog =new JFXDialog(stackPane, content, JFXDialog.DialogTransition.LEFT, true); - JFXButton button=new JFXButton("Okay"); - button.setOnAction(new EventHandler(){ - @Override - public void handle(ActionEvent event){ - errorDialog.close(); - } - }); - button.setButtonType(com.jfoenix.controls.JFXButton.ButtonType.RAISED); - button.setPrefHeight(32); - button.setStyle(dialogBtnStyle); - content.setActions(button); - main.pane.getChildren().add(stackPane); - AnchorPane.setTopAnchor(stackPane, (main.pane.getHeight()-content.getPrefHeight())/2); - AnchorPane.setLeftAnchor(stackPane, (main.pane.getWidth()-content.getPrefWidth())/2); - errorDialog.show(); - + String headingText = "Error while adding a new Game!"; + String bodyText = "There was some truble adding your game." + + "\nOne of the needed values was empty, please try again to add your game."; + JFXInfoDialog addGameErrorDialog = new JFXInfoDialog(headingText, bodyText, dialogBtnStyle, 450, 170, main.pane); + addGameErrorDialog.show(); } else { coverName = new File(coverPath).getName(); try {