* fixed a few typos
* code clean up
This commit is contained in:
Jannik 2017-11-24 17:07:53 +01:00
parent ba9fd1bb32
commit 922b1443e1
2 changed files with 92 additions and 72 deletions

View File

@ -55,7 +55,7 @@ public class Main extends Application {
public MainWindowController mainWindowController; // TODO find a better way
CloudController cloudController;
AnchorPane pane;
private Scene scene;
Scene scene; // TODO make private
private String dirWin = System.getProperty("user.home") + "/Documents/cemu_UI"; // Windows: C:/Users/"User"/Documents/cemu_UI
private String dirLinux = System.getProperty("user.home") + "/cemu_UI"; // Linux: /home/"User"/cemu_UI
private String gamesDBdownloadURL = "https://github.com/Seil0/cemu_UI/raw/master/downloadContent/games.db";
@ -92,7 +92,7 @@ public class Main extends Application {
mainWindowController = loader.getController(); // Link of FXMLController and controller class
mainWindowController.setMain(this); // call setMain
//get os and the right paths
// get OS and the specific paths
if (System.getProperty("os.name").equals("Linux")) {
directory = new File(dirLinux);
configFile = new File(dirLinux + "/config.xml");

View File

@ -365,7 +365,7 @@ public class MainWindowController {
courseTreeTable.getColumns().add(timeColumn);
courseTreeTable.getColumns().add(starsColumn);
courseTreeTable.getColumns().add(idColumn);
courseTreeTable.getColumns().get(3).setVisible(false); //hide idColumn (important)
courseTreeTable.getColumns().get(3).setVisible(false); // the idColumn should not bee displayed
LOGGER.info("initializing UI done");
}
@ -409,21 +409,13 @@ public class MainWindowController {
edit.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
try {
LOGGER.info("edit "+selectedGameTitleID);
if (selectedGameTitleID == null) {
LOGGER.warn("trying to edit null! null is not valid!");
String headingText = "edit game";
String bodyText = "please select a game, \""+selectedGameTitleID+"\" is not a valid type!";
JFXInfoDialog aboutDialog = new JFXInfoDialog(headingText, bodyText, dialogBtnStyle, 350, 170, main.pane);
aboutDialog.show();
} else {
String[] gameInfo = dbController.getGameInfo(selectedGameTitleID);
//new edit dialog
String headingText = "activate cloud savegame sync (beta)";
String bodyText = "You just activate the cloud savegame sync function of cemu_UI, "
+ "\nwhich is currently in beta. Are you sure you want to do this?";
String headingText = "edit a game";
String bodyText = "You can edit the tile and rom/cover path.";
JFXEditGameDialog editGameDialog = new JFXEditGameDialog(headingText, bodyText, dialogBtnStyle, 350, 300,
1, MWC, main.primaryStage, main.pane);
editGameDialog.setTitle(gameInfo[0]);
@ -431,7 +423,31 @@ public class MainWindowController {
editGameDialog.setRomPath(gameInfo[2]);
editGameDialog.setTitleID(gameInfo[3]);
editGameDialog.show();
} catch (Exception e) {
LOGGER.warn("trying to edit " + selectedGameTitleID + ",which is not a valid type!", e);
}
// if (selectedGameTitleID == null) {
// LOGGER.warn("trying to edit null! null is not valid!");
//
// String headingText = "edit game";
// String bodyText = "please select a game, \""+selectedGameTitleID+"\" is not a valid type!";
// JFXInfoDialog aboutDialog = new JFXInfoDialog(headingText, bodyText, dialogBtnStyle, 350, 170, main.pane);
// aboutDialog.show();
// } else {
// String[] gameInfo = dbController.getGameInfo(selectedGameTitleID);
//
// //new edit dialog
// String headingText = "edit a game";
// String bodyText = "You can edit the tile and rom/cover path.";
// JFXEditGameDialog editGameDialog = new JFXEditGameDialog(headingText, bodyText, dialogBtnStyle, 350, 300,
// 1, MWC, main.primaryStage, main.pane);
// editGameDialog.setTitle(gameInfo[0]);
// editGameDialog.setCoverPath(gameInfo[1]);
// editGameDialog.setRomPath(gameInfo[2]);
// editGameDialog.setTitleID(gameInfo[3]);
// editGameDialog.show();
// }
}
});
@ -873,7 +889,7 @@ public class MainWindowController {
ZipFile zipFile = new ZipFile(source);
zipFile.extractAll(destination);
//rename zipfile
// rename zip-file
File course = new File(destination + "/course000");
course.renameTo( new File(destination + "/" + courseName));
LOGGER.info("Added new course: " + courseName + ", full path is: " + destination + "/" + courseName);
@ -963,10 +979,9 @@ public class MainWindowController {
@FXML
void addBtnAction(ActionEvent event){
String headingText = "activate cloud savegame sync (beta)";
String bodyText = "You just activate the cloud savegame sync function of cemu_UI, "
+ "\nwhich is currently in beta. Are you sure you want to do this?";
JFXEditGameDialog addGameDialog = new JFXEditGameDialog(headingText, bodyText, dialogBtnStyle, 350, 300,
String headingText = "add a new game to cemu_UI";
String bodyText = "";
JFXEditGameDialog addGameDialog = new JFXEditGameDialog(headingText, bodyText, dialogBtnStyle, 450, 300,
0, this, main.primaryStage, main.pane);
addGameDialog.show();
}
@ -1108,8 +1123,10 @@ public class MainWindowController {
}
}
// setting total playtime, if total playtime > 60 minutes, format is "x hours x minutes" (x h x min),
// else only minutes are showed
/**
* 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(titleID)) > 60) {
int hoursPlayed = (int) Math.floor(Integer.parseInt(dbController.getTotalPlaytime(titleID)) / 60);
int minutesPlayed = Integer.parseInt(dbController.getTotalPlaytime(titleID)) - 60 * hoursPlayed;
@ -1340,8 +1357,11 @@ public class MainWindowController {
xPosHelper++;
}
// System.out.println("Breit: " + main.pane.getWidth());
// System.out.println("Breit2: " + mainAnchorPane.getWidth());
// TODO needs testing
System.out.println("Breit: " + main.pane.getWidth());
System.out.println("Breit2: " + mainAnchorPane.getWidth());
System.out.println("Breite3: " + main.scene.getWidth());
System.out.println("Breite4: " + main.primaryStage.getWidth());
// System.out.println("xPosHelper: " + xPosHelper);
// System.out.println("yPos: " + yPos);
// System.out.println("xPos: " + xPos);