mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 06:18:44 +00:00
Finish screen not appearing. Start screen opened simultanously.
This commit is contained in:
@@ -1,14 +1,5 @@
|
||||
package seng302.visualiser;
|
||||
|
||||
import javafx.application.Platform;
|
||||
import javafx.util.Pair;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import seng302.gameServer.messages.*;
|
||||
import seng302.model.stream.packets.PacketType;
|
||||
import seng302.model.stream.packets.StreamPacket;
|
||||
import seng302.utilities.XMLParser;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@@ -23,6 +14,7 @@ import java.util.TimerTask;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.zip.CRC32;
|
||||
import java.util.zip.Checksum;
|
||||
import javafx.application.Platform;
|
||||
import javafx.util.Pair;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -99,6 +91,7 @@ public class ClientToServerThread implements Runnable {
|
||||
|
||||
private ByteArrayOutputStream crcBuffer;
|
||||
private boolean socketOpen = true;
|
||||
private boolean ignoreDC = false;
|
||||
|
||||
/**
|
||||
* Constructor for ClientToServerThread which takes in ipAddress and portNumber and attempts to
|
||||
@@ -181,8 +174,10 @@ public class ClientToServerThread implements Runnable {
|
||||
closeSocket();
|
||||
|
||||
Platform.runLater(() -> {
|
||||
ViewManager.getInstance().showErrorSnackBar("Server rejected connection.");
|
||||
ViewManager.getInstance().goToStartView();
|
||||
if (ignoreDC) {
|
||||
ViewManager.getInstance().showErrorSnackBar("Server rejected connection.");
|
||||
ViewManager.getInstance().goToStartView();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -198,7 +193,7 @@ public class ClientToServerThread implements Runnable {
|
||||
}
|
||||
|
||||
private void notifyDisconnectListeners (String message) {
|
||||
if (socketOpen) {
|
||||
if (socketOpen && !ignoreDC) {
|
||||
for (DisconnectedFromHostListener listener : disconnectionListeners) {
|
||||
listener.notifyDisconnection(message);
|
||||
}
|
||||
@@ -448,4 +443,8 @@ public class ClientToServerThread implements Runnable {
|
||||
public boolean hasStarted() {
|
||||
return isStarted;
|
||||
}
|
||||
|
||||
public void ignoreDC() {
|
||||
ignoreDC = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,12 +49,6 @@ import seng302.visualiser.controllers.RaceViewController;
|
||||
import seng302.visualiser.controllers.ViewManager;
|
||||
import seng302.visualiser.controllers.dialogs.PopupDialogController;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZoneOffset;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* This class is a client side instance of a yacht racing game in JavaFX. The game is instantiated
|
||||
* with a JavaFX Pane to insert itself into.
|
||||
@@ -210,7 +204,11 @@ public class GameClient {
|
||||
controller.setContent(message);
|
||||
controller.setOptionButtonText("GO HOME");
|
||||
controller
|
||||
.setOptionButtonEventHandler(event -> ViewManager.getInstance().goToStartView());
|
||||
.setOptionButtonEventHandler(event -> {
|
||||
System.out.println("inShowConnectionError");
|
||||
ViewManager.getInstance().goToStartView();
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ public class GameView3D extends GameView{
|
||||
|
||||
private final double FOV = 60;
|
||||
private final double DEFAULT_CAMERA_X = 0;
|
||||
private final double DEFAULT_CAMERA_Y = 100;
|
||||
private final double DEFAULT_CAMERA_Y = 160;
|
||||
|
||||
private Group root3D;
|
||||
private SubScene view;
|
||||
@@ -509,8 +509,7 @@ public class GameView3D extends GameView{
|
||||
|
||||
private void updateMarkArrows (ClientYacht yacht, int legNumber) {
|
||||
CompoundMark compoundMark;
|
||||
legNumber += 1;
|
||||
if (legNumber - 1 >= 0) {
|
||||
if (legNumber - 1 >= 0 && legNumber-1 < course.size()) {
|
||||
Sounds.playMarkRoundingSound();
|
||||
compoundMark = course.get(legNumber-1);
|
||||
for (Mark mark : compoundMark.getMarks()) {
|
||||
@@ -518,7 +517,7 @@ public class GameView3D extends GameView{
|
||||
}
|
||||
}
|
||||
CompoundMark nextMark = null;
|
||||
if (legNumber < course.size() - 1) {
|
||||
if (legNumber < course.size()) {
|
||||
Sounds.playMarkRoundingSound();
|
||||
nextMark = course.get(legNumber);
|
||||
for (Mark mark : nextMark.getMarks()) {
|
||||
|
||||
@@ -16,8 +16,8 @@ public class IsometricCamera extends PerspectiveCamera implements RaceCamera {
|
||||
private final Double MAX_Y = 170.0;
|
||||
|
||||
private final Double PAN_LIMIT = 160.0;
|
||||
private final Double NEAR_ZOOM_LIMIT = -50.0;
|
||||
private final Double FAR_ZOOM_LIMIT = -160.0;
|
||||
private final Double NEAR_ZOOM_LIMIT = -30.0;
|
||||
private final Double FAR_ZOOM_LIMIT = -180.0;
|
||||
|
||||
private Double horizontalPan;
|
||||
private Double verticalPan;
|
||||
@@ -29,7 +29,8 @@ public class IsometricCamera extends PerspectiveCamera implements RaceCamera {
|
||||
super(true);
|
||||
transforms = this.getTransforms();
|
||||
|
||||
zoomFactor = (FAR_ZOOM_LIMIT + NEAR_ZOOM_LIMIT) / 2.0;
|
||||
// zoomFactor = (FAR_ZOOM_LIMIT + NEAR_ZOOM_LIMIT) / 2.0;
|
||||
zoomFactor = FAR_ZOOM_LIMIT;
|
||||
horizontalPan = cameraStartX;
|
||||
verticalPan = cameraStartY;
|
||||
|
||||
|
||||
@@ -11,9 +11,9 @@ import seng302.visualiser.fxObjects.assets_3D.BoatObject;
|
||||
|
||||
public class TopDownCamera extends PerspectiveCamera implements RaceCamera {
|
||||
|
||||
private final Double PAN_LIMIT = 30.0;
|
||||
private final Double NEAR_ZOOM_LIMIT = -30.0;
|
||||
private final Double FAR_ZOOM_LIMIT = -130.0;
|
||||
private final Double PAN_LIMIT = 40d;
|
||||
private final Double NEAR_ZOOM_LIMIT = -35d;
|
||||
private final Double FAR_ZOOM_LIMIT = -145d;
|
||||
private final Double ZOOM_STEP = 2.5;
|
||||
|
||||
private ObservableList<Transform> transforms;
|
||||
|
||||
@@ -225,7 +225,7 @@ public class LobbyController implements Initializable {
|
||||
}
|
||||
|
||||
private void leaveLobby() {
|
||||
|
||||
System.out.println("LEFT LOBBY");
|
||||
ViewManager.getInstance().getGameClient().stopGame();
|
||||
ViewManager.getInstance().goToStartView();
|
||||
}
|
||||
|
||||
@@ -197,7 +197,9 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
||||
}
|
||||
|
||||
public void showFinishDialog(ArrayList<ClientYacht> finishedBoats) {
|
||||
System.out.println("called");
|
||||
raceState.setRaceStarted(false);
|
||||
ViewManager.getInstance().getGameClient().getServerThread().ignoreDC();
|
||||
createFinishDialog(finishedBoats);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ import com.jfoenix.controls.JFXButton;
|
||||
import com.jfoenix.controls.JFXListView;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.ResourceBundle;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
@@ -26,7 +25,10 @@ public class FinishDialogController implements Initializable {
|
||||
|
||||
@Override
|
||||
public void initialize(URL location, ResourceBundle resources) {
|
||||
playAgain.setOnAction(event -> ViewManager.getInstance().goToStartView());
|
||||
playAgain.setOnAction(event -> {
|
||||
System.out.println("CALLED HERE");
|
||||
ViewManager.getInstance().goToStartView();
|
||||
});
|
||||
}
|
||||
|
||||
public void setFinishedBoats(ArrayList<ClientYacht> finishedBoats) {
|
||||
|
||||
Reference in New Issue
Block a user