Added toggle button for the chat history

#story[1274]
This commit is contained in:
William Muir
2017-09-28 16:39:59 +13:00
parent 4f80640718
commit a1d468c689
3 changed files with 39 additions and 3 deletions
@@ -68,7 +68,7 @@ public class GameState implements Runnable {
//Collision constants //Collision constants
private static final Double MARK_COLLISION_DISTANCE = 15d; private static final Double MARK_COLLISION_DISTANCE = 15d;
public static final Double YACHT_COLLISION_DISTANCE = 25.0; public static final Double YACHT_COLLISION_DISTANCE = 15.0;
private static final Double BOUNCE_DISTANCE_MARK = 20.0; private static final Double BOUNCE_DISTANCE_MARK = 20.0;
public static final Double BOUNCE_DISTANCE_YACHT = 30.0; public static final Double BOUNCE_DISTANCE_YACHT = 30.0;
private static final Double COLLISION_VELOCITY_PENALTY = 0.3; private static final Double COLLISION_VELOCITY_PENALTY = 0.3;
@@ -50,6 +50,8 @@ public class RaceViewController extends Thread {
@FXML @FXML
private Pane chatHistoryHolder; private Pane chatHistoryHolder;
@FXML @FXML
private JFXButton chatToggleButton;
@FXML
private TextField chatInput; private TextField chatInput;
@FXML @FXML
private Label timerLabel; private Label timerLabel;
@@ -85,6 +87,8 @@ public class RaceViewController extends Thread {
public void initialize() { public void initialize() {
miniMapPane.setVisible(false); miniMapPane.setVisible(false);
miniMapButton.setVisible(false); miniMapButton.setVisible(false);
chatHistoryHolder.setVisible(false);
chatToggleButton.setVisible(false);
contentStackPane.setVisible(false); contentStackPane.setVisible(false);
Image loadingImage = new Image("PP.png"); Image loadingImage = new Image("PP.png");
loadingScreen.setImage(loadingImage); loadingScreen.setImage(loadingImage);
@@ -120,6 +124,9 @@ public class RaceViewController extends Thread {
chatHistoryHolder.heightProperty() chatHistoryHolder.heightProperty()
); );
contentStackPane.getChildren().remove(chatToggleButton);
contentStackPane.getChildren().add(chatToggleButton);
contentStackPane.setOnMouseClicked(event -> { contentStackPane.setOnMouseClicked(event -> {
contentStackPane.requestFocus(); contentStackPane.requestFocus();
}); });
@@ -146,6 +153,9 @@ public class RaceViewController extends Thread {
contentStackPane.setVisible(true); contentStackPane.setVisible(true);
miniMapPane.setVisible(true); miniMapPane.setVisible(true);
miniMapButton.setVisible(true); miniMapButton.setVisible(true);
chatHistoryHolder.setVisible(true);
chatToggleButton.setVisible(true);
Platform.runLater(() -> contentStackPane.requestFocus()); Platform.runLater(() -> contentStackPane.requestFocus());
} }
@@ -197,6 +207,16 @@ public class RaceViewController extends Thread {
} }
}); });
chatToggleButton.setOnMouseClicked((event) -> {
if (chatHistoryHolder.visibleProperty().get()) {
chatHistoryHolder.setVisible(false);
chatToggleButton.setText("+");
} else {
chatHistoryHolder.setVisible(true);
chatToggleButton.setText("");
}
});
Platform.runLater(() -> { Platform.runLater(() -> {
contentStackPane.getChildren().add(0, gameView.getAssets()); contentStackPane.getChildren().add(0, gameView.getAssets());
((SubScene) gameView.getAssets()).widthProperty() ((SubScene) gameView.getAssets()).widthProperty()
+18 -2
View File
@@ -1,5 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<?import com.jfoenix.controls.*?>
<?import java.lang.*?>
<?import java.net.*?>
<?import javafx.geometry.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.image.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.*?>
<?import com.jfoenix.controls.JFXButton?> <?import com.jfoenix.controls.JFXButton?>
<?import com.jfoenix.controls.JFXSpinner?> <?import com.jfoenix.controls.JFXSpinner?>
<?import com.jfoenix.controls.JFXTextField?> <?import com.jfoenix.controls.JFXTextField?>
@@ -15,6 +23,7 @@
<?import javafx.scene.layout.RowConstraints?> <?import javafx.scene.layout.RowConstraints?>
<?import javafx.scene.layout.StackPane?> <?import javafx.scene.layout.StackPane?>
<?import javafx.scene.text.Font?> <?import javafx.scene.text.Font?>
<StackPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity" prefHeight="800.0" prefWidth="1200.0" style="-fx-background-color: skyblue;" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng302.visualiser.controllers.RaceViewController"> <StackPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity" prefHeight="800.0" prefWidth="1200.0" style="-fx-background-color: skyblue;" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng302.visualiser.controllers.RaceViewController">
<children> <children>
<StackPane fx:id="contentStackPane" maxHeight="1.7976931348623157E308" <StackPane fx:id="contentStackPane" maxHeight="1.7976931348623157E308"
@@ -314,8 +323,7 @@
<Insets right="15.0" top="15.0" /> <Insets right="15.0" top="15.0" />
</StackPane.margin> </StackPane.margin>
</Pane> </Pane>
<JFXButton fx:id="miniMapButton" text="—" <JFXButton fx:id="miniMapButton" text="—" StackPane.alignment="TOP_RIGHT">
StackPane.alignment="TOP_RIGHT">
<font> <font>
<Font size="15.0" /> <Font size="15.0" />
</font> </font>
@@ -330,6 +338,14 @@
<JFXSpinner layoutX="566.0" layoutY="692.0" radius="30.0"/> <JFXSpinner layoutX="566.0" layoutY="692.0" radius="30.0"/>
</children> </children>
</AnchorPane> </AnchorPane>
<JFXButton fx:id="chatToggleButton" text="—" StackPane.alignment="BOTTOM_RIGHT">
<font>
<Font size="15.0"/>
</font>
<StackPane.margin>
<Insets bottom="70.0" right="10.0"/>
</StackPane.margin>
</JFXButton>
</children> </children>
<stylesheets> <stylesheets>
<URL value="@../css/Master.css"/> <URL value="@../css/Master.css"/>