Feat: Add chat box into game ui
This commit is contained in:
+13
-9
@@ -7,6 +7,7 @@ import ch.unibas.dmi.dbis.cs108.casono.client.game.GameState;
|
|||||||
import ch.unibas.dmi.dbis.cs108.casono.client.game.Player;
|
import ch.unibas.dmi.dbis.cs108.casono.client.game.Player;
|
||||||
import ch.unibas.dmi.dbis.cs108.casono.client.game.PlayerId;
|
import ch.unibas.dmi.dbis.cs108.casono.client.game.PlayerId;
|
||||||
import ch.unibas.dmi.dbis.cs108.casono.client.network.ClientService;
|
import ch.unibas.dmi.dbis.cs108.casono.client.network.ClientService;
|
||||||
|
import ch.unibas.dmi.dbis.cs108.casono.client.ui.chatui.ChatBoxController;
|
||||||
import ch.unibas.dmi.dbis.cs108.casono.client.ui.gameui.gameuicomponents.PlayerStatusController;
|
import ch.unibas.dmi.dbis.cs108.casono.client.ui.gameui.gameuicomponents.PlayerStatusController;
|
||||||
import ch.unibas.dmi.dbis.cs108.casono.client.ui.gameui.gameuicomponents.TaskbarController;
|
import ch.unibas.dmi.dbis.cs108.casono.client.ui.gameui.gameuicomponents.TaskbarController;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -18,6 +19,7 @@ import java.util.concurrent.CompletableFuture;
|
|||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.fxml.FXMLLoader;
|
import javafx.fxml.FXMLLoader;
|
||||||
|
import javafx.scene.Node;
|
||||||
import javafx.scene.Parent;
|
import javafx.scene.Parent;
|
||||||
import javafx.scene.Scene;
|
import javafx.scene.Scene;
|
||||||
import javafx.scene.control.Label;
|
import javafx.scene.control.Label;
|
||||||
@@ -239,7 +241,6 @@ public class CasinoGameController {
|
|||||||
// empty display only (optional)
|
// empty display only (optional)
|
||||||
renderCommunityCards(List.of());
|
renderCommunityCards(List.of());
|
||||||
renderPlayerCards(List.of());
|
renderPlayerCards(List.of());
|
||||||
initializeChatIfPossible();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -257,7 +258,7 @@ public class CasinoGameController {
|
|||||||
this.chatUsername = username;
|
this.chatUsername = username;
|
||||||
this.chatClientService = clientService;
|
this.chatClientService = clientService;
|
||||||
this.chatLobbyId = lobbyId;
|
this.chatLobbyId = lobbyId;
|
||||||
initializeChatIfPossible();
|
//initializeChatIfPossible();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -270,16 +271,14 @@ public class CasinoGameController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
chatController = new ChatController(chatUsername, chatClientService);
|
ChatBoxController chatBoxController = new ChatBoxController(chatUsername, chatController);
|
||||||
|
|
||||||
URL resource = getClass().getResource("/ui-structure/components/chatui/chatbox.fxml");
|
URL resource = getClass().getResource("/ui-structure/components/chatui/chatbox.fxml");
|
||||||
FXMLLoader loader = new FXMLLoader(resource);
|
FXMLLoader loader = new FXMLLoader(resource);
|
||||||
loader.setController(chatController.getChatBoxController());
|
loader.setController(chatBoxController);
|
||||||
|
|
||||||
Parent root = loader.load();
|
chatContainer.getChildren().add(loader.load());
|
||||||
|
|
||||||
Stage chatStage = new Stage();
|
|
||||||
|
|
||||||
|
/*
|
||||||
chatStage.setTitle("Casono");
|
chatStage.setTitle("Casono");
|
||||||
|
|
||||||
String iconPath = getClass().getResource("/images/logoinverted.png").toExternalForm();
|
String iconPath = getClass().getResource("/images/logoinverted.png").toExternalForm();
|
||||||
@@ -294,7 +293,7 @@ public class CasinoGameController {
|
|||||||
chatStage.setOnCloseRequest(event -> chatInitialized = false);
|
chatStage.setOnCloseRequest(event -> chatInitialized = false);
|
||||||
|
|
||||||
chatStage.show();
|
chatStage.show();
|
||||||
|
*/
|
||||||
if (chatLobbyId >= 0) {
|
if (chatLobbyId >= 0) {
|
||||||
chatController.setLobbyChat(chatLobbyId);
|
chatController.setLobbyChat(chatLobbyId);
|
||||||
}
|
}
|
||||||
@@ -1340,4 +1339,9 @@ public class CasinoGameController {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void startChat(ChatController chatController) {
|
||||||
|
this.chatController = chatController;
|
||||||
|
initializeChatIfPossible();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package ch.unibas.dmi.dbis.cs108.casono.client.ui.gameui;
|
package ch.unibas.dmi.dbis.cs108.casono.client.ui.gameui;
|
||||||
|
|
||||||
|
import ch.unibas.dmi.dbis.cs108.casono.client.chat.ChatController;
|
||||||
import ch.unibas.dmi.dbis.cs108.casono.client.ClientApp;
|
import ch.unibas.dmi.dbis.cs108.casono.client.ClientApp;
|
||||||
import ch.unibas.dmi.dbis.cs108.casono.client.game.GameService;
|
import ch.unibas.dmi.dbis.cs108.casono.client.game.GameService;
|
||||||
import ch.unibas.dmi.dbis.cs108.casono.client.game.PlayerId;
|
import ch.unibas.dmi.dbis.cs108.casono.client.game.PlayerId;
|
||||||
@@ -25,6 +26,7 @@ public class CasinoGameUI extends Application {
|
|||||||
private static final Logger LOG = Logger.getLogger(CasinoGameUI.class.getName());
|
private static final Logger LOG = Logger.getLogger(CasinoGameUI.class.getName());
|
||||||
|
|
||||||
private static ClientService clientService;
|
private static ClientService clientService;
|
||||||
|
private static ChatController chatController;
|
||||||
|
|
||||||
private static String username;
|
private static String username;
|
||||||
private static int lobbyId = -1;
|
private static int lobbyId = -1;
|
||||||
@@ -65,6 +67,10 @@ public class CasinoGameUI extends Application {
|
|||||||
CasinoGameUI.lobbyId = lobbyId;
|
CasinoGameUI.lobbyId = lobbyId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void setChatController(ChatController chatController) {
|
||||||
|
CasinoGameUI.chatController = chatController;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The main entry point for the JavaFX application. This method is called after the application
|
* The main entry point for the JavaFX application. This method is called after the application
|
||||||
* is
|
* is
|
||||||
@@ -113,6 +119,8 @@ public class CasinoGameUI extends Application {
|
|||||||
Parent root = fxmlLoader.load();
|
Parent root = fxmlLoader.load();
|
||||||
CasinoGameController controller = fxmlLoader.getController();
|
CasinoGameController controller = fxmlLoader.getController();
|
||||||
|
|
||||||
|
controller.startChat(chatController);
|
||||||
|
|
||||||
if (lobbyId <= 0) {
|
if (lobbyId <= 0) {
|
||||||
throw new IllegalStateException("CasinoGameUI: lobbyId must be set before start()");
|
throw new IllegalStateException("CasinoGameUI: lobbyId must be set before start()");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user