code clean up and minor fixes

*better save twice than non
*fixed a bug that prevented cemu_UI from finding the savegames folder in
google drive
This commit is contained in:
Seil0 2017-05-25 19:07:16 +02:00
parent 65b716cb77
commit 9ab7b61cd9
23 changed files with 110 additions and 40 deletions

3
bin/.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
/application/
/recources/
/cloudControllerInstances/

View File

@ -30,22 +30,27 @@
</HBox> </HBox>
<VBox fx:id="sideMenuVBox" layoutY="32.0" prefHeight="568.0" prefWidth="175.0" visible="false" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="38.0"> <VBox fx:id="sideMenuVBox" layoutY="32.0" prefHeight="568.0" prefWidth="175.0" visible="false" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="38.0">
<children> <children>
<JFXButton fx:id="aboutBtn" alignment="TOP_LEFT" maxHeight="38.0" maxWidth="150.0" onAction="#aboutBtnAction" prefHeight="38.0" prefWidth="150.0" text="About" textAlignment="LEFT"> <JFXButton fx:id="aboutBtn" alignment="TOP_LEFT" maxHeight="38.0" maxWidth="190.0" onAction="#aboutBtnAction" prefHeight="38.0" prefWidth="190.0" text="About" textAlignment="LEFT">
<font> <font>
<Font name="System Bold" size="14.0" /> <Font name="System Bold" size="14.0" />
</font> </font>
</JFXButton> </JFXButton>
<JFXButton fx:id="settingsBtn" alignment="TOP_LEFT" maxHeight="38.0" maxWidth="150.0" onAction="#settingsBtnAction" prefHeight="38.0" prefWidth="150.0" text="Settings" textAlignment="LEFT"> <JFXButton fx:id="settingsBtn" alignment="TOP_LEFT" maxHeight="38.0" maxWidth="213.0" onAction="#settingsBtnAction" prefHeight="38.0" prefWidth="213.0" text="Settings" textAlignment="LEFT">
<font> <font>
<Font name="System Bold" size="14.0" /> <Font name="System Bold" size="14.0" />
</font> </font>
</JFXButton> </JFXButton>
<JFXButton fx:id="addBtn" alignment="TOP_LEFT" maxHeight="38.0" maxWidth="150.0" onAction="#addBtnAction" prefHeight="38.0" prefWidth="150.0" text="Add new Game" textAlignment="LEFT"> <JFXButton fx:id="addBtn" alignment="TOP_LEFT" maxHeight="38.0" maxWidth="193.0" onAction="#addBtnAction" prefHeight="38.0" prefWidth="193.0" text="Add new Game" textAlignment="LEFT">
<font> <font>
<Font name="System Bold" size="14.0" /> <Font name="System Bold" size="14.0" />
</font> </font>
</JFXButton> </JFXButton>
<JFXButton fx:id="reloadRomsBtn" alignment="TOP_LEFT" maxHeight="38.0" maxWidth="150.0" onAction="#reloadRomsBtnAction" prefHeight="38.0" prefWidth="150.0" text="reload roms" textAlignment="LEFT"> <JFXButton fx:id="reloadRomsBtn" alignment="TOP_LEFT" maxHeight="38.0" maxWidth="199.0" onAction="#reloadRomsBtnAction" prefHeight="38.0" prefWidth="199.0" text="reload roms" textAlignment="LEFT">
<font>
<Font name="System Bold" size="14.0" />
</font>
</JFXButton>
<JFXButton fx:id="smmdbBtn" alignment="TOP_LEFT" onAction="#smmdbBtnAction" prefHeight="38.0" prefWidth="216.0" text="smmdb">
<font> <font>
<Font name="System Bold" size="14.0" /> <Font name="System Bold" size="14.0" />
</font> </font>
@ -53,7 +58,7 @@
</children> </children>
</VBox> </VBox>
<!-- space between settings sections 35px, between sections elements (label + element) 20px, between label and element 3px(or more) --> <!-- space between settings sections 35px, between sections elements (label + element) 20px, between label and element 3px(or more) -->
<AnchorPane fx:id="settingsAnchorPane" layoutX="38.0" layoutY="27.0" prefHeight="573.0" prefWidth="862.0" style="-fx-background-color: white;" visible="false" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="175.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="38.0"> <AnchorPane fx:id="settingsAnchorPane" layoutX="38.0" layoutY="27.0" prefHeight="573.0" style="-fx-background-color: white;" visible="false" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="175.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="38.0">
<children> <children>
<Label layoutX="22.0" layoutY="59.0" text="Cemu Directory" AnchorPane.leftAnchor="14.0" AnchorPane.topAnchor="59.0" /> <Label layoutX="22.0" layoutY="59.0" text="Cemu Directory" AnchorPane.leftAnchor="14.0" AnchorPane.topAnchor="59.0" />
<JFXTextField fx:id="cemuTextField" layoutX="18.0" layoutY="83.0" maxWidth="305.0" minWidth="305.0" onAction="#cemuTextFieldAction" prefHeight="32.0" prefWidth="305.0" promptText="cemu directory" AnchorPane.leftAnchor="14.0" AnchorPane.topAnchor="79.0" /> <JFXTextField fx:id="cemuTextField" layoutX="18.0" layoutY="83.0" maxWidth="305.0" minWidth="305.0" onAction="#cemuTextFieldAction" prefHeight="32.0" prefWidth="305.0" promptText="cemu directory" AnchorPane.leftAnchor="14.0" AnchorPane.topAnchor="79.0" />
@ -77,6 +82,7 @@
<JFXToggleButton fx:id="cloudSyncToggleBtn" layoutX="14.0" layoutY="264.0" onAction="#cloudSyncToggleBtnAction" text="cloud savegames (Google Drive)" AnchorPane.leftAnchor="14.0" AnchorPane.topAnchor="267.0" /> <JFXToggleButton fx:id="cloudSyncToggleBtn" layoutX="14.0" layoutY="264.0" onAction="#cloudSyncToggleBtnAction" text="cloud savegames (Google Drive)" AnchorPane.leftAnchor="14.0" AnchorPane.topAnchor="267.0" />
</children> </children>
</AnchorPane> </AnchorPane>
<AnchorPane fx:id="smmdbAnchorPane" style="-fx-background-color: white;" visible="false" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="175.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="38.0" />
<JFXButton fx:id="playBtn" buttonType="RAISED" maxHeight="38.0" maxWidth="100.0" onAction="#playBtnAction" ripplerFill="#c92a2a" text="play" visible="false" AnchorPane.bottomAnchor="7.0" AnchorPane.leftAnchor="396.0" AnchorPane.rightAnchor="396.0" AnchorPane.topAnchor="555.0"> <JFXButton fx:id="playBtn" buttonType="RAISED" maxHeight="38.0" maxWidth="100.0" onAction="#playBtnAction" ripplerFill="#c92a2a" text="play" visible="false" AnchorPane.bottomAnchor="7.0" AnchorPane.leftAnchor="396.0" AnchorPane.rightAnchor="396.0" AnchorPane.topAnchor="555.0">
<font> <font>
<Font name="System Bold" size="14.0" /> <Font name="System Bold" size="14.0" />

Binary file not shown.

View File

@ -30,21 +30,22 @@ public class CloudController {
void initializeConnection(String cloudService, String cemuDirectory) { void initializeConnection(String cloudService, String cemuDirectory) {
System.out.println("sartting cloud initialisation... "); System.out.println("sartting cloud initialisation... ");
if(cloudService == "GoogleDrive") { if(cloudService.equals("GoogleDrive")) {
System.out.println("selected service is Google Drive");
try { try {
googleDriveController.main(cemuDirectory); googleDriveController.main(cemuDirectory);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
if(cloudService == "Dropbox") { if(cloudService.equals("Dropbox")) {
System.out.println("selected service is Dropbox");
} }
System.out.println("cloud initialisation done!"); System.out.println("cloud initialisation done!");
} }
void stratupCheck(String cloudService, String cemuDirectory) { void stratupCheck(String cloudService, String cemuDirectory) {
if(cloudService == "GoogleDrive") { if(cloudService.equals("GoogleDrive")) {
System.out.println("starting startup check google drive..."); System.out.println("starting startup check google drive...");
try { try {
if (!googleDriveController.checkFolder()) { if (!googleDriveController.checkFolder()) {
@ -70,7 +71,7 @@ public class CloudController {
e.printStackTrace(); e.printStackTrace();
} }
} }
if(cloudService == "Dropbox") { if(cloudService.equals("Dropbox")) {
} }
} }
@ -87,19 +88,20 @@ public class CloudController {
}); });
System.out.println("starting sync in new thread..."); System.out.println("starting sync in new thread...");
if(cloudService == "GoogleDrive") { if(cloudService.equals("GoogleDrive")) {
try { try {
googleDriveController.sync(cemuDirectory); googleDriveController.sync(cemuDirectory);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
if(cloudService == "Dropbox") { if(cloudService.equals("Dropbox")) {
} }
Platform.runLater(() -> { Platform.runLater(() -> {
main.mainWindowController.getPlayBtn().setText("play"); main.mainWindowController.getPlayBtn().setText("play");
}); });
main.mainWindowController.saveSettings();
System.out.println("sync finished!"); System.out.println("sync finished!");
} }
}); });
@ -114,14 +116,14 @@ public class CloudController {
public void run() { public void run() {
System.out.println("starting uploadFile in new thread..."); System.out.println("starting uploadFile in new thread...");
if(cloudService == "GoogleDrive") { if(cloudService.equals("GoogleDrive")) {
try { try {
googleDriveController.uploadFile(file); googleDriveController.uploadFile(file);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
if(cloudService == "Dropbox") { if(cloudService.equals("Dropbox")) {
} }
} }
@ -129,26 +131,22 @@ public class CloudController {
} }
// void download(String cloudService) {
//
// }
public String getFolderID(String cloudService) { public String getFolderID(String cloudService) {
String folderID = ""; String folderID = "";
if(cloudService == "GoogleDrive") { if(cloudService.equals("GoogleDrive")) {
folderID = googleDriveController.getFolderID(); folderID = googleDriveController.getFolderID();
} }
if(cloudService == "Dropbox") { if(cloudService.equals("Dropbox")) {
} }
return folderID; return folderID;
} }
public void setFolderID(String folderID, String cloudService) { public void setFolderID(String folderID, String cloudService) {
if(cloudService == "GoogleDrive") { if(cloudService.equals("GoogleDrive")) {
googleDriveController.setFolderID(folderID); googleDriveController.setFolderID(folderID);
} }
if(cloudService == "Dropbox") { if(cloudService.equals("Dropbox")) {
} }
} }

View File

@ -30,22 +30,27 @@
</HBox> </HBox>
<VBox fx:id="sideMenuVBox" layoutY="32.0" prefHeight="568.0" prefWidth="175.0" visible="false" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="38.0"> <VBox fx:id="sideMenuVBox" layoutY="32.0" prefHeight="568.0" prefWidth="175.0" visible="false" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="38.0">
<children> <children>
<JFXButton fx:id="aboutBtn" alignment="TOP_LEFT" maxHeight="38.0" maxWidth="150.0" onAction="#aboutBtnAction" prefHeight="38.0" prefWidth="150.0" text="About" textAlignment="LEFT"> <JFXButton fx:id="aboutBtn" alignment="TOP_LEFT" maxHeight="38.0" maxWidth="190.0" onAction="#aboutBtnAction" prefHeight="38.0" prefWidth="190.0" text="About" textAlignment="LEFT">
<font> <font>
<Font name="System Bold" size="14.0" /> <Font name="System Bold" size="14.0" />
</font> </font>
</JFXButton> </JFXButton>
<JFXButton fx:id="settingsBtn" alignment="TOP_LEFT" maxHeight="38.0" maxWidth="150.0" onAction="#settingsBtnAction" prefHeight="38.0" prefWidth="150.0" text="Settings" textAlignment="LEFT"> <JFXButton fx:id="settingsBtn" alignment="TOP_LEFT" maxHeight="38.0" maxWidth="213.0" onAction="#settingsBtnAction" prefHeight="38.0" prefWidth="213.0" text="Settings" textAlignment="LEFT">
<font> <font>
<Font name="System Bold" size="14.0" /> <Font name="System Bold" size="14.0" />
</font> </font>
</JFXButton> </JFXButton>
<JFXButton fx:id="addBtn" alignment="TOP_LEFT" maxHeight="38.0" maxWidth="150.0" onAction="#addBtnAction" prefHeight="38.0" prefWidth="150.0" text="Add new Game" textAlignment="LEFT"> <JFXButton fx:id="addBtn" alignment="TOP_LEFT" maxHeight="38.0" maxWidth="193.0" onAction="#addBtnAction" prefHeight="38.0" prefWidth="193.0" text="Add new Game" textAlignment="LEFT">
<font> <font>
<Font name="System Bold" size="14.0" /> <Font name="System Bold" size="14.0" />
</font> </font>
</JFXButton> </JFXButton>
<JFXButton fx:id="reloadRomsBtn" alignment="TOP_LEFT" maxHeight="38.0" maxWidth="150.0" onAction="#reloadRomsBtnAction" prefHeight="38.0" prefWidth="150.0" text="reload roms" textAlignment="LEFT"> <JFXButton fx:id="reloadRomsBtn" alignment="TOP_LEFT" maxHeight="38.0" maxWidth="199.0" onAction="#reloadRomsBtnAction" prefHeight="38.0" prefWidth="199.0" text="reload roms" textAlignment="LEFT">
<font>
<Font name="System Bold" size="14.0" />
</font>
</JFXButton>
<JFXButton fx:id="smmdbBtn" alignment="TOP_LEFT" onAction="#smmdbBtnAction" prefHeight="38.0" prefWidth="216.0" text="smmdb">
<font> <font>
<Font name="System Bold" size="14.0" /> <Font name="System Bold" size="14.0" />
</font> </font>
@ -53,7 +58,7 @@
</children> </children>
</VBox> </VBox>
<!-- space between settings sections 35px, between sections elements (label + element) 20px, between label and element 3px(or more) --> <!-- space between settings sections 35px, between sections elements (label + element) 20px, between label and element 3px(or more) -->
<AnchorPane fx:id="settingsAnchorPane" layoutX="38.0" layoutY="27.0" prefHeight="573.0" prefWidth="862.0" style="-fx-background-color: white;" visible="false" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="175.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="38.0"> <AnchorPane fx:id="settingsAnchorPane" layoutX="38.0" layoutY="27.0" prefHeight="573.0" style="-fx-background-color: white;" visible="false" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="175.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="38.0">
<children> <children>
<Label layoutX="22.0" layoutY="59.0" text="Cemu Directory" AnchorPane.leftAnchor="14.0" AnchorPane.topAnchor="59.0" /> <Label layoutX="22.0" layoutY="59.0" text="Cemu Directory" AnchorPane.leftAnchor="14.0" AnchorPane.topAnchor="59.0" />
<JFXTextField fx:id="cemuTextField" layoutX="18.0" layoutY="83.0" maxWidth="305.0" minWidth="305.0" onAction="#cemuTextFieldAction" prefHeight="32.0" prefWidth="305.0" promptText="cemu directory" AnchorPane.leftAnchor="14.0" AnchorPane.topAnchor="79.0" /> <JFXTextField fx:id="cemuTextField" layoutX="18.0" layoutY="83.0" maxWidth="305.0" minWidth="305.0" onAction="#cemuTextFieldAction" prefHeight="32.0" prefWidth="305.0" promptText="cemu directory" AnchorPane.leftAnchor="14.0" AnchorPane.topAnchor="79.0" />
@ -77,6 +82,7 @@
<JFXToggleButton fx:id="cloudSyncToggleBtn" layoutX="14.0" layoutY="264.0" onAction="#cloudSyncToggleBtnAction" text="cloud savegames (Google Drive)" AnchorPane.leftAnchor="14.0" AnchorPane.topAnchor="267.0" /> <JFXToggleButton fx:id="cloudSyncToggleBtn" layoutX="14.0" layoutY="264.0" onAction="#cloudSyncToggleBtnAction" text="cloud savegames (Google Drive)" AnchorPane.leftAnchor="14.0" AnchorPane.topAnchor="267.0" />
</children> </children>
</AnchorPane> </AnchorPane>
<AnchorPane fx:id="smmdbAnchorPane" style="-fx-background-color: white;" visible="false" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="175.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="38.0" />
<JFXButton fx:id="playBtn" buttonType="RAISED" maxHeight="38.0" maxWidth="100.0" onAction="#playBtnAction" ripplerFill="#c92a2a" text="play" visible="false" AnchorPane.bottomAnchor="7.0" AnchorPane.leftAnchor="396.0" AnchorPane.rightAnchor="396.0" AnchorPane.topAnchor="555.0"> <JFXButton fx:id="playBtn" buttonType="RAISED" maxHeight="38.0" maxWidth="100.0" onAction="#playBtnAction" ripplerFill="#c92a2a" text="play" visible="false" AnchorPane.bottomAnchor="7.0" AnchorPane.leftAnchor="396.0" AnchorPane.rightAnchor="396.0" AnchorPane.topAnchor="555.0">
<font> <font>
<Font name="System Bold" size="14.0" /> <Font name="System Bold" size="14.0" />

View File

@ -27,6 +27,7 @@ import java.time.LocalDate;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.Optional; import java.util.Optional;
import java.util.Properties; import java.util.Properties;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
@ -37,6 +38,7 @@ import com.jfoenix.controls.JFXHamburger;
import com.jfoenix.controls.JFXTextField; import com.jfoenix.controls.JFXTextField;
import com.jfoenix.controls.JFXToggleButton; import com.jfoenix.controls.JFXToggleButton;
import com.jfoenix.transitions.hamburger.HamburgerBackArrowBasicTransition; import com.jfoenix.transitions.hamburger.HamburgerBackArrowBasicTransition;
import javafx.animation.FadeTransition; import javafx.animation.FadeTransition;
import javafx.animation.ParallelTransition; import javafx.animation.ParallelTransition;
import javafx.animation.TranslateTransition; import javafx.animation.TranslateTransition;
@ -82,6 +84,9 @@ public class MainWindowController {
@FXML @FXML
private JFXButton reloadRomsBtn; private JFXButton reloadRomsBtn;
@FXML
private JFXButton smmdbBtn;
@FXML @FXML
private JFXButton cemuTFBtn; private JFXButton cemuTFBtn;
@ -118,6 +123,9 @@ public class MainWindowController {
@FXML @FXML
private AnchorPane settingsAnchorPane; private AnchorPane settingsAnchorPane;
@FXML
private AnchorPane smmdbAnchorPane;
@FXML @FXML
private AnchorPane gamesAnchorPane; private AnchorPane gamesAnchorPane;
@ -138,7 +146,7 @@ public class MainWindowController {
private boolean playTrue = false; private boolean playTrue = false;
private boolean fullscreen; private boolean fullscreen;
private boolean cloudSync; private boolean cloudSync;
private String cloudService = "GoogleDrive"; //set cloud provider (at the moment only GoogleDrive, Dropbox is planed) private String cloudService; //set cloud provider (at the moment only GoogleDrive, Dropbox is planed)
private String cemuPath; private String cemuPath;
private String romPath; private String romPath;
private String gameExecutePath; private String gameExecutePath;
@ -146,7 +154,7 @@ public class MainWindowController {
private String selectedGameTitle; private String selectedGameTitle;
private String color; private String color;
private String version = "0.1.5"; private String version = "0.1.5";
private String buildNumber = "015"; private String buildNumber = "017";
private String versionName = "Gusty Garden"; private String versionName = "Gusty Garden";
private int xPos = -200; private int xPos = -200;
private int yPos = 17; private int yPos = 17;
@ -173,10 +181,12 @@ public class MainWindowController {
private ImageView info_black = new ImageView(new Image("recources/icons/ic_info_black_24dp_1x.png")); private ImageView info_black = new ImageView(new Image("recources/icons/ic_info_black_24dp_1x.png"));
private ImageView settings_black = new ImageView(new Image("recources/icons/ic_settings_black_24dp_1x.png")); private ImageView settings_black = new ImageView(new Image("recources/icons/ic_settings_black_24dp_1x.png"));
private ImageView cached_black = new ImageView(new Image("recources/icons/ic_cached_black_24dp_1x.png")); private ImageView cached_black = new ImageView(new Image("recources/icons/ic_cached_black_24dp_1x.png"));
private ImageView smmdb_black = new ImageView(new Image("recources/icons/ic_get_app_black_24dp_1x.png"));
private ImageView add_circle_white = new ImageView(new Image("recources/icons/ic_add_circle_white_24dp_1x.png")); private ImageView add_circle_white = new ImageView(new Image("recources/icons/ic_add_circle_white_24dp_1x.png"));
private ImageView info_white = new ImageView(new Image("recources/icons/ic_info_white_24dp_1x.png")); private ImageView info_white = new ImageView(new Image("recources/icons/ic_info_white_24dp_1x.png"));
private ImageView settings_white = new ImageView(new Image("recources/icons/ic_settings_white_24dp_1x.png")); private ImageView settings_white = new ImageView(new Image("recources/icons/ic_settings_white_24dp_1x.png"));
private ImageView cached_white = new ImageView(new Image("recources/icons/ic_cached_white_24dp_1x.png")); private ImageView cached_white = new ImageView(new Image("recources/icons/ic_cached_white_24dp_1x.png"));
private ImageView smmdb_white = new ImageView(new Image("recources/icons/ic_get_app_white_24dp_1x.png"));
public void setMain(Main main) { public void setMain(Main main) {
this.main = main; this.main = main;
@ -190,6 +200,7 @@ public class MainWindowController {
fullscreenToggleBtn.setSelected(isFullscreen()); fullscreenToggleBtn.setSelected(isFullscreen());
cloudSyncToggleBtn.setSelected(isCloudSync()); cloudSyncToggleBtn.setSelected(isCloudSync());
edit.setDisable(true); edit.setDisable(true);
smmdbBtn.setDisable(true);
applyColor(); applyColor();
} }
@ -457,6 +468,11 @@ public class MainWindowController {
System.exit(0); //finishes itself System.exit(0); //finishes itself
} }
@FXML
void smmdbBtnAction() {
System.out.println("yeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeehaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
}
@FXML @FXML
void playBtnAction(ActionEvent event) throws InterruptedException, IOException{ void playBtnAction(ActionEvent event) throws InterruptedException, IOException{
dbController.setLastPlayed(selectedGameTitleID); dbController.setLastPlayed(selectedGameTitleID);
@ -516,13 +532,13 @@ public class MainWindowController {
@FXML @FXML
void cemuTextFieldAction(ActionEvent event){ void cemuTextFieldAction(ActionEvent event){
setCemuPath(cemuTextField.getText()); setCemuPath(cemuTextField.getText());
saveSettings();//TODO remove (only save on exit settings) saveSettings();
} }
@FXML @FXML
void romTextFieldAction(ActionEvent event){ void romTextFieldAction(ActionEvent event){
setRomPath(romTextField.getText()); setRomPath(romTextField.getText());
saveSettings();//TODO remove (only save on exit settings) saveSettings();
} }
@FXML @FXML
@ -532,7 +548,7 @@ public class MainWindowController {
}else{ }else{
fullscreen = true; fullscreen = true;
} }
saveSettings();//TODO remove (only save on exit settings) saveSettings();
} }
@FXML @FXML
@ -548,6 +564,8 @@ public class MainWindowController {
Optional<ButtonType> coverResult = cloudWarningAlert.showAndWait(); Optional<ButtonType> coverResult = cloudWarningAlert.showAndWait();
if (coverResult.get() == ButtonType.OK){ if (coverResult.get() == ButtonType.OK){
cloudSync = true; cloudSync = true;
//TODO rework for other cloud services
cloudService = "GoogleDrive";
main.cloudController.initializeConnection(getCloudService(), getCemuPath()); main.cloudController.initializeConnection(getCloudService(), getCemuPath());
main.cloudController.sync(getCloudService(), getCemuPath()); main.cloudController.sync(getCloudService(), getCemuPath());
} else { } else {
@ -555,7 +573,7 @@ public class MainWindowController {
} }
} }
saveSettings();//TODO remove (only save on exit settings) saveSettings();
} }
@FXML @FXML
@ -666,11 +684,19 @@ public class MainWindowController {
dbController.loadSingleRom(titleID); dbController.loadSingleRom(titleID);
} catch (SQLException e) { } catch (SQLException e) {
// Auto-generated catch block // Auto-generated catch block
System.out.println("Oops, something went wrong! Error during adding a game.");
e.printStackTrace(); e.printStackTrace();
} }
} }
} }
/**
* add game to the program and initialize all needed actions (start, time stamps, titleID)
* @param title : game title
* @param coverPath : path to cover (cache)
* @param romPath : path to rom file (.rpx)
* @param titleID : rom ID
*/
void addGame(String title, String coverPath, String romPath, String titleID){ void addGame(String title, String coverPath, String romPath, String titleID){
ImageView imageView = new ImageView(); ImageView imageView = new ImageView();
Label gameTitleLabel = new Label(title); Label gameTitleLabel = new Label(title);
@ -698,6 +724,7 @@ public class MainWindowController {
public void handle(MouseEvent event) { public void handle(MouseEvent event) {
System.out.println("selected: "+title+"; ID: "+titleID); System.out.println("selected: "+title+"; ID: "+titleID);
//getting the selected game index by comparing event.getSource() with games.get(i).getButton()
for(int i=0; i<games.size(); i++){ for(int i=0; i<games.size(); i++){
if(games.get(i).getButton() == event.getSource()){ if(games.get(i).getButton() == event.getSource()){
selectedUIDataIndex = i; selectedUIDataIndex = i;
@ -711,7 +738,8 @@ public class MainWindowController {
lastGameLabel.setStyle("-fx-underline: false;"); lastGameLabel.setStyle("-fx-underline: false;");
games.get(selectedUIDataIndex).getLabel().setStyle("-fx-underline: true;"); games.get(selectedUIDataIndex).getLabel().setStyle("-fx-underline: true;");
lastGameLabel = games.get(selectedUIDataIndex).getLabel(); lastGameLabel = games.get(selectedUIDataIndex).getLabel();
//setting last played
if(dbController.getLastPlayed(titleID).equals("") || dbController.getLastPlayed(titleID).equals(null)){ if(dbController.getLastPlayed(titleID).equals("") || dbController.getLastPlayed(titleID).equals(null)){
lastTimePlayedBtn.setText("Last played, never"); lastTimePlayedBtn.setText("Last played, never");
timePlayedBtn.setText(dbController.getTimePlayed(titleID)+ " min"); timePlayedBtn.setText(dbController.getTimePlayed(titleID)+ " min");
@ -737,16 +765,20 @@ public class MainWindowController {
timePlayedBtn.setText(dbController.getTimePlayed(titleID)+ " min"); timePlayedBtn.setText(dbController.getTimePlayed(titleID)+ " min");
} }
} }
if(playTrue == false){ if (!playTrue) {
playBtnSlideIn(); playBtnSlideIn();
} }
if (menuTrue) {
sideMenuSlideOut();
}
} }
}); });
games.add(new uiDataType(VBox, gameTitleLabel, gameBtn, titleID, romPath)); games.add(new uiDataType(VBox, gameTitleLabel, gameBtn, titleID, romPath));
} }
//add all games to the UI (only called on startup)
void addUIData(){ void addUIData(){
for(int i=0; i<games.size(); i++){ for(int i=0; i<games.size(); i++){
gamesAnchorPane.getChildren().add(games.get(i).getVBox()); gamesAnchorPane.getChildren().add(games.get(i).getVBox());
@ -784,6 +816,7 @@ public class MainWindowController {
settingsBtn.setStyle("-fx-text-fill: WHITE;"); settingsBtn.setStyle("-fx-text-fill: WHITE;");
addBtn.setStyle("-fx-text-fill: WHITE;"); addBtn.setStyle("-fx-text-fill: WHITE;");
reloadRomsBtn.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;"); playBtn.setStyle("-fx-text-fill: WHITE; -fx-font-family: Roboto Medium;");
cemuTFBtn.setStyle(btnStyleWhite); cemuTFBtn.setStyle(btnStyleWhite);
romTFBtn.setStyle(btnStyleWhite); romTFBtn.setStyle(btnStyleWhite);
@ -793,6 +826,7 @@ public class MainWindowController {
settingsBtn.setGraphic(settings_white); settingsBtn.setGraphic(settings_white);
addBtn.setGraphic(add_circle_white); addBtn.setGraphic(add_circle_white);
reloadRomsBtn.setGraphic(cached_white); reloadRomsBtn.setGraphic(cached_white);
smmdbBtn.setGraphic(smmdb_white);
menuHam.getStyleClass().add("jfx-hamburgerW"); menuHam.getStyleClass().add("jfx-hamburgerW");
}else{ }else{
@ -800,6 +834,7 @@ public class MainWindowController {
settingsBtn.setStyle("-fx-text-fill: BLACK;"); settingsBtn.setStyle("-fx-text-fill: BLACK;");
addBtn.setStyle("-fx-text-fill: BLACK;"); addBtn.setStyle("-fx-text-fill: BLACK;");
reloadRomsBtn.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;"); playBtn.setStyle("-fx-text-fill: BLACK; -fx-font-family: Roboto Medium;");
cemuTFBtn.setStyle(btnStyleBlack); cemuTFBtn.setStyle(btnStyleBlack);
romTFBtn.setStyle(btnStyleBlack); romTFBtn.setStyle(btnStyleBlack);
@ -809,6 +844,7 @@ public class MainWindowController {
settingsBtn.setGraphic(settings_black); settingsBtn.setGraphic(settings_black);
addBtn.setGraphic(add_circle_black); addBtn.setGraphic(add_circle_black);
reloadRomsBtn.setGraphic(cached_black); reloadRomsBtn.setGraphic(cached_black);
smmdbBtn.setGraphic(smmdb_black);
menuHam.getStyleClass().add("jfx-hamburgerB"); menuHam.getStyleClass().add("jfx-hamburgerB");
} }
@ -827,6 +863,7 @@ public class MainWindowController {
props.setProperty("color", getColor()); props.setProperty("color", getColor());
props.setProperty("fullscreen", String.valueOf(isFullscreen())); props.setProperty("fullscreen", String.valueOf(isFullscreen()));
props.setProperty("cloudSync", String.valueOf(cloudSync)); props.setProperty("cloudSync", String.valueOf(cloudSync));
props.setProperty("cloudService", getCloudService());
props.setProperty("folderID", main.cloudController.getFolderID(getCloudService())); props.setProperty("folderID", main.cloudController.getFolderID(getCloudService()));
if(System.getProperty("os.name").equals("Linux")){ if(System.getProperty("os.name").equals("Linux")){
outputStream = new FileOutputStream(fileLinux); outputStream = new FileOutputStream(fileLinux);
@ -856,6 +893,7 @@ public class MainWindowController {
setColor(props.getProperty("color")); setColor(props.getProperty("color"));
setFullscreen(Boolean.parseBoolean(props.getProperty("fullscreen"))); setFullscreen(Boolean.parseBoolean(props.getProperty("fullscreen")));
setCloudSync(Boolean.parseBoolean(props.getProperty("cloudSync"))); setCloudSync(Boolean.parseBoolean(props.getProperty("cloudSync")));
setCloudService(props.getProperty("cloudService"));
main.cloudController.setFolderID(props.getProperty("folderID"), getCloudService()); main.cloudController.setFolderID(props.getProperty("folderID"), getCloudService());
inputStream.close(); inputStream.close();
System.out.println("done!"); System.out.println("done!");

View File

@ -53,7 +53,7 @@ public class dbController {
loadRomDatabase(); loadRomDatabase();
loadGamesDatabase(); loadGamesDatabase();
createRomDatabase(); createRomDatabase();
loadRoms(); loadAllRoms();
checkRemoveEntry(); checkRemoveEntry();
System.out.println("<==========finished loading sql==========>"); System.out.println("<==========finished loading sql==========>");
} }
@ -141,7 +141,7 @@ public class dbController {
} }
//load all rom's on startup to the UI //load all rom's on startup to the UI
void loadRoms(){ void loadAllRoms(){
System.out.println("loading all rom's on startup to mwc ..."); System.out.println("loading all rom's on startup to mwc ...");
try { try {
Statement stmt = connection.createStatement(); Statement stmt = connection.createStatement();

View File

@ -110,6 +110,10 @@ public class GoogleDriveController {
} }
public void sync(String cemuDirectory) throws IOException { public void sync(String cemuDirectory) throws IOException {
//in case there is no folderID saved, look it up first
if (getFolderID() == "" || getFolderID() == null) {
getSavegamesFolderID();
}
getLocalSavegames(); getLocalSavegames();
getCloudSavegames(); getCloudSavegames();
@ -205,7 +209,21 @@ public class GoogleDriveController {
cloudSavegamesName.add(file.getName()); cloudSavegamesName.add(file.getName());
cloudSavegames.add(file); cloudSavegames.add(file);
} }
} }
private void getSavegamesFolderID() throws IOException {
Files.List request = service.files().list().setQ("mimeType = 'application/vnd.google-apps.folder' and name = 'cemu_savegames'");
FileList files = request.execute();
try {
System.out.println("FolderID: " + files.getFiles().get(0).getId());
setFolderID(files.getFiles().get(0).getId());
} catch (Exception e) {
System.out.println("Oops, something went wrong! It seems that you have more than one folder called 'cemu_savegames'!");
e.printStackTrace();
}
}
//upload a file to the cloud from the local savegames folder //upload a file to the cloud from the local savegames folder
public void uploadFile(java.io.File uploadFile) throws IOException{ public void uploadFile(java.io.File uploadFile) throws IOException{
@ -261,6 +279,7 @@ public class GoogleDriveController {
System.out.println("finished uploading all files!"); System.out.println("finished uploading all files!");
} catch (IOException e) { } catch (IOException e) {
//Auto-generated catch block //Auto-generated catch block
System.out.println("Oops, there went something wrong! Error during uploading all files.");
e.printStackTrace(); e.printStackTrace();
} }
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 114 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 116 B