mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 06:18:44 +00:00
Fixed a bug that race view doesn't fit in decorator.
- recreated a new stage and decorator to fix the bug as decorator might not be able to be reused. #story[1245]
This commit is contained in:
@@ -10,6 +10,7 @@ import javafx.fxml.FXML;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.geometry.Point2D;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.SubScene;
|
||||
import javafx.scene.chart.LineChart;
|
||||
import javafx.scene.chart.NumberAxis;
|
||||
import javafx.scene.chart.XYChart;
|
||||
@@ -176,7 +177,16 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
||||
updateOrder(raceState.getPlayerPositions());
|
||||
gameView = new GameView3D();
|
||||
// gameView.setFrameRateFXText(fpsDisplay);
|
||||
Platform.runLater(() -> contentAnchorPane.getChildren().add(0, gameView.getAssets()));
|
||||
Platform.runLater(() -> {
|
||||
contentAnchorPane.getChildren().add(0, gameView.getAssets());
|
||||
((SubScene) gameView.getAssets()).widthProperty()
|
||||
.bind(ViewManager.getInstance().getStage().widthProperty());
|
||||
((SubScene) gameView.getAssets()).heightProperty()
|
||||
.bind(ViewManager.getInstance().getStage().heightProperty());
|
||||
System.out.println(((SubScene) gameView.getAssets()).getHeight());
|
||||
System.out.println(((SubScene) gameView.getAssets()).getWidth());
|
||||
|
||||
});
|
||||
gameView.setBoats(new ArrayList<>(participants.values()));
|
||||
gameView.updateBorder(raceData.getCourseLimit());
|
||||
gameView.updateTokens(raceData.getTokens());
|
||||
|
||||
@@ -34,6 +34,11 @@ public class ViewManager {
|
||||
private HashMap<String, String> properties; //TODO is this the best way to do this??
|
||||
private ObservableList<String> playerList;
|
||||
private Logger logger = LoggerFactory.getLogger(ViewManager.class);
|
||||
|
||||
public Stage getStage() {
|
||||
return stage;
|
||||
}
|
||||
|
||||
private Stage stage;
|
||||
|
||||
private ViewManager() {
|
||||
@@ -170,21 +175,31 @@ public class ViewManager {
|
||||
Platform.runLater(() -> {
|
||||
try {
|
||||
stage.close();
|
||||
stage = new Stage();
|
||||
|
||||
Scene scene = new Scene(loader.load());
|
||||
JFXDecorator decorator = new JFXDecorator(stage, loader.load(), false, true, true);
|
||||
decorator.setCustomMaximize(true);
|
||||
decorator.applyCss();
|
||||
decorator.getStylesheets()
|
||||
.add(getClass().getResource("/css/master.css").toExternalForm());
|
||||
|
||||
Scene scene = new Scene(decorator);
|
||||
// set key press event to catch key stoke
|
||||
scene.setOnKeyPressed(gameClient::keyPressed);
|
||||
scene.setOnKeyReleased(gameClient::keyReleased);
|
||||
|
||||
Rectangle2D visualBounds = Screen.getPrimary().getVisualBounds();
|
||||
stage = new Stage();
|
||||
// uncomment to make it full screen
|
||||
// Rectangle2D visualBounds = Screen.getPrimary().getVisualBounds();
|
||||
// stage.setX(visualBounds.getMinX());
|
||||
// stage.setY(visualBounds.getMinY());
|
||||
// stage.setWidth(visualBounds.getWidth());
|
||||
// stage.setHeight(visualBounds.getHeight());
|
||||
// stage.setMaximized(true);
|
||||
// stage.setFullScreen(true);
|
||||
|
||||
stage.setMinHeight(500);
|
||||
stage.setMinWidth(800);
|
||||
stage.setOnCloseRequest(e -> closeAll());
|
||||
stage.setX(visualBounds.getMinX());
|
||||
stage.setY(visualBounds.getMinY());
|
||||
stage.setWidth(visualBounds.getWidth());
|
||||
stage.setHeight(visualBounds.getHeight());
|
||||
stage.setMaximized(true);
|
||||
stage.setFullScreen(true);
|
||||
stage.setScene(scene);
|
||||
stage.show();
|
||||
} catch (Exception e) {
|
||||
|
||||
Reference in New Issue
Block a user