order, totems, visual effects
@@ -84,7 +84,7 @@ public class Game implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* The order logic card associated with this game.
|
* The order logic card associated with this game.
|
||||||
*/
|
*/
|
||||||
private OrderLogicCard orderLogicCard;
|
public OrderLogicCard orderLogicCard;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The board associated with this game.
|
* The board associated with this game.
|
||||||
|
|||||||
@@ -109,16 +109,17 @@ public abstract class OrderLogicCard implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* TODO rifare javadoc
|
||||||
* Returns the {@code Player}'s position based on it's {@code Username}.
|
* Returns the {@code Player}'s position based on it's {@code Username}.
|
||||||
* @param username The desired {@code Player}'s username.
|
* @param username The desired {@code Player}'s username.
|
||||||
* @return {@code int} - the {@code Player}'s position.
|
* @return {@code int} - the {@code Player}'s position.
|
||||||
* @see Player
|
* @see Player
|
||||||
*/
|
*/
|
||||||
protected int getPosition(String username)
|
public int getPosition(String username)
|
||||||
{
|
{
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
for (Player p : players) {
|
for (OrderPlayer p : playerList) {
|
||||||
if (p.getUserName().equals(username))
|
if (p.player.getUserName().equals(username))
|
||||||
return pos;
|
return pos;
|
||||||
pos++;
|
pos++;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,9 @@
|
|||||||
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.*;
|
||||||
import it.polimi.ingsw.gc14.Model.Cards.BuildingCard;
|
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.Game;
|
|
||||||
import it.polimi.ingsw.gc14.Model.PlayableCard;
|
|
||||||
import it.polimi.ingsw.gc14.Model.Player;
|
|
||||||
import it.polimi.ingsw.gc14.Model.Slot;
|
|
||||||
import javafx.animation.ScaleTransition;
|
import javafx.animation.ScaleTransition;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.geometry.Insets;
|
import javafx.geometry.Insets;
|
||||||
@@ -86,18 +82,56 @@ public class MainFXMLController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ==== HELPER ====
|
// ==== HELPER ====
|
||||||
private ImageView createSlot(Slot slot) {
|
private StackPane createOrder(String num, boolean withZoom, boolean withShadow) {
|
||||||
ImageView img = new ImageView(new Image(getClass().getResourceAsStream("/GUIImages/Fronts/card-"+slot.getSlotId()+".png")));
|
ImageView img = new ImageView(new Image(getClass().getResourceAsStream("/GUIImages/Orders/order-" + num + ".png")));
|
||||||
img.setFitHeight(240);
|
img.setFitHeight(240);
|
||||||
img.setPreserveRatio(true);
|
img.setPreserveRatio(true);
|
||||||
|
|
||||||
Rectangle clip = new Rectangle();
|
Rectangle clip = new Rectangle();
|
||||||
clip.setWidth(img.getBoundsInLocal().getWidth());
|
clip.setWidth(img.getBoundsInLocal().getWidth());
|
||||||
clip.setHeight(240);
|
clip.setHeight(240);
|
||||||
clip.setArcWidth(20);
|
clip.setArcWidth(20);
|
||||||
clip.setArcHeight(20);
|
clip.setArcHeight(20);
|
||||||
img.setClip(clip);
|
img.setClip(clip);
|
||||||
return img;
|
StackPane wrapper = new StackPane(img);
|
||||||
|
if (withShadow) {
|
||||||
|
addShadow(wrapper);
|
||||||
|
}
|
||||||
|
if (withZoom) {
|
||||||
|
addHoverZoom(wrapper);
|
||||||
|
}
|
||||||
|
return wrapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
private StackPane createSlot(Slot slot, boolean withZoom, boolean withShadow) {
|
||||||
|
ImageView img = new ImageView(new Image(getClass().getResourceAsStream("/GUIImages/Fronts/card-" + slot.getSlotId() + ".png")));
|
||||||
|
img.setFitHeight(240);
|
||||||
|
img.setPreserveRatio(true);
|
||||||
|
Rectangle clip = new Rectangle();
|
||||||
|
clip.setWidth(img.getBoundsInLocal().getWidth());
|
||||||
|
clip.setHeight(240);
|
||||||
|
clip.setArcWidth(20);
|
||||||
|
clip.setArcHeight(20);
|
||||||
|
img.setClip(clip);
|
||||||
|
StackPane wrapper = new StackPane(img);
|
||||||
|
|
||||||
|
Player player = model.getSlotMap().get(slot);
|
||||||
|
if (player != null) {
|
||||||
|
int index = model.getPlayers().indexOf(player);
|
||||||
|
ImageView totem = new ImageView(new Image(getClass().getResourceAsStream("/GUIImages/Totems/totem_" + index + ".png")));
|
||||||
|
totem.setFitHeight(70);
|
||||||
|
totem.setPreserveRatio(true);
|
||||||
|
StackPane.setAlignment(totem, Pos.TOP_LEFT);
|
||||||
|
StackPane.setMargin(totem, new Insets(8, 0, 0, 57));
|
||||||
|
wrapper.getChildren().add(totem);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (withShadow) {
|
||||||
|
addShadow(wrapper);
|
||||||
|
}
|
||||||
|
if (withZoom) {
|
||||||
|
addHoverZoom(wrapper);
|
||||||
|
}
|
||||||
|
return wrapper;
|
||||||
}
|
}
|
||||||
private StackPane createCard(PlayableCard card, boolean withZoom, boolean withShadow) {
|
private StackPane createCard(PlayableCard card, boolean withZoom, boolean withShadow) {
|
||||||
String id = card.getIdIMG();
|
String id = card.getIdIMG();
|
||||||
@@ -201,16 +235,42 @@ public class MainFXMLController {
|
|||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private void renderOrder() {
|
||||||
|
StackPane card = createOrder(Integer.toString(model.getNPlayers()), true, true);
|
||||||
|
|
||||||
|
VBox overlay = new VBox(-20);
|
||||||
|
overlay.setPickOnBounds(false);
|
||||||
|
StackPane.setAlignment(overlay, Pos.TOP_LEFT);
|
||||||
|
StackPane.setMargin(overlay, new Insets(9, 0, 0, 57));
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
for (Player player : model.getPlayers()) {
|
||||||
|
final int index = i;
|
||||||
|
|
||||||
|
ImageView totem = new ImageView(new Image(getClass().getResourceAsStream("/GUIImages/Totems/totem_" + index + ".png")));
|
||||||
|
totem.setFitHeight(70);
|
||||||
|
totem.setPreserveRatio(true);
|
||||||
|
if (!(model.orderLogicCard.getPosition(player.getUserName()) != -1 && !model.getSlotMap().containsValue(player))) {
|
||||||
|
totem.setOpacity(0.0);
|
||||||
|
}
|
||||||
|
overlay.getChildren().add(totem);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
card.getChildren().add(overlay);
|
||||||
|
board.getChildren().add(card);
|
||||||
|
}
|
||||||
private void renderBoard() {
|
private void renderBoard() {
|
||||||
board.setSpacing(14);
|
board.setSpacing(14);
|
||||||
board.setAlignment(Pos.CENTER);
|
board.setAlignment(Pos.CENTER);
|
||||||
board.getChildren().clear();
|
board.getChildren().clear();
|
||||||
|
|
||||||
|
renderOrder();
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (Map.Entry<Slot, Player> entry : model.getSlotMap().entrySet()) {
|
for (Map.Entry<Slot, Player> entry : model.getSlotMap().entrySet()) {
|
||||||
Slot slot = entry.getKey();
|
Slot slot = entry.getKey();
|
||||||
final int index = i;
|
final int index = i;
|
||||||
ImageView img = createSlot(slot);
|
StackPane img = createSlot(slot, true, true);
|
||||||
img.setOnMouseClicked(e -> controller.slotChoice(username, index));
|
img.setOnMouseClicked(e -> controller.slotChoice(username, index));
|
||||||
board.getChildren().add(img);
|
board.getChildren().add(img);
|
||||||
i++;
|
i++;
|
||||||
@@ -289,18 +349,16 @@ public class MainFXMLController {
|
|||||||
}
|
}
|
||||||
private void renderPlayers(VBox playersHand) {
|
private void renderPlayers(VBox playersHand) {
|
||||||
for (Player player : model.getPlayers()) {
|
for (Player player : model.getPlayers()) {
|
||||||
|
if(player.getUserName().equals(username)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
VBox card = new VBox();
|
VBox card = new VBox();
|
||||||
VBox.setMargin(card, new Insets(5, 5, 5, 5));
|
VBox.setMargin(card, new Insets(5, 5, 5, 5));
|
||||||
card.setAlignment(Pos.CENTER);
|
card.setAlignment(Pos.CENTER);
|
||||||
card.getStyleClass().add("player-card");
|
card.getStyleClass().add("player-card");
|
||||||
|
|
||||||
Label usernameLabel;
|
Label usernameLabel = new Label(player.getUserName());
|
||||||
if(player.getUserName().equals(username)) {
|
|
||||||
usernameLabel = new Label(player.getUserName()+" (you)");
|
|
||||||
|
|
||||||
} else {
|
|
||||||
usernameLabel = new Label(player.getUserName());
|
|
||||||
}
|
|
||||||
usernameLabel.getStyleClass().add("label-medium");
|
usernameLabel.getStyleClass().add("label-medium");
|
||||||
Label foodLabel = new Label("Food: " + player.getFoodValue());
|
Label foodLabel = new Label("Food: " + player.getFoodValue());
|
||||||
foodLabel.getStyleClass().add("label-small");
|
foodLabel.getStyleClass().add("label-small");
|
||||||
@@ -314,6 +372,34 @@ public class MainFXMLController {
|
|||||||
|
|
||||||
playersHand.getChildren().add(card);
|
playersHand.getChildren().add(card);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Region spacer = new Region();
|
||||||
|
VBox.setVgrow(spacer, Priority.ALWAYS);
|
||||||
|
playersHand.getChildren().add(spacer);
|
||||||
|
|
||||||
|
VBox card = new VBox();
|
||||||
|
VBox.setMargin(card, new Insets(5, 5, 5, 5));
|
||||||
|
card.setAlignment(Pos.CENTER);
|
||||||
|
card.getStyleClass().add("frame");
|
||||||
|
|
||||||
|
Label usernameLabel = new Label(username);
|
||||||
|
usernameLabel.getStyleClass().add("label-medium");
|
||||||
|
int index = model.getPlayers().indexOf(
|
||||||
|
model.getPlayers().stream()
|
||||||
|
.filter(p -> p.getUserName().equals(username))
|
||||||
|
.findFirst()
|
||||||
|
.orElse(null)
|
||||||
|
);
|
||||||
|
ImageView totem = new ImageView(new Image(getClass().getResourceAsStream("/GUIImages/Totems/totem_" + index + ".png")));
|
||||||
|
totem.setFitHeight(10);
|
||||||
|
totem.setPreserveRatio(true);
|
||||||
|
Label foodLabel = new Label("Food: " + model.getPlayerByUsername(username).getFoodValue());
|
||||||
|
foodLabel.getStyleClass().add("label-small");
|
||||||
|
Label prestigeLabel = new Label("Prestige: " + model.getPlayerByUsername(username).getPrestigeValue());
|
||||||
|
prestigeLabel.getStyleClass().add("label-small");
|
||||||
|
card.getChildren().addAll(usernameLabel, totem, foodLabel, prestigeLabel);
|
||||||
|
|
||||||
|
playersHand.getChildren().add(card);
|
||||||
}
|
}
|
||||||
private void renderIcons(HBox icons, Player player) {
|
private void renderIcons(HBox icons, Player player) {
|
||||||
String[][] iconTypes = {
|
String[][] iconTypes = {
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 380 KiB After Width: | Height: | Size: 373 KiB |
|
Before Width: | Height: | Size: 415 KiB After Width: | Height: | Size: 406 KiB |
|
Before Width: | Height: | Size: 414 KiB After Width: | Height: | Size: 410 KiB |
|
Before Width: | Height: | Size: 380 KiB After Width: | Height: | Size: 374 KiB |
|
Before Width: | Height: | Size: 393 KiB After Width: | Height: | Size: 387 KiB |
|
Before Width: | Height: | Size: 394 KiB After Width: | Height: | Size: 389 KiB |
|
Before Width: | Height: | Size: 409 KiB After Width: | Height: | Size: 406 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 13 KiB |
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 17 KiB |
|
After Width: | Height: | Size: 17 KiB |
|
After Width: | Height: | Size: 711 KiB |
|
After Width: | Height: | Size: 691 KiB |
|
After Width: | Height: | Size: 692 KiB |
|
After Width: | Height: | Size: 730 KiB |
|
After Width: | Height: | Size: 18 KiB |
|
After Width: | Height: | Size: 19 KiB |
|
After Width: | Height: | Size: 9.0 KiB |
|
After Width: | Height: | Size: 9.9 KiB |
|
After Width: | Height: | Size: 9.0 KiB |