Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexBaan committed Feb 15, 2024
2 parents b5e967e + b81c39e commit e3bbe20
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions src/main/java/it/unibo/view/AppViewImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.image.ImageView;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.VBox;
Expand All @@ -21,23 +22,20 @@
*/
public final class AppViewImpl implements AppView {
private final Stage stage;
private static final int DEFAULT_HEIGHT = 350;
private static final int DEFAULT_HEIGHT = 450;
private final BoardView boardView;
private final BankView bankView;
private final PlayersView playersView;

private final CurrentPlayerView currentPlayerView;

private final Map<String, Color> playerColors = new HashMap<>();

/**
* Constructor of AppView.
*
* @param stage the stage
* @param stage the stage
* @param players the list of players names
*/
public AppViewImpl(final Stage stage, final List<String> players) {

final MainController controller = new MainControllerImpl(this, players);
final var colors = List.of(Color.RED, Color.ORANGE, Color.LIMEGREEN, Color.MAGENTA);
controller.getPlayerNames().stream().forEach(p -> playerColors.put(p, colors.get(playerColors.size())));
Expand Down Expand Up @@ -73,6 +71,7 @@ public Scene getScene() throws IOException {
final Scene scene = new Scene(root);

rightSide.getChildren().add(costCard());
rightSide.getChildren().add(ruleButton());
rightSide.getChildren().add(bankView);
rightSide.getChildren().add(playersView);
root.setBottom(currentPlayerView);
Expand All @@ -87,12 +86,28 @@ public Scene getScene() throws IOException {
* @return an ImageView representing the cost card.
*/
private ImageView costCard() {
final ImageView costCard = new ImageView("imgs/building-costs/building_cost_no_develop_cards.png");
final ImageView costCard = new ImageView("imgs/building-costs/building_cost.png");
costCard.setFitHeight(DEFAULT_HEIGHT);
costCard.setPreserveRatio(true);
return costCard;
}

private Button ruleButton() {
final Button ruleButton = new Button("Rules");
final Stage stage = new Stage();
final BorderPane root = new BorderPane();
final ImageView imageView = new ImageView("imgs/rules/turn_rules.png");
imageView.setPreserveRatio(true);
imageView.fitHeightProperty().bind(stage.heightProperty());
root.setCenter(imageView);
stage.setScene(new Scene(root));
stage.setMaximized(true);
ruleButton.setOnAction(e -> {
stage.show();
});
return ruleButton;
}

@Override
public void redrawCurrentPlayer() {
currentPlayerView.draw();
Expand Down
Binary file modified src/main/resources/imgs/building-costs/building_cost.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.

0 comments on commit e3bbe20

Please sign in to comment.