rlease 0.3.3 #7
@ -148,7 +148,6 @@ public class Main extends Application {
|
|||||||
|
|
||||||
// init here as it loads the games to the mwc and the gui, therefore the window must exist
|
// init here as it loads the games to the mwc and the gui, therefore the window must exist
|
||||||
mainWindowController.init();
|
mainWindowController.init();
|
||||||
mainWindowController.getDbController().init();
|
|
||||||
|
|
||||||
// if cloud sync is activated start sync
|
// if cloud sync is activated start sync
|
||||||
if (XMLController.isCloudSync()) {
|
if (XMLController.isCloudSync()) {
|
||||||
|
@ -56,7 +56,7 @@ import com.cemu_UI.datatypes.CourseTableDataType;
|
|||||||
import com.cemu_UI.datatypes.GlobalDataTypes.CloudService;
|
import com.cemu_UI.datatypes.GlobalDataTypes.CloudService;
|
||||||
import com.cemu_UI.datatypes.SmmdbApiDataType;
|
import com.cemu_UI.datatypes.SmmdbApiDataType;
|
||||||
import com.cemu_UI.datatypes.UIROMDataType;
|
import com.cemu_UI.datatypes.UIROMDataType;
|
||||||
import com.cemu_UI.uiElements.JFXEditGameDialog;
|
import com.cemu_UI.uiElements.JFXEditGameAlert;
|
||||||
import com.cemu_UI.uiElements.JFXInfoAlert;
|
import com.cemu_UI.uiElements.JFXInfoAlert;
|
||||||
import com.cemu_UI.uiElements.JFXOkayCancelAlert;
|
import com.cemu_UI.uiElements.JFXOkayCancelAlert;
|
||||||
import com.cemu_UI.uiElements.JFXTextAreaAlert;
|
import com.cemu_UI.uiElements.JFXTextAreaAlert;
|
||||||
@ -187,7 +187,7 @@ public class MainWindowController {
|
|||||||
private boolean menuTrue = false;
|
private boolean menuTrue = false;
|
||||||
private boolean playTrue = false;
|
private boolean playTrue = false;
|
||||||
private String gameExecutePath;
|
private String gameExecutePath;
|
||||||
private String dialogBtnStyle;
|
private String btnStyle;
|
||||||
private String selectedGameTitleID;
|
private String selectedGameTitleID;
|
||||||
private String selectedGameTitle;
|
private String selectedGameTitle;
|
||||||
private String id;
|
private String id;
|
||||||
@ -216,21 +216,7 @@ public class MainWindowController {
|
|||||||
private ContextMenu gameContextMenu = new ContextMenu(edit, remove, addUpdate, addDLC);
|
private ContextMenu gameContextMenu = new ContextMenu(edit, remove, addUpdate, addDLC);
|
||||||
private Label lastGameLabel = new Label();
|
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
|
// language support
|
||||||
private ResourceBundle bundle;
|
|
||||||
private String language;
|
|
||||||
private String lastPlayed;
|
private String lastPlayed;
|
||||||
private String today;
|
private String today;
|
||||||
private String yesterday;
|
private String yesterday;
|
||||||
@ -239,7 +225,7 @@ public class MainWindowController {
|
|||||||
public MainWindowController(Main main) {
|
public MainWindowController(Main main) {
|
||||||
xmlController = new XMLController();
|
xmlController = new XMLController();
|
||||||
this.main = main;
|
this.main = main;
|
||||||
dbController = new DBController(this);
|
dbController = DBController.getInstance();
|
||||||
smmdbAPIController = new SmmdbAPIController();
|
smmdbAPIController = new SmmdbAPIController();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -252,6 +238,11 @@ public class MainWindowController {
|
|||||||
checkAutoUpdate();
|
checkAutoUpdate();
|
||||||
initUI();
|
initUI();
|
||||||
initActions();
|
initActions();
|
||||||
|
|
||||||
|
dbController.init();
|
||||||
|
dbController.refreshDataBase();
|
||||||
|
games = dbController.loadAllGames();
|
||||||
|
addAllGames();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -351,14 +342,14 @@ public class MainWindowController {
|
|||||||
String[] gameInfo = dbController.getGameInfo(selectedGameTitleID);
|
String[] gameInfo = dbController.getGameInfo(selectedGameTitleID);
|
||||||
|
|
||||||
// new edit dialog
|
// new edit dialog
|
||||||
String headingText = bundle.getString("editHeadingText") + " \"" + selectedGameTitle + "\"";
|
String headingText = XMLController.getLocalBundle().getString("editHeadingText") + " \"" + selectedGameTitle + "\"";
|
||||||
JFXEditGameDialog editGameDialog = new JFXEditGameDialog(headingText, bundle.getString("editBodyText"),
|
JFXEditGameAlert editGameAlert = new JFXEditGameAlert(headingText,
|
||||||
dialogBtnStyle, 450, 300, 1, MWC, primaryStage, main.getPane());
|
XMLController.getLocalBundle().getString("editBodyText"), btnStyle, 1, primaryStage, MWC);
|
||||||
editGameDialog.setTitle(gameInfo[0]);
|
editGameAlert.setTitle(gameInfo[0]);
|
||||||
editGameDialog.setCoverPath(gameInfo[1]);
|
editGameAlert.setCoverPath(gameInfo[1]);
|
||||||
editGameDialog.setRomPath(gameInfo[2]);
|
editGameAlert.setRomPath(gameInfo[2]);
|
||||||
editGameDialog.setTitleID(gameInfo[3]);
|
editGameAlert.setTitleID(gameInfo[3]);
|
||||||
editGameDialog.show();
|
editGameAlert.showAndWait();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.warn("trying to edit " + selectedGameTitleID + ",which is not a valid type!", e);
|
LOGGER.warn("trying to edit " + selectedGameTitleID + ",which is not a valid type!", e);
|
||||||
}
|
}
|
||||||
@ -367,10 +358,9 @@ public class MainWindowController {
|
|||||||
remove.setOnAction(event -> {
|
remove.setOnAction(event -> {
|
||||||
try {
|
try {
|
||||||
LOGGER.info("remove " + selectedGameTitle + "(" + selectedGameTitleID + ")");
|
LOGGER.info("remove " + selectedGameTitle + "(" + selectedGameTitleID + ")");
|
||||||
String headingText = bundle.getString("removeHeadingText") + " \"" + selectedGameTitle + "\"";
|
String headingText = XMLController.getLocalBundle().getString("removeHeadingText") + " \"" + selectedGameTitle + "\"";
|
||||||
String bodyText = bundle.getString("removeBodyText") + " " + selectedGameTitle + " ?";
|
String bodyText = XMLController.getLocalBundle().getString("removeBodyText") + " " + selectedGameTitle + " ?";
|
||||||
|
JFXOkayCancelAlert removeGameAlert = new JFXOkayCancelAlert(headingText, bodyText, btnStyle,
|
||||||
JFXOkayCancelAlert removeGameAlert = new JFXOkayCancelAlert(headingText, bodyText, dialogBtnStyle,
|
|
||||||
primaryStage);
|
primaryStage);
|
||||||
removeGameAlert.setOkayAction(e -> {
|
removeGameAlert.setOkayAction(e -> {
|
||||||
try {
|
try {
|
||||||
@ -411,10 +401,10 @@ public class MainWindowController {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
LOGGER.info("copying the content of " + updatePath + " to " + destDir.toString());
|
LOGGER.info("copying the content of " + updatePath + " to " + destDir.toString());
|
||||||
playBtn.setText(bundle.getString("playBtnUpdating"));
|
playBtn.setText(XMLController.getLocalBundle().getString("playBtnUpdating"));
|
||||||
playBtn.setDisable(true);
|
playBtn.setDisable(true);
|
||||||
FileUtils.copyDirectory(srcDir, destDir);
|
FileUtils.copyDirectory(srcDir, destDir);
|
||||||
playBtn.setText(bundle.getString("playBtnPlay"));
|
playBtn.setText(XMLController.getLocalBundle().getString("playBtnPlay"));
|
||||||
playBtn.setDisable(false);
|
playBtn.setDisable(false);
|
||||||
LOGGER.info("copying files done!");
|
LOGGER.info("copying files done!");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@ -430,9 +420,9 @@ public class MainWindowController {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
String headingText = bundle.getString("addUpdateHeadingText") + " \"" + selectedGameTitle + "\"";
|
String headingText = XMLController.getLocalBundle().getString("addUpdateHeadingText") + " \"" + selectedGameTitle + "\"";
|
||||||
JFXOkayCancelAlert updateGameAlert = new JFXOkayCancelAlert(headingText,
|
JFXOkayCancelAlert updateGameAlert = new JFXOkayCancelAlert(headingText,
|
||||||
bundle.getString("addUpdateBodyText"), dialogBtnStyle, primaryStage);
|
XMLController.getLocalBundle().getString("addUpdateBodyText"), btnStyle, primaryStage);
|
||||||
updateGameAlert.setOkayAction(okayAction);
|
updateGameAlert.setOkayAction(okayAction);
|
||||||
updateGameAlert.setCancelAction(cancelAction);
|
updateGameAlert.setCancelAction(cancelAction);
|
||||||
updateGameAlert.showAndWait();
|
updateGameAlert.showAndWait();
|
||||||
@ -447,7 +437,7 @@ public class MainWindowController {
|
|||||||
public void handle(ActionEvent event) {
|
public void handle(ActionEvent event) {
|
||||||
try {
|
try {
|
||||||
LOGGER.info("add DLC: " + selectedGameTitleID);
|
LOGGER.info("add DLC: " + selectedGameTitleID);
|
||||||
String headingText = bundle.getString("addDLCHeadingText") + " \"" + selectedGameTitle + "\"";
|
String headingText = XMLController.getLocalBundle().getString("addDLCHeadingText") + " \"" + selectedGameTitle + "\"";
|
||||||
EventHandler<ActionEvent> okayAction = new EventHandler<ActionEvent>() {
|
EventHandler<ActionEvent> okayAction = new EventHandler<ActionEvent>() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(ActionEvent event) {
|
public void handle(ActionEvent event) {
|
||||||
@ -465,10 +455,10 @@ public class MainWindowController {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
LOGGER.info("copying the content of " + dlcPath + " to " + destDir.toString());
|
LOGGER.info("copying the content of " + dlcPath + " to " + destDir.toString());
|
||||||
playBtn.setText(bundle.getString("playBtnCopyingFiles"));
|
playBtn.setText(XMLController.getLocalBundle().getString("playBtnCopyingFiles"));
|
||||||
playBtn.setDisable(true);
|
playBtn.setDisable(true);
|
||||||
FileUtils.copyDirectory(srcDir, destDir);
|
FileUtils.copyDirectory(srcDir, destDir);
|
||||||
playBtn.setText(bundle.getString("playBtnPlay"));
|
playBtn.setText(XMLController.getLocalBundle().getString("playBtnPlay"));
|
||||||
playBtn.setDisable(false);
|
playBtn.setDisable(false);
|
||||||
LOGGER.info("copying files done!");
|
LOGGER.info("copying files done!");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@ -485,7 +475,7 @@ public class MainWindowController {
|
|||||||
};
|
};
|
||||||
|
|
||||||
JFXOkayCancelAlert addDLCAlert = new JFXOkayCancelAlert(headingText,
|
JFXOkayCancelAlert addDLCAlert = new JFXOkayCancelAlert(headingText,
|
||||||
bundle.getString("addDLCBodyText"), dialogBtnStyle, primaryStage);
|
XMLController.getLocalBundle().getString("addDLCBodyText"), btnStyle, primaryStage);
|
||||||
addDLCAlert.setOkayAction(okayAction);
|
addDLCAlert.setOkayAction(okayAction);
|
||||||
addDLCAlert.setCancelAction(cancelAction);
|
addDLCAlert.setCancelAction(cancelAction);
|
||||||
addDLCAlert.showAndWait();
|
addDLCAlert.showAndWait();
|
||||||
@ -561,7 +551,7 @@ public class MainWindowController {
|
|||||||
smmdbImageView.setImage(scaledImage); // set imageview to image
|
smmdbImageView.setImage(scaledImage); // set imageview to image
|
||||||
} catch (MalformedURLException | URISyntaxException e) {
|
} catch (MalformedURLException | URISyntaxException e) {
|
||||||
LOGGER.warn("There was either a problem or no image!", e);
|
LOGGER.warn("There was either a problem or no image!", e);
|
||||||
smmdbImageView.setImage(close_black);
|
smmdbImageView.setImage(new Image("icons/close_black_2048x2048.png"));
|
||||||
}
|
}
|
||||||
addCourseDescription(courses.get(i));
|
addCourseDescription(courses.get(i));
|
||||||
}
|
}
|
||||||
@ -613,16 +603,16 @@ public class MainWindowController {
|
|||||||
LOGGER.error("Cloud not read the license file!", ex);
|
LOGGER.error("Cloud not read the license file!", ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
JFXTextAreaAlert licenseAlert = new JFXTextAreaAlert("cemu_UI", textAreaText, dialogBtnStyle, primaryStage);
|
JFXTextAreaAlert licenseAlert = new JFXTextAreaAlert("cemu_UI", textAreaText, btnStyle, primaryStage);
|
||||||
licenseAlert.showAndWait();
|
licenseAlert.showAndWait();
|
||||||
};
|
};
|
||||||
|
|
||||||
JFXOkayCancelAlert licenseOverviewAlert = new JFXOkayCancelAlert(
|
JFXOkayCancelAlert licenseOverviewAlert = new JFXOkayCancelAlert(
|
||||||
bundle.getString("licensesLblHeadingText"), bundle.getString("licensesLblBodyText"),
|
XMLController.getLocalBundle().getString("licensesLblHeadingText"),
|
||||||
dialogBtnStyle, primaryStage);
|
XMLController.getLocalBundle().getString("licensesLblBodyText"), btnStyle, primaryStage);
|
||||||
licenseOverviewAlert.setOkayAction(oE -> {});
|
licenseOverviewAlert.setOkayAction(oE -> {});
|
||||||
licenseOverviewAlert.setCancelAction(cancelAction);
|
licenseOverviewAlert.setCancelAction(cancelAction);
|
||||||
licenseOverviewAlert.setCancelText(bundle.getString("showLicenses"));
|
licenseOverviewAlert.setCancelText(XMLController.getLocalBundle().getString("showLicenses"));
|
||||||
licenseOverviewAlert.showAndWait();
|
licenseOverviewAlert.showAndWait();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -633,7 +623,7 @@ public class MainWindowController {
|
|||||||
xmlController.saveSettings();
|
xmlController.saveSettings();
|
||||||
} else {
|
} else {
|
||||||
String bodyText = newValue + ": No such file or directory";
|
String bodyText = newValue + ": No such file or directory";
|
||||||
JFXInfoAlert fileErrorDialog = new JFXInfoAlert("Waring!", bodyText, dialogBtnStyle, primaryStage);
|
JFXInfoAlert fileErrorDialog = new JFXInfoAlert("Waring!", bodyText, btnStyle, primaryStage);
|
||||||
fileErrorDialog.showAndWait();
|
fileErrorDialog.showAndWait();
|
||||||
LOGGER.warn(newValue + ": No such file or directory");
|
LOGGER.warn(newValue + ": No such file or directory");
|
||||||
}
|
}
|
||||||
@ -646,7 +636,7 @@ public class MainWindowController {
|
|||||||
reloadRoms();
|
reloadRoms();
|
||||||
} else {
|
} else {
|
||||||
String bodyText = newValue + ": No such file or directory";
|
String bodyText = newValue + ": No such file or directory";
|
||||||
JFXInfoAlert fileErrorDialog = new JFXInfoAlert("Waring!", bodyText, dialogBtnStyle, primaryStage);
|
JFXInfoAlert fileErrorDialog = new JFXInfoAlert("Waring!", bodyText, btnStyle, primaryStage);
|
||||||
fileErrorDialog.showAndWait();
|
fileErrorDialog.showAndWait();
|
||||||
LOGGER.warn(newValue + ": No such file or directory");
|
LOGGER.warn(newValue + ": No such file or directory");
|
||||||
}
|
}
|
||||||
@ -662,10 +652,11 @@ public class MainWindowController {
|
|||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private void aboutBtnAction() {
|
private void aboutBtnAction() {
|
||||||
String bodyText = "cemu_UI by @Seil0 \nVersion: " + version + " (" + buildNumber + ") \"" + versionName + "\" \n"
|
String bodyText = "cemu_UI by @Seil0 \nVersion: " + version + " (" + buildNumber + ") \"" + versionName
|
||||||
+ bundle.getString("aboutBtnBodyText");
|
+ "\" \n" + XMLController.getLocalBundle().getString("aboutBtnBodyText");
|
||||||
|
|
||||||
JFXInfoAlert infoAlert = new JFXInfoAlert(bundle.getString("aboutBtnHeadingText"), bodyText, dialogBtnStyle, primaryStage);
|
JFXInfoAlert infoAlert = new JFXInfoAlert(XMLController.getLocalBundle().getString("aboutBtnHeadingText"),
|
||||||
|
bodyText, btnStyle, primaryStage);
|
||||||
infoAlert.showAndWait();
|
infoAlert.showAndWait();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -694,7 +685,7 @@ public class MainWindowController {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
Platform.runLater(() -> {
|
Platform.runLater(() -> {
|
||||||
smmdbDownloadBtn.setText(bundle.getString("smmdbDownloadBtnLoading"));
|
smmdbDownloadBtn.setText(XMLController.getLocalBundle().getString("smmdbDownloadBtnLoading"));
|
||||||
smmdbDownloadBtn.setDisable(true);
|
smmdbDownloadBtn.setDisable(true);
|
||||||
root.getChildren().remove(0,root.getChildren().size());
|
root.getChildren().remove(0,root.getChildren().size());
|
||||||
});
|
});
|
||||||
@ -708,7 +699,7 @@ public class MainWindowController {
|
|||||||
|
|
||||||
Platform.runLater(() -> {
|
Platform.runLater(() -> {
|
||||||
root.getChildren().add(new TreeItem<CourseTableDataType>(helpCourse)); // add data to root-node
|
root.getChildren().add(new TreeItem<CourseTableDataType>(helpCourse)); // add data to root-node
|
||||||
smmdbDownloadBtn.setText(bundle.getString("smmdbDownloadBtnDownload"));
|
smmdbDownloadBtn.setText(XMLController.getLocalBundle().getString("smmdbDownloadBtnDownload"));
|
||||||
smmdbDownloadBtn.setDisable(false);
|
smmdbDownloadBtn.setDisable(false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -870,8 +861,8 @@ public class MainWindowController {
|
|||||||
|
|
||||||
// cloud sync init error dialog
|
// cloud sync init error dialog
|
||||||
JFXInfoAlert cloudSyncErrorDialog = new JFXInfoAlert(
|
JFXInfoAlert cloudSyncErrorDialog = new JFXInfoAlert(
|
||||||
bundle.getString("cloudSyncErrorHeadingText"),
|
XMLController.getLocalBundle().getString("cloudSyncErrorHeadingText"),
|
||||||
bundle.getString("cloudSyncErrorBodyText"), dialogBtnStyle, primaryStage);
|
XMLController.getLocalBundle().getString("cloudSyncErrorBodyText"), btnStyle, primaryStage);
|
||||||
cloudSyncErrorDialog.showAndWait();
|
cloudSyncErrorDialog.showAndWait();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -881,8 +872,8 @@ public class MainWindowController {
|
|||||||
};
|
};
|
||||||
|
|
||||||
JFXOkayCancelAlert cloudSyncWarningAlert = new JFXOkayCancelAlert(
|
JFXOkayCancelAlert cloudSyncWarningAlert = new JFXOkayCancelAlert(
|
||||||
bundle.getString("cloudSyncWaringHeadingText"), bundle.getString("cloudSyncWaringHeadingText"),
|
XMLController.getLocalBundle().getString("cloudSyncWaringHeadingText"),
|
||||||
dialogBtnStyle, primaryStage);
|
XMLController.getLocalBundle().getString("cloudSyncWaringHeadingText"), btnStyle, primaryStage);
|
||||||
cloudSyncWarningAlert.setOkayAction(okayAction);
|
cloudSyncWarningAlert.setOkayAction(okayAction);
|
||||||
cloudSyncWarningAlert.setCancelAction(e -> cloudSyncToggleBtn.setSelected(false));
|
cloudSyncWarningAlert.setCancelAction(e -> cloudSyncToggleBtn.setSelected(false));
|
||||||
cloudSyncWarningAlert.showAndWait();
|
cloudSyncWarningAlert.showAndWait();
|
||||||
@ -897,10 +888,10 @@ public class MainWindowController {
|
|||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private void addBtnAction() {
|
private void addBtnAction() {
|
||||||
JFXEditGameDialog addGameDialog = new JFXEditGameDialog(bundle.getString("addGameBtnHeadingText"),
|
JFXEditGameAlert addGameAlert = new JFXEditGameAlert(
|
||||||
bundle.getString("addGameBtnBodyText"), dialogBtnStyle, 450, 300, 0, this, primaryStage,
|
XMLController.getLocalBundle().getString("addGameBtnHeadingText"),
|
||||||
main.getPane());
|
XMLController.getLocalBundle().getString("addGameBtnBodyText"), btnStyle, 0, primaryStage, MWC);
|
||||||
addGameDialog.show();
|
addGameAlert.showAndWait();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -916,9 +907,10 @@ public class MainWindowController {
|
|||||||
if (romPath.length() == 0 || coverPath.length() == 0 || title.length() == 0 || titleID.length() == 0) {
|
if (romPath.length() == 0 || coverPath.length() == 0 || title.length() == 0 || titleID.length() == 0) {
|
||||||
LOGGER.info("No parameter set!");
|
LOGGER.info("No parameter set!");
|
||||||
|
|
||||||
//addGame error dialog
|
// addGame error dialog
|
||||||
JFXInfoAlert errorAlert = new JFXInfoAlert(bundle.getString("addBtnReturnErrorHeadingText"),
|
JFXInfoAlert errorAlert = new JFXInfoAlert(
|
||||||
bundle.getString("addBtnReturnErrorBodyText"), dialogBtnStyle, primaryStage);
|
XMLController.getLocalBundle().getString("addBtnReturnErrorHeadingText"),
|
||||||
|
XMLController.getLocalBundle().getString("addBtnReturnErrorBodyText"), btnStyle, primaryStage);
|
||||||
errorAlert.showAndWait();
|
errorAlert.showAndWait();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -936,7 +928,8 @@ public class MainWindowController {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
dbController.addGame(title, coverPath, romPath, titleID, "", "", "", "0");
|
dbController.addGame(title, coverPath, romPath, titleID, "", "", "", "0");
|
||||||
dbController.loadSingleGame(titleID);
|
games.add(dbController.loadSingleGame(titleID));
|
||||||
|
addGame(games.stream().filter(x -> x.getRomPath().equals(romPath)).findFirst().orElse(null));
|
||||||
if (menuTrue) {
|
if (menuTrue) {
|
||||||
sideMenuSlideOut();
|
sideMenuSlideOut();
|
||||||
burgerTask.setRate(-1.0);
|
burgerTask.setRate(-1.0);
|
||||||
@ -953,7 +946,8 @@ public class MainWindowController {
|
|||||||
public void editBtnReturn(String title, String coverPath, String romPath, String titleID) {
|
public void editBtnReturn(String title, String coverPath, String romPath, String titleID) {
|
||||||
dbController.setGameInfo(title, coverPath, romPath, titleID);
|
dbController.setGameInfo(title, coverPath, romPath, titleID);
|
||||||
games.remove(selectedUIDataIndex);
|
games.remove(selectedUIDataIndex);
|
||||||
dbController.loadSingleGame(titleID);
|
games.add(dbController.loadSingleGame(titleID));
|
||||||
|
addGame(games.stream().filter(x -> x.getRomPath().equals(romPath)).findFirst().orElse(null));
|
||||||
refreshUIData();
|
refreshUIData();
|
||||||
|
|
||||||
LOGGER.info("successfully edited " + titleID + ", new name is \"" + title + "\"");
|
LOGGER.info("successfully edited " + titleID + ", new name is \"" + title + "\"");
|
||||||
@ -967,7 +961,7 @@ public class MainWindowController {
|
|||||||
* @param titleID : game ID
|
* @param titleID : game ID
|
||||||
*/
|
*/
|
||||||
public void addGame(String title, String coverPath, String romPath, String titleID){
|
public void addGame(String title, String coverPath, String romPath, String titleID){
|
||||||
UIROMDataType uiROMElement = new UIROMDataType(titleID, romPath, title, coverPath, gameContextMenu);
|
UIROMDataType uiROMElement = new UIROMDataType(romPath, titleID, title, coverPath, gameContextMenu);
|
||||||
|
|
||||||
uiROMElement.getButton().addEventHandler(MouseEvent.MOUSE_CLICKED, new EventHandler<MouseEvent>() {
|
uiROMElement.getButton().addEventHandler(MouseEvent.MOUSE_CLICKED, new EventHandler<MouseEvent>() {
|
||||||
@Override
|
@Override
|
||||||
@ -1038,6 +1032,85 @@ public class MainWindowController {
|
|||||||
games.add(uiROMElement);
|
games.add(uiROMElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* add the context menu and button action for all games
|
||||||
|
*/
|
||||||
|
private void addAllGames() {
|
||||||
|
for (UIROMDataType game : games) {
|
||||||
|
addGame(game);
|
||||||
|
}
|
||||||
|
|
||||||
|
refreshUIData(); // refresh the list of games displayed on screen
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* add the context menu and button action for one game
|
||||||
|
* @param game a game
|
||||||
|
*/
|
||||||
|
private void addGame(UIROMDataType game) {
|
||||||
|
game.getButton().setContextMenu(gameContextMenu);
|
||||||
|
game.getButton().addEventHandler(MouseEvent.MOUSE_CLICKED, (event) -> {
|
||||||
|
LOGGER.info("selected: " + game.getLabel().getText() + "; ID: " + game.getTitleID());
|
||||||
|
// 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 = game.getRomPath();
|
||||||
|
selectedGameTitleID = game.getTitleID();
|
||||||
|
selectedGameTitle = game.getName();
|
||||||
|
|
||||||
|
// 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(game.getTitleID()).equals("") || dbController.getLastPlayed(game.getTitleID()).equals(null)) {
|
||||||
|
lastTimePlayedBtn.setText(lastPlayed + never);
|
||||||
|
totalPlaytimeBtn.setText(dbController.getTotalPlaytime(game.getTitleID()) + " 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(game.getTitleID()).replaceAll("-", ""));
|
||||||
|
|
||||||
|
if (tLastPlayedDay == tToday) {
|
||||||
|
lastTimePlayedBtn.setText(lastPlayed + today);
|
||||||
|
} else if (tLastPlayedDay == tYesterday) {
|
||||||
|
lastTimePlayedBtn.setText(lastPlayed + yesterday);
|
||||||
|
} else {
|
||||||
|
lastTimePlayedBtn.setText(lastPlayed + dbController.getLastPlayed(game.getTitleID()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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(game.getTitleID())) > 60) {
|
||||||
|
int hoursPlayed = (int) Math.floor(Integer.parseInt(dbController.getTotalPlaytime(game.getTitleID())) / 60);
|
||||||
|
int minutesPlayed = Integer.parseInt(dbController.getTotalPlaytime(game.getTitleID())) - 60 * hoursPlayed;
|
||||||
|
totalPlaytimeBtn.setText(hoursPlayed + " h " + minutesPlayed + " min");
|
||||||
|
} else {
|
||||||
|
totalPlaytimeBtn.setText(dbController.getTotalPlaytime(game.getTitleID()) + " min");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!playTrue) {
|
||||||
|
playBtnSlideIn();
|
||||||
|
}
|
||||||
|
if (menuTrue) {
|
||||||
|
sideMenuSlideOut();
|
||||||
|
burgerTask.setRate(-1.0);
|
||||||
|
burgerTask.play();
|
||||||
|
menuTrue = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* reload all ROMs from the ROM directory
|
* reload all ROMs from the ROM directory
|
||||||
*/
|
*/
|
||||||
@ -1055,10 +1128,10 @@ public class MainWindowController {
|
|||||||
|
|
||||||
dbController.loadRomDirectory(XMLController.getRomDirectoryPath()); // reload the ROM directory
|
dbController.loadRomDirectory(XMLController.getRomDirectoryPath()); // reload the ROM directory
|
||||||
games.clear(); // remove all games from the mwc game list
|
games.clear(); // remove all games from the mwc game list
|
||||||
dbController.loadAllGames(); // load all games from the database to the mwc
|
games = dbController.loadAllGames();
|
||||||
|
addAllGames();
|
||||||
|
|
||||||
Platform.runLater(() -> {
|
Platform.runLater(() -> {
|
||||||
refreshUIData(); // refresh the list of games displayed on screen
|
|
||||||
mainAnchorPane.getChildren().remove(spinner);
|
mainAnchorPane.getChildren().remove(spinner);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -1077,58 +1150,55 @@ public class MainWindowController {
|
|||||||
switch (XMLController.getUsrLocal()) {
|
switch (XMLController.getUsrLocal()) {
|
||||||
case "en_US":
|
case "en_US":
|
||||||
XMLController.setLocalBundle(ResourceBundle.getBundle("locals.cemu_UI-Local", Locale.US)); // us_English
|
XMLController.setLocalBundle(ResourceBundle.getBundle("locals.cemu_UI-Local", Locale.US)); // us_English
|
||||||
bundle = ResourceBundle.getBundle("locals.cemu_UI-Local", Locale.US); // us_English
|
|
||||||
languageChoisBox.getSelectionModel().select(0);
|
languageChoisBox.getSelectionModel().select(0);
|
||||||
break;
|
break;
|
||||||
case "de_DE":
|
case "de_DE":
|
||||||
XMLController.setLocalBundle(ResourceBundle.getBundle("locals.cemu_UI-Local", Locale.GERMAN)); // German
|
XMLController.setLocalBundle(ResourceBundle.getBundle("locals.cemu_UI-Local", Locale.GERMAN)); // German
|
||||||
bundle = ResourceBundle.getBundle("locals.cemu_UI-Local", Locale.GERMAN); // German
|
|
||||||
languageChoisBox.getSelectionModel().select(1);
|
languageChoisBox.getSelectionModel().select(1);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
XMLController.setLocalBundle(ResourceBundle.getBundle("locals.cemu_UI-Local", Locale.US)); // default local
|
XMLController.setLocalBundle(ResourceBundle.getBundle("locals.cemu_UI-Local", Locale.US)); // default local
|
||||||
bundle = ResourceBundle.getBundle("locals.cemu_UI-Local", Locale.US); // default local
|
|
||||||
languageChoisBox.getSelectionModel().select(0);
|
languageChoisBox.getSelectionModel().select(0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Buttons
|
// Buttons
|
||||||
aboutBtn.setText(bundle.getString("aboutBtn"));
|
aboutBtn.setText(XMLController.getLocalBundle().getString("aboutBtn"));
|
||||||
settingsBtn.setText(bundle.getString("settingsBtn"));
|
settingsBtn.setText(XMLController.getLocalBundle().getString("settingsBtn"));
|
||||||
addBtn.setText(bundle.getString("addBtn"));
|
addBtn.setText(XMLController.getLocalBundle().getString("addBtn"));
|
||||||
reloadRomsBtn.setText(bundle.getString("reloadRomsBtn"));
|
reloadRomsBtn.setText(XMLController.getLocalBundle().getString("reloadRomsBtn"));
|
||||||
smmdbBtn.setText(bundle.getString("smmdbBtn"));
|
smmdbBtn.setText(XMLController.getLocalBundle().getString("smmdbBtn"));
|
||||||
cemuTFBtn.setText(bundle.getString("cemuTFBtn"));
|
cemuTFBtn.setText(XMLController.getLocalBundle().getString("cemuTFBtn"));
|
||||||
romTFBtn.setText(bundle.getString("romTFBtn"));
|
romTFBtn.setText(XMLController.getLocalBundle().getString("romTFBtn"));
|
||||||
updateBtn.setText(bundle.getString("updateBtnCheckNow"));
|
updateBtn.setText(XMLController.getLocalBundle().getString("updateBtnCheckNow"));
|
||||||
smmdbDownloadBtn.setText(bundle.getString("smmdbDownloadBtn"));
|
smmdbDownloadBtn.setText(XMLController.getLocalBundle().getString("smmdbDownloadBtn"));
|
||||||
playBtn.setText(bundle.getString("playBtn"));
|
playBtn.setText(XMLController.getLocalBundle().getString("playBtn"));
|
||||||
cloudSyncToggleBtn.setText(bundle.getString("cloudSyncToggleBtn"));
|
cloudSyncToggleBtn.setText(XMLController.getLocalBundle().getString("cloudSyncToggleBtn"));
|
||||||
autoUpdateToggleBtn.setText(bundle.getString("autoUpdateToggleBtn"));
|
autoUpdateToggleBtn.setText(XMLController.getLocalBundle().getString("autoUpdateToggleBtn"));
|
||||||
fullscreenToggleBtn.setText(bundle.getString("fullscreenToggleBtn"));
|
fullscreenToggleBtn.setText(XMLController.getLocalBundle().getString("fullscreenToggleBtn"));
|
||||||
|
|
||||||
// Labels
|
// Labels
|
||||||
cemu_UISettingsLbl.setText(bundle.getString("cemu_UISettingsLbl"));
|
cemu_UISettingsLbl.setText(XMLController.getLocalBundle().getString("cemu_UISettingsLbl"));
|
||||||
cemuDirectoryLbl.setText(bundle.getString("cemuDirectoryLbl"));
|
cemuDirectoryLbl.setText(XMLController.getLocalBundle().getString("cemuDirectoryLbl"));
|
||||||
romDirectoryLbl.setText(bundle.getString("romDirectoryLbl"));
|
romDirectoryLbl.setText(XMLController.getLocalBundle().getString("romDirectoryLbl"));
|
||||||
mainColorLbl.setText(bundle.getString("mainColorLbl"));
|
mainColorLbl.setText(XMLController.getLocalBundle().getString("mainColorLbl"));
|
||||||
languageLbl.setText(bundle.getString("languageLbl"));
|
languageLbl.setText(XMLController.getLocalBundle().getString("languageLbl"));
|
||||||
updateLbl.setText(bundle.getString("updateLbl"));
|
updateLbl.setText(XMLController.getLocalBundle().getString("updateLbl"));
|
||||||
branchLbl.setText(bundle.getString("branchLbl"));
|
branchLbl.setText(XMLController.getLocalBundle().getString("branchLbl"));
|
||||||
cemuSettingsLbl.setText(bundle.getString("cemuSettingsLbl"));
|
cemuSettingsLbl.setText(XMLController.getLocalBundle().getString("cemuSettingsLbl"));
|
||||||
licensesLbl.setText(bundle.getString("licensesLbl"));
|
licensesLbl.setText(XMLController.getLocalBundle().getString("licensesLbl"));
|
||||||
|
|
||||||
// Columns
|
// Columns
|
||||||
titleColumn.setText(bundle.getString("titleColumn"));
|
titleColumn.setText(XMLController.getLocalBundle().getString("titleColumn"));
|
||||||
idColumn.setText(bundle.getString("idColumn"));
|
idColumn.setText(XMLController.getLocalBundle().getString("idColumn"));
|
||||||
starsColumn.setText(bundle.getString("starsColumn"));
|
starsColumn.setText(XMLController.getLocalBundle().getString("starsColumn"));
|
||||||
timeColumn.setText(bundle.getString("timeColumn"));
|
timeColumn.setText(XMLController.getLocalBundle().getString("timeColumn"));
|
||||||
|
|
||||||
// Strings
|
// Strings
|
||||||
lastPlayed = bundle.getString("lastPlayed");
|
lastPlayed = XMLController.getLocalBundle().getString("lastPlayed");
|
||||||
today = bundle.getString("today");
|
today = XMLController.getLocalBundle().getString("today");
|
||||||
yesterday = bundle.getString("yesterday");
|
yesterday = XMLController.getLocalBundle().getString("yesterday");
|
||||||
never = bundle.getString("never");
|
never = XMLController.getLocalBundle().getString("never");
|
||||||
}
|
}
|
||||||
|
|
||||||
// if AutoUpdate, then check for updates
|
// if AutoUpdate, then check for updates
|
||||||
@ -1271,8 +1341,7 @@ public class MainWindowController {
|
|||||||
// change the color of all needed GUI elements
|
// change the color of all needed GUI elements
|
||||||
private void applyColor() {
|
private void applyColor() {
|
||||||
String boxStyle = "-fx-background-color: #" + XMLController.getColor() + ";";
|
String boxStyle = "-fx-background-color: #" + XMLController.getColor() + ";";
|
||||||
String btnStyleBlack = "-fx-button-type: RAISED; -fx-background-color: #" + XMLController.getColor() + "; -fx-text-fill: BLACK;";
|
String textFill = "";
|
||||||
String btnStyleWhite = "-fx-button-type: RAISED; -fx-background-color: #" + XMLController.getColor() + "; -fx-text-fill: WHITE;";
|
|
||||||
BigInteger icolor = new BigInteger(XMLController.getColor(),16);
|
BigInteger icolor = new BigInteger(XMLController.getColor(),16);
|
||||||
BigInteger ccolor = new BigInteger("78909cff",16);
|
BigInteger ccolor = new BigInteger("78909cff",16);
|
||||||
|
|
||||||
@ -1282,55 +1351,45 @@ public class MainWindowController {
|
|||||||
romTextField.setFocusColor(Color.valueOf(XMLController.getColor()));
|
romTextField.setFocusColor(Color.valueOf(XMLController.getColor()));
|
||||||
|
|
||||||
if (icolor.compareTo(ccolor) == -1) {
|
if (icolor.compareTo(ccolor) == -1) {
|
||||||
dialogBtnStyle = btnStyleWhite;
|
textFill = "-fx-text-fill: WHITE;";
|
||||||
|
|
||||||
aboutBtn.setStyle("-fx-text-fill: WHITE;");
|
aboutBtn.setGraphic(new ImageView(new Image("icons/ic_info_white_24dp_1x.png")));
|
||||||
settingsBtn.setStyle("-fx-text-fill: WHITE;");
|
settingsBtn.setGraphic(new ImageView(new Image("icons/ic_settings_white_24dp_1x.png")));
|
||||||
addBtn.setStyle("-fx-text-fill: WHITE;");
|
addBtn.setGraphic(new ImageView(new Image("icons/ic_add_circle_white_24dp_1x.png")));
|
||||||
reloadRomsBtn.setStyle("-fx-text-fill: WHITE;");
|
reloadRomsBtn.setGraphic(new ImageView(new Image("icons/ic_cached_white_24dp_1x.png")));
|
||||||
smmdbBtn.setStyle("-fx-text-fill: WHITE;");
|
smmdbBtn.setGraphic(new ImageView(new Image("icons/ic_get_app_white_24dp_1x.png")));
|
||||||
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().clear();
|
||||||
menuHam.getStyleClass().add("jfx-hamburgerW");
|
menuHam.getStyleClass().add("jfx-hamburgerW");
|
||||||
} else {
|
} else {
|
||||||
dialogBtnStyle = btnStyleBlack;
|
textFill = "-fx-text-fill: BLACK;";
|
||||||
|
|
||||||
aboutBtn.setStyle("-fx-text-fill: BLACK;");
|
aboutBtn.setGraphic(new ImageView(new Image("icons/ic_info_black_24dp_1x.png")));
|
||||||
settingsBtn.setStyle("-fx-text-fill: BLACK;");
|
settingsBtn.setGraphic(new ImageView(new Image("icons/ic_settings_black_24dp_1x.png")));
|
||||||
addBtn.setStyle("-fx-text-fill: BLACK;");
|
addBtn.setGraphic(new ImageView(new Image("icons/ic_add_circle_black_24dp_1x.png")));
|
||||||
reloadRomsBtn.setStyle("-fx-text-fill: BLACK;");
|
reloadRomsBtn.setGraphic(new ImageView(new Image("icons/ic_cached_black_24dp_1x.png")));
|
||||||
smmdbBtn.setStyle("-fx-text-fill: BLACK;");
|
smmdbBtn.setGraphic(new ImageView(new Image("icons/ic_get_app_black_24dp_1x.png")));
|
||||||
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().clear();
|
||||||
menuHam.getStyleClass().add("jfx-hamburgerB");
|
menuHam.getStyleClass().add("jfx-hamburgerB");
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < games.size(); i++) {
|
btnStyle = "-fx-button-type: RAISED; -fx-background-color: #" + XMLController.getColor() + "; " + textFill;
|
||||||
games.get(i).getButton().setRipplerFill(Paint.valueOf(XMLController.getColor()));
|
|
||||||
|
aboutBtn.setStyle(textFill);
|
||||||
|
settingsBtn.setStyle(textFill);
|
||||||
|
addBtn.setStyle(textFill);
|
||||||
|
reloadRomsBtn.setStyle(textFill);
|
||||||
|
smmdbBtn.setStyle(textFill);
|
||||||
|
playBtn.setStyle(textFill);
|
||||||
|
cemuTFBtn.setStyle(btnStyle);
|
||||||
|
romTFBtn.setStyle(btnStyle);
|
||||||
|
updateBtn.setStyle(btnStyle);
|
||||||
|
smmdbDownloadBtn.setStyle(btnStyle);
|
||||||
|
playBtn.setStyle(btnStyle);
|
||||||
|
|
||||||
|
for(UIROMDataType game : games) {
|
||||||
|
game.getButton().setRipplerFill(Paint.valueOf(XMLController.getColor()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1412,10 +1471,6 @@ public class MainWindowController {
|
|||||||
return main;
|
return main;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DBController getDbController() {
|
|
||||||
return dbController;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Stage getPrimaryStage() {
|
public Stage getPrimaryStage() {
|
||||||
return primaryStage;
|
return primaryStage;
|
||||||
}
|
}
|
||||||
@ -1444,18 +1499,6 @@ public class MainWindowController {
|
|||||||
this.playBtn = playBtn;
|
this.playBtn = playBtn;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getLanguage() {
|
|
||||||
return language;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLanguage(String language) {
|
|
||||||
this.language = language;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ResourceBundle getBundle() {
|
|
||||||
return bundle;
|
|
||||||
}
|
|
||||||
|
|
||||||
public AnchorPane getMainAnchorPane() {
|
public AnchorPane getMainAnchorPane() {
|
||||||
return mainAnchorPane;
|
return mainAnchorPane;
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,8 @@ import net.lingala.zip4j.exception.ZipException;
|
|||||||
|
|
||||||
public class CloudController {
|
public class CloudController {
|
||||||
|
|
||||||
|
// TODO make singleton
|
||||||
|
|
||||||
public CloudController(MainWindowController mwc) {
|
public CloudController(MainWindowController mwc) {
|
||||||
this.mwc = mwc;
|
this.mwc = mwc;
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,7 @@ import java.io.IOException;
|
|||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.DriverManager;
|
import java.sql.DriverManager;
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.sql.Statement;
|
import java.sql.Statement;
|
||||||
@ -45,92 +46,94 @@ import org.apache.logging.log4j.Logger;
|
|||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
import com.cemu_UI.application.MainWindowController;
|
import com.cemu_UI.datatypes.UIROMDataType;
|
||||||
|
|
||||||
|
import javafx.collections.FXCollections;
|
||||||
|
import javafx.collections.ObservableList;
|
||||||
|
|
||||||
public class DBController {
|
public class DBController {
|
||||||
|
|
||||||
public DBController(MainWindowController mainWindowController) {
|
private static DBController instance = null;
|
||||||
this.mainWindowController = mainWindowController;
|
|
||||||
}
|
|
||||||
|
|
||||||
private MainWindowController mainWindowController;
|
|
||||||
private ArrayList<String> entries = new ArrayList<>();
|
private ArrayList<String> entries = new ArrayList<>();
|
||||||
private String DB_PATH_localRoms;
|
private String DB_PATH_LocalGames;
|
||||||
private String DB_PATH_games;
|
private String DB_PATH_ReverenceGames;
|
||||||
private Connection connection = null;
|
private Connection connectionLocal = null;
|
||||||
private Connection connectionGames = null;
|
private Connection connectionReverence = null;
|
||||||
private static final Logger LOGGER = LogManager.getLogger(DBController.class.getName());
|
private static final Logger LOGGER = LogManager.getLogger(DBController.class.getName());
|
||||||
|
|
||||||
/**
|
public DBController() {
|
||||||
* initialize the sqlite database controller
|
|
||||||
* load ROM and games database
|
}
|
||||||
* load all games
|
|
||||||
*/
|
public static DBController getInstance() {
|
||||||
public void init() {
|
if (instance == null) {
|
||||||
LOGGER.info("<========== starting loading sql ==========>");
|
instance = new DBController();
|
||||||
loadRomDatabase();
|
}
|
||||||
loadGamesDatabase();
|
|
||||||
createRomDatabase();
|
return instance;
|
||||||
LOGGER.info("<========== finished loading sql ==========>");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set the path to the localRoms.db file and initialize the connection
|
* initialize the {@link DBController} with the database connection check if
|
||||||
|
* there is a need to create a new database refresh the database
|
||||||
|
*/
|
||||||
|
public void init() {
|
||||||
|
initDatabaseConnection();
|
||||||
|
createRomDatabase();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* create a new connection to the HomeFlix.db database
|
||||||
|
* AutoCommit is set to false to prevent some issues, so manual commit is active!
|
||||||
*
|
*
|
||||||
* TODO this should be called LocalGames
|
* TODO this should be called LocalGames
|
||||||
*/
|
*/
|
||||||
private void loadRomDatabase() {
|
private void initDatabaseConnection() {
|
||||||
if (System.getProperty("os.name").equals("Linux")) {
|
DB_PATH_LocalGames = XMLController.getDirCemuUI() + "/localRoms.db";
|
||||||
DB_PATH_localRoms = System.getProperty("user.home") + "/cemu_UI/localRoms.db";
|
DB_PATH_ReverenceGames = XMLController.getRference_gamesFile().getAbsolutePath();
|
||||||
} else {
|
|
||||||
DB_PATH_localRoms = System.getProperty("user.home") + "\\Documents\\cemu_UI" + "\\" + "localRoms.db";
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
// create a database connection
|
// create a database connection
|
||||||
connection = DriverManager.getConnection("jdbc:sqlite:" + DB_PATH_localRoms);
|
connectionLocal = DriverManager.getConnection("jdbc:sqlite:" + DB_PATH_LocalGames);
|
||||||
connection.setAutoCommit(false); // AutoCommit to false -> manual commit is active
|
connectionLocal.setAutoCommit(false);
|
||||||
} 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");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
connectionReverence = DriverManager.getConnection("jdbc:sqlite:" + DB_PATH_ReverenceGames);
|
||||||
* set the path to the localRoms.db file and initialize the connection
|
connectionReverence.setAutoCommit(false);
|
||||||
* games.db contains a reverence list to for the automatic detection mode
|
|
||||||
*/
|
|
||||||
private void loadGamesDatabase() {
|
|
||||||
DB_PATH_games = XMLController.getRference_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) {
|
} catch (SQLException e) {
|
||||||
LOGGER.error("error while loading the games database", e);
|
// if the error message is "out of memory", it probably means no database file is found
|
||||||
|
LOGGER.error("error while loading the Local- or ReverenceGames database", e);
|
||||||
}
|
}
|
||||||
LOGGER.info("games database loaded successfull");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
LOGGER.info("Local- and ReverenceGames database loaded successfull");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* creating the local_roms table in localRoms.db
|
* creating the local_roms table in localRoms.db
|
||||||
* if the table has no entries, call loadRomDirectory
|
* if the table has no entries, call loadRomDirectory
|
||||||
*
|
*
|
||||||
* TODO the local_roms table should be called local_games
|
* TODO the local_roms table should be called LocalGames
|
||||||
*/
|
*/
|
||||||
void createRomDatabase() {
|
void createRomDatabase() {
|
||||||
try {
|
try {
|
||||||
Statement stmt = connection.createStatement();
|
Statement stmt = connectionLocal.createStatement();
|
||||||
stmt.executeUpdate("create table if not exists local_roms (title, coverPath, romPath, titleID, productCode, region, lastPlayed, timePlayed)");
|
stmt.executeUpdate("create table if not exists local_roms (title, coverPath, romPath, titleID, productCode, region, lastPlayed, timePlayed)");
|
||||||
|
connectionLocal.commit();
|
||||||
stmt.close();
|
stmt.close();
|
||||||
connection.commit();
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
LOGGER.error("error while creating ROM database", e);
|
LOGGER.error("error while creating local-games database", e);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* refresh database to contain all (new added) games
|
||||||
|
*/
|
||||||
|
public void refreshDataBase() {
|
||||||
|
LOGGER.info("<========== starting refreshing database ==========>");
|
||||||
|
|
||||||
|
entries.clear();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Statement stmt = connection.createStatement();
|
Statement stmt = connectionLocal.createStatement();
|
||||||
ResultSet rs = stmt.executeQuery("SELECT * FROM local_roms");
|
ResultSet rs = stmt.executeQuery("SELECT * FROM local_roms");
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
entries.add(rs.getString(2));
|
entries.add(rs.getString(2));
|
||||||
@ -140,63 +143,80 @@ public class DBController {
|
|||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
LOGGER.error("error while loading ROMs from ROM database, local_roms table", e);
|
LOGGER.error("error while loading ROMs from ROM database, local_roms table", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entries.size() == 0) {
|
if (entries.size() == 0) {
|
||||||
mainWindowController.reloadRoms();
|
|
||||||
} else {
|
|
||||||
loadAllGames();
|
loadAllGames();
|
||||||
mainWindowController.refreshUIData();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LOGGER.info("<========== finished refreshing database ==========>");
|
||||||
}
|
}
|
||||||
|
|
||||||
// add a game to the database
|
// 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{
|
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();
|
Statement stmt = connectionLocal.createStatement();
|
||||||
stmt.executeUpdate("insert into local_roms values ('"+title+"','"+coverPath+"','"+romPath+"','"+titleID+"',"
|
stmt.executeUpdate("insert into local_roms values ('"+title+"','"+coverPath+"','"+romPath+"','"+titleID+"',"
|
||||||
+ "'"+productCode+"','"+region+"','"+lastPlayed+"','"+timePlayed+"')");
|
+ "'"+productCode+"','"+region+"','"+lastPlayed+"','"+timePlayed+"')");
|
||||||
connection.commit();
|
connectionLocal.commit();
|
||||||
stmt.close();
|
stmt.close();
|
||||||
LOGGER.info("added \""+title+"\" to ROM database");
|
LOGGER.info("added \""+title+"\" to ROM database");
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove a game from the database
|
// remove a game from the database
|
||||||
public void removeGame(String titleID) throws SQLException{
|
public void removeGame(String titleID) throws SQLException{
|
||||||
Statement stmt = connection.createStatement();
|
Statement stmt = connectionLocal.createStatement();
|
||||||
stmt.executeUpdate("delete from local_roms where titleID = '"+titleID+"'");
|
stmt.executeUpdate("delete from local_roms where titleID = '"+titleID+"'");
|
||||||
connection.commit();
|
connectionLocal.commit();
|
||||||
stmt.close();
|
stmt.close();
|
||||||
LOGGER.info("removed \""+titleID+"\" from ROM database");
|
LOGGER.info("removed \""+titleID+"\" from ROM database");
|
||||||
}
|
}
|
||||||
|
|
||||||
//load all ROMs to the mainWindowController
|
/**
|
||||||
public void loadAllGames(){
|
* load all games from the database to a ObservableList, order entries by title
|
||||||
LOGGER.info("loading all games on startup into the mainWindowController ...");
|
* @return a ObservableList that contains all local games from the database
|
||||||
|
*/
|
||||||
|
public ObservableList<UIROMDataType> loadAllGames() {
|
||||||
|
ObservableList<UIROMDataType> games = FXCollections.observableArrayList();
|
||||||
|
LOGGER.info("loading all local games from the database ...");
|
||||||
try {
|
try {
|
||||||
Statement stmt = connection.createStatement();
|
Statement stmt = connectionLocal.createStatement();
|
||||||
ResultSet rs = stmt.executeQuery("SELECT * FROM local_roms");
|
ResultSet rs = stmt.executeQuery("SELECT * FROM local_roms");
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
mainWindowController.addGame(rs.getString(1), rs.getString(2), rs.getString(3), rs.getString(4));
|
games.add(new UIROMDataType(rs.getString("romPath"), rs.getString("titleID"), rs.getString("title"),
|
||||||
|
rs.getString("coverPath")));
|
||||||
}
|
}
|
||||||
stmt.close();
|
stmt.close();
|
||||||
rs.close();
|
rs.close();
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
LOGGER.error("error while loading all games into the mainWindowController", e);
|
LOGGER.error("error while loading all local games from the database", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return games;
|
||||||
}
|
}
|
||||||
|
|
||||||
//load a single ROM to the mainWindowController
|
/**
|
||||||
public void loadSingleGame(String titleID){
|
* load one game from the database
|
||||||
LOGGER.info("loading a single game (ID: "+titleID+") into the mainWindowController ...");
|
* @param titleID the titleID of the game you wish to get
|
||||||
|
* @return the game you asked for
|
||||||
|
*/
|
||||||
|
public UIROMDataType loadSingleGame(String titleID) {
|
||||||
|
UIROMDataType game = null;
|
||||||
|
LOGGER.info("loading a single game (ID: {}) from the database ...", titleID);
|
||||||
try {
|
try {
|
||||||
Statement stmt = connection.createStatement();
|
PreparedStatement ps = connectionLocal.prepareStatement("SELECT * FROM local_roms where titleID = ?");
|
||||||
ResultSet rs = stmt.executeQuery("SELECT * FROM local_roms where titleID = '"+titleID+"'");
|
ps.setString(1, titleID);
|
||||||
|
ResultSet rs = ps.executeQuery();
|
||||||
|
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
mainWindowController.addGame(rs.getString(1), rs.getString(2), rs.getString(3), rs.getString(4));
|
game = new UIROMDataType(rs.getString("romPath"), rs.getString("titleID"), rs.getString("title"),
|
||||||
|
rs.getString("coverPath"));
|
||||||
}
|
}
|
||||||
stmt.close();
|
|
||||||
rs.close();
|
rs.close();
|
||||||
|
ps.close();
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
LOGGER.error("error while loading a single game into the mainWindowController", e);
|
LOGGER.error("error while loading a single game into the mainWindowController", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return game;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -210,7 +230,7 @@ public class DBController {
|
|||||||
File pictureCache = XMLController.getPictureCache();
|
File pictureCache = XMLController.getPictureCache();
|
||||||
String coverPath;
|
String coverPath;
|
||||||
try {
|
try {
|
||||||
Statement stmt = connectionGames.createStatement();
|
Statement stmt = connectionReverence.createStatement();
|
||||||
List<File> files = (List<File>) FileUtils.listFiles(dir, extensions, true);
|
List<File> files = (List<File>) FileUtils.listFiles(dir, extensions, true);
|
||||||
LOGGER.info("<============================== start loading ROM Directory ==============================>");
|
LOGGER.info("<============================== start loading ROM Directory ==============================>");
|
||||||
LOGGER.info("Getting all .rpx files in " + dir.getCanonicalPath()+" including those in subdirectories");
|
LOGGER.info("Getting all .rpx files in " + dir.getCanonicalPath()+" including those in subdirectories");
|
||||||
@ -256,7 +276,7 @@ public class DBController {
|
|||||||
* @throws SQLException
|
* @throws SQLException
|
||||||
*/
|
*/
|
||||||
private boolean checkAddEntry(String title) throws SQLException{
|
private boolean checkAddEntry(String title) throws SQLException{
|
||||||
Statement stmt = connection.createStatement();
|
Statement stmt = connectionLocal.createStatement();
|
||||||
boolean check = false;
|
boolean check = false;
|
||||||
ResultSet rs = stmt.executeQuery("SELECT * FROM local_roms WHERE title = '"+title+"';");
|
ResultSet rs = stmt.executeQuery("SELECT * FROM local_roms WHERE title = '"+title+"';");
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
@ -274,15 +294,6 @@ public class DBController {
|
|||||||
//LOGGER.info("check if entry removed not done yet!");
|
//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
|
* getting info for a game with titleID
|
||||||
* @param titleID Title-ID of the Game
|
* @param titleID Title-ID of the Game
|
||||||
@ -292,7 +303,7 @@ public class DBController {
|
|||||||
String[] gameInfo = new String[4];
|
String[] gameInfo = new String[4];
|
||||||
LOGGER.info("getting game info for titleID: "+titleID+" ...");
|
LOGGER.info("getting game info for titleID: "+titleID+" ...");
|
||||||
try {
|
try {
|
||||||
Statement stmt = connection.createStatement();
|
Statement stmt = connectionLocal.createStatement();
|
||||||
ResultSet rs = stmt.executeQuery("SELECT * FROM local_roms where titleID = '"+titleID+"'");
|
ResultSet rs = stmt.executeQuery("SELECT * FROM local_roms where titleID = '"+titleID+"'");
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
gameInfo[0] = rs.getString(1);// title
|
gameInfo[0] = rs.getString(1);// title
|
||||||
@ -311,10 +322,10 @@ public class DBController {
|
|||||||
public void setGameInfo(String title, String coverPath, String romPath, String titleID){
|
public void setGameInfo(String title, String coverPath, String romPath, String titleID){
|
||||||
LOGGER.info("setting game info for titleID: "+titleID+" ...");
|
LOGGER.info("setting game info for titleID: "+titleID+" ...");
|
||||||
try {
|
try {
|
||||||
Statement stmt = connection.createStatement();
|
Statement stmt = connectionLocal.createStatement();
|
||||||
stmt.executeUpdate("UPDATE local_roms SET title = '" + title + "', coverPath = '" + coverPath + "',"
|
stmt.executeUpdate("UPDATE local_roms SET title = '" + title + "', coverPath = '" + coverPath + "',"
|
||||||
+ " romPath = '" + romPath + "' WHERE titleID = '"+titleID+"';");
|
+ " romPath = '" + romPath + "' WHERE titleID = '"+titleID+"';");
|
||||||
connection.commit();
|
connectionLocal.commit();
|
||||||
stmt.close();
|
stmt.close();
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
LOGGER.error("error while setting game info", e);
|
LOGGER.error("error while setting game info", e);
|
||||||
@ -323,9 +334,9 @@ public class DBController {
|
|||||||
|
|
||||||
public void setLastPlayed(String titleID){
|
public void setLastPlayed(String titleID){
|
||||||
try{
|
try{
|
||||||
Statement stmt = connection.createStatement();
|
Statement stmt = connectionLocal.createStatement();
|
||||||
stmt.executeUpdate("UPDATE local_roms SET lastPlayed=date('now') WHERE titleID = '"+titleID+"';");
|
stmt.executeUpdate("UPDATE local_roms SET lastPlayed=date('now') WHERE titleID = '"+titleID+"';");
|
||||||
connection.commit();
|
connectionLocal.commit();
|
||||||
stmt.close();
|
stmt.close();
|
||||||
}catch(SQLException e){
|
}catch(SQLException e){
|
||||||
LOGGER.error("failed to set the last played", e);
|
LOGGER.error("failed to set the last played", e);
|
||||||
@ -335,7 +346,7 @@ public class DBController {
|
|||||||
public String getLastPlayed(String titleID){
|
public String getLastPlayed(String titleID){
|
||||||
String lastPlayed = null;
|
String lastPlayed = null;
|
||||||
try{
|
try{
|
||||||
Statement stmt = connection.createStatement();
|
Statement stmt = connectionLocal.createStatement();
|
||||||
ResultSet rs = stmt.executeQuery("SELECT lastPlayed FROM local_roms WHERE titleID = '"+titleID+"';" );
|
ResultSet rs = stmt.executeQuery("SELECT lastPlayed FROM local_roms WHERE titleID = '"+titleID+"';" );
|
||||||
lastPlayed = rs.getString(1);
|
lastPlayed = rs.getString(1);
|
||||||
stmt.close();
|
stmt.close();
|
||||||
@ -348,9 +359,9 @@ public class DBController {
|
|||||||
|
|
||||||
public void setTotalPlaytime(String timePlayed, String titleID){
|
public void setTotalPlaytime(String timePlayed, String titleID){
|
||||||
try{
|
try{
|
||||||
Statement stmt = connection.createStatement();
|
Statement stmt = connectionLocal.createStatement();
|
||||||
stmt.executeUpdate("UPDATE local_roms SET timePlayed='"+timePlayed+"' WHERE titleID = '"+titleID+"';");
|
stmt.executeUpdate("UPDATE local_roms SET timePlayed='"+timePlayed+"' WHERE titleID = '"+titleID+"';");
|
||||||
connection.commit();
|
connectionLocal.commit();
|
||||||
stmt.close();
|
stmt.close();
|
||||||
}catch(SQLException e){
|
}catch(SQLException e){
|
||||||
LOGGER.error("failed to set total play time", e);
|
LOGGER.error("failed to set total play time", e);
|
||||||
@ -361,7 +372,7 @@ public class DBController {
|
|||||||
public String getTotalPlaytime(String titleID){
|
public String getTotalPlaytime(String titleID){
|
||||||
String timePlayed = null;
|
String timePlayed = null;
|
||||||
try{
|
try{
|
||||||
Statement stmt = connection.createStatement();
|
Statement stmt = connectionLocal.createStatement();
|
||||||
ResultSet rs = stmt.executeQuery("SELECT timePlayed FROM local_roms WHERE titleID = '"+titleID+"';" );
|
ResultSet rs = stmt.executeQuery("SELECT timePlayed FROM local_roms WHERE titleID = '"+titleID+"';" );
|
||||||
timePlayed = rs.getString(1);
|
timePlayed = rs.getString(1);
|
||||||
stmt.close();
|
stmt.close();
|
||||||
@ -372,5 +383,13 @@ public class DBController {
|
|||||||
return timePlayed;
|
return timePlayed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -36,19 +36,32 @@ import javafx.scene.text.FontWeight;
|
|||||||
|
|
||||||
public class UIROMDataType extends VBox {
|
public class UIROMDataType extends VBox {
|
||||||
|
|
||||||
private String titleID;
|
|
||||||
private String romPath;
|
private String romPath;
|
||||||
|
private String titleID;
|
||||||
|
private String name;
|
||||||
private Label label = new Label();
|
private Label label = new Label();
|
||||||
private JFXButton button = new JFXButton();
|
private JFXButton button = new JFXButton();
|
||||||
private ImageView imageView = new ImageView();
|
private ImageView imageView = new ImageView();
|
||||||
|
|
||||||
public UIROMDataType(String titleID, String romPath, String text, String coverPath, ContextMenu contextMenu) {
|
public UIROMDataType(String romPath, String titleID, String name, String coverPath) {
|
||||||
this();
|
this();
|
||||||
|
|
||||||
this.titleID = titleID;
|
|
||||||
this.romPath = romPath;
|
this.romPath = romPath;
|
||||||
|
this.titleID = titleID;
|
||||||
|
this.name = name;
|
||||||
|
|
||||||
label.setText(text);
|
label.setText(name);
|
||||||
|
imageView.setImage(new Image(new File(coverPath).toURI().toString()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public UIROMDataType(String romPath, String titleID, String name, String coverPath, ContextMenu contextMenu) {
|
||||||
|
this();
|
||||||
|
|
||||||
|
this.romPath = romPath;
|
||||||
|
this.titleID = titleID;
|
||||||
|
this.name = name;
|
||||||
|
|
||||||
|
label.setText(name);
|
||||||
imageView.setImage(new Image(new File(coverPath).toURI().toString()));
|
imageView.setImage(new Image(new File(coverPath).toURI().toString()));
|
||||||
button.setContextMenu(contextMenu);
|
button.setContextMenu(contextMenu);
|
||||||
}
|
}
|
||||||
@ -67,12 +80,16 @@ public class UIROMDataType extends VBox {
|
|||||||
button.setGraphic(imageView);
|
button.setGraphic(imageView);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getRomPath() {
|
||||||
|
return romPath;
|
||||||
|
}
|
||||||
|
|
||||||
public String getTitleID() {
|
public String getTitleID() {
|
||||||
return titleID;
|
return titleID;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getRomPath() {
|
public String getName() {
|
||||||
return romPath;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Label getLabel() {
|
public Label getLabel() {
|
||||||
@ -87,12 +104,16 @@ public class UIROMDataType extends VBox {
|
|||||||
return imageView;
|
return imageView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setRomPath(String romPath) {
|
||||||
|
this.romPath = romPath;
|
||||||
|
}
|
||||||
|
|
||||||
public void setTitleID(String titleID) {
|
public void setTitleID(String titleID) {
|
||||||
this.titleID = titleID;
|
this.titleID = titleID;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRomPath(String romPath) {
|
public void setName(String name) {
|
||||||
this.romPath = romPath;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLabel(Label label) {
|
public void setLabel(Label label) {
|
||||||
|
250
src/main/java/com/cemu_UI/uiElements/JFXEditGameAlert.java
Normal file
250
src/main/java/com/cemu_UI/uiElements/JFXEditGameAlert.java
Normal file
@ -0,0 +1,250 @@
|
|||||||
|
/**
|
||||||
|
* 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 java.io.File;
|
||||||
|
|
||||||
|
import com.cemu_UI.application.MainWindowController;
|
||||||
|
import com.cemu_UI.controller.XMLController;
|
||||||
|
import com.jfoenix.controls.JFXAlert;
|
||||||
|
import com.jfoenix.controls.JFXButton;
|
||||||
|
import com.jfoenix.controls.JFXDialogLayout;
|
||||||
|
|
||||||
|
import javafx.event.ActionEvent;
|
||||||
|
import javafx.geometry.Insets;
|
||||||
|
import javafx.scene.control.Label;
|
||||||
|
import javafx.scene.control.TextField;
|
||||||
|
import javafx.scene.layout.GridPane;
|
||||||
|
import javafx.scene.layout.VBox;
|
||||||
|
import javafx.scene.text.Text;
|
||||||
|
import javafx.stage.FileChooser;
|
||||||
|
import javafx.stage.Stage;
|
||||||
|
|
||||||
|
public class JFXEditGameAlert {
|
||||||
|
|
||||||
|
private String headingText;
|
||||||
|
private String bodyText;
|
||||||
|
private String title = "";
|
||||||
|
private String coverPath = "";
|
||||||
|
private String romPath = "";
|
||||||
|
private String titleID = "";
|
||||||
|
private String btnStyle;
|
||||||
|
private int mode;
|
||||||
|
private Stage stage;
|
||||||
|
private MainWindowController mwc; // TODO remove this!
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new JFoenix Alert to show some information with okay and cancel option
|
||||||
|
* @param headingText Heading text of the alert
|
||||||
|
* @param bodyText Content text of the alert
|
||||||
|
* @param btnStyle Style of the buttons
|
||||||
|
* @param mode Set to 0 for add and 1 for edit mode
|
||||||
|
* @param stage Stage to which the Alert belongs
|
||||||
|
* @param mwc a mwc dep, it's horrible i know
|
||||||
|
*/
|
||||||
|
public JFXEditGameAlert(String headingText, String bodyText, String btnStyle, int mode, Stage stage, MainWindowController mwc) {
|
||||||
|
this.headingText = headingText;
|
||||||
|
this.bodyText = bodyText;
|
||||||
|
this.btnStyle = btnStyle;
|
||||||
|
this.mode = mode;
|
||||||
|
this.stage = stage;
|
||||||
|
this.mwc = mwc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void showAndWait( ) {
|
||||||
|
JFXAlert<Void> alert = new JFXAlert<>(stage);
|
||||||
|
|
||||||
|
TextField gameTitleTF = new TextField();
|
||||||
|
gameTitleTF.setPromptText(XMLController.getLocalBundle().getString("gameTitle"));
|
||||||
|
TextField gameTitleIDTF = new TextField();
|
||||||
|
gameTitleIDTF.setPromptText(XMLController.getLocalBundle().getString("titleID"));
|
||||||
|
TextField romPathTF = new TextField();
|
||||||
|
romPathTF.setPromptText(XMLController.getLocalBundle().getString("romPath"));
|
||||||
|
TextField gameCoverTF = new TextField();
|
||||||
|
gameCoverTF.setPromptText(XMLController.getLocalBundle().getString("coverPath"));
|
||||||
|
|
||||||
|
if (mode == 1) {
|
||||||
|
gameTitleTF.setText(title);
|
||||||
|
gameTitleIDTF.setText(titleID);
|
||||||
|
romPathTF.setText(romPath);
|
||||||
|
gameCoverTF.setText(coverPath);
|
||||||
|
|
||||||
|
gameTitleIDTF.setEditable(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
JFXButton okayBtn = new JFXButton(XMLController.getLocalBundle().getString("okayBtnText"));
|
||||||
|
okayBtn.setOnAction(event -> {
|
||||||
|
if (romPathTF.getText().toString().length() == 0 || gameCoverTF.getText().toString().length() == 0
|
||||||
|
|| gameTitleTF.getText().toString().length() == 0
|
||||||
|
|| gameTitleIDTF.getText().toString().length() == 0) {
|
||||||
|
|
||||||
|
// addGame error dialog
|
||||||
|
JFXInfoAlert errorDialog = new JFXInfoAlert(
|
||||||
|
XMLController.getLocalBundle().getString("editGameDialogHeadingTextError"),
|
||||||
|
XMLController.getLocalBundle().getString("editGameDialogBodyTextError"), btnStyle, stage);
|
||||||
|
errorDialog.showAndWait();
|
||||||
|
} else {
|
||||||
|
switch (mode) {
|
||||||
|
case 0:
|
||||||
|
// add-mode title, coverPath, romPath, titleID
|
||||||
|
mwc.addBtnReturn(gameTitleTF.getText().toString(), gameCoverTF.getText().toString(),
|
||||||
|
romPathTF.getText().toString(), gameTitleIDTF.getText().toString());
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
// edit mode
|
||||||
|
mwc.editBtnReturn(gameTitleTF.getText().toString(), gameCoverTF.getText().toString(),
|
||||||
|
romPathTF.getText().toString(), gameTitleIDTF.getText().toString());
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
alert.close();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
okayBtn.setButtonType(com.jfoenix.controls.JFXButton.ButtonType.RAISED);
|
||||||
|
okayBtn.setPrefHeight(32);
|
||||||
|
okayBtn.setStyle(btnStyle);
|
||||||
|
|
||||||
|
JFXButton cancelBtn = new JFXButton(XMLController.getLocalBundle().getString("cancelBtnText"));
|
||||||
|
cancelBtn.addEventHandler(ActionEvent.ACTION, (e)-> alert.close());
|
||||||
|
cancelBtn.setButtonType(com.jfoenix.controls.JFXButton.ButtonType.RAISED);
|
||||||
|
cancelBtn.setPrefHeight(32);
|
||||||
|
cancelBtn.setStyle(btnStyle);
|
||||||
|
|
||||||
|
JFXButton selectPathBtn = new JFXButton(XMLController.getLocalBundle().getString("editGameDialogSelectPathBtn"));
|
||||||
|
selectPathBtn.setPrefWidth(110);
|
||||||
|
selectPathBtn.setStyle(btnStyle);
|
||||||
|
selectPathBtn.setOnAction(event -> {
|
||||||
|
FileChooser romDirectoryChooser = new FileChooser();
|
||||||
|
File romDirectory = romDirectoryChooser.showOpenDialog(stage);
|
||||||
|
romPathTF.setText(romDirectory.getAbsolutePath());
|
||||||
|
});
|
||||||
|
|
||||||
|
JFXButton selectCoverBtn = new JFXButton(XMLController.getLocalBundle().getString("editGameDialogSelectCoverBtn"));
|
||||||
|
selectCoverBtn.setPrefWidth(110);
|
||||||
|
selectCoverBtn.setStyle(btnStyle);
|
||||||
|
selectCoverBtn.setOnAction(event -> {
|
||||||
|
FileChooser coverDirectoryChooser = new FileChooser();
|
||||||
|
File coverDirectory = coverDirectoryChooser.showOpenDialog(stage);
|
||||||
|
gameCoverTF.setText(coverDirectory.getAbsolutePath());
|
||||||
|
});
|
||||||
|
|
||||||
|
GridPane grid = new GridPane();
|
||||||
|
grid.setHgap(10);
|
||||||
|
grid.setVgap(10);
|
||||||
|
grid.setPadding(new Insets(15, 10, 10, 10));
|
||||||
|
grid.add(new Label(XMLController.getLocalBundle().getString("gameTitle") + ":"), 0, 0);
|
||||||
|
grid.add(gameTitleTF, 1, 0);
|
||||||
|
grid.add(new Label(XMLController.getLocalBundle().getString("titleID") + ":"), 0, 1);
|
||||||
|
grid.add(gameTitleIDTF, 1, 1);
|
||||||
|
grid.add(new Label(XMLController.getLocalBundle().getString("romPath") + ":"), 0, 2);
|
||||||
|
grid.add(romPathTF, 1, 2);
|
||||||
|
grid.add(selectPathBtn, 2, 2);
|
||||||
|
grid.add(new Label(XMLController.getLocalBundle().getString("coverPath") + ":"), 0, 3);
|
||||||
|
grid.add(gameCoverTF, 1, 3);
|
||||||
|
grid.add(selectCoverBtn, 2, 3);
|
||||||
|
|
||||||
|
VBox vbox = new VBox();
|
||||||
|
vbox.getChildren().addAll(new Text(bodyText), grid);
|
||||||
|
|
||||||
|
JFXDialogLayout content = new JFXDialogLayout();
|
||||||
|
content.setActions(cancelBtn, okayBtn);
|
||||||
|
content.setHeading(new Text(headingText));
|
||||||
|
content.setBody(vbox);
|
||||||
|
alert.setContent(content);
|
||||||
|
alert.showAndWait();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getHeadingText() {
|
||||||
|
return headingText;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBodyText() {
|
||||||
|
return bodyText;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTitle() {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCoverPath() {
|
||||||
|
return coverPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRomPath() {
|
||||||
|
return romPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTitleID() {
|
||||||
|
return titleID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBtnStyle() {
|
||||||
|
return btnStyle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMode() {
|
||||||
|
return mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Stage getStage() {
|
||||||
|
return stage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHeadingText(String headingText) {
|
||||||
|
this.headingText = headingText;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBodyText(String bodyText) {
|
||||||
|
this.bodyText = bodyText;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTitle(String title) {
|
||||||
|
this.title = title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCoverPath(String coverPath) {
|
||||||
|
this.coverPath = coverPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRomPath(String romPath) {
|
||||||
|
this.romPath = romPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTitleID(String titleID) {
|
||||||
|
this.titleID = titleID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBtnStyle(String btnStyle) {
|
||||||
|
this.btnStyle = btnStyle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMode(int mode) {
|
||||||
|
this.mode = mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStage(Stage stage) {
|
||||||
|
this.stage = stage;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,230 +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 java.io.File;
|
|
||||||
|
|
||||||
import com.cemu_UI.application.MainWindowController;
|
|
||||||
import com.cemu_UI.controller.XMLController;
|
|
||||||
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.geometry.Insets;
|
|
||||||
import javafx.scene.control.Label;
|
|
||||||
import javafx.scene.control.TextField;
|
|
||||||
import javafx.scene.layout.AnchorPane;
|
|
||||||
import javafx.scene.layout.GridPane;
|
|
||||||
import javafx.scene.layout.Pane;
|
|
||||||
import javafx.scene.layout.StackPane;
|
|
||||||
import javafx.scene.layout.VBox;
|
|
||||||
import javafx.scene.text.Text;
|
|
||||||
import javafx.stage.FileChooser;
|
|
||||||
import javafx.stage.Stage;
|
|
||||||
|
|
||||||
public class JFXEditGameDialog {
|
|
||||||
|
|
||||||
private String headingText;
|
|
||||||
private String bodyText;
|
|
||||||
private String dialogBtnStyle;
|
|
||||||
private String title = "";
|
|
||||||
private String coverPath = "";
|
|
||||||
private String romPath = "";
|
|
||||||
private String titleID = "";
|
|
||||||
private int dialogWidth;
|
|
||||||
private int dialogHeight;
|
|
||||||
private int mode;
|
|
||||||
private Stage stage;
|
|
||||||
private Pane pane;
|
|
||||||
private MainWindowController mwc;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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 mode set to 0 for add and 1 for edit mode
|
|
||||||
* @param stage the primary stage
|
|
||||||
* @param pane pane to which the dialog belongs
|
|
||||||
*/
|
|
||||||
public JFXEditGameDialog(String headingText, String bodyText, String dialogBtnStyle, int dialogWidth,
|
|
||||||
int dialogHeight, int mode, MainWindowController mwc, Stage stage, Pane pane) {
|
|
||||||
this.headingText = headingText;
|
|
||||||
this.bodyText = bodyText;
|
|
||||||
this.dialogBtnStyle = dialogBtnStyle;
|
|
||||||
this.dialogWidth = dialogWidth;
|
|
||||||
this.dialogHeight = dialogHeight;
|
|
||||||
this.mode = mode;
|
|
||||||
this.mwc = mwc;
|
|
||||||
this.stage = stage;
|
|
||||||
this.pane = pane;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void show() {
|
|
||||||
JFXDialogLayout content = new JFXDialogLayout();
|
|
||||||
StackPane stackPane = new StackPane();
|
|
||||||
stackPane.autosize();
|
|
||||||
JFXDialog dialog = new JFXDialog(stackPane, content, JFXDialog.DialogTransition.LEFT, true);
|
|
||||||
|
|
||||||
TextField gameTitleTF = new TextField();
|
|
||||||
gameTitleTF.setPromptText(XMLController.getLocalBundle().getString("gameTitle"));
|
|
||||||
TextField gameTitleIDTF = new TextField();
|
|
||||||
gameTitleIDTF.setPromptText(XMLController.getLocalBundle().getString("titleID"));
|
|
||||||
TextField romPathTF = new TextField();
|
|
||||||
romPathTF.setPromptText(XMLController.getLocalBundle().getString("romPath"));
|
|
||||||
TextField gameCoverTF = new TextField();
|
|
||||||
gameCoverTF.setPromptText(XMLController.getLocalBundle().getString("coverPath"));
|
|
||||||
|
|
||||||
if (mode == 1) {
|
|
||||||
gameTitleTF.setText(title);
|
|
||||||
gameTitleIDTF.setText(titleID);
|
|
||||||
romPathTF.setText(romPath);
|
|
||||||
gameCoverTF.setText(coverPath);
|
|
||||||
|
|
||||||
gameTitleIDTF.setEditable(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
JFXButton okayBtn = new JFXButton(XMLController.getLocalBundle().getString("okayBtnText"));
|
|
||||||
okayBtn.setOnAction(new EventHandler<ActionEvent>() {
|
|
||||||
@Override
|
|
||||||
public void handle(ActionEvent event) {
|
|
||||||
if (romPathTF.getText().toString().length() == 0 || gameCoverTF.getText().toString().length() == 0
|
|
||||||
|| gameTitleTF.getText().toString().length() == 0 || gameTitleIDTF.getText().toString().length() == 0) {
|
|
||||||
|
|
||||||
// LOGGER.info("No parameter set!");
|
|
||||||
|
|
||||||
// addGame error dialog
|
|
||||||
JFXInfoAlert errorDialog = new JFXInfoAlert(
|
|
||||||
XMLController.getLocalBundle().getString("editGameDialogHeadingTextError"),
|
|
||||||
XMLController.getLocalBundle().getString("editGameDialogBodyTextError"), dialogBtnStyle,
|
|
||||||
stage);
|
|
||||||
errorDialog.showAndWait();
|
|
||||||
} else {
|
|
||||||
switch (mode) {
|
|
||||||
case 0:
|
|
||||||
// add-mode title, coverPath, romPath, titleID
|
|
||||||
mwc.addBtnReturn(gameTitleTF.getText().toString(), gameCoverTF.getText().toString(),
|
|
||||||
romPathTF.getText().toString(), gameTitleIDTF.getText().toString());
|
|
||||||
dialog.close();
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
// edit mode
|
|
||||||
mwc.editBtnReturn(gameTitleTF.getText().toString(), gameCoverTF.getText().toString(),
|
|
||||||
romPathTF.getText().toString(), gameTitleIDTF.getText().toString());
|
|
||||||
dialog.close();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
dialog.close();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
okayBtn.setButtonType(com.jfoenix.controls.JFXButton.ButtonType.RAISED);
|
|
||||||
okayBtn.setPrefHeight(32);
|
|
||||||
okayBtn.setStyle(dialogBtnStyle);
|
|
||||||
|
|
||||||
JFXButton cancelBtn = new JFXButton(XMLController.getLocalBundle().getString("cancelBtnText"));
|
|
||||||
cancelBtn.setOnAction(new EventHandler<ActionEvent>() {
|
|
||||||
@Override
|
|
||||||
public void handle(ActionEvent event) {
|
|
||||||
dialog.close();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
cancelBtn.setButtonType(com.jfoenix.controls.JFXButton.ButtonType.RAISED);
|
|
||||||
cancelBtn.setPrefHeight(32);
|
|
||||||
cancelBtn.setStyle(dialogBtnStyle);
|
|
||||||
|
|
||||||
JFXButton selectPathBtn = new JFXButton(XMLController.getLocalBundle().getString("editGameDialogSelectPathBtn"));
|
|
||||||
selectPathBtn.setPrefWidth(110);
|
|
||||||
selectPathBtn.setStyle(dialogBtnStyle);
|
|
||||||
selectPathBtn.setOnAction(new EventHandler<ActionEvent>() {
|
|
||||||
@Override
|
|
||||||
public void handle(ActionEvent event) {
|
|
||||||
FileChooser romDirectoryChooser = new FileChooser();
|
|
||||||
File romDirectory = romDirectoryChooser.showOpenDialog(stage);
|
|
||||||
romPathTF.setText(romDirectory.getAbsolutePath());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
JFXButton selectCoverBtn = new JFXButton(XMLController.getLocalBundle().getString("editGameDialogSelectCoverBtn"));
|
|
||||||
selectCoverBtn.setPrefWidth(110);
|
|
||||||
selectCoverBtn.setStyle(dialogBtnStyle);
|
|
||||||
selectCoverBtn.setOnAction(new EventHandler<ActionEvent>() {
|
|
||||||
@Override
|
|
||||||
public void handle(ActionEvent event) {
|
|
||||||
FileChooser coverDirectoryChooser = new FileChooser();
|
|
||||||
File coverDirectory = coverDirectoryChooser.showOpenDialog(stage);
|
|
||||||
gameCoverTF.setText(coverDirectory.getAbsolutePath());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
GridPane grid = new GridPane();
|
|
||||||
grid.setHgap(10);
|
|
||||||
grid.setVgap(10);
|
|
||||||
grid.setPadding(new Insets(15, 10, 10, 10));
|
|
||||||
grid.add(new Label(XMLController.getLocalBundle().getString("gameTitle") + ":"), 0, 0);
|
|
||||||
grid.add(gameTitleTF, 1, 0);
|
|
||||||
grid.add(new Label(XMLController.getLocalBundle().getString("titleID") + ":"), 0, 1);
|
|
||||||
grid.add(gameTitleIDTF, 1, 1);
|
|
||||||
grid.add(new Label(XMLController.getLocalBundle().getString("romPath") + ":"), 0, 2);
|
|
||||||
grid.add(romPathTF, 1, 2);
|
|
||||||
grid.add(selectPathBtn, 2, 2);
|
|
||||||
grid.add(new Label(XMLController.getLocalBundle().getString("coverPath") + ":"), 0, 3);
|
|
||||||
grid.add(gameCoverTF, 1, 3);
|
|
||||||
grid.add(selectCoverBtn, 2, 3);
|
|
||||||
|
|
||||||
Text bdyText = new Text(bodyText);
|
|
||||||
|
|
||||||
VBox vbox = new VBox();
|
|
||||||
vbox.getChildren().addAll(bdyText, grid);
|
|
||||||
|
|
||||||
content.setHeading(new Text(headingText));
|
|
||||||
content.setBody(vbox);
|
|
||||||
content.setActions(cancelBtn, 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();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTitle(String title) {
|
|
||||||
this.title = title;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCoverPath(String coverPath) {
|
|
||||||
this.coverPath = coverPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRomPath(String romPath) {
|
|
||||||
this.romPath = romPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTitleID(String titleID) {
|
|
||||||
this.titleID = titleID;
|
|
||||||
}
|
|
||||||
}
|
|
@ -42,7 +42,7 @@ public class JFXInfoAlert {
|
|||||||
* @param headerText Heading text of the alert
|
* @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 btnStyle Style of the okay button
|
||||||
* @param stage stage to which the dialog belongs
|
* @param stage Stage to which the Alert belongs
|
||||||
*/
|
*/
|
||||||
public JFXInfoAlert(String headingText, String bodyText, String btnStyle, Stage stage) {
|
public JFXInfoAlert(String headingText, String bodyText, String btnStyle, Stage stage) {
|
||||||
setHeadingText(headingText);
|
setHeadingText(headingText);
|
||||||
|
@ -44,6 +44,13 @@ public class JFXOkayCancelAlert {
|
|||||||
private String okayText = XMLController.getLocalBundle().getString("okayBtnText");
|
private String okayText = XMLController.getLocalBundle().getString("okayBtnText");
|
||||||
private String cancelText = XMLController.getLocalBundle().getString("cancelBtnText");
|
private String cancelText = XMLController.getLocalBundle().getString("cancelBtnText");
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param headingText Heading text of the alert
|
||||||
|
* @param bodyText Content text of the alert
|
||||||
|
* @param btnStyle Style of the buttons
|
||||||
|
* @param stage Stage to which the Alert belongs
|
||||||
|
*/
|
||||||
public JFXOkayCancelAlert(String headingText, String bodyText, String btnStyle, Stage stage) {
|
public JFXOkayCancelAlert(String headingText, String bodyText, String btnStyle, Stage stage) {
|
||||||
setHeadingText(headingText);
|
setHeadingText(headingText);
|
||||||
setBodyText(bodyText);
|
setBodyText(bodyText);
|
||||||
@ -55,18 +62,14 @@ public class JFXOkayCancelAlert {
|
|||||||
JFXAlert<Void> alert = new JFXAlert<>(stage);
|
JFXAlert<Void> alert = new JFXAlert<>(stage);
|
||||||
|
|
||||||
JFXButton okayBtn = new JFXButton(okayText);
|
JFXButton okayBtn = new JFXButton(okayText);
|
||||||
okayBtn.addEventHandler(ActionEvent.ACTION, (e)-> {
|
okayBtn.addEventHandler(ActionEvent.ACTION, (e)-> alert.close());
|
||||||
alert.close();
|
|
||||||
});
|
|
||||||
okayBtn.addEventHandler(ActionEvent.ACTION, okayAction);
|
okayBtn.addEventHandler(ActionEvent.ACTION, okayAction);
|
||||||
okayBtn.setButtonType(com.jfoenix.controls.JFXButton.ButtonType.RAISED);
|
okayBtn.setButtonType(com.jfoenix.controls.JFXButton.ButtonType.RAISED);
|
||||||
okayBtn.setPrefHeight(32);
|
okayBtn.setPrefHeight(32);
|
||||||
okayBtn.setStyle(btnStyle);
|
okayBtn.setStyle(btnStyle);
|
||||||
|
|
||||||
JFXButton cancelBtn = new JFXButton(cancelText);
|
JFXButton cancelBtn = new JFXButton(cancelText);
|
||||||
cancelBtn.addEventHandler(ActionEvent.ACTION, (e)-> {
|
cancelBtn.addEventHandler(ActionEvent.ACTION, (e)-> alert.close());
|
||||||
alert.close();
|
|
||||||
});
|
|
||||||
cancelBtn.addEventHandler(ActionEvent.ACTION, cancelAction);
|
cancelBtn.addEventHandler(ActionEvent.ACTION, cancelAction);
|
||||||
cancelBtn.setButtonType(com.jfoenix.controls.JFXButton.ButtonType.RAISED);
|
cancelBtn.setButtonType(com.jfoenix.controls.JFXButton.ButtonType.RAISED);
|
||||||
cancelBtn.setPrefHeight(32);
|
cancelBtn.setPrefHeight(32);
|
||||||
|
@ -38,10 +38,10 @@ public class JFXTextAreaAlert {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new JFoenix Alert to show some information on a TextArea
|
* Creates a new JFoenix Alert to show some information on a TextArea
|
||||||
* @param headingText just the heading
|
* @param headingText Heading text of the alert
|
||||||
* @param textAreaText all text to needed on the TextArea belongs here
|
* @param textAreaText Content text of the alert
|
||||||
* @param btnStyle Style of the okay button
|
* @param btnStyle Style of the okay button
|
||||||
* @param stage stage to which the dialog belongs
|
* @param stage Stage to which the Alert belongs
|
||||||
*/
|
*/
|
||||||
public JFXTextAreaAlert(String headingText, String textAreaText, String btnStyle, Stage stage) {
|
public JFXTextAreaAlert(String headingText, String textAreaText, String btnStyle, Stage stage) {
|
||||||
setHeadingText(headingText);
|
setHeadingText(headingText);
|
||||||
|
Loading…
Reference in New Issue
Block a user