|
|
|
@ -56,7 +56,7 @@ import com.cemu_UI.datatypes.CourseTableDataType;
|
|
|
|
|
import com.cemu_UI.datatypes.GlobalDataTypes.CloudService; |
|
|
|
|
import com.cemu_UI.datatypes.SmmdbApiDataType; |
|
|
|
|
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.JFXOkayCancelAlert; |
|
|
|
|
import com.cemu_UI.uiElements.JFXTextAreaAlert; |
|
|
|
@ -187,7 +187,7 @@ public class MainWindowController {
|
|
|
|
|
private boolean menuTrue = false; |
|
|
|
|
private boolean playTrue = false; |
|
|
|
|
private String gameExecutePath; |
|
|
|
|
private String dialogBtnStyle; |
|
|
|
|
private String btnStyle; |
|
|
|
|
private String selectedGameTitleID; |
|
|
|
|
private String selectedGameTitle; |
|
|
|
|
private String id; |
|
|
|
@ -215,22 +215,8 @@ public class MainWindowController {
|
|
|
|
|
private MenuItem addDLC = new MenuItem("add DLC"); |
|
|
|
|
private ContextMenu gameContextMenu = new ContextMenu(edit, remove, addUpdate, addDLC); |
|
|
|
|
private Label lastGameLabel = new Label(); |
|
|
|
|
|
|
|
|
|
private ImageView add_circle_black = new ImageView(new Image("icons/ic_add_circle_black_24dp_1x.png")); |
|
|
|
|
private ImageView info_black = new ImageView(new Image("icons/ic_info_black_24dp_1x.png")); |
|
|
|
|
private ImageView settings_black = new ImageView(new Image("icons/ic_settings_black_24dp_1x.png")); |
|
|
|
|
private ImageView cached_black = new ImageView(new Image("icons/ic_cached_black_24dp_1x.png")); |
|
|
|
|
private ImageView smmdb_black = new ImageView(new Image("icons/ic_get_app_black_24dp_1x.png")); |
|
|
|
|
private ImageView add_circle_white = new ImageView(new Image("icons/ic_add_circle_white_24dp_1x.png")); |
|
|
|
|
private ImageView info_white = new ImageView(new Image("icons/ic_info_white_24dp_1x.png")); |
|
|
|
|
private ImageView settings_white = new ImageView(new Image("icons/ic_settings_white_24dp_1x.png")); |
|
|
|
|
private ImageView cached_white = new ImageView(new Image("icons/ic_cached_white_24dp_1x.png")); |
|
|
|
|
private ImageView smmdb_white = new ImageView(new Image("icons/ic_get_app_white_24dp_1x.png")); |
|
|
|
|
private Image close_black = new Image("icons/close_black_2048x2048.png"); |
|
|
|
|
|
|
|
|
|
// language support
|
|
|
|
|
private ResourceBundle bundle; |
|
|
|
|
private String language; |
|
|
|
|
private String lastPlayed; |
|
|
|
|
private String today; |
|
|
|
|
private String yesterday; |
|
|
|
@ -239,7 +225,7 @@ public class MainWindowController {
|
|
|
|
|
public MainWindowController(Main main) { |
|
|
|
|
xmlController = new XMLController(); |
|
|
|
|
this.main = main; |
|
|
|
|
dbController = new DBController(this); |
|
|
|
|
dbController = DBController.getInstance(); |
|
|
|
|
smmdbAPIController = new SmmdbAPIController(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -252,6 +238,11 @@ public class MainWindowController {
|
|
|
|
|
checkAutoUpdate(); |
|
|
|
|
initUI(); |
|
|
|
|
initActions(); |
|
|
|
|
|
|
|
|
|
dbController.init(); |
|
|
|
|
dbController.refreshDataBase(); |
|
|
|
|
games = dbController.loadAllGames(); |
|
|
|
|
addAllGames(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -351,14 +342,14 @@ public class MainWindowController {
|
|
|
|
|
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(); |
|
|
|
|
String headingText = XMLController.getLocalBundle().getString("editHeadingText") + " \"" + selectedGameTitle + "\""; |
|
|
|
|
JFXEditGameAlert editGameAlert = new JFXEditGameAlert(headingText, |
|
|
|
|
XMLController.getLocalBundle().getString("editBodyText"), btnStyle, 1, primaryStage, MWC); |
|
|
|
|
editGameAlert.setTitle(gameInfo[0]); |
|
|
|
|
editGameAlert.setCoverPath(gameInfo[1]); |
|
|
|
|
editGameAlert.setRomPath(gameInfo[2]); |
|
|
|
|
editGameAlert.setTitleID(gameInfo[3]); |
|
|
|
|
editGameAlert.showAndWait(); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
LOGGER.warn("trying to edit " + selectedGameTitleID + ",which is not a valid type!", e); |
|
|
|
|
} |
|
|
|
@ -367,10 +358,9 @@ public class MainWindowController {
|
|
|
|
|
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, |
|
|
|
|
String headingText = XMLController.getLocalBundle().getString("removeHeadingText") + " \"" + selectedGameTitle + "\""; |
|
|
|
|
String bodyText = XMLController.getLocalBundle().getString("removeBodyText") + " " + selectedGameTitle + " ?"; |
|
|
|
|
JFXOkayCancelAlert removeGameAlert = new JFXOkayCancelAlert(headingText, bodyText, btnStyle, |
|
|
|
|
primaryStage); |
|
|
|
|
removeGameAlert.setOkayAction(e -> { |
|
|
|
|
try { |
|
|
|
@ -411,10 +401,10 @@ public class MainWindowController {
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
LOGGER.info("copying the content of " + updatePath + " to " + destDir.toString()); |
|
|
|
|
playBtn.setText(bundle.getString("playBtnUpdating")); |
|
|
|
|
playBtn.setText(XMLController.getLocalBundle().getString("playBtnUpdating")); |
|
|
|
|
playBtn.setDisable(true); |
|
|
|
|
FileUtils.copyDirectory(srcDir, destDir); |
|
|
|
|
playBtn.setText(bundle.getString("playBtnPlay")); |
|
|
|
|
playBtn.setText(XMLController.getLocalBundle().getString("playBtnPlay")); |
|
|
|
|
playBtn.setDisable(false); |
|
|
|
|
LOGGER.info("copying files done!"); |
|
|
|
|
} 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, |
|
|
|
|
bundle.getString("addUpdateBodyText"), dialogBtnStyle, primaryStage); |
|
|
|
|
XMLController.getLocalBundle().getString("addUpdateBodyText"), btnStyle, primaryStage); |
|
|
|
|
updateGameAlert.setOkayAction(okayAction); |
|
|
|
|
updateGameAlert.setCancelAction(cancelAction); |
|
|
|
|
updateGameAlert.showAndWait(); |
|
|
|
@ -447,7 +437,7 @@ public class MainWindowController {
|
|
|
|
|
public void handle(ActionEvent event) { |
|
|
|
|
try { |
|
|
|
|
LOGGER.info("add DLC: " + selectedGameTitleID); |
|
|
|
|
String headingText = bundle.getString("addDLCHeadingText") + " \"" + selectedGameTitle + "\""; |
|
|
|
|
String headingText = XMLController.getLocalBundle().getString("addDLCHeadingText") + " \"" + selectedGameTitle + "\""; |
|
|
|
|
EventHandler<ActionEvent> okayAction = new EventHandler<ActionEvent>() { |
|
|
|
|
@Override |
|
|
|
|
public void handle(ActionEvent event) { |
|
|
|
@ -465,10 +455,10 @@ public class MainWindowController {
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
LOGGER.info("copying the content of " + dlcPath + " to " + destDir.toString()); |
|
|
|
|
playBtn.setText(bundle.getString("playBtnCopyingFiles")); |
|
|
|
|
playBtn.setText(XMLController.getLocalBundle().getString("playBtnCopyingFiles")); |
|
|
|
|
playBtn.setDisable(true); |
|
|
|
|
FileUtils.copyDirectory(srcDir, destDir); |
|
|
|
|
playBtn.setText(bundle.getString("playBtnPlay")); |
|
|
|
|
playBtn.setText(XMLController.getLocalBundle().getString("playBtnPlay")); |
|
|
|
|
playBtn.setDisable(false); |
|
|
|
|
LOGGER.info("copying files done!"); |
|
|
|
|
} catch (IOException e) { |
|
|
|
@ -485,7 +475,7 @@ public class MainWindowController {
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
JFXOkayCancelAlert addDLCAlert = new JFXOkayCancelAlert(headingText, |
|
|
|
|
bundle.getString("addDLCBodyText"), dialogBtnStyle, primaryStage); |
|
|
|
|
XMLController.getLocalBundle().getString("addDLCBodyText"), btnStyle, primaryStage); |
|
|
|
|
addDLCAlert.setOkayAction(okayAction); |
|
|
|
|
addDLCAlert.setCancelAction(cancelAction); |
|
|
|
|
addDLCAlert.showAndWait(); |
|
|
|
@ -561,7 +551,7 @@ public class MainWindowController {
|
|
|
|
|
smmdbImageView.setImage(scaledImage); // set imageview to image
|
|
|
|
|
} catch (MalformedURLException | URISyntaxException e) { |
|
|
|
|
LOGGER.warn("There was either a problem or no image!", e); |
|
|
|
|
smmdbImageView.setImage(close_black); |
|
|
|
|
smmdbImageView.setImage(new Image("icons/close_black_2048x2048.png")); |
|
|
|
|
} |
|
|
|
|
addCourseDescription(courses.get(i)); |
|
|
|
|
} |
|
|
|
@ -613,16 +603,16 @@ public class MainWindowController {
|
|
|
|
|
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(); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
JFXOkayCancelAlert licenseOverviewAlert = new JFXOkayCancelAlert( |
|
|
|
|
bundle.getString("licensesLblHeadingText"), bundle.getString("licensesLblBodyText"), |
|
|
|
|
dialogBtnStyle, primaryStage); |
|
|
|
|
XMLController.getLocalBundle().getString("licensesLblHeadingText"), |
|
|
|
|
XMLController.getLocalBundle().getString("licensesLblBodyText"), btnStyle, primaryStage); |
|
|
|
|
licenseOverviewAlert.setOkayAction(oE -> {}); |
|
|
|
|
licenseOverviewAlert.setCancelAction(cancelAction); |
|
|
|
|
licenseOverviewAlert.setCancelText(bundle.getString("showLicenses")); |
|
|
|
|
licenseOverviewAlert.setCancelText(XMLController.getLocalBundle().getString("showLicenses")); |
|
|
|
|
licenseOverviewAlert.showAndWait(); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
@ -633,7 +623,7 @@ public class MainWindowController {
|
|
|
|
|
xmlController.saveSettings(); |
|
|
|
|
} else { |
|
|
|
|
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(); |
|
|
|
|
LOGGER.warn(newValue + ": No such file or directory"); |
|
|
|
|
} |
|
|
|
@ -646,7 +636,7 @@ public class MainWindowController {
|
|
|
|
|
reloadRoms(); |
|
|
|
|
} else { |
|
|
|
|
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(); |
|
|
|
|
LOGGER.warn(newValue + ": No such file or directory"); |
|
|
|
|
} |
|
|
|
@ -662,10 +652,11 @@ public class MainWindowController {
|
|
|
|
|
|
|
|
|
|
@FXML |
|
|
|
|
private void aboutBtnAction() { |
|
|
|
|
String bodyText = "cemu_UI by @Seil0 \nVersion: " + version + " (" + buildNumber + ") \"" + versionName + "\" \n" |
|
|
|
|
+ bundle.getString("aboutBtnBodyText"); |
|
|
|
|
|
|
|
|
|
JFXInfoAlert infoAlert = new JFXInfoAlert(bundle.getString("aboutBtnHeadingText"), bodyText, dialogBtnStyle, primaryStage); |
|
|
|
|
String bodyText = "cemu_UI by @Seil0 \nVersion: " + version + " (" + buildNumber + ") \"" + versionName |
|
|
|
|
+ "\" \n" + XMLController.getLocalBundle().getString("aboutBtnBodyText"); |
|
|
|
|
|
|
|
|
|
JFXInfoAlert infoAlert = new JFXInfoAlert(XMLController.getLocalBundle().getString("aboutBtnHeadingText"), |
|
|
|
|
bodyText, btnStyle, primaryStage); |
|
|
|
|
infoAlert.showAndWait(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -694,7 +685,7 @@ public class MainWindowController {
|
|
|
|
|
@Override |
|
|
|
|
public void run() { |
|
|
|
|
Platform.runLater(() -> { |
|
|
|
|
smmdbDownloadBtn.setText(bundle.getString("smmdbDownloadBtnLoading")); |
|
|
|
|
smmdbDownloadBtn.setText(XMLController.getLocalBundle().getString("smmdbDownloadBtnLoading")); |
|
|
|
|
smmdbDownloadBtn.setDisable(true); |
|
|
|
|
root.getChildren().remove(0,root.getChildren().size()); |
|
|
|
|
}); |
|
|
|
@ -708,7 +699,7 @@ public class MainWindowController {
|
|
|
|
|
|
|
|
|
|
Platform.runLater(() -> { |
|
|
|
|
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); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
@ -870,8 +861,8 @@ public class MainWindowController {
|
|
|
|
|
|
|
|
|
|
// cloud sync init error dialog
|
|
|
|
|
JFXInfoAlert cloudSyncErrorDialog = new JFXInfoAlert( |
|
|
|
|
bundle.getString("cloudSyncErrorHeadingText"), |
|
|
|
|
bundle.getString("cloudSyncErrorBodyText"), dialogBtnStyle, primaryStage); |
|
|
|
|
XMLController.getLocalBundle().getString("cloudSyncErrorHeadingText"), |
|
|
|
|
XMLController.getLocalBundle().getString("cloudSyncErrorBodyText"), btnStyle, primaryStage); |
|
|
|
|
cloudSyncErrorDialog.showAndWait(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -881,8 +872,8 @@ public class MainWindowController {
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
JFXOkayCancelAlert cloudSyncWarningAlert = new JFXOkayCancelAlert( |
|
|
|
|
bundle.getString("cloudSyncWaringHeadingText"), bundle.getString("cloudSyncWaringHeadingText"), |
|
|
|
|
dialogBtnStyle, primaryStage); |
|
|
|
|
XMLController.getLocalBundle().getString("cloudSyncWaringHeadingText"), |
|
|
|
|
XMLController.getLocalBundle().getString("cloudSyncWaringHeadingText"), btnStyle, primaryStage); |
|
|
|
|
cloudSyncWarningAlert.setOkayAction(okayAction); |
|
|
|
|
cloudSyncWarningAlert.setCancelAction(e -> cloudSyncToggleBtn.setSelected(false)); |
|
|
|
|
cloudSyncWarningAlert.showAndWait(); |
|
|
|
@ -897,10 +888,10 @@ public class MainWindowController {
|
|
|
|
|
|
|
|
|
|
@FXML |
|
|
|
|
private void addBtnAction() { |
|
|
|
|
JFXEditGameDialog addGameDialog = new JFXEditGameDialog(bundle.getString("addGameBtnHeadingText"), |
|
|
|
|
bundle.getString("addGameBtnBodyText"), dialogBtnStyle, 450, 300, 0, this, primaryStage, |
|
|
|
|
main.getPane()); |
|
|
|
|
addGameDialog.show(); |
|
|
|
|
JFXEditGameAlert addGameAlert = new JFXEditGameAlert( |
|
|
|
|
XMLController.getLocalBundle().getString("addGameBtnHeadingText"), |
|
|
|
|
XMLController.getLocalBundle().getString("addGameBtnBodyText"), btnStyle, 0, primaryStage, MWC); |
|
|
|
|
addGameAlert.showAndWait(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -916,9 +907,10 @@ public class MainWindowController {
|
|
|
|
|
if (romPath.length() == 0 || coverPath.length() == 0 || title.length() == 0 || titleID.length() == 0) { |
|
|
|
|
LOGGER.info("No parameter set!"); |
|
|
|
|
|
|
|
|
|
//addGame error dialog
|
|
|
|
|
JFXInfoAlert errorAlert = new JFXInfoAlert(bundle.getString("addBtnReturnErrorHeadingText"), |
|
|
|
|
bundle.getString("addBtnReturnErrorBodyText"), dialogBtnStyle, primaryStage); |
|
|
|
|
// addGame error dialog
|
|
|
|
|
JFXInfoAlert errorAlert = new JFXInfoAlert( |
|
|
|
|
XMLController.getLocalBundle().getString("addBtnReturnErrorHeadingText"), |
|
|
|
|
XMLController.getLocalBundle().getString("addBtnReturnErrorBodyText"), btnStyle, primaryStage); |
|
|
|
|
errorAlert.showAndWait(); |
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
@ -936,7 +928,8 @@ public class MainWindowController {
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
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) { |
|
|
|
|
sideMenuSlideOut(); |
|
|
|
|
burgerTask.setRate(-1.0); |
|
|
|
@ -953,7 +946,8 @@ public class MainWindowController {
|
|
|
|
|
public void editBtnReturn(String title, String coverPath, String romPath, String titleID) { |
|
|
|
|
dbController.setGameInfo(title, coverPath, romPath, titleID); |
|
|
|
|
games.remove(selectedUIDataIndex); |
|
|
|
|
dbController.loadSingleGame(titleID); |
|
|
|
|
games.add(dbController.loadSingleGame(titleID)); |
|
|
|
|
addGame(games.stream().filter(x -> x.getRomPath().equals(romPath)).findFirst().orElse(null)); |
|
|
|
|
refreshUIData(); |
|
|
|
|
|
|
|
|
|
LOGGER.info("successfully edited " + titleID + ", new name is \"" + title + "\""); |
|
|
|
@ -967,7 +961,7 @@ public class MainWindowController {
|
|
|
|
|
* @param titleID : game ID |
|
|
|
|
*/ |
|
|
|
|
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>() { |
|
|
|
|
@Override |
|
|
|
@ -1038,6 +1032,85 @@ public class MainWindowController {
|
|
|
|
|
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 |
|
|
|
|
*/ |
|
|
|
@ -1055,10 +1128,10 @@ public class MainWindowController {
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
games = dbController.loadAllGames(); |
|
|
|
|
addAllGames(); |
|
|
|
|
|
|
|
|
|
Platform.runLater(() -> { |
|
|
|
|
refreshUIData(); // refresh the list of games displayed on screen
|
|
|
|
|
mainAnchorPane.getChildren().remove(spinner); |
|
|
|
|
}); |
|
|
|
|
}; |
|
|
|
@ -1077,58 +1150,55 @@ public class MainWindowController {
|
|
|
|
|
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
|
|
|
|
|
languageChoisBox.getSelectionModel().select(0); |
|
|
|
|
break; |
|
|
|
|
case "de_DE": |
|
|
|
|
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); |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
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); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Buttons
|
|
|
|
|
aboutBtn.setText(bundle.getString("aboutBtn")); |
|
|
|
|
settingsBtn.setText(bundle.getString("settingsBtn")); |
|
|
|
|
addBtn.setText(bundle.getString("addBtn")); |
|
|
|
|
reloadRomsBtn.setText(bundle.getString("reloadRomsBtn")); |
|
|
|
|
smmdbBtn.setText(bundle.getString("smmdbBtn")); |
|
|
|
|
cemuTFBtn.setText(bundle.getString("cemuTFBtn")); |
|
|
|
|
romTFBtn.setText(bundle.getString("romTFBtn")); |
|
|
|
|
updateBtn.setText(bundle.getString("updateBtnCheckNow")); |
|
|
|
|
smmdbDownloadBtn.setText(bundle.getString("smmdbDownloadBtn")); |
|
|
|
|
playBtn.setText(bundle.getString("playBtn")); |
|
|
|
|
cloudSyncToggleBtn.setText(bundle.getString("cloudSyncToggleBtn")); |
|
|
|
|
autoUpdateToggleBtn.setText(bundle.getString("autoUpdateToggleBtn")); |
|
|
|
|
fullscreenToggleBtn.setText(bundle.getString("fullscreenToggleBtn")); |
|
|
|
|
aboutBtn.setText(XMLController.getLocalBundle().getString("aboutBtn")); |
|
|
|
|
settingsBtn.setText(XMLController.getLocalBundle().getString("settingsBtn")); |
|
|
|
|
addBtn.setText(XMLController.getLocalBundle().getString("addBtn")); |
|
|
|
|
reloadRomsBtn.setText(XMLController.getLocalBundle().getString("reloadRomsBtn")); |
|
|
|
|
smmdbBtn.setText(XMLController.getLocalBundle().getString("smmdbBtn")); |
|
|
|
|
cemuTFBtn.setText(XMLController.getLocalBundle().getString("cemuTFBtn")); |
|
|
|
|
romTFBtn.setText(XMLController.getLocalBundle().getString("romTFBtn")); |
|
|
|
|
updateBtn.setText(XMLController.getLocalBundle().getString("updateBtnCheckNow")); |
|
|
|
|
smmdbDownloadBtn.setText(XMLController.getLocalBundle().getString("smmdbDownloadBtn")); |
|
|
|
|
playBtn.setText(XMLController.getLocalBundle().getString("playBtn")); |
|
|
|
|
cloudSyncToggleBtn.setText(XMLController.getLocalBundle().getString("cloudSyncToggleBtn")); |
|
|
|
|
autoUpdateToggleBtn.setText(XMLController.getLocalBundle().getString("autoUpdateToggleBtn")); |
|
|
|
|
fullscreenToggleBtn.setText(XMLController.getLocalBundle().getString("fullscreenToggleBtn")); |
|
|
|
|
|
|
|
|
|
// Labels
|
|
|
|
|
cemu_UISettingsLbl.setText(bundle.getString("cemu_UISettingsLbl")); |
|
|
|
|
cemuDirectoryLbl.setText(bundle.getString("cemuDirectoryLbl")); |
|
|
|
|
romDirectoryLbl.setText(bundle.getString("romDirectoryLbl")); |
|
|
|
|
mainColorLbl.setText(bundle.getString("mainColorLbl")); |
|
|
|
|
languageLbl.setText(bundle.getString("languageLbl")); |
|
|
|
|
updateLbl.setText(bundle.getString("updateLbl")); |
|
|
|
|
branchLbl.setText(bundle.getString("branchLbl")); |
|
|
|
|
cemuSettingsLbl.setText(bundle.getString("cemuSettingsLbl")); |
|
|
|
|
licensesLbl.setText(bundle.getString("licensesLbl")); |
|
|
|
|
cemu_UISettingsLbl.setText(XMLController.getLocalBundle().getString("cemu_UISettingsLbl")); |
|
|
|
|
cemuDirectoryLbl.setText(XMLController.getLocalBundle().getString("cemuDirectoryLbl")); |
|
|
|
|
romDirectoryLbl.setText(XMLController.getLocalBundle().getString("romDirectoryLbl")); |
|
|
|
|
mainColorLbl.setText(XMLController.getLocalBundle().getString("mainColorLbl")); |
|
|
|
|
languageLbl.setText(XMLController.getLocalBundle().getString("languageLbl")); |
|
|
|
|
updateLbl.setText(XMLController.getLocalBundle().getString("updateLbl")); |
|
|
|
|
branchLbl.setText(XMLController.getLocalBundle().getString("branchLbl")); |
|
|
|
|
cemuSettingsLbl.setText(XMLController.getLocalBundle().getString("cemuSettingsLbl")); |
|
|
|
|
licensesLbl.setText(XMLController.getLocalBundle().getString("licensesLbl")); |
|
|
|
|
|
|
|
|
|
// Columns
|
|
|
|
|
titleColumn.setText(bundle.getString("titleColumn")); |
|
|
|
|
idColumn.setText(bundle.getString("idColumn")); |
|
|
|
|
starsColumn.setText(bundle.getString("starsColumn")); |
|
|
|
|
timeColumn.setText(bundle.getString("timeColumn")); |
|
|
|
|
titleColumn.setText(XMLController.getLocalBundle().getString("titleColumn")); |
|
|
|
|
idColumn.setText(XMLController.getLocalBundle().getString("idColumn")); |
|
|
|
|
starsColumn.setText(XMLController.getLocalBundle().getString("starsColumn")); |
|
|
|
|
timeColumn.setText(XMLController.getLocalBundle().getString("timeColumn")); |
|
|
|
|
|
|
|
|
|
// Strings
|
|
|
|
|
lastPlayed = bundle.getString("lastPlayed"); |
|
|
|
|
today = bundle.getString("today"); |
|
|
|
|
yesterday = bundle.getString("yesterday"); |
|
|
|
|
never = bundle.getString("never"); |
|
|
|
|
lastPlayed = XMLController.getLocalBundle().getString("lastPlayed"); |
|
|
|
|
today = XMLController.getLocalBundle().getString("today"); |
|
|
|
|
yesterday = XMLController.getLocalBundle().getString("yesterday"); |
|
|
|
|
never = XMLController.getLocalBundle().getString("never"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// if AutoUpdate, then check for updates
|
|
|
|
@ -1271,8 +1341,7 @@ public class MainWindowController {
|
|
|
|
|
// change the color of all needed GUI elements
|
|
|
|
|
private void applyColor() { |
|
|
|
|
String boxStyle = "-fx-background-color: #" + XMLController.getColor() + ";"; |
|
|
|
|
String btnStyleBlack = "-fx-button-type: RAISED; -fx-background-color: #" + XMLController.getColor() + "; -fx-text-fill: BLACK;"; |
|
|
|
|
String btnStyleWhite = "-fx-button-type: RAISED; -fx-background-color: #" + XMLController.getColor() + "; -fx-text-fill: WHITE;"; |
|
|
|
|
String textFill = ""; |
|
|
|
|
BigInteger icolor = new BigInteger(XMLController.getColor(),16); |
|
|
|
|
BigInteger ccolor = new BigInteger("78909cff",16); |
|
|
|
|
|
|
|
|
@ -1282,55 +1351,45 @@ public class MainWindowController {
|
|
|
|
|
romTextField.setFocusColor(Color.valueOf(XMLController.getColor())); |
|
|
|
|
|
|
|
|
|
if (icolor.compareTo(ccolor) == -1) { |
|
|
|
|
dialogBtnStyle = btnStyleWhite; |
|
|
|
|
|
|
|
|
|
aboutBtn.setStyle("-fx-text-fill: WHITE;"); |
|
|
|
|
settingsBtn.setStyle("-fx-text-fill: WHITE;"); |
|
|
|
|
addBtn.setStyle("-fx-text-fill: WHITE;"); |
|
|
|
|
reloadRomsBtn.setStyle("-fx-text-fill: WHITE;"); |
|
|
|
|
smmdbBtn.setStyle("-fx-text-fill: WHITE;"); |
|
|
|
|
playBtn.setStyle("-fx-text-fill: WHITE; -fx-font-family: Roboto Medium;"); |
|
|
|
|
cemuTFBtn.setStyle(btnStyleWhite); |
|
|
|
|
romTFBtn.setStyle(btnStyleWhite); |
|
|
|
|
updateBtn.setStyle(btnStyleWhite); |
|
|
|
|
smmdbDownloadBtn.setStyle(btnStyleWhite); |
|
|
|
|
playBtn.setStyle(btnStyleWhite); |
|
|
|
|
|
|
|
|
|
aboutBtn.setGraphic(info_white); |
|
|
|
|
settingsBtn.setGraphic(settings_white); |
|
|
|
|
addBtn.setGraphic(add_circle_white); |
|
|
|
|
reloadRomsBtn.setGraphic(cached_white); |
|
|
|
|
smmdbBtn.setGraphic(smmdb_white); |
|
|
|
|
textFill = "-fx-text-fill: WHITE;"; |
|
|
|
|
|
|
|
|
|
aboutBtn.setGraphic(new ImageView(new Image("icons/ic_info_white_24dp_1x.png"))); |
|
|
|
|
settingsBtn.setGraphic(new ImageView(new Image("icons/ic_settings_white_24dp_1x.png"))); |
|
|
|
|
addBtn.setGraphic(new ImageView(new Image("icons/ic_add_circle_white_24dp_1x.png"))); |
|
|
|
|
reloadRomsBtn.setGraphic(new ImageView(new Image("icons/ic_cached_white_24dp_1x.png"))); |
|
|
|
|
smmdbBtn.setGraphic(new ImageView(new Image("icons/ic_get_app_white_24dp_1x.png"))); |
|
|
|
|
|
|
|
|
|
menuHam.getStyleClass().clear(); |
|
|
|
|
menuHam.getStyleClass().add("jfx-hamburgerW"); |
|
|
|
|
} else { |
|
|
|
|
dialogBtnStyle = btnStyleBlack; |
|
|
|
|
|
|
|
|
|
aboutBtn.setStyle("-fx-text-fill: BLACK;"); |
|
|
|
|
settingsBtn.setStyle("-fx-text-fill: BLACK;"); |
|
|
|
|
addBtn.setStyle("-fx-text-fill: BLACK;"); |
|
|
|
|
reloadRomsBtn.setStyle("-fx-text-fill: BLACK;"); |
|
|
|
|
smmdbBtn.setStyle("-fx-text-fill: BLACK;"); |
|
|
|
|
playBtn.setStyle("-fx-text-fill: BLACK; -fx-font-family: Roboto Medium;"); |
|
|
|
|
cemuTFBtn.setStyle(btnStyleBlack); |
|
|
|
|
romTFBtn.setStyle(btnStyleBlack); |
|
|
|
|
updateBtn.setStyle(btnStyleBlack); |
|
|
|
|
smmdbDownloadBtn.setStyle(btnStyleBlack); |
|
|
|
|
playBtn.setStyle(btnStyleBlack); |
|
|
|
|
|
|
|
|
|
aboutBtn.setGraphic(info_black); |
|
|
|
|
settingsBtn.setGraphic(settings_black); |
|
|
|
|
addBtn.setGraphic(add_circle_black); |
|
|
|
|
reloadRomsBtn.setGraphic(cached_black); |
|
|
|
|
smmdbBtn.setGraphic(smmdb_black); |
|
|
|
|
textFill = "-fx-text-fill: BLACK;"; |
|
|
|
|
|
|
|
|
|
aboutBtn.setGraphic(new ImageView(new Image("icons/ic_info_black_24dp_1x.png"))); |
|
|
|
|
settingsBtn.setGraphic(new ImageView(new Image("icons/ic_settings_black_24dp_1x.png"))); |
|
|
|
|
addBtn.setGraphic(new ImageView(new Image("icons/ic_add_circle_black_24dp_1x.png"))); |
|
|
|
|
reloadRomsBtn.setGraphic(new ImageView(new Image("icons/ic_cached_black_24dp_1x.png"))); |
|
|
|
|
smmdbBtn.setGraphic(new ImageView(new Image("icons/ic_get_app_black_24dp_1x.png"))); |
|
|
|
|
|
|
|
|
|
menuHam.getStyleClass().clear(); |
|
|
|
|
menuHam.getStyleClass().add("jfx-hamburgerB"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
for (int i = 0; i < games.size(); i++) { |
|
|
|
|
games.get(i).getButton().setRipplerFill(Paint.valueOf(XMLController.getColor())); |
|
|
|
|
|
|
|
|
|
btnStyle = "-fx-button-type: RAISED; -fx-background-color: #" + XMLController.getColor() + "; " + textFill; |
|
|
|
|
|
|
|
|
|
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())); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -1411,10 +1470,6 @@ public class MainWindowController {
|
|
|
|
|
public Main getMain() { |
|
|
|
|
return main; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public DBController getDbController() { |
|
|
|
|
return dbController; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public Stage getPrimaryStage() { |
|
|
|
|
return primaryStage; |
|
|
|
@ -1444,18 +1499,6 @@ public class MainWindowController {
|
|
|
|
|
this.playBtn = playBtn; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public String getLanguage() { |
|
|
|
|
return language; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void setLanguage(String language) { |
|
|
|
|
this.language = language; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public ResourceBundle getBundle() { |
|
|
|
|
return bundle; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public AnchorPane getMainAnchorPane() { |
|
|
|
|
return mainAnchorPane; |
|
|
|
|
} |
|
|
|
|