code clean up
This commit is contained in:
parent
922b1443e1
commit
fe6ddedab9
|
@ -40,7 +40,6 @@ import java.sql.SQLException;
|
|||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Optional;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
@ -80,9 +79,6 @@ import javafx.event.ActionEvent;
|
|||
import javafx.event.EventHandler;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.scene.control.Alert;
|
||||
import javafx.scene.control.Alert.AlertType;
|
||||
import javafx.scene.control.ButtonType;
|
||||
import javafx.scene.control.ChoiceBox;
|
||||
import javafx.scene.control.ContextMenu;
|
||||
import javafx.scene.control.Label;
|
||||
|
@ -416,8 +412,8 @@ public class MainWindowController {
|
|||
// 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);
|
||||
JFXEditGameDialog editGameDialog = new JFXEditGameDialog(headingText, bodyText, dialogBtnStyle, 450,
|
||||
300, 1, MWC, main.primaryStage, main.pane);
|
||||
editGameDialog.setTitle(gameInfo[0]);
|
||||
editGameDialog.setCoverPath(gameInfo[1]);
|
||||
editGameDialog.setRomPath(gameInfo[2]);
|
||||
|
@ -426,63 +422,41 @@ public class MainWindowController {
|
|||
} 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();
|
||||
// }
|
||||
}
|
||||
});
|
||||
|
||||
remove.setOnAction(new EventHandler<ActionEvent>() {
|
||||
@Override
|
||||
public void handle(ActionEvent event) {
|
||||
LOGGER.info("remove "+selectedGameTitleID);
|
||||
if(selectedGameTitleID == null){
|
||||
LOGGER.warn("trying to remove null! null is not valid!");
|
||||
|
||||
String headingText = "remove 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{
|
||||
Alert alert = new Alert(AlertType.CONFIRMATION);
|
||||
alert.setTitle("remove");
|
||||
alert.setHeaderText("cemu_UI");
|
||||
alert.setContentText("Are you sure you want to delete "+selectedGameTitle+" ?");
|
||||
alert.initOwner(main.primaryStage);
|
||||
|
||||
Optional<ButtonType> result = alert.showAndWait();
|
||||
if (result.get() == ButtonType.OK){
|
||||
try {
|
||||
// remove game from database
|
||||
games.remove(selectedUIDataIndex);
|
||||
dbController.removeRom(selectedGameTitleID);
|
||||
|
||||
// refresh all games at gamesAnchorPane (UI)
|
||||
refreshUIData();
|
||||
LOGGER.info("remove " + selectedGameTitle + "(" + selectedGameTitleID + ")");
|
||||
String headingText = "remove \"" + selectedGameTitle + "\"";
|
||||
String bodyText = "Are you sure you want to delete " + selectedGameTitle + " ?";
|
||||
EventHandler<ActionEvent> okayAction = new EventHandler<ActionEvent>() {
|
||||
@Override
|
||||
public void handle(ActionEvent event) {
|
||||
try {
|
||||
games.remove(selectedUIDataIndex); // remove game form games-list
|
||||
dbController.removeRom(selectedGameTitleID); // remove game from database
|
||||
refreshUIData(); // refresh all games at gamesAnchorPane (UI)
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("error!",e);
|
||||
LOGGER.error("error while removing ROM from database!", e);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
EventHandler<ActionEvent> cancelAction = new EventHandler<ActionEvent>() {
|
||||
@Override
|
||||
public void handle(ActionEvent event) {
|
||||
// do nothing
|
||||
}
|
||||
};
|
||||
|
||||
JFXOkayCancelDialog removeGameDialog = new JFXOkayCancelDialog(headingText, bodyText,
|
||||
dialogBtnStyle, 350, 170, okayAction, cancelAction, main.pane);
|
||||
removeGameDialog.show();
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("error while removing " + selectedGameTitle + "(" + selectedGameTitleID + ")", e);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -490,15 +464,8 @@ public class MainWindowController {
|
|||
addUpdate.setOnAction(new EventHandler<ActionEvent>() {
|
||||
@Override
|
||||
public void handle(ActionEvent event) {
|
||||
try {
|
||||
LOGGER.info("update: " + selectedGameTitleID);
|
||||
if (selectedGameTitleID == null) {
|
||||
LOGGER.warn("trying to update null! null is not valid!");
|
||||
String headingText = "update game";
|
||||
String bodyText = "please select a game,\n"
|
||||
+ "\""+selectedGameTitleID+"\" is not a valid type!";
|
||||
JFXInfoDialog updateGameErrorDialog = new JFXInfoDialog(headingText, bodyText, dialogBtnStyle, 350, 170, main.pane);
|
||||
updateGameErrorDialog.show();
|
||||
} else {
|
||||
String headingText = "update \"" + selectedGameTitle + "\"";
|
||||
String bodyText = "pleas select the update root directory";
|
||||
EventHandler<ActionEvent> okayAction = new EventHandler<ActionEvent>() {
|
||||
|
@ -508,9 +475,9 @@ public class MainWindowController {
|
|||
File selectedDirecroty = directoryChooser.showDialog(main.primaryStage);
|
||||
String updatePath = selectedDirecroty.getAbsolutePath();
|
||||
String[] parts = selectedGameTitleID.split("-"); // split string into 2 parts at "-"
|
||||
|
||||
File srcDir = new File(updatePath);
|
||||
File destDir;
|
||||
|
||||
if (System.getProperty("os.name").equals("Linux")) {
|
||||
destDir = new File(cemuPath + "/mlc01/usr/title/" + parts[0] + "/" + parts[1]);
|
||||
} else {
|
||||
|
@ -539,13 +506,15 @@ public class MainWindowController {
|
|||
EventHandler<ActionEvent> cancelAction = new EventHandler<ActionEvent>() {
|
||||
@Override
|
||||
public void handle(ActionEvent event) {
|
||||
|
||||
// do nothing
|
||||
}
|
||||
};
|
||||
|
||||
JFXOkayCancelDialog updateGameDialog = new JFXOkayCancelDialog(headingText, bodyText,
|
||||
dialogBtnStyle, 350, 170, okayAction, cancelAction, main.pane);
|
||||
updateGameDialog.show();
|
||||
} catch (Exception e) {
|
||||
LOGGER.warn("trying to update " + selectedGameTitleID + ",which is not a valid type!", e);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -553,16 +522,8 @@ public class MainWindowController {
|
|||
addDLC.setOnAction(new EventHandler<ActionEvent>() {
|
||||
@Override
|
||||
public void handle(ActionEvent event) {
|
||||
try {
|
||||
LOGGER.info("add DLC: " + selectedGameTitleID);
|
||||
|
||||
if (selectedGameTitleID == null) {
|
||||
LOGGER.warn("trying to add a dlc to null! null is not valid!");
|
||||
String headingText = "add DLC";
|
||||
String bodyText = "please select a game,\n"
|
||||
+ "\"" + selectedGameTitleID + "\" is not a valid type!";
|
||||
JFXInfoDialog addDLCErrorDialog = new JFXInfoDialog(headingText, bodyText, dialogBtnStyle, 350, 170, main.pane);
|
||||
addDLCErrorDialog.show();
|
||||
} else {
|
||||
String headingText = "add a DLC to \"" + selectedGameTitle + "\"";
|
||||
String bodyText = "pleas select the DLC root directory";
|
||||
EventHandler<ActionEvent> okayAction = new EventHandler<ActionEvent>() {
|
||||
|
@ -577,7 +538,8 @@ public class MainWindowController {
|
|||
if (System.getProperty("os.name").equals("Linux")) {
|
||||
destDir = new File(cemuPath + "/mlc01/usr/title/" + parts[0] + "/" + parts[1] + "/aoc");
|
||||
} else {
|
||||
destDir = new File(cemuPath+"\\mlc01\\usr\\title\\"+parts[0]+"\\"+parts[1]+"\\aoc");
|
||||
destDir = new File(
|
||||
cemuPath + "\\mlc01\\usr\\title\\" + parts[0] + "\\" + parts[1] + "\\aoc");
|
||||
}
|
||||
|
||||
// if directory doesn't exist create it
|
||||
|
@ -602,13 +564,15 @@ public class MainWindowController {
|
|||
EventHandler<ActionEvent> cancelAction = new EventHandler<ActionEvent>() {
|
||||
@Override
|
||||
public void handle(ActionEvent event) {
|
||||
|
||||
// do nothing
|
||||
}
|
||||
};
|
||||
|
||||
JFXOkayCancelDialog addDLCDialog = new JFXOkayCancelDialog(headingText, bodyText,
|
||||
dialogBtnStyle, 350, 170, okayAction, cancelAction, main.pane);
|
||||
JFXOkayCancelDialog addDLCDialog = new JFXOkayCancelDialog(headingText, bodyText, dialogBtnStyle,
|
||||
350, 170, okayAction, cancelAction, main.pane);
|
||||
addDLCDialog.show();
|
||||
} catch (Exception e) {
|
||||
LOGGER.warn("trying to add a dlc to " + selectedGameTitleID + ",which is not a valid type!", e);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -637,7 +601,8 @@ public class MainWindowController {
|
|||
public void changed(ObservableValue<?> observable, Object oldVal, Object newVal) {
|
||||
selected = courseTreeTable.getSelectionModel().getSelectedIndex(); // get selected item
|
||||
|
||||
// FIXME if a item is selected and you change the sorting,you can't select a new item
|
||||
// FIXME if a item is selected and you change the sorting,you can't select a new
|
||||
// item
|
||||
id = idColumn.getCellData(selected); // get name of selected item
|
||||
|
||||
for (int i = 0; i < courses.size(); i++) {
|
||||
|
@ -759,8 +724,8 @@ public class MainWindowController {
|
|||
|
||||
// add query response to courseTreeTable
|
||||
for (int i = 0; i < courses.size(); i++) {
|
||||
CourseTableDataType helpCourse = new CourseTableDataType(courses.get(i).getTitle(), courses.get(i).getId(),
|
||||
courses.get(i).getTime(), courses.get(i).getStars());
|
||||
CourseTableDataType helpCourse = new CourseTableDataType(courses.get(i).getTitle(),
|
||||
courses.get(i).getId(), courses.get(i).getTime(), courses.get(i).getStars());
|
||||
|
||||
root.getChildren().add(new TreeItem<CourseTableDataType>(helpCourse)); // add data to root-node
|
||||
}
|
||||
|
@ -836,7 +801,8 @@ public class MainWindowController {
|
|||
} else {
|
||||
setAutoUpdate(true);
|
||||
}
|
||||
saveSettings(); }
|
||||
saveSettings();
|
||||
}
|
||||
|
||||
@FXML
|
||||
void smmdbDownloadBtnAction(ActionEvent event) {
|
||||
|
@ -981,8 +947,8 @@ public class MainWindowController {
|
|||
void addBtnAction(ActionEvent event) {
|
||||
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);
|
||||
JFXEditGameDialog addGameDialog = new JFXEditGameDialog(headingText, bodyText, dialogBtnStyle, 450, 300, 0,
|
||||
this, main.primaryStage, main.pane);
|
||||
addGameDialog.show();
|
||||
}
|
||||
|
||||
|
@ -1357,11 +1323,8 @@ public class MainWindowController {
|
|||
xPosHelper++;
|
||||
}
|
||||
|
||||
// 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("Breit: " + main.pane.getWidth());
|
||||
// System.out.println("Breit2: " + mainAnchorPane.getWidth());
|
||||
// System.out.println("xPosHelper: " + xPosHelper);
|
||||
// System.out.println("yPos: " + yPos);
|
||||
// System.out.println("xPos: " + xPos);
|
||||
|
|
Loading…
Reference in New Issue