mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 06:18:44 +00:00
fixed being able to zoom while chatting by holding shift and then pressing z and x #story[1246]
This commit is contained in:
@@ -64,6 +64,7 @@ public class GameView extends Pane {
|
|||||||
private double metersPerPixelX, metersPerPixelY;
|
private double metersPerPixelX, metersPerPixelY;
|
||||||
|
|
||||||
final double SCALE_DELTA = 1.1;
|
final double SCALE_DELTA = 1.1;
|
||||||
|
private boolean isZoom = false;
|
||||||
|
|
||||||
private Text fpsDisplay = new Text();
|
private Text fpsDisplay = new Text();
|
||||||
private Polygon raceBorder = new CourseBoundary();
|
private Polygon raceBorder = new CourseBoundary();
|
||||||
@@ -101,7 +102,7 @@ public class GameView extends Pane {
|
|||||||
|
|
||||||
private void zoomOut() {
|
private void zoomOut() {
|
||||||
scaleFactor = 0.1;
|
scaleFactor = 0.1;
|
||||||
if (this.getScaleX() > 0.5) {
|
if (this.isZoom && this.getScaleX() > 0.5) {
|
||||||
this.setScaleX(this.getScaleX() - scaleFactor);
|
this.setScaleX(this.getScaleX() - scaleFactor);
|
||||||
this.setScaleY(this.getScaleY() - scaleFactor);
|
this.setScaleY(this.getScaleY() - scaleFactor);
|
||||||
}
|
}
|
||||||
@@ -109,7 +110,7 @@ public class GameView extends Pane {
|
|||||||
|
|
||||||
private void zoomIn() {
|
private void zoomIn() {
|
||||||
scaleFactor = 0.10;
|
scaleFactor = 0.10;
|
||||||
if (this.getScaleX() < 2.5) {
|
if (this.isZoom && this.getScaleX() < 2.5) {
|
||||||
this.setScaleX(this.getScaleX() + scaleFactor);
|
this.setScaleX(this.getScaleX() + scaleFactor);
|
||||||
this.setScaleY(this.getScaleY() + scaleFactor);
|
this.setScaleY(this.getScaleY() + scaleFactor);
|
||||||
}
|
}
|
||||||
@@ -142,6 +143,13 @@ public class GameView extends Pane {
|
|||||||
gameObjects.add(raceBorder);
|
gameObjects.add(raceBorder);
|
||||||
gameObjects.add(markers);
|
gameObjects.add(markers);
|
||||||
initializeTimer();
|
initializeTimer();
|
||||||
|
this.sceneProperty().addListener(((observable, oldValue, scene) -> {
|
||||||
|
if (scene != null) {
|
||||||
|
setupZoom();
|
||||||
|
} else {
|
||||||
|
disableZoom();
|
||||||
|
}
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initializeTimer() {
|
private void initializeTimer() {
|
||||||
@@ -439,8 +447,7 @@ public class GameView extends Pane {
|
|||||||
/**
|
/**
|
||||||
* Enables zoom. Has to be called after this is added to a scene.
|
* Enables zoom. Has to be called after this is added to a scene.
|
||||||
*/
|
*/
|
||||||
public void enableZoom () {
|
private void setupZoom() {
|
||||||
if (this.getScene() != null) {
|
|
||||||
this.getScene().addEventHandler(KeyEvent.KEY_PRESSED, (event) -> {
|
this.getScene().addEventHandler(KeyEvent.KEY_PRESSED, (event) -> {
|
||||||
if (event.getCode() == KeyCode.Z) {
|
if (event.getCode() == KeyCode.Z) {
|
||||||
zoomIn();
|
zoomIn();
|
||||||
@@ -448,8 +455,17 @@ public class GameView extends Pane {
|
|||||||
zoomOut();
|
zoomOut();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
enableZoom();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void enableZoom() {
|
||||||
|
isZoom = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void disableZoom() {
|
||||||
|
isZoom = false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rescales the race to the size of the window.
|
* Rescales the race to the size of the window.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -160,7 +160,6 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
|||||||
gameView.updateCourse(
|
gameView.updateCourse(
|
||||||
new ArrayList<>(raceData.getCompoundMarks().values()), raceData.getMarkSequence()
|
new ArrayList<>(raceData.getCompoundMarks().values()), raceData.getMarkSequence()
|
||||||
);
|
);
|
||||||
gameView.enableZoom();
|
|
||||||
gameView.setBoatAsPlayer(player);
|
gameView.setBoatAsPlayer(player);
|
||||||
gameView.startRace();
|
gameView.startRace();
|
||||||
|
|
||||||
@@ -175,6 +174,13 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
|||||||
updateWindDirection(raceState.windDirectionProperty().doubleValue());
|
updateWindDirection(raceState.windDirectionProperty().doubleValue());
|
||||||
updateWindSpeed(raceState.getWindSpeed());
|
updateWindSpeed(raceState.getWindSpeed());
|
||||||
gameView.setWindDir(raceState.windDirectionProperty().doubleValue());
|
gameView.setWindDir(raceState.windDirectionProperty().doubleValue());
|
||||||
|
chatInput.focusedProperty().addListener((obs, oldValue, newValue) -> {
|
||||||
|
if (newValue) {
|
||||||
|
gameView.disableZoom();
|
||||||
|
} else {
|
||||||
|
gameView.enableZoom();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user