mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 06:18:44 +00:00
experimenting with map scaling
#implement
This commit is contained in:
@@ -48,7 +48,7 @@ public class ClientToServerThread implements Runnable {
|
||||
|
||||
@FunctionalInterface
|
||||
public interface DisconnectedFromHostListener {
|
||||
void notifYDisconnection (String message);
|
||||
void notifyDisconnection(String message);
|
||||
}
|
||||
|
||||
private class ByteReadException extends Exception {
|
||||
@@ -170,7 +170,7 @@ public class ClientToServerThread implements Runnable {
|
||||
private void notifyDisconnectListeners (String message) {
|
||||
if (socketOpen) {
|
||||
for (DisconnectedFromHostListener listener : disconnectionListeners) {
|
||||
listener.notifYDisconnection(message);
|
||||
listener.notifyDisconnection(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package seng302.visualiser;
|
||||
|
||||
import javafx.application.Platform;
|
||||
import javafx.beans.value.ChangeListener;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.geometry.Point2D;
|
||||
import javafx.scene.*;
|
||||
@@ -54,6 +55,8 @@ public class GameView extends Pane {
|
||||
private List<CompoundMark> compoundMarks = new ArrayList<>();
|
||||
private List<Corner> courseOrder = new ArrayList<>();
|
||||
|
||||
private ChangeListener<? super Number> heightChangeListener;
|
||||
|
||||
private ImageView mapImage = new ImageView();
|
||||
|
||||
private enum ScaleDirection {
|
||||
@@ -70,14 +73,30 @@ public class GameView extends Pane {
|
||||
gameObjects = this.getChildren();
|
||||
gameObjects.addAll(mapImage, raceBorder, markers, tokens);
|
||||
this.parentProperty().addListener((obs, old, parent) -> {
|
||||
if (old != null) {
|
||||
((Pane) old).heightProperty().removeListener(heightChangeListener);
|
||||
}
|
||||
if (parent != null) {
|
||||
canvasWidth = parent.prefWidth(1) * 1.5;
|
||||
canvasHeight = parent.prefHeight(1) * 1.5;
|
||||
heightChangeListener = (observableValue, oldHeight, newHeight) -> {
|
||||
canvasWidth = ((Pane) parent).getWidth();
|
||||
canvasHeight = newHeight.doubleValue();
|
||||
updateBorder(borderPoints);
|
||||
updateCourse(compoundMarks, courseOrder);
|
||||
};
|
||||
((Pane) parent).heightProperty().addListener(heightChangeListener);
|
||||
// }
|
||||
// if (parent != null) {
|
||||
// canvasWidth = parent.prefWidth(1);
|
||||
// canvasHeight = parent.prefHeight(1);
|
||||
// rescaleRace(borderPoints);
|
||||
System.out.println("parent = " + parent.maxWidth(100));
|
||||
System.out.println("parent.minWidth(1) = " + parent.minWidth(100));
|
||||
System.out.println(canvasWidth);
|
||||
System.out.println(canvasHeight);
|
||||
// System.out.println("parent = " + parent.maxWidth(100));
|
||||
// System.out.println("parent.minWidth(1) = " + parent.minWidth(100));
|
||||
// System.out.println(canvasWidth);
|
||||
// System.out.println(canvasHeight);
|
||||
canvasWidth = ((Pane) parent).getHeight();
|
||||
canvasWidth = ((Pane) parent).getWidth();
|
||||
System.out.println("canvasWidth = " + canvasWidth);
|
||||
System.out.println("canvasHeight = " + canvasHeight);
|
||||
this.getChildren().add(new Circle(canvasWidth / 2, canvasHeight / 2, 7, Color.GREENYELLOW));
|
||||
this.getChildren().add(new Circle(canvasWidth, canvasHeight, 7, Color.GREENYELLOW));
|
||||
this.getChildren().add(new Circle(0,0, 7, Color.GREENYELLOW));
|
||||
|
||||
@@ -2,6 +2,12 @@ package seng302.visualiser.controllers;
|
||||
|
||||
import com.jfoenix.controls.JFXButton;
|
||||
import com.jfoenix.controls.JFXDialog;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.ResourceBundle;
|
||||
import javafx.application.Platform;
|
||||
import javafx.collections.ListChangeListener;
|
||||
import javafx.fxml.FXML;
|
||||
@@ -9,7 +15,7 @@ import javafx.fxml.FXMLLoader;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.ScrollPane;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.scene.paint.Color;
|
||||
@@ -27,13 +33,6 @@ import seng302.visualiser.GameView;
|
||||
import seng302.visualiser.controllers.cells.PlayerCell;
|
||||
import seng302.visualiser.controllers.dialogs.BoatCustomizeController;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
public class LobbyController implements Initializable {
|
||||
|
||||
//--------FXML BEGIN--------//
|
||||
@@ -50,7 +49,7 @@ public class LobbyController implements Initializable {
|
||||
@FXML
|
||||
private Label mapName;
|
||||
@FXML
|
||||
private Pane serverMap;
|
||||
private AnchorPane serverMap;
|
||||
//---------FXML END---------//
|
||||
|
||||
private RaceState raceState;
|
||||
@@ -105,7 +104,16 @@ public class LobbyController implements Initializable {
|
||||
leaveLobbyButton.setOnMouseEntered(e -> Sounds.playHoverSound());
|
||||
customizeButton.setOnMouseEntered(e -> Sounds.playHoverSound());
|
||||
beginRaceButton.setOnMouseEntered(e -> Sounds.playHoverSound());
|
||||
|
||||
serverMap.setPrefWidth(serverMap.getWidth());
|
||||
serverMap.setPrefHeight(serverMap.getHeight());
|
||||
serverMap.widthProperty().addListener((obs, oldVal, newVal) -> {
|
||||
System.out.println("LISTEN " + newVal);
|
||||
serverMap.setPrefWidth(newVal.doubleValue());
|
||||
});
|
||||
serverMap.heightProperty().addListener((obs, oldVal, newVal) -> {
|
||||
System.out.println("LISTEN HEIUGHT "+newVal);
|
||||
serverMap.setPrefHeight(newVal.doubleValue());
|
||||
});
|
||||
initMapPreview();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user