Fixed: temp

This commit is contained in:
rubenpirreram
2026-05-18 17:35:13 +02:00
parent 07e7028ac9
commit 99523beb05
2 changed files with 24 additions and 9 deletions
@@ -7,11 +7,15 @@ import it.polimi.ingsw.gc14.Network.NetworkEvent;
import it.polimi.ingsw.gc14.View.GUI.LoginFXMLController;
import it.polimi.ingsw.gc14.View.GUI.MainFXMLController;
import it.polimi.ingsw.gc14.View.IView;
import javafx.animation.PauseTransition;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.stage.Stage;
import javafx.util.Duration;
import java.io.IOException;
@@ -99,36 +103,35 @@ public class GUI extends Application implements IView {
Platform.runLater(() -> {
event.apply(miniModel);
if (controller.miniModel.currentState.getGameStage() == TOTEM_CHOICE) {
primaryStage.setMaximized(true);
controllerTotem.render();
primaryStage.setScene(totemScene);
primaryStage.setMaximized(true);
}
else if (controller.miniModel.currentState.getGameStage() == GameStages.ENDED) {
primaryStage.setMaximized(true);
controllerLeaderboard.render();
primaryStage.setScene(leaderboardScene);
}else {
primaryStage.setMaximized(true);
} else {
controllerMain.render(event);
primaryStage.setScene(mainScene);
primaryStage.setMaximized(true);
}
});
}
public void render() {
if (!Platform.isFxApplicationThread()) {
Platform.runLater(this::render);
return;
}
if (controller.miniModel.currentState.getGameStage() == TOTEM_CHOICE) {
primaryStage.setMaximized(true);
controllerTotem.render();
primaryStage.setScene(totemScene);
} else {
primaryStage.setMaximized(true);
} else {
controllerMain.render();
primaryStage.setScene(mainScene);
primaryStage.setMaximized(true);
}
}
@@ -11,8 +11,11 @@ import javafx.animation.AnimationTimer;
import javafx.animation.PauseTransition;
import javafx.animation.ScaleTransition;
import javafx.application.Platform;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.event.Event;
import javafx.fxml.FXML;
import javafx.geometry.Bounds;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Cursor;
@@ -76,6 +79,15 @@ public class MainFXMLController {
});
}
});
mainHBox.layoutBoundsProperty().addListener(new ChangeListener<Bounds>() {
@Override
public void changed(ObservableValue<? extends Bounds> obs, Bounds ov, Bounds nv) {
if (nv.getWidth() > 0 && nv.getHeight() > 0 && controller != null) {
mainHBox.layoutBoundsProperty().removeListener(this);
render();
}
}
});
initPopup();
renderBackground();
}
@@ -311,10 +323,10 @@ public class MainFXMLController {
if (!cardList.isEmpty()) {
StackPane img = createCard(cardList.getLast(), true, true, parent);
Label label = new Label(String.valueOf(cardList.size()));
label.setTranslateY(-55);
label.setTranslateX(10);
label.getStyleClass().add("label-large");
StackPane.setAlignment(label, Pos.TOP_RIGHT);
StackPane.setMargin(label, new Insets(8, 8, 0, 0));
img.getChildren().add(label);
img.setOnMouseClicked(e -> openPopup(new ArrayList<>(cardList)));
parent.getChildren().add(img);
} else {