Skip to content

Commit

Permalink
Removed test condition, added some removing options
Browse files Browse the repository at this point in the history
  • Loading branch information
Safranil committed Jun 28, 2016
1 parent 51dcb95 commit 2b92b2a
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ public Void call() {
});

int returnCode = p.waitFor();
if (returnCode != 0 || true) {
if (returnCode != 0) {
MiroaLauncher.LOGGER.severe("Minecraft return code is "+returnCode+", starting crash handler");
PlatformImpl.runAndWait(() -> Main.mainStage.show());
CrashHandler crashHandler = new CrashHandler(
Expand Down
32 changes: 25 additions & 7 deletions src/main/java/fr/safranil/minecraft/miroa/OptionController.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import javafx.scene.control.TextField;
import javafx.stage.FileChooser;
import javafx.stage.Stage;
import org.apache.commons.io.FileUtils;

import java.awt.*;
import java.io.File;
Expand All @@ -45,13 +46,6 @@ public class OptionController {
@FXML
Button logoutButton;

@FXML
Hyperlink hyperlinkLog;
@FXML
Hyperlink hyperlinkLauncher;
@FXML
Hyperlink hyperlinkWebsite;

@FXML
public void initialize() {
MiroaLauncher.LOGGER.info("Initializing option controller");
Expand Down Expand Up @@ -94,6 +88,30 @@ public void openLauncherDir () {
Main.hostServices.showDocument(MiroaLauncher.OS.getWorkingDirectory().getAbsolutePath());
}

@FXML
public void removeLog () {
try {
FileUtils.deleteDirectory(new File(MiroaLauncher.OS.getWorkingDirectory(), "logs"));
} catch (IOException e) {
MiroaLauncher.LOGGER.info("Error when removing log files");
e.printStackTrace();
Utils.displayException("Suppression impossible", "Une erreur est survenue lors de la suppression.", e);
}
}

@FXML
public void removeLauncher () {
for(File file : MiroaLauncher.OS.getWorkingDirectory().listFiles()) {
String name = file.getName();
if (!name.equals("saves") &&
!name.equals("launcher_profiles.json") &&
!name.equals("server.dat") &&
!name.equals("launcher.jar")) {
FileUtils.deleteQuietly(file);
}
}
}

@FXML
public void closeAction() {
Stage stage = (Stage) cancelButton.getScene().getWindow();
Expand Down
21 changes: 12 additions & 9 deletions src/main/resources/fr/safranil/minecraft/miroa/option.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>

<BorderPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="301.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="fr.safranil.minecraft.miroa.OptionController">
<BorderPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="344.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="fr.safranil.minecraft.miroa.OptionController">
<top>
<Pane maxHeight="20.0" minHeight="20.0" prefHeight="20.0" BorderPane.alignment="CENTER" />
</top>
Expand Down Expand Up @@ -56,10 +56,11 @@
<Label text="Option de mémoire pour Java :" />
<ChoiceBox fx:id="memoryChoice" maxWidth="1.7976931348623157E308" />
<Pane layoutX="10.0" layoutY="57.0" maxHeight="20.0" minHeight="20.0" prefHeight="20.0" />
<Hyperlink fx:id="hyperlinkLog" onAction="#openLog" text="Ouvrir le repertoire des logs" />
<Hyperlink fx:id="hyperlinkLauncher" onAction="#openLauncherDir" text="Ouvrir le repertoire du launcher" />
<Hyperlink fx:id="hyperlinkWebsite" onAction="#openWebsite" text="Ouvrir le site internet dans le navigateur web" />
<Pane maxHeight="30.0" minHeight="30.0" prefHeight="30.0" />
<Hyperlink onAction="#openLog" text="Ouvrir le repertoire des logs" />
<Hyperlink onAction="#openLauncherDir" text="Ouvrir le repertoire du launcher" />
<Hyperlink onAction="#openWebsite" text="Ouvrir le site internet dans le navigateur web" />
<Hyperlink layoutX="10.0" layoutY="185.0" onAction="#removeLog" text="Supprimer tous les logs" />
<Hyperlink layoutX="10.0" layoutY="198.0" onAction="#removeLauncher" text="Supprimer tous les fichiers du launcher (sauf mondes)" />
<GridPane>
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
Expand All @@ -69,12 +70,14 @@
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<Button fx:id="cancelButton" maxWidth="1.7976931348623157E308" mnemonicParsing="false" onAction="#closeAction" text="Annuler" GridPane.columnIndex="1" />
<Button fx:id="saveButton" maxWidth="1.7976931348623157E308" mnemonicParsing="false" onAction="#saveAction" text="Enregistrer" GridPane.columnIndex="3" />
<Button fx:id="logoutButton" maxWidth="100.0" minWidth="100.0" mnemonicParsing="false" onAction="#logoutAction" prefWidth="100.0" text="Déconnexion" GridPane.columnIndex="4" GridPane.halignment="RIGHT" />
<Button fx:id="cancelButton" maxWidth="1.7976931348623157E308" mnemonicParsing="false" onAction="#closeAction" text="Annuler" GridPane.columnIndex="1" GridPane.rowIndex="1" />
<Button fx:id="saveButton" maxWidth="1.7976931348623157E308" mnemonicParsing="false" onAction="#saveAction" text="Enregistrer" GridPane.columnIndex="3" GridPane.rowIndex="1" />
<Button fx:id="logoutButton" maxWidth="100.0" minWidth="100.0" mnemonicParsing="false" onAction="#logoutAction" prefWidth="100.0" text="Déconnexion" GridPane.columnIndex="4" GridPane.halignment="RIGHT" GridPane.rowIndex="1" />
<Pane maxHeight="30.0" minHeight="30.0" prefHeight="30.0" GridPane.columnIndex="4" />
</children>
</GridPane>
</children>
Expand Down

0 comments on commit 2b92b2a

Please sign in to comment.