Refactor of GUI - synchronized methods
Changed info box
This commit is contained in:
@@ -38,7 +38,6 @@ public class ClientController {
|
||||
public ClientController(IView view) {
|
||||
this.view = view;
|
||||
this.client = null;
|
||||
this.miniModel = new MiniModel();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,46 +1,69 @@
|
||||
package it.polimi.ingsw.gc14.Model.GamePackage;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Represents the possible stages of a game.
|
||||
*/
|
||||
public enum GameStages {
|
||||
|
||||
/**
|
||||
* Stage in which the game is waiting for players to join.
|
||||
*/
|
||||
WAITING,
|
||||
WAITING("Waiting"),
|
||||
|
||||
/**
|
||||
* Stage in which players choose their totems.
|
||||
*/
|
||||
TOTEM_CHOICE,
|
||||
TOTEM_CHOICE("Totem"),
|
||||
|
||||
/**
|
||||
* Stage in which players select their action slots.
|
||||
*/
|
||||
SLOT_CHOICE,
|
||||
SLOT_CHOICE("Slot"),
|
||||
|
||||
/**
|
||||
* Stage in which the mandatory actions associated with the chosen slots are resolved.
|
||||
*/
|
||||
RES_ACTIONS,
|
||||
RES_ACTIONS("Actions"),
|
||||
|
||||
/**
|
||||
* Stage in which an optional card effect can be resolved.
|
||||
*/
|
||||
OPT_CARD_E,
|
||||
OPT_CARD_E("Card Effect"),
|
||||
|
||||
/**
|
||||
* Stage in which an event card is being resolved.
|
||||
*/
|
||||
RES_EVENT,
|
||||
RES_EVENT("Event"),
|
||||
|
||||
/**
|
||||
* Stage in which end-of-round or end-of-game operations are processed.
|
||||
*/
|
||||
ENDING,
|
||||
ENDING("Ending"),
|
||||
|
||||
/**
|
||||
* Stage indicating that the game has ended.
|
||||
*/
|
||||
ENDED
|
||||
}
|
||||
ENDED("Ended");
|
||||
|
||||
/** The human-readable name of this stage, used in {@link #toString()}. */
|
||||
private final String displayName;
|
||||
|
||||
/**
|
||||
* Constructs a {@code GameStages} value with the given display name.
|
||||
*
|
||||
* @param displayName the human-readable label for this stage
|
||||
*/
|
||||
GameStages(String displayName) {
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the human-readable name of this stage.
|
||||
*
|
||||
* @return the display name (e.g. {@code "Slot"} for {@code SLOT_CHOICE})
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return displayName;
|
||||
}
|
||||
}
|
||||
@@ -46,12 +46,14 @@ public class AddPlayer extends NetworkEvent implements Serializable {
|
||||
//TODO
|
||||
@Override
|
||||
public boolean apply(MiniModel miniModel){
|
||||
if(isError)
|
||||
return false;
|
||||
miniModel.setPlayers(playerList);
|
||||
miniModel.setOrderLogicCard(orderLogicCard);
|
||||
miniModel.setCurrentState(currentState);
|
||||
miniModel.setSlotPlayerMap(slotPlayerMap);
|
||||
return true;
|
||||
synchronized (miniModel) {
|
||||
if (isError)
|
||||
return false;
|
||||
miniModel.setPlayers(playerList);
|
||||
miniModel.setOrderLogicCard(orderLogicCard);
|
||||
miniModel.setCurrentState(currentState);
|
||||
miniModel.setSlotPlayerMap(slotPlayerMap);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,15 +59,17 @@ public class ApplyNextRound extends NetworkEvent implements Serializable{
|
||||
}
|
||||
public boolean apply(MiniModel miniModel)
|
||||
{
|
||||
miniModel.setSlotPlayerMap(slotPlayerMap);
|
||||
miniModel.setOrderLogicCard(orderLogicCard);
|
||||
miniModel.setCurrentState(currentState);
|
||||
miniModel.setPlayers(players);
|
||||
miniModel.upperListTribeCards=upperListTribeCards;
|
||||
miniModel.lowerListTribeCards=lowerListTribeCards;
|
||||
miniModel.upperListBuildingCards=upperListBuildingCards;
|
||||
miniModel.lowerListBuildingCards=lowerListBuildingCards;
|
||||
return true;
|
||||
synchronized (miniModel) {
|
||||
miniModel.setSlotPlayerMap(slotPlayerMap);
|
||||
miniModel.setOrderLogicCard(orderLogicCard);
|
||||
miniModel.setCurrentState(currentState);
|
||||
miniModel.setPlayers(players);
|
||||
miniModel.upperListTribeCards = upperListTribeCards;
|
||||
miniModel.lowerListTribeCards = lowerListTribeCards;
|
||||
miniModel.upperListBuildingCards = upperListBuildingCards;
|
||||
miniModel.lowerListBuildingCards = lowerListBuildingCards;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -33,16 +33,17 @@ public class DisconnectedPlayer extends NetworkEvent implements Serializable{
|
||||
//TODO
|
||||
@Override
|
||||
public boolean apply(MiniModel miniModel){
|
||||
if(isError)
|
||||
return false;
|
||||
if(miniModel!=null)
|
||||
{
|
||||
miniModel.setPlayers(playerList);
|
||||
miniModel.setOrderLogicCard(orderLogicCard);
|
||||
miniModel.setCurrentState(currentState);
|
||||
miniModel.setSlotPlayerMap(slotPlayerMap);
|
||||
synchronized (miniModel) {
|
||||
if (isError)
|
||||
return false;
|
||||
if (miniModel != null) {
|
||||
miniModel.setPlayers(playerList);
|
||||
miniModel.setOrderLogicCard(orderLogicCard);
|
||||
miniModel.setCurrentState(currentState);
|
||||
miniModel.setSlotPlayerMap(slotPlayerMap);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+10
-9
@@ -39,16 +39,17 @@ public class DrawLowerBuildingCard extends NetworkEvent implements Serializable
|
||||
//TODO
|
||||
@Override
|
||||
public boolean apply(MiniModel miniModel){
|
||||
if(isError)
|
||||
return false;
|
||||
|
||||
miniModel.lowerListBuildingCards.remove(pos);
|
||||
miniModel.setPlayers(playerList);
|
||||
miniModel.setOrderLogicCard(orderLogicCard);
|
||||
miniModel.setCurrentState(currentState);
|
||||
miniModel.setSlotPlayerMap(slotPlayerMap);
|
||||
return true;
|
||||
synchronized (miniModel) {
|
||||
if (isError)
|
||||
return false;
|
||||
|
||||
miniModel.lowerListBuildingCards.remove(pos);
|
||||
miniModel.setPlayers(playerList);
|
||||
miniModel.setOrderLogicCard(orderLogicCard);
|
||||
miniModel.setCurrentState(currentState);
|
||||
miniModel.setSlotPlayerMap(slotPlayerMap);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -38,16 +38,17 @@ public class DrawLowerTribeCard extends NetworkEvent implements Serializable{
|
||||
//TODO
|
||||
@Override
|
||||
public boolean apply(MiniModel miniModel){
|
||||
if(isError)
|
||||
return false;
|
||||
|
||||
miniModel.lowerListTribeCards.remove(pos);
|
||||
miniModel.setPlayers(playerList);
|
||||
miniModel.setOrderLogicCard(orderLogicCard);
|
||||
miniModel.setCurrentState(currentState);
|
||||
miniModel.setSlotPlayerMap(slotPlayerMap);
|
||||
return true;
|
||||
synchronized (miniModel) {
|
||||
if (isError)
|
||||
return false;
|
||||
|
||||
miniModel.lowerListTribeCards.remove(pos);
|
||||
miniModel.setPlayers(playerList);
|
||||
miniModel.setOrderLogicCard(orderLogicCard);
|
||||
miniModel.setCurrentState(currentState);
|
||||
miniModel.setSlotPlayerMap(slotPlayerMap);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+10
-9
@@ -39,15 +39,16 @@ public class DrawUpperBuildingCard extends NetworkEvent implements Serializable
|
||||
//TODO
|
||||
@Override
|
||||
public boolean apply(MiniModel miniModel){
|
||||
if(isError)
|
||||
return false;
|
||||
|
||||
miniModel.upperListBuildingCards.remove(pos);
|
||||
miniModel.setPlayers(playerList);
|
||||
miniModel.setOrderLogicCard(orderLogicCard);
|
||||
miniModel.setCurrentState(currentState);
|
||||
miniModel.setSlotPlayerMap(slotPlayerMap);
|
||||
return true;
|
||||
synchronized (miniModel) {
|
||||
if (isError)
|
||||
return false;
|
||||
|
||||
miniModel.upperListBuildingCards.remove(pos);
|
||||
miniModel.setPlayers(playerList);
|
||||
miniModel.setOrderLogicCard(orderLogicCard);
|
||||
miniModel.setCurrentState(currentState);
|
||||
miniModel.setSlotPlayerMap(slotPlayerMap);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,15 +38,16 @@ public class DrawUpperTribeCard extends NetworkEvent implements Serializable{
|
||||
//TODO
|
||||
@Override
|
||||
public boolean apply(MiniModel miniModel){
|
||||
if(isError)
|
||||
return false;
|
||||
miniModel.upperListTribeCards.remove(pos);
|
||||
miniModel.setPlayers(playerList);
|
||||
miniModel.setOrderLogicCard(orderLogicCard);
|
||||
miniModel.setCurrentState(currentState);
|
||||
miniModel.setSlotPlayerMap(slotPlayerMap);
|
||||
return true;
|
||||
|
||||
synchronized (miniModel) {
|
||||
if (isError)
|
||||
return false;
|
||||
miniModel.upperListTribeCards.remove(pos);
|
||||
miniModel.setPlayers(playerList);
|
||||
miniModel.setOrderLogicCard(orderLogicCard);
|
||||
miniModel.setCurrentState(currentState);
|
||||
miniModel.setSlotPlayerMap(slotPlayerMap);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -48,12 +48,14 @@ public class EndedGame extends NetworkEvent implements Serializable{
|
||||
}
|
||||
public boolean apply(MiniModel miniModel)
|
||||
{
|
||||
miniModel.setSlotPlayerMap(slotPlayerMap);
|
||||
miniModel.setOrderLogicCard(orderLogicCard);
|
||||
miniModel.setCurrentState(currentState);
|
||||
miniModel.setPlayers(players);
|
||||
miniModel.setStandingPlayers(players);
|
||||
return true;
|
||||
synchronized (miniModel) {
|
||||
miniModel.setSlotPlayerMap(slotPlayerMap);
|
||||
miniModel.setOrderLogicCard(orderLogicCard);
|
||||
miniModel.setCurrentState(currentState);
|
||||
miniModel.setPlayers(players);
|
||||
miniModel.setStandingPlayers(players);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -45,16 +45,18 @@ public class ReconnectPlayer extends NetworkEvent implements Serializable {
|
||||
*/
|
||||
@Override
|
||||
public boolean apply(MiniModel miniModel) {
|
||||
if (isError)
|
||||
return false;
|
||||
synchronized (miniModel) {
|
||||
if (isError)
|
||||
return false;
|
||||
|
||||
if (miniModel != null) {
|
||||
miniModel.setPlayers(playerList);
|
||||
miniModel.setOrderLogicCard(orderLogicCard);
|
||||
miniModel.setCurrentState(currentState);
|
||||
miniModel.setSlotPlayerMap(slotPlayerMap);
|
||||
if (miniModel != null) {
|
||||
miniModel.setPlayers(playerList);
|
||||
miniModel.setOrderLogicCard(orderLogicCard);
|
||||
miniModel.setCurrentState(currentState);
|
||||
miniModel.setSlotPlayerMap(slotPlayerMap);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -33,14 +33,15 @@ public class SkipTurn extends NetworkEvent implements Serializable{
|
||||
//TODO
|
||||
@Override
|
||||
public boolean apply(MiniModel miniModel){
|
||||
if(isError)
|
||||
return false;
|
||||
miniModel.setPlayers(playerList);
|
||||
miniModel.setOrderLogicCard(orderLogicCard);
|
||||
miniModel.setCurrentState(currentState);
|
||||
miniModel.setSlotPlayerMap(slotPlayerMap);
|
||||
return true;
|
||||
|
||||
synchronized (miniModel) {
|
||||
if (isError)
|
||||
return false;
|
||||
miniModel.setPlayers(playerList);
|
||||
miniModel.setOrderLogicCard(orderLogicCard);
|
||||
miniModel.setCurrentState(currentState);
|
||||
miniModel.setSlotPlayerMap(slotPlayerMap);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -39,14 +39,15 @@ public class SlotChoice extends NetworkEvent implements Serializable {
|
||||
//TODO
|
||||
@Override
|
||||
public boolean apply(MiniModel miniModel){
|
||||
if(isError)
|
||||
return false;
|
||||
miniModel.setPlayers(playerList);
|
||||
miniModel.setOrderLogicCard(orderLogicCard);
|
||||
miniModel.setCurrentState(currentState);
|
||||
miniModel.setSlotPlayerMap(slotPlayerMap);
|
||||
return true;
|
||||
|
||||
synchronized (miniModel) {
|
||||
if (isError)
|
||||
return false;
|
||||
miniModel.setPlayers(playerList);
|
||||
miniModel.setOrderLogicCard(orderLogicCard);
|
||||
miniModel.setCurrentState(currentState);
|
||||
miniModel.setSlotPlayerMap(slotPlayerMap);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -69,14 +69,16 @@ public class TotemChoice extends NetworkEvent implements Serializable {
|
||||
*/
|
||||
@Override
|
||||
public boolean apply(MiniModel miniModel) {
|
||||
if (isError)
|
||||
return false;
|
||||
synchronized (miniModel) {
|
||||
if (isError)
|
||||
return false;
|
||||
|
||||
miniModel.setPlayers(playerList);
|
||||
miniModel.setOrderLogicCard(orderLogicCard);
|
||||
miniModel.setCurrentState(currentState);
|
||||
miniModel.setSlotPlayerMap(slotPlayerMap);
|
||||
miniModel.setAvailableTotems(availableTotems);
|
||||
return true;
|
||||
miniModel.setPlayers(playerList);
|
||||
miniModel.setOrderLogicCard(orderLogicCard);
|
||||
miniModel.setCurrentState(currentState);
|
||||
miniModel.setSlotPlayerMap(slotPlayerMap);
|
||||
miniModel.setAvailableTotems(availableTotems);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -40,10 +40,8 @@ public class ClientCallbackImpl extends UnicastRemoteObject implements IClientCa
|
||||
*/
|
||||
@Override
|
||||
public void onGameInit(MiniModel model) throws RemoteException {
|
||||
Platform.runLater(() -> {
|
||||
clientController.setModel(model);
|
||||
clientController.view.render();
|
||||
});
|
||||
clientController.setModel(model);
|
||||
clientController.view.render();
|
||||
}
|
||||
|
||||
|
||||
@@ -56,15 +54,12 @@ public class ClientCallbackImpl extends UnicastRemoteObject implements IClientCa
|
||||
*/
|
||||
@Override
|
||||
public void onAction(NetworkEvent event) throws RemoteException {
|
||||
synchronized (clientController) {
|
||||
if(event.getIsError()) {
|
||||
clientController.view.showError(event.toString());
|
||||
} else {
|
||||
Platform.runLater(() -> {
|
||||
event.apply(clientController.miniModel);
|
||||
clientController.view.render();
|
||||
});
|
||||
}
|
||||
if(event.getIsError()) {
|
||||
clientController.view.showError(event.toString());
|
||||
} else {
|
||||
event.apply(clientController.miniModel);
|
||||
clientController.view.render();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,8 +83,6 @@ public class GUI extends Application implements IView {
|
||||
showLogin();
|
||||
stage.setTitle("Mesos");
|
||||
primaryStage.setMaximized(true);
|
||||
primaryStage.setMinWidth(1583);
|
||||
primaryStage.setMinHeight(734);
|
||||
primaryStage.setOnCloseRequest(e -> {
|
||||
Platform.exit();
|
||||
System.exit(0);
|
||||
@@ -106,38 +104,23 @@ public class GUI extends Application implements IView {
|
||||
this.controller=controller;
|
||||
}
|
||||
|
||||
|
||||
public void applyAndRender(NetworkEvent event) {
|
||||
public void render() {
|
||||
Platform.runLater(() -> {
|
||||
if (event!=null) {
|
||||
event.apply(miniModel);
|
||||
}
|
||||
if (controller.miniModel.currentState.getGameStage() == TOTEM_CHOICE) {
|
||||
primaryStage.setScene(totemScene);
|
||||
controllerTotem.render();
|
||||
} else if (controller.miniModel.currentState.getGameStage() == GameStages.ENDED) {
|
||||
primaryStage.setScene(leaderboardScene);
|
||||
controllerLeaderboard.render();
|
||||
} else {
|
||||
primaryStage.setScene(mainScene);
|
||||
controllerMain.render(event);
|
||||
controllerMain.initPopup(mainScene);
|
||||
synchronized (miniModel) {
|
||||
if (controller.miniModel.currentState.getGameStage() == TOTEM_CHOICE) {
|
||||
primaryStage.setScene(totemScene);
|
||||
controllerTotem.render();
|
||||
} else if (controller.miniModel.currentState.getGameStage() == ENDED) {
|
||||
primaryStage.setScene(leaderboardScene);
|
||||
controllerLeaderboard.render();
|
||||
} else {
|
||||
primaryStage.setScene(mainScene);
|
||||
controllerMain.initPopup(mainScene);
|
||||
controllerMain.render();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void render() {
|
||||
if (controller.miniModel.currentState.getGameStage() == TOTEM_CHOICE) {
|
||||
primaryStage.setScene(totemScene);
|
||||
controllerTotem.render();
|
||||
} else if (controller.miniModel.currentState.getGameStage() == ENDED){
|
||||
primaryStage.setScene(leaderboardScene);
|
||||
controllerLeaderboard.render();
|
||||
}else {
|
||||
primaryStage.setScene(mainScene);
|
||||
controllerMain.initPopup(mainScene);
|
||||
controllerMain.render();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void showMessage(String message) {
|
||||
|
||||
@@ -7,8 +7,6 @@ import it.polimi.ingsw.gc14.Model.Cards.TribeCard;
|
||||
import it.polimi.ingsw.gc14.Model.Orders.OrderPlayer;
|
||||
import it.polimi.ingsw.gc14.Network.EventType;
|
||||
import it.polimi.ingsw.gc14.Network.NetworkEvent;
|
||||
import javafx.animation.AnimationTimer;
|
||||
import javafx.animation.PauseTransition;
|
||||
import javafx.animation.ScaleTransition;
|
||||
import javafx.application.Platform;
|
||||
import javafx.beans.value.ChangeListener;
|
||||
@@ -18,6 +16,7 @@ import javafx.fxml.FXML;
|
||||
import javafx.geometry.Bounds;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.geometry.Rectangle2D;
|
||||
import javafx.scene.Cursor;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.Scene;
|
||||
@@ -33,7 +32,7 @@ import javafx.scene.paint.Color;
|
||||
import javafx.scene.shape.*;
|
||||
import javafx.scene.text.Font;
|
||||
import javafx.stage.Popup;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.stage.Screen;
|
||||
import javafx.stage.Window;
|
||||
import javafx.util.Duration;
|
||||
|
||||
@@ -41,21 +40,16 @@ import java.util.*;
|
||||
|
||||
public class MainFXMLController {
|
||||
|
||||
@FXML private HBox currentStateBar;
|
||||
@FXML private ScrollPane playerSide;
|
||||
@FXML private HBox mainHBox;
|
||||
@FXML private ImageView backgroundImage;
|
||||
@FXML private HBox board;
|
||||
@FXML private HBox upperList;
|
||||
@FXML private HBox lowerList;
|
||||
@FXML private HBox myHand;
|
||||
@FXML private VBox sidePanel;
|
||||
@FXML private HBox buttonRow;
|
||||
@FXML private Button skipBtn;
|
||||
@FXML private Button detailsBtn;
|
||||
@FXML private HBox info;
|
||||
@FXML private Label era;
|
||||
@FXML private Label round;
|
||||
@FXML private Label player;
|
||||
@FXML private Label infoText;
|
||||
|
||||
private Popup popup;
|
||||
private HBox popupCards;
|
||||
@@ -70,15 +64,14 @@ public class MainFXMLController {
|
||||
p -> new Image(getClass().getResourceAsStream(p)));
|
||||
}
|
||||
|
||||
|
||||
public void setController(ClientController controller) {
|
||||
this.controller = controller;
|
||||
}
|
||||
|
||||
|
||||
@FXML
|
||||
public void initialize() {
|
||||
Font.loadFont(getClass().getResourceAsStream("/Fonts/InknutAntiqua-Regular.ttf"), 14);
|
||||
|
||||
popup = new Popup();
|
||||
mainHBox.sceneProperty().addListener((obs, oldScene, newScene) -> {
|
||||
if (newScene != null) {
|
||||
@@ -88,17 +81,7 @@ public class MainFXMLController {
|
||||
});
|
||||
}
|
||||
});
|
||||
mainHBox.layoutBoundsProperty().addListener(new ChangeListener<Bounds>() {
|
||||
@Override
|
||||
public void changed(ObservableValue<? extends Bounds> obs, Bounds ov, Bounds nv) {
|
||||
if (nv.getWidth() > 0 && nv.getHeight() > 0 && controller != null) {
|
||||
mainHBox.layoutBoundsProperty().removeListener(this);
|
||||
render();
|
||||
}
|
||||
}
|
||||
});
|
||||
addHoverZoom(skipBtn);
|
||||
addHoverZoom(detailsBtn);
|
||||
|
||||
renderBackground();
|
||||
}
|
||||
|
||||
@@ -138,11 +121,9 @@ public class MainFXMLController {
|
||||
Rectangle clip = new Rectangle();
|
||||
clip.setArcWidth(20);
|
||||
clip.setArcHeight(20);
|
||||
clip.heightProperty().bind(img.fitHeightProperty());
|
||||
clip.widthProperty().bind(img.fitHeightProperty().multiply(
|
||||
img.getImage().getWidth() / img.getImage().getHeight()
|
||||
));
|
||||
img.setClip(clip);
|
||||
clip.heightProperty().bind(img.layoutBoundsProperty().map(b -> b.getHeight()));
|
||||
clip.widthProperty().bind(img.layoutBoundsProperty().map(b -> b.getWidth()));
|
||||
}
|
||||
|
||||
private void addHoverZoom(Node node) {
|
||||
@@ -190,7 +171,7 @@ public class MainFXMLController {
|
||||
private StackPane createSlot(Slot slot, boolean withZoom, boolean withShadow) {
|
||||
ImageView img = new ImageView(loadImage("/GUIImages/Fronts/card-" + slot.getSlotId() + ".png"));
|
||||
img.setPreserveRatio(true);
|
||||
img.fitHeightProperty().bind(board.heightProperty().add(-15));
|
||||
img.fitHeightProperty().bind(board.heightProperty().add(-15)); // TODO perchè è tutto moltiplicato per una costante ma in board facciamo -15?
|
||||
addClip(img);
|
||||
StackPane wrapper = new StackPane(img);
|
||||
|
||||
@@ -200,10 +181,7 @@ public class MainFXMLController {
|
||||
totem.fitHeightProperty().bind(img.fitHeightProperty().multiply(0.332));
|
||||
totem.setPreserveRatio(true);
|
||||
StackPane.setAlignment(totem, Pos.TOP_LEFT);
|
||||
StackPane.setMargin(totem, new Insets(0, 0, 0, 0.224 * img.getFitHeight()));
|
||||
img.fitHeightProperty().addListener((obs, ov, nv) -> {
|
||||
StackPane.setMargin(totem, new Insets(0, 0, 0, 0.224 * nv.doubleValue()));
|
||||
});
|
||||
StackPane.setMargin(totem, new Insets(0, 0, 0, 0.224 * img.getFitHeight())); // TODO perchè margine sx incrementa con altezza e non larghezza?
|
||||
wrapper.getChildren().add(totem);
|
||||
}
|
||||
|
||||
@@ -288,9 +266,9 @@ public class MainFXMLController {
|
||||
}
|
||||
}
|
||||
|
||||
private void drawMyHandList(ArrayList<? extends PlayableCard> cardList, HBox parent) {
|
||||
private void drawMyHandList(ArrayList<? extends PlayableCard> cardList) {
|
||||
if (!cardList.isEmpty()) {
|
||||
StackPane img = createCard(cardList.getLast(), true, true, parent);
|
||||
StackPane img = createCard(cardList.getLast(), true, true, myHand);
|
||||
Label label = new Label(String.valueOf(cardList.size()));
|
||||
label.setTranslateY(-55);
|
||||
label.setTranslateX(10);
|
||||
@@ -298,13 +276,13 @@ public class MainFXMLController {
|
||||
StackPane.setAlignment(label, Pos.TOP_RIGHT);
|
||||
img.getChildren().add(label);
|
||||
img.setOnMouseClicked(e -> openPopup(new ArrayList<>(cardList)));
|
||||
parent.getChildren().add(img);
|
||||
myHand.getChildren().add(img);
|
||||
} else {
|
||||
Region placeholder = new Region();
|
||||
placeholder.prefHeightProperty().bind(parent.heightProperty().multiply(0.85));
|
||||
placeholder.prefHeightProperty().bind(myHand.heightProperty().multiply(0.85));
|
||||
placeholder.prefWidthProperty().bind(placeholder.prefHeightProperty().multiply(0.675));
|
||||
placeholder.setStyle("-fx-background-color: transparent;");
|
||||
parent.getChildren().add(placeholder);
|
||||
myHand.getChildren().add(placeholder);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -313,8 +291,15 @@ public class MainFXMLController {
|
||||
VBox.setMargin(card, new Insets(15,15,15,15));
|
||||
card.getStyleClass().add("player-card");
|
||||
card.setPadding(new Insets(8));
|
||||
addHoverZoom(card);
|
||||
addShadow(card);
|
||||
|
||||
if(player.getUserName().equals(controller.miniModel.currentState.getCurrentPlayer().getUserName())) {
|
||||
ScaleTransition scaleUp = new ScaleTransition(Duration.millis(150), card);
|
||||
scaleUp.setToX(1.1);
|
||||
scaleUp.setToY(1.1);
|
||||
scaleUp.play();
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Riga 1: totem + nome
|
||||
HBox headerRow = new HBox(8);
|
||||
@@ -482,7 +467,6 @@ public class MainFXMLController {
|
||||
4, new double[]{0.142, 0.316, 0.503, 0.690},
|
||||
5, new double[]{0.066, 0.251, 0.433, 0.617, 0.802}
|
||||
);
|
||||
|
||||
double[] positions = slotPositions.get(numPlayers);
|
||||
if (positions == null) return;
|
||||
|
||||
@@ -548,27 +532,27 @@ public class MainFXMLController {
|
||||
myHand.setAlignment(Pos.CENTER);
|
||||
|
||||
Player me = controller.miniModel.players.get(controller.myUsername);
|
||||
drawMyHandList(me.artists,myHand);
|
||||
drawMyHandList(me.gatherers,myHand);
|
||||
drawMyHandList(me.inventors,myHand);
|
||||
drawMyHandList(me.builders,myHand);
|
||||
drawMyHandList(me.shamans,myHand);
|
||||
drawMyHandList(me.hunters,myHand);
|
||||
drawMyHandList(me.buildingCards,myHand);
|
||||
drawMyHandList(me.artists);
|
||||
drawMyHandList(me.gatherers);
|
||||
drawMyHandList(me.inventors);
|
||||
drawMyHandList(me.builders);
|
||||
drawMyHandList(me.shamans);
|
||||
drawMyHandList(me.hunters);
|
||||
drawMyHandList(me.buildingCards);
|
||||
}
|
||||
|
||||
private void renderSidePanel() {
|
||||
currentStateBar.getChildren().clear();
|
||||
currentStateBar.getChildren().add(new Label("Round:"+controller.miniModel.currentState.getRound()));
|
||||
era.setText(Integer.toString(controller.miniModel.currentState.getEra()));
|
||||
round.setText(Integer.toString(controller.miniModel.currentState.getRound()));
|
||||
player.setText(controller.miniModel.currentState.getCurrentPlayer().getUserName());
|
||||
infoText.setText("Round: "+Integer.toString(controller.miniModel.currentState.getRound()) + " • " + controller.miniModel.currentState.getGameStage().toString());
|
||||
skipBtn.setOnAction(e -> controller.skipTurn(controller.myUsername));
|
||||
// ← VBox separato solo per i player
|
||||
VBox playerList = new VBox(6);
|
||||
detailsBtn.setOnAction(e -> openDetailsPopup());
|
||||
|
||||
addHoverZoom(skipBtn);
|
||||
addHoverZoom(detailsBtn);
|
||||
|
||||
VBox playerList = new VBox();
|
||||
playerList.setFillWidth(true);
|
||||
for (Player p : controller.miniModel.players.values()) {
|
||||
renderPlayer(p, playerList); // ← passa playerList invece di sidePanel
|
||||
renderPlayer(p, playerList);
|
||||
}
|
||||
playerSide.setContent(playerList);
|
||||
}
|
||||
@@ -587,7 +571,7 @@ public class MainFXMLController {
|
||||
);
|
||||
|
||||
popup.getContent().add(popupCards);
|
||||
popup.setAutoHide(false); // gestito manualmente per permettere click sulle carte
|
||||
popup.setAutoHide(false);
|
||||
popup.addEventHandler(Event.ANY, e -> {
|
||||
if (popup.getScene() != null) {
|
||||
popup.getScene().setFill(Color.TRANSPARENT);
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
<StackPane xmlns="http://javafx.com/javafx/21"
|
||||
xmlns:fx="http://javafx.com/fxml/1"
|
||||
fx:controller="it.polimi.ingsw.gc14.View.GUI.LoginFXMLController"
|
||||
prefWidth="1280" prefHeight="720"
|
||||
style="-fx-background-color: #09060300;"
|
||||
stylesheets="@styles.css">
|
||||
|
||||
|
||||
@@ -7,11 +7,11 @@
|
||||
<?import javafx.scene.control.Button?>
|
||||
<HBox fx:id="mainHBox"
|
||||
maxHeight="Infinity" maxWidth="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"
|
||||
stylesheets="@styles.css">
|
||||
|
||||
<children>
|
||||
<!-- VBox sinistra: si espande per riempire tutto lo spazio disponibile -->
|
||||
<VBox alignment="CENTER"
|
||||
@@ -23,7 +23,6 @@
|
||||
<Insets top="5" right="5" bottom="5" left="5" />
|
||||
</HBox.margin>
|
||||
<children>
|
||||
<HBox fx:id="currentStateBar" style="-fx-background-color: #ffffff59" maxHeight="30" minHeight="30" prefHeight="30" alignment="CENTER" />
|
||||
<HBox fx:id="upperList" styleClass="card-list" VBox.vgrow="ALWAYS">
|
||||
<VBox.margin>
|
||||
<Insets top="5" right="5" bottom="5" left="5" />
|
||||
@@ -61,32 +60,13 @@
|
||||
<Insets bottom="10" left="10" right="10" top="10" />
|
||||
</HBox.margin>
|
||||
<children>
|
||||
<HBox fx:id="info" prefHeight="107.0" prefWidth="483.0" styleClass="frame">
|
||||
<children>
|
||||
<VBox alignment="CENTER" prefHeight="107.0" prefWidth="161.0" spacing="2">
|
||||
<children>
|
||||
<Label styleClass="label-medium" text="Era" />
|
||||
<Label fx:id="era" styleClass="label-medium" text="VALORE" />
|
||||
</children>
|
||||
</VBox>
|
||||
<VBox alignment="CENTER" prefHeight="107.0" prefWidth="161.0" spacing="2">
|
||||
<children>
|
||||
<Label styleClass="label-medium" text="Round" />
|
||||
<Label fx:id="round" styleClass="label-medium" text="VALORE" />
|
||||
</children>
|
||||
</VBox>
|
||||
<VBox alignment="CENTER" prefHeight="107.0" prefWidth="161.0" spacing="2">
|
||||
<children>
|
||||
<Label styleClass="label-medium" text="Player" />
|
||||
<Label fx:id="player" styleClass="label-medium" text="VALORE" />
|
||||
</children>
|
||||
</VBox>
|
||||
</children>
|
||||
<HBox fx:id="info" prefHeight="107.0" prefWidth="483.0" styleClass="frame" alignment="CENTER">
|
||||
<Label fx:id="infoText" styleClass="label-medium" text="VALORE" />
|
||||
</HBox>
|
||||
<HBox alignment="CENTER" fx:id="buttonRow" >
|
||||
<HBox spacing="10">
|
||||
<Button fx:id="skipBtn" styleClass="action-button" text="Skip Turn"/>
|
||||
<Button fx:id="detailsBtn" styleClass="action-button" onAction="#openDetailsPopup" text="Ending Details"/>
|
||||
<Button fx:id="detailsBtn" styleClass="action-button" text="Ending Details"/>
|
||||
</HBox>
|
||||
<VBox.margin>
|
||||
<Insets top="5" right="5" bottom="5" left="5"/>
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
<StackPane xmlns="http://javafx.com/javafx/21"
|
||||
xmlns:fx="http://javafx.com/fxml/1"
|
||||
fx:controller="it.polimi.ingsw.gc14.View.GUI.TotemFXMLController"
|
||||
prefWidth="1280" prefHeight="720"
|
||||
style="-fx-background-color: #09060300;">
|
||||
<ImageView fx:id="backgroundImage" fitWidth="1920" fitHeight="1080" preserveRatio="false">
|
||||
</ImageView>
|
||||
|
||||
Reference in New Issue
Block a user