Feat: Add chat box into the game screen #303

Merged
m.ginkel merged 28 commits from feat/chat-integration into main 2026-04-24 14:14:17 +02:00
2 changed files with 19 additions and 5 deletions
Showing only changes of commit 8bb0bfaf09 - Show all commits
@@ -250,6 +250,11 @@ public class ChatBoxController {
ChatController.ChatKey key = new ChatController.ChatKey(ChatType.GLOBAL); ChatController.ChatKey key = new ChatController.ChatKey(ChatType.GLOBAL);
ChatModel global = chatModelMap.get(key); ChatModel global = chatModelMap.get(key);
ChatViewController globalController = chatController.activeChatControllers.get(key); ChatViewController globalController = chatController.activeChatControllers.get(key);
for (String user : chatController.getLocalUserList()) {
addWhisperUser(user);
}
for (Message msg : global.messages) { for (Message msg : global.messages) {
globalController.showMessage(msg); globalController.showMessage(msg);
} }
@@ -265,7 +265,7 @@ public class CasinoGameController {
this.chatUsername = username; this.chatUsername = username;
this.chatClientService = clientService; this.chatClientService = clientService;
this.chatLobbyId = lobbyId; this.chatLobbyId = lobbyId;
//startChat(chatController); initializeChatIfPossible();
} }
/** /**
@@ -273,13 +273,16 @@ public class CasinoGameController {
* is available and the chat has not already been initialized. * is available and the chat has not already been initialized.
*/ */
private void initializeChatIfPossible() { private void initializeChatIfPossible() {
if (chatInitialized || chatClientService == null || chatUsername == null) { if (chatInitialized
|| chatClientService == null
|| chatUsername == null
|| chatController == null) {
return; return;
} }
try { try {
String username = chatUsername; chatController.updateUsername(chatUsername);
// chatController = new ChatController(username, chatClientService);
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(chatController.getChatBoxController());
@@ -289,7 +292,13 @@ public class CasinoGameController {
AnchorPane.setBottomAnchor(chatNode, 6.0); AnchorPane.setBottomAnchor(chatNode, 6.0);
AnchorPane.setLeftAnchor(chatNode, 0.0); AnchorPane.setLeftAnchor(chatNode, 0.0);
AnchorPane.setRightAnchor(chatNode, 6.0); AnchorPane.setRightAnchor(chatNode, 6.0);
// gridManager.setChatController(chatController);
chatController.getChatBoxController().loadChats();
chatInitialized = true;
if (chatLobbyId >= 0) {
chatController.setLobbyChat(chatLobbyId);
}
} catch (IOException e) { } catch (IOException e) {
LOGGER.warning("Could not initialize game chat UI: " + e.getMessage()); LOGGER.warning("Could not initialize game chat UI: " + e.getMessage());
} }