Add: profile picture loading in PlayerStatusController
This commit is contained in:
+39
-7
@@ -20,15 +20,19 @@ public class PlayerStatusController {
|
|||||||
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(PlayerStatusController.class.getName());
|
private static final Logger LOGGER = Logger.getLogger(PlayerStatusController.class.getName());
|
||||||
|
|
||||||
@FXML private Label playerName;
|
@FXML Label playerName;
|
||||||
@FXML private Label playerMoney;
|
@FXML Label playerMoney;
|
||||||
@FXML private ImageView dealerIcon;
|
@FXML ImageView dealerIcon;
|
||||||
@FXML private Pane parent;
|
@FXML ImageView playerProfileImage;
|
||||||
@FXML private VBox playerStatusBox;
|
@FXML Pane parent;
|
||||||
@FXML private HBox statusInnerBoxTop;
|
@FXML VBox playerStatusBox;
|
||||||
@FXML private HBox statusInnerBoxBottom;
|
@FXML HBox statusInnerBoxTop;
|
||||||
|
@FXML HBox statusInnerBoxBottom;
|
||||||
|
|
||||||
private Image dealerImage;
|
private Image dealerImage;
|
||||||
|
// Profile images (loaded from resources/images/profile-picture)
|
||||||
|
private Image profileUserImage;
|
||||||
|
private Image profileDealerImage;
|
||||||
private Player player;
|
private Player player;
|
||||||
private boolean turnHighlighted;
|
private boolean turnHighlighted;
|
||||||
private static final String DEALER_IMAGE_PATH = "/images/chip-dealer-blue-5.png";
|
private static final String DEALER_IMAGE_PATH = "/images/chip-dealer-blue-5.png";
|
||||||
@@ -53,6 +57,26 @@ public class PlayerStatusController {
|
|||||||
LOGGER.log(Level.SEVERE, "Error loading dealer image", e);
|
LOGGER.log(Level.SEVERE, "Error loading dealer image", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
var base = "/images/profile-picture/";
|
||||||
|
var uUser = getClass().getResource(base + "poker_user_491.png");
|
||||||
|
var uDealer = getClass().getResource(base + "poker_dealer_471.png");
|
||||||
|
|
||||||
|
if (uUser != null) {
|
||||||
|
profileUserImage = new Image(uUser.toExternalForm(), true);
|
||||||
|
}
|
||||||
|
if (uDealer != null) {
|
||||||
|
profileDealerImage = new Image(uDealer.toExternalForm(), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (playerProfileImage != null && profileUserImage != null) {
|
||||||
|
playerProfileImage.setImage(profileUserImage);
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOGGER.log(Level.FINE, "Could not load profile images", e);
|
||||||
|
}
|
||||||
|
|
||||||
dealerIcon.layoutXProperty().bind(parent.widthProperty().multiply(DEALER_ICON_X_FACTOR));
|
dealerIcon.layoutXProperty().bind(parent.widthProperty().multiply(DEALER_ICON_X_FACTOR));
|
||||||
dealerIcon.setVisible(false);
|
dealerIcon.setVisible(false);
|
||||||
}
|
}
|
||||||
@@ -160,6 +184,14 @@ public class PlayerStatusController {
|
|||||||
if (isDealer && dealerImage != null) {
|
if (isDealer && dealerImage != null) {
|
||||||
dealerIcon.setImage(dealerImage);
|
dealerIcon.setImage(dealerImage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (playerProfileImage != null) {
|
||||||
|
if (isDealer && profileDealerImage != null) {
|
||||||
|
playerProfileImage.setImage(profileDealerImage);
|
||||||
|
} else if (profileUserImage != null) {
|
||||||
|
playerProfileImage.setImage(profileUserImage);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user