Feat: Add chat box into the game screen #303
@@ -7,6 +7,7 @@ import ch.unibas.dmi.dbis.cs108.casono.client.ui.chatui.ChatBoxController;
|
|||||||
import ch.unibas.dmi.dbis.cs108.casono.client.ui.chatui.ChatViewController;
|
import ch.unibas.dmi.dbis.cs108.casono.client.ui.chatui.ChatViewController;
|
||||||
import ch.unibas.dmi.dbis.cs108.casono.server.network.command.parsing.RequestParameter;
|
import ch.unibas.dmi.dbis.cs108.casono.server.network.command.parsing.RequestParameter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -15,7 +16,6 @@ import java.util.Set;
|
|||||||
import java.util.Timer;
|
import java.util.Timer;
|
||||||
import java.util.TimerTask;
|
import java.util.TimerTask;
|
||||||
import java.util.WeakHashMap;
|
import java.util.WeakHashMap;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
@@ -41,7 +41,9 @@ public class ChatController {
|
|||||||
return chatBoxController;
|
return chatBoxController;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setChatBoxController(ChatBoxController chatBoxController) {this.chatBoxController = chatBoxController; }
|
public void setChatBoxController(ChatBoxController chatBoxController) {
|
||||||
|
this.chatBoxController = chatBoxController;
|
||||||
|
}
|
||||||
|
|
||||||
private ChatBoxController chatBoxController;
|
private ChatBoxController chatBoxController;
|
||||||
private int lobbyId = -1;
|
private int lobbyId = -1;
|
||||||
@@ -71,7 +73,6 @@ public class ChatController {
|
|||||||
|
|
||||||
public final Map<ChatController.ChatKey, ChatViewController> activeChatControllers;
|
public final Map<ChatController.ChatKey, ChatViewController> activeChatControllers;
|
||||||
|
|
||||||
|
|
||||||
private final Logger logger;
|
private final Logger logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+6
-8
@@ -3,6 +3,7 @@ package ch.unibas.dmi.dbis.cs108.casono.client.ui.chatui;
|
|||||||
import ch.unibas.dmi.dbis.cs108.casono.client.chat.ChatController;
|
import ch.unibas.dmi.dbis.cs108.casono.client.chat.ChatController;
|
||||||
import ch.unibas.dmi.dbis.cs108.casono.client.chat.ChatModel;
|
import ch.unibas.dmi.dbis.cs108.casono.client.chat.ChatModel;
|
||||||
import ch.unibas.dmi.dbis.cs108.casono.client.chat.ChatType;
|
import ch.unibas.dmi.dbis.cs108.casono.client.chat.ChatType;
|
||||||
|
import ch.unibas.dmi.dbis.cs108.casono.client.chat.Message;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -11,8 +12,6 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
import ch.unibas.dmi.dbis.cs108.casono.client.chat.Message;
|
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.fxml.FXMLLoader;
|
import javafx.fxml.FXMLLoader;
|
||||||
@@ -45,7 +44,6 @@ public class ChatBoxController {
|
|||||||
|
|
||||||
@FXML private final Map<String, Tab> usernameTabMap;
|
@FXML private final Map<String, Tab> usernameTabMap;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for the ChatBoxController, initializes the necessary fields and data structures
|
* Constructor for the ChatBoxController, initializes the necessary fields and data structures
|
||||||
* for managing chat tabs and whisper chats.
|
* for managing chat tabs and whisper chats.
|
||||||
@@ -76,9 +74,7 @@ public class ChatBoxController {
|
|||||||
public void initialize() {
|
public void initialize() {
|
||||||
ChatType global = ChatType.GLOBAL;
|
ChatType global = ChatType.GLOBAL;
|
||||||
ChatModel globalChatModel = new ChatModel(global, username, -1, null);
|
ChatModel globalChatModel = new ChatModel(global, username, -1, null);
|
||||||
chatController
|
chatController.getChatModelMap().put(new ChatController.ChatKey(global), globalChatModel);
|
||||||
.getChatModelMap()
|
|
||||||
.put(new ChatController.ChatKey(global), globalChatModel);
|
|
||||||
addChatTab("GLOBAL", globalChatModel, global);
|
addChatTab("GLOBAL", globalChatModel, global);
|
||||||
addWhisperChatButton.setOnAction(event -> addWhisperChatButton.show());
|
addWhisperChatButton.setOnAction(event -> addWhisperChatButton.show());
|
||||||
}
|
}
|
||||||
@@ -197,7 +193,8 @@ public class ChatBoxController {
|
|||||||
ChatViewController chatViewController =
|
ChatViewController chatViewController =
|
||||||
new ChatViewController(
|
new ChatViewController(
|
||||||
this.chatController, chatModel, this.username);
|
this.chatController, chatModel, this.username);
|
||||||
chatController.activeChatControllers.put(new ChatController.ChatKey(chatType), chatViewController);
|
chatController.activeChatControllers.put(
|
||||||
|
new ChatController.ChatKey(chatType), chatViewController);
|
||||||
fxmlLoader.setController(chatViewController);
|
fxmlLoader.setController(chatViewController);
|
||||||
Node load = fxmlLoader.load();
|
Node load = fxmlLoader.load();
|
||||||
VBox.setVgrow(load, Priority.ALWAYS);
|
VBox.setVgrow(load, Priority.ALWAYS);
|
||||||
@@ -259,7 +256,8 @@ public class ChatBoxController {
|
|||||||
globalController.showMessage(msg);
|
globalController.showMessage(msg);
|
||||||
}
|
}
|
||||||
for (String user : chatController.getLocalUserList()) {
|
for (String user : chatController.getLocalUserList()) {
|
||||||
ChatController.ChatKey whisperUserKey = new ChatController.ChatKey(ChatType.WHISPER, user);
|
ChatController.ChatKey whisperUserKey =
|
||||||
|
new ChatController.ChatKey(ChatType.WHISPER, user);
|
||||||
if (chatModelMap.containsKey(whisperUserKey)) {
|
if (chatModelMap.containsKey(whisperUserKey)) {
|
||||||
ChatModel whisperChatModel = chatModelMap.get(whisperUserKey);
|
ChatModel whisperChatModel = chatModelMap.get(whisperUserKey);
|
||||||
addWhisperChat(user, whisperChatModel);
|
addWhisperChat(user, whisperChatModel);
|
||||||
|
|||||||
+4
-8
@@ -7,7 +7,6 @@ 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;
|
||||||
@@ -20,15 +19,12 @@ 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.Node;
|
||||||
import javafx.scene.Parent;
|
|
||||||
import javafx.scene.Scene;
|
|
||||||
import javafx.scene.control.Label;
|
import javafx.scene.control.Label;
|
||||||
import javafx.scene.image.Image;
|
import javafx.scene.image.Image;
|
||||||
import javafx.scene.image.ImageView;
|
import javafx.scene.image.ImageView;
|
||||||
import javafx.scene.layout.AnchorPane;
|
import javafx.scene.layout.AnchorPane;
|
||||||
import javafx.scene.layout.HBox;
|
import javafx.scene.layout.HBox;
|
||||||
import javafx.scene.layout.VBox;
|
import javafx.scene.layout.VBox;
|
||||||
import javafx.stage.Stage;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller for the casino gaming area.
|
* Controller for the casino gaming area.
|
||||||
@@ -71,6 +67,7 @@ public class CasinoGameController {
|
|||||||
private int lastPot = Integer.MIN_VALUE;
|
private int lastPot = Integer.MIN_VALUE;
|
||||||
private ChatController chatController;
|
private ChatController chatController;
|
||||||
|
|
||||||
|
public static final double CHAT_CONTAINER_CONSTANT = 6.0;
|
||||||
private static final int TOTAL_SLOTS = 5;
|
private static final int TOTAL_SLOTS = 5;
|
||||||
private static final int PLAYER_SLOTS = 2;
|
private static final int PLAYER_SLOTS = 2;
|
||||||
private int pot = 0;
|
private int pot = 0;
|
||||||
@@ -288,10 +285,10 @@ public class CasinoGameController {
|
|||||||
loader.setController(chatController.getChatBoxController());
|
loader.setController(chatController.getChatBoxController());
|
||||||
Node chatNode = loader.load();
|
Node chatNode = loader.load();
|
||||||
chatContainer.getChildren().setAll(chatNode);
|
chatContainer.getChildren().setAll(chatNode);
|
||||||
AnchorPane.setTopAnchor(chatNode, 6.0);
|
AnchorPane.setTopAnchor(chatNode, CHAT_CONTAINER_CONSTANT);
|
||||||
AnchorPane.setBottomAnchor(chatNode, 6.0);
|
AnchorPane.setBottomAnchor(chatNode, CHAT_CONTAINER_CONSTANT);
|
||||||
AnchorPane.setLeftAnchor(chatNode, 0.0);
|
AnchorPane.setLeftAnchor(chatNode, 0.0);
|
||||||
AnchorPane.setRightAnchor(chatNode, 6.0);
|
AnchorPane.setRightAnchor(chatNode, CHAT_CONTAINER_CONSTANT);
|
||||||
|
|
||||||
chatController.getChatBoxController().loadChats();
|
chatController.getChatBoxController().loadChats();
|
||||||
chatInitialized = true;
|
chatInitialized = true;
|
||||||
@@ -1338,5 +1335,4 @@ public class CasinoGameController {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
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.chat.ChatController;
|
||||||
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;
|
||||||
import ch.unibas.dmi.dbis.cs108.casono.client.network.ClientService;
|
import ch.unibas.dmi.dbis.cs108.casono.client.network.ClientService;
|
||||||
@@ -58,7 +58,9 @@ public class CasinoGameUI extends Application {
|
|||||||
CasinoGameUI.username = username;
|
CasinoGameUI.username = username;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setChatController(ChatController chatController) {CasinoGameUI.chatController = chatController;}
|
public static void setChatController(ChatController chatController) {
|
||||||
|
CasinoGameUI.chatController = chatController;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the lobby ID to be used by the application.
|
* Sets the lobby ID to be used by the application.
|
||||||
|
|||||||
+4
-2
@@ -1,7 +1,7 @@
|
|||||||
package ch.unibas.dmi.dbis.cs108.casono.client.ui.lobbyui;
|
package ch.unibas.dmi.dbis.cs108.casono.client.ui.lobbyui;
|
||||||
|
|
||||||
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.chat.ChatController;
|
||||||
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.network.LobbyClient;
|
import ch.unibas.dmi.dbis.cs108.casono.client.network.LobbyClient;
|
||||||
import ch.unibas.dmi.dbis.cs108.casono.client.ui.gameui.CasinoGameUI;
|
import ch.unibas.dmi.dbis.cs108.casono.client.ui.gameui.CasinoGameUI;
|
||||||
@@ -591,5 +591,7 @@ public class LobbyButtonGridManager {
|
|||||||
return lobbyClient;
|
return lobbyClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setChatController(ChatController chatController) { this.chatController = chatController; }
|
public void setChatController(ChatController chatController) {
|
||||||
|
this.chatController = chatController;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user