code cleanup
removed some unnecessary save calls * removed some unnecessary things after opening a directorychooser * typo fixes
This commit is contained in:
parent
061f58105a
commit
b4fc36621a
|
@ -54,9 +54,9 @@ import org.apache.commons.io.FileUtils;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
|
import com.cemu_UI.controller.DBController;
|
||||||
import com.cemu_UI.controller.SmmdbAPIController;
|
import com.cemu_UI.controller.SmmdbAPIController;
|
||||||
import com.cemu_UI.controller.UpdateController;
|
import com.cemu_UI.controller.UpdateController;
|
||||||
import com.cemu_UI.controller.DBController;
|
|
||||||
import com.cemu_UI.datatypes.CourseTableDataType;
|
import com.cemu_UI.datatypes.CourseTableDataType;
|
||||||
import com.cemu_UI.datatypes.SmmdbApiDataType;
|
import com.cemu_UI.datatypes.SmmdbApiDataType;
|
||||||
import com.cemu_UI.datatypes.UIROMDataType;
|
import com.cemu_UI.datatypes.UIROMDataType;
|
||||||
|
@ -801,24 +801,30 @@ public class MainWindowController {
|
||||||
cemuTextField.textProperty().addListener(new ChangeListener<String>() {
|
cemuTextField.textProperty().addListener(new ChangeListener<String>() {
|
||||||
@Override
|
@Override
|
||||||
public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
|
public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
|
||||||
setCemuPath(cemuTextField.getText());
|
if (new File(newValue).exists()) {
|
||||||
|
setCemuPath(newValue);
|
||||||
saveSettings();
|
saveSettings();
|
||||||
|
} else {
|
||||||
|
String bodyText = newValue + ": No such file or directory";
|
||||||
|
JFXInfoDialog fileErrorDialog = new JFXInfoDialog("Waring!", bodyText, dialogBtnStyle, 190, 150, main.getPane());
|
||||||
|
fileErrorDialog.show();
|
||||||
|
LOGGER.warn(newValue + ": No such file or directory");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
romTextField.textProperty().addListener(new ChangeListener<String>() {
|
romTextField.textProperty().addListener(new ChangeListener<String>() {
|
||||||
@Override
|
@Override
|
||||||
public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
|
public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
|
||||||
setRomDirectoryPath(romTextField.getText());
|
if (new File(newValue).exists()) {
|
||||||
|
setRomDirectoryPath(newValue);
|
||||||
saveSettings();
|
saveSettings();
|
||||||
|
|
||||||
if (new File(romTextField.getText()).exists()) {
|
|
||||||
reloadRoms();
|
reloadRoms();
|
||||||
} else {
|
} else {
|
||||||
String bodyText = "No such file or directory";
|
String bodyText = newValue + ": No such file or directory";
|
||||||
JFXInfoDialog fileErrorDialog = new JFXInfoDialog("Waring!", bodyText, dialogBtnStyle, 190, 150, main.getPane());
|
JFXInfoDialog fileErrorDialog = new JFXInfoDialog("Waring!", bodyText, dialogBtnStyle, 190, 150, main.getPane());
|
||||||
fileErrorDialog.show();
|
fileErrorDialog.show();
|
||||||
LOGGER.warn("Directory does not exist");
|
LOGGER.warn(newValue + ": No such file or directory");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -827,7 +833,7 @@ public class MainWindowController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
void detailsSlideoutBtnAction(ActionEvent event) {
|
void detailsSlideoutBtnAction() {
|
||||||
playBtnSlideOut();
|
playBtnSlideOut();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -840,7 +846,7 @@ public class MainWindowController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
void settingsBtnAction(ActionEvent event) {
|
void settingsBtnAction() {
|
||||||
if (smmdbTrue) {
|
if (smmdbTrue) {
|
||||||
smmdbAnchorPane.setVisible(false);
|
smmdbAnchorPane.setVisible(false);
|
||||||
smmdbTrue = false;
|
smmdbTrue = false;
|
||||||
|
@ -900,7 +906,7 @@ public class MainWindowController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
void playBtnAction(ActionEvent event) throws InterruptedException, IOException {
|
void playBtnAction() throws InterruptedException, IOException {
|
||||||
dbController.setLastPlayed(selectedGameTitleID);
|
dbController.setLastPlayed(selectedGameTitleID);
|
||||||
playGame = new playGame(this, dbController);
|
playGame = new playGame(this, dbController);
|
||||||
|
|
||||||
|
@ -908,52 +914,33 @@ public class MainWindowController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
void totalPlaytimeBtnAction(ActionEvent event) {
|
void totalPlaytimeBtnAction() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
void lastTimePlayedBtnAction(ActionEvent event) {
|
void lastTimePlayedBtnAction() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
void cemuTFBtnAction(ActionEvent event) {
|
void cemuTFBtnAction() {
|
||||||
File cemuDirectory = directoryChooser.showDialog(main.getPrimaryStage());
|
File cemuDirectory = directoryChooser.showDialog(main.getPrimaryStage());
|
||||||
if (cemuDirectory == null) {
|
if (cemuDirectory != null) {
|
||||||
LOGGER.warn("No Directory selected");
|
cemuTextField.setText(cemuDirectory.getAbsolutePath());
|
||||||
} else {
|
|
||||||
setCemuPath(cemuDirectory.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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
void romTFBtnAction(ActionEvent event) {
|
void romTFBtnAction() {
|
||||||
File romDirectory = directoryChooser.showDialog(main.getPrimaryStage());
|
File romDirectory = directoryChooser.showDialog(main.getPrimaryStage());
|
||||||
setRomDirectoryPath(romDirectory.getAbsolutePath());
|
if (romDirectory != null) {
|
||||||
saveSettings();
|
romTextField.setText(romDirectory.getAbsolutePath());
|
||||||
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");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
void updateBtnAction(ActionEvent event) {
|
void updateBtnAction() {
|
||||||
updateController = new UpdateController(this, buildNumber, useBeta);
|
updateController = new UpdateController(this, buildNumber, useBeta);
|
||||||
Thread updateThread = new Thread(updateController);
|
Thread updateThread = new Thread(updateController);
|
||||||
updateThread.setName("Updater");
|
updateThread.setName("Updater");
|
||||||
|
@ -961,7 +948,7 @@ public class MainWindowController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
void autoUpdateToggleBtnAction(ActionEvent event) {
|
void autoUpdateToggleBtnAction() {
|
||||||
if (isAutoUpdate()) {
|
if (isAutoUpdate()) {
|
||||||
setAutoUpdate(false);
|
setAutoUpdate(false);
|
||||||
} else {
|
} else {
|
||||||
|
@ -971,12 +958,12 @@ public class MainWindowController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
void courseSearchTextFiledAction(ActionEvent event) {
|
void courseSearchTextFiledAction() {
|
||||||
// not in use
|
// not in use
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
void smmdbDownloadBtnAction(ActionEvent event) {
|
void smmdbDownloadBtnAction() {
|
||||||
String downloadUrl = "http://smmdb.ddns.net/api/downloadcourse?id=" + id + "&type=zip";
|
String downloadUrl = "http://smmdb.ddns.net/api/downloadcourse?id=" + id + "&type=zip";
|
||||||
String downloadFileURL = getCemuPath() + "/" + id + ".zip"; // getCemuPath() + "/" + smmID + "/" + id + ".rar"
|
String downloadFileURL = getCemuPath() + "/" + id + ".zip"; // getCemuPath() + "/" + smmID + "/" + id + ".rar"
|
||||||
String outputFile = getCemuPath() + "/";
|
String outputFile = getCemuPath() + "/";
|
||||||
|
@ -1044,7 +1031,7 @@ public class MainWindowController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
void fullscreenToggleBtnAction(ActionEvent event) {
|
void fullscreenToggleBtnAction() {
|
||||||
if (fullscreen) {
|
if (fullscreen) {
|
||||||
fullscreen = false;
|
fullscreen = false;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1054,7 +1041,7 @@ public class MainWindowController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
void cloudSyncToggleBtnAction(ActionEvent event) {
|
void cloudSyncToggleBtnAction() {
|
||||||
if(cloudSync) {
|
if(cloudSync) {
|
||||||
cloudSync = false;
|
cloudSync = false;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1103,13 +1090,13 @@ public class MainWindowController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
void colorPickerAction(ActionEvent event) {
|
void colorPickerAction() {
|
||||||
editColor(colorPicker.getValue().toString());
|
editColor(colorPicker.getValue().toString());
|
||||||
applyColor();
|
applyColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
void addBtnAction(ActionEvent event) {
|
void addBtnAction() {
|
||||||
String headingText = addGameBtnHeadingText;
|
String headingText = addGameBtnHeadingText;
|
||||||
String bodyText = addGameBtnBodyText;
|
String bodyText = addGameBtnBodyText;
|
||||||
JFXEditGameDialog addGameDialog = new JFXEditGameDialog(headingText, bodyText, dialogBtnStyle, 450, 300, 0,
|
JFXEditGameDialog addGameDialog = new JFXEditGameDialog(headingText, bodyText, dialogBtnStyle, 450, 300, 0,
|
||||||
|
@ -1308,15 +1295,9 @@ public class MainWindowController {
|
||||||
thread.start();
|
thread.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
// add all games saved in games(ArrayList) to gamesAnchorPane
|
|
||||||
void addUIData() {
|
|
||||||
for (int i = 0; i < games.size(); i++) {
|
|
||||||
gamesAnchorPane.getChildren().add(games.get(i).getVBox());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//remove all games from gamesAnchorPane and add them afterwards
|
//remove all games from gamesAnchorPane and add them afterwards
|
||||||
public void refreshUIData() {
|
public void refreshUIData() {
|
||||||
|
System.out.println("refresh");
|
||||||
//remove all games form gamesAnchorPane
|
//remove all games form gamesAnchorPane
|
||||||
gamesAnchorPane.getChildren().removeAll(gamesAnchorPane.getChildren());
|
gamesAnchorPane.getChildren().removeAll(gamesAnchorPane.getChildren());
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
# Buttons
|
# Buttons
|
||||||
aboutBtn = About
|
aboutBtn = About
|
||||||
settingsBtn = Setting
|
settingsBtn = Settings
|
||||||
addBtn = Add new Game
|
addBtn = Add new Game
|
||||||
reloadRomsBtn = reload ROMs
|
reloadRomsBtn = reload ROMs
|
||||||
smmdbBtn = smmdb
|
smmdbBtn = smmdb
|
||||||
|
|
Loading…
Reference in New Issue