Add unimplemented, about pages

This commit is contained in:
Tyler 2024-07-24 20:59:50 +01:00
parent 2827d79556
commit 21fa946011
Signed by: observer
GPG Key ID: 934A62C2C469FFAF
5 changed files with 87 additions and 6 deletions

View File

@ -1,19 +1,26 @@
package com.shr4pnel.minesweeper; package com.shr4pnel.minesweeper;
import java.io.IOException;
import java.net.URL; import java.net.URL;
import java.util.Timer; import java.util.Timer;
import java.util.TimerTask; import java.util.TimerTask;
import javafx.event.ActionEvent; import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Node; import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Button; import javafx.scene.control.Button;
import javafx.scene.control.MenuItem;
import javafx.scene.control.RadioMenuItem; import javafx.scene.control.RadioMenuItem;
import javafx.scene.image.Image; import javafx.scene.image.Image;
import javafx.scene.image.ImageView; import javafx.scene.image.ImageView;
import javafx.scene.input.MouseButton; import javafx.scene.input.MouseButton;
import javafx.scene.input.MouseEvent; import javafx.scene.input.MouseEvent;
import javafx.scene.layout.GridPane; import javafx.scene.layout.GridPane;
import javafx.stage.Stage;
public class Controller { public class Controller {
@FXML @FXML
@ -25,6 +32,9 @@ public class Controller {
@FXML @FXML
private RadioMenuItem color, marks; private RadioMenuItem color, marks;
@FXML
private MenuItem about;
private Grid gridHandler; private Grid gridHandler;
private GridWrapper wrapper; private GridWrapper wrapper;
private boolean gameOver = false; private boolean gameOver = false;
@ -40,14 +50,40 @@ public class Controller {
private void initialize() { private void initialize() {
setNotYetImplemented(color); setNotYetImplemented(color);
setNotYetImplemented(marks); setNotYetImplemented(marks);
about.setOnAction(this::openAbout);
setupGrid(); setupGrid();
gridHandler = new Grid(); gridHandler = new Grid();
wrapper = gridHandler.grid; wrapper = gridHandler.grid;
expandedTiles = new boolean[30][16]; expandedTiles = new boolean[30][16];
} }
private void openAbout(ActionEvent actionEvent) {
try {
Parent root = FXMLLoader.load(getClass().getResource("about.fxml"));
Stage stage = new Stage();
stage.setTitle("About");
stage.setScene(new Scene(root));
stage.show();
} catch (IOException e) {
e.printStackTrace();
}
}
private void setNotYetImplemented(RadioMenuItem node) { private void setNotYetImplemented(RadioMenuItem node) {
node.setOnAction((ActionEvent e) -> System.out.println("https://http.cat/images/501.jpg")); node.setOnAction(new EventHandler<>() {
@Override
public void handle(ActionEvent actionEvent) {
try {
Parent root = FXMLLoader.load(getClass().getResource("unimplemented.fxml"));
Stage stage = new Stage();
stage.setTitle("Unimplemented!");
stage.setScene(new Scene(root));
stage.show();
} catch (IOException e) {
e.printStackTrace();
}
}
});
} }
private void setupGrid() { private void setupGrid() {
@ -60,8 +96,7 @@ public class Controller {
} }
private Button createBlankButton() { private Button createBlankButton() {
Image blank = Image blank = new Image(String.valueOf(getClass().getResource("img/blank.png")), 16, 16, true, false);
new Image(String.valueOf(getClass().getResource("img/blank.png")), 16, 16, true, true);
ImageView blankImage = new ImageView(blank); ImageView blankImage = new ImageView(blank);
Button blankButton = new Button(); Button blankButton = new Button();
blankButton.setGraphic(blankImage); blankButton.setGraphic(blankImage);

View File

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.image.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.*?>
<AnchorPane prefHeight="225.0" prefWidth="454.0" xmlns="http://javafx.com/javafx/17.0.2-ea" xmlns:fx="http://javafx.com/fxml/1">
<children>
<ImageView fitHeight="150.0" fitWidth="200.0" layoutX="146.0" layoutY="31.0" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@winmine.png" />
</image>
</ImageView>
<Text layoutY="42.0" strokeType="OUTSIDE" strokeWidth="0.0" text="made with love - shrapnelnet" textAlignment="CENTER" wrappingWidth="454.0">
<font>
<Font name="Source Code Pro" size="13.0" />
</font>
</Text>
<Text layoutY="183.0" strokeType="OUTSIDE" strokeWidth="0.0" text="greeTz: b4rkod, ping, cockpit, vulon, i330 n' porcupine" textAlignment="CENTER" wrappingWidth="454.0">
<font>
<Font name="Source Code Pro" size="13.0" />
</font>
</Text>
<Text layoutY="200.0" strokeType="OUTSIDE" strokeWidth="0.0" text="next time make your own!" textAlignment="CENTER" wrappingWidth="454.0">
<font>
<Font name="Source Code Pro" size="13.0" />
</font>
</Text>
</children>
</AnchorPane>

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

View File

@ -8,7 +8,7 @@
<VBox maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="350.0" prefWidth="500.0" style="-fx-border-color: black; -fx-border-width: 1px;" stylesheets="@fix-glow.css" xmlns="http://javafx.com/javafx/17.0.2-ea" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.shr4pnel.minesweeper.Controller"> <VBox maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="350.0" prefWidth="500.0" style="-fx-border-color: black; -fx-border-width: 1px;" stylesheets="@fix-glow.css" xmlns="http://javafx.com/javafx/17.0.2-ea" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.shr4pnel.minesweeper.Controller">
<children> <children>
<MenuBar style="-fx-background-color: white;"> <MenuBar prefWidth="498.0" style="-fx-background-color: white;">
<menus> <menus>
<Menu mnemonicParsing="false" text="Game"> <Menu mnemonicParsing="false" text="Game">
<items> <items>
@ -23,7 +23,7 @@
<ToggleGroup fx:id="difficulty" /> <ToggleGroup fx:id="difficulty" />
</toggleGroup> </toggleGroup>
</RadioMenuItem> </RadioMenuItem>
<RadioMenuItem mnemonicParsing="false" text="Internmediate" toggleGroup="$difficulty" /> <RadioMenuItem mnemonicParsing="false" text="Intermediate" toggleGroup="$difficulty" />
<RadioMenuItem mnemonicParsing="false" selected="true" text="Expert" toggleGroup="$difficulty" /> <RadioMenuItem mnemonicParsing="false" selected="true" text="Expert" toggleGroup="$difficulty" />
<SeparatorMenuItem mnemonicParsing="false" /> <SeparatorMenuItem mnemonicParsing="false" />
<RadioMenuItem fx:id="marks" mnemonicParsing="false" selected="true" text="Marks (?)" /> <RadioMenuItem fx:id="marks" mnemonicParsing="false" selected="true" text="Marks (?)" />
@ -36,7 +36,7 @@
</Menu> </Menu>
<Menu mnemonicParsing="false" text="Help"> <Menu mnemonicParsing="false" text="Help">
<items> <items>
<MenuItem mnemonicParsing="false" text="About Minesweeper" /> <MenuItem fx:id="about" mnemonicParsing="false" text="About Minesweeper" />
</items> </items>
</Menu> </Menu>
</menus> </menus>

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.image.*?>
<?import javafx.scene.layout.*?>
<Pane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="420.0" prefWidth="525.0" xmlns="http://javafx.com/javafx/17.0.2-ea" xmlns:fx="http://javafx.com/fxml/1">
<children>
<ImageView fitHeight="420.0" fitWidth="531.0" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@img/204.jpg" />
</image>
</ImageView>
</children>
</Pane>