Fix: whisper chat not working in game UI

This commit is contained in:
Julian Kropff
2026-04-24 11:16:34 +02:00
parent 33998e4a88
commit 8bb0bfaf09
2 changed files with 19 additions and 5 deletions
@@ -250,6 +250,11 @@ public class ChatBoxController {
ChatController.ChatKey key = new ChatController.ChatKey(ChatType.GLOBAL);
ChatModel global = chatModelMap.get(key);
ChatViewController globalController = chatController.activeChatControllers.get(key);
for (String user : chatController.getLocalUserList()) {
addWhisperUser(user);
}
for (Message msg : global.messages) {
globalController.showMessage(msg);
}
@@ -265,7 +265,7 @@ public class CasinoGameController {
this.chatUsername = username;
this.chatClientService = clientService;
this.chatLobbyId = lobbyId;
//startChat(chatController);
initializeChatIfPossible();
}
/**
@@ -273,13 +273,16 @@ public class CasinoGameController {
* is available and the chat has not already been initialized.
*/
private void initializeChatIfPossible() {
if (chatInitialized || chatClientService == null || chatUsername == null) {
if (chatInitialized
|| chatClientService == null
|| chatUsername == null
|| chatController == null) {
return;
}
try {
String username = chatUsername;
// chatController = new ChatController(username, chatClientService);
chatController.updateUsername(chatUsername);
URL resource = getClass().getResource("/ui-structure/components/chatui/chatbox.fxml");
FXMLLoader loader = new FXMLLoader(resource);
loader.setController(chatController.getChatBoxController());
@@ -289,7 +292,13 @@ public class CasinoGameController {
AnchorPane.setBottomAnchor(chatNode, 6.0);
AnchorPane.setLeftAnchor(chatNode, 0.0);
AnchorPane.setRightAnchor(chatNode, 6.0);
// gridManager.setChatController(chatController);
chatController.getChatBoxController().loadChats();
chatInitialized = true;
if (chatLobbyId >= 0) {
chatController.setLobbyChat(chatLobbyId);
}
} catch (IOException e) {
LOGGER.warning("Could not initialize game chat UI: " + e.getMessage());
}