the license dialog is now a alert & reduced main usage in mwc

This commit is contained in:
Jannik 2019-05-17 00:22:51 +02:00
parent 7d376535ae
commit a4c8eb2efe
Signed by: Seil0
GPG Key ID: E8459F3723C52C24
17 changed files with 216 additions and 261 deletions

View File

@ -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<? extends Number> 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();

View File

@ -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<String> languageChoisBox;
@FXML private ChoiceBox<String> 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<ActionEvent>() {
@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<ActionEvent>() {
@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<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
@ -506,7 +495,7 @@ public class MainWindowController {
}
});
gamesAnchorPane.addEventHandler(MouseEvent.MOUSE_CLICKED, new EventHandler<MouseEvent>() {
gamesFlowPane.addEventHandler(MouseEvent.MOUSE_CLICKED, new EventHandler<MouseEvent>() {
@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<ActionEvent> 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<MouseEvent>() {
@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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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

View File

@ -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;

View File

@ -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);

View File

@ -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
*/

View File

@ -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<Void> 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;
}
}

View File

@ -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<ActionEvent>() {
@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;
}
}

View File

@ -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;

View File

@ -23,13 +23,11 @@
<children>
<ScrollPane fx:id="mainScrollPane" fitToWidth="true" layoutY="38.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="38.0">
<content>
<AnchorPane fx:id="gamesAnchorPane">
<FlowPane fx:id="gamesFlowPane" hgap="3.0" vgap="7.0">
<padding>
<Insets bottom="17.0" />
</padding>
<children>
<FlowPane fx:id="gamesFlowPane" prefHeight="217.0" prefWidth="902.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
</children></AnchorPane>
</FlowPane>
</content>
</ScrollPane>
<HBox fx:id="topHBox" prefHeight="38.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">