Fix: small changes to ChatUI
This commit is contained in:
@@ -38,4 +38,8 @@ public class ClientApp {
|
|||||||
LOGGER.info("You've selected the client. It will connect port {} at host {}", port, host);
|
LOGGER.info("You've selected the client. It will connect port {} at host {}", port, host);
|
||||||
Launcher.main(new String[] {});
|
Launcher.main(new String[] {});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
start(args[0]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,10 @@ public class ChatController {
|
|||||||
chatClient = new ChatClient(clientService);
|
chatClient = new ChatClient(clientService);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ChatModel getChatModel(int index) {
|
||||||
|
return chatModelArrayList.get(index);
|
||||||
|
}
|
||||||
|
|
||||||
public void createLobbyChat(int lobbyId, ChatType chatType) {
|
public void createLobbyChat(int lobbyId, ChatType chatType) {
|
||||||
ChatModel chatModel = new ChatModel(chatType, username, lobbyId);
|
ChatModel chatModel = new ChatModel(chatType, username, lobbyId);
|
||||||
chatModelArrayList.add(chatModel);
|
chatModelArrayList.add(chatModel);
|
||||||
|
|||||||
+15
-11
@@ -3,18 +3,23 @@ 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 java.net.URL;
|
||||||
|
import java.util.ResourceBundle;
|
||||||
import java.util.Timer;
|
import java.util.Timer;
|
||||||
import java.util.TimerTask;
|
import java.util.TimerTask;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
|
import javafx.fxml.Initializable;
|
||||||
import javafx.scene.control.ButtonBar;
|
import javafx.scene.control.ButtonBar;
|
||||||
import javafx.scene.control.ToggleButton;
|
import javafx.scene.control.ToggleButton;
|
||||||
import javafx.scene.control.ToggleGroup;
|
import javafx.scene.control.ToggleGroup;
|
||||||
import javafx.scene.layout.VBox;
|
import javafx.scene.layout.VBox;
|
||||||
|
|
||||||
/** Responsible for the presentation of the ChatModel to the Client */
|
/** Responsible for the presentation of the ChatModel to the Client */
|
||||||
public class ChatViewController {
|
public class ChatViewController implements Initializable {
|
||||||
|
|
||||||
private final GlobalChatView globalChatView;
|
private final ChatModel globalChatModel;
|
||||||
|
private GlobalChatView globalChatView;
|
||||||
|
|
||||||
private LobbyChatView lobbyChatView;
|
private LobbyChatView lobbyChatView;
|
||||||
|
|
||||||
@@ -26,10 +31,6 @@ public class ChatViewController {
|
|||||||
|
|
||||||
private Boolean lobbyActivated;
|
private Boolean lobbyActivated;
|
||||||
|
|
||||||
@FXML private VBox whisperChatVBox;
|
|
||||||
|
|
||||||
@FXML private VBox whisperChat;
|
|
||||||
|
|
||||||
@FXML private ToggleButton changeGlobalChatButton;
|
@FXML private ToggleButton changeGlobalChatButton;
|
||||||
|
|
||||||
@FXML private ToggleButton changeLobbyChatButton;
|
@FXML private ToggleButton changeLobbyChatButton;
|
||||||
@@ -50,9 +51,8 @@ public class ChatViewController {
|
|||||||
String username, ChatModel globalChatModel, ChatController controller) {
|
String username, ChatModel globalChatModel, ChatController controller) {
|
||||||
this.username = username;
|
this.username = username;
|
||||||
this.controller = controller;
|
this.controller = controller;
|
||||||
this.globalChatView =
|
|
||||||
new GlobalChatView(username, new ChatModel(ChatType.GLOBAL, username), controller);
|
|
||||||
this.timer = new Timer();
|
this.timer = new Timer();
|
||||||
|
this.globalChatModel = globalChatModel;
|
||||||
timer.schedule(
|
timer.schedule(
|
||||||
new TimerTask() {
|
new TimerTask() {
|
||||||
@Override
|
@Override
|
||||||
@@ -69,10 +69,14 @@ public class ChatViewController {
|
|||||||
REFRESH_TIME);
|
REFRESH_TIME);
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
|
||||||
public void initialize() {}
|
|
||||||
|
|
||||||
@FXML
|
@Override
|
||||||
|
public void initialize(URL location, ResourceBundle resourceBundle) {
|
||||||
|
this.globalChatView =
|
||||||
|
new GlobalChatView(username, globalChatModel, controller);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public void setLobbyChat(int lobbyId) {
|
public void setLobbyChat(int lobbyId) {
|
||||||
this.lobbyChatView =
|
this.lobbyChatView =
|
||||||
new LobbyChatView(
|
new LobbyChatView(
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ 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 ch.unibas.dmi.dbis.cs108.casono.client.chat.Message;
|
||||||
|
import javafx.beans.property.BooleanProperty;
|
||||||
|
import javafx.beans.property.SimpleBooleanProperty;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.scene.control.Button;
|
import javafx.scene.control.Button;
|
||||||
import javafx.scene.control.Label;
|
import javafx.scene.control.Label;
|
||||||
@@ -28,6 +30,8 @@ public class GlobalChatView {
|
|||||||
|
|
||||||
@FXML private ScrollPane globalChatScrollPane;
|
@FXML private ScrollPane globalChatScrollPane;
|
||||||
|
|
||||||
|
final BooleanProperty isContentVisible = new SimpleBooleanProperty(true);
|
||||||
|
|
||||||
private static final int CHAT_PADDING = 20;
|
private static final int CHAT_PADDING = 20;
|
||||||
|
|
||||||
public GlobalChatView(String username, ChatModel globalChatModel, ChatController controller) {
|
public GlobalChatView(String username, ChatModel globalChatModel, ChatController controller) {
|
||||||
@@ -36,11 +40,11 @@ public class GlobalChatView {
|
|||||||
this.globalChatModel = globalChatModel;
|
this.globalChatModel = globalChatModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
globalChatInputField.setOnAction(event -> sendGlobalMessage());
|
globalChatInputField.setOnAction(event -> sendGlobalMessage());
|
||||||
globalChatSendButton.setOnAction(event -> sendGlobalMessage());
|
globalChatSendButton.setOnAction(event -> sendGlobalMessage());
|
||||||
globalChatScrollPane.vvalueProperty().bind(globalChatVBox.heightProperty());
|
globalChatScrollPane.vvalueProperty().bind(globalChatVBox.heightProperty());
|
||||||
|
globalChatVBox.visibleProperty().bind(isContentVisible);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendGlobalMessage() {
|
public void sendGlobalMessage() {
|
||||||
@@ -48,7 +52,7 @@ public class GlobalChatView {
|
|||||||
if (!message.isEmpty()) {
|
if (!message.isEmpty()) {
|
||||||
globalChatInputField.clear();
|
globalChatInputField.clear();
|
||||||
Message msg = new Message(ChatType.GLOBAL, 0, username, null, message);
|
Message msg = new Message(ChatType.GLOBAL, 0, username, null, message);
|
||||||
controller.sendMessageToNetwork(msg);
|
controller.onSendToNetwork(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,6 +68,6 @@ public class GlobalChatView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setVisibility(Boolean bool) {
|
public void setVisibility(Boolean bool) {
|
||||||
globalChatVBox.setVisible(bool);
|
this.isContentVisible.set(bool);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ public class LobbyChatView {
|
|||||||
if (!message.isEmpty()) {
|
if (!message.isEmpty()) {
|
||||||
lobbyChatInputField.clear();
|
lobbyChatInputField.clear();
|
||||||
Message msg = new Message(ChatType.LOBBY, lobbyId, username, null, message);
|
Message msg = new Message(ChatType.LOBBY, lobbyId, username, null, message);
|
||||||
controller.sendMessageToNetwork(msg);
|
controller.onSendToNetwork(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -106,7 +106,7 @@
|
|||||||
</VBox>
|
</VBox>
|
||||||
|
|
||||||
<!-- RECHTER BEREICH (Info-Box) -->
|
<!-- RECHTER BEREICH (Info-Box) -->
|
||||||
<fx:include source="components/Chatbox.fxml" GridPane.columnIndex="2"/>
|
<fx:include source="components/chatui/chatbox.fxml" GridPane.columnIndex="2"/>
|
||||||
</children>
|
</children>
|
||||||
</GridPane>
|
</GridPane>
|
||||||
</AnchorPane>
|
</AnchorPane>
|
||||||
|
|||||||
@@ -14,10 +14,10 @@
|
|||||||
- Globaler Chat (Gesamter Server)
|
- Globaler Chat (Gesamter Server)
|
||||||
|
|
||||||
Features, die später implementiert werden sollen:
|
Features, die später implementiert werden sollen:
|
||||||
- Schicke Chat-Bubbles mit Namen und Uhrzeit.
|
- Schicke Chat-Bubbles mit Namen und Uhrzeit./home/mathis/dev/Gruppe-13/src/main/resources/ui-structure/gameuicomponents/chatui
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<VBox xmlns="http://javafx.com/javafx/21"
|
<StackPane xmlns="http://javafx.com/javafx/21"
|
||||||
xmlns:fx="http://javafx.com/fxml/1"
|
xmlns:fx="http://javafx.com/fxml/1"
|
||||||
fx:controller="ch.unibas.dmi.dbis.cs108.casono.client.ui.chatui.ChatViewController"
|
fx:controller="ch.unibas.dmi.dbis.cs108.casono.client.ui.chatui.ChatViewController"
|
||||||
alignment="CENTER"
|
alignment="CENTER"
|
||||||
@@ -28,24 +28,22 @@
|
|||||||
<Insets top="30" right="30" bottom="30" left="10"/>
|
<Insets top="30" right="30" bottom="30" left="10"/>
|
||||||
</padding>
|
</padding>
|
||||||
|
|
||||||
<children>
|
|
||||||
|
|
||||||
<fx:include source="globalchat.fxml"/>
|
<fx:include source="globalchat.fxml"/>
|
||||||
|
|
||||||
<fx:include source="lobbychat.fxml"/>
|
<fx:include source="lobbychat.fxml"/>
|
||||||
|
|
||||||
<fx:include source="whisperchat.fxml"/>
|
<fx:include source="whisperchat.fxml"/>
|
||||||
|
|
||||||
<ButtonBar fx:id="buttonBar">
|
<ButtonBar fx:id="buttonBar">
|
||||||
<padding>
|
<padding>
|
||||||
<Insets>...</Insets>
|
<Insets>...</Insets>
|
||||||
</padding>
|
</padding>
|
||||||
<buttons>
|
<buttons>
|
||||||
<ToggleButton fx:id="changeGlobalChatButton" text="Global Chat" onAction="#" styleClass="yellow-button"/>
|
<ToggleButton fx:id="changeGlobalChatButton" text="Global Chat" onAction="#switchChat" styleClass="yellow-button"/>
|
||||||
<ToggleButton fx:id="changeLobbyChatButton" text="Lobby Chat" onAction="#" styleClass="yellow-button"/>
|
<ToggleButton fx:id="changeLobbyChatButton" text="Lobby Chat" styleClass="yellow-button"/>
|
||||||
<ToggleButton fx:id="changeWhisperChatButton" text="Whisper Chat" onAction="#" styleClass="yellow-button"/>
|
<ToggleButton fx:id="changeWhisperChatButton" text="Whisper Chat" styleClass="yellow-button"/>
|
||||||
</buttons>
|
</buttons>
|
||||||
</ButtonBar>
|
</ButtonBar>
|
||||||
|
|
||||||
</children>
|
</StackPane>
|
||||||
</VBox>
|
|
||||||
@@ -7,7 +7,9 @@
|
|||||||
<?import javafx.scene.layout.*?>
|
<?import javafx.scene.layout.*?>
|
||||||
|
|
||||||
<!-- VBox for the global chat, should only be visible when activated via changeGlobalChatButton-->
|
<!-- VBox for the global chat, should only be visible when activated via changeGlobalChatButton-->
|
||||||
<VBox fx:id="globalChatVBox"
|
<VBox xmlns="http://javafx.com/javafx/21"
|
||||||
|
xmlns:fx="http://javafx.com/fxml/1"
|
||||||
|
fx:id="globalChatVBox"
|
||||||
VBox.vgrow="ALWAYS"
|
VBox.vgrow="ALWAYS"
|
||||||
styleClass="chat-box"
|
styleClass="chat-box"
|
||||||
spacing="10"
|
spacing="10"
|
||||||
@@ -15,26 +17,23 @@
|
|||||||
visible="true"
|
visible="true"
|
||||||
fx:controller="ch.unibas.dmi.dbis.cs108.casono.client.ui.chatui.GlobalChatView">
|
fx:controller="ch.unibas.dmi.dbis.cs108.casono.client.ui.chatui.GlobalChatView">
|
||||||
|
|
||||||
<children>
|
<Label text="== GLOBAL CHAT ==" styleClass="chat-header" alignment="CENTER" maxWidth="Infinity"/>
|
||||||
<Label text="== GLOBAL CHAT ==" styleClass="chat-header" alignment="CENTER" maxWidth="Infinity"/>
|
<Region minHeight="4" styleClass="chat-separator"/>
|
||||||
<Region minHeight="4" styleClass="chat-separator"/>
|
<!-- Chatnachrichten werden hier hinzugefügt -->
|
||||||
|
<ScrollPane fx:id="globalChatScrollPane" fitToWidth="true" vbarPolicy="AS_NEEDED" hbarPolicy="NEVER"
|
||||||
|
VBox.vgrow="ALWAYS" styleClass="chat-scroll-pane">
|
||||||
|
<content>
|
||||||
|
<VBox fx:id="globalChat" spacing="10" styleClass="chat-VBox"/>
|
||||||
|
</content>
|
||||||
|
</ScrollPane>
|
||||||
|
|
||||||
<!-- Chatnachrichten werden hier hinzugefügt -->
|
<!-- Eingabebereich -->
|
||||||
<ScrollPane fx:id="globalChatScrollPane" fitToWidth="true" vbarPolicy="AS_NEEDED" hbarPolicy="NEVER"
|
<HBox spacing="10">
|
||||||
VBox.vgrow="ALWAYS" styleClass="chat-scroll-pane">
|
<!-- TODO: Größe des TextFields dynamisch anpassen -->
|
||||||
<content>
|
<TextField fx:id="globalChatInputField" HBox.hgrow="ALWAYS" promptText="Nachricht eingeben..."
|
||||||
<VBox fx:id="globalChat" spacing="10" styleClass="chat-VBox"/>
|
styleClass="gray-input-field" onAction="#sendGlobalMessage"/>
|
||||||
</content>
|
<Button fx:id="globalChatSendButton" text="SENDEN" onAction="#sendGlobalMessage"
|
||||||
</ScrollPane>
|
styleClass="yellow-button"/>
|
||||||
|
</HBox>
|
||||||
<!-- Eingabebereich -->
|
|
||||||
<HBox spacing="10">
|
|
||||||
<!-- TODO: Größe des TextFields dynamisch anpassen -->
|
|
||||||
<TextField fx:id="globalChatInputField" HBox.hgrow="ALWAYS" promptText="Nachricht eingeben..."
|
|
||||||
styleClass="gray-input-field" onAction="#sendGlobalMessage"/>
|
|
||||||
<Button fx:id="globalChatSendButton" text="SENDEN" onAction="#sendGlobalMessage"
|
|
||||||
styleClass="yellow-button"/>
|
|
||||||
</HBox>
|
|
||||||
</children>
|
|
||||||
</VBox>
|
</VBox>
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,9 @@
|
|||||||
|
|
||||||
<!-- VBox for the lobby chat, should only be visible when activated via changeLobbyChatButton-->
|
<!-- VBox for the lobby chat, should only be visible when activated via changeLobbyChatButton-->
|
||||||
|
|
||||||
<VBox fx:id="lobbyChatVBox"
|
<VBox xmlns="http://javafx.com/javafx/21"
|
||||||
|
xmlns:fx="http://javafx.com/fxml/1"
|
||||||
|
fx:id="lobbyChatVBox"
|
||||||
VBox.vgrow="ALWAYS"
|
VBox.vgrow="ALWAYS"
|
||||||
styleClass="chat-box"
|
styleClass="chat-box"
|
||||||
spacing="10"
|
spacing="10"
|
||||||
|
|||||||
@@ -8,7 +8,9 @@
|
|||||||
|
|
||||||
<!-- VBox for the whisper chat, should only be visible when activated via changeWhisperChatButton-->
|
<!-- VBox for the whisper chat, should only be visible when activated via changeWhisperChatButton-->
|
||||||
|
|
||||||
<VBox fx:id="whisperChatVBox"
|
<VBox xmlns="http://javafx.com/javafx/21"
|
||||||
|
xmlns:fx="http://javafx.com/fxml/1"
|
||||||
|
fx:id="whisperChatVBox"
|
||||||
VBox.vgrow="ALWAYS"
|
VBox.vgrow="ALWAYS"
|
||||||
styleClass="chat-box"
|
styleClass="chat-box"
|
||||||
spacing="10"
|
spacing="10"
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package ch.unibas.dmi.dbis.cs108.casono.client.chat;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
public class ChatTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void chatTest() {
|
||||||
|
Client.main(new String[]{"mathis"});
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user