Added: Now Order Card has totem images instead rectangle

This commit is contained in:
rubenpirreram
2026-05-20 19:18:56 +02:00
parent 506def6ffa
commit 7a4f8f2384
@@ -480,7 +480,6 @@ public class MainFXMLController {
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);