From cd3db8f06847c444795b1e5661a220480c3f9fae Mon Sep 17 00:00:00 2001 From: Jakub Pelc Date: Mon, 22 May 2023 19:16:45 +0200 Subject: [PATCH] finished --- .../cvut/fel/pjv/codenames/GUI/ChatView.java | 19 ++++++++++++------- .../cvut/fel/pjv/codenames/GUI/GameView.java | 2 ++ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/CodeNames/src/main/java/cz/cvut/fel/pjv/codenames/GUI/ChatView.java b/CodeNames/src/main/java/cz/cvut/fel/pjv/codenames/GUI/ChatView.java index 0869e81..9e91091 100644 --- a/CodeNames/src/main/java/cz/cvut/fel/pjv/codenames/GUI/ChatView.java +++ b/CodeNames/src/main/java/cz/cvut/fel/pjv/codenames/GUI/ChatView.java @@ -21,7 +21,7 @@ public class ChatView extends Application { private Stage stage; private TextArea chatLog; private TextArea inputField; - private boolean enabled = false; + private boolean enabled = true; private ChatController chatControl; private Client localClient; private double xOffset = 0; @@ -53,12 +53,16 @@ public void showChatWindow(String title) { inputField.setMaxHeight(28); inputField.setOnKeyPressed((event) -> { if (event.getCode() == KeyCode.ENTER) { - sendMessage(); + if(enabled) { + sendMessage(); + } } }); Button sendButton = new Button("Send"); sendButton.setOnAction((ActionEvent e) -> { - sendMessage(); + if(enabled) { + sendMessage(); + } }); VBox vbox = new VBox(4, msgLabel, chatLog, inputLabel, inputField, sendButton); vbox.setPadding(new Insets(8)); @@ -94,9 +98,9 @@ public void addMessage(String msg) { */ public void enableChat(){ enabled = true; - javafx.application.Platform.runLater(() -> { + /*javafx.application.Platform.runLater(() -> { inputField.setDisable(false); - }); + });*/ } /** @@ -104,9 +108,10 @@ public void enableChat(){ */ public void disableChat(){ enabled = false; - javafx.application.Platform.runLater(() -> { + /*javafx.application.Platform.runLater(() -> { + inputField.setDisable(true); - }); + });*/ } /** diff --git a/CodeNames/src/main/java/cz/cvut/fel/pjv/codenames/GUI/GameView.java b/CodeNames/src/main/java/cz/cvut/fel/pjv/codenames/GUI/GameView.java index 5de1276..5fc6e36 100644 --- a/CodeNames/src/main/java/cz/cvut/fel/pjv/codenames/GUI/GameView.java +++ b/CodeNames/src/main/java/cz/cvut/fel/pjv/codenames/GUI/GameView.java @@ -69,6 +69,7 @@ public void update(){ @Override public void start(Stage primaryStage) { if(role == Player.PlayerRole.SPY_MASTER){ + localControl.getChatController().setChatDisable(); viewS.start(primaryStage); } if(role == Player.PlayerRole.FIELD_OPERATIVE){ @@ -92,6 +93,7 @@ public void gameEnd(){ if(role == Player.PlayerRole.FIELD_OPERATIVE_LEADER){ viewL.gameEnd(); } + localControl.getChatController().setChatEnable(); } }