diff --git a/mvnw b/mvnw old mode 100755 new mode 100644 diff --git a/src/main/java/it/polimi/ingsw/gc14/View/GUI/GUI.java b/src/main/java/it/polimi/ingsw/gc14/View/GUI/GUI.java index 7c32b35..9eaa70e 100644 --- a/src/main/java/it/polimi/ingsw/gc14/View/GUI/GUI.java +++ b/src/main/java/it/polimi/ingsw/gc14/View/GUI/GUI.java @@ -10,13 +10,14 @@ import javafx.stage.Stage; public class GUI implements IView { // stessa interfaccia che implementa TUI private final Stage stage; - private final MainView mainView = new MainView(); + private final MainView mainView; private Game model; private ClientController controller; private String username; public GUI(Stage stage) { this.stage = stage; + this.mainView = new MainView(); } @Override 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 4fd4ae1..c31cb79 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 @@ -2,6 +2,7 @@ package it.polimi.ingsw.gc14.View.GUI; import it.polimi.ingsw.gc14.Controller.ClientController; 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.Player; import it.polimi.ingsw.gc14.Model.Slot; @@ -9,11 +10,15 @@ import javafx.beans.value.ChangeListener; import javafx.beans.value.ObservableValue; import javafx.fxml.FXML; import javafx.geometry.Bounds; +import javafx.geometry.Insets; import javafx.geometry.Pos; import javafx.scene.control.Button; +import javafx.scene.control.Label; import javafx.scene.image.*; import javafx.scene.layout.*; import javafx.scene.shape.*; +import javafx.scene.text.Font; +import javafx.stage.Popup; import java.util.ArrayList; import java.util.List; @@ -21,18 +26,25 @@ import java.util.Map; public class MainFXMLController { + @FXML private HBox mainHBox; @FXML private HBox board; @FXML private HBox upperList; @FXML private HBox lowerList; @FXML private HBox myHand; @FXML private VBox playersHand; - @FXML private Button reload; + private Popup popup; + private HBox popupCards; private Game model; private ClientController controller; private String username; + @FXML + public void initialize() { + initPopup(); + } + public void setModel(Game model) { this.model = model; } @@ -41,7 +53,7 @@ public class MainFXMLController { public void render() { - + //mainHBox.setBackground(new Background(new BackgroundImage(new Image(getClass().getResourceAsStream("/GUIImages/Background.png")), null, null, null, null))); // Upper list upperList.setSpacing(6); upperList.setAlignment(Pos.CENTER); @@ -51,14 +63,13 @@ public class MainFXMLController { for (TribeCard card : model.getUpperListTribeCards()) { final int index = i; - Image tribeImg = new Image(getClass().getResourceAsStream("/GUIImages/Fronts/card-" + card.getIdIMG() + ".png")); - ImageView view = new ImageView(tribeImg); - view.fitHeightProperty().bind(upperList.heightProperty().subtract(10)); - view.setPreserveRatio(true); + ImageView img = new ImageView(new Image(getClass().getResourceAsStream("/GUIImages/Fronts/card-" + card.getIdIMG() + ".png"))); + img.fitHeightProperty().bind(upperList.heightProperty().subtract(10)); + img.setPreserveRatio(true); - view.setOnMouseClicked(e -> controller.drawUpperTribeCard(username, index)); + img.setOnMouseClicked(e -> controller.drawUpperTribeCard(username, index)); - upperList.getChildren().add(view); + upperList.getChildren().add(img); i++; } @@ -73,15 +84,14 @@ public class MainFXMLController { Slot slot = entry.getKey(); final int index = i; - Image slotImg = new Image(getClass().getResourceAsStream("/GUIImages/Fronts/card-"+slot.getSlotId()+".png")); - ImageView view = new ImageView(slotImg); + ImageView img = new ImageView(new Image(getClass().getResourceAsStream("/GUIImages/Fronts/card-"+slot.getSlotId()+".png"))); - view.fitHeightProperty().bind(board.heightProperty().subtract(10)); - view.setPreserveRatio(true); + img.fitHeightProperty().bind(board.heightProperty().subtract(10)); + img.setPreserveRatio(true); - view.setOnMouseClicked(e -> controller.slotChoice(username, index)); + img.setOnMouseClicked(e -> controller.slotChoice(username, index)); - board.getChildren().add(view); + board.getChildren().add(img); i++; } @@ -96,14 +106,13 @@ public class MainFXMLController { for (TribeCard card : model.getLowerListTribeCards()) { final int index = i; - Image tribeImg = new Image(getClass().getResourceAsStream("/GUIImages/Fronts/card-" + card.getIdIMG() + ".png")); - ImageView view = new ImageView(tribeImg); - view.fitHeightProperty().bind(lowerList.heightProperty().subtract(10)); - view.setPreserveRatio(true); + ImageView img = new ImageView(new Image(getClass().getResourceAsStream("/GUIImages/Fronts/card-" + card.getIdIMG() + ".png"))); + img.fitHeightProperty().bind(lowerList.heightProperty().subtract(10)); + img.setPreserveRatio(true); - view.setOnMouseClicked(e -> controller.drawLowerTribeCard(username, index)); + img.setOnMouseClicked(e -> controller.drawLowerTribeCard(username, index)); - lowerList.getChildren().add(view); + lowerList.getChildren().add(img); i++; } @@ -111,159 +120,79 @@ public class MainFXMLController { // My hand myHand.getChildren().clear(); myHand.setSpacing(6); - //myHand.setAlignment(Pos.CENTER_LEFT); + myHand.setAlignment(Pos.CENTER); - 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)); + drawMyHandCard(myHand, model.getPlayerByUsername(username).artists); + drawMyHandCard(myHand, model.getPlayerByUsername(username).gatherers); + drawMyHandCard(myHand, model.getPlayerByUsername(username).inventors); + drawMyHandCard(myHand, model.getPlayerByUsername(username).builders); + drawMyHandCard(myHand, model.getPlayerByUsername(username).shamans); + drawMyHandCard(myHand, model.getPlayerByUsername(username).hunters); + } - /** - // 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 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)); + img.setPreserveRatio(true); - 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++; + 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); + + StackPane stack = new StackPane(img, label); + stack.setClip(null); + stack.setOnMouseClicked(e -> openPopup(cardList)); + + myHand.getChildren().add(stack); } - 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 popup.hide()); + VBox content = new VBox(10, closeBtn, popupCards); + content.setPadding(new Insets(20)); + content.setStyle("-fx-background-color: #222; -fx-border-color: white; -fx-border-width: 2; -fx-border-radius: 10; -fx-background-radius: 10;"); - private Pane createCardPane(List 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() { - @Override - public void changed(ObservableValue obs, Bounds old, Bounds bounds) { - if (bounds.getWidth() > 0) { - pane.setPrefWidth(bounds.getWidth() + (n - 1) * 50); - view.layoutBoundsProperty().removeListener(this); - } - } - }); - } - } - return pane; + popup = new Popup(); + popup.getContent().add(content); + popup.setAutoHide(true); // si chiude anche cliccando fuori } + + private void openPopup(ArrayList cardList) { + popupCards.getChildren().clear(); + + for (TribeCard card : cardList) { + ImageView img = new ImageView(new Image(getClass().getResourceAsStream( + "/GUIImages/Fronts/card-" + card.getIdIMG() + ".png"))); + img.setFitHeight(200); + img.setPreserveRatio(true); + popupCards.getChildren().add(img); + } + + javafx.stage.Window window = myHand.getScene().getWindow(); + + // Mostralo prima fuori schermo + popup.show(window, 0, 0); + + // Poi centralo con le dimensioni reali + double x = window.getX() + (window.getWidth() - popup.getWidth()) / 2; + double y = window.getY() + (window.getHeight() - popup.getHeight()) / 2; + popup.setX(x); + popup.setY(y); + } + + } diff --git a/src/main/resources/Fonts/InknutAntiqua-Black.ttf b/src/main/resources/Fonts/InknutAntiqua-Black.ttf new file mode 100644 index 0000000..e4e1b09 Binary files /dev/null and b/src/main/resources/Fonts/InknutAntiqua-Black.ttf differ diff --git a/src/main/resources/Fonts/InknutAntiqua-Bold.ttf b/src/main/resources/Fonts/InknutAntiqua-Bold.ttf new file mode 100644 index 0000000..a926d32 Binary files /dev/null and b/src/main/resources/Fonts/InknutAntiqua-Bold.ttf differ diff --git a/src/main/resources/Fonts/InknutAntiqua-ExtraBold.ttf b/src/main/resources/Fonts/InknutAntiqua-ExtraBold.ttf new file mode 100644 index 0000000..62340b2 Binary files /dev/null and b/src/main/resources/Fonts/InknutAntiqua-ExtraBold.ttf differ diff --git a/src/main/resources/Fonts/InknutAntiqua-Light.ttf b/src/main/resources/Fonts/InknutAntiqua-Light.ttf new file mode 100644 index 0000000..b986946 Binary files /dev/null and b/src/main/resources/Fonts/InknutAntiqua-Light.ttf differ diff --git a/src/main/resources/Fonts/InknutAntiqua-Medium.ttf b/src/main/resources/Fonts/InknutAntiqua-Medium.ttf new file mode 100644 index 0000000..7c452a2 Binary files /dev/null and b/src/main/resources/Fonts/InknutAntiqua-Medium.ttf differ diff --git a/src/main/resources/Fonts/InknutAntiqua-Regular.ttf b/src/main/resources/Fonts/InknutAntiqua-Regular.ttf new file mode 100644 index 0000000..241f222 Binary files /dev/null and b/src/main/resources/Fonts/InknutAntiqua-Regular.ttf differ diff --git a/src/main/resources/Fonts/InknutAntiqua-SemiBold.ttf b/src/main/resources/Fonts/InknutAntiqua-SemiBold.ttf new file mode 100644 index 0000000..d169a5c Binary files /dev/null and b/src/main/resources/Fonts/InknutAntiqua-SemiBold.ttf differ diff --git a/src/main/resources/Fonts/OFL.txt b/src/main/resources/Fonts/OFL.txt new file mode 100644 index 0000000..0dccedd --- /dev/null +++ b/src/main/resources/Fonts/OFL.txt @@ -0,0 +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. diff --git a/src/main/resources/GUIImages/Background.png b/src/main/resources/GUIImages/Background.png new file mode 100644 index 0000000..45bd2f5 Binary files /dev/null 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 2a5b6c7..9b67da2 100644 --- a/src/main/resources/GUIScene/main.fxml +++ b/src/main/resources/GUIScene/main.fxml @@ -4,18 +4,17 @@ - - + - - - - + + + + - +