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>
</executions>
</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>
</build>
</project>
@@ -2,23 +2,23 @@ package it.polimi.ingsw.gc14;
import it.polimi.ingsw.gc14.Controller.ClientController;
import it.polimi.ingsw.gc14.View.GUI.GUI;
import it.polimi.ingsw.gc14.View.IView;
import javafx.application.Application;
import javafx.stage.Stage;
import static javafx.application.Application.launch;
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 class ClientLauncherGUI {
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()) {
controller.view.showError(event.toString());
} else {
synchronized (controller) {
event.apply(controller.miniModel);
}
controller.view.render();
controller.view.applyAndRender(event);
}
} else if (read instanceof MiniModel model) {
synchronized (controller) {
controller.setModel(model);
controller.view.render();
}
controller.view.render();
}
} catch (ClassNotFoundException e) {
@@ -75,6 +75,9 @@ public class GUI extends Application implements IView {
showLogin();
stage.setTitle("Mesos");
primaryStage.setMaximized(true);
primaryStage.setMinWidth(800);
primaryStage.setMinHeight(600);
primaryStage.show();
}
@@ -96,14 +99,17 @@ 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);
}
else if (controller.miniModel.currentState.getGameStage() == GameStages.ENDED) {
primaryStage.setMaximized(true);
controllerLeaderboard.render();
primaryStage.setScene(leaderboardScene);
primaryStage.setFullScreen(true);
}else {
primaryStage.setMaximized(true);
controllerMain.render(event);
primaryStage.setScene(mainScene);
}
@@ -116,9 +122,11 @@ public class GUI extends Application implements IView {
return;
}
if (controller.miniModel.currentState.getGameStage() == TOTEM_CHOICE) {
primaryStage.setMaximized(true);
controllerTotem.render();
primaryStage.setScene(totemScene);
} else {
primaryStage.setMaximized(true);
controllerMain.render();
primaryStage.setScene(mainScene);
}
@@ -6,6 +6,7 @@ import javafx.animation.ScaleTransition;
import it.polimi.ingsw.gc14.Model.PlayableCard;
import javafx.event.Event;
import javafx.fxml.FXML;
import javafx.scene.control.ScrollPane;
import javafx.stage.Popup;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
@@ -66,32 +67,34 @@ public class LeaderboardFXMLController {
public void render() {
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
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);
// Separatore
Region sep = new Region();
sep.setPrefHeight(16);
rankingList.getChildren().add(sep);
// Separatore
Region sep = new Region();
sep.setPrefHeight(16);
rankingList.getChildren().add(sep);
for (int i = 0; i < sorted.size(); i++) {
rankingList.getChildren().add(createPlayerRow(i + 1, sorted.get(i)));
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
for (PlayableCard card : cards) {
ImageView img = new ImageView(loadImage("/GUIImages/Fronts/card-" + card.getIdIMG() + ".png"));
img.setFitHeight(160);
img.setFitHeight(230);
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);
row.getChildren().add(img);
}
@@ -307,11 +307,16 @@ public class LeaderboardFXMLController {
grid.getChildren().add(empty);
}
grid.setMaxHeight(460);
grid.setMaxWidth(680);
popupContent.getChildren().add(grid);
ScrollPane scrollPane = new ScrollPane(grid);
scrollPane.setFitToWidth(true);
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();
scrollPane.setMaxHeight(window.getHeight() * 0.8);
popupContent.getChildren().add(scrollPane);
popup.show(window, 0, 0);
popup.getScene().setFill(Color.TRANSPARENT);
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.Network.EventType;
import it.polimi.ingsw.gc14.Network.NetworkEvent;
import javafx.animation.AnimationTimer;
import javafx.animation.PauseTransition;
import javafx.animation.ScaleTransition;
import javafx.application.Platform;
import javafx.event.Event;
import javafx.fxml.FXML;
import javafx.geometry.Insets;
@@ -24,6 +27,7 @@ import javafx.scene.paint.Color;
import javafx.scene.shape.*;
import javafx.scene.text.Font;
import javafx.stage.Popup;
import javafx.stage.Stage;
import javafx.stage.Window;
import javafx.util.Duration;
@@ -67,11 +71,8 @@ public class MainFXMLController {
mainHBox.sceneProperty().addListener((obs, oldScene, newScene) -> {
if (newScene != null) {
newScene.getRoot().applyCss();
// chiudi popup cliccando fuori da esso
newScene.addEventFilter(MouseEvent.MOUSE_PRESSED, e -> {
if (popup.isShowing()) {
popup.hide();
}
if (popup.isShowing()) popup.hide();
});
}
});
@@ -107,13 +108,15 @@ public class MainFXMLController {
// ==== EFFECTS ====
private void addClip(Node node) {
private void addClip(ImageView img) {
Rectangle clip = new Rectangle();
clip.setWidth(node.getBoundsInLocal().getWidth());
clip.setHeight(node.getBoundsInLocal().getHeight());
clip.setArcWidth(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) {
@@ -152,7 +155,7 @@ public class MainFXMLController {
// ==== ELEMENTS ====
private StackPane createOrder(String num) {
ImageView img = new ImageView(loadImage("/GUIImages/Orders/order-" + num + ".png"));
img.setFitHeight(240);
img.fitHeightProperty().bind(board.heightProperty().add(-15));
img.setPreserveRatio(true);
addClip(img);
return new StackPane(img);
@@ -160,18 +163,18 @@ public class MainFXMLController {
private StackPane createSlot(Slot slot, boolean withZoom, boolean withShadow) {
ImageView img = new ImageView(loadImage("/GUIImages/Fronts/card-" + slot.getSlotId() + ".png"));
img.setFitHeight(240);
img.setPreserveRatio(true);
img.fitHeightProperty().bind(board.heightProperty().add(-15));
addClip(img);
StackPane wrapper = new StackPane(img);
Player player = controller.miniModel.slotPlayerMap.get(slot);
if (player != null && controller.miniModel.getPositionByUsername(player.getUserName()) != -1) {
ImageView totem = new ImageView(loadImage("/GUIImages/Totems/totem_" + player.totem.toString().toLowerCase(Locale.ROOT) + ".png"));
totem.setFitHeight(70);
totem.setFitHeight(68);
totem.setPreserveRatio(true);
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);
}
@@ -180,13 +183,12 @@ public class MainFXMLController {
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"));
img.setFitHeight(200);
img.setPreserveRatio(true);
img.fitHeightProperty().bind(parent.heightProperty().multiply(0.85));
addClip(img);
StackPane wrapper = new StackPane(img);
if (withShadow) addShadow(wrapper);
if (withZoom) addHoverZoom(wrapper);
return wrapper;
@@ -236,6 +238,7 @@ public class MainFXMLController {
case "builders" -> new ArrayList<>(p.builders);
case "shamans" -> new ArrayList<>(p.shamans);
case "hunters" -> new ArrayList<>(p.hunters);
case "building" -> new ArrayList<>(p.buildingCards);
default -> new ArrayList<>();
};
}
@@ -250,7 +253,7 @@ public class MainFXMLController {
int i = 0;
for (TribeCard card : controller.miniModel.board.upperListTribe) {
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));
upperList.getChildren().add(img);
i++;
@@ -266,7 +269,7 @@ public class MainFXMLController {
int i = 0;
for (TribeCard card : controller.miniModel.board.lowerListTribe) {
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));
lowerList.getChildren().add(img);
i++;
@@ -277,7 +280,7 @@ public class MainFXMLController {
private void drawUpperBuilding() {
ArrayList<BuildingCard> cardList = new ArrayList<>(controller.miniModel.board.upperListBuilding);
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.setTranslateY(-55);
label.setTranslateX(10);
@@ -292,7 +295,7 @@ public class MainFXMLController {
private void drawLowerBuilding() {
ArrayList<BuildingCard> cardList = new ArrayList<>(controller.miniModel.board.lowerListBuilding);
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.setTranslateY(-55);
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()) {
StackPane img = createCard(cardList.getLast(), true, true);
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);
img.getChildren().add(label);
img.setOnMouseClicked(e -> openPopup(new ArrayList<>(cardList)));
myHand.getChildren().add(img);
parent.getChildren().add(img);
} else {
Region placeholder = new Region();
placeholder.setPrefHeight(200);
placeholder.setPrefWidth(200 * 0.675);
placeholder.prefHeightProperty().bind(parent.heightProperty().multiply(0.85));
placeholder.prefWidthProperty().bind(placeholder.prefHeightProperty().multiply(0.675));
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);
// Riga 2: cibo + prestigio
// Riga 2: cibo + prestigio + building
HBox statsRow = new HBox(10);
statsRow.setAlignment(Pos.CENTER);
@@ -367,13 +369,31 @@ public class MainFXMLController {
prestigeLabel.getStyleClass().add("label-small");
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
HBox iconsRow1 = new HBox(6);
iconsRow1.setSpacing(20);
iconsRow1.setAlignment(Pos.CENTER);
HBox iconsRow2 = new HBox(6);
iconsRow2.setAlignment(Pos.CENTER);
iconsRow2.setSpacing(20);
renderIcons(iconsRow1, iconsRow2, player);
card.getChildren().addAll(headerRow, statsRow, iconsRow1, iconsRow2);
@@ -413,7 +433,7 @@ public class MainFXMLController {
default -> "/GUIImages/Backs/back-001.png";
};
ImageView back = new ImageView(loadImage(path));
back.setFitHeight(240);
back.fitHeightProperty().bind(board.heightProperty().add(-15));
back.setPreserveRatio(true);
addClip(back);
addShadow(back);
@@ -427,7 +447,7 @@ public class MainFXMLController {
VBox overlay = new VBox(-20);
overlay.setPickOnBounds(false);
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) {
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);
Player me = controller.miniModel.players.get(controller.myUsername);
drawMyHandList(me.artists);
drawMyHandList(me.gatherers);
drawMyHandList(me.inventors);
drawMyHandList(me.builders);
drawMyHandList(me.shamans);
drawMyHandList(me.hunters);
drawMyHandList(me.buildingCards);
drawMyHandList(me.artists,myHand);
drawMyHandList(me.gatherers,myHand);
drawMyHandList(me.inventors,myHand);
drawMyHandList(me.builders,myHand);
drawMyHandList(me.shamans,myHand);
drawMyHandList(me.hunters,myHand);
drawMyHandList(me.buildingCards,myHand);
}
private void renderSidePanel() {
@@ -479,6 +499,25 @@ public class MainFXMLController {
VBox.setMargin(info, new Insets(5, 5, 5, 5));
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()) {
renderPlayer(player);
}
@@ -521,7 +560,7 @@ public class MainFXMLController {
private void openPopup(ArrayList<? extends PlayableCard> cardList) {
popupCards.getChildren().clear();
for (PlayableCard card : cardList) {
popupCards.getChildren().add(createCard(card, false, false));
popupCards.getChildren().add(createCardPopup(card, false, false));
}
showPopup();
}
@@ -531,7 +570,7 @@ public class MainFXMLController {
popupCards.getChildren().clear();
for (int i = 0; i < cardList.size(); i++) {
final int index = i;
StackPane img = createCard(cardList.get(i), true, false);
StackPane img = createCardPopup(cardList.get(i), true, false);
img.setOnMouseClicked(e -> {
popup.hide();
controller.drawUpperBuildingCard(controller.myUsername, index);
@@ -546,7 +585,7 @@ public class MainFXMLController {
popupCards.getChildren().clear();
for (int i = 0; i < cardList.size(); i++) {
final int index = i;
StackPane img = createCard(cardList.get(i), true, false);
StackPane img = createCardPopup(cardList.get(i), true, false);
img.setOnMouseClicked(e -> {
popup.hide();
controller.drawLowerBuildingCard(controller.myUsername, index);
@@ -555,4 +594,25 @@ public class MainFXMLController {
}
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.layout.HBox?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.control.ScrollPane?>
<HBox fx:id="mainHBox"
maxHeight="Infinity" maxWidth="Infinity"
prefHeight="1080.0" prefWidth="1920.0"
@@ -22,64 +23,76 @@
<Insets top="5" right="5" bottom="5" left="5" />
</HBox.margin>
<children>
<HBox fx:id="upperList" prefHeight="220" minHeight="220" maxHeight="220" styleClass="card-list">
<VBox.margin>
<Insets top="5" right="5" bottom="5" left="5" />
</VBox.margin>
</HBox>
<HBox fx:id="board" prefHeight="255" minHeight="255" maxHeight="255" styleClass="card-list">
<VBox.margin>
<Insets top="5" right="5" bottom="5" left="5" />
</VBox.margin>
</HBox>
<HBox fx:id="lowerList" prefHeight="220" minHeight="220" maxHeight="220" styleClass="card-list">
<VBox.margin>
<Insets top="5" right="5" bottom="5" left="5" />
</VBox.margin>
</HBox>
<HBox fx:id="myHand" prefHeight="220" minHeight="220" maxHeight="220" styleClass="card-list">
<VBox.margin>
<Insets top="5" right="5" bottom="5" left="5" />
</VBox.margin>
</HBox>
<HBox fx:id="upperList" styleClass="card-list" VBox.vgrow="ALWAYS">
<VBox.margin>
<Insets top="5" right="5" bottom="5" left="5" />
</VBox.margin>
</HBox>
<HBox fx:id="board" prefHeight="220" minHeight="220" maxHeight="220" styleClass="card-list" VBox.vgrow="NEVER">
<VBox.margin>
<Insets top="5" right="5" bottom="5" left="5" />
</VBox.margin>
</HBox>
<HBox fx:id="lowerList" styleClass="card-list" VBox.vgrow="ALWAYS">
<VBox.margin>
<Insets top="5" right="5" bottom="5" left="5" />
</VBox.margin>
</HBox>
<HBox fx:id="myHand" styleClass="card-list" VBox.vgrow="ALWAYS">
<VBox.margin>
<Insets top="5" right="5" bottom="5" left="5" />
</VBox.margin>
</HBox>
</children>
</VBox>
<!-- VBox destra: dimensione fissa, non si espande -->
<VBox fx:id="sidePanel"
prefWidth="250.0"
maxWidth="250.0"
minWidth="250.0"
HBox.hgrow="NEVER"
styleClass="side-panel">
<HBox.margin>
<Insets bottom="10" left="10" right="10" top="10" />
</HBox.margin>
<children>
<HBox fx:id="info" prefHeight="107.0" prefWidth="483.0" styleClass="frame">
<children>
<VBox alignment="CENTER" prefHeight="107.0" prefWidth="161.0" spacing="2">
<children>
<Label styleClass="label-medium" text="Era" />
<Label fx:id="era" styleClass="label-medium" text="VALORE" />
</children>
</VBox>
<VBox alignment="CENTER" prefHeight="107.0" prefWidth="161.0" spacing="2">
<children>
<Label styleClass="label-medium" text="Round" />
<Label fx:id="round" styleClass="label-medium" text="VALORE" />
</children>
</VBox>
<VBox alignment="CENTER" prefHeight="107.0" prefWidth="161.0" spacing="2">
<children>
<Label styleClass="label-medium" text="Player" />
<Label fx:id="player" styleClass="label-medium" text="VALORE" />
</children>
</VBox>
</children>
</HBox>
</children>
</VBox>
<VBox fx:id="sidePanel"
prefWidth="250.0"
maxWidth="250.0"
minWidth="250.0"
HBox.hgrow="NEVER"
styleClass="side-panel">
<HBox.margin>
<Insets bottom="10" left="10" right="10" top="10" />
</HBox.margin>
<children>
<ScrollPane fitToWidth="true" hbarPolicy="NEVER" vbarPolicy="AS_NEEDED" VBox.vgrow="ALWAYS">
<content>
<VBox spacing="10">
<children>
<HBox fx:id="info" prefHeight="107.0" prefWidth="483.0" styleClass="frame">
<children>
<VBox alignment="CENTER" prefHeight="107.0" prefWidth="161.0" spacing="2">
<children>
<Label styleClass="label-medium" text="Era" />
<Label fx:id="era" styleClass="label-medium" text="VALORE" />
</children>
</VBox>
<VBox alignment="CENTER" prefHeight="107.0" prefWidth="161.0" spacing="2">
<children>
<Label styleClass="label-medium" text="Round" />
<Label fx:id="round" styleClass="label-medium" text="VALORE" />
</children>
</VBox>
<VBox alignment="CENTER" prefHeight="107.0" prefWidth="161.0" spacing="2">
<children>
<Label styleClass="label-medium" text="Player" />
<Label fx:id="player" styleClass="label-medium" text="VALORE" />
</children>
</VBox>
</children>
</HBox>
<!-- altri elementi qui sotto -->
</children>
</VBox>
</content>
</ScrollPane>
</children>
</VBox>
</children>
</HBox>
+8 -8
View File
@@ -7,21 +7,21 @@
<StackPane xmlns="http://javafx.com/javafx"
xmlns:fx="http://javafx.com/fxml"
fx:controller="it.polimi.ingsw.gc14.View.GUI.LeaderboardFXMLController"
fx:id="rootPane"
prefWidth="1280"
prefHeight="720">
fx:id="rootPane">
<!-- Overlay scuro semitrasparente sopra il background -->
<Region style="-fx-background-color: rgba(0,0,0,0.45);"/>
<!-- Contenuto centrato -->
<VBox fx:id="mainVBox" alignment="CENTER" spacing="32">
<padding><Insets top="50" right="120" bottom="50" left="120"/></padding>
<!-- Lista giocatori (Winner/GameOver label aggiunta da render()) -->
<VBox fx:id="rankingList" alignment="CENTER" spacing="16"/>
<ScrollPane fitToWidth="true"
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"
styleClass="action-button"
onAction="#onNewGame"/>
+14
View File
@@ -47,4 +47,18 @@
-fx-background-insets: 0, 5, 10, 15;
-fx-background-radius: 15, 12, 8, 4;
-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;
}