|
|
|
@ -24,12 +24,8 @@ import java.awt.Graphics2D;
|
|
|
|
|
import java.awt.image.BufferedImage; |
|
|
|
|
import java.io.BufferedReader; |
|
|
|
|
import java.io.File; |
|
|
|
|
import java.io.FileInputStream; |
|
|
|
|
import java.io.FileOutputStream; |
|
|
|
|
import java.io.IOException; |
|
|
|
|
import java.io.InputStream; |
|
|
|
|
import java.io.InputStreamReader; |
|
|
|
|
import java.io.OutputStream; |
|
|
|
|
import java.math.BigInteger; |
|
|
|
|
import java.net.HttpURLConnection; |
|
|
|
|
import java.net.MalformedURLException; |
|
|
|
@ -54,6 +50,7 @@ import org.apache.logging.log4j.Logger;
|
|
|
|
|
import com.cemu_UI.controller.DBController; |
|
|
|
|
import com.cemu_UI.controller.SmmdbAPIController; |
|
|
|
|
import com.cemu_UI.controller.UpdateController; |
|
|
|
|
import com.cemu_UI.controller.XMLController; |
|
|
|
|
import com.cemu_UI.datatypes.CourseTableDataType; |
|
|
|
|
import com.cemu_UI.datatypes.GlobalDataTypes.CloudService; |
|
|
|
|
import com.cemu_UI.datatypes.SmmdbApiDataType; |
|
|
|
@ -102,6 +99,7 @@ import javafx.scene.text.FontWeight;
|
|
|
|
|
import javafx.scene.text.Text; |
|
|
|
|
import javafx.scene.text.TextFlow; |
|
|
|
|
import javafx.stage.DirectoryChooser; |
|
|
|
|
import javafx.stage.Stage; |
|
|
|
|
import javafx.util.Duration; |
|
|
|
|
import net.lingala.zip4j.core.ZipFile; |
|
|
|
|
import net.lingala.zip4j.exception.ZipException; |
|
|
|
@ -182,19 +180,13 @@ public class MainWindowController {
|
|
|
|
|
private playGame playGame; |
|
|
|
|
private static MainWindowController MWC; |
|
|
|
|
private UpdateController updateController; |
|
|
|
|
private XMLController xmlController; |
|
|
|
|
private Stage primaryStage; |
|
|
|
|
private boolean menuTrue = false; |
|
|
|
|
private boolean settingsTrue = false; |
|
|
|
|
private boolean playTrue = false; |
|
|
|
|
private boolean smmdbTrue = false; |
|
|
|
|
private boolean autoUpdate = false; |
|
|
|
|
private boolean useBeta = false; |
|
|
|
|
private boolean fullscreen; |
|
|
|
|
private boolean cloudSync; |
|
|
|
|
private CloudService cloudService; |
|
|
|
|
private String cemuPath; |
|
|
|
|
private String romDirectoryPath; |
|
|
|
|
private String gameExecutePath; |
|
|
|
|
private String color; |
|
|
|
|
private String dialogBtnStyle; |
|
|
|
|
private String selectedGameTitleID; |
|
|
|
|
private String selectedGameTitle; |
|
|
|
@ -204,13 +196,10 @@ public class MainWindowController {
|
|
|
|
|
private String versionName = "Purple Comet"; |
|
|
|
|
private int xPos = -200; |
|
|
|
|
private int yPos = 17; |
|
|
|
|
private int xPosHelper; |
|
|
|
|
private int xPosHelper = 0; |
|
|
|
|
private int oldXPosHelper; |
|
|
|
|
private int selectedUIDataIndex; |
|
|
|
|
private int selected; |
|
|
|
|
private long lastLocalSync; |
|
|
|
|
private double windowWidth; |
|
|
|
|
private double windowHeight; |
|
|
|
|
private DirectoryChooser directoryChooser = new DirectoryChooser(); |
|
|
|
|
private ObservableList<String> branches = FXCollections.observableArrayList("stable", "beta"); |
|
|
|
|
private ObservableList<String> languages = FXCollections.observableArrayList("English (en_US)", "Deutsch (de_DE)"); |
|
|
|
@ -279,8 +268,9 @@ public class MainWindowController {
|
|
|
|
|
private String smmdbDownloadBtnDownload; |
|
|
|
|
|
|
|
|
|
public MainWindowController(Main main) { |
|
|
|
|
xmlController = new XMLController(); |
|
|
|
|
this.main = main; |
|
|
|
|
dbController = new DBController(main, this); |
|
|
|
|
dbController = new DBController(this); |
|
|
|
|
smmdbAPIController = new SmmdbAPIController(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -289,7 +279,7 @@ public class MainWindowController {
|
|
|
|
|
* loadSettings, checkAutoUpdate, initUI and initActions |
|
|
|
|
*/ |
|
|
|
|
public void init() { |
|
|
|
|
loadSettings(); |
|
|
|
|
xmlController.loadSettings(); // load settings
|
|
|
|
|
checkAutoUpdate(); |
|
|
|
|
initUI(); |
|
|
|
|
initActions(); |
|
|
|
@ -301,21 +291,24 @@ public class MainWindowController {
|
|
|
|
|
private void initUI() { |
|
|
|
|
LOGGER.info("initializing UI ..."); |
|
|
|
|
|
|
|
|
|
if (getWindowWidth() > 100 && getWindowHeight() > 100) { |
|
|
|
|
mainAnchorPane.setPrefSize(getWindowWidth(), getWindowHeight()); |
|
|
|
|
primaryStage = (Stage) mainAnchorPane.getScene().getWindow(); // set primary stage for dialogs
|
|
|
|
|
|
|
|
|
|
// TODO this is broken
|
|
|
|
|
if (XMLController.getWindowWidth() > 100 && XMLController.getWindowHeight() > 100) { |
|
|
|
|
mainAnchorPane.setPrefSize(XMLController.getWindowWidth(), XMLController.getWindowHeight()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
cemuTextField.setText(cemuPath); |
|
|
|
|
romTextField.setText(romDirectoryPath); |
|
|
|
|
colorPicker.setValue(Color.valueOf(getColor())); |
|
|
|
|
fullscreenToggleBtn.setSelected(isFullscreen()); |
|
|
|
|
cloudSyncToggleBtn.setSelected(isCloudSync()); |
|
|
|
|
autoUpdateToggleBtn.setSelected(isAutoUpdate()); |
|
|
|
|
cemuTextField.setText(XMLController.getCemuPath()); |
|
|
|
|
romTextField.setText(XMLController.getRomDirectoryPath()); |
|
|
|
|
colorPicker.setValue(Color.valueOf(XMLController.getColor())); |
|
|
|
|
fullscreenToggleBtn.setSelected(XMLController.isFullscreen()); |
|
|
|
|
cloudSyncToggleBtn.setSelected(XMLController.isCloudSync()); |
|
|
|
|
autoUpdateToggleBtn.setSelected(XMLController.isAutoUpdate()); |
|
|
|
|
branchChoisBox.setItems(branches); |
|
|
|
|
languageChoisBox.setItems(languages); |
|
|
|
|
bottomHBox.setPickOnBounds(false); |
|
|
|
|
|
|
|
|
|
if (isUseBeta()) { |
|
|
|
|
if (XMLController.isUseBeta()) { |
|
|
|
|
branchChoisBox.getSelectionModel().select(1); |
|
|
|
|
} else { |
|
|
|
|
branchChoisBox.getSelectionModel().select(0); |
|
|
|
@ -373,7 +366,7 @@ public class MainWindowController {
|
|
|
|
|
} |
|
|
|
|
if (settingsTrue) { |
|
|
|
|
settingsScrollPane.setVisible(false); |
|
|
|
|
saveSettings(); |
|
|
|
|
xmlController.saveSettings(); |
|
|
|
|
settingsTrue = false; |
|
|
|
|
} |
|
|
|
|
if (smmdbTrue) { |
|
|
|
@ -393,7 +386,7 @@ public class MainWindowController {
|
|
|
|
|
// new edit dialog
|
|
|
|
|
String headingText = editHeadingText + " \"" + selectedGameTitle + "\""; |
|
|
|
|
JFXEditGameDialog editGameDialog = new JFXEditGameDialog(headingText, editBodyText, dialogBtnStyle, 450, |
|
|
|
|
300, 1, MWC, main.getPrimaryStage(), main.getPane()); |
|
|
|
|
300, 1, MWC, primaryStage, main.getPane()); |
|
|
|
|
editGameDialog.setTitle(gameInfo[0]); |
|
|
|
|
editGameDialog.setCoverPath(gameInfo[1]); |
|
|
|
|
editGameDialog.setRomPath(gameInfo[2]); |
|
|
|
@ -451,11 +444,11 @@ public class MainWindowController {
|
|
|
|
|
@Override |
|
|
|
|
public void handle(ActionEvent event) { |
|
|
|
|
DirectoryChooser directoryChooser = new DirectoryChooser(); |
|
|
|
|
File selectedDirecroty = directoryChooser.showDialog(main.getPrimaryStage()); |
|
|
|
|
File selectedDirecroty = directoryChooser.showDialog(primaryStage); |
|
|
|
|
String updatePath = selectedDirecroty.getAbsolutePath(); |
|
|
|
|
String[] parts = selectedGameTitleID.split("-"); // split string into 2 parts at "-"
|
|
|
|
|
File srcDir = new File(updatePath); |
|
|
|
|
File destDir = new File(cemuPath + "/mlc01/usr/title/" + parts[0] + "/" + parts[1]); |
|
|
|
|
File destDir = new File(XMLController.getCemuPath() + "/mlc01/usr/title/" + parts[0] + "/" + parts[1]); |
|
|
|
|
|
|
|
|
|
// if directory doesn't exist create it
|
|
|
|
|
if (destDir.exists() != true) { |
|
|
|
@ -502,11 +495,11 @@ public class MainWindowController {
|
|
|
|
|
@Override |
|
|
|
|
public void handle(ActionEvent event) { |
|
|
|
|
DirectoryChooser directoryChooser = new DirectoryChooser(); |
|
|
|
|
File selectedDirecroty = directoryChooser.showDialog(main.getPrimaryStage()); |
|
|
|
|
File selectedDirecroty = directoryChooser.showDialog(primaryStage); |
|
|
|
|
String dlcPath = selectedDirecroty.getAbsolutePath(); |
|
|
|
|
String[] parts = selectedGameTitleID.split("-"); // split string into 2 parts at "-"
|
|
|
|
|
File srcDir = new File(dlcPath); |
|
|
|
|
File destDir = new File(cemuPath + "/mlc01/usr/title/" + parts[0] + "/" + parts[1] + "/aoc"); |
|
|
|
|
File destDir = new File(XMLController.getCemuPath() + "/mlc01/usr/title/" + parts[0] + "/" + parts[1] + "/aoc"); |
|
|
|
|
|
|
|
|
|
// if directory doesn't exist create it
|
|
|
|
|
if (destDir.exists() != true) { |
|
|
|
@ -628,26 +621,27 @@ public class MainWindowController {
|
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
languageChoisBox.getSelectionModel().selectedIndexProperty().addListener(new ChangeListener<Number>() { |
|
|
|
|
@Override |
|
|
|
|
public void changed(ObservableValue<? extends Number> ov, Number value, Number new_value) { |
|
|
|
|
String language = languageChoisBox.getItems().get((int) new_value).toString(); |
|
|
|
|
language = language.substring(language.length()-6,language.length()-1); //reading only en_US from English (en_US)
|
|
|
|
|
setLanguage(language); |
|
|
|
|
setUILanguage(); |
|
|
|
|
saveSettings(); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
languageChoisBox.getSelectionModel().selectedIndexProperty().addListener(new ChangeListener<Number>() { |
|
|
|
|
@Override |
|
|
|
|
public void changed(ObservableValue<? extends Number> ov, Number value, Number new_value) { |
|
|
|
|
String language = languageChoisBox.getItems().get((int) new_value).toString(); |
|
|
|
|
language = language.substring(language.length() - 6, language.length() - 1); // reading only en_US from
|
|
|
|
|
// English (en_US)
|
|
|
|
|
XMLController.setUsrLocal(language); |
|
|
|
|
setUILanguage(); |
|
|
|
|
xmlController.saveSettings(); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
branchChoisBox.getSelectionModel().selectedIndexProperty().addListener(new ChangeListener<Number>() { |
|
|
|
|
@Override |
|
|
|
|
public void changed(ObservableValue<? extends Number> ov, Number value, Number new_value) { |
|
|
|
|
if (branchChoisBox.getItems().get((int) new_value).toString() == "beta") { |
|
|
|
|
setUseBeta(true); |
|
|
|
|
XMLController.setUseBeta(true); |
|
|
|
|
} else { |
|
|
|
|
setUseBeta(false); |
|
|
|
|
XMLController.setUseBeta(false); |
|
|
|
|
} |
|
|
|
|
saveSettings(); |
|
|
|
|
xmlController.saveSettings(); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
@ -702,11 +696,11 @@ public class MainWindowController {
|
|
|
|
|
@Override |
|
|
|
|
public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) { |
|
|
|
|
if (new File(newValue).exists()) { |
|
|
|
|
setCemuPath(newValue); |
|
|
|
|
saveSettings(); |
|
|
|
|
XMLController.setCemuPath(newValue); |
|
|
|
|
xmlController.saveSettings(); |
|
|
|
|
} else { |
|
|
|
|
String bodyText = newValue + ": No such file or directory"; |
|
|
|
|
JFXInfoAlert fileErrorDialog = new JFXInfoAlert("Waring!", bodyText, dialogBtnStyle, main.getPrimaryStage()); |
|
|
|
|
JFXInfoAlert fileErrorDialog = new JFXInfoAlert("Waring!", bodyText, dialogBtnStyle, primaryStage); |
|
|
|
|
fileErrorDialog.showAndWait(); |
|
|
|
|
LOGGER.warn(newValue + ": No such file or directory"); |
|
|
|
|
} |
|
|
|
@ -717,12 +711,12 @@ public class MainWindowController {
|
|
|
|
|
@Override |
|
|
|
|
public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) { |
|
|
|
|
if (new File(newValue).exists()) { |
|
|
|
|
setRomDirectoryPath(newValue); |
|
|
|
|
saveSettings(); |
|
|
|
|
XMLController.setRomDirectoryPath(newValue); |
|
|
|
|
xmlController.saveSettings(); |
|
|
|
|
reloadRoms(); |
|
|
|
|
} else { |
|
|
|
|
String bodyText = newValue + ": No such file or directory"; |
|
|
|
|
JFXInfoAlert fileErrorDialog = new JFXInfoAlert("Waring!", bodyText, dialogBtnStyle, main.getPrimaryStage()); |
|
|
|
|
JFXInfoAlert fileErrorDialog = new JFXInfoAlert("Waring!", bodyText, dialogBtnStyle, primaryStage); |
|
|
|
|
fileErrorDialog.showAndWait(); |
|
|
|
|
LOGGER.warn(newValue + ": No such file or directory"); |
|
|
|
|
} |
|
|
|
@ -742,7 +736,7 @@ public class MainWindowController {
|
|
|
|
|
String bodyText = "cemu_UI by @Seil0 \nVersion: " + version + " (" + buildNumber + ") \"" + versionName + "\" \n" |
|
|
|
|
+ aboutBtnBodyText; |
|
|
|
|
|
|
|
|
|
JFXInfoAlert infoAlert = new JFXInfoAlert(aboutBtnHeadingText, bodyText, dialogBtnStyle, main.getPrimaryStage()); |
|
|
|
|
JFXInfoAlert infoAlert = new JFXInfoAlert(aboutBtnHeadingText, bodyText, dialogBtnStyle, primaryStage); |
|
|
|
|
infoAlert.showAndWait(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -755,7 +749,7 @@ public class MainWindowController {
|
|
|
|
|
if (settingsTrue) { |
|
|
|
|
settingsScrollPane.setVisible(false); |
|
|
|
|
settingsTrue = false; |
|
|
|
|
saveSettings(); |
|
|
|
|
xmlController.saveSettings(); |
|
|
|
|
} else { |
|
|
|
|
settingsScrollPane.setVisible(true); |
|
|
|
|
settingsTrue = true; |
|
|
|
@ -826,7 +820,7 @@ public class MainWindowController {
|
|
|
|
|
|
|
|
|
|
@FXML |
|
|
|
|
private void cemuTFBtnAction() { |
|
|
|
|
File cemuDirectory = directoryChooser.showDialog(main.getPrimaryStage()); |
|
|
|
|
File cemuDirectory = directoryChooser.showDialog(primaryStage); |
|
|
|
|
if (cemuDirectory != null) { |
|
|
|
|
cemuTextField.setText(cemuDirectory.getAbsolutePath()); |
|
|
|
|
} |
|
|
|
@ -834,7 +828,7 @@ public class MainWindowController {
|
|
|
|
|
|
|
|
|
|
@FXML |
|
|
|
|
private void romTFBtnAction() { |
|
|
|
|
File romDirectory = directoryChooser.showDialog(main.getPrimaryStage()); |
|
|
|
|
File romDirectory = directoryChooser.showDialog(primaryStage); |
|
|
|
|
if (romDirectory != null) { |
|
|
|
|
romTextField.setText(romDirectory.getAbsolutePath()); |
|
|
|
|
} |
|
|
|
@ -842,7 +836,7 @@ public class MainWindowController {
|
|
|
|
|
|
|
|
|
|
@FXML |
|
|
|
|
private void updateBtnAction() { |
|
|
|
|
updateController = new UpdateController(this, buildNumber, useBeta); |
|
|
|
|
updateController = new UpdateController(this, buildNumber, XMLController.isUseBeta()); |
|
|
|
|
Thread updateThread = new Thread(updateController); |
|
|
|
|
updateThread.setName("Updater"); |
|
|
|
|
updateThread.start(); |
|
|
|
@ -850,12 +844,8 @@ public class MainWindowController {
|
|
|
|
|
|
|
|
|
|
@FXML |
|
|
|
|
private void autoUpdateToggleBtnAction() { |
|
|
|
|
if (isAutoUpdate()) { |
|
|
|
|
setAutoUpdate(false); |
|
|
|
|
} else { |
|
|
|
|
setAutoUpdate(true); |
|
|
|
|
} |
|
|
|
|
saveSettings(); |
|
|
|
|
XMLController.setAutoUpdate(!XMLController.isAutoUpdate()); |
|
|
|
|
xmlController.saveSettings(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@FXML |
|
|
|
@ -866,8 +856,8 @@ public class MainWindowController {
|
|
|
|
|
@FXML |
|
|
|
|
private void smmdbDownloadBtnAction() { |
|
|
|
|
String downloadUrl = "http://smmdb.ddns.net/api/downloadcourse?id=" + id + "&type=zip"; |
|
|
|
|
String downloadFileURL = getCemuPath() + "/" + id + ".zip"; // getCemuPath() + "/" + smmID + "/" + id + ".rar"
|
|
|
|
|
String outputFile = getCemuPath() + "/"; |
|
|
|
|
String downloadFileURL = XMLController.getCemuPath() + "/" + id + ".zip"; // getCemuPath() + "/" + smmID + "/" + id + ".rar"
|
|
|
|
|
String outputFile = XMLController.getCemuPath() + "/"; |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
LOGGER.info("beginning download ..."); |
|
|
|
@ -933,41 +923,36 @@ public class MainWindowController {
|
|
|
|
|
|
|
|
|
|
@FXML |
|
|
|
|
private void fullscreenToggleBtnAction() { |
|
|
|
|
if (fullscreen) { |
|
|
|
|
fullscreen = false; |
|
|
|
|
} else { |
|
|
|
|
fullscreen = true; |
|
|
|
|
} |
|
|
|
|
saveSettings(); |
|
|
|
|
XMLController.setFullscreen(!XMLController.isFullscreen()); |
|
|
|
|
xmlController.saveSettings(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@FXML |
|
|
|
|
private void cloudSyncToggleBtnAction() { |
|
|
|
|
if(cloudSync) { |
|
|
|
|
cloudSync = false; |
|
|
|
|
} else { |
|
|
|
|
XMLController.setCloudSync(!XMLController.isCloudSync()); |
|
|
|
|
|
|
|
|
|
if(XMLController.isCloudSync()) { |
|
|
|
|
EventHandler<ActionEvent> okayAction = new EventHandler<ActionEvent>(){ |
|
|
|
|
@Override |
|
|
|
|
public void handle(ActionEvent event){ |
|
|
|
|
cloudSync = true; |
|
|
|
|
//TODO rework for other cloud services
|
|
|
|
|
// CloudService service = CloudService.GoogleDrive;
|
|
|
|
|
cloudService = CloudService.GoogleDrive; |
|
|
|
|
XMLController.setCloudService(CloudService.GoogleDrive); |
|
|
|
|
|
|
|
|
|
// start cloud sync in new thread
|
|
|
|
|
Thread thread = new Thread(new Runnable() { |
|
|
|
|
@Override |
|
|
|
|
public void run() { |
|
|
|
|
|
|
|
|
|
if (main.getCloudController().initializeConnection(getCloudService(), getCemuPath())) { |
|
|
|
|
main.getCloudController().sync(getCloudService(), getCemuPath(), main.getDirectory().getPath()); |
|
|
|
|
saveSettings(); |
|
|
|
|
if (main.getCloudController().initializeConnection(XMLController.getCloudService(), XMLController.getCemuPath())) { |
|
|
|
|
main.getCloudController().sync(XMLController.getCloudService(), XMLController.getCemuPath(), XMLController.getDirCemuUIPath()); |
|
|
|
|
xmlController.saveSettings(); |
|
|
|
|
} else { |
|
|
|
|
cloudSyncToggleBtn.setSelected(false); |
|
|
|
|
|
|
|
|
|
// cloud sync init error dialog
|
|
|
|
|
JFXInfoAlert cloudSyncErrorDialog = new JFXInfoAlert(cloudSyncErrorHeadingText, |
|
|
|
|
cloudSyncErrorBodyText, dialogBtnStyle, main.getPrimaryStage()); |
|
|
|
|
cloudSyncErrorBodyText, dialogBtnStyle, primaryStage); |
|
|
|
|
cloudSyncErrorDialog.showAndWait(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -1002,7 +987,7 @@ public class MainWindowController {
|
|
|
|
|
String headingText = addGameBtnHeadingText; |
|
|
|
|
String bodyText = addGameBtnBodyText; |
|
|
|
|
JFXEditGameDialog addGameDialog = new JFXEditGameDialog(headingText, bodyText, dialogBtnStyle, 450, 300, 0, |
|
|
|
|
this, main.getPrimaryStage(), main.getPane()); |
|
|
|
|
this, primaryStage, main.getPane()); |
|
|
|
|
addGameDialog.show(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -1021,11 +1006,11 @@ public class MainWindowController {
|
|
|
|
|
|
|
|
|
|
//addGame error dialog
|
|
|
|
|
JFXInfoAlert errorDialog = new JFXInfoAlert(addBtnReturnErrorHeadingText, addBtnReturnErrorBodyText, |
|
|
|
|
dialogBtnStyle, main.getPrimaryStage()); |
|
|
|
|
dialogBtnStyle, primaryStage); |
|
|
|
|
errorDialog.showAndWait(); |
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
File pictureCache = main.getPictureCache(); |
|
|
|
|
File pictureCache = XMLController.getPictureCache(); |
|
|
|
|
String coverName = new File(coverPath).getName(); |
|
|
|
|
try { |
|
|
|
|
BufferedImage originalImage = ImageIO.read(new File(coverPath)); //load cover
|
|
|
|
@ -1184,7 +1169,7 @@ public class MainWindowController {
|
|
|
|
|
main.getPane().getChildren().add(spinner); // add spinner to pane
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
dbController.loadRomDirectory(getRomDirectoryPath()); // reload the ROM directory
|
|
|
|
|
dbController.loadRomDirectory(XMLController.getRomDirectoryPath()); // reload the ROM directory
|
|
|
|
|
games.removeAll(games); // remove all games from the mwc game list
|
|
|
|
|
dbController.loadAllGames(); // load all games from the database to the mwc
|
|
|
|
|
|
|
|
|
@ -1218,7 +1203,7 @@ public class MainWindowController {
|
|
|
|
|
|
|
|
|
|
// set the selected local strings to all needed elements
|
|
|
|
|
void setUILanguage(){ |
|
|
|
|
switch(getLanguage()){ |
|
|
|
|
switch(XMLController.getUsrLocal()){ |
|
|
|
|
case "en_US": |
|
|
|
|
bundle = ResourceBundle.getBundle("locals.cemu_UI-Local", Locale.US); //us_English
|
|
|
|
|
languageChoisBox.getSelectionModel().select(0); |
|
|
|
@ -1302,10 +1287,10 @@ public class MainWindowController {
|
|
|
|
|
// if AutoUpdate, then check for updates
|
|
|
|
|
private void checkAutoUpdate() { |
|
|
|
|
|
|
|
|
|
if (isAutoUpdate()) { |
|
|
|
|
if (XMLController.isAutoUpdate()) { |
|
|
|
|
try { |
|
|
|
|
LOGGER.info("AutoUpdate: looking for updates on startup ..."); |
|
|
|
|
updateController = new UpdateController(this, buildNumber, useBeta); |
|
|
|
|
updateController = new UpdateController(this, buildNumber, XMLController.isUseBeta()); |
|
|
|
|
Thread updateThread = new Thread(updateController); |
|
|
|
|
updateThread.setName("Updater"); |
|
|
|
|
updateThread.start(); |
|
|
|
@ -1456,16 +1441,16 @@ public class MainWindowController {
|
|
|
|
|
|
|
|
|
|
// change the color of all needed GUI elements
|
|
|
|
|
private void applyColor() { |
|
|
|
|
String boxStyle = "-fx-background-color: #"+getColor()+";"; |
|
|
|
|
String btnStyleBlack = "-fx-button-type: RAISED; -fx-background-color: #"+getColor()+"; -fx-text-fill: BLACK;"; |
|
|
|
|
String btnStyleWhite = "-fx-button-type: RAISED; -fx-background-color: #"+getColor()+"; -fx-text-fill: WHITE;"; |
|
|
|
|
BigInteger icolor = new BigInteger(getColor(),16); |
|
|
|
|
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;"; |
|
|
|
|
BigInteger icolor = new BigInteger(XMLController.getColor(),16); |
|
|
|
|
BigInteger ccolor = new BigInteger("78909cff",16); |
|
|
|
|
|
|
|
|
|
sideMenuVBox.setStyle(boxStyle); |
|
|
|
|
topHBox.setStyle(boxStyle); |
|
|
|
|
cemuTextField.setFocusColor(Color.valueOf(getColor())); |
|
|
|
|
romTextField.setFocusColor(Color.valueOf(getColor())); |
|
|
|
|
cemuTextField.setFocusColor(Color.valueOf(XMLController.getColor())); |
|
|
|
|
romTextField.setFocusColor(Color.valueOf(XMLController.getColor())); |
|
|
|
|
|
|
|
|
|
if (icolor.compareTo(ccolor) == -1) { |
|
|
|
|
dialogBtnStyle = btnStyleWhite; |
|
|
|
@ -1516,158 +1501,7 @@ public class MainWindowController {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
for (int i = 0; i < games.size(); i++) { |
|
|
|
|
games.get(i).getButton().setRipplerFill(Paint.valueOf(getColor())); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* save settings to the config.xml file |
|
|
|
|
*/ |
|
|
|
|
public void saveSettings() { |
|
|
|
|
LOGGER.info("saving Settings ..."); |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
props.setProperty("cemuPath", getCemuPath()); |
|
|
|
|
props.setProperty("romPath", getRomDirectoryPath()); |
|
|
|
|
props.setProperty("color", getColor()); |
|
|
|
|
props.setProperty("language", getLanguage()); |
|
|
|
|
props.setProperty("fullscreen", String.valueOf(isFullscreen())); |
|
|
|
|
props.setProperty("cloudSync", String.valueOf(isCloudSync())); |
|
|
|
|
props.setProperty("autoUpdate", String.valueOf(isAutoUpdate())); |
|
|
|
|
props.setProperty("useBeta", String.valueOf(isUseBeta())); |
|
|
|
|
if (getCloudService() == null) { |
|
|
|
|
props.setProperty("cloudService", ""); |
|
|
|
|
} else { |
|
|
|
|
props.setProperty("cloudService", getCloudService().toString()); |
|
|
|
|
} |
|
|
|
|
props.setProperty("folderID", main.getCloudController().getFolderID(getCloudService())); |
|
|
|
|
props.setProperty("lastLocalSync", String.valueOf(getLastLocalSync())); |
|
|
|
|
props.setProperty("windowWidth", String.valueOf(mainAnchorPane.getWidth())); |
|
|
|
|
props.setProperty("windowHeight", String.valueOf(mainAnchorPane.getHeight())); |
|
|
|
|
|
|
|
|
|
OutputStream outputStream = new FileOutputStream(main.getConfigFile()); // new output-stream
|
|
|
|
|
props.storeToXML(outputStream, "cemu_UI settings"); // write new .xml
|
|
|
|
|
outputStream.close(); |
|
|
|
|
LOGGER.info("saving Settings done!"); |
|
|
|
|
} catch (IOException e) { |
|
|
|
|
LOGGER.error("an error occured", e); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* loading saved settings from the config.xml file |
|
|
|
|
* if a value is not present, default is used instead |
|
|
|
|
*/ |
|
|
|
|
private void loadSettings() { |
|
|
|
|
LOGGER.info("loading settings ..."); |
|
|
|
|
try { |
|
|
|
|
InputStream inputStream = new FileInputStream(main.getConfigFile()); |
|
|
|
|
props.loadFromXML(inputStream); // new input-stream from .xml
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
setCemuPath(props.getProperty("cemuPath")); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
LOGGER.error("cloud not load cemuPath", e); |
|
|
|
|
setCemuPath(""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
setRomDirectoryPath(props.getProperty("romPath")); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
LOGGER.error("could not load romPath", e); |
|
|
|
|
setRomDirectoryPath(""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
setColor(props.getProperty("color")); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
LOGGER.error("could not load color value, setting default instead", e); |
|
|
|
|
setColor("00a8cc"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (props.getProperty("language") == null) { |
|
|
|
|
LOGGER.error("cloud not load language, setting default instead"); |
|
|
|
|
setLanguage("en_US"); |
|
|
|
|
} else { |
|
|
|
|
setLanguage(props.getProperty("language")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
setFullscreen(Boolean.parseBoolean(props.getProperty("fullscreen"))); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
LOGGER.error("could not load fullscreen, setting default instead", e); |
|
|
|
|
setFullscreen(false); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
setCloudSync(Boolean.parseBoolean(props.getProperty("cloudSync"))); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
LOGGER.error("could not load cloudSync, setting default instead", e); |
|
|
|
|
setCloudSync(false); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
setAutoUpdate(Boolean.parseBoolean(props.getProperty("autoUpdate"))); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
LOGGER.error("cloud not load autoUpdate", e); |
|
|
|
|
setAutoUpdate(false); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
setUseBeta(Boolean.parseBoolean(props.getProperty("useBeta"))); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
LOGGER.error("cloud not load autoUpdate", e); |
|
|
|
|
setUseBeta(false); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
switch (props.getProperty("cloudService")) { |
|
|
|
|
case "GoogleDrive": |
|
|
|
|
setCloudService(CloudService.GoogleDrive); |
|
|
|
|
break; |
|
|
|
|
case "Dropbox": |
|
|
|
|
setCloudService(CloudService.Dropbox); |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
LOGGER.error("could not load cloudSync", e); |
|
|
|
|
setCloudService(null); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
main.getCloudController().setFolderID(props.getProperty("folderID"), getCloudService()); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
LOGGER.error("could not load folderID, disable cloud sync. Please contact an developer", e); |
|
|
|
|
setCloudSync(false); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
setLastLocalSync(Long.parseLong(props.getProperty("lastLocalSync"))); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
LOGGER.error("could not load lastSuccessSync, setting default instead", e); |
|
|
|
|
setLastLocalSync(0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
setWindowWidth(Double.parseDouble(props.getProperty("windowWidth"))); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
LOGGER.error("could not load windowWidth, setting default instead", e); |
|
|
|
|
setWindowWidth(904); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
setWindowHeight(Double.parseDouble(props.getProperty("windowHeight"))); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
LOGGER.error("could not load windowHeight, setting default instead", e); |
|
|
|
|
setWindowHeight(600); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
inputStream.close(); |
|
|
|
|
LOGGER.info("loading settings done!"); |
|
|
|
|
} catch (IOException e) { |
|
|
|
|
LOGGER.error("an error occured", e); |
|
|
|
|
games.get(i).getButton().setRipplerFill(Paint.valueOf(XMLController.getColor())); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -1709,8 +1543,8 @@ public class MainWindowController {
|
|
|
|
|
private void editColor(String input){ |
|
|
|
|
StringBuilder sb = new StringBuilder(input); |
|
|
|
|
sb.delete(0, 2); |
|
|
|
|
this.color = sb.toString(); |
|
|
|
|
saveSettings(); |
|
|
|
|
XMLController.setColor(sb.toString()); |
|
|
|
|
xmlController.saveSettings(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@SuppressWarnings("unused") |
|
|
|
@ -1718,8 +1552,8 @@ public class MainWindowController {
|
|
|
|
|
* @return the main color in hexadecimal format |
|
|
|
|
*/ |
|
|
|
|
private String hexToRgb() { |
|
|
|
|
LOGGER.info(getColor()); |
|
|
|
|
int hex = Integer.parseInt(getColor().substring(0, 5), 16); |
|
|
|
|
LOGGER.info(XMLController.getColor()); |
|
|
|
|
int hex = Integer.parseInt(XMLController.getColor().substring(0, 5), 16); |
|
|
|
|
|
|
|
|
|
int r = (hex & 0xFF0000) >> 16; |
|
|
|
|
int g = (hex & 0xFF00) >> 8; |
|
|
|
@ -1752,33 +1586,9 @@ public class MainWindowController {
|
|
|
|
|
public DBController getDbController() { |
|
|
|
|
return dbController; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void setMainAnchorPane(AnchorPane mainAnchorPane) { |
|
|
|
|
this.mainAnchorPane = mainAnchorPane; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public String getCemuPath() { |
|
|
|
|
return cemuPath; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void setCemuPath(String cemuPath) { |
|
|
|
|
this.cemuPath = cemuPath; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public String getRomDirectoryPath() { |
|
|
|
|
return romDirectoryPath; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void setRomDirectoryPath(String romDirectoryPath) { |
|
|
|
|
this.romDirectoryPath = romDirectoryPath; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public String getColor() { |
|
|
|
|
return color; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void setColor(String color) { |
|
|
|
|
this.color = color; |
|
|
|
|
public Stage getPrimaryStage() { |
|
|
|
|
return primaryStage; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public int getxPos() { |
|
|
|
@ -1805,46 +1615,6 @@ public class MainWindowController {
|
|
|
|
|
this.xPosHelper = xPosHelper; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public long getLastLocalSync() { |
|
|
|
|
return lastLocalSync; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void setLastLocalSync(long lastLocalSync) { |
|
|
|
|
this.lastLocalSync = lastLocalSync; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public boolean isFullscreen() { |
|
|
|
|
return fullscreen; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void setFullscreen(boolean fullscreen) { |
|
|
|
|
this.fullscreen = fullscreen; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public boolean isCloudSync() { |
|
|
|
|
return cloudSync; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void setCloudSync(boolean cloudSync) { |
|
|
|
|
this.cloudSync = cloudSync; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public boolean isAutoUpdate() { |
|
|
|
|
return autoUpdate; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void setAutoUpdate(boolean autoUpdate) { |
|
|
|
|
this.autoUpdate = autoUpdate; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public boolean isUseBeta() { |
|
|
|
|
return useBeta; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void setUseBeta(boolean useBeta) { |
|
|
|
|
this.useBeta = useBeta; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public String getGameExecutePath() { |
|
|
|
|
return gameExecutePath; |
|
|
|
|
} |
|
|
|
@ -1861,14 +1631,6 @@ public class MainWindowController {
|
|
|
|
|
this.selectedGameTitleID = selectedGameTitleID; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public CloudService getCloudService() { |
|
|
|
|
return cloudService; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void setCloudService(CloudService cloudService) { |
|
|
|
|
this.cloudService = cloudService; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public JFXButton getPlayBtn() { |
|
|
|
|
return playBtn; |
|
|
|
|
} |
|
|
|
@ -1876,31 +1638,11 @@ public class MainWindowController {
|
|
|
|
|
public void setPlayBtn(JFXButton playBtn) { |
|
|
|
|
this.playBtn = playBtn; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public double getWindowWidth() { |
|
|
|
|
return windowWidth; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void setWindowWidth(double windowWidth) { |
|
|
|
|
this.windowWidth = windowWidth; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public double getWindowHeight() { |
|
|
|
|
return windowHeight; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void setWindowHeight(double windowHeight) { |
|
|
|
|
this.windowHeight = windowHeight; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public int getOldXPosHelper() { |
|
|
|
|
return oldXPosHelper; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void setOldXPosHelper(int oldXPosHelper) { |
|
|
|
|
this.oldXPosHelper = oldXPosHelper; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public String getLanguage() { |
|
|
|
|
return language; |
|
|
|
|
} |
|
|
|
@ -1913,10 +1655,6 @@ public class MainWindowController {
|
|
|
|
|
return bundle; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void setBundle(ResourceBundle bundle) { |
|
|
|
|
this.bundle = bundle; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public AnchorPane getMainAnchorPane() { |
|
|
|
|
return mainAnchorPane; |
|
|
|
|
} |
|
|
|
|