From a4c8eb2efe6a2ba76b2c6007004edb36a53399af Mon Sep 17 00:00:00 2001 From: Seil0 Date: Fri, 17 May 2019 00:22:51 +0200 Subject: [PATCH] the license dialog is now a alert & reduced main usage in mwc --- .../java/com/cemu_UI/application/Main.java | 7 - .../application/MainWindowController.java | 221 +++++++----------- .../com/cemu_UI/application/playGame.java | 3 +- .../cemu_UI/controller/CloudController.java | 3 +- .../com/cemu_UI/controller/DBController.java | 3 +- .../controller/SmmdbAPIController.java | 3 +- .../cemu_UI/controller/UpdateController.java | 3 +- .../com/cemu_UI/controller/XMLController.java | 3 +- .../datatypes/CourseTableDataType.java | 3 +- .../cemu_UI/datatypes/GlobalDataTypes.java | 2 +- .../cemu_UI/datatypes/SmmdbApiDataType.java | 3 +- .../com/cemu_UI/datatypes/UIROMDataType.java | 8 +- .../com/cemu_UI/uiElements/JFXInfoAlert.java | 4 +- .../cemu_UI/uiElements/JFXTextAreaAlert.java | 104 +++++++++ .../uiElements/JFXTextAreaInfoDialog.java | 98 -------- .../GoogleDriveController.java | 3 +- src/main/resources/fxml/MainWindow.fxml | 6 +- 17 files changed, 216 insertions(+), 261 deletions(-) create mode 100644 src/main/java/com/cemu_UI/uiElements/JFXTextAreaAlert.java delete mode 100644 src/main/java/com/cemu_UI/uiElements/JFXTextAreaInfoDialog.java diff --git a/src/main/java/com/cemu_UI/application/Main.java b/src/main/java/com/cemu_UI/application/Main.java index 8b48a89..22e6fc4 100644 --- a/src/main/java/com/cemu_UI/application/Main.java +++ b/src/main/java/com/cemu_UI/application/Main.java @@ -129,7 +129,6 @@ public class Main extends Application { XMLController.getPictureCache().mkdir(); } - if (!XMLController.getRference_gamesFile().exists()) { if (XMLController.getGamesDBFile().exists()) { XMLController.getGamesDBFile().delete(); @@ -221,12 +220,6 @@ public class Main extends Application { @Override public void changed(ObservableValue observable, Number oldValue, final Number newValue) { - int xMaxElements = (int) Math.floor((mainWindowController.getMainAnchorPane().getWidth() - 36) / 217); - - // call only if there is enough space for a new row - if (mainWindowController.getOldXNextElement() != xMaxElements) { - mainWindowController.refreshUIData(); - } // if saveTask is already running kill it if (saveTask != null) saveTask.cancel(); diff --git a/src/main/java/com/cemu_UI/application/MainWindowController.java b/src/main/java/com/cemu_UI/application/MainWindowController.java index a4f080b..7fca061 100644 --- a/src/main/java/com/cemu_UI/application/MainWindowController.java +++ b/src/main/java/com/cemu_UI/application/MainWindowController.java @@ -59,7 +59,7 @@ import com.cemu_UI.datatypes.UIROMDataType; import com.cemu_UI.uiElements.JFXEditGameDialog; import com.cemu_UI.uiElements.JFXInfoAlert; import com.cemu_UI.uiElements.JFXOkayCancelAlert; -import com.cemu_UI.uiElements.JFXTextAreaInfoDialog; +import com.cemu_UI.uiElements.JFXTextAreaAlert; import com.jfoenix.controls.JFXButton; import com.jfoenix.controls.JFXColorPicker; import com.jfoenix.controls.JFXHamburger; @@ -138,17 +138,16 @@ public class MainWindowController { @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 FlowPane gamesFlowPane; - @FXML private ScrollPane mainScrollPane; @FXML private ScrollPane settingsScrollPane; @FXML private ScrollPane smmdbScrollPane; @FXML private ScrollPane smmdbImageViewScrollPane; + + @FXML private AnchorPane mainAnchorPane; + @FXML private AnchorPane settingsAnchorPane; + @FXML private AnchorPane smmdbAnchorPane; + + @FXML private FlowPane gamesFlowPane; @FXML private VBox sideMenuVBox; @@ -195,10 +194,6 @@ public class MainWindowController { private String version = "0.3.2"; private String buildNumber = "085"; private String versionName = "Purple Comet"; - private int xPos = -200; - private int yPos = 17; - private int xNextElement = 0; - private int oldXNextElement; private int selectedUIDataIndex; private int selected; private DirectoryChooser directoryChooser = new DirectoryChooser(); @@ -350,55 +345,49 @@ public class MainWindowController { } }); - edit.setOnAction(new EventHandler() { - @Override - public void handle(ActionEvent event) { - try { - LOGGER.info("edit " + selectedGameTitleID); - String[] gameInfo = dbController.getGameInfo(selectedGameTitleID); + edit.setOnAction(event -> { + try { + LOGGER.info("edit " + selectedGameTitleID); + String[] gameInfo = dbController.getGameInfo(selectedGameTitleID); - // new edit dialog - String headingText = bundle.getString("editHeadingText") + " \"" + selectedGameTitle + "\""; - JFXEditGameDialog editGameDialog = new JFXEditGameDialog(headingText, bundle.getString("editBodyText"), dialogBtnStyle, 450, - 300, 1, MWC, primaryStage, 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); - } + // new edit dialog + String headingText = bundle.getString("editHeadingText") + " \"" + selectedGameTitle + "\""; + JFXEditGameDialog editGameDialog = new JFXEditGameDialog(headingText, bundle.getString("editBodyText"), + dialogBtnStyle, 450, 300, 1, MWC, primaryStage, 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 = bundle.getString("removeHeadingText") + " \"" + selectedGameTitle + "\""; - String bodyText = bundle.getString("removeBodyText") + " " + selectedGameTitle + " ?"; - - JFXOkayCancelAlert removeGameAlert = new JFXOkayCancelAlert(headingText, - bodyText, dialogBtnStyle, primaryStage); - removeGameAlert.setOkayAction(e -> { - 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 ex) { - LOGGER.error("error while removing ROM from database!", ex); - } - }); - removeGameAlert.setCancelAction(e -> LOGGER.info("Action canceld by user!")); - removeGameAlert.showAndWait(); - } catch (Exception e) { - LOGGER.error("error while removing " + selectedGameTitle + "(" + selectedGameTitleID + ")", e); - } - } + remove.setOnAction(event -> { + try { + LOGGER.info("remove " + selectedGameTitle + "(" + selectedGameTitleID + ")"); + String headingText = bundle.getString("removeHeadingText") + " \"" + selectedGameTitle + "\""; + String bodyText = bundle.getString("removeBodyText") + " " + selectedGameTitle + " ?"; + + JFXOkayCancelAlert removeGameAlert = new JFXOkayCancelAlert(headingText, bodyText, dialogBtnStyle, + primaryStage); + removeGameAlert.setOkayAction(e -> { + 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 ex) { + LOGGER.error("error while removing ROM from database!", ex); + } + }); + removeGameAlert.setCancelAction(e -> LOGGER.info("Action canceld by user!")); + removeGameAlert.showAndWait(); + } catch (Exception e) { + LOGGER.error("error while removing " + selectedGameTitle + "(" + selectedGameTitleID + ")", e); + } }); - + addUpdate.setOnAction(new EventHandler() { @Override public void handle(ActionEvent event) { @@ -506,7 +495,7 @@ public class MainWindowController { } }); - gamesAnchorPane.addEventHandler(MouseEvent.MOUSE_CLICKED, new EventHandler() { + gamesFlowPane.addEventHandler(MouseEvent.MOUSE_CLICKED, new EventHandler() { @Override public void handle(MouseEvent event) { if (playTrue) { @@ -580,13 +569,13 @@ public class MainWindowController { } }); - helpLbl.setOnMouseClicked(e -> { - if (e.getButton().equals(MouseButton.PRIMARY)) { + helpLbl.setOnMouseClicked(event -> { + if (event.getButton().equals(MouseButton.PRIMARY)) { Main.getMain().getHostServices().showDocument("https://git.mosad.xyz/Seil0/cemu_UI/issues/3"); } }); - languageChoisBox.getSelectionModel().selectedIndexProperty().addListener((e, oldValue, newValue) -> { + languageChoisBox.getSelectionModel().selectedIndexProperty().addListener((event, oldValue, newValue) -> { String language = languageChoisBox.getItems().get((int) newValue).toString(); language = language.substring(language.length() - 6, language.length() - 1); // reading only en_US from // English (en_US) @@ -604,11 +593,11 @@ public class MainWindowController { xmlController.saveSettings(); }); - licensesLbl.setOnMouseClicked(e -> { - if (e.getButton().equals(MouseButton.PRIMARY)) { + licensesLbl.setOnMouseClicked(event -> { + if (event.getButton().equals(MouseButton.PRIMARY)) { EventHandler cancelAction = cE -> { - String bodyText = ""; + String textAreaText = ""; try { BufferedReader licenseBR = new BufferedReader( @@ -616,18 +605,16 @@ public class MainWindowController { String currentLine; while ((currentLine = licenseBR.readLine()) != null) { - bodyText = bodyText + currentLine + "\n"; + textAreaText = textAreaText + currentLine + "\n"; } licenseBR.close(); } catch (IOException ex) { LOGGER.error("Cloud not read the license file!", ex); } - - JFXTextAreaInfoDialog licenseDialog = new JFXTextAreaInfoDialog("cemu_UI", "", - dialogBtnStyle, 510, 450, main.getPane()); - licenseDialog.getTextArea().setEditable(false); - licenseDialog.show(); + + JFXTextAreaAlert licenseAlert = new JFXTextAreaAlert("cemu_UI", textAreaText, dialogBtnStyle, primaryStage); + licenseAlert.showAndWait(); }; JFXOkayCancelAlert licenseOverviewAlert = new JFXOkayCancelAlert( @@ -930,9 +917,9 @@ public class MainWindowController { LOGGER.info("No parameter set!"); //addGame error dialog - JFXInfoAlert errorDialog = new JFXInfoAlert(bundle.getString("addBtnReturnErrorHeadingText"), + JFXInfoAlert errorAlert = new JFXInfoAlert(bundle.getString("addBtnReturnErrorHeadingText"), bundle.getString("addBtnReturnErrorBodyText"), dialogBtnStyle, primaryStage); - errorDialog.showAndWait(); + errorAlert.showAndWait(); } else { File pictureCache = XMLController.getPictureCache(); @@ -980,7 +967,7 @@ public class MainWindowController { * @param titleID : game ID */ public void addGame(String title, String coverPath, String romPath, String titleID){ - UIROMDataType uiROMElement = new UIROMDataType(title, coverPath, gameContextMenu); + UIROMDataType uiROMElement = new UIROMDataType(titleID, romPath, title, coverPath, gameContextMenu); uiROMElement.getButton().addEventHandler(MouseEvent.MOUSE_CLICKED, new EventHandler() { @Override @@ -1057,57 +1044,37 @@ public class MainWindowController { 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(XMLController.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(); + AnchorPane.setTopAnchor(spinner, (mainAnchorPane.getPrefHeight() - spinner.getPrefHeight()) / 2); + AnchorPane.setLeftAnchor(spinner, (mainAnchorPane.getPrefWidth() - spinner.getPrefWidth()) / 2); + + Runnable task = () -> { + Platform.runLater(() -> { + gamesFlowPane.getChildren().clear(); //remove all games form gamesFlowPane + mainAnchorPane.getChildren().add(spinner); // add spinner to mainAnchorPane + }); + + dbController.loadRomDirectory(XMLController.getRomDirectoryPath()); // reload the ROM directory + games.clear(); // 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 + mainAnchorPane.getChildren().remove(spinner); + }); + }; + + new Thread(task).start(); } - // remove all games from gamesAnchorPane and add them afterwards + // remove all games from gamesFlowPane and add them afterwards public void refreshUIData() { - // remove all games form gamesAnchorPane - gamesAnchorPane.getChildren().clear(); - - // reset position - xPos = -200; - yPos = 17; - xNextElement = 0; - - // add all games to gamesAnchorPane (UI) -// for (UIROMDataType game : games) { -// generatePosition(); -// -// game.setLayoutX(xPos); -// game.setLayoutY(yPos); -// gamesAnchorPane.getChildren().add(game); -// } - - // TODO + gamesFlowPane.getChildren().clear(); gamesFlowPane.getChildren().addAll(games); } // set the selected local strings to all needed elements void setUILanguage(){ - switch(XMLController.getUsrLocal()){ + switch (XMLController.getUsrLocal()) { case "en_US": XMLController.setLocalBundle(ResourceBundle.getBundle("locals.cemu_UI-Local", Locale.US)); // us_English bundle = ResourceBundle.getBundle("locals.cemu_UI-Local", Locale.US); // us_English @@ -1123,7 +1090,7 @@ public class MainWindowController { bundle = ResourceBundle.getBundle("locals.cemu_UI-Local", Locale.US); // default local languageChoisBox.getSelectionModel().select(0); break; - } + } // Buttons aboutBtn.setText(bundle.getString("aboutBtn")); @@ -1300,24 +1267,6 @@ public class MainWindowController { } } - - /** - * xMaxElements based on window width -36 - * calculates how many games can be displayed in one row - */ - private void generatePosition() { - int xMaxElements = (int) Math.floor((mainAnchorPane.getWidth() - 36) / 217); - - if(xNextElement >= xMaxElements){ - oldXNextElement = xNextElement; - xPos = 17; - yPos = yPos + 345; - xNextElement = 1; - }else{ - xPos = xPos + 217; - xNextElement++; - } - } // change the color of all needed GUI elements private void applyColor() { @@ -1494,10 +1443,6 @@ public class MainWindowController { public void setPlayBtn(JFXButton playBtn) { this.playBtn = playBtn; } - - public int getOldXNextElement() { - return oldXNextElement; - } public String getLanguage() { return language; diff --git a/src/main/java/com/cemu_UI/application/playGame.java b/src/main/java/com/cemu_UI/application/playGame.java index 8930493..f702c57 100644 --- a/src/main/java/com/cemu_UI/application/playGame.java +++ b/src/main/java/com/cemu_UI/application/playGame.java @@ -1,7 +1,7 @@ /** * cemu_UI * - * Copyright 2017-2018 <@Seil0> + * Copyright 2017-2019 <@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 @@ -18,6 +18,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. */ + package com.cemu_UI.application; import java.io.IOException; diff --git a/src/main/java/com/cemu_UI/controller/CloudController.java b/src/main/java/com/cemu_UI/controller/CloudController.java index 1c21507..0716578 100644 --- a/src/main/java/com/cemu_UI/controller/CloudController.java +++ b/src/main/java/com/cemu_UI/controller/CloudController.java @@ -1,7 +1,7 @@ /** * cemu_UI * - * Copyright 2017-2018 <@Seil0> + * Copyright 2017-2019 <@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 @@ -18,6 +18,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. */ + package com.cemu_UI.controller; import java.io.File; diff --git a/src/main/java/com/cemu_UI/controller/DBController.java b/src/main/java/com/cemu_UI/controller/DBController.java index 9b739e9..718d965 100644 --- a/src/main/java/com/cemu_UI/controller/DBController.java +++ b/src/main/java/com/cemu_UI/controller/DBController.java @@ -1,7 +1,7 @@ /** * cemu_UI * - * Copyright 2017-2018 <@Seil0> + * Copyright 2017-2019 <@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 @@ -18,6 +18,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. */ + package com.cemu_UI.controller; import java.awt.Graphics2D; diff --git a/src/main/java/com/cemu_UI/controller/SmmdbAPIController.java b/src/main/java/com/cemu_UI/controller/SmmdbAPIController.java index d683f83..d84626f 100644 --- a/src/main/java/com/cemu_UI/controller/SmmdbAPIController.java +++ b/src/main/java/com/cemu_UI/controller/SmmdbAPIController.java @@ -1,7 +1,7 @@ /** * cemu_UI * - * Copyright 2017-2018 <@Seil0> + * Copyright 2017-2019 <@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 @@ -18,6 +18,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. */ + package com.cemu_UI.controller; import java.io.BufferedReader; diff --git a/src/main/java/com/cemu_UI/controller/UpdateController.java b/src/main/java/com/cemu_UI/controller/UpdateController.java index 074aa0e..b7cdcc4 100644 --- a/src/main/java/com/cemu_UI/controller/UpdateController.java +++ b/src/main/java/com/cemu_UI/controller/UpdateController.java @@ -1,7 +1,7 @@ /** * cemu_UI * - * Copyright 2017-2018 <@Seil0> + * Copyright 2017-2019 <@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 @@ -18,6 +18,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. */ + package com.cemu_UI.controller; import java.io.BufferedReader; diff --git a/src/main/java/com/cemu_UI/controller/XMLController.java b/src/main/java/com/cemu_UI/controller/XMLController.java index b9bec3c..f0bc0d5 100644 --- a/src/main/java/com/cemu_UI/controller/XMLController.java +++ b/src/main/java/com/cemu_UI/controller/XMLController.java @@ -1,7 +1,7 @@ /** * cemu_UI * - * Copyright 2019 <@Seil0> + * Copyright 2017-2019 <@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 @@ -18,6 +18,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. */ + package com.cemu_UI.controller; import java.io.File; diff --git a/src/main/java/com/cemu_UI/datatypes/CourseTableDataType.java b/src/main/java/com/cemu_UI/datatypes/CourseTableDataType.java index f1f79f1..da923d9 100644 --- a/src/main/java/com/cemu_UI/datatypes/CourseTableDataType.java +++ b/src/main/java/com/cemu_UI/datatypes/CourseTableDataType.java @@ -1,7 +1,7 @@ /** * cemu_UI * - * Copyright 2017-2018 <@Seil0> + * Copyright 2017-2019 <@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 @@ -18,6 +18,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. */ + package com.cemu_UI.datatypes; import com.jfoenix.controls.datamodels.treetable.RecursiveTreeObject; diff --git a/src/main/java/com/cemu_UI/datatypes/GlobalDataTypes.java b/src/main/java/com/cemu_UI/datatypes/GlobalDataTypes.java index 2d37806..d259223 100644 --- a/src/main/java/com/cemu_UI/datatypes/GlobalDataTypes.java +++ b/src/main/java/com/cemu_UI/datatypes/GlobalDataTypes.java @@ -1,7 +1,7 @@ /** * cemu_UI * - * Copyright 2017-2018 <@Seil0> + * Copyright 2017-2019 <@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 diff --git a/src/main/java/com/cemu_UI/datatypes/SmmdbApiDataType.java b/src/main/java/com/cemu_UI/datatypes/SmmdbApiDataType.java index 749fa3a..8a1f17a 100644 --- a/src/main/java/com/cemu_UI/datatypes/SmmdbApiDataType.java +++ b/src/main/java/com/cemu_UI/datatypes/SmmdbApiDataType.java @@ -1,7 +1,7 @@ /** * cemu_UI * - * Copyright 2017-2018 <@Seil0> + * Copyright 2017-2019 <@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 @@ -18,6 +18,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. */ + package com.cemu_UI.datatypes; import javafx.beans.property.IntegerProperty; diff --git a/src/main/java/com/cemu_UI/datatypes/UIROMDataType.java b/src/main/java/com/cemu_UI/datatypes/UIROMDataType.java index 8ee3982..3e797e4 100644 --- a/src/main/java/com/cemu_UI/datatypes/UIROMDataType.java +++ b/src/main/java/com/cemu_UI/datatypes/UIROMDataType.java @@ -1,7 +1,7 @@ /** * cemu_UI * - * Copyright 2017-2018 <@Seil0> + * Copyright 2017-2019 <@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 @@ -18,6 +18,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. */ + package com.cemu_UI.datatypes; import java.io.File; @@ -41,9 +42,12 @@ public class UIROMDataType extends VBox { private JFXButton button = new JFXButton(); private ImageView imageView = new ImageView(); - public UIROMDataType(String text, String coverPath, ContextMenu contextMenu) { + public UIROMDataType(String titleID, String romPath, String text, String coverPath, ContextMenu contextMenu) { this(); + this.titleID = titleID; + this.romPath = romPath; + label.setText(text); imageView.setImage(new Image(new File(coverPath).toURI().toString())); button.setContextMenu(contextMenu); diff --git a/src/main/java/com/cemu_UI/uiElements/JFXInfoAlert.java b/src/main/java/com/cemu_UI/uiElements/JFXInfoAlert.java index 71b2b00..e4ad63f 100644 --- a/src/main/java/com/cemu_UI/uiElements/JFXInfoAlert.java +++ b/src/main/java/com/cemu_UI/uiElements/JFXInfoAlert.java @@ -1,5 +1,5 @@ /** - * Kellerkinder Framework Alerts + * cemu_UI * * Copyright 2017-2019 <@Seil0> * @@ -40,7 +40,7 @@ public class JFXInfoAlert { /** * Creates a new JFoenix Alert to show some information * @param headerText Heading text of the alert - * @param bodyText Content 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 */ diff --git a/src/main/java/com/cemu_UI/uiElements/JFXTextAreaAlert.java b/src/main/java/com/cemu_UI/uiElements/JFXTextAreaAlert.java new file mode 100644 index 0000000..2116eb9 --- /dev/null +++ b/src/main/java/com/cemu_UI/uiElements/JFXTextAreaAlert.java @@ -0,0 +1,104 @@ +/** + * cemu_UI + * + * Copyright 2017-2019 <@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.uiElements; + +import com.jfoenix.controls.JFXAlert; +import com.jfoenix.controls.JFXButton; +import com.jfoenix.controls.JFXDialogLayout; +import com.jfoenix.controls.JFXTextArea; + +import javafx.scene.text.Text; +import javafx.stage.Stage; + +public class JFXTextAreaAlert { + + private String headingText; + private String textAreaText; + private String btnStyle; + private Stage stage; + + /** + * Creates a new JFoenix Alert to show some information on a TextArea + * @param headingText just the heading + * @param textAreaText all text to needed on the TextArea belongs here + * @param btnStyle Style of the okay button + * @param stage stage to which the dialog belongs + */ + public JFXTextAreaAlert(String headingText, String textAreaText, String btnStyle, Stage stage) { + setHeadingText(headingText); + setTextAreaText(textAreaText); + setBtnStyle(btnStyle); + setStage(stage); + } + + public void showAndWait( ) { + JFXAlert alert = new JFXAlert<>(stage); + JFXTextArea textArea = new JFXTextArea(textAreaText); + textArea.setMinWidth(450); + + JFXButton button = new JFXButton("Okay"); + button.setOnAction(event -> alert.close()); + button.setButtonType(com.jfoenix.controls.JFXButton.ButtonType.RAISED); + button.setPrefHeight(32); + button.setStyle(btnStyle); + + JFXDialogLayout content = new JFXDialogLayout(); + content.setActions(button); + content.setHeading(new Text(headingText)); + content.setBody(textArea); + alert.setContent(content); + alert.showAndWait(); + } + + public String getHeadingText() { + return headingText; + } + + public String getTextAreaText() { + return textAreaText; + } + + public String getBtnStyle() { + return btnStyle; + } + + public Stage getStage() { + return stage; + } + + public void setHeadingText(String headingText) { + this.headingText = headingText; + } + + public void setTextAreaText(String textAreaText) { + this.textAreaText = textAreaText; + } + + public void setBtnStyle(String btnStyle) { + this.btnStyle = btnStyle; + } + + public void setStage(Stage stage) { + this.stage = stage; + } + +} diff --git a/src/main/java/com/cemu_UI/uiElements/JFXTextAreaInfoDialog.java b/src/main/java/com/cemu_UI/uiElements/JFXTextAreaInfoDialog.java deleted file mode 100644 index 4e191da..0000000 --- a/src/main/java/com/cemu_UI/uiElements/JFXTextAreaInfoDialog.java +++ /dev/null @@ -1,98 +0,0 @@ -/** - * cemu_UI - * - * Copyright 2017-2019 <@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.uiElements; - -import com.jfoenix.controls.JFXButton; -import com.jfoenix.controls.JFXDialog; -import com.jfoenix.controls.JFXDialogLayout; -import com.jfoenix.controls.JFXTextArea; - -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; - -public class JFXTextAreaInfoDialog { - - private String headingText; - private String bodyText; - private String dialogBtnStyle; - private int dialogWidth; - private int dialogHeight; - private JFXTextArea textArea; - private 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 JFXTextAreaInfoDialog(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 void show() { - textArea = new JFXTextArea(bodyText); - - JFXDialogLayout content = new JFXDialogLayout(); - content.setHeading(new Text(headingText)); - content.setBody(textArea); - content.setPrefSize(dialogWidth, dialogHeight); - 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); - pane.getChildren().add(stackPane); - AnchorPane.setTopAnchor(stackPane, (pane.getHeight() - content.getPrefHeight()) / 2); - AnchorPane.setLeftAnchor(stackPane, (pane.getWidth() - content.getPrefWidth()) / 2); - dialog.show(); - } - - public JFXTextArea getTextArea() { - return textArea; - } - - public void setTextArea(JFXTextArea textArea) { - this.textArea = textArea; - } -} diff --git a/src/main/java/com/cemu_UI/vendorCloudController/GoogleDriveController.java b/src/main/java/com/cemu_UI/vendorCloudController/GoogleDriveController.java index b62e2de..45f9ce5 100644 --- a/src/main/java/com/cemu_UI/vendorCloudController/GoogleDriveController.java +++ b/src/main/java/com/cemu_UI/vendorCloudController/GoogleDriveController.java @@ -1,7 +1,7 @@ /** * cemu_UI * - * Copyright 2017-2018 <@Seil0> + * Copyright 2017-2019 <@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 @@ -18,6 +18,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. */ + package com.cemu_UI.vendorCloudController; import java.io.FileOutputStream; diff --git a/src/main/resources/fxml/MainWindow.fxml b/src/main/resources/fxml/MainWindow.fxml index fd7e7aa..8d87df3 100644 --- a/src/main/resources/fxml/MainWindow.fxml +++ b/src/main/resources/fxml/MainWindow.fxml @@ -23,13 +23,11 @@ - + - - - +