Merge pull request #95 from rubenpirreram/GUI

G UI
This commit is contained in:
rubenpirreram
2026-05-12 14:33:57 +02:00
committed by GitHub
49 changed files with 665 additions and 216 deletions
Vendored Executable → Regular
View File
@@ -7,6 +7,7 @@ import it.polimi.ingsw.gc14.View.GUI.GUI;
import it.polimi.ingsw.gc14.View.GUI.LoginView; import it.polimi.ingsw.gc14.View.GUI.LoginView;
import javafx.application.Application; import javafx.application.Application;
import javafx.application.Platform; import javafx.application.Platform;
import javafx.scene.text.Font;
import javafx.stage.Stage; import javafx.stage.Stage;
public class ClientLauncherGUI extends Application { public class ClientLauncherGUI extends Application {
@@ -122,7 +122,7 @@ public class Game implements Serializable {
/** /**
* The order logic card associated with this game. * The order logic card associated with this game.
*/ */
private OrderLogicCard orderLogicCard; public OrderLogicCard orderLogicCard;
/** /**
* The board associated with this game. * The board associated with this game.
@@ -123,16 +123,17 @@ public abstract class OrderLogicCard implements Serializable {
} }
/** /**
* TODO rifare javadoc
* Returns the {@code Player}'s position based on it's {@code Username}. * Returns the {@code Player}'s position based on it's {@code Username}.
* @param username The desired {@code Player}'s username. * @param username The desired {@code Player}'s username.
* @return {@code int} - the {@code Player}'s position. * @return {@code int} - the {@code Player}'s position.
* @see Player * @see Player
*/ */
protected int getPosition(String username) public int getPosition(String username)
{ {
int pos = 0; int pos = 0;
for (Player p : players) { for (OrderPlayer p : playerList) {
if (p.getUserName().equals(username)) if (p.player.getUserName().equals(username))
return pos; return pos;
pos++; pos++;
} }
@@ -10,13 +10,14 @@ import javafx.stage.Stage;
public class GUI implements IView { // stessa interfaccia che implementa TUI public class GUI implements IView { // stessa interfaccia che implementa TUI
private final Stage stage; private final Stage stage;
private final MainView mainView = new MainView(); private final MainView mainView;
private Game model; private Game model;
private ClientController controller; private ClientController controller;
private String username; private String username;
public GUI(Stage stage) { public GUI(Stage stage) {
this.stage = stage; this.stage = stage;
this.mainView = new MainView();
} }
@Override @Override
@@ -1,269 +1,524 @@
package it.polimi.ingsw.gc14.View.GUI; package it.polimi.ingsw.gc14.View.GUI;
import it.polimi.ingsw.gc14.Controller.ClientController; import it.polimi.ingsw.gc14.Controller.ClientController;
import it.polimi.ingsw.gc14.Model.*;
import it.polimi.ingsw.gc14.Model.Cards.BuildingCard;
import it.polimi.ingsw.gc14.Model.Cards.TribeCard; import it.polimi.ingsw.gc14.Model.Cards.TribeCard;
import it.polimi.ingsw.gc14.Model.Game; import javafx.animation.ScaleTransition;
import it.polimi.ingsw.gc14.Model.Player; import javafx.event.Event;
import it.polimi.ingsw.gc14.Model.Slot;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.geometry.Bounds; import javafx.geometry.Insets;
import javafx.geometry.Pos; import javafx.geometry.Pos;
import javafx.scene.control.Button; import javafx.scene.Cursor;
import javafx.scene.Node;
import javafx.scene.control.Label;
import javafx.scene.effect.ColorAdjust;
import javafx.scene.effect.DropShadow;
import javafx.scene.image.*; import javafx.scene.image.*;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.*; import javafx.scene.layout.*;
import javafx.scene.paint.Color;
import javafx.scene.shape.*; 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; import java.util.ArrayList;
import java.util.List; import java.util.HashMap;
import java.util.Map; import java.util.Map;
public class MainFXMLController { public class MainFXMLController {
@FXML private HBox mainHBox;
@FXML private HBox board; @FXML private HBox board;
@FXML private HBox upperList; @FXML private HBox upperList;
@FXML private HBox lowerList; @FXML private HBox lowerList;
@FXML private HBox myHand; @FXML private HBox myHand;
@FXML private VBox playersHand;
@FXML private Button reload; @FXML private VBox sidePanel;
@FXML private HBox info;
@FXML private Label era;
@FXML private Label round;
@FXML private Label player;
private Popup popup;
private HBox popupCards;
private Game model; private Game model;
private ClientController controller; private ClientController controller;
private String username; private String username;
private final Map<String, ImageView> cardCache = new HashMap<>();
public void setModel(Game model) { public void setModel(Game model) {this.model = model;}
this.model = model;
}
public void setController(ClientController controller) {this.controller = controller;} public void setController(ClientController controller) {this.controller = controller;}
public void setUsername(String username) {this.username = username;} public void setUsername(String username) {this.username = username;}
@FXML
public void initialize() {
// Import font and apply CSS
Font.loadFont(getClass().getResourceAsStream("/Fonts/InknutAntiqua-Regular.ttf"), 14);
mainHBox.sceneProperty().addListener((obs, oldScene, newScene) -> {
if (newScene != null) {
newScene.getRoot().applyCss();
}
});
// Initialize popup
initPopup();
}
public void render() { public void render() {
renderBackground();
renderUpper();
renderBoard();
renderLower();
renderMyHand();
renderSidePanel();
}
// ==== HELPER ====
private StackPane createOrder(String num, boolean withZoom, boolean withShadow) {
ImageView img = new ImageView(new Image(getClass().getResourceAsStream("/GUIImages/Orders/order-" + num + ".png")));
img.setFitHeight(240);
img.setPreserveRatio(true);
Rectangle clip = new Rectangle();
clip.setWidth(img.getBoundsInLocal().getWidth());
clip.setHeight(240);
clip.setArcWidth(20);
clip.setArcHeight(20);
img.setClip(clip);
StackPane wrapper = new StackPane(img);
if (withShadow) {
addShadow(wrapper);
}
if (withZoom) {
addHoverZoom(wrapper);
}
return wrapper;
}
private StackPane createSlot(Slot slot, boolean withZoom, boolean withShadow) {
ImageView img = new ImageView(new Image(getClass().getResourceAsStream("/GUIImages/Fronts/card-" + slot.getSlotId() + ".png")));
img.setFitHeight(240);
img.setPreserveRatio(true);
Rectangle clip = new Rectangle();
clip.setWidth(img.getBoundsInLocal().getWidth());
clip.setHeight(240);
clip.setArcWidth(20);
clip.setArcHeight(20);
img.setClip(clip);
StackPane wrapper = new StackPane(img);
Player player = model.getSlotMap().get(slot);
if (player != null) {
int index = model.getPlayers().indexOf(player);
ImageView totem = new ImageView(new Image(getClass().getResourceAsStream("/GUIImages/Totems/totem_" + index + ".png")));
totem.setFitHeight(70);
totem.setPreserveRatio(true);
StackPane.setAlignment(totem, Pos.TOP_LEFT);
StackPane.setMargin(totem, new Insets(8, 0, 0, 57));
wrapper.getChildren().add(totem);
}
if (withShadow) {
addShadow(wrapper);
}
if (withZoom) {
addHoverZoom(wrapper);
}
return wrapper;
}
private StackPane createCard(PlayableCard card, boolean withZoom, boolean withShadow) {
String id = card.getIdIMG();
ImageView img;
if (cardCache.containsKey(id)) {
img = new ImageView(cardCache.get(id).getImage());
} else {
img = new ImageView(new Image(getClass().getResourceAsStream("/GUIImages/Fronts/card-" + id + ".png")));
cardCache.put(id, img);
}
img.setFitHeight(200);
img.setPreserveRatio(true);
Rectangle clip = new Rectangle();
clip.setWidth(img.getBoundsInLocal().getWidth());
clip.setHeight(200);
clip.setArcWidth(20);
clip.setArcHeight(20);
img.setClip(clip);
StackPane wrapper = new StackPane(img);
if (withShadow) {
addShadow(wrapper);
}
if (withZoom) {
addHoverZoom(wrapper);
}
return wrapper;
}
private void addHoverZoom(Node node) {
ScaleTransition scaleUp = new ScaleTransition(Duration.millis(150), node);
scaleUp.setToX(1.1);
scaleUp.setToY(1.1);
ScaleTransition scaleDown = new ScaleTransition(Duration.millis(150), node);
scaleDown.setToX(1.0);
scaleDown.setToY(1.0);
node.addEventHandler(MouseEvent.MOUSE_ENTERED, e -> { scaleUp.play(); node.setCursor(Cursor.HAND); });
node.addEventHandler(MouseEvent.MOUSE_EXITED, e -> { scaleDown.play(); node.setCursor(Cursor.DEFAULT); });
}
private void addShadow(Node node) {
DropShadow shadow = new DropShadow();
shadow.setColor(Color.rgb(0, 0, 0, 0.3));
shadow.setRadius(6);
shadow.setOffsetX(2);
shadow.setOffsetY(2);
node.setEffect(shadow);
node.addEventHandler(MouseEvent.MOUSE_ENTERED, e -> {
shadow.setRadius(16);
shadow.setOffsetX(4);
shadow.setOffsetY(4);
shadow.setColor(Color.rgb(0, 0, 0, 0.5));
});
node.addEventHandler(MouseEvent.MOUSE_EXITED, e -> {
shadow.setRadius(6);
shadow.setOffsetX(2);
shadow.setOffsetY(2);
shadow.setColor(Color.rgb(0, 0, 0, 0.3));
});
}
// Upper list
upperList.setSpacing(6); // ==== RENDER METHODS ====
// BACKGROUND
private void renderBackground() {
BackgroundSize size = new BackgroundSize(
BackgroundSize.AUTO, BackgroundSize.AUTO,
false, false, true, true
);
mainHBox.setBackground(new Background(new BackgroundImage(
new Image(getClass().getResourceAsStream("/GUIImages/Background.png")),
BackgroundRepeat.NO_REPEAT,
BackgroundRepeat.NO_REPEAT,
BackgroundPosition.CENTER,
size
)));
}
// UPPER, LOWER AND BOARD
private void renderUpper() {
upperList.setSpacing(14);
upperList.setAlignment(Pos.CENTER); upperList.setAlignment(Pos.CENTER);
upperList.getChildren().clear(); upperList.getChildren().clear();
int i = 0; int i = 0;
for (TribeCard card : model.getUpperListTribeCards()) { for (TribeCard card : model.getUpperListTribeCards()) {
final int index = i; final int index = i;
StackPane img = createCard(card, true, true);
Image tribeImg = new Image(getClass().getResourceAsStream("/GUIImages/Fronts/card-" + card.getIdIMG() + ".png")); img.setOnMouseClicked(e -> controller.drawUpperTribeCard(username, index));
ImageView view = new ImageView(tribeImg); upperList.getChildren().add(img);
view.fitHeightProperty().bind(upperList.heightProperty().subtract(10));
view.setPreserveRatio(true);
view.setOnMouseClicked(e -> controller.drawUpperTribeCard(username, index));
upperList.getChildren().add(view);
i++; i++;
} }
i = 0;
for (BuildingCard card : model.getUpperListBuilding()) {
final int index = i;
StackPane img = createCard(card, true, true);
img.setOnMouseClicked(e -> controller.drawUpperBuildingCard(username, index));
upperList.getChildren().add(img);
i++;
}
}
private void renderOrder() {
StackPane card = createOrder(Integer.toString(model.getNPlayers()), false, false);
VBox overlay = new VBox(-20);
overlay.setPickOnBounds(false);
StackPane.setAlignment(overlay, Pos.TOP_LEFT);
StackPane.setMargin(overlay, new Insets(9, 0, 0, 57));
// Board int i = 0;
board.setSpacing(6); for (Player player : model.getPlayers()) {
final int index = i;
ImageView totem = new ImageView(new Image(getClass().getResourceAsStream("/GUIImages/Totems/totem_" + index + ".png")));
totem.setFitHeight(70);
totem.setPreserveRatio(true);
if (!(model.orderLogicCard.getPosition(player.getUserName()) != -1 && !model.getSlotMap().containsValue(player))) {
totem.setOpacity(0.0);
}
overlay.getChildren().add(totem);
i++;
}
card.getChildren().add(overlay);
board.getChildren().add(card);
}
private void renderBoard() {
board.setSpacing(14);
board.setAlignment(Pos.CENTER); board.setAlignment(Pos.CENTER);
board.getChildren().clear(); board.getChildren().clear();
i = 0; 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;
for (Map.Entry<Slot, Player> entry : model.getSlotMap().entrySet()) { for (Map.Entry<Slot, Player> entry : model.getSlotMap().entrySet()) {
Slot slot = entry.getKey(); Slot slot = entry.getKey();
final int index = i; final int index = i;
StackPane img = createSlot(slot, true, true);
Image slotImg = new Image(getClass().getResourceAsStream("/GUIImages/Fronts/card-"+slot.getSlotId()+".png")); img.setOnMouseClicked(e -> controller.slotChoice(username, index));
ImageView view = new ImageView(slotImg); board.getChildren().add(img);
view.fitHeightProperty().bind(board.heightProperty().subtract(10));
view.setPreserveRatio(true);
view.setOnMouseClicked(e -> controller.slotChoice(username, index));
board.getChildren().add(view);
i++; i++;
} }
}
private void renderLower() {
lowerList.setSpacing(14);
// Lower list
lowerList.setSpacing(6);
lowerList.setAlignment(Pos.CENTER); lowerList.setAlignment(Pos.CENTER);
lowerList.getChildren().clear(); lowerList.getChildren().clear();
i = 0; int i = 0;
for (TribeCard card : model.getLowerListTribeCards()) { for (TribeCard card : model.getLowerListTribeCards()) {
final int index = i; final int index = i;
StackPane img = createCard(card, true, true);
Image tribeImg = new Image(getClass().getResourceAsStream("/GUIImages/Fronts/card-" + card.getIdIMG() + ".png")); img.setOnMouseClicked(e -> controller.drawLowerTribeCard(username, index));
ImageView view = new ImageView(tribeImg); lowerList.getChildren().add(img);
view.fitHeightProperty().bind(lowerList.heightProperty().subtract(10));
view.setPreserveRatio(true);
view.setOnMouseClicked(e -> controller.drawLowerTribeCard(username, index));
lowerList.getChildren().add(view);
i++; i++;
} }
i = 0;
for (BuildingCard card : model.getLowerListBuilding()) {
final int index = i;
StackPane img = createCard(card, true, true);
img.setOnMouseClicked(e -> controller.drawLowerBuildingCard(username, index));
lowerList.getChildren().add(img);
i++;
}
}
// MY HAND
// My hand private void renderMyHand() {
myHand.getChildren().clear(); myHand.getChildren().clear();
myHand.setSpacing(6); myHand.setSpacing(14);
//myHand.setAlignment(Pos.CENTER_LEFT); myHand.setAlignment(Pos.CENTER);
myHand.getChildren().add(createCardPane(model.getPlayerByUsername(username).artists.stream().map(x -> (TribeCard) x).toList(), myHand)); drawMyHandList(myHand, model.getPlayerByUsername(username).artists);
myHand.getChildren().add(createCardPane(model.getPlayerByUsername(username).gatherers.stream().map(x -> (TribeCard) x).toList(), myHand)); drawMyHandList(myHand, model.getPlayerByUsername(username).gatherers);
myHand.getChildren().add(createCardPane(model.getPlayerByUsername(username).inventors.stream().map(x -> (TribeCard) x).toList(), myHand)); drawMyHandList(myHand, model.getPlayerByUsername(username).inventors);
myHand.getChildren().add(createCardPane(model.getPlayerByUsername(username).builders.stream().map(x -> (TribeCard) x).toList(), myHand)); drawMyHandList(myHand, model.getPlayerByUsername(username).builders);
myHand.getChildren().add(createCardPane(model.getPlayerByUsername(username).shamans.stream().map(x -> (TribeCard) x).toList(), myHand)); drawMyHandList(myHand, model.getPlayerByUsername(username).shamans);
myHand.getChildren().add(createCardPane(model.getPlayerByUsername(username).hunters.stream().map(x -> (TribeCard) x).toList(), myHand)); drawMyHandList(myHand, model.getPlayerByUsername(username).hunters);
drawMyHandList(myHand, model.getPlayerByUsername(username).buildingCards);
}
private void drawMyHandList(HBox myHand, ArrayList<? extends PlayableCard> cardList) {
if (!cardList.isEmpty()) {
StackPane img = createCard(cardList.getLast(), true, true);
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); // aggiungi il label dentro lo StackPane di createCard
img.setOnMouseClicked(e -> openPopup(cardList));
myHand.getChildren().add(img);
} else {
Region placeholder = new Region();
placeholder.setPrefHeight(200);
placeholder.setPrefWidth(200 * 0.675);
placeholder.setStyle("-fx-background-color: transparent;");
myHand.getChildren().add(placeholder);
}
}
// SIDE PANEL
private void renderSidePanel() {
sidePanel.getChildren().clear();
sidePanel.setSpacing(6);
/** era.setText(Integer.toString(model.getCurrentState().getEra()));
// Artists round.setText(Integer.toString(model.getCurrentState().getRound()));
Pane artists = new Pane(); player.setText(model.getCurrentState().getCurrentPlayer().getUserName());
artists.prefHeightProperty().bind(myHand.heightProperty()); VBox.setMargin(info, new Insets(5, 5, 5, 5));
artists.prefWidthProperty().bind( sidePanel.getChildren().add(info);
artists.heightProperty().multiply(0.63).add((model.getPlayerByUsername(username).artists.size() - 1) * 50)
renderPlayers(sidePanel);
}
private void renderPlayers(VBox playersHand) {
for (Player player : model.getPlayers()) {
// 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");
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);
}
}
private void renderIcons(HBox iconsRow1, HBox iconsRow2, Player player) {
String[][] iconTypes = {
{"Artist", "artists"},
{"Gatherer", "gatherers"},
{"Inventor", "inventors"},
{"Builder", "builders"},
{"Shaman", "shamans"},
{"Hunter", "hunters"}
};
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);
icon.setFitHeight(28);
icon.setPreserveRatio(true);
icon.setImage(new Image(getClass().getResourceAsStream("/GUIImages/Icons/" + iconName + ".png")));
ArrayList<PlayableCard> cards = getPlayerCards(player.getUserName(), fieldName);
if (cards.isEmpty()) {
ColorAdjust grayscale = new ColorAdjust();
//grayscale.setSaturation(-1.0);
icon.setEffect(grayscale);
icon.setOpacity(0.3);
} else {
icon.setOnMouseClicked(e -> openPopup(cards));
addHoverZoom(icon);
}
if (i < 3) iconsRow1.getChildren().add(icon);
else iconsRow2.getChildren().add(icon);
}
}
private ArrayList<PlayableCard> getPlayerCards(String username, String type) {
Player p = model.getPlayerByUsername(username);
return switch (type) {
case "artists" -> new ArrayList<>(p.artists);
case "gatherers" -> new ArrayList<>(p.gatherers);
case "inventors" -> new ArrayList<>(p.inventors);
case "builders" -> new ArrayList<>(p.builders);
case "shamans" -> new ArrayList<>(p.shamans);
case "hunters" -> new ArrayList<>(p.hunters);
default -> new ArrayList<>();
};
}
// POPUP
private void initPopup() {
popupCards = new HBox(10);
popupCards.setAlignment(Pos.CENTER);
popupCards.setPadding(new Insets(10));
popupCards.setStyle(
"-fx-background-color: #b42224;" +
"-fx-border-color: black;" +
"-fx-border-width: 2;" +
"-fx-border-radius: 10;" +
"-fx-background-radius: 10;"
); );
for (int j=0;j<model.getPlayerByUsername(username).artists.size();j++) {
TribeCard card=model.getPlayerByUsername(username).artists.get(j);
Image tribeImg = new Image(getClass().getResourceAsStream("/GUIImages/Fronts/card-" + card.getIdIMG() + ".png")); Rectangle clip = new Rectangle();
ImageView view = new ImageView(tribeImg); clip.setArcWidth(20);
view.fitHeightProperty().bind(artists.heightProperty().subtract(10)); clip.setArcHeight(20);
view.setPreserveRatio(true); clip.widthProperty().bind(popupCards.widthProperty());
view.setLayoutX((model.getPlayerByUsername(username).artists.size() -j ) * 50); // solo X cambia clip.heightProperty().bind(popupCards.heightProperty());
view.setLayoutY(5); popupCards.setClip(clip);
artists.getChildren().addLast(view);
i++;
}
myHand.getChildren().add(artists);
// Gatherers popup = new Popup();
Pane gatherers=new Pane(); popup.getContent().add(popupCards);
gatherers.prefHeightProperty().bind(myHand.heightProperty()); popup.setAutoHide(true);
gatherers.prefWidthProperty().bind(
gatherers.heightProperty().multiply(0.63).add((model.getPlayerByUsername(username).gatherers.size() - 1) * 50)
);
for (int j=0;j<model.getPlayerByUsername(username).gatherers.size();j++) {
TribeCard card=model.getPlayerByUsername(username).gatherers.get(j);
Image tribeImg = new Image(getClass().getResourceAsStream("/GUIImages/Fronts/card-" + card.getIdIMG() + ".png")); // Aspetta che la scena del popup esista, poi la rendi trasparente
ImageView view = new ImageView(tribeImg); popup.addEventHandler(Event.ANY, e -> {
view.fitHeightProperty().bind(artists.heightProperty().subtract(10)); if (popup.getScene() != null) {
view.setPreserveRatio(true); popup.getScene().setFill(Color.TRANSPARENT);
view.setLayoutX((model.getPlayerByUsername(username).gatherers.size() -j ) * 50); // solo X cambia
view.setLayoutY(5);
gatherers.getChildren().addLast(view);
i++;
}
myHand.getChildren().add(gatherers);
// Inventors
Pane inventors=new Pane();
inventors.prefHeightProperty().bind(myHand.heightProperty());
for (int j=0;j<model.getPlayerByUsername(username).inventors.size();j++) {
TribeCard card=model.getPlayerByUsername(username).inventors.get(j);
Image tribeImg = new Image(getClass().getResourceAsStream("/GUIImages/Fronts/card-" + card.getIdIMG() + ".png"));
ImageView view = new ImageView(tribeImg);
view.fitHeightProperty().bind(inventors.heightProperty().subtract(10));
view.setPreserveRatio(true);
view.setLayoutX((model.getPlayerByUsername(username).inventors.size() -j )* 50); // solo X cambia
view.setLayoutY(5);
inventors.getChildren().addLast(view);
i++;
}
myHand.getChildren().add(inventors);
// Builders
Pane builders=new Pane();
builders.prefHeightProperty().bind(myHand.heightProperty());
for (int j=0;j<model.getPlayerByUsername(username).builders.size();j++) {
TribeCard card=model.getPlayerByUsername(username).builders.get(j);
Image tribeImg = new Image(getClass().getResourceAsStream("/GUIImages/Fronts/card-" + card.getIdIMG() + ".png"));
ImageView view = new ImageView(tribeImg);
view.fitHeightProperty().bind(builders.heightProperty().subtract(10));
view.setPreserveRatio(true);
view.setLayoutX((model.getPlayerByUsername(username).builders.size() -j ) * 50); // solo X cambia
view.setLayoutY(5);
builders.getChildren().addLast(view);
i++;
}
myHand.getChildren().add(builders);
// Shamans
Pane shamans=new Pane();
shamans.prefHeightProperty().bind(myHand.heightProperty());
for (int j=0;j<model.getPlayerByUsername(username).shamans.size();j++) {
TribeCard card=model.getPlayerByUsername(username).shamans.get(j);
Image tribeImg = new Image(getClass().getResourceAsStream("/GUIImages/Fronts/card-" + card.getIdIMG() + ".png"));
ImageView view = new ImageView(tribeImg);
view.fitHeightProperty().bind(shamans.heightProperty().subtract(10));
view.setPreserveRatio(true);
view.setLayoutX((model.getPlayerByUsername(username).shamans.size() -j ) * 50); // solo X cambia
view.setLayoutY(5);
shamans.getChildren().addLast(view);
i++;
}
myHand.getChildren().add(shamans);
// Hunters
Pane hunters=new Pane();
hunters.prefHeightProperty().bind(myHand.heightProperty());
for (int j=0;j<model.getPlayerByUsername(username).hunters.size();j++) {
TribeCard card=model.getPlayerByUsername(username).hunters.get(j);
Image tribeImg = new Image(getClass().getResourceAsStream("/GUIImages/Fronts/card-" + card.getIdIMG() + ".png"));
ImageView view = new ImageView(tribeImg);
view.fitHeightProperty().bind(hunters.heightProperty().subtract(10));
view.setPreserveRatio(true);
view.setLayoutX((model.getPlayerByUsername(username).hunters.size() -j )* 50); // solo X cambia
view.setLayoutY(5);
hunters.getChildren().addLast(view);
i++;
}
myHand.getChildren().add(hunters);
*/
}
private Pane createCardPane(List<TribeCard> cards, HBox container) {
Pane pane = new Pane();
int n = cards.size();
pane.prefHeightProperty().bind(container.heightProperty());
for (int j = 0; j < n; j++) {
TribeCard card = cards.get(j);
Image tribeImg = new Image(getClass().getResourceAsStream("/GUIImages/Fronts/card-" + card.getIdIMG() + ".png"));
ImageView view = new ImageView(tribeImg);
view.fitHeightProperty().bind(pane.heightProperty().subtract(10));
view.setPreserveRatio(true);
view.setLayoutX(j * 50);
view.setLayoutY(5);
pane.getChildren().add(view);
if (j == 0) {
view.layoutBoundsProperty().addListener(new ChangeListener<Bounds>() {
@Override
public void changed(ObservableValue<? extends Bounds> obs, Bounds old, Bounds bounds) {
if (bounds.getWidth() > 0) {
pane.setPrefWidth(bounds.getWidth() + (n - 1) * 50);
view.layoutBoundsProperty().removeListener(this);
}
} }
}); });
} }
private void openPopup(ArrayList<? extends PlayableCard> cardList) {
popupCards.getChildren().clear();
for (PlayableCard card : cardList) {
StackPane img = createCard(card, false, false);
popupCards.getChildren().add(img);
} }
return pane; Window window = myHand.getScene().getWindow();
popup.show(window, (window.getWidth() - popup.getWidth()) / 2, (window.getHeight() - popup.getHeight()) / 2);
// La scena esiste solo dopo show()
popup.getScene().setFill(Color.TRANSPARENT);
} }
} }
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+93
View File
@@ -0,0 +1,93 @@
Copyright (c) 2014 Claus Eggers Sørensen (es@forthehearts.net)
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
https://openfontlicense.org
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 832 KiB

After

Width:  |  Height:  |  Size: 832 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 833 KiB

After

Width:  |  Height:  |  Size: 832 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 834 KiB

After

Width:  |  Height:  |  Size: 833 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 846 KiB

After

Width:  |  Height:  |  Size: 845 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 905 KiB

After

Width:  |  Height:  |  Size: 900 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 905 KiB

After

Width:  |  Height:  |  Size: 902 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 884 KiB

After

Width:  |  Height:  |  Size: 881 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 380 KiB

After

Width:  |  Height:  |  Size: 373 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 415 KiB

After

Width:  |  Height:  |  Size: 406 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 414 KiB

After

Width:  |  Height:  |  Size: 410 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 380 KiB

After

Width:  |  Height:  |  Size: 374 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 393 KiB

After

Width:  |  Height:  |  Size: 387 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 394 KiB

After

Width:  |  Height:  |  Size: 389 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 409 KiB

After

Width:  |  Height:  |  Size: 406 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 711 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 691 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 692 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 730 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.0 KiB

+59 -11
View File
@@ -1,23 +1,71 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.Button?> <?import javafx.geometry.Insets?>
<?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.layout.Pane?> <HBox fx:id="mainHBox" maxHeight="1080.0" maxWidth="1920.0" minHeight="-Infinity" minWidth="-Infinity" prefHeight="1080.0" prefWidth="1920.0" xmlns="http://javafx.com/javafx/26" xmlns:fx="http://javafx.com/fxml/1" fx:controller="it.polimi.ingsw.gc14.View.GUI.MainFXMLController" stylesheets="@styles.css">
<HBox maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity" prefHeight="1080.0" prefWidth="1920.0" xmlns="http://javafx.com/javafx/26" xmlns:fx="http://javafx.com/fxml/1" fx:controller="it.polimi.ingsw.gc14.View.GUI.MainFXMLController">
<children> <children>
<VBox prefHeight="1080.0" prefWidth="1486.0">
<VBox prefHeight="1080.0" prefWidth="1486.0" fillWidth="false" alignment="CENTER">
<HBox.margin>
<Insets top="5" right="5" bottom="5" left="5" />
</HBox.margin>
<children> <children>
<HBox fx:id="upperList" prefHeight="255.0" prefWidth="200.0" style="-fx-background-color: #91352d;" /> <HBox fx:id="upperList" prefHeight="220" minHeight="220" maxHeight="220" styleClass="card-list">
<HBox fx:id="board" prefHeight="300.0" prefWidth="200.0" style="-fx-background-color: #2d3c91;" /> <VBox.margin>
<HBox fx:id="lowerList" prefHeight="255.0" prefWidth="200.0" style="-fx-background-color: #2d915b;" /> <Insets top="5" right="5" bottom="5" left="5" />
<HBox fx:id="myHand" prefHeight="270.0" prefWidth="1324.0" style="-fx-background-color: #8e912d;" /> </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>
</children> </children>
</VBox> </VBox>
<VBox fx:id="playersHand" prefHeight="1080.0" prefWidth="531.0" style="-fx-background-color: #742d91;">
<VBox fx:id="sidePanel" prefWidth="250.0" styleClass="side-panel">
<HBox.margin>
<Insets bottom="10" left="10" right="10" top="10" />
</HBox.margin>
<children> <children>
<Button fx:id="reload" mnemonicParsing="false" onAction="#render" prefHeight="335.0" prefWidth="510.0" text="Reload" /> <HBox fx:id="info" prefHeight="107.0" prefWidth="483.0" styleClass="frame">
</children></VBox> <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>
</children> </children>
</HBox> </HBox>
+50
View File
@@ -0,0 +1,50 @@
.card-list {
-fx-background-color: rgba(255,255,255,0.35);
-fx-background-radius: 15;
-fx-padding: 10;
}
.side-panel {
-fx-background-color: rgba(255,255,255,0.35);
-fx-background-radius: 15;
}
.label-small {
-fx-font-family: 'Inknut Antiqua';
-fx-font-size: 12px;
-fx-font-weight: bold;
-fx-text-fill: black;
}
.label-medium {
-fx-font-family: 'Inknut Antiqua';
-fx-font-size: 18px;
-fx-font-weight: bold;
-fx-text-fill: black;
}
.label-large {
-fx-font-family: 'Inknut Antiqua';
-fx-font-size: 50px;
-fx-font-weight: bold;
-fx-text-fill: black;
}
.player-card {
-fx-border-color: #6a040f;
-fx-border-width: 2;
-fx-border-radius: 15;
-fx-background-radius: 15;
-fx-background-color: #f48c06;
}
.frame {
-fx-background-color:
#8B6914,
#FFF8DC,
#8B6914,
#FFF8DC;
-fx-background-insets: 0, 5, 10, 15;
-fx-background-radius: 15, 12, 8, 4;
-fx-padding: 15 15 15 15;
}