Small refactor

This commit is contained in:
2026-05-25 17:32:17 +02:00
parent 24ae732805
commit 22c4c6cc0f
4 changed files with 38 additions and 46 deletions
@@ -167,7 +167,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.sceneProperty().get().heightProperty().subtract(40).divide(4).multiply(0.94)); // TODO perchè è tutto moltiplicato per una costante ma in board facciamo -15?
img.fitHeightProperty().bind(board.sceneProperty().get().heightProperty().subtract(40).divide(4).multiply(0.94));
addClip(img);
StackPane wrapper = new StackPane(img);
@@ -177,7 +177,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())); // TODO perchè margine sx incrementa con altezza e non larghezza?
StackPane.setMargin(totem, new Insets(0, 0, 0, 0.224 * img.getFitHeight()));
wrapper.getChildren().add(totem);
}
@@ -209,7 +209,7 @@ public class MainFXMLController {
for (TribeCard card : controller.miniModel.upperListTribeCards) {
final int index = i;
StackPane img = createCard(card, true, true, upperList);
img.setOnMouseClicked(e -> controller.drawUpperTribeCard(controller.myUsername, index));
img.setOnMouseClicked(e -> controller.drawUpperTribeCard(index));
upperList.getChildren().add(img);
i++;
}
@@ -225,7 +225,7 @@ public class MainFXMLController {
for (TribeCard card : controller.miniModel.lowerListTribeCards) {
final int index = i;
StackPane img = createCard(card, true, true, lowerList);
img.setOnMouseClicked(e -> controller.drawLowerTribeCard(controller.myUsername, index));
img.setOnMouseClicked(e -> controller.drawLowerTribeCard(index));
lowerList.getChildren().add(img);
i++;
}
@@ -275,7 +275,7 @@ public class MainFXMLController {
myHand.getChildren().add(img);
} else {
Region placeholder = new Region();
placeholder.prefHeightProperty().bind(myHand.heightProperty().multiply(0.90));
placeholder.prefHeightProperty().bind(myHand.getScene().heightProperty().subtract(40).divide(4).multiply(0.90));
placeholder.prefWidthProperty().bind(placeholder.prefHeightProperty().multiply(0.675));
placeholder.setStyle("-fx-background-color: transparent;");
myHand.getChildren().add(placeholder);
@@ -530,7 +530,7 @@ public class MainFXMLController {
Slot slot = entry.getKey();
final int index = i;
StackPane img = createSlot(slot, true, true);
img.setOnMouseClicked(e -> controller.slotChoice(controller.myUsername, index));
img.setOnMouseClicked(e -> controller.slotChoice(index));
board.getChildren().add(img);
i++;
}
@@ -553,7 +553,7 @@ public class MainFXMLController {
private void renderSidePanel() {
infoText.setText("Round: "+Integer.toString(controller.miniModel.currentState.getRound()) + "" + controller.miniModel.currentState.getGameStage().toString());
skipBtn.setOnAction(e -> controller.skipTurn(controller.myUsername));
skipBtn.setOnAction(e -> controller.skipTurn());
detailsBtn.setOnAction(e -> openDetailsPopup());
addHoverZoom(skipBtn);
@@ -614,7 +614,7 @@ public class MainFXMLController {
StackPane img = createCardPopup(cardList.get(i), true, false);
img.setOnMouseClicked(e -> {
popup.hide();
controller.drawUpperBuildingCard(controller.myUsername, index);
controller.drawUpperBuildingCard(index);
});
popupCards.getChildren().add(img);
}
@@ -629,7 +629,7 @@ public class MainFXMLController {
StackPane img = createCardPopup(cardList.get(i), true, false);
img.setOnMouseClicked(e -> {
popup.hide();
controller.drawLowerBuildingCard(controller.myUsername, index);
controller.drawLowerBuildingCard(index);
});
popupCards.getChildren().add(img);
}
@@ -197,7 +197,7 @@ public class TotemFXMLController {
@FXML
private void onConfirm() {
if (selectedIndex >= 0) {
controller.totemChoice(controller.myUsername, selectedIndex);
controller.totemChoice(selectedIndex);
}
}
}