Add: other players, text, background, style

This commit is contained in:
2026-05-10 12:19:30 +02:00
parent be1b746363
commit 558f5b8d9c
6 changed files with 267 additions and 109 deletions
+1 -1
View File
@@ -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);
}
}
} }
+93 -93
View File
@@ -1,93 +1,93 @@
Copyright (c) 2014 Claus Eggers Sørensen (es@forthehearts.net) 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 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: This license is copied below, and is also available with a FAQ at:
https://openfontlicense.org https://openfontlicense.org
----------------------------------------------------------- -----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
----------------------------------------------------------- -----------------------------------------------------------
PREAMBLE PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership open framework in which fonts may be shared and improved in partnership
with others. with others.
The OFL allows the licensed fonts to be used, studied, modified and The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded, fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives, names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives. to any document created using the fonts or their derivatives.
DEFINITIONS DEFINITIONS
"Font Software" refers to the set of files released by the Copyright "Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation. include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the "Reserved Font Name" refers to any names specified as such after the
copyright statement(s). copyright statement(s).
"Original Version" refers to the collection of Font Software components as "Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s). distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting, "Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the 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 Original Version, by changing formats or by porting the Font Software to a
new environment. new environment.
"Author" refers to any designer, engineer, programmer, technical "Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software. writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify, a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions: Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components, 1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself. in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled, 2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text 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. 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 3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as Copyright Holder. This restriction only applies to the primary font name as
presented to the users. presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font 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 Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written Copyright Holder(s) and the Author(s) or with their explicit written
permission. permission.
5) The Font Software, modified or unmodified, in part or in whole, 5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created remain under this license does not apply to any document created
using the Font Software. using the Font Software.
TERMINATION TERMINATION
This license becomes null and void if any of the above conditions are This license becomes null and void if any of the above conditions are
not met. not met.
DISCLAIMER DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 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 FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE. OTHER DEALINGS IN THE FONT SOFTWARE.
Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 MiB

After

Width:  |  Height:  |  Size: 6.2 MiB

+49 -9
View File
@@ -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>
</children> </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>
<VBox fx:id="playersHand" prefHeight="1080.0" prefWidth="531.0" style="-fx-background-color: white;"> <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> <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">
<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>
</VBox>
<VBox alignment="CENTER" prefHeight="107.0" prefWidth="161.0" spacing="2">
<children>
<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>
+8
View File
@@ -0,0 +1,8 @@
@font-face {
src: url('/Fonts/InknutAntiqua-Regular.ttf');
font-family: 'Inknut Antiqua';
}
.label {
-fx-font-family: 'Inknut Antiqua';
}