From 3364f8b516c96ec1cf188e8b5ce8ffa6f6e92c89 Mon Sep 17 00:00:00 2001 From: Kusal Ekanayake Date: Thu, 7 Sep 2017 17:02:42 +1200 Subject: [PATCH] Made chat history transparent. #story[1246] --- .../visualiser/controllers/RaceViewController.java | 8 +++++--- .../java/seng302/visualiser/fxObjects/ChatHistory.java | 9 ++++++++- src/main/resources/views/RaceView.fxml | 2 +- src/test/java/features/SendChat.feature | 2 +- src/test/java/steps/SendChatSteps.java | 4 ++-- 5 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/main/java/seng302/visualiser/controllers/RaceViewController.java b/src/main/java/seng302/visualiser/controllers/RaceViewController.java index 300722cd..2ac1f201 100644 --- a/src/main/java/seng302/visualiser/controllers/RaceViewController.java +++ b/src/main/java/seng302/visualiser/controllers/RaceViewController.java @@ -105,6 +105,7 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel private Timer timer = new Timer(); private List> sparkLineData = new ArrayList<>(); private ImportantAnnotationsState importantAnnotations; + private boolean done = false; public void initialize() { Sounds.stopMusic(); @@ -140,6 +141,8 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel // chatHistory.textProperty().addListener((obs, oldValue, newValue) -> { // chatHistory.setScrollTop(Double.MAX_VALUE); // }); + done = true; + } public void loadRace ( @@ -574,9 +577,8 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel * for the combobox to take action upon selection */ private void initialiseBoatSelectionComboBox() { - yachtSelectionComboBox.setItems( - FXCollections.observableArrayList(participants.values()) - ); + ObservableList selectables = FXCollections.observableArrayList(participants.values()); + yachtSelectionComboBox.setItems(selectables); yachtSelectionComboBox.valueProperty().addListener((obs, lastSelection, selectedBoat) -> { if (selectedBoat != null) { gameView.selectBoat(selectedBoat); diff --git a/src/main/java/seng302/visualiser/fxObjects/ChatHistory.java b/src/main/java/seng302/visualiser/fxObjects/ChatHistory.java index a7f92117..93f5a58b 100644 --- a/src/main/java/seng302/visualiser/fxObjects/ChatHistory.java +++ b/src/main/java/seng302/visualiser/fxObjects/ChatHistory.java @@ -4,6 +4,8 @@ import java.util.Arrays; import javafx.collections.ListChangeListener; import javafx.scene.Node; import javafx.scene.control.ScrollPane; +import javafx.scene.layout.Background; +import javafx.scene.paint.Color; import javafx.scene.paint.Paint; import javafx.scene.text.Text; import javafx.scene.text.TextFlow; @@ -22,8 +24,13 @@ public class ChatHistory extends ScrollPane { this.setFitToHeight(true); this.setMaxHeight(Double.MAX_VALUE); this.setMaxWidth(Double.MAX_VALUE); - this.setVbarPolicy(ScrollBarPolicy.ALWAYS); + this.setVbarPolicy(ScrollBarPolicy.AS_NEEDED); this.setHbarPolicy(ScrollBarPolicy.NEVER); + this.lookup(".scroll-pane").setStyle("-fx-background: rgba(255, 255, 255, 0.1); -fx-background-color: rgba(255, 255, 255, 0.1);"); + + this.textFlow.setStyle( + "-fx-background: rgba(255, 255, 255, 0.1); -fx-background-color: rgba(255, 255, 255, 0.1);" + ); //This makes the window auto scroll. textFlow.getChildren().addListener((ListChangeListener) c -> this.setVvalue(1.0) diff --git a/src/main/resources/views/RaceView.fxml b/src/main/resources/views/RaceView.fxml index f1473f5e..9acfb887 100644 --- a/src/main/resources/views/RaceView.fxml +++ b/src/main/resources/views/RaceView.fxml @@ -23,7 +23,7 @@ - + diff --git a/src/test/java/features/SendChat.feature b/src/test/java/features/SendChat.feature index 08397454..29020e24 100644 --- a/src/test/java/features/SendChat.feature +++ b/src/test/java/features/SendChat.feature @@ -1,5 +1,5 @@ Feature: SendChat Scenario: User send chat to another client Given There are two games running - When the user has pressed sends the message "Hello world" in a text box + When the first client has sent the message "Hello world" Then the other client should receive the message "Hello world" diff --git a/src/test/java/steps/SendChatSteps.java b/src/test/java/steps/SendChatSteps.java index 7d5499ad..93600ce3 100644 --- a/src/test/java/steps/SendChatSteps.java +++ b/src/test/java/steps/SendChatSteps.java @@ -21,7 +21,7 @@ public class SendChatSteps { private MainServerThread mst; -//TODO Need to mock the controller pane in order to run the full game client + //TODO Need to mock the controller pane in order to run the full game client @Given("^There are two games running$") public void the_are_two_games_running() throws Throwable { mst = new MainServerThread(); @@ -42,7 +42,7 @@ public class SendChatSteps { } - @When("^the user has pressed sends the message \"([^\"]*)\" in a text box$") + @When("^the first client has sent the message \"([^\"]*)\"$") public void the_user_has_pressed_sends_the_message_in_a_text_box(String arg1) throws Throwable { client.sendChatterMessage("[time_prefix] " + arg1); }