mirror of
https://github.com/2OOP/pism.git
synced 2026-02-04 10:54:51 +00:00
Squashed commit of the following:
commit a517f2f302baa89f8ef59946a31c7bb59c56770f Author: Stef <stbuwalda@gmail.com> Date: Thu Nov 27 15:43:43 2025 +0100 Make it so the game shows "Waiting on ... to make their move". Styling isn't done but it is easier to see who's turn it is. There is a lot of structuring to do in the previous code...
This commit is contained in:
@@ -15,10 +15,12 @@ import javafx.scene.text.Text;
|
|||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
public final class GameView extends View {
|
public final class GameView extends View {
|
||||||
|
// TODO: This should be it's own file...
|
||||||
private static class GameOverView extends View {
|
private static class GameOverView extends View {
|
||||||
private final boolean iWon;
|
private final boolean iWon;
|
||||||
private final String winner;
|
private final String winner;
|
||||||
|
|
||||||
|
// TODO: Make winner generic, there is no "I won" unless you play online or against bot. Should be a generic "... won" to simplify
|
||||||
public GameOverView(boolean iWon, String winner) {
|
public GameOverView(boolean iWon, String winner) {
|
||||||
super(false, "bg-popup");
|
super(false, "bg-popup");
|
||||||
|
|
||||||
@@ -71,6 +73,8 @@ public final class GameView extends View {
|
|||||||
|
|
||||||
private final Text nextPlayerHeader;
|
private final Text nextPlayerHeader;
|
||||||
|
|
||||||
|
private final Text gameStateFeedback = text();
|
||||||
|
|
||||||
private final ListView<Text> chatListView;
|
private final ListView<Text> chatListView;
|
||||||
private final TextField chatInput;
|
private final TextField chatInput;
|
||||||
|
|
||||||
@@ -112,34 +116,24 @@ public final class GameView extends View {
|
|||||||
exitButton.setText(AppContext.getString("exit"));
|
exitButton.setText(AppContext.getString("exit"));
|
||||||
exitButton.setOnAction(_ -> onExit.run());
|
exitButton.setOnAction(_ -> onExit.run());
|
||||||
|
|
||||||
currentPlayerHeader = header("", "current-player");
|
currentPlayerHeader = header("", "header");
|
||||||
currentMoveHeader = header();
|
currentMoveHeader = header();
|
||||||
|
|
||||||
nextPlayerHeader = header();
|
nextPlayerHeader = header();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setup() {
|
public void setup() {
|
||||||
add(Pos.TOP_RIGHT,
|
add(
|
||||||
fit(vboxFill(
|
Pos.TOP_CENTER,
|
||||||
currentPlayerHeader,
|
gameStateFeedback
|
||||||
|
|
||||||
hboxFill(
|
|
||||||
separator(),
|
|
||||||
currentMoveHeader,
|
|
||||||
separator()
|
|
||||||
),
|
|
||||||
|
|
||||||
nextPlayerHeader
|
|
||||||
))
|
|
||||||
);
|
);
|
||||||
|
|
||||||
add(Pos.BOTTOM_LEFT,
|
add(Pos.BOTTOM_LEFT,
|
||||||
vboxFill(
|
vboxFill(
|
||||||
forfeitButton,
|
forfeitButton,
|
||||||
exitButton
|
exitButton
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (chatListView != null) {
|
if (chatListView != null) {
|
||||||
add(Pos.BOTTOM_RIGHT,
|
add(Pos.BOTTOM_RIGHT,
|
||||||
@@ -153,6 +147,7 @@ public final class GameView extends View {
|
|||||||
|
|
||||||
public void nextPlayer(boolean isMe, String currentPlayer, String currentMove, String nextPlayer) {
|
public void nextPlayer(boolean isMe, String currentPlayer, String currentMove, String nextPlayer) {
|
||||||
Platform.runLater(() -> {
|
Platform.runLater(() -> {
|
||||||
|
gameStateFeedback.setText("Waiting on " + currentPlayer + " to make their move.");
|
||||||
currentPlayerHeader.setText(currentPlayer);
|
currentPlayerHeader.setText(currentPlayer);
|
||||||
currentMoveHeader.setText(currentMove);
|
currentMoveHeader.setText(currentMove);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user