Launcher now disappears when game starts and reappears when game ends.

This commit is contained in:
François Autin 2021-06-25 17:35:18 +02:00
parent a4484404cd
commit 87c1ff3af1
2 changed files with 42 additions and 4 deletions

View File

@ -2,6 +2,7 @@ package launcher;
import gameplay.match.*;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.scene.Parent;
@ -9,10 +10,12 @@ import javafx.scene.Scene;
import javafx.scene.control.ChoiceBox;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.scene.control.CheckBox;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import javafx.stage.Window;
import javafx.fxml.*;
import java.io.IOException;
@ -166,9 +169,22 @@ public class Launcher extends Application {
try {
fillArraySettings();
setter.setSettings();
match.main(null);
hideWindow();
Thread t = new Thread() {
public void run() {
try {
match.main(null);
} catch (Exception e) {
e.printStackTrace();
}
}
};
t.start();
t.join();
showWindow();
} catch (Exception e) {
System.out.println("Fill all boxes to launch the game");
e.printStackTrace();
System.exit(1);
}
}
@ -245,6 +261,28 @@ public class Launcher extends Application {
arraysettings.put("stage", "default");
}
/**
* hides the launcher
*/
@FXML
private void hideWindow() {
HBox hb = (HBox) namespace.get("window");
Scene sc = hb.getScene();
Window win = sc.getWindow();
win.hide();
}
/**
* shows the launcher
* @throws Exception
*/
@FXML
private void showWindow() throws Exception {
setter.parse();
Stage st = new Stage();
start(st);
}
/**
* quits the launcher and the game
*/

View File

@ -41,7 +41,7 @@ public class Settings {
* @author François Autin
* @author Indy Boyeau
*/
private void parse() throws Exception {
protected void parse() throws Exception {
// Initializing the parser
JSONParser jsonP = new JSONParser();
@ -93,7 +93,7 @@ public class Settings {
} catch (IOException e) {
e.printStackTrace();
System.exit(1);
} catch (ParseException e) {
} catch (Exception e) {
rounds = 3;
p1 = "default";
p2 = "default";