Added: Now Order Card has totem images instead rectangle
This commit is contained in:
@@ -471,16 +471,15 @@ public class MainFXMLController {
|
||||
StackPane card = createOrder(Integer.toString(numPlayers));
|
||||
|
||||
Map<Integer, double[]> slotPositions = Map.of(
|
||||
2, new double[]{0.229 ,0.413},
|
||||
3, new double[]{0.183,0.367, 0.548},
|
||||
4, new double[]{0.142,0.316, 0.503, 0.690},
|
||||
5, new double[]{0.066, 0.251, 0.433, 0.617,0.802}
|
||||
2, new double[]{0.229, 0.413},
|
||||
3, new double[]{0.183, 0.367, 0.548},
|
||||
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;
|
||||
|
||||
|
||||
Pane overlay = new Pane();
|
||||
overlay.setPickOnBounds(false);
|
||||
overlay.setMouseTransparent(true);
|
||||
@@ -488,43 +487,42 @@ public class MainFXMLController {
|
||||
for (int i = 0; i < controller.miniModel.orderLogicCard.playerList.size(); i++) {
|
||||
OrderPlayer op = controller.miniModel.orderLogicCard.playerList.get(i);
|
||||
|
||||
// colore dal totem del giocatore
|
||||
Color color = totemColor(op.player.totem);
|
||||
// Carica immagine totem come in createSlot
|
||||
ImageView totem = new ImageView(loadImage(
|
||||
"/GUIImages/Totems/totem_" + op.player.totem.toString().toLowerCase(Locale.ROOT) + ".png"
|
||||
));
|
||||
totem.setPreserveRatio(true);
|
||||
|
||||
Rectangle rect = new Rectangle(48, 26, color);
|
||||
rect.setArcWidth(4);
|
||||
rect.setArcHeight(4);
|
||||
if (controller.miniModel.slotPlayerMap.containsValue(op.player)) {
|
||||
rect.setVisible(false);
|
||||
totem.setVisible(false);
|
||||
}
|
||||
|
||||
final double yRatio = positions[i];
|
||||
|
||||
overlay.prefHeightProperty().bind(card.heightProperty());
|
||||
overlay.prefWidthProperty().bind(card.widthProperty());
|
||||
// posizione X fissa, Y proporzionale
|
||||
|
||||
// Scala altezza totem proporzionalmente come in createSlot (0.127 della card)
|
||||
totem.fitHeightProperty().bind(card.heightProperty().multiply(0.323));
|
||||
|
||||
// Posizione Y proporzionale, X fissa
|
||||
card.heightProperty().addListener((obs, ov, nv) -> {
|
||||
rect.setY(nv.doubleValue() * yRatio);
|
||||
rect.setHeight(0.127*nv.doubleValue());
|
||||
totem.setLayoutY(nv.doubleValue() * (yRatio-0.196));
|
||||
});
|
||||
card.widthProperty().addListener((obs, ov, nv) -> {
|
||||
rect.setX(nv.doubleValue() * 0.323);
|
||||
rect.setWidth(0.375*nv.doubleValue());
|
||||
totem.setLayoutX(nv.doubleValue() * 0.364);
|
||||
});
|
||||
if (card.getHeight() > 0 && card.getWidth() > 0) {
|
||||
rect.setY(card.getHeight() * yRatio);
|
||||
rect.setHeight(0.127*yRatio);
|
||||
|
||||
rect.setX(card.getHeight() * 0.323);
|
||||
rect.setWidth(0.375*card.getHeight());
|
||||
}
|
||||
// Inizializzazione immediata se già dimensionato
|
||||
if (card.getHeight() > 0) totem.setLayoutY(card.getHeight() *(yRatio-0.196));
|
||||
if (card.getWidth() > 0) totem.setLayoutX(card.getWidth() * 0.364);
|
||||
|
||||
overlay.getChildren().add(rect);
|
||||
overlay.getChildren().add(totem);
|
||||
}
|
||||
|
||||
card.getChildren().add(overlay);
|
||||
board.getChildren().add(card);
|
||||
}
|
||||
|
||||
private Color totemColor(Totems totem) {
|
||||
return switch (totem) {
|
||||
case ORANGE -> Color.rgb(223, 76, 17);
|
||||
|
||||
Reference in New Issue
Block a user