Skip to content

Commit

Permalink
place pawn uic
Browse files Browse the repository at this point in the history
  • Loading branch information
jennifermliu committed Jun 6, 2018
1 parent f25441d commit 6490179
Show file tree
Hide file tree
Showing 4 changed files with 303 additions and 12 deletions.
Binary file added image/board.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/admin/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public static void main(String[] args) {
@Override
public void start(Stage stage) throws IOException {
FXMLLoader loader = new FXMLLoader();
loader.setLocation(App.class.getResource("PlayTurn.fxml"));
loader.setLocation(App.class.getResource("StartGame.fxml"));
BorderPane startGameView = loader.load();
Scene scene = new Scene(startGameView);
stage.setScene(scene);
Expand Down
240 changes: 229 additions & 11 deletions src/admin/StartGame.fxml
Original file line number Diff line number Diff line change
@@ -1,14 +1,232 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.ChoiceBox?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Text?>

<AnchorPane xmlns="http://javafx.com/javafx"
xmlns:fx="http://javafx.com/fxml"
fx:controller="tsuro.admin.App"
prefHeight="400.0" prefWidth="600.0">

</AnchorPane>
<BorderPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="560.0" prefWidth="480.0" xmlns="http://javafx.com/javafx/9.0.4" xmlns:fx="http://javafx.com/fxml/1" fx:controller="tsuro.admin.StartGameController">
<center>
<ImageView fx:id="boardImageView" fitHeight="360.0" fitWidth="360.0" pickOnBounds="true" BorderPane.alignment="CENTER" />
</center>
<top>
<VBox prefHeight="140.0" prefWidth="480.0" BorderPane.alignment="CENTER">
<children>
<VBox prefHeight="80.0" prefWidth="480.0" style="-fx-border-color: black;">
<children>
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Choose a starting position to place pawn">
<VBox.margin>
<Insets bottom="5.0" left="100.0" right="20.0" top="5.0" />
</VBox.margin>
</Text>
<HBox prefWidth="480.0">
<children>
<VBox prefWidth="100.0">
<children>
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Side" textAlignment="CENTER" />
<ChoiceBox fx:id="sideDropdown" prefWidth="80.0" />
</children>
<HBox.margin>
<Insets left="60.0" />
</HBox.margin>
<padding>
<Insets right="20.0" />
</padding>
</VBox>
<VBox prefWidth="100.0">
<children>
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Index" />
<ChoiceBox fx:id="indexDropdown" prefWidth="80.0" />
</children>
<HBox.margin>
<Insets />
</HBox.margin>
<padding>
<Insets right="20.0" />
</padding>
</VBox>
<Button fx:id="submitButton" mnemonicParsing="false" text="Submit">
<HBox.margin>
<Insets top="15.0" />
</HBox.margin>
</Button>
</children>
</HBox>
</children>
</VBox>
<HBox layoutX="10.0" layoutY="10.0" prefHeight="60.0" prefWidth="480.0">
<children>
<HBox prefHeight="60.0" prefWidth="60.0" />
<HBox prefHeight="60.0" prefWidth="60.0">
<children>
<Label alignment="BOTTOM_RIGHT" prefHeight="60.0" prefWidth="60.0" text="0 " />
<Label alignment="BOTTOM_LEFT" layoutX="10.0" layoutY="10.0" prefHeight="60.0" prefWidth="60.0" text=" 1" />
</children>
</HBox>
<HBox layoutX="70.0" layoutY="10.0" prefHeight="60.0" prefWidth="60.0">
<children>
<Label alignment="BOTTOM_RIGHT" prefHeight="60.0" prefWidth="60.0" text="2 " />
<Label alignment="BOTTOM_LEFT" layoutX="10.0" layoutY="10.0" prefHeight="60.0" prefWidth="60.0" text=" 3" />
</children>
</HBox>
<HBox layoutX="130.0" layoutY="10.0" prefHeight="60.0" prefWidth="60.0">
<children>
<Label alignment="BOTTOM_RIGHT" prefHeight="60.0" prefWidth="60.0" text="4 " />
<Label alignment="BOTTOM_LEFT" layoutX="10.0" layoutY="10.0" prefHeight="60.0" prefWidth="60.0" text=" 5" />
</children>
</HBox>
<HBox layoutX="70.0" layoutY="10.0" prefHeight="60.0" prefWidth="60.0">
<children>
<Label alignment="BOTTOM_RIGHT" prefHeight="60.0" prefWidth="60.0" text="6 " />
<Label alignment="BOTTOM_LEFT" layoutX="10.0" layoutY="10.0" prefHeight="60.0" prefWidth="60.0" text=" 7" />
</children>
</HBox>
<HBox layoutX="70.0" layoutY="10.0" prefHeight="60.0" prefWidth="60.0">
<children>
<Label alignment="BOTTOM_RIGHT" prefHeight="60.0" prefWidth="60.0" text="8 " />
<Label alignment="BOTTOM_LEFT" layoutX="10.0" layoutY="10.0" prefHeight="60.0" prefWidth="60.0" text=" 9" />
</children>
</HBox>
<HBox layoutX="190.0" layoutY="10.0" prefHeight="60.0" prefWidth="60.0">
<children>
<Label alignment="BOTTOM_RIGHT" prefHeight="60.0" prefWidth="60.0" text="10 " />
<Label alignment="BOTTOM_LEFT" layoutX="10.0" layoutY="10.0" prefHeight="60.0" prefWidth="60.0" text=" 11" />
</children>
</HBox>
<HBox layoutX="10.0" layoutY="10.0" prefHeight="60.0" prefWidth="60.0" />
</children>
</HBox>
</children></VBox>
</top>
<bottom>
<HBox prefHeight="60.0" prefWidth="480.0" BorderPane.alignment="CENTER">
<children>
<HBox prefHeight="60.0" prefWidth="60.0" />
<HBox layoutX="10.0" layoutY="10.0" prefHeight="60.0" prefWidth="60.0">
<children>
<Label alignment="CENTER_RIGHT" prefHeight="30.0" prefWidth="60.0" text="0 " />
<Label layoutX="10.0" layoutY="10.0" prefHeight="30.0" prefWidth="60.0" text=" 1" />
</children>
</HBox>
<HBox layoutX="70.0" layoutY="10.0" prefHeight="60.0" prefWidth="60.0">
<children>
<Label alignment="CENTER_RIGHT" prefHeight="30.0" prefWidth="60.0" text="2 " />
<Label layoutX="10.0" layoutY="10.0" prefHeight="30.0" prefWidth="60.0" text=" 3" />
</children>
</HBox>
<HBox layoutX="70.0" layoutY="10.0" prefHeight="60.0" prefWidth="60.0">
<children>
<Label alignment="CENTER_RIGHT" prefHeight="30.0" prefWidth="60.0" text="4 " />
<Label layoutX="10.0" layoutY="10.0" prefHeight="30.0" prefWidth="60.0" text=" 5" />
</children>
</HBox>
<HBox layoutX="130.0" layoutY="10.0" prefHeight="60.0" prefWidth="60.0">
<children>
<Label alignment="CENTER_RIGHT" prefHeight="30.0" prefWidth="60.0" text="6 " />
<Label layoutX="10.0" layoutY="10.0" prefHeight="30.0" prefWidth="60.0" text=" 7" />
</children>
</HBox>
<HBox layoutX="190.0" layoutY="10.0" prefHeight="60.0" prefWidth="60.0">
<children>
<Label alignment="CENTER_RIGHT" prefHeight="30.0" prefWidth="60.0" text="8 " />
<Label layoutX="10.0" layoutY="10.0" prefHeight="30.0" prefWidth="60.0" text=" 9" />
</children>
</HBox>
<HBox layoutX="250.0" layoutY="10.0" prefHeight="60.0" prefWidth="60.0">
<children>
<Label alignment="CENTER_RIGHT" prefHeight="30.0" prefWidth="60.0" text="10 " />
<Label layoutX="10.0" layoutY="10.0" prefHeight="30.0" prefWidth="60.0" text=" 11" />
</children>
</HBox>
<HBox layoutX="10.0" layoutY="10.0" prefHeight="60.0" prefWidth="60.0" />
</children></HBox>
</bottom>
<left>
<VBox prefHeight="360.0" prefWidth="60.0" BorderPane.alignment="CENTER">
<children>
<VBox prefHeight="60.0" prefWidth="30.0">
<children>
<Label alignment="BOTTOM_RIGHT" prefHeight="30.0" prefWidth="60.0" text="0 " />
<Label alignment="TOP_RIGHT" layoutX="10.0" layoutY="40.0" prefHeight="30.0" prefWidth="60.0" text="1 " />
</children>
</VBox>
<VBox layoutX="10.0" layoutY="10.0" prefHeight="60.0" prefWidth="30.0">
<children>
<Label alignment="BOTTOM_RIGHT" prefHeight="30.0" prefWidth="60.0" text="2 " />
<Label alignment="TOP_RIGHT" layoutX="10.0" layoutY="40.0" prefHeight="30.0" prefWidth="60.0" text="3 " />
</children>
</VBox>
<VBox layoutX="10.0" layoutY="70.0" prefHeight="60.0" prefWidth="30.0">
<children>
<Label alignment="BOTTOM_RIGHT" prefHeight="30.0" prefWidth="60.0" text="4 " />
<Label alignment="TOP_RIGHT" layoutX="10.0" layoutY="40.0" prefHeight="30.0" prefWidth="60.0" text="5 " />
</children>
</VBox>
<VBox layoutX="10.0" layoutY="70.0" prefHeight="60.0" prefWidth="30.0">
<children>
<Label alignment="BOTTOM_RIGHT" prefHeight="30.0" prefWidth="60.0" text="6 " />
<Label alignment="TOP_RIGHT" layoutX="10.0" layoutY="40.0" prefHeight="30.0" prefWidth="60.0" text="7 " />
</children>
</VBox>
<VBox layoutX="10.0" layoutY="130.0" prefHeight="60.0" prefWidth="30.0">
<children>
<Label alignment="BOTTOM_RIGHT" prefHeight="30.0" prefWidth="60.0" text="8 " />
<Label alignment="TOP_RIGHT" layoutX="10.0" layoutY="40.0" prefHeight="30.0" prefWidth="60.0" text="9 " />
</children>
</VBox>
<VBox layoutX="10.0" layoutY="190.0" prefHeight="60.0" prefWidth="30.0">
<children>
<Label alignment="BOTTOM_RIGHT" prefHeight="30.0" prefWidth="60.0" text="10 " />
<Label alignment="TOP_RIGHT" layoutX="10.0" layoutY="40.0" prefHeight="30.0" prefWidth="60.0" text="11 " />
</children>
</VBox>
</children>
</VBox>
</left>
<right>
<VBox prefHeight="360.0" prefWidth="60.0" BorderPane.alignment="CENTER">
<children>
<VBox prefHeight="200.0" prefWidth="100.0">
<children>
<Label alignment="BOTTOM_LEFT" prefHeight="30.0" prefWidth="60.0" text=" 0" />
<Label alignment="TOP_LEFT" layoutX="10.0" layoutY="10.0" prefHeight="30.0" prefWidth="60.0" text=" 1" />
</children>
</VBox>
<VBox layoutX="10.0" layoutY="10.0" prefHeight="200.0" prefWidth="100.0">
<children>
<Label alignment="BOTTOM_LEFT" prefHeight="30.0" prefWidth="60.0" text=" 2" />
<Label alignment="TOP_LEFT" layoutX="10.0" layoutY="10.0" prefHeight="30.0" prefWidth="60.0" text=" 3" />
</children>
</VBox>
<VBox layoutX="10.0" layoutY="190.0" prefHeight="200.0" prefWidth="100.0">
<children>
<Label alignment="BOTTOM_LEFT" prefHeight="30.0" prefWidth="60.0" text=" 4" />
<Label alignment="TOP_LEFT" layoutX="10.0" layoutY="10.0" prefHeight="30.0" prefWidth="60.0" text=" 5" />
</children>
</VBox>
<VBox layoutX="10.0" layoutY="250.0" prefHeight="200.0" prefWidth="100.0">
<children>
<Label alignment="BOTTOM_LEFT" prefHeight="30.0" prefWidth="60.0" text=" 6" />
<Label alignment="TOP_LEFT" layoutX="10.0" layoutY="10.0" prefHeight="30.0" prefWidth="60.0" text=" 7" />
</children>
</VBox>
<VBox layoutX="10.0" layoutY="190.0" prefHeight="200.0" prefWidth="100.0">
<children>
<Label alignment="BOTTOM_LEFT" prefHeight="30.0" prefWidth="60.0" text=" 8" />
<Label alignment="TOP_LEFT" layoutX="10.0" layoutY="10.0" prefHeight="30.0" prefWidth="60.0" text=" 9" />
</children>
</VBox>
<VBox layoutX="10.0" layoutY="82.0" prefHeight="200.0" prefWidth="100.0">
<children>
<Label alignment="BOTTOM_LEFT" prefHeight="30.0" prefWidth="60.0" text=" 10" />
<Label alignment="TOP_LEFT" layoutX="10.0" layoutY="10.0" prefHeight="30.0" prefWidth="60.0" text=" 11" />
</children>
</VBox>
</children></VBox>
</right>
</BorderPane>
73 changes: 73 additions & 0 deletions src/admin/StartGameController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package tsuro.admin;

import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.ChoiceBox;
import javafx.scene.control.MenuButton;
import javafx.scene.control.MenuItem;
import javafx.scene.effect.ImageInput;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.List;

public class StartGameController {
public static enum Side { TOP, LEFT, RIGHT, BOTTOM }

@FXML
private ImageView boardImageView;

@FXML
private ChoiceBox<String> sideDropdown;

@FXML
private ChoiceBox<Integer> indexDropdown;

@FXML
private Button submitButton;

private String side;
private Integer index;
private int BOARD_SIZE = 360;


public void initialize() throws FileNotFoundException {

Image boardImage = new Image(new FileInputStream("board/board.png"), BOARD_SIZE, BOARD_SIZE, false, true);
boardImageView.setImage(boardImage);

boardImageView.setOnMouseClicked(event -> {
System.out.println("image clicked");
});

sideDropdown.getItems().addAll("top", "down", "left", "right");

for(int i = 0; i < 12; i++){
indexDropdown.getItems().add(i);
}
sideDropdown.setOnMouseClicked(event -> {
System.out.println("side dropdown clicked");
});

indexDropdown.setOnMouseClicked(event -> {
System.out.println("index dropdown clicked");
});

submitButton.setOnMouseClicked(event -> {
System.out.println("submit clicked");
side = sideDropdown.getValue();
index = indexDropdown.getValue();
if(side != null && index != null){
System.out.println(side);
System.out.println(index);
}
else{
System.out.println("should not submit now");
}
});
}
}

0 comments on commit 6490179

Please sign in to comment.