Merge pull request #88 from rubenpirreram/GUI

G UI
This commit is contained in:
rubenpirreram
2026-05-07 15:23:29 +02:00
committed by GitHub
120 changed files with 163 additions and 0 deletions
@@ -5,7 +5,10 @@ import it.polimi.ingsw.gc14.Model.Cards.TribeCard;
import it.polimi.ingsw.gc14.Model.Game;
import it.polimi.ingsw.gc14.Model.Player;
import it.polimi.ingsw.gc14.Model.Slot;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.fxml.FXML;
import javafx.geometry.Bounds;
import javafx.geometry.Pos;
import javafx.scene.control.Button;
import javafx.scene.image.*;
@@ -103,5 +106,164 @@ public class MainFXMLController {
lowerList.getChildren().add(view);
i++;
}
// My hand
myHand.getChildren().clear();
myHand.setSpacing(6);
//myHand.setAlignment(Pos.CENTER_LEFT);
myHand.getChildren().add(createCardPane(model.getPlayerByUsername(username).artists.stream().map(x -> (TribeCard) x).toList(), myHand));
myHand.getChildren().add(createCardPane(model.getPlayerByUsername(username).gatherers.stream().map(x -> (TribeCard) x).toList(), myHand));
myHand.getChildren().add(createCardPane(model.getPlayerByUsername(username).inventors.stream().map(x -> (TribeCard) x).toList(), myHand));
myHand.getChildren().add(createCardPane(model.getPlayerByUsername(username).builders.stream().map(x -> (TribeCard) x).toList(), myHand));
myHand.getChildren().add(createCardPane(model.getPlayerByUsername(username).shamans.stream().map(x -> (TribeCard) x).toList(), myHand));
myHand.getChildren().add(createCardPane(model.getPlayerByUsername(username).hunters.stream().map(x -> (TribeCard) x).toList(), myHand));
/**
// Artists
Pane artists = new Pane();
artists.prefHeightProperty().bind(myHand.heightProperty());
artists.prefWidthProperty().bind(
artists.heightProperty().multiply(0.63).add((model.getPlayerByUsername(username).artists.size() - 1) * 50)
);
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"));
ImageView view = new ImageView(tribeImg);
view.fitHeightProperty().bind(artists.heightProperty().subtract(10));
view.setPreserveRatio(true);
view.setLayoutX((model.getPlayerByUsername(username).artists.size() -j ) * 50); // solo X cambia
view.setLayoutY(5);
artists.getChildren().addLast(view);
i++;
}
myHand.getChildren().add(artists);
// Gatherers
Pane gatherers=new Pane();
gatherers.prefHeightProperty().bind(myHand.heightProperty());
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"));
ImageView view = new ImageView(tribeImg);
view.fitHeightProperty().bind(artists.heightProperty().subtract(10));
view.setPreserveRatio(true);
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);
}
}
});
}
}
return pane;
}
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 979 KiB

After

Width:  |  Height:  |  Size: 974 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 978 KiB

After

Width:  |  Height:  |  Size: 974 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1007 KiB

After

Width:  |  Height:  |  Size: 1002 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1007 KiB

After

Width:  |  Height:  |  Size: 1002 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1008 KiB

After

Width:  |  Height:  |  Size: 1002 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 957 KiB

After

Width:  |  Height:  |  Size: 953 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 953 KiB

After

Width:  |  Height:  |  Size: 948 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 957 KiB

After

Width:  |  Height:  |  Size: 953 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 952 KiB

After

Width:  |  Height:  |  Size: 947 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 894 KiB

After

Width:  |  Height:  |  Size: 890 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 891 KiB

After

Width:  |  Height:  |  Size: 887 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 895 KiB

After

Width:  |  Height:  |  Size: 891 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 891 KiB

After

Width:  |  Height:  |  Size: 887 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 931 KiB

After

Width:  |  Height:  |  Size: 926 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 926 KiB

After

Width:  |  Height:  |  Size: 921 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 931 KiB

After

Width:  |  Height:  |  Size: 926 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 926 KiB

After

Width:  |  Height:  |  Size: 922 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 932 KiB

After

Width:  |  Height:  |  Size: 927 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 840 KiB

After

Width:  |  Height:  |  Size: 837 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 838 KiB

After

Width:  |  Height:  |  Size: 835 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 836 KiB

After

Width:  |  Height:  |  Size: 833 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 840 KiB

After

Width:  |  Height:  |  Size: 837 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 842 KiB

After

Width:  |  Height:  |  Size: 839 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: 837 KiB

After

Width:  |  Height:  |  Size: 835 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 939 KiB

After

Width:  |  Height:  |  Size: 934 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 936 KiB

After

Width:  |  Height:  |  Size: 931 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 933 KiB

After

Width:  |  Height:  |  Size: 928 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 931 KiB

After

Width:  |  Height:  |  Size: 927 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1007 KiB

After

Width:  |  Height:  |  Size: 1002 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1007 KiB

After

Width:  |  Height:  |  Size: 1002 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 979 KiB

After

Width:  |  Height:  |  Size: 974 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 979 KiB

After

Width:  |  Height:  |  Size: 974 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 979 KiB

After

Width:  |  Height:  |  Size: 974 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1007 KiB

After

Width:  |  Height:  |  Size: 1002 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 957 KiB

After

Width:  |  Height:  |  Size: 953 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 952 KiB

After

Width:  |  Height:  |  Size: 947 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 958 KiB

After

Width:  |  Height:  |  Size: 953 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 952 KiB

After

Width:  |  Height:  |  Size: 948 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 894 KiB

After

Width:  |  Height:  |  Size: 890 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 892 KiB

After

Width:  |  Height:  |  Size: 888 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 895 KiB

After

Width:  |  Height:  |  Size: 891 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 891 KiB

After

Width:  |  Height:  |  Size: 887 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 932 KiB

After

Width:  |  Height:  |  Size: 927 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 926 KiB

After

Width:  |  Height:  |  Size: 921 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 931 KiB

After

Width:  |  Height:  |  Size: 926 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 926 KiB

After

Width:  |  Height:  |  Size: 921 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 839 KiB

After

Width:  |  Height:  |  Size: 836 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 834 KiB

After

Width:  |  Height:  |  Size: 832 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 842 KiB

After

Width:  |  Height:  |  Size: 839 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 833 KiB

After

Width:  |  Height:  |  Size: 831 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 838 KiB

After

Width:  |  Height:  |  Size: 835 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 840 KiB

After

Width:  |  Height:  |  Size: 837 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 938 KiB

After

Width:  |  Height:  |  Size: 933 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 936 KiB

After

Width:  |  Height:  |  Size: 931 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 933 KiB

After

Width:  |  Height:  |  Size: 929 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 936 KiB

After

Width:  |  Height:  |  Size: 932 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 978 KiB

After

Width:  |  Height:  |  Size: 974 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1007 KiB

After

Width:  |  Height:  |  Size: 1002 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1007 KiB

After

Width:  |  Height:  |  Size: 1002 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 979 KiB

After

Width:  |  Height:  |  Size: 974 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 957 KiB

After

Width:  |  Height:  |  Size: 953 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 952 KiB

After

Width:  |  Height:  |  Size: 948 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 957 KiB

After

Width:  |  Height:  |  Size: 953 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 952 KiB

After

Width:  |  Height:  |  Size: 948 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 895 KiB

After

Width:  |  Height:  |  Size: 891 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 891 KiB

After

Width:  |  Height:  |  Size: 888 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 894 KiB

After

Width:  |  Height:  |  Size: 890 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 926 KiB

After

Width:  |  Height:  |  Size: 922 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 931 KiB

After

Width:  |  Height:  |  Size: 926 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 926 KiB

After

Width:  |  Height:  |  Size: 921 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 931 KiB

After

Width:  |  Height:  |  Size: 926 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 833 KiB

After

Width:  |  Height:  |  Size: 831 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 838 KiB

After

Width:  |  Height:  |  Size: 835 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 836 KiB

After

Width:  |  Height:  |  Size: 834 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 839 KiB

After

Width:  |  Height:  |  Size: 836 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 834 KiB

After

Width:  |  Height:  |  Size: 832 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 833 KiB

After

Width:  |  Height:  |  Size: 831 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 840 KiB

After

Width:  |  Height:  |  Size: 837 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 939 KiB

After

Width:  |  Height:  |  Size: 934 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 942 KiB

After

Width:  |  Height:  |  Size: 937 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 938 KiB

After

Width:  |  Height:  |  Size: 933 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 942 KiB

After

Width:  |  Height:  |  Size: 937 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 939 KiB

After

Width:  |  Height:  |  Size: 934 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 731 KiB

After

Width:  |  Height:  |  Size: 699 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 742 KiB

After

Width:  |  Height:  |  Size: 711 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 792 KiB

After

Width:  |  Height:  |  Size: 759 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 802 KiB

After

Width:  |  Height:  |  Size: 771 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 732 KiB

After

Width:  |  Height:  |  Size: 701 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 744 KiB

After

Width:  |  Height:  |  Size: 712 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 794 KiB

After

Width:  |  Height:  |  Size: 761 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 808 KiB

After

Width:  |  Height:  |  Size: 776 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 733 KiB

After

Width:  |  Height:  |  Size: 701 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 809 KiB

After

Width:  |  Height:  |  Size: 777 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 744 KiB

After

Width:  |  Height:  |  Size: 712 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 793 KiB

After

Width:  |  Height:  |  Size: 760 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 MiB

After

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 MiB

After

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 MiB

After

Width:  |  Height:  |  Size: 1.1 MiB

Some files were not shown because too many files have changed in this diff Show More