commit 218da32ee4a3cb13cbccef6da1727feb5e7a0954
parent 7430acc0b4b64f7c3cca11283d0b3fa157e8999d
Author: A Koens <[email protected]>
Date: Sun, 29 Jan 2023 15:22:57 +0100
Library implementation
Diffstat:
8 files changed, 186 insertions(+), 164 deletions(-)
diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java
@@ -16,20 +16,18 @@ module nl.isygameclient {
exports nl.isygameclient;
// Controllers
exports nl.isygameclient.controllers.games.tictactoe;
- exports nl.isygameclient.controllers.game_selector;
// Models
exports nl.isygameclient.models;
exports nl.isygameclient.util;
exports nl.isygameclient.models.settings;
- exports nl.isygameclient.models.games.tictactoe;
+ exports nl.isygameclient.models.games;
exports nl.isygameclient.models.board;
opens nl.isygameclient to javafx.fxml;
opens nl.isygameclient.controllers.games to javafx.fxml;
- opens nl.isygameclient.controllers.game_selector to javafx.fxml;
opens nl.isygameclient.controllers.games.tictactoe to javafx.fxml;
opens nl.isygameclient.controllers.games.othello to javafx.fxml;
@@ -37,8 +35,6 @@ module nl.isygameclient {
opens nl.isygameclient.models to com.google.gson;
opens nl.isygameclient.models.board to com.google.gson;
opens nl.isygameclient.models.settings to com.google.gson;
- opens nl.isygameclient.models.games.tictactoe to com.google.gson;
- exports nl.isygameclient.models.games;
opens nl.isygameclient.models.games to com.google.gson;
}
diff --git a/src/main/java/nl/isygameclient/controllers/GameCardController.java b/src/main/java/nl/isygameclient/controllers/GameCardController.java
@@ -0,0 +1,4 @@
+package nl.isygameclient.controllers;
+
+public class GameCardController {
+}
diff --git a/src/main/java/nl/isygameclient/controllers/GameLibraryController.java b/src/main/java/nl/isygameclient/controllers/GameLibraryController.java
@@ -1,6 +1,7 @@
package nl.isygameclient.controllers;
import javafx.collections.ObservableList;
+import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
@@ -9,9 +10,12 @@ import java.util.ResourceBundle;
public class GameLibraryController implements Initializable {
-
@Override
public void initialize(URL url, ResourceBundle resourceBundle) {
}
+
+ public void onStartGameButtonClick(ActionEvent e) {
+
+ }
}
\ No newline at end of file
diff --git a/src/main/java/nl/isygameclient/controllers/game_selector/GameCardController.java b/src/main/java/nl/isygameclient/controllers/game_selector/GameCardController.java
@@ -1,45 +1,45 @@
-package nl.isygameclient.controllers.game_selector;
-
-import javafx.fxml.FXML;
-import javafx.scene.control.Label;
-import javafx.scene.image.Image;
-import javafx.scene.image.ImageView;
-import javafx.scene.input.MouseEvent;
-import nl.isygameclient.Application;
-
-public class GameCardController {
-
- private GameCard gameCard;
-
- @FXML
- private ImageView gameImage;
-
- @FXML
- private Label gameTitle;
-
- public void initializeCard(GameCard gameCard) {
- this.gameCard = gameCard;
- // Set Title
- gameTitle.setText(gameCard.getName());
- loadImage();
- }
-
- public void loadImage() {
- // Load Image
- if (gameCard.getImgSrc() != null) {
- var imageSrc = Application.class.getResource(gameCard.getImgSrc());
- if (imageSrc != null) {
- gameImage.setImage(new Image(imageSrc.toExternalForm()));
- } else {
- System.err.printf("Image for: %s at %s, doen not exist\n", gameCard.getName(), gameCard.getImgSrc());
- }
- } else {
- System.err.printf("ImgSrc for: %s, not provided\n", gameCard.getName());
- }
- }
-
- @FXML
- protected void onCardMouseClick(MouseEvent event) {
- GameSelectorController.onGameClick(event, gameCard);
- }
-}
+//package nl.isygameclient.controllers.game_selector;
+//
+//import javafx.fxml.FXML;
+//import javafx.scene.control.Label;
+//import javafx.scene.image.Image;
+//import javafx.scene.image.ImageView;
+//import javafx.scene.input.MouseEvent;
+//import nl.isygameclient.Application;
+//
+//public class GameCardController {
+//
+// privat e GameCard gameCard;
+//
+// @FXML
+// private ImageView gameImage;
+//
+// @FXML
+// private Label gameTitle;
+//
+// public void initializeCard(GameCard gameCard) {
+// this.gameCard = gameCard;
+// // Set Title
+// gameTitle.setText(gameCard.getName());
+// loadImage();
+// }
+//
+// public void loadImage() {
+// // Load Image
+// if (gameCard.getImgSrc() != null) {
+// var imageSrc = Application.class.getResource(gameCard.getImgSrc());
+// if (imageSrc != null) {
+// gameImage.setImage(new Image(imageSrc.toExternalForm()));
+// } else {
+// System.err.printf("Image for: %s at %s, doen not exist\n", gameCard.getName(), gameCard.getImgSrc());
+// }
+// } else {
+// System.err.printf("ImgSrc for: %s, not provided\n", gameCard.getName());
+// }
+// }
+//
+// @FXML
+// protected void onCardMouseClick(MouseEvent event) {
+// GameSelectorController.onGameClick(event, gameCard);
+// }
+//}
diff --git a/src/main/java/nl/isygameclient/controllers/game_selector/GameSelectorController.java b/src/main/java/nl/isygameclient/controllers/game_selector/GameSelectorController.java
@@ -1,109 +1,109 @@
-package nl.isygameclient.controllers.game_selector;
-
-import javafx.collections.FXCollections;
-import javafx.fxml.FXML;
-import javafx.fxml.FXMLLoader;
-import javafx.fxml.Initializable;
-import javafx.scene.Node;
-import javafx.scene.control.ListCell;
-import javafx.scene.control.ListView;
-import javafx.scene.control.TextField;
-import javafx.scene.input.MouseEvent;
-import javafx.scene.layout.FlowPane;
-import javafx.scene.layout.VBox;
-import nl.isygameclient.Application;
-import nl.isygameclient.util.SettingsFileHandler;
-import nl.isygameclient.util.StageHandler;
-
-import java.io.IOException;
-import java.net.URL;
-import java.util.List;
-import java.util.ResourceBundle;
-import java.util.stream.Collectors;
-
-public class GameSelectorController implements Initializable {
-
- private final List<GameCard> gameCards = SettingsFileHandler.load().gameCards;
-
- @FXML
- public TextField searchBox;
- @FXML
- public ListView<GameCard> gamesList;
- @FXML
- public VBox gameDetail;
-
- @FXML
- public FlowPane gameContainer;
-
- public static void onGameClick(MouseEvent event, GameCard gameCard) {
- var stageHandler = StageHandler.get();
- var stageName = "Game";
- if (event.getClickCount() == 2 && gameCard.getViewSrc() != null && !stageHandler.getStage(stageName).isShowing()) {
- stageHandler.changeSceneOfStage(stageName, gameCard.getViewSrc());
- var stage = stageHandler.getStage(stageName);
- stage.setTitle(gameCard.getName());
- stage.show();
- stageHandler.iconifyStage("GameSelector");
- }
- }
-
- @Override
- public void initialize(URL url, ResourceBundle resourceBundle) {
- initializeGamesListView();
- initializeGamesListCells();
- initializeGameCards();
- }
-
- private void initializeGamesListView() {
- gamesList.setItems(FXCollections.observableList(gameCards));
- searchBox.textProperty().addListener((observable, oldValue, newValue) -> {
- var filteredList = FXCollections.observableList(filterGameCards(newValue));
- gamesList.setItems(filteredList);
- });
- }
-
- private void initializeGamesListCells() {
- gamesList.setCellFactory(lv -> {
- ListCell<GameCard> listCell = new ListCell<>() {
- @Override
- protected void updateItem(GameCard item, boolean empty) {
- super.updateItem(item, empty);
-
- if (empty || item == null || item.getName() == null) {
- setText(null);
- } else {
- setText(item.getName());
- }
- }
- };
- listCell.setOnMouseClicked((event) -> {
- GameCard gameCard = listCell.getItem();
- onGameClick(event, gameCard);
- });
- return listCell;
- });
- }
-
- private void initializeGameCards() {
- try {
- for (GameCard gameCard : gameCards) {
- FXMLLoader fxmlLoader = new FXMLLoader(Application.class.getResource("views/game_selector/GameCard.fxml"));
- Node node = fxmlLoader.load();
- GameCardController controller = fxmlLoader.getController();
- controller.initializeCard(gameCard);
- gameContainer.getChildren().add(node);
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
-
- private List<GameCard> filterGameCards(String value) {
- return gameCards.stream().filter(gameCard -> gameCard.getName().contains(value)).collect(Collectors.toList());
- }
-
- @FXML
- protected void onClearSearchButtonClick() {
- searchBox.clear();
- }
-}
+//package nl.isygameclient.controllers.game_selector;
+//
+//import javafx.collections.FXCollections;
+//import javafx.fxml.FXML;
+//import javafx.fxml.FXMLLoader;
+//import javafx.fxml.Initializable;
+//import javafx.scene.Node;
+//import javafx.scene.control.ListCell;
+//import javafx.scene.control.ListView;
+//import javafx.scene.control.TextField;
+//import javafx.scene.input.MouseEvent;
+//import javafx.scene.layout.FlowPane;
+//import javafx.scene.layout.VBox;
+//import nl.isygameclient.Application;
+//import nl.isygameclient.util.SettingsFileHandler;
+//import nl.isygameclient.util.StageHandler;
+//
+//import java.io.IOException;
+//import java.net.URL;
+//import java.util.List;
+//import java.util.ResourceBundle;
+//import java.util.stream.Collectors;
+//
+//public class GameSelectorController implements Initializable {
+//
+// private final List<GameCard> gameCards = SettingsFileHandler.load().gameCards;
+//
+// @FXML
+// public TextField searchBox;
+// @FXML
+// public ListView<GameCard> gamesList;
+// @FXML
+// public VBox gameDetail;
+//
+// @FXML
+// public FlowPane gameContainer;
+//
+// public static void onGameClick(MouseEvent event, GameCard gameCard) {
+// var stageHandler = StageHandler.get();
+// var stageName = "Game";
+// if (event.getClickCount() == 2 && gameCard.getViewSrc() != null && !stageHandler.getStage(stageName).isShowing()) {
+// stageHandler.changeSceneOfStage(stageName, gameCard.getViewSrc());
+// var stage = stageHandler.getStage(stageName);
+// stage.setTitle(gameCard.getName());
+// stage.show();
+// stageHandler.iconifyStage("GameSelector");
+// }
+// }
+//
+// @Override
+// public void initialize(URL url, ResourceBundle resourceBundle) {
+// initializeGamesListView();
+// initializeGamesListCells();
+// initializeGameCards();
+// }
+//
+// private void initializeGamesListView() {
+// gamesList.setItems(FXCollections.observableList(gameCards));
+// searchBox.textProperty().addListener((observable, oldValue, newValue) -> {
+// var filteredList = FXCollections.observableList(filterGameCards(newValue));
+// gamesList.setItems(filteredList);
+// });
+// }
+//
+// private void initializeGamesListCells() {
+// gamesList.setCellFactory(lv -> {
+// ListCell<GameCard> listCell = new ListCell<>() {
+// @Override
+// protected void updateItem(GameCard item, boolean empty) {
+// super.updateItem(item, empty);
+//
+// if (empty || item == null || item.getName() == null) {
+// setText(null);
+// } else {
+// setText(item.getName());
+// }
+// }
+// };
+// listCell.setOnMouseClicked((event) -> {
+// GameCard gameCard = listCell.getItem();
+// onGameClick(event, gameCard);
+// });
+// return listCell;
+// });
+// }
+//
+// private void initializeGameCards() {
+// try {
+// for (GameCard gameCard : gameCards) {
+// FXMLLoader fxmlLoader = new FXMLLoader(Application.class.getResource("views/game_selector/GameCard.fxml"));
+// Node node = fxmlLoader.load();
+// GameCardController controller = fxmlLoader.getController();
+// controller.initializeCard(gameCard);
+// gameContainer.getChildren().add(node);
+// }
+// } catch (IOException e) {
+// e.printStackTrace();
+// }
+// }
+//
+// private List<GameCard> filterGameCards(String value) {
+// return gameCards.stream().filter(gameCard -> gameCard.getName().contains(value)).collect(Collectors.toList());
+// }
+//
+// @FXML
+// protected void onClearSearchButtonClick() {
+// searchBox.clear();
+// }
+//}
diff --git a/src/main/resources/nl/isygameclient/css/style.css b/src/main/resources/nl/isygameclient/css/style.css
@@ -4,10 +4,15 @@
.transparent {
-fx-background-color: transparent;
+ -fx-control-inner-background: transparent;
-fx-text-fill: transparent;
-fx-fill: transparent;
}
+.scroll-pane > .viewport {
+ -fx-background-color: transparent;
+}
+
.rounded {
-fx-border-radius: 10px;
-fx-background-radius: 10px;
diff --git a/src/main/resources/nl/isygameclient/views/game-card.fxml b/src/main/resources/nl/isygameclient/views/game-card.fxml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<?import java.lang.*?>
+<?import java.util.*?>
+<?import javafx.scene.*?>
+<?import javafx.scene.control.*?>
+<?import javafx.scene.layout.*?>
+
+<AnchorPane xmlns="http://javafx.com/javafx"
+ xmlns:fx="http://javafx.com/fxml"
+ fx:controller="nl.isygameclient.controllers.GameCardController"
+ prefHeight="400.0" prefWidth="600.0">
+
+</AnchorPane>
diff --git a/src/main/resources/nl/isygameclient/views/game-library.fxml b/src/main/resources/nl/isygameclient/views/game-library.fxml
@@ -14,11 +14,10 @@
<?import javafx.scene.layout.FlowPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.VBox?>
-<?import javafx.collections.ObservableList?>
<ScrollPane fitToHeight="true" fitToWidth="true" hbarPolicy="NEVER" prefWidth="1200.0" styleClass="transparent" vbarPolicy="NEVER" xmlns="http://javafx.com/javafx/19" xmlns:fx="http://javafx.com/fxml/1">
<content>
- <BorderPane>
+ <BorderPane styleClass="transparent">
<top>
<HBox alignment="CENTER" spacing="15" BorderPane.alignment="CENTER">
<children>
@@ -59,11 +58,11 @@
</HBox>
</top>
<center>
- <FlowPane fx:id="games" hgap="15.0" prefHeight="200.0" prefWidth="200.0" vgap="15.0" BorderPane.alignment="CENTER">
+ <FlowPane fx:id="games" hgap="15.0" prefHeight="200.0" prefWidth="200.0" vgap="15.0" BorderPane.alignment="CENTER">
<padding>
<Insets bottom="15.0" left="15.0" right="15.0" top="15.0" />
</padding>
- <children >
+ <children>
<VBox prefHeight="300.0" prefWidth="200.0">
<children>
<ImageView fitHeight="250.0" fitWidth="200.0" pickOnBounds="true">