mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 14:28:43 +00:00
Researched and implemented a way for the game to listen for key presses. When one of the valid key controls are pressed, feedback is given in the console. Has yet to be connected to a method which will create and send a message to the server.
#pair[kre39,zyt10] #story[988]
This commit is contained in:
@@ -8,6 +8,7 @@ import javafx.scene.Group;
|
||||
import javafx.scene.canvas.Canvas;
|
||||
import javafx.scene.canvas.GraphicsContext;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.scene.input.KeyEvent;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.scene.paint.Color;
|
||||
import javafx.scene.shape.Polygon;
|
||||
@@ -109,6 +110,7 @@ public class CanvasController {
|
||||
// Bind canvas size to stack pane size.
|
||||
canvas.widthProperty().bind(new SimpleDoubleProperty(CANVAS_WIDTH));
|
||||
canvas.heightProperty().bind(new SimpleDoubleProperty(CANVAS_HEIGHT));
|
||||
|
||||
}
|
||||
|
||||
public void initializeCanvas (){
|
||||
@@ -525,4 +527,5 @@ public class CanvasController {
|
||||
List<MarkGroup> getMarkGroups() {
|
||||
return markGroups;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,8 +1,11 @@
|
||||
package seng302.controllers;
|
||||
|
||||
import com.sun.org.apache.bcel.internal.generic.BREAKPOINT;
|
||||
import javafx.event.EventHandler;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.input.KeyEvent;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.scene.layout.Pane;
|
||||
|
||||
@@ -35,5 +38,39 @@ public class Controller implements Initializable {
|
||||
contentPane.getStylesheets().add(getClass().getResource("/css/master.css").toString());
|
||||
setContentPane("/views/StartScreenView.fxml");
|
||||
StreamParser.boatLocations.clear();
|
||||
|
||||
|
||||
}
|
||||
|
||||
/** Handle the key-pressed event from the text field. */
|
||||
public void keyPressed(KeyEvent e) {
|
||||
switch (e.getCode()){
|
||||
case SPACE: // align with vmg
|
||||
System.out.println("Key pressed = space");
|
||||
break;
|
||||
case PAGE_UP: // upwind
|
||||
System.out.println("Key pressed = page up");
|
||||
break;
|
||||
case PAGE_DOWN: // downwind
|
||||
System.out.println("Key pressed = page down");
|
||||
break;
|
||||
case ENTER: // tack/gybe
|
||||
System.out.println("Key pressed = enter");
|
||||
break;
|
||||
case Z: // zoom in
|
||||
System.out.println("Key pressed = z");
|
||||
break;
|
||||
case X: // zoom out
|
||||
System.out.println("Key pressed = x");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void keyReleased(KeyEvent e) {
|
||||
switch (e.getCode()) {
|
||||
case SHIFT: // sails in/sails out
|
||||
System.out.println("Key pressed = shift");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import javafx.animation.KeyFrame;
|
||||
import javafx.animation.Timeline;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.event.EventHandler;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.geometry.Point2D;
|
||||
@@ -16,6 +17,7 @@ import javafx.scene.control.Button;
|
||||
import javafx.scene.control.CheckBox;
|
||||
import javafx.scene.control.ComboBox;
|
||||
import javafx.scene.control.Slider;
|
||||
import javafx.scene.input.KeyEvent;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.scene.layout.VBox;
|
||||
@@ -103,6 +105,7 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
||||
initialiseBoatSelectionComboBox();
|
||||
includedCanvasController.timer.start();
|
||||
selectAnnotationBtn.setOnAction(event -> loadSelectAnnotationView());
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -136,7 +139,6 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
||||
Scene scene = new Scene(fxmlLoader.load(), 469, 298);
|
||||
scene.getStylesheets().add(getClass().getResource("/css/master.css").toString());
|
||||
stage.initStyle(StageStyle.UNDECORATED);
|
||||
|
||||
stage.setScene(scene);
|
||||
stage.show();
|
||||
|
||||
@@ -637,4 +639,5 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
||||
public static boolean sparkLineStatus(Integer yachtId) {
|
||||
return sparkLineData.containsKey(yachtId);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -7,4 +7,5 @@
|
||||
<?import java.lang.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
|
||||
<AnchorPane fx:id="contentPane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng302.controllers.Controller" />
|
||||
|
||||
<AnchorPane fx:id="contentPane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" onKeyPressed="#keyPressed" onKeyReleased="#keyReleased" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng302.controllers.Controller" />
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
<Font name="System Bold" size="13.0" />
|
||||
</font>
|
||||
</Text>
|
||||
<CheckBox fx:id="toggleFps" graphicTextGap="0.0" layoutX="21.0" layoutY="453.0" mnemonicParsing="false" prefHeight="18.0" prefWidth="143.0" selected="true" styleClass="ui-checkbox" text="Show FPS" textFill="WHITE" />
|
||||
<CheckBox fx:id="toggleFps" focusTraversable="false" graphicTextGap="0.0" layoutX="21.0" layoutY="453.0" mnemonicParsing="false" prefHeight="18.0" prefWidth="143.0" selected="true" styleClass="ui-checkbox" text="Show FPS" textFill="WHITE" />
|
||||
<VBox fx:id="positionVbox" layoutX="12.0" layoutY="280.0" prefHeight="140.0" prefWidth="200.0" styleClass="text-white" />
|
||||
<Pane layoutX="11.0" layoutY="30.0" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="51.0" prefWidth="193.0">
|
||||
<children>
|
||||
@@ -48,9 +48,9 @@
|
||||
</Pane>
|
||||
<Slider fx:id="annotationSlider" blockIncrement="1.0" layoutX="38.0" layoutY="527.0" majorTickUnit="1.0" max="2.0" minorTickCount="0" prefHeight="51.0" prefWidth="170.0" showTickLabels="true" showTickMarks="true" snapToTicks="true" styleClass="ui-slider" />
|
||||
<Label layoutX="10.0" layoutY="499.0" text="Annotations" textFill="WHITE" />
|
||||
<Button fx:id="selectAnnotationBtn" layoutX="35.0" layoutY="578.0" mnemonicParsing="false" prefHeight="18.0" prefWidth="170.0" styleClass="blue-ui-btn" text="Select Annotations" textFill="WHITE" />
|
||||
<Button fx:id="selectAnnotationBtn" focusTraversable="false" layoutX="35.0" layoutY="578.0" mnemonicParsing="false" prefHeight="18.0" prefWidth="170.0" styleClass="blue-ui-btn" text="Select Annotations" textFill="WHITE" />
|
||||
<Text fill="WHITE" layoutX="11.0" layoutY="649.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Boat Selection" />
|
||||
<ComboBox fx:id="boatSelectionComboBox" layoutX="37.0" layoutY="664.0" prefHeight="25.0" prefWidth="170.0" promptText="Select Boat" styleClass="combo-box-base" />
|
||||
<ComboBox fx:id="boatSelectionComboBox" focusTraversable="false" layoutX="37.0" layoutY="664.0" prefHeight="25.0" prefWidth="170.0" promptText="Select Boat" styleClass="combo-box-base" />
|
||||
<LineChart fx:id="raceSparkLine" layoutX="-1.0" layoutY="719.0" legendVisible="false" prefHeight="277.0" prefWidth="246.0" title="Boat Positions">
|
||||
<xAxis>
|
||||
<CategoryAxis label="Leg Number" side="BOTTOM" styleClass="spark-line-xaxis" />
|
||||
|
||||
Reference in New Issue
Block a user