Skip to content

Commit

Permalink
finished
Browse files Browse the repository at this point in the history
  • Loading branch information
kubakubakuba committed May 22, 2023
1 parent 9f36b6a commit cd3db8f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -94,19 +98,20 @@ public void addMessage(String msg) {
*/
public void enableChat(){
enabled = true;
javafx.application.Platform.runLater(() -> {
/*javafx.application.Platform.runLater(() -> {
inputField.setDisable(false);
});
});*/
}

/**
* Disable chat
*/
public void disableChat(){
enabled = false;
javafx.application.Platform.runLater(() -> {
/*javafx.application.Platform.runLater(() -> {
inputField.setDisable(true);
});
});*/
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand All @@ -92,6 +93,7 @@ public void gameEnd(){
if(role == Player.PlayerRole.FIELD_OPERATIVE_LEADER){
viewL.gameEnd();
}
localControl.getChatController().setChatEnable();
}

}

0 comments on commit cd3db8f

Please sign in to comment.