documentation cleanups, code cleanup
* removed one unnecessary restart * added warning if the ROM directory could not be opened
This commit is contained in:
parent
3a6a7b7cce
commit
061f58105a
|
@ -811,6 +811,15 @@ public class MainWindowController {
|
|||
public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
|
||||
setRomDirectoryPath(romTextField.getText());
|
||||
saveSettings();
|
||||
|
||||
if (new File(romTextField.getText()).exists()) {
|
||||
reloadRoms();
|
||||
} else {
|
||||
String bodyText = "No such file or directory";
|
||||
JFXInfoDialog fileErrorDialog = new JFXInfoDialog("Waring!", bodyText, dialogBtnStyle, 190, 150, main.getPane());
|
||||
fileErrorDialog.show();
|
||||
LOGGER.warn("Directory does not exist");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -905,14 +914,14 @@ public class MainWindowController {
|
|||
|
||||
@FXML
|
||||
void lastTimePlayedBtnAction(ActionEvent event) {
|
||||
System.out.println(lastTimePlayedBtn.getWidth());
|
||||
|
||||
}
|
||||
|
||||
@FXML
|
||||
void cemuTFBtnAction(ActionEvent event) {
|
||||
File cemuDirectory = directoryChooser.showDialog(main.getPrimaryStage());
|
||||
if (cemuDirectory == null) {
|
||||
LOGGER.info("No Directory selected");
|
||||
LOGGER.warn("No Directory selected");
|
||||
} else {
|
||||
setCemuPath(cemuDirectory.getAbsolutePath());
|
||||
saveSettings();
|
||||
|
@ -929,18 +938,17 @@ public class MainWindowController {
|
|||
@FXML
|
||||
void romTFBtnAction(ActionEvent event) {
|
||||
File romDirectory = directoryChooser.showDialog(main.getPrimaryStage());
|
||||
if (romDirectory == null) {
|
||||
LOGGER.info("No Directory selected");
|
||||
} else {
|
||||
setRomDirectoryPath(romDirectory.getAbsolutePath());
|
||||
saveSettings();
|
||||
cemuTextField.setText(getCemuPath());
|
||||
try {
|
||||
Runtime.getRuntime().exec("java -jar cemu_UI.jar"); // start again
|
||||
System.exit(0); // finishes itself
|
||||
} catch (IOException e) {
|
||||
LOGGER.error("an error occurred", e);
|
||||
}
|
||||
romTextField.setText(getRomDirectoryPath());
|
||||
|
||||
if (romDirectory.exists()) {
|
||||
reloadRoms();
|
||||
} else {
|
||||
String bodyText = "No such file or directory";
|
||||
JFXInfoDialog fileErrorDialog = new JFXInfoDialog("Waring!", bodyText, dialogBtnStyle, 190, 150, main.getPane());
|
||||
fileErrorDialog.show();
|
||||
LOGGER.warn("Directory does not exist");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1269,6 +1277,9 @@ public class MainWindowController {
|
|||
games.add(uiROMElement);
|
||||
}
|
||||
|
||||
/**
|
||||
* reload all ROMs from the ROM directory
|
||||
*/
|
||||
public void reloadRoms() {
|
||||
JFXSpinner spinner = new JFXSpinner();
|
||||
spinner.setPrefSize(30, 30);
|
||||
|
@ -1323,6 +1334,7 @@ public class MainWindowController {
|
|||
}
|
||||
}
|
||||
|
||||
// set the selected local strings to all needed elements
|
||||
void setUILanguage(){
|
||||
switch(getLanguage()){
|
||||
case "en_US":
|
||||
|
@ -1405,6 +1417,7 @@ public class MainWindowController {
|
|||
smmdbDownloadBtnDownload = bundle.getString("smmdbDownloadBtnDownload");
|
||||
}
|
||||
|
||||
// if AutoUpdate, then check for updates
|
||||
private void checkAutoUpdate() {
|
||||
|
||||
if (isAutoUpdate()) {
|
||||
|
@ -1574,6 +1587,7 @@ public class MainWindowController {
|
|||
// System.out.println("xPos: " + xPos);
|
||||
}
|
||||
|
||||
// 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;";
|
||||
|
@ -1637,6 +1651,9 @@ public class MainWindowController {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* save settings to the config.xml file
|
||||
*/
|
||||
public void saveSettings(){
|
||||
LOGGER.info("saving Settings ...");
|
||||
|
||||
|
@ -1658,6 +1675,7 @@ public class MainWindowController {
|
|||
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();
|
||||
|
|
|
@ -230,7 +230,7 @@ public class DBController {
|
|||
|
||||
// for all elements in the games table check if it's already present, else add it
|
||||
while (rs.next()) {
|
||||
if (checkEntry(rs.getString(2))) {
|
||||
if (checkAddEntry(rs.getString(2))) {
|
||||
LOGGER.info(rs.getString(2) + ": game already in database");
|
||||
} else {
|
||||
LOGGER.info("adding cover to cache ...");
|
||||
|
@ -252,7 +252,13 @@ public class DBController {
|
|||
}
|
||||
}
|
||||
|
||||
private boolean checkEntry(String title) throws SQLException{
|
||||
/**
|
||||
* check if there is a game with the given name already in the database
|
||||
* @param title game title
|
||||
* @return true if the game exists, false if not
|
||||
* @throws SQLException
|
||||
*/
|
||||
private boolean checkAddEntry(String title) throws SQLException{
|
||||
Statement stmt = connection.createStatement();
|
||||
boolean check = false;
|
||||
ResultSet rs = stmt.executeQuery("SELECT * FROM local_roms WHERE title = '"+title+"';");
|
||||
|
|
Loading…
Reference in New Issue