use a ProcessBuilder instead of Runtime.exec

This commit is contained in:
Jannik 2018-02-03 14:22:41 +01:00
parent 88e31468d4
commit b88c530ac2
4 changed files with 24 additions and 58 deletions

View File

@ -141,7 +141,6 @@ public class Main extends Application {
mainWindowController.setLanguage("en_US"); mainWindowController.setLanguage("en_US");
mainWindowController.setLastLocalSync(0); mainWindowController.setLastLocalSync(0);
mainWindowController.setxPosHelper(0); mainWindowController.setxPosHelper(0);
mainWindowController.setExecuteCommand(mainWindowController.getCemuPath() + "/Cemu.exe -g ");
mainWindowController.saveSettings(); mainWindowController.saveSettings();
Runtime.getRuntime().exec("java -jar cemu_UI.jar"); //start again (preventing Bugs) Runtime.getRuntime().exec("java -jar cemu_UI.jar"); //start again (preventing Bugs)
System.exit(0); //finishes itself System.exit(0); //finishes itself

View File

@ -284,14 +284,13 @@ public class MainWindowController {
private String cemuPath; private String cemuPath;
private String romDirectoryPath; private String romDirectoryPath;
private String gameExecutePath; private String gameExecutePath;
private String executeCommand;
private String color; private String color;
private String dialogBtnStyle; private String dialogBtnStyle;
private String selectedGameTitleID; private String selectedGameTitleID;
private String selectedGameTitle; private String selectedGameTitle;
private String id; private String id;
private String version = "0.3.0"; private String version = "0.3.0";
private String buildNumber = "073"; private String buildNumber = "075";
private String versionName = "Puzzle Plank Galaxy"; private String versionName = "Puzzle Plank Galaxy";
private int xPos = -200; private int xPos = -200;
private int yPos = 17; private int yPos = 17;
@ -404,7 +403,6 @@ public class MainWindowController {
cemuTextField.setText(cemuPath); cemuTextField.setText(cemuPath);
romTextField.setText(romDirectoryPath); romTextField.setText(romDirectoryPath);
executeCommandTextFiled.setText(getExecuteCommand());
colorPicker.setValue(Color.valueOf(getColor())); colorPicker.setValue(Color.valueOf(getColor()));
fullscreenToggleBtn.setSelected(isFullscreen()); fullscreenToggleBtn.setSelected(isFullscreen());
cloudSyncToggleBtn.setSelected(isCloudSync()); cloudSyncToggleBtn.setSelected(isCloudSync());
@ -821,14 +819,6 @@ public class MainWindowController {
saveSettings(); saveSettings();
} }
}); });
executeCommandTextFiled.textProperty().addListener(new ChangeListener<String>() {
@Override
public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
setExecuteCommand(executeCommandTextFiled.getText());
saveSettings();
}
});
LOGGER.info("initializing Actions done!"); LOGGER.info("initializing Actions done!");
} }
@ -1055,12 +1045,8 @@ public class MainWindowController {
void fullscreenToggleBtnAction(ActionEvent event) { void fullscreenToggleBtnAction(ActionEvent event) {
if (fullscreen) { if (fullscreen) {
fullscreen = false; fullscreen = false;
setExecuteCommand(getExecuteCommand().replace("-f -g", "-g"));
executeCommandTextFiled.setText(getExecuteCommand());
} else { } else {
fullscreen = true; fullscreen = true;
setExecuteCommand(getExecuteCommand().replace("-g", "-f -g"));
executeCommandTextFiled.setText(getExecuteCommand());
} }
saveSettings(); saveSettings();
} }
@ -1669,7 +1655,6 @@ public class MainWindowController {
try { try {
props.setProperty("cemuPath", getCemuPath()); props.setProperty("cemuPath", getCemuPath());
props.setProperty("romPath", getRomDirectoryPath()); props.setProperty("romPath", getRomDirectoryPath());
props.setProperty("executeCommand", getExecuteCommand());
props.setProperty("color", getColor()); props.setProperty("color", getColor());
props.setProperty("language", getLanguage()); props.setProperty("language", getLanguage());
props.setProperty("fullscreen", String.valueOf(isFullscreen())); props.setProperty("fullscreen", String.valueOf(isFullscreen()));
@ -1727,13 +1712,6 @@ public class MainWindowController {
setRomDirectoryPath(""); setRomDirectoryPath("");
} }
if (props.getProperty("executeCommand") == null) {
LOGGER.error("could not load executeCommand, setting default instead!");
setExecuteCommand(getCemuPath() + "\\Cemu.exe -g ");
} else {
setExecuteCommand(props.getProperty("executeCommand"));
}
try { try {
setColor(props.getProperty("color")); setColor(props.getProperty("color"));
} catch (Exception e) { } catch (Exception e) {
@ -1907,14 +1885,6 @@ public class MainWindowController {
public void setRomDirectoryPath(String romDirectoryPath) { public void setRomDirectoryPath(String romDirectoryPath) {
this.romDirectoryPath = romDirectoryPath; this.romDirectoryPath = romDirectoryPath;
} }
public String getExecuteCommand() {
return executeCommand;
}
public void setExecuteCommand(String executeCommand) {
this.executeCommand = executeCommand;
}
public String getColor() { public String getColor() {
return color; return color;

View File

@ -45,7 +45,7 @@ public class playGame extends Thread{
@Override @Override
public void run(){ public void run(){
String selectedGameTitleID = mainWindowController.getSelectedGameTitleID(); String selectedGameTitleID = mainWindowController.getSelectedGameTitleID();
String executeComand; // String executeComand;
long startTime; long startTime;
long endTime; long endTime;
int timePlayedNow; int timePlayedNow;
@ -57,25 +57,31 @@ public class playGame extends Thread{
}); });
startTime = System.currentTimeMillis(); startTime = System.currentTimeMillis();
try{ try{
executeComand = mainWindowController.getExecuteCommand() + " \"" + mainWindowController.getGameExecutePath() + "\""; // executeComand = mainWindowController.getExecuteCommand() + " \"" + mainWindowController.getGameExecutePath() + "\"";
if(mainWindowController.isFullscreen()){
if(System.getProperty("os.name").equals("Linux")){
p = new ProcessBuilder("wine", mainWindowController.getCemuPath() + "/Cemu.exe", "-f",
"-g \"" + mainWindowController.getGameExecutePath() + "\"").start();
} else {
p = new ProcessBuilder(mainWindowController.getCemuPath() + "/Cemu.exe", "-f",
"-g \"" + mainWindowController.getGameExecutePath() + "\"").start();
}
}else{
if(System.getProperty("os.name").equals("Linux")){
p = new ProcessBuilder("wine", mainWindowController.getCemuPath() + "/Cemu.exe",
"-g \"" + mainWindowController.getGameExecutePath() + "\"").start();
} else {
p = new ProcessBuilder(mainWindowController.getCemuPath() + "/Cemu.exe",
"-g \"" + mainWindowController.getGameExecutePath() + "\"").start();
}
}
// LOGGER.info(p.toString());
// if(mainWindowController.isFullscreen()){ // p = Runtime.getRuntime().exec(");
// if(System.getProperty("os.name").equals("Linux")){ // p = new ProcessBuilder("wine", "/home/jannik/Downloads/cemu_1.11.3/Cemu.exe", "-g \"" + mainWindowController.getGameExecutePath() + "\"").start();
// executeComand = "wine "+mainWindowController.getCemuPath()+"/Cemu.exe -f -g \""+mainWindowController.getGameExecutePath()+"\"";
// } else {
// executeComand = mainWindowController.getCemuPath()+"\\Cemu.exe -f -g \""+mainWindowController.getGameExecutePath()+"\"";
// }
// }else{
// if(System.getProperty("os.name").equals("Linux")){
// executeComand = "wine "+mainWindowController.getCemuPath()+"/Cemu.exe -g \""+mainWindowController.getGameExecutePath()+"\"";
// } else {
// executeComand = mainWindowController.getCemuPath() + "\\Cemu.exe -g " + "\"" + mainWindowController.getGameExecutePath() + "\"";
// }
// }
LOGGER.info(executeComand);
p = Runtime.getRuntime().exec(executeComand);
p.waitFor(); p.waitFor();
endTime = System.currentTimeMillis(); endTime = System.currentTimeMillis();
timePlayedNow = (int) Math.floor(((endTime - startTime)/1000/60)); timePlayedNow = (int) Math.floor(((endTime - startTime)/1000/60));

View File

@ -170,15 +170,6 @@
<VBox.margin> <VBox.margin>
<Insets top="-10.0" /> <Insets top="-10.0" />
</VBox.margin></JFXToggleButton> </VBox.margin></JFXToggleButton>
<VBox prefHeight="200.0" prefWidth="100.0" spacing="7.0">
<children>
<Label fx:id="cemuDirectoryLbl1" text="execute command" />
<JFXTextField fx:id="executeCommandTextFiled" maxWidth="430.0" minWidth="430.0" prefHeight="25.0" prefWidth="430.0" promptText="execute command" />
</children>
<padding>
<Insets right="5.0" />
</padding>
</VBox>
<Label fx:id="licensesLbl" text="Licenses" /> <Label fx:id="licensesLbl" text="Licenses" />
</children> </children>
<padding> <padding>