Fix: Improvements to UI
This commit is contained in:
@@ -32,7 +32,7 @@ public class ClientLauncherGUI extends Application {
|
|||||||
// Connessione in un thread separato — non bloccare il JavaFX thread!
|
// Connessione in un thread separato — non bloccare il JavaFX thread!
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
if (networkType == 0) {
|
if (networkType == 0) {
|
||||||
RMIClient client = new RMIClient(controller, ip, 1099);
|
RMIClient client = new RMIClient(controller, ip, 1099, "localhost");
|
||||||
if (client.connect(nome, numPlayer)) {
|
if (client.connect(nome, numPlayer)) {
|
||||||
controller.setClient(client);
|
controller.setClient(client);
|
||||||
// Da qui in poi il server chiamerà onGameInit → render()
|
// Da qui in poi il server chiamerà onGameInit → render()
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ public class Game implements Serializable {
|
|||||||
* The mapping between slots and the players assigned to them.
|
* The mapping between slots and the players assigned to them.
|
||||||
*/
|
*/
|
||||||
private HashMap<Slot,Player> slotMap;
|
private HashMap<Slot,Player> slotMap;
|
||||||
|
public HashMap<Slot,Player> getSlotMap() {return slotMap;};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The configured number of players for this game.
|
* The configured number of players for this game.
|
||||||
|
|||||||
@@ -22,6 +22,11 @@ public class GUI implements IView { // stessa interfaccia che implementa TUI
|
|||||||
public void setModel(Game model) {
|
public void setModel(Game model) {
|
||||||
this.model = model;
|
this.model = model;
|
||||||
mainView.setModel(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() {
|
public void render() {
|
||||||
Platform.runLater(() -> {
|
Platform.runLater(() -> {
|
||||||
mainView.render();
|
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.Cards.TribeCard;
|
||||||
import it.polimi.ingsw.gc14.Model.Game;
|
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.fxml.FXML;
|
||||||
|
import javafx.geometry.Pos;
|
||||||
|
import javafx.scene.control.Button;
|
||||||
import javafx.scene.image.*;
|
import javafx.scene.image.*;
|
||||||
import javafx.scene.layout.*;
|
import javafx.scene.layout.*;
|
||||||
import javafx.scene.shape.*;
|
import javafx.scene.shape.*;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class MainFXMLController {
|
public class MainFXMLController {
|
||||||
|
|
||||||
@@ -17,6 +22,8 @@ public class MainFXMLController {
|
|||||||
@FXML private HBox myHand;
|
@FXML private HBox myHand;
|
||||||
@FXML private VBox playersHand;
|
@FXML private VBox playersHand;
|
||||||
|
|
||||||
|
@FXML private Button reload;
|
||||||
|
|
||||||
private Game model;
|
private Game model;
|
||||||
|
|
||||||
public void setModel(Game model) {
|
public void setModel(Game model) {
|
||||||
@@ -26,17 +33,54 @@ public class MainFXMLController {
|
|||||||
public void render() {
|
public void render() {
|
||||||
Image placeholder = new Image(getClass().getResourceAsStream("/GUIImages/Fronts/card-001.png"));
|
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()) {
|
for (TribeCard card : model.getUpperListTribeCards()) {
|
||||||
ImageView view = new ImageView(placeholder);
|
ImageView view = new ImageView(placeholder);
|
||||||
view.setFitHeight(250);
|
view.fitHeightProperty().bind(upperList.heightProperty().subtract(10));
|
||||||
view.setPreserveRatio(true);
|
view.setPreserveRatio(true);
|
||||||
|
|
||||||
|
view.setOnMouseClicked(e -> System.out.println(card.toStringBoard()));
|
||||||
|
|
||||||
upperList.getChildren().add(view);
|
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()) {
|
for (TribeCard card : model.getLowerListTribeCards()) {
|
||||||
ImageView view = new ImageView(placeholder);
|
ImageView view = new ImageView(placeholder);
|
||||||
view.setFitHeight(250);
|
view.fitHeightProperty().bind(upperList.heightProperty().subtract(10));
|
||||||
view.setPreserveRatio(true);
|
view.setPreserveRatio(true);
|
||||||
|
|
||||||
|
view.setOnMouseClicked(e -> System.out.println(card.toStringBoard()));
|
||||||
|
|
||||||
lowerList.getChildren().add(view);
|
lowerList.getChildren().add(view);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,4 +36,8 @@ public class MainView {
|
|||||||
public void render() {
|
public void render() {
|
||||||
fxmlController.render();
|
fxmlController.render();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void reload() {
|
||||||
|
render();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<?import javafx.scene.control.Button?>
|
||||||
<?import javafx.scene.layout.HBox?>
|
<?import javafx.scene.layout.HBox?>
|
||||||
<?import javafx.scene.layout.VBox?>
|
<?import javafx.scene.layout.VBox?>
|
||||||
|
|
||||||
@@ -7,12 +8,15 @@
|
|||||||
<children>
|
<children>
|
||||||
<VBox prefHeight="1080.0" prefWidth="1486.0">
|
<VBox prefHeight="1080.0" prefWidth="1486.0">
|
||||||
<children>
|
<children>
|
||||||
<HBox fx:id="upperList" prefHeight="250.0" prefWidth="200.0" style="-fx-background-color: #91352d;" />
|
<HBox fx:id="upperList" prefHeight="255.0" prefWidth="200.0" style="-fx-background-color: #91352d;" />
|
||||||
<HBox fx:id="board" prefHeight="250.0" prefWidth="200.0" style="-fx-background-color: #2d3c91;" />
|
<HBox fx:id="board" prefHeight="300.0" prefWidth="200.0" style="-fx-background-color: #2d3c91;" />
|
||||||
<HBox fx:id="lowerList" prefHeight="250.0" prefWidth="200.0" style="-fx-background-color: #2d915b;" />
|
<HBox fx:id="lowerList" prefHeight="255.0" prefWidth="200.0" style="-fx-background-color: #2d915b;" />
|
||||||
<HBox fx:id="myHand" prefHeight="250.0" prefWidth="1324.0" style="-fx-background-color: #8e912d;" />
|
<HBox fx:id="myHand" prefHeight="270.0" prefWidth="1324.0" style="-fx-background-color: #8e912d;" />
|
||||||
</children>
|
</children>
|
||||||
</VBox>
|
</VBox>
|
||||||
<VBox fx:id="playersHand" prefHeight="1080.0" prefWidth="531.0" style="-fx-background-color: #742d91;" />
|
<VBox fx:id="playersHand" prefHeight="1080.0" prefWidth="531.0" style="-fx-background-color: #742d91;">
|
||||||
|
<children>
|
||||||
|
<Button fx:id="reload" mnemonicParsing="false" onAction="#render" prefHeight="335.0" prefWidth="510.0" text="Reload" />
|
||||||
|
</children></VBox>
|
||||||
</children>
|
</children>
|
||||||
</HBox>
|
</HBox>
|
||||||
|
|||||||
Reference in New Issue
Block a user