Combined SingleServer and MultiServer into one class

This commit is contained in:
2021-03-20 16:30:54 +01:00
parent fa7bda4230
commit 1b4bcd1ec2
16 changed files with 115 additions and 339 deletions

View File

@@ -21,6 +21,7 @@ public class Engine extends Application {
private static final CountDownLatch latch = new CountDownLatch(1);
private static Engine engine = null;
private boolean mouseClicked = false;
private boolean windowClosed = false;
private Point coordinates = new Point();
private Stage primaryStage;
@@ -62,7 +63,7 @@ public class Engine extends Application {
latch.countDown();
}
public void updateTitle(String title){
public void updateTitle(String title) {
System.out.println("title: " + title);
primaryStage.setTitle(title);
}
@@ -90,7 +91,7 @@ public class Engine extends Application {
System.err.println("Wrong length of gameState string");
return;
}
if (gameState.equals("---------")){
if (gameState.equals("---------")) {
grid.getChildren().clear();
}
for (int i = 0; i < gameState.length(); i++) {
@@ -112,6 +113,8 @@ public class Engine extends Application {
coordinates.setLocation(event.getX(), event.getY());
}
public boolean isWindowClosed() {return windowClosed;}
public boolean isMouseClicked() {
return mouseClicked;
}
@@ -134,6 +137,10 @@ public class Engine extends Application {
primaryStage.setScene(this.setScene());
primaryStage.sizeToScene();
primaryStage.show();
primaryStage.setOnCloseRequest(event -> {
windowClosed = true;
});
}
public static void main(String[] args) {