diff --git a/.idea/misc.xml b/.idea/misc.xml index 0c04b52..078a25f 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -8,7 +8,7 @@ - + \ No newline at end of file diff --git a/src/main/java/it/polimi/ingsw/gc14/View/GUI/MainFXMLController.java b/src/main/java/it/polimi/ingsw/gc14/View/GUI/MainFXMLController.java index c31cb79..ed3c56d 100644 --- a/src/main/java/it/polimi/ingsw/gc14/View/GUI/MainFXMLController.java +++ b/src/main/java/it/polimi/ingsw/gc14/View/GUI/MainFXMLController.java @@ -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 cardList) { + void drawMyHandCard(HBox myHand, ArrayList 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 cardList) { + private void openPopup(ArrayList 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 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); + } + } + } diff --git a/src/main/resources/Fonts/OFL.txt b/src/main/resources/Fonts/OFL.txt index 0dccedd..f18e45d 100644 --- a/src/main/resources/Fonts/OFL.txt +++ b/src/main/resources/Fonts/OFL.txt @@ -1,93 +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. +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. diff --git a/src/main/resources/GUIImages/Background.png b/src/main/resources/GUIImages/Background.png index 45bd2f5..f342e39 100644 Binary files a/src/main/resources/GUIImages/Background.png and b/src/main/resources/GUIImages/Background.png differ diff --git a/src/main/resources/GUIScene/main.fxml b/src/main/resources/GUIScene/main.fxml index 9b67da2..4d70c44 100644 --- a/src/main/resources/GUIScene/main.fxml +++ b/src/main/resources/GUIScene/main.fxml @@ -1,22 +1,62 @@ - + + - + - - - - - + + + + + + + + + + + + + + + + + + + + - + + + + -