Merge pull request #110 from rubenpirreram/GUI-2.0

G UI 2.0
This commit is contained in:
rubenpirreram
2026-05-18 16:08:21 +02:00
committed by GitHub
10 changed files with 502 additions and 151 deletions
+172
View File
@@ -0,0 +1,172 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>it.polimi.ingsw</groupId>
<artifactId>GC14</artifactId>
<name>ing-sw-2026-pirrera-radice-pagani-pellegrino</name>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version>
<configuration>
<source>25</source>
<target>25</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.2.5</version>
</plugin>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.8</version>
<executions>
<execution>
<id>default-cli</id>
<configuration>
<mainClass>it.polimi.ingsw.gc14.HelloApplication</mainClass>
<launcher>app</launcher>
<jlinkZipName>app</jlinkZipName>
<jlinkImageName>app</jlinkImageName>
<noManPages>true</noManPages>
<stripDebug>true</stripDebug>
<noHeaderFiles>true</noHeaderFiles>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-shade-plugin</artifactId>
<version>3.5.2</version>
<executions>
<execution>
<id>server</id>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<finalName>Server</finalName>
<transformers>
<transformer>
<mainClass>it.polimi.ingsw.gc14.ServerLauncher</mainClass>
</transformer>
</transformers>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
<execution>
<id>client-tui</id>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<finalName>ClientTUI</finalName>
<transformers>
<transformer>
<mainClass>it.polimi.ingsw.gc14.ClientLauncherTUI</mainClass>
</transformer>
</transformers>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
<execution>
<id>client-gui</id>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<finalName>ClientGUI</finalName>
<transformers>
<transformer>
<mainClass>it.polimi.ingsw.gc14.ClientLauncherGUI</mainClass>
</transformer>
</transformers>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.12.1</version>
<scope>test</scope>
<exclusions>
<exclusion>
<artifactId>opentest4j</artifactId>
<groupId>org.opentest4j</groupId>
</exclusion>
<exclusion>
<artifactId>junit-platform-commons</artifactId>
<groupId>org.junit.platform</groupId>
</exclusion>
<exclusion>
<artifactId>apiguardian-api</artifactId>
<groupId>org.apiguardian</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.12.1</version>
<scope>test</scope>
<exclusions>
<exclusion>
<artifactId>junit-platform-engine</artifactId>
<groupId>org.junit.platform</groupId>
</exclusion>
<exclusion>
<artifactId>apiguardian-api</artifactId>
<groupId>org.apiguardian</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<junit.version>5.12.1</junit.version>
</properties>
</project>
+83
View File
@@ -91,6 +91,89 @@
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.5.2</version>
<executions>
<!-- SERVER -->
<execution>
<id>server</id>
<phase>package</phase>
<goals><goal>shade</goal></goals>
<configuration>
<finalName>Server</finalName>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>it.polimi.ingsw.gc14.ServerLauncher</mainClass>
</transformer>
</transformers>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
<!-- CLIENT TUI -->
<execution>
<id>client-tui</id>
<phase>package</phase>
<goals><goal>shade</goal></goals>
<configuration>
<finalName>ClientTUI</finalName>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>it.polimi.ingsw.gc14.ClientLauncherTUI</mainClass>
</transformer>
</transformers>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
<!-- CLIENT GUI -->
<execution>
<id>client-gui</id>
<phase>package</phase>
<goals><goal>shade</goal></goals>
<configuration>
<finalName>ClientGUI</finalName>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>it.polimi.ingsw.gc14.ClientLauncherGUI</mainClass>
</transformer>
</transformers>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>
</plugins> </plugins>
</build> </build>
</project> </project>
@@ -2,23 +2,23 @@ package it.polimi.ingsw.gc14;
import it.polimi.ingsw.gc14.Controller.ClientController; import it.polimi.ingsw.gc14.Controller.ClientController;
import it.polimi.ingsw.gc14.View.GUI.GUI; import it.polimi.ingsw.gc14.View.GUI.GUI;
import it.polimi.ingsw.gc14.View.IView;
import javafx.application.Application; import javafx.application.Application;
import javafx.stage.Stage; import javafx.stage.Stage;
import static javafx.application.Application.launch; public class ClientLauncherGUI {
public class ClientLauncherGUI extends Application {
@Override
public void start(Stage stage) throws Exception {
GUI view = new GUI(stage);
ClientController controller = new ClientController(view);
view.setController(controller);
view.start(stage);
}
public static void main(String[] args) { public static void main(String[] args) {
launch(); System.setProperty("glass.win.uiScale", "1.0");
Application.launch(GUIApp.class, args);
}
public static class GUIApp extends Application {
@Override
public void start(Stage stage) throws Exception {
GUI view = new GUI(stage);
ClientController controller = new ClientController(view);
view.setController(controller);
view.start(stage);
}
} }
} }
@@ -161,18 +161,14 @@ public class TCPClient implements IClient {
if (event.getIsError()) { if (event.getIsError()) {
controller.view.showError(event.toString()); controller.view.showError(event.toString());
} else { } else {
synchronized (controller) { controller.view.applyAndRender(event);
event.apply(controller.miniModel);
}
controller.view.render();
} }
} else if (read instanceof MiniModel model) { } else if (read instanceof MiniModel model) {
synchronized (controller) { synchronized (controller) {
controller.setModel(model); controller.setModel(model);
controller.view.render();
} }
controller.view.render();
} }
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
@@ -75,6 +75,9 @@ public class GUI extends Application implements IView {
showLogin(); showLogin();
stage.setTitle("Mesos"); stage.setTitle("Mesos");
primaryStage.setMaximized(true);
primaryStage.setMinWidth(800);
primaryStage.setMinHeight(600);
primaryStage.show(); primaryStage.show();
} }
@@ -96,14 +99,17 @@ public class GUI extends Application implements IView {
Platform.runLater(() -> { Platform.runLater(() -> {
event.apply(miniModel); event.apply(miniModel);
if (controller.miniModel.currentState.getGameStage() == TOTEM_CHOICE) { if (controller.miniModel.currentState.getGameStage() == TOTEM_CHOICE) {
primaryStage.setMaximized(true);
controllerTotem.render(); controllerTotem.render();
primaryStage.setScene(totemScene); primaryStage.setScene(totemScene);
} }
else if (controller.miniModel.currentState.getGameStage() == GameStages.ENDED) { else if (controller.miniModel.currentState.getGameStage() == GameStages.ENDED) {
primaryStage.setMaximized(true);
controllerLeaderboard.render(); controllerLeaderboard.render();
primaryStage.setScene(leaderboardScene); primaryStage.setScene(leaderboardScene);
primaryStage.setFullScreen(true);
}else { }else {
primaryStage.setMaximized(true);
controllerMain.render(event); controllerMain.render(event);
primaryStage.setScene(mainScene); primaryStage.setScene(mainScene);
} }
@@ -116,9 +122,11 @@ public class GUI extends Application implements IView {
return; return;
} }
if (controller.miniModel.currentState.getGameStage() == TOTEM_CHOICE) { if (controller.miniModel.currentState.getGameStage() == TOTEM_CHOICE) {
primaryStage.setMaximized(true);
controllerTotem.render(); controllerTotem.render();
primaryStage.setScene(totemScene); primaryStage.setScene(totemScene);
} else { } else {
primaryStage.setMaximized(true);
controllerMain.render(); controllerMain.render();
primaryStage.setScene(mainScene); primaryStage.setScene(mainScene);
} }
@@ -6,6 +6,7 @@ import javafx.animation.ScaleTransition;
import it.polimi.ingsw.gc14.Model.PlayableCard; import it.polimi.ingsw.gc14.Model.PlayableCard;
import javafx.event.Event; import javafx.event.Event;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.scene.control.ScrollPane;
import javafx.stage.Popup; import javafx.stage.Popup;
import javafx.geometry.Insets; import javafx.geometry.Insets;
import javafx.geometry.Pos; import javafx.geometry.Pos;
@@ -66,32 +67,34 @@ public class LeaderboardFXMLController {
public void render() { public void render() {
rankingList.getChildren().clear(); rankingList.getChildren().clear();
if(controller.miniModel.standingPlayers!=null)
{
List<Player> sorted = controller.miniModel.standingPlayers;
List<Player> sorted = controller.miniModel.standingPlayers; boolean iWon = sorted.get(0).getUserName().equals(controller.myUsername);
boolean iWon = sorted.get(0).getUserName().equals(controller.myUsername); // Label grande Winner / Game Over
Label outcomeLabel = new Label(iWon ? "\uD83C\uDFC6 WINNER! \uD83C\uDFC6" : "GAME OVER");
outcomeLabel.setStyle(
"-fx-font-size: 64px;" +
"-fx-font-weight: bold;" +
"-fx-text-fill: " + (iWon ? "#FFD700;" : "#FF4444;")
);
DropShadow glow = new DropShadow();
glow.setColor(iWon ? Color.rgb(255, 200, 0, 0.95) : Color.rgb(220, 0, 0, 0.95));
glow.setRadius(35);
glow.setSpread(0.35);
outcomeLabel.setEffect(glow);
rankingList.getChildren().add(outcomeLabel);
// Label grande Winner / Game Over // Separatore
Label outcomeLabel = new Label(iWon ? "\uD83C\uDFC6 WINNER! \uD83C\uDFC6" : "GAME OVER"); Region sep = new Region();
outcomeLabel.setStyle( sep.setPrefHeight(16);
"-fx-font-size: 64px;" + rankingList.getChildren().add(sep);
"-fx-font-weight: bold;" +
"-fx-text-fill: " + (iWon ? "#FFD700;" : "#FF4444;")
);
DropShadow glow = new DropShadow();
glow.setColor(iWon ? Color.rgb(255, 200, 0, 0.95) : Color.rgb(220, 0, 0, 0.95));
glow.setRadius(35);
glow.setSpread(0.35);
outcomeLabel.setEffect(glow);
rankingList.getChildren().add(outcomeLabel);
// Separatore for (int i = 0; i < sorted.size(); i++) {
Region sep = new Region(); rankingList.getChildren().add(createPlayerRow(i + 1, sorted.get(i)));
sep.setPrefHeight(16); }
rankingList.getChildren().add(sep);
for (int i = 0; i < sorted.size(); i++) {
rankingList.getChildren().add(createPlayerRow(i + 1, sorted.get(i)));
} }
} }
@@ -289,11 +292,8 @@ public class LeaderboardFXMLController {
// Carte piccole in riga // Carte piccole in riga
for (PlayableCard card : cards) { for (PlayableCard card : cards) {
ImageView img = new ImageView(loadImage("/GUIImages/Fronts/card-" + card.getIdIMG() + ".png")); ImageView img = new ImageView(loadImage("/GUIImages/Fronts/card-" + card.getIdIMG() + ".png"));
img.setFitHeight(160); img.setFitHeight(230);
img.setPreserveRatio(true); img.setPreserveRatio(true);
// Tooltip al hover: mostra la carta grande in un secondo popup
img.addEventHandler(MouseEvent.MOUSE_ENTERED, e -> img.setFitHeight(180));
img.addEventHandler(MouseEvent.MOUSE_EXITED, e -> img.setFitHeight(160));
img.setCursor(Cursor.HAND); img.setCursor(Cursor.HAND);
row.getChildren().add(img); row.getChildren().add(img);
} }
@@ -307,11 +307,16 @@ public class LeaderboardFXMLController {
grid.getChildren().add(empty); grid.getChildren().add(empty);
} }
grid.setMaxHeight(460); ScrollPane scrollPane = new ScrollPane(grid);
grid.setMaxWidth(680); scrollPane.setFitToWidth(true);
popupContent.getChildren().add(grid); scrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
scrollPane.setVbarPolicy(ScrollPane.ScrollBarPolicy.AS_NEEDED);
scrollPane.setStyle("-fx-background: transparent; -fx-background-color: transparent;");
// altezza massima = 80% della finestra
Window window = rootPane.getScene().getWindow(); Window window = rootPane.getScene().getWindow();
scrollPane.setMaxHeight(window.getHeight() * 0.8);
popupContent.getChildren().add(scrollPane);
popup.show(window, 0, 0); popup.show(window, 0, 0);
popup.getScene().setFill(Color.TRANSPARENT); popup.getScene().setFill(Color.TRANSPARENT);
popup.setX(window.getX() + (window.getWidth() - popup.getWidth()) / 2); popup.setX(window.getX() + (window.getWidth() - popup.getWidth()) / 2);
@@ -7,7 +7,10 @@ import it.polimi.ingsw.gc14.Model.Cards.TribeCard;
import it.polimi.ingsw.gc14.Model.Orders.OrderPlayer; import it.polimi.ingsw.gc14.Model.Orders.OrderPlayer;
import it.polimi.ingsw.gc14.Network.EventType; import it.polimi.ingsw.gc14.Network.EventType;
import it.polimi.ingsw.gc14.Network.NetworkEvent; import it.polimi.ingsw.gc14.Network.NetworkEvent;
import javafx.animation.AnimationTimer;
import javafx.animation.PauseTransition;
import javafx.animation.ScaleTransition; import javafx.animation.ScaleTransition;
import javafx.application.Platform;
import javafx.event.Event; import javafx.event.Event;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.geometry.Insets; import javafx.geometry.Insets;
@@ -24,6 +27,7 @@ import javafx.scene.paint.Color;
import javafx.scene.shape.*; import javafx.scene.shape.*;
import javafx.scene.text.Font; import javafx.scene.text.Font;
import javafx.stage.Popup; import javafx.stage.Popup;
import javafx.stage.Stage;
import javafx.stage.Window; import javafx.stage.Window;
import javafx.util.Duration; import javafx.util.Duration;
@@ -67,11 +71,8 @@ public class MainFXMLController {
mainHBox.sceneProperty().addListener((obs, oldScene, newScene) -> { mainHBox.sceneProperty().addListener((obs, oldScene, newScene) -> {
if (newScene != null) { if (newScene != null) {
newScene.getRoot().applyCss(); newScene.getRoot().applyCss();
// chiudi popup cliccando fuori da esso
newScene.addEventFilter(MouseEvent.MOUSE_PRESSED, e -> { newScene.addEventFilter(MouseEvent.MOUSE_PRESSED, e -> {
if (popup.isShowing()) { if (popup.isShowing()) popup.hide();
popup.hide();
}
}); });
} }
}); });
@@ -107,13 +108,15 @@ public class MainFXMLController {
// ==== EFFECTS ==== // ==== EFFECTS ====
private void addClip(Node node) { private void addClip(ImageView img) {
Rectangle clip = new Rectangle(); Rectangle clip = new Rectangle();
clip.setWidth(node.getBoundsInLocal().getWidth());
clip.setHeight(node.getBoundsInLocal().getHeight());
clip.setArcWidth(20); clip.setArcWidth(20);
clip.setArcHeight(20); clip.setArcHeight(20);
node.setClip(clip); clip.heightProperty().bind(img.fitHeightProperty());
clip.widthProperty().bind(img.fitHeightProperty().multiply(
img.getImage().getWidth() / img.getImage().getHeight()
));
img.setClip(clip);
} }
private void addHoverZoom(Node node) { private void addHoverZoom(Node node) {
@@ -152,7 +155,7 @@ public class MainFXMLController {
// ==== ELEMENTS ==== // ==== ELEMENTS ====
private StackPane createOrder(String num) { private StackPane createOrder(String num) {
ImageView img = new ImageView(loadImage("/GUIImages/Orders/order-" + num + ".png")); ImageView img = new ImageView(loadImage("/GUIImages/Orders/order-" + num + ".png"));
img.setFitHeight(240); img.fitHeightProperty().bind(board.heightProperty().add(-15));
img.setPreserveRatio(true); img.setPreserveRatio(true);
addClip(img); addClip(img);
return new StackPane(img); return new StackPane(img);
@@ -160,18 +163,18 @@ public class MainFXMLController {
private StackPane createSlot(Slot slot, boolean withZoom, boolean withShadow) { private StackPane createSlot(Slot slot, boolean withZoom, boolean withShadow) {
ImageView img = new ImageView(loadImage("/GUIImages/Fronts/card-" + slot.getSlotId() + ".png")); ImageView img = new ImageView(loadImage("/GUIImages/Fronts/card-" + slot.getSlotId() + ".png"));
img.setFitHeight(240);
img.setPreserveRatio(true); img.setPreserveRatio(true);
img.fitHeightProperty().bind(board.heightProperty().add(-15));
addClip(img); addClip(img);
StackPane wrapper = new StackPane(img); StackPane wrapper = new StackPane(img);
Player player = controller.miniModel.slotPlayerMap.get(slot); Player player = controller.miniModel.slotPlayerMap.get(slot);
if (player != null && controller.miniModel.getPositionByUsername(player.getUserName()) != -1) { if (player != null && controller.miniModel.getPositionByUsername(player.getUserName()) != -1) {
ImageView totem = new ImageView(loadImage("/GUIImages/Totems/totem_" + player.totem.toString().toLowerCase(Locale.ROOT) + ".png")); ImageView totem = new ImageView(loadImage("/GUIImages/Totems/totem_" + player.totem.toString().toLowerCase(Locale.ROOT) + ".png"));
totem.setFitHeight(70); totem.setFitHeight(68);
totem.setPreserveRatio(true); totem.setPreserveRatio(true);
StackPane.setAlignment(totem, Pos.TOP_LEFT); StackPane.setAlignment(totem, Pos.TOP_LEFT);
StackPane.setMargin(totem, new Insets(8, 0, 0, 57)); StackPane.setMargin(totem, new Insets(0, 0, 0, 46));
wrapper.getChildren().add(totem); wrapper.getChildren().add(totem);
} }
@@ -180,13 +183,12 @@ public class MainFXMLController {
return wrapper; return wrapper;
} }
private StackPane createCard(PlayableCard card, boolean withZoom, boolean withShadow) { private StackPane createCard(PlayableCard card, boolean withZoom, boolean withShadow, Region parent) {
ImageView img = new ImageView(loadImage("/GUIImages/Fronts/card-" + card.getIdIMG() + ".png")); ImageView img = new ImageView(loadImage("/GUIImages/Fronts/card-" + card.getIdIMG() + ".png"));
img.setFitHeight(200);
img.setPreserveRatio(true); img.setPreserveRatio(true);
img.fitHeightProperty().bind(parent.heightProperty().multiply(0.85));
addClip(img); addClip(img);
StackPane wrapper = new StackPane(img); StackPane wrapper = new StackPane(img);
if (withShadow) addShadow(wrapper); if (withShadow) addShadow(wrapper);
if (withZoom) addHoverZoom(wrapper); if (withZoom) addHoverZoom(wrapper);
return wrapper; return wrapper;
@@ -236,6 +238,7 @@ public class MainFXMLController {
case "builders" -> new ArrayList<>(p.builders); case "builders" -> new ArrayList<>(p.builders);
case "shamans" -> new ArrayList<>(p.shamans); case "shamans" -> new ArrayList<>(p.shamans);
case "hunters" -> new ArrayList<>(p.hunters); case "hunters" -> new ArrayList<>(p.hunters);
case "building" -> new ArrayList<>(p.buildingCards);
default -> new ArrayList<>(); default -> new ArrayList<>();
}; };
} }
@@ -250,7 +253,7 @@ public class MainFXMLController {
int i = 0; int i = 0;
for (TribeCard card : controller.miniModel.board.upperListTribe) { for (TribeCard card : controller.miniModel.board.upperListTribe) {
final int index = i; final int index = i;
StackPane img = createCard(card, true, true); StackPane img = createCard(card, true, true, upperList);
img.setOnMouseClicked(e -> controller.drawUpperTribeCard(controller.myUsername, index)); img.setOnMouseClicked(e -> controller.drawUpperTribeCard(controller.myUsername, index));
upperList.getChildren().add(img); upperList.getChildren().add(img);
i++; i++;
@@ -266,7 +269,7 @@ public class MainFXMLController {
int i = 0; int i = 0;
for (TribeCard card : controller.miniModel.board.lowerListTribe) { for (TribeCard card : controller.miniModel.board.lowerListTribe) {
final int index = i; final int index = i;
StackPane img = createCard(card, true, true); StackPane img = createCard(card, true, true, lowerList);
img.setOnMouseClicked(e -> controller.drawLowerTribeCard(controller.myUsername, index)); img.setOnMouseClicked(e -> controller.drawLowerTribeCard(controller.myUsername, index));
lowerList.getChildren().add(img); lowerList.getChildren().add(img);
i++; i++;
@@ -277,7 +280,7 @@ public class MainFXMLController {
private void drawUpperBuilding() { private void drawUpperBuilding() {
ArrayList<BuildingCard> cardList = new ArrayList<>(controller.miniModel.board.upperListBuilding); ArrayList<BuildingCard> cardList = new ArrayList<>(controller.miniModel.board.upperListBuilding);
if (!cardList.isEmpty()) { if (!cardList.isEmpty()) {
StackPane img = createCard(cardList.getLast(), true, true); StackPane img = createCard(cardList.getLast(), true, true, upperList);
Label label = new Label(String.valueOf(cardList.size())); Label label = new Label(String.valueOf(cardList.size()));
label.setTranslateY(-55); label.setTranslateY(-55);
label.setTranslateX(10); label.setTranslateX(10);
@@ -292,7 +295,7 @@ public class MainFXMLController {
private void drawLowerBuilding() { private void drawLowerBuilding() {
ArrayList<BuildingCard> cardList = new ArrayList<>(controller.miniModel.board.lowerListBuilding); ArrayList<BuildingCard> cardList = new ArrayList<>(controller.miniModel.board.lowerListBuilding);
if (!cardList.isEmpty()) { if (!cardList.isEmpty()) {
StackPane img = createCard(cardList.getLast(), true, true); StackPane img = createCard(cardList.getLast(), true, true, lowerList);
Label label = new Label(String.valueOf(cardList.size())); Label label = new Label(String.valueOf(cardList.size()));
label.setTranslateY(-55); label.setTranslateY(-55);
label.setTranslateX(10); label.setTranslateX(10);
@@ -304,23 +307,22 @@ public class MainFXMLController {
} }
} }
private void drawMyHandList(ArrayList<? extends PlayableCard> cardList) { private void drawMyHandList(ArrayList<? extends PlayableCard> cardList, HBox parent) {
if (!cardList.isEmpty()) { if (!cardList.isEmpty()) {
StackPane img = createCard(cardList.getLast(), true, true); StackPane img = createCard(cardList.getLast(), true, true, parent);
Label label = new Label(String.valueOf(cardList.size())); Label label = new Label(String.valueOf(cardList.size()));
label.setTranslateY(-55); label.setTranslateY(-55);
label.setTranslateX(10); label.setTranslateX(10);
label.getStyleClass().add("label-large"); label.getStyleClass().add("label-large");
StackPane.setAlignment(label, Pos.TOP_RIGHT); StackPane.setAlignment(label, Pos.TOP_RIGHT);
img.getChildren().add(label);
img.setOnMouseClicked(e -> openPopup(new ArrayList<>(cardList))); img.setOnMouseClicked(e -> openPopup(new ArrayList<>(cardList)));
myHand.getChildren().add(img); parent.getChildren().add(img);
} else { } else {
Region placeholder = new Region(); Region placeholder = new Region();
placeholder.setPrefHeight(200); placeholder.prefHeightProperty().bind(parent.heightProperty().multiply(0.85));
placeholder.setPrefWidth(200 * 0.675); placeholder.prefWidthProperty().bind(placeholder.prefHeightProperty().multiply(0.675));
placeholder.setStyle("-fx-background-color: transparent;"); placeholder.setStyle("-fx-background-color: transparent;");
myHand.getChildren().add(placeholder); parent.getChildren().add(placeholder);
} }
} }
@@ -345,7 +347,7 @@ public class MainFXMLController {
} }
headerRow.getChildren().addAll(totem, usernameLabel); headerRow.getChildren().addAll(totem, usernameLabel);
// Riga 2: cibo + prestigio // Riga 2: cibo + prestigio + building
HBox statsRow = new HBox(10); HBox statsRow = new HBox(10);
statsRow.setAlignment(Pos.CENTER); statsRow.setAlignment(Pos.CENTER);
@@ -367,13 +369,31 @@ public class MainFXMLController {
prestigeLabel.getStyleClass().add("label-small"); prestigeLabel.getStyleClass().add("label-small");
prestigeBox.getChildren().addAll(PPIcon, prestigeLabel); prestigeBox.getChildren().addAll(PPIcon, prestigeLabel);
statsRow.getChildren().addAll(foodBox, prestigeBox); ImageView icon = new ImageView();
icon.setFitWidth(28);
icon.setFitHeight(28);
icon.setPreserveRatio(true);
icon.setImage(loadImage("/GUIImages/Icons/Building.png"));
ArrayList<PlayableCard> cards = getPlayerCards(player.getUserName(), "building");
if (cards.isEmpty()) {
ColorAdjust grayscale = new ColorAdjust();
icon.setEffect(grayscale);
icon.setOpacity(0.3);
} else {
icon.setOnMouseClicked(e -> openPopup(new ArrayList<>(cards)));
addHoverZoom(icon);
}
statsRow.getChildren().addAll(foodBox, prestigeBox,icon);
// Righe 3-4: icone carte // Righe 3-4: icone carte
HBox iconsRow1 = new HBox(6); HBox iconsRow1 = new HBox(6);
iconsRow1.setSpacing(20);
iconsRow1.setAlignment(Pos.CENTER); iconsRow1.setAlignment(Pos.CENTER);
HBox iconsRow2 = new HBox(6); HBox iconsRow2 = new HBox(6);
iconsRow2.setAlignment(Pos.CENTER); iconsRow2.setAlignment(Pos.CENTER);
iconsRow2.setSpacing(20);
renderIcons(iconsRow1, iconsRow2, player); renderIcons(iconsRow1, iconsRow2, player);
card.getChildren().addAll(headerRow, statsRow, iconsRow1, iconsRow2); card.getChildren().addAll(headerRow, statsRow, iconsRow1, iconsRow2);
@@ -413,7 +433,7 @@ public class MainFXMLController {
default -> "/GUIImages/Backs/back-001.png"; default -> "/GUIImages/Backs/back-001.png";
}; };
ImageView back = new ImageView(loadImage(path)); ImageView back = new ImageView(loadImage(path));
back.setFitHeight(240); back.fitHeightProperty().bind(board.heightProperty().add(-15));
back.setPreserveRatio(true); back.setPreserveRatio(true);
addClip(back); addClip(back);
addShadow(back); addShadow(back);
@@ -427,7 +447,7 @@ public class MainFXMLController {
VBox overlay = new VBox(-20); VBox overlay = new VBox(-20);
overlay.setPickOnBounds(false); overlay.setPickOnBounds(false);
StackPane.setAlignment(overlay, Pos.TOP_LEFT); StackPane.setAlignment(overlay, Pos.TOP_LEFT);
StackPane.setMargin(overlay, new Insets(9, 0, 0, 57)); StackPane.setMargin(overlay, new Insets(9, 0, 0, 46));
for (OrderPlayer player : controller.miniModel.orderLogicCard.playerList) { for (OrderPlayer player : controller.miniModel.orderLogicCard.playerList) {
ImageView totem = new ImageView(loadImage("/GUIImages/Totems/totem_" + player.player.totem.toString().toLowerCase(Locale.ROOT) + ".png")); ImageView totem = new ImageView(loadImage("/GUIImages/Totems/totem_" + player.player.totem.toString().toLowerCase(Locale.ROOT) + ".png"));
@@ -460,13 +480,13 @@ public class MainFXMLController {
myHand.setAlignment(Pos.CENTER); myHand.setAlignment(Pos.CENTER);
Player me = controller.miniModel.players.get(controller.myUsername); Player me = controller.miniModel.players.get(controller.myUsername);
drawMyHandList(me.artists); drawMyHandList(me.artists,myHand);
drawMyHandList(me.gatherers); drawMyHandList(me.gatherers,myHand);
drawMyHandList(me.inventors); drawMyHandList(me.inventors,myHand);
drawMyHandList(me.builders); drawMyHandList(me.builders,myHand);
drawMyHandList(me.shamans); drawMyHandList(me.shamans,myHand);
drawMyHandList(me.hunters); drawMyHandList(me.hunters,myHand);
drawMyHandList(me.buildingCards); drawMyHandList(me.buildingCards,myHand);
} }
private void renderSidePanel() { private void renderSidePanel() {
@@ -479,6 +499,25 @@ public class MainFXMLController {
VBox.setMargin(info, new Insets(5, 5, 5, 5)); VBox.setMargin(info, new Insets(5, 5, 5, 5));
sidePanel.getChildren().add(info); sidePanel.getChildren().add(info);
// ===== NUOVO: bottoni Skip Turn e Dettagli =====
HBox buttonRow = new HBox(8);
buttonRow.setAlignment(Pos.CENTER);
VBox.setMargin(buttonRow, new Insets(0, 5, 5, 5));
javafx.scene.control.Button skipBtn = new javafx.scene.control.Button("Skip Turn");
skipBtn.getStyleClass().add("action-button");
skipBtn.setOnAction(e -> controller.skipTurn(controller.myUsername));
addHoverZoom(skipBtn);
javafx.scene.control.Button detailsBtn = new javafx.scene.control.Button("Ending Details");
detailsBtn.getStyleClass().add("action-button");
detailsBtn.setOnAction(e -> openDetailsPopup());
addHoverZoom(detailsBtn);
buttonRow.getChildren().addAll(skipBtn, detailsBtn);
sidePanel.getChildren().add(buttonRow);
// ================================================
for (Player player : controller.miniModel.players.values()) { for (Player player : controller.miniModel.players.values()) {
renderPlayer(player); renderPlayer(player);
} }
@@ -521,7 +560,7 @@ public class MainFXMLController {
private void openPopup(ArrayList<? extends PlayableCard> cardList) { private void openPopup(ArrayList<? extends PlayableCard> cardList) {
popupCards.getChildren().clear(); popupCards.getChildren().clear();
for (PlayableCard card : cardList) { for (PlayableCard card : cardList) {
popupCards.getChildren().add(createCard(card, false, false)); popupCards.getChildren().add(createCardPopup(card, false, false));
} }
showPopup(); showPopup();
} }
@@ -531,7 +570,7 @@ public class MainFXMLController {
popupCards.getChildren().clear(); popupCards.getChildren().clear();
for (int i = 0; i < cardList.size(); i++) { for (int i = 0; i < cardList.size(); i++) {
final int index = i; final int index = i;
StackPane img = createCard(cardList.get(i), true, false); StackPane img = createCardPopup(cardList.get(i), true, false);
img.setOnMouseClicked(e -> { img.setOnMouseClicked(e -> {
popup.hide(); popup.hide();
controller.drawUpperBuildingCard(controller.myUsername, index); controller.drawUpperBuildingCard(controller.myUsername, index);
@@ -546,7 +585,7 @@ public class MainFXMLController {
popupCards.getChildren().clear(); popupCards.getChildren().clear();
for (int i = 0; i < cardList.size(); i++) { for (int i = 0; i < cardList.size(); i++) {
final int index = i; final int index = i;
StackPane img = createCard(cardList.get(i), true, false); StackPane img = createCardPopup(cardList.get(i), true, false);
img.setOnMouseClicked(e -> { img.setOnMouseClicked(e -> {
popup.hide(); popup.hide();
controller.drawLowerBuildingCard(controller.myUsername, index); controller.drawLowerBuildingCard(controller.myUsername, index);
@@ -555,4 +594,25 @@ public class MainFXMLController {
} }
showPopup(); showPopup();
} }
private void openDetailsPopup() {
popupCards.getChildren().clear();
ImageView img = new ImageView(loadImage("/GUIImages/Backs/back-118.png"));
img.setFitHeight(290);
img.setPreserveRatio(true);
addClip(img);
StackPane wrapper = new StackPane(img);
addShadow(wrapper);
popupCards.getChildren().add(wrapper);
showPopup();
}
private StackPane createCardPopup(PlayableCard card, boolean withZoom, boolean withShadow) {
ImageView img = new ImageView(loadImage("/GUIImages/Fronts/card-" + card.getIdIMG() + ".png"));
img.setFitHeight(200);
img.setPreserveRatio(true);
addClip(img);
StackPane wrapper = new StackPane(img);
if (withShadow) addShadow(wrapper);
if (withZoom) addHoverZoom(wrapper);
return wrapper;
}
} }
+67 -54
View File
@@ -3,6 +3,7 @@
<?import javafx.scene.control.Label?> <?import javafx.scene.control.Label?>
<?import javafx.scene.layout.HBox?> <?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.VBox?> <?import javafx.scene.layout.VBox?>
<?import javafx.scene.control.ScrollPane?>
<HBox fx:id="mainHBox" <HBox fx:id="mainHBox"
maxHeight="Infinity" maxWidth="Infinity" maxHeight="Infinity" maxWidth="Infinity"
prefHeight="1080.0" prefWidth="1920.0" prefHeight="1080.0" prefWidth="1920.0"
@@ -22,64 +23,76 @@
<Insets top="5" right="5" bottom="5" left="5" /> <Insets top="5" right="5" bottom="5" left="5" />
</HBox.margin> </HBox.margin>
<children> <children>
<HBox fx:id="upperList" prefHeight="220" minHeight="220" maxHeight="220" styleClass="card-list"> <HBox fx:id="upperList" styleClass="card-list" VBox.vgrow="ALWAYS">
<VBox.margin> <VBox.margin>
<Insets top="5" right="5" bottom="5" left="5" /> <Insets top="5" right="5" bottom="5" left="5" />
</VBox.margin> </VBox.margin>
</HBox> </HBox>
<HBox fx:id="board" prefHeight="255" minHeight="255" maxHeight="255" styleClass="card-list">
<VBox.margin> <HBox fx:id="board" prefHeight="220" minHeight="220" maxHeight="220" styleClass="card-list" VBox.vgrow="NEVER">
<Insets top="5" right="5" bottom="5" left="5" /> <VBox.margin>
</VBox.margin> <Insets top="5" right="5" bottom="5" left="5" />
</HBox> </VBox.margin>
<HBox fx:id="lowerList" prefHeight="220" minHeight="220" maxHeight="220" styleClass="card-list"> </HBox>
<VBox.margin>
<Insets top="5" right="5" bottom="5" left="5" /> <HBox fx:id="lowerList" styleClass="card-list" VBox.vgrow="ALWAYS">
</VBox.margin> <VBox.margin>
</HBox> <Insets top="5" right="5" bottom="5" left="5" />
<HBox fx:id="myHand" prefHeight="220" minHeight="220" maxHeight="220" styleClass="card-list"> </VBox.margin>
<VBox.margin> </HBox>
<Insets top="5" right="5" bottom="5" left="5" />
</VBox.margin> <HBox fx:id="myHand" styleClass="card-list" VBox.vgrow="ALWAYS">
</HBox> <VBox.margin>
<Insets top="5" right="5" bottom="5" left="5" />
</VBox.margin>
</HBox>
</children> </children>
</VBox> </VBox>
<!-- VBox destra: dimensione fissa, non si espande --> <!-- VBox destra: dimensione fissa, non si espande -->
<VBox fx:id="sidePanel" <VBox fx:id="sidePanel"
prefWidth="250.0" prefWidth="250.0"
maxWidth="250.0" maxWidth="250.0"
minWidth="250.0" minWidth="250.0"
HBox.hgrow="NEVER" HBox.hgrow="NEVER"
styleClass="side-panel"> styleClass="side-panel">
<HBox.margin> <HBox.margin>
<Insets bottom="10" left="10" right="10" top="10" /> <Insets bottom="10" left="10" right="10" top="10" />
</HBox.margin> </HBox.margin>
<children> <children>
<HBox fx:id="info" prefHeight="107.0" prefWidth="483.0" styleClass="frame"> <ScrollPane fitToWidth="true" hbarPolicy="NEVER" vbarPolicy="AS_NEEDED" VBox.vgrow="ALWAYS">
<children> <content>
<VBox alignment="CENTER" prefHeight="107.0" prefWidth="161.0" spacing="2"> <VBox spacing="10">
<children> <children>
<Label styleClass="label-medium" text="Era" /> <HBox fx:id="info" prefHeight="107.0" prefWidth="483.0" styleClass="frame">
<Label fx:id="era" styleClass="label-medium" text="VALORE" /> <children>
</children> <VBox alignment="CENTER" prefHeight="107.0" prefWidth="161.0" spacing="2">
</VBox> <children>
<VBox alignment="CENTER" prefHeight="107.0" prefWidth="161.0" spacing="2"> <Label styleClass="label-medium" text="Era" />
<children> <Label fx:id="era" styleClass="label-medium" text="VALORE" />
<Label styleClass="label-medium" text="Round" /> </children>
<Label fx:id="round" styleClass="label-medium" text="VALORE" /> </VBox>
</children> <VBox alignment="CENTER" prefHeight="107.0" prefWidth="161.0" spacing="2">
</VBox> <children>
<VBox alignment="CENTER" prefHeight="107.0" prefWidth="161.0" spacing="2"> <Label styleClass="label-medium" text="Round" />
<children> <Label fx:id="round" styleClass="label-medium" text="VALORE" />
<Label styleClass="label-medium" text="Player" /> </children>
<Label fx:id="player" styleClass="label-medium" text="VALORE" /> </VBox>
</children> <VBox alignment="CENTER" prefHeight="107.0" prefWidth="161.0" spacing="2">
</VBox> <children>
</children> <Label styleClass="label-medium" text="Player" />
</HBox> <Label fx:id="player" styleClass="label-medium" text="VALORE" />
</children> </children>
</VBox> </VBox>
</children>
</HBox>
<!-- altri elementi qui sotto -->
</children>
</VBox>
</content>
</ScrollPane>
</children>
</VBox>
</children> </children>
</HBox> </HBox>
+8 -8
View File
@@ -7,21 +7,21 @@
<StackPane xmlns="http://javafx.com/javafx" <StackPane xmlns="http://javafx.com/javafx"
xmlns:fx="http://javafx.com/fxml" xmlns:fx="http://javafx.com/fxml"
fx:controller="it.polimi.ingsw.gc14.View.GUI.LeaderboardFXMLController" fx:controller="it.polimi.ingsw.gc14.View.GUI.LeaderboardFXMLController"
fx:id="rootPane" fx:id="rootPane">
prefWidth="1280"
prefHeight="720">
<!-- Overlay scuro semitrasparente sopra il background -->
<Region style="-fx-background-color: rgba(0,0,0,0.45);"/> <Region style="-fx-background-color: rgba(0,0,0,0.45);"/>
<!-- Contenuto centrato -->
<VBox fx:id="mainVBox" alignment="CENTER" spacing="32"> <VBox fx:id="mainVBox" alignment="CENTER" spacing="32">
<padding><Insets top="50" right="120" bottom="50" left="120"/></padding> <padding><Insets top="50" right="120" bottom="50" left="120"/></padding>
<!-- Lista giocatori (Winner/GameOver label aggiunta da render()) --> <ScrollPane fitToWidth="true"
<VBox fx:id="rankingList" alignment="CENTER" spacing="16"/> hbarPolicy="NEVER"
vbarPolicy="AS_NEEDED"
style="-fx-background: transparent; -fx-background-color: transparent;"
VBox.vgrow="ALWAYS">
<VBox fx:id="rankingList" alignment="CENTER" spacing="16"/>
</ScrollPane>
<!-- Bottone nuova partita -->
<Button fx:id="newGameButton" text="NUOVA PARTITA" <Button fx:id="newGameButton" text="NUOVA PARTITA"
styleClass="action-button" styleClass="action-button"
onAction="#onNewGame"/> onAction="#onNewGame"/>
+14
View File
@@ -47,4 +47,18 @@
-fx-background-insets: 0, 5, 10, 15; -fx-background-insets: 0, 5, 10, 15;
-fx-background-radius: 15, 12, 8, 4; -fx-background-radius: 15, 12, 8, 4;
-fx-padding: 15 15 15 15; -fx-padding: 15 15 15 15;
}
.action-button {
-fx-background-color: #9d0208;
-fx-text-fill: white;
-fx-font-family: "Inknut Antiqua";
-fx-font-size: 11px;
-fx-background-radius: 8;
-fx-border-radius: 8;
-fx-padding: 4 10 4 10;
-fx-cursor: hand;
}
.action-button:hover {
-fx-background-color: #b42224;
} }