Fix: Improvements to UI
This commit is contained in:
@@ -22,6 +22,11 @@ public class GUI implements IView { // stessa interfaccia che implementa TUI
|
||||
public void setModel(Game model) {
|
||||
this.model = model;
|
||||
mainView.setModel(model);
|
||||
|
||||
Platform.runLater(() -> {
|
||||
stage.setScene(mainView.getScene());
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -32,7 +37,6 @@ public class GUI implements IView { // stessa interfaccia che implementa TUI
|
||||
public void render() {
|
||||
Platform.runLater(() -> {
|
||||
mainView.render();
|
||||
stage.setScene(mainView.getScene());
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -2,12 +2,17 @@ package it.polimi.ingsw.gc14.View.GUI;
|
||||
|
||||
import it.polimi.ingsw.gc14.Model.Cards.TribeCard;
|
||||
import it.polimi.ingsw.gc14.Model.Game;
|
||||
import it.polimi.ingsw.gc14.Model.Player;
|
||||
import it.polimi.ingsw.gc14.Model.Slot;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.image.*;
|
||||
import javafx.scene.layout.*;
|
||||
import javafx.scene.shape.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class MainFXMLController {
|
||||
|
||||
@@ -17,6 +22,8 @@ public class MainFXMLController {
|
||||
@FXML private HBox myHand;
|
||||
@FXML private VBox playersHand;
|
||||
|
||||
@FXML private Button reload;
|
||||
|
||||
private Game model;
|
||||
|
||||
public void setModel(Game model) {
|
||||
@@ -26,17 +33,54 @@ public class MainFXMLController {
|
||||
public void render() {
|
||||
Image placeholder = new Image(getClass().getResourceAsStream("/GUIImages/Fronts/card-001.png"));
|
||||
|
||||
upperList.setSpacing(6);
|
||||
upperList.setAlignment(Pos.CENTER);
|
||||
upperList.getChildren().clear();
|
||||
|
||||
for (TribeCard card : model.getUpperListTribeCards()) {
|
||||
ImageView view = new ImageView(placeholder);
|
||||
view.setFitHeight(250);
|
||||
view.fitHeightProperty().bind(upperList.heightProperty().subtract(10));
|
||||
view.setPreserveRatio(true);
|
||||
|
||||
view.setOnMouseClicked(e -> System.out.println(card.toStringBoard()));
|
||||
|
||||
upperList.getChildren().add(view);
|
||||
}
|
||||
|
||||
|
||||
board.setSpacing(6);
|
||||
board.setAlignment(Pos.CENTER);
|
||||
board.getChildren().clear();
|
||||
|
||||
for (Map.Entry<Slot, Player> entry : model.getSlotMap().entrySet()) {
|
||||
Slot slot = entry.getKey();
|
||||
Image slotImg = new Image(getClass().getResourceAsStream("/GUIImages/Fronts/card-"+slot.getSlotId()+".png"));
|
||||
ImageView view = new ImageView(slotImg);
|
||||
|
||||
view.fitHeightProperty().bind(board.heightProperty().subtract(10));
|
||||
view.setPreserveRatio(true);
|
||||
|
||||
//view.setOnMouseClicked(e -> System.out.println(card.toStringBoard()));
|
||||
|
||||
board.getChildren().add(view);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
lowerList.setSpacing(6);
|
||||
lowerList.setAlignment(Pos.CENTER);
|
||||
lowerList.getChildren().clear();
|
||||
|
||||
lowerList.getChildren().clear();
|
||||
for (TribeCard card : model.getLowerListTribeCards()) {
|
||||
ImageView view = new ImageView(placeholder);
|
||||
view.setFitHeight(250);
|
||||
view.fitHeightProperty().bind(upperList.heightProperty().subtract(10));
|
||||
view.setPreserveRatio(true);
|
||||
|
||||
view.setOnMouseClicked(e -> System.out.println(card.toStringBoard()));
|
||||
|
||||
lowerList.getChildren().add(view);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,4 +36,8 @@ public class MainView {
|
||||
public void render() {
|
||||
fxmlController.render();
|
||||
}
|
||||
|
||||
public void reload() {
|
||||
render();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user