Add: other players, text, background, style
This commit is contained in:
Generated
+1
-1
@@ -8,7 +8,7 @@
|
|||||||
</list>
|
</list>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_25" default="true" project-jdk-name="25" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_26" default="true" project-jdk-name="openjdk-26" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/out" />
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
@@ -1,9 +1,11 @@
|
|||||||
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.Cards.BuildingCard;
|
||||||
import it.polimi.ingsw.gc14.Model.Cards.TribeCard;
|
import it.polimi.ingsw.gc14.Model.Cards.TribeCard;
|
||||||
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters.*;
|
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters.*;
|
||||||
import it.polimi.ingsw.gc14.Model.Game;
|
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.Player;
|
||||||
import it.polimi.ingsw.gc14.Model.Slot;
|
import it.polimi.ingsw.gc14.Model.Slot;
|
||||||
import javafx.beans.value.ChangeListener;
|
import javafx.beans.value.ChangeListener;
|
||||||
@@ -33,6 +35,11 @@ public class MainFXMLController {
|
|||||||
@FXML private HBox myHand;
|
@FXML private HBox myHand;
|
||||||
@FXML private VBox playersHand;
|
@FXML private VBox playersHand;
|
||||||
@FXML private Button reload;
|
@FXML private Button reload;
|
||||||
|
@FXML private HBox INFO;
|
||||||
|
@FXML private Label era;
|
||||||
|
@FXML private Label round;
|
||||||
|
@FXML private Label player;
|
||||||
|
|
||||||
private Popup popup;
|
private Popup popup;
|
||||||
private HBox popupCards;
|
private HBox popupCards;
|
||||||
|
|
||||||
@@ -52,9 +59,25 @@ public class MainFXMLController {
|
|||||||
public void setUsername(String username) {this.username = username;}
|
public void setUsername(String username) {this.username = username;}
|
||||||
|
|
||||||
public void render() {
|
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.setSpacing(6);
|
||||||
upperList.setAlignment(Pos.CENTER);
|
upperList.setAlignment(Pos.CENTER);
|
||||||
upperList.getChildren().clear();
|
upperList.getChildren().clear();
|
||||||
@@ -73,6 +96,20 @@ public class MainFXMLController {
|
|||||||
i++;
|
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
|
||||||
board.setSpacing(6);
|
board.setSpacing(6);
|
||||||
@@ -116,6 +153,20 @@ public class MainFXMLController {
|
|||||||
i++;
|
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
|
// My hand
|
||||||
myHand.getChildren().clear();
|
myHand.getChildren().clear();
|
||||||
@@ -128,11 +179,26 @@ public class MainFXMLController {
|
|||||||
drawMyHandCard(myHand, model.getPlayerByUsername(username).builders);
|
drawMyHandCard(myHand, model.getPlayerByUsername(username).builders);
|
||||||
drawMyHandCard(myHand, model.getPlayerByUsername(username).shamans);
|
drawMyHandCard(myHand, model.getPlayerByUsername(username).shamans);
|
||||||
drawMyHandCard(myHand, model.getPlayerByUsername(username).hunters);
|
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()) {
|
if (!cardList.isEmpty()) {
|
||||||
ImageView img = new ImageView(new Image(getClass().getResourceAsStream("/GUIImages/Fronts/card-" + cardList.getLast().getIdIMG() + ".png")));
|
ImageView img = new ImageView(new Image(getClass().getResourceAsStream("/GUIImages/Fronts/card-" + cardList.getLast().getIdIMG() + ".png")));
|
||||||
img.fitHeightProperty().bind(myHand.heightProperty().subtract(10));
|
img.fitHeightProperty().bind(myHand.heightProperty().subtract(10));
|
||||||
@@ -141,7 +207,6 @@ public class MainFXMLController {
|
|||||||
Label label = new Label(String.valueOf(cardList.size()));
|
Label label = new Label(String.valueOf(cardList.size()));
|
||||||
label.setTranslateY(-55);
|
label.setTranslateY(-55);
|
||||||
label.setTranslateX(10);
|
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;");
|
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);
|
StackPane.setAlignment(label, Pos.TOP_RIGHT);
|
||||||
|
|
||||||
@@ -171,10 +236,10 @@ public class MainFXMLController {
|
|||||||
popup.setAutoHide(true); // si chiude anche cliccando fuori
|
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();
|
popupCards.getChildren().clear();
|
||||||
|
|
||||||
for (TribeCard card : cardList) {
|
for (PlayableCard card : cardList) {
|
||||||
ImageView img = new ImageView(new Image(getClass().getResourceAsStream(
|
ImageView img = new ImageView(new Image(getClass().getResourceAsStream(
|
||||||
"/GUIImages/Fronts/card-" + card.getIdIMG() + ".png")));
|
"/GUIImages/Fronts/card-" + card.getIdIMG() + ".png")));
|
||||||
img.setFitHeight(200);
|
img.setFitHeight(200);
|
||||||
@@ -194,5 +259,50 @@ public class MainFXMLController {
|
|||||||
popup.setY(y);
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 2.7 MiB After Width: | Height: | Size: 6.2 MiB |
@@ -1,22 +1,62 @@
|
|||||||
<?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?>
|
||||||
|
|
||||||
<HBox fx:id="mainHBox" 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" >
|
<HBox fx:id="mainHBox" 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">
|
||||||
<children>
|
<children>
|
||||||
<HBox fx:id="upperList" prefHeight="255.0" prefWidth="200.0" />
|
<HBox fx:id="upperList" prefHeight="250.0" prefWidth="200.0" style="-fx-background-color: rgba(255,255,255,0.35); -fx-background-radius: 15;">
|
||||||
<HBox fx:id="board" prefHeight="300.0" prefWidth="200.0" />
|
<VBox.margin>
|
||||||
<HBox fx:id="lowerList" prefHeight="255.0" prefWidth="200.0" />
|
<Insets top="5" right="5" bottom="5" left="5" />
|
||||||
<HBox fx:id="myHand" prefHeight="270.0" prefWidth="1324.0" />
|
</VBox.margin>
|
||||||
|
</HBox>
|
||||||
|
<HBox fx:id="board" prefHeight="330.0" prefWidth="200.0" style="-fx-background-color: rgba(255,255,255,0.35); -fx-background-radius: 15;">
|
||||||
|
<VBox.margin>
|
||||||
|
<Insets top="5" right="5" bottom="5" left="5" />
|
||||||
|
</VBox.margin>
|
||||||
|
</HBox>
|
||||||
|
<HBox fx:id="lowerList" prefHeight="250.0" prefWidth="200.0" style="-fx-background-color: rgba(255,255,255,0.35); -fx-background-radius: 15;">
|
||||||
|
<VBox.margin>
|
||||||
|
<Insets top="5" right="5" bottom="5" left="5" />
|
||||||
|
</VBox.margin>
|
||||||
|
</HBox>
|
||||||
|
<HBox fx:id="myHand" prefHeight="250.0" prefWidth="200.0" style="-fx-background-color: rgba(255,255,255,0.35); -fx-background-radius: 15;">
|
||||||
|
<VBox.margin>
|
||||||
|
<Insets top="5" right="5" bottom="5" left="5" />
|
||||||
|
</VBox.margin>
|
||||||
|
</HBox> </children>
|
||||||
|
</VBox>
|
||||||
|
<VBox fx:id="playersHand" prefHeight="1080.0" prefWidth="531.0" style="-fx-background-color: rgba(255,255,255,0.35); -fx-background-radius: 15;">
|
||||||
|
<HBox.margin>
|
||||||
|
<Insets bottom="10" left="10" right="10" top="10" />
|
||||||
|
</HBox.margin>
|
||||||
|
<children>
|
||||||
|
<HBox fx:id="INFO" prefHeight="107.0" prefWidth="483.0">
|
||||||
|
<children>
|
||||||
|
<VBox alignment="CENTER" prefHeight="107.0" prefWidth="161.0" spacing="2">
|
||||||
|
<children>
|
||||||
|
<Label style="-fx-font-family: 'Inknut Antiqua'; -fx-font-size: 11px; -fx-text-fill: gray;" text="ERA" />
|
||||||
|
<Label fx:id="era" style="-fx-font-family: 'Inknut Antiqua'; -fx-font-size: 18px; -fx-font-weight: bold;" text="VALORE" />
|
||||||
</children>
|
</children>
|
||||||
</VBox>
|
</VBox>
|
||||||
<VBox fx:id="playersHand" prefHeight="1080.0" prefWidth="531.0" style="-fx-background-color: white;">
|
<VBox alignment="CENTER" prefHeight="107.0" prefWidth="161.0" spacing="2">
|
||||||
<children>
|
<children>
|
||||||
<Button fx:id="reload" mnemonicParsing="false" onAction="#render" prefHeight="335.0" prefWidth="510.0" text="Reload" />
|
<Label style="-fx-font-size: 11px; -fx-text-fill: gray;" text="ROUND" />
|
||||||
|
<Label fx:id="round" style="-fx-font-size: 18px; -fx-font-weight: bold;" text="VALORE" />
|
||||||
|
</children>
|
||||||
|
</VBox>
|
||||||
|
<VBox alignment="CENTER" prefHeight="107.0" prefWidth="161.0" spacing="2">
|
||||||
|
<children>
|
||||||
|
<Label style="-fx-font-size: 11px; -fx-text-fill: gray;" text="PLAYER" />
|
||||||
|
<Label fx:id="player" style="-fx-font-size: 18px; -fx-font-weight: bold;" text="VALORE" />
|
||||||
|
</children>
|
||||||
|
</VBox>
|
||||||
|
</children>
|
||||||
|
</HBox>
|
||||||
</children></VBox>
|
</children></VBox>
|
||||||
</children>
|
</children>
|
||||||
</HBox>
|
</HBox>
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
@font-face {
|
||||||
|
src: url('/Fonts/InknutAntiqua-Regular.ttf');
|
||||||
|
font-family: 'Inknut Antiqua';
|
||||||
|
}
|
||||||
|
|
||||||
|
.label {
|
||||||
|
-fx-font-family: 'Inknut Antiqua';
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user