Add: other players, text, background, style
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
package it.polimi.ingsw.gc14.View.GUI;
|
||||
|
||||
import it.polimi.ingsw.gc14.Controller.ClientController;
|
||||
import it.polimi.ingsw.gc14.Model.Cards.BuildingCard;
|
||||
import it.polimi.ingsw.gc14.Model.Cards.TribeCard;
|
||||
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters.*;
|
||||
import it.polimi.ingsw.gc14.Model.Game;
|
||||
import it.polimi.ingsw.gc14.Model.PlayableCard;
|
||||
import it.polimi.ingsw.gc14.Model.Player;
|
||||
import it.polimi.ingsw.gc14.Model.Slot;
|
||||
import javafx.beans.value.ChangeListener;
|
||||
@@ -33,6 +35,11 @@ public class MainFXMLController {
|
||||
@FXML private HBox myHand;
|
||||
@FXML private VBox playersHand;
|
||||
@FXML private Button reload;
|
||||
@FXML private HBox INFO;
|
||||
@FXML private Label era;
|
||||
@FXML private Label round;
|
||||
@FXML private Label player;
|
||||
|
||||
private Popup popup;
|
||||
private HBox popupCards;
|
||||
|
||||
@@ -52,9 +59,25 @@ public class MainFXMLController {
|
||||
public void setUsername(String username) {this.username = username;}
|
||||
|
||||
public void render() {
|
||||
Font.loadFont(getClass().getResourceAsStream("/Fonts/InknutAntiqua-Regular.ttf"), 16);
|
||||
|
||||
//mainHBox.setBackground(new Background(new BackgroundImage(new Image(getClass().getResourceAsStream("/GUIImages/Background.png")), null, null, null, null)));
|
||||
// Upper list
|
||||
|
||||
BackgroundSize size = new BackgroundSize(
|
||||
BackgroundSize.AUTO, // width
|
||||
BackgroundSize.AUTO, // height
|
||||
false, // widthAsPercentage
|
||||
false, // heightAsPercentage
|
||||
true, // contain
|
||||
true // cover ← questo è quello che ti serve
|
||||
);
|
||||
|
||||
mainHBox.setBackground(new Background(new BackgroundImage(
|
||||
new Image(getClass().getResourceAsStream("/GUIImages/Background.png")),
|
||||
BackgroundRepeat.NO_REPEAT,
|
||||
BackgroundRepeat.NO_REPEAT,
|
||||
BackgroundPosition.CENTER,
|
||||
size
|
||||
))); // Upper list
|
||||
upperList.setSpacing(6);
|
||||
upperList.setAlignment(Pos.CENTER);
|
||||
upperList.getChildren().clear();
|
||||
@@ -73,6 +96,20 @@ public class MainFXMLController {
|
||||
i++;
|
||||
}
|
||||
|
||||
i = 0;
|
||||
for (BuildingCard card : model.getUpperListBuilding()) {
|
||||
final int index = i;
|
||||
|
||||
ImageView img = new ImageView(new Image(getClass().getResourceAsStream("/GUIImages/Fronts/card-" + card.getIdIMG() + ".png")));
|
||||
img.fitHeightProperty().bind(upperList.heightProperty().subtract(10));
|
||||
img.setPreserveRatio(true);
|
||||
|
||||
img.setOnMouseClicked(e -> controller.drawUpperBuildingCard(username, index));
|
||||
|
||||
upperList.getChildren().add(img);
|
||||
i++;
|
||||
}
|
||||
|
||||
|
||||
// Board
|
||||
board.setSpacing(6);
|
||||
@@ -116,6 +153,20 @@ public class MainFXMLController {
|
||||
i++;
|
||||
}
|
||||
|
||||
i = 0;
|
||||
for (BuildingCard card : model.getLowerListBuilding()) {
|
||||
final int index = i;
|
||||
|
||||
ImageView img = new ImageView(new Image(getClass().getResourceAsStream("/GUIImages/Fronts/card-" + card.getIdIMG() + ".png")));
|
||||
img.fitHeightProperty().bind(lowerList.heightProperty().subtract(10));
|
||||
img.setPreserveRatio(true);
|
||||
|
||||
img.setOnMouseClicked(e -> controller.drawLowerBuildingCard(username, index));
|
||||
|
||||
lowerList.getChildren().add(img);
|
||||
i++;
|
||||
}
|
||||
|
||||
|
||||
// My hand
|
||||
myHand.getChildren().clear();
|
||||
@@ -128,11 +179,26 @@ public class MainFXMLController {
|
||||
drawMyHandCard(myHand, model.getPlayerByUsername(username).builders);
|
||||
drawMyHandCard(myHand, model.getPlayerByUsername(username).shamans);
|
||||
drawMyHandCard(myHand, model.getPlayerByUsername(username).hunters);
|
||||
drawMyHandCard(myHand, model.getPlayerByUsername(username).buildingCards);
|
||||
|
||||
|
||||
// Other players and info
|
||||
playersHand.getChildren().clear();
|
||||
era.setText(Integer.toString(model.getCurrentState().getEra()));
|
||||
round.setText(Integer.toString(model.getCurrentState().getRound()));
|
||||
player.setText(model.getCurrentState().getCurrentPlayer().getUserName());
|
||||
era.setStyle("-fx-font-family: 'Inknut Antiqua'; -fx-font-size: 20px; -fx-font-weight: bold; -fx-text-fill: black;");
|
||||
round.setStyle("-fx-font-family: 'Inknut Antiqua'; -fx-font-size: 20px; -fx-font-weight: bold; -fx-text-fill: black;");
|
||||
player.setStyle("-fx-font-family: 'Inknut Antiqua'; -fx-font-size: 20px; -fx-font-weight: bold; -fx-text-fill: black;");
|
||||
//INFO.getChildren().;
|
||||
//INFO.getChildren().add(round);
|
||||
//INFO.getChildren().add(player);
|
||||
playersHand.getChildren().add(INFO);
|
||||
renderPlayers(playersHand);
|
||||
|
||||
}
|
||||
|
||||
void drawMyHandCard(HBox myHand, ArrayList<? extends TribeCard> cardList) {
|
||||
void drawMyHandCard(HBox myHand, ArrayList<? extends PlayableCard> cardList) {
|
||||
if (!cardList.isEmpty()) {
|
||||
ImageView img = new ImageView(new Image(getClass().getResourceAsStream("/GUIImages/Fronts/card-" + cardList.getLast().getIdIMG() + ".png")));
|
||||
img.fitHeightProperty().bind(myHand.heightProperty().subtract(10));
|
||||
@@ -141,7 +207,6 @@ public class MainFXMLController {
|
||||
Label label = new Label(String.valueOf(cardList.size()));
|
||||
label.setTranslateY(-55);
|
||||
label.setTranslateX(10);
|
||||
Font.loadFont(getClass().getResourceAsStream("/Fonts/InknutAntiqua-Regular.ttf"), 16);
|
||||
label.setStyle("-fx-font-family: 'Inknut Antiqua'; -fx-font-size: 50px; -fx-font-weight: bold; -fx-text-fill: black;");
|
||||
StackPane.setAlignment(label, Pos.TOP_RIGHT);
|
||||
|
||||
@@ -171,10 +236,10 @@ public class MainFXMLController {
|
||||
popup.setAutoHide(true); // si chiude anche cliccando fuori
|
||||
}
|
||||
|
||||
private void openPopup(ArrayList<? extends TribeCard> cardList) {
|
||||
private void openPopup(ArrayList<? extends PlayableCard> cardList) {
|
||||
popupCards.getChildren().clear();
|
||||
|
||||
for (TribeCard card : cardList) {
|
||||
for (PlayableCard card : cardList) {
|
||||
ImageView img = new ImageView(new Image(getClass().getResourceAsStream(
|
||||
"/GUIImages/Fronts/card-" + card.getIdIMG() + ".png")));
|
||||
img.setFitHeight(200);
|
||||
@@ -194,5 +259,50 @@ public class MainFXMLController {
|
||||
popup.setY(y);
|
||||
}
|
||||
|
||||
private void renderPlayers(VBox playersHand) {
|
||||
for (Player player : model.getPlayers()) {
|
||||
VBox card = new VBox(5);
|
||||
card.setAlignment(javafx.geometry.Pos.CENTER);
|
||||
card.setPrefWidth(150);
|
||||
card.setPrefHeight(100);
|
||||
card.setStyle(
|
||||
"-fx-border-color: black;" +
|
||||
"-fx-border-width: 2;" +
|
||||
"-fx-border-radius: 8;" +
|
||||
"-fx-background-radius: 8;" +
|
||||
"-fx-background-color: white;" +
|
||||
"-fx-padding: 10;"
|
||||
);
|
||||
|
||||
|
||||
Label usernameLabel = new Label(player.getUserName());
|
||||
if(player.getUserName().equals(username)) {
|
||||
usernameLabel.setStyle("-fx-font-family: 'Inknut Antiqua'; -fx-font-size: 16px; -fx-font-weight: bold; -fx-text-fill: #c40501;");
|
||||
} else {
|
||||
usernameLabel.setStyle("-fx-font-family: 'Inknut Antiqua'; -fx-font-size: 16px; -fx-font-weight: bold;");
|
||||
}
|
||||
|
||||
Label foodLabel = new Label("Food: " + player.getFoodValue());
|
||||
foodLabel.setStyle("-fx-font-family: 'Inknut Antiqua'; -fx-font-size: 12px; -fx-font-weight: bold; ");
|
||||
|
||||
Label prestigeLabel = new Label("Prestige: " + player.getPrestigeValue());
|
||||
prestigeLabel.setStyle("-fx-font-family: 'Inknut Antiqua'; -fx-font-size: 12px; -fx-font-weight: bold; ");
|
||||
|
||||
card.getChildren().addAll(usernameLabel, foodLabel, prestigeLabel);
|
||||
|
||||
ArrayList<PlayableCard> playerCard = new ArrayList<>();
|
||||
playerCard.addAll(model.getPlayerByUsername(player.getUserName()).artists);
|
||||
playerCard.addAll(model.getPlayerByUsername(player.getUserName()).gatherers);
|
||||
playerCard.addAll(model.getPlayerByUsername(player.getUserName()).inventors);
|
||||
playerCard.addAll(model.getPlayerByUsername(player.getUserName()).builders);
|
||||
playerCard.addAll(model.getPlayerByUsername(player.getUserName()).shamans);
|
||||
playerCard.addAll(model.getPlayerByUsername(player.getUserName()).hunters);
|
||||
playerCard.addAll(model.getPlayerByUsername(player.getUserName()).buildingCards);
|
||||
|
||||
card.setOnMouseClicked(e -> openPopup(playerCard));
|
||||
playersHand.getChildren().add(card);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user