diff --git a/src/main/java/it/polimi/ingsw/gc14/View/GUI/MainFXMLController.java b/src/main/java/it/polimi/ingsw/gc14/View/GUI/MainFXMLController.java index 9f65148..fc9b1bf 100644 --- a/src/main/java/it/polimi/ingsw/gc14/View/GUI/MainFXMLController.java +++ b/src/main/java/it/polimi/ingsw/gc14/View/GUI/MainFXMLController.java @@ -5,6 +5,7 @@ import it.polimi.ingsw.gc14.Model.*; import it.polimi.ingsw.gc14.Model.Cards.BuildingCard; import it.polimi.ingsw.gc14.Model.Cards.TribeCard; import javafx.animation.ScaleTransition; +import javafx.event.Event; import javafx.fxml.FXML; import javafx.geometry.Insets; import javafx.geometry.Pos; @@ -20,6 +21,7 @@ import javafx.scene.paint.Color; import javafx.scene.shape.*; import javafx.scene.text.Font; import javafx.stage.Popup; +import javafx.stage.Window; import javafx.util.Duration; import java.util.ArrayList; @@ -236,7 +238,7 @@ public class MainFXMLController { } } private void renderOrder() { - StackPane card = createOrder(Integer.toString(model.getNPlayers()), true, true); + StackPane card = createOrder(Integer.toString(model.getNPlayers()), false, false); VBox overlay = new VBox(-20); overlay.setPickOnBounds(false); @@ -264,6 +266,26 @@ public class MainFXMLController { board.setAlignment(Pos.CENTER); board.getChildren().clear(); + String path = ""; + switch (model.getCurrentState().getEra()) { + case 1 -> path = "/GUIImages/Backs/back-001.png"; + case 2 -> path = "/GUIImages/Backs/back-030.png"; + case 3 -> path = "/GUIImages/Backs/back-058.png"; + } + ImageView back = new ImageView(new Image(getClass().getResourceAsStream(path))); + back.setFitHeight(240); + back.setPreserveRatio(true); + Rectangle clip = new Rectangle(); + clip.setWidth(back.getBoundsInLocal().getWidth()); + clip.setHeight(240); + clip.setArcWidth(20); + clip.setArcHeight(20); + back.setClip(clip); + addShadow(back); + addHoverZoom(back); + board.getChildren().add(back); + + renderOrder(); int i = 0; @@ -349,59 +371,65 @@ public class MainFXMLController { } private void renderPlayers(VBox playersHand) { for (Player player : model.getPlayers()) { - if(player.getUserName().equals(username)) { - continue; - } - VBox card = new VBox(); - VBox.setMargin(card, new Insets(5, 5, 5, 5)); - card.setAlignment(Pos.CENTER); + // Card container + VBox card = new VBox(3); + VBox.setMargin(card, new Insets(5)); card.getStyleClass().add("player-card"); + card.setPadding(new Insets(8)); + addHoverZoom(card); + addShadow(card); + // Riga 1: icona totem + nome + HBox headerRow = new HBox(8); + headerRow.setAlignment(Pos.CENTER); + int index = model.getPlayers().indexOf(player); + ImageView totem = new ImageView(new Image(getClass().getResourceAsStream("/GUIImages/Totems/totem_" + index + ".png"))); + totem.setFitHeight(20); + totem.setPreserveRatio(true); Label usernameLabel = new Label(player.getUserName()); - usernameLabel.getStyleClass().add("label-medium"); - Label foodLabel = new Label("Food: " + player.getFoodValue()); - foodLabel.getStyleClass().add("label-small"); - Label prestigeLabel = new Label("Prestige: " + player.getPrestigeValue()); - prestigeLabel.getStyleClass().add("label-small"); - HBox icons = new HBox(); - icons.setSpacing(6); - icons.setAlignment(Pos.CENTER); - renderIcons(icons, player); - card.getChildren().addAll(usernameLabel, foodLabel, prestigeLabel, icons); + if (player.getUserName().equals(username)) { + usernameLabel.setStyle("-fx-text-fill: #9d0208"); + } + headerRow.getChildren().addAll(totem, usernameLabel); + // Riga 2: cibo + prestigio + HBox statsRow = new HBox(10); + statsRow.setAlignment(Pos.CENTER); + + HBox foodBox = new HBox(4); + foodBox.setAlignment(Pos.CENTER); + ImageView foodIcon = new ImageView(new Image(getClass().getResourceAsStream("/GUIImages/Icons/Food.png"))); + foodIcon.setFitHeight(20); + foodIcon.setPreserveRatio(true); + Label foodLabel = new Label(String.valueOf(player.getFoodValue())); + foodLabel.getStyleClass().add("label-small"); + foodBox.getChildren().addAll(foodIcon, foodLabel); + + HBox prestigeBox = new HBox(1); + prestigeBox.setAlignment(Pos.CENTER); + ImageView PPIcon = new ImageView(new Image(getClass().getResourceAsStream("/GUIImages/Icons/PrestigePoint.png"))); + PPIcon.setFitHeight(35); + PPIcon.setPreserveRatio(true); + Label prestigeLabel = new Label(String.valueOf(player.getPrestigeValue())); + prestigeLabel.getStyleClass().add("label-small"); + prestigeBox.getChildren().addAll(PPIcon, prestigeLabel); + + statsRow.getChildren().addAll(foodBox, prestigeBox); + + // Righe 3-4: icone carte (3 per riga) + HBox iconsRow1 = new HBox(6); + iconsRow1.setAlignment(Pos.CENTER); + HBox iconsRow2 = new HBox(6); + iconsRow2.setAlignment(Pos.CENTER); + renderIcons(iconsRow1, iconsRow2, player); // vedi sotto + + card.getChildren().addAll(headerRow, statsRow, iconsRow1, iconsRow2); playersHand.getChildren().add(card); } - Region spacer = new Region(); - VBox.setVgrow(spacer, Priority.ALWAYS); - playersHand.getChildren().add(spacer); - - VBox card = new VBox(); - VBox.setMargin(card, new Insets(5, 5, 5, 5)); - card.setAlignment(Pos.CENTER); - card.getStyleClass().add("frame"); - - Label usernameLabel = new Label(username); - usernameLabel.getStyleClass().add("label-medium"); - int index = model.getPlayers().indexOf( - model.getPlayers().stream() - .filter(p -> p.getUserName().equals(username)) - .findFirst() - .orElse(null) - ); - ImageView totem = new ImageView(new Image(getClass().getResourceAsStream("/GUIImages/Totems/totem_" + index + ".png"))); - totem.setFitHeight(10); - totem.setPreserveRatio(true); - Label foodLabel = new Label("Food: " + model.getPlayerByUsername(username).getFoodValue()); - foodLabel.getStyleClass().add("label-small"); - Label prestigeLabel = new Label("Prestige: " + model.getPlayerByUsername(username).getPrestigeValue()); - prestigeLabel.getStyleClass().add("label-small"); - card.getChildren().addAll(usernameLabel, totem, foodLabel, prestigeLabel); - - playersHand.getChildren().add(card); } - private void renderIcons(HBox icons, Player player) { + private void renderIcons(HBox iconsRow1, HBox iconsRow2, Player player) { String[][] iconTypes = { {"Artist", "artists"}, {"Gatherer", "gatherers"}, @@ -411,9 +439,9 @@ public class MainFXMLController { {"Hunter", "hunters"} }; - for (String[] type : iconTypes) { - String iconName = type[0]; - String fieldName = type[1]; + for (int i = 0; i < iconTypes.length; i++) { + String iconName = iconTypes[i][0]; + String fieldName = iconTypes[i][1]; ImageView icon = new ImageView(); icon.setFitWidth(28); @@ -424,15 +452,16 @@ public class MainFXMLController { ArrayList cards = getPlayerCards(player.getUserName(), fieldName); if (cards.isEmpty()) { ColorAdjust grayscale = new ColorAdjust(); - grayscale.setSaturation(-1.0); + //grayscale.setSaturation(-1.0); icon.setEffect(grayscale); - icon.setOpacity(0.5); + icon.setOpacity(0.3); } else { icon.setOnMouseClicked(e -> openPopup(cards)); addHoverZoom(icon); } - icons.getChildren().add(icon); + if (i < 3) iconsRow1.getChildren().add(icon); + else iconsRow2.getChildren().add(icon); } } private ArrayList getPlayerCards(String username, String type) { @@ -474,7 +503,7 @@ public class MainFXMLController { popup.setAutoHide(true); // Aspetta che la scena del popup esista, poi la rendi trasparente - popup.addEventHandler(javafx.event.Event.ANY, e -> { + popup.addEventHandler(Event.ANY, e -> { if (popup.getScene() != null) { popup.getScene().setFill(Color.TRANSPARENT); } @@ -486,7 +515,7 @@ public class MainFXMLController { StackPane img = createCard(card, false, false); popupCards.getChildren().add(img); } - javafx.stage.Window window = myHand.getScene().getWindow(); + Window window = myHand.getScene().getWindow(); popup.show(window, (window.getWidth() - popup.getWidth()) / 2, (window.getHeight() - popup.getHeight()) / 2); // La scena esiste solo dopo show() diff --git a/src/main/resources/GUIImages/Backs/back-001.png b/src/main/resources/GUIImages/Backs/back-001.png index 89dec13..a0793ae 100644 Binary files a/src/main/resources/GUIImages/Backs/back-001.png and b/src/main/resources/GUIImages/Backs/back-001.png differ diff --git a/src/main/resources/GUIImages/Backs/back-030.png b/src/main/resources/GUIImages/Backs/back-030.png index a196534..98bb464 100644 Binary files a/src/main/resources/GUIImages/Backs/back-030.png and b/src/main/resources/GUIImages/Backs/back-030.png differ diff --git a/src/main/resources/GUIImages/Backs/back-058.png b/src/main/resources/GUIImages/Backs/back-058.png index a71865e..a36ca21 100644 Binary files a/src/main/resources/GUIImages/Backs/back-058.png and b/src/main/resources/GUIImages/Backs/back-058.png differ diff --git a/src/main/resources/GUIImages/Backs/back-095.png b/src/main/resources/GUIImages/Backs/back-095.png index 8381fbc..f963717 100644 Binary files a/src/main/resources/GUIImages/Backs/back-095.png and b/src/main/resources/GUIImages/Backs/back-095.png differ diff --git a/src/main/resources/GUIImages/Backs/back-097.png b/src/main/resources/GUIImages/Backs/back-097.png index 5905498..ee1bbdf 100644 Binary files a/src/main/resources/GUIImages/Backs/back-097.png and b/src/main/resources/GUIImages/Backs/back-097.png differ diff --git a/src/main/resources/GUIImages/Backs/back-103.png b/src/main/resources/GUIImages/Backs/back-103.png index 033193c..b2ae7df 100644 Binary files a/src/main/resources/GUIImages/Backs/back-103.png and b/src/main/resources/GUIImages/Backs/back-103.png differ diff --git a/src/main/resources/GUIImages/Backs/back-110.png b/src/main/resources/GUIImages/Backs/back-110.png index efc1db5..88c01a7 100644 Binary files a/src/main/resources/GUIImages/Backs/back-110.png and b/src/main/resources/GUIImages/Backs/back-110.png differ diff --git a/src/main/resources/GUIScene/main.fxml b/src/main/resources/GUIScene/main.fxml index d1bbb93..62d9eb4 100644 --- a/src/main/resources/GUIScene/main.fxml +++ b/src/main/resources/GUIScene/main.fxml @@ -38,7 +38,7 @@ - + @@ -65,6 +65,7 @@ - + + diff --git a/src/main/resources/GUIScene/styles.css b/src/main/resources/GUIScene/styles.css index 0720a4c..77d2670 100644 --- a/src/main/resources/GUIScene/styles.css +++ b/src/main/resources/GUIScene/styles.css @@ -31,11 +31,11 @@ } .player-card { - -fx-border-color: black; + -fx-border-color: #6a040f; -fx-border-width: 2; -fx-border-radius: 15; -fx-background-radius: 15; - -fx-background-color: #b42224; + -fx-background-color: #f48c06; } .frame {