WIP added FXML main screen
parent
677c3aed6d
commit
b568c967c6
|
@ -1,14 +1,21 @@
|
|||
package latice.application;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
import javafx.application.Application;
|
||||
import javafx.event.EventHandler;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.Parent;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.scene.input.ClipboardContent;
|
||||
|
@ -29,13 +36,14 @@ import javafx.scene.shape.Rectangle;
|
|||
import javafx.scene.text.Font;
|
||||
import javafx.scene.text.Text;
|
||||
import javafx.stage.Stage;
|
||||
import latice.controller.MainScreenController;
|
||||
import latice.model.Color;
|
||||
import latice.model.Deck;
|
||||
import latice.model.Rack;
|
||||
import latice.model.Shape;
|
||||
import latice.model.Tile;
|
||||
|
||||
public class LaticeApplicationWindow extends Application{
|
||||
public class LaticeApplicationWindow extends Application {
|
||||
|
||||
javafx.scene.paint.Color realColor = new javafx.scene.paint.Color(0, 0, 0, 0);
|
||||
|
||||
|
@ -46,10 +54,12 @@ public class LaticeApplicationWindow extends Application{
|
|||
Tile greenLeaf = new Tile(Color.GREEN, Shape.FEATHER);
|
||||
Tile redFlower = new Tile(Color.RED, Shape.FLOWER);
|
||||
|
||||
ArrayList<Tile> listRackTile = Rack.getListRackTile();
|
||||
ArrayList<Image> listTileImage = Rack.getRackTileImage();
|
||||
ArrayList<Tile> listOfTile = new ArrayList<Tile>();
|
||||
Map<Rectangle, Tile> assocRectangleTile = new HashMap<Rectangle, Tile>();
|
||||
|
||||
|
||||
public static int indexTileClicked;
|
||||
|
||||
|
||||
|
@ -64,7 +74,10 @@ public class LaticeApplicationWindow extends Application{
|
|||
|
||||
|
||||
@Override
|
||||
public void start(Stage primaryStage) throws Exception {
|
||||
public void start(Stage primaryStage) throws Exception{
|
||||
Parent loader = FXMLLoader.load(getClass().getResource("../view/MainScreen.fxml"));
|
||||
Scene menu = new Scene(loader, 1280, 720);
|
||||
MainScreenController MSC = new MainScreenController();
|
||||
//root layout
|
||||
BorderPane root = new BorderPane();
|
||||
|
||||
|
@ -89,7 +102,7 @@ public class LaticeApplicationWindow extends Application{
|
|||
for (int i=1; i<10 ; i++) {
|
||||
for (int j=1; j < 10 ; j++) {
|
||||
|
||||
r[counterI][counterJ] = new Rectangle(i*52+358,j*52+3,50,50);
|
||||
r[counterI][counterJ] = new Rectangle(i*52+307,j*52+3,50,50);
|
||||
r[counterI][counterJ].setFill(realColor.TRANSPARENT);
|
||||
pane.getChildren().add(r[counterI][counterJ]);
|
||||
System.out.println(r[counterI][counterJ]);
|
||||
|
@ -138,10 +151,26 @@ public class LaticeApplicationWindow extends Application{
|
|||
Rack rack2 = new Rack(deck);
|
||||
HBox rackImage = rack2.createImageTileOfRack();
|
||||
|
||||
|
||||
root.setBottom(rackImage);
|
||||
|
||||
ArrayList<Tile> listRackTile = Rack.getListRackTile();
|
||||
|
||||
//Confirm Button
|
||||
Image checkMark = new Image("checkMark.png");
|
||||
ImageView checkMarkView = new ImageView(checkMark);
|
||||
Button confirmButton = new Button("Confirm", checkMarkView);
|
||||
root.setAlignment(confirmButton, Pos.BOTTOM_LEFT);
|
||||
confirmButton.setOnMouseClicked(new EventHandler<MouseEvent>() {
|
||||
|
||||
@Override
|
||||
public void handle(MouseEvent arg0) {
|
||||
// TODO on mouse clicked on confirm
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
root.setRight(confirmButton);
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
@ -230,13 +259,14 @@ public class LaticeApplicationWindow extends Application{
|
|||
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
Scene scene = new Scene(root, 1280, 720);
|
||||
|
||||
primaryStage.setResizable(false);
|
||||
primaryStage.setTitle("Latice");
|
||||
primaryStage.setScene(scene);
|
||||
primaryStage.setScene(menu);
|
||||
primaryStage.show();
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
package latice.controller;
|
||||
|
||||
import javafx.application.Platform;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.input.MouseEvent;
|
||||
|
||||
import javafx.scene.shape.Rectangle;
|
||||
import latice.application.LaticeApplicationWindow;
|
||||
|
||||
public class MainScreenController extends LaticeApplicationWindow{
|
||||
@FXML
|
||||
private Rectangle playButton;
|
||||
@FXML
|
||||
private Rectangle rulesButton;
|
||||
@FXML
|
||||
private Rectangle exitButton;
|
||||
|
||||
// Event Listener on Rectangle[#playButton].onMouseClicked
|
||||
@FXML
|
||||
public void playButtonClicked(MouseEvent event) {
|
||||
System.out.println("playButtonClicked");
|
||||
|
||||
}
|
||||
// Event Listener on Rectangle[#rulesButton].onMouseClicked
|
||||
@FXML
|
||||
public void rulesButtonClicked(MouseEvent event) {
|
||||
System.out.println("rulesButtonClicked");
|
||||
}
|
||||
// Event Listener on Rectangle[#exitButton].onMouseClicked
|
||||
@FXML
|
||||
public void exitButtonClicked(MouseEvent event) {
|
||||
System.out.println("exitButtonClicked");
|
||||
Platform.exit();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.scene.image.Image?>
|
||||
<?import javafx.scene.image.ImageView?>
|
||||
<?import javafx.scene.layout.BorderPane?>
|
||||
<?import javafx.scene.layout.Pane?>
|
||||
<?import javafx.scene.shape.Rectangle?>
|
||||
|
||||
<BorderPane prefHeight="720.0" prefWidth="1280.0" xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1" fx:controller="latice.controller.MainScreenController">
|
||||
<center>
|
||||
<Pane prefHeight="200.0" prefWidth="200.0" BorderPane.alignment="CENTER">
|
||||
<children>
|
||||
<ImageView fitHeight="720.0" fitWidth="1280.0" pickOnBounds="true" preserveRatio="true">
|
||||
<image>
|
||||
<Image url="@/mainScreen.png" />
|
||||
</image>
|
||||
</ImageView>
|
||||
<Rectangle fx:id="playButton" arcHeight="5.0" arcWidth="5.0" fill="TRANSPARENT" height="151.0" layoutX="345.0" layoutY="175.0" onMouseClicked="#playButtonClicked" stroke="TRANSPARENT" strokeType="INSIDE" width="582.0" />
|
||||
<Rectangle fx:id="rulesButton" arcHeight="5.0" arcWidth="5.0" fill="#1f93ff00" height="152.0" layoutX="346.0" layoutY="355.0" onMouseClicked="#rulesButtonClicked" stroke="TRANSPARENT" strokeType="INSIDE" width="585.0" />
|
||||
<Rectangle fx:id="exitButton" arcHeight="5.0" arcWidth="5.0" fill="#1f93ff00" height="152.0" layoutX="348.0" layoutY="535.0" onMouseClicked="#exitButtonClicked" stroke="TRANSPARENT" strokeType="INSIDE" width="583.0" />
|
||||
</children></Pane>
|
||||
</center>
|
||||
</BorderPane>
|
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
Binary file not shown.
After Width: | Height: | Size: 299 KiB |
Loading…
Reference in New Issue