hanze/game-client

change com.example.isygameclient to nl.isygameclient numero dos (738e3e8a4d3ad7620835d6eaef04de6b582dfbc0)
Repositories

commit 738e3e8a4d3ad7620835d6eaef04de6b582dfbc0
parent 4e050b6a242c6c5e5e5bb1fd3ba8ccad0ddc5c3e
Author: Friedel Schön <derfriedmundschoen@gmail.com>
Date:   Wed,  5 Oct 2022 14:48:12 +0200

change com.example.isygameclient to nl.isygameclient numero dos

Diffstat:
Msettings.properties2+-
Msrc/main/java/module-info.java20++++++++++----------
Msrc/main/java/nl/isygameclient/Application.java39++++++++++++++++++---------------------
Asrc/main/java/nl/isygameclient/NetworkClient.java4++++
Msrc/main/java/nl/isygameclient/controllers/HelloController.java22+++++++++++-----------
Msrc/main/java/nl/isygameclient/models/SimpleCalculator.java8++++----
Msrc/main/java/nl/isygameclient/util/Settings.java10+++++-----
Msrc/main/java/nl/isygameclient/util/SettingsHandler.java118+++++++++++++++++++++++++++++++++++++++----------------------------------------
Dsrc/main/resources/com/example/isygameclient/views/hello-view.fxml14--------------
Rsrc/main/resources/com/example/isygameclient/css/hello.css -> src/main/resources/nl/isygameclient/css/hello.css0
Rsrc/main/resources/com/example/isygameclient/images/reversie_logo.png -> src/main/resources/nl/isygameclient/images/reversie_logo.png0
Rsrc/main/resources/com/example/isygameclient/images/tictactoe_logo.png -> src/main/resources/nl/isygameclient/images/tictactoe_logo.png0
Asrc/main/resources/nl/isygameclient/views/hello-view.fxml14++++++++++++++
Dsrc/test/java/com/example/isygameclient/models/SimpleCalculatorTest.java20--------------------
Dsrc/test/java/com/example/isygameclient/util/SettingsTest.java14--------------
Asrc/test/java/nl/isygameclient/models/SimpleCalculatorTest.java20++++++++++++++++++++
Asrc/test/java/nl/isygameclient/util/SettingsTest.java14++++++++++++++
17 files changed, 159 insertions(+), 160 deletions(-)

diff --git a/settings.properties b/settings.properties @@ -1,5 +1,5 @@ #Application Settings -#Wed Oct 05 14:33:10 CEST 2022 +#Wed Oct 05 14:47:58 CEST 2022 fullscreen=false screenHeight=480 screenWidth=680 diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java @@ -1,15 +1,15 @@ -module com.example.isygameclient { - requires javafx.controls; - requires javafx.fxml; +module nl.isygameclient { + requires javafx.controls; + requires javafx.fxml; - requires org.controlsfx.controls; - requires org.kordamp.bootstrapfx.core; + requires org.controlsfx.controls; + requires org.kordamp.bootstrapfx.core; - requires static lombok; + requires static lombok; - exports com.example.isygameclient; - exports com.example.isygameclient.controllers; + exports nl.isygameclient; + exports nl.isygameclient.controllers; - opens com.example.isygameclient to javafx.fxml; - opens com.example.isygameclient.controllers to javafx.fxml; + opens nl.isygameclient to javafx.fxml; + opens nl.isygameclient.controllers to javafx.fxml; } \ No newline at end of file diff --git a/src/main/java/nl/isygameclient/Application.java b/src/main/java/nl/isygameclient/Application.java @@ -1,30 +1,27 @@ -package com.example.isygameclient; - -import com.example.isygameclient.util.SettingsHandler; +package nl.isygameclient; +import java.io.IOException; import javafx.fxml.FXMLLoader; import javafx.scene.Scene; import javafx.stage.Stage; - -import java.io.IOException; +import nl.isygameclient.util.SettingsHandler; public class Application extends javafx.application.Application { - @Override - public void start(Stage primaryStage) throws IOException { - FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("views/hello-view.fxml")); - Scene scene = new Scene(fxmlLoader.load(), SettingsHandler.getSettings().getScreenWidth(), - SettingsHandler.getSettings().getScreenHeight()); - primaryStage.setTitle(SettingsHandler.getSettings().getTitle()); - primaryStage.setScene(scene); - primaryStage.setFullScreen(SettingsHandler.getSettings().isFullscreen()); - primaryStage.show(); - primaryStage.setOnCloseRequest((windowEvent) -> { - SettingsHandler.saveProperties(); - }); - } + @Override + public void start(Stage primaryStage) throws IOException { + FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("views/hello-view.fxml")); + Scene scene = new Scene(fxmlLoader.load(), SettingsHandler.getSettings().getScreenWidth(), SettingsHandler.getSettings().getScreenHeight()); + primaryStage.setTitle(SettingsHandler.getSettings().getTitle()); + primaryStage.setScene(scene); + primaryStage.setFullScreen(SettingsHandler.getSettings().isFullscreen()); + primaryStage.show(); + primaryStage.setOnCloseRequest((windowEvent) -> { + SettingsHandler.saveProperties(); + }); + } - public static void main(String[] args) { - launch(); - } + public static void main(String[] args) { + launch(); + } } \ No newline at end of file diff --git a/src/main/java/nl/isygameclient/NetworkClient.java b/src/main/java/nl/isygameclient/NetworkClient.java @@ -0,0 +1,4 @@ +package nl.isygameclient; + +public interface NetworkClient { +} diff --git a/src/main/java/nl/isygameclient/controllers/HelloController.java b/src/main/java/nl/isygameclient/controllers/HelloController.java @@ -1,21 +1,21 @@ -package com.example.isygameclient.controllers; +package nl.isygameclient.controllers; -import com.example.isygameclient.util.SettingsHandler; import javafx.fxml.FXML; import javafx.scene.control.Button; import javafx.scene.control.Label; import javafx.stage.Stage; +import nl.isygameclient.util.SettingsHandler; public class HelloController { - @FXML - private Label welcomeText; + @FXML + private Label welcomeText; - @FXML - private Button welcomeButton; + @FXML + private Button welcomeButton; - @FXML - protected void onHelloButtonClick() { - welcomeText.setText(SettingsHandler.getSettings().getTitle()); - ((Stage)welcomeButton.getScene().getWindow()).setFullScreen(true); - } + @FXML + protected void onHelloButtonClick() { + welcomeText.setText(SettingsHandler.getSettings().getTitle()); + ((Stage) welcomeButton.getScene().getWindow()).setFullScreen(true); + } } \ No newline at end of file diff --git a/src/main/java/nl/isygameclient/models/SimpleCalculator.java b/src/main/java/nl/isygameclient/models/SimpleCalculator.java @@ -1,8 +1,8 @@ -package com.example.isygameclient.models; +package nl.isygameclient.models; public class SimpleCalculator { - public int add (int numberA, int numberB) { - return numberA + numberB; - } + public int add(int numberA, int numberB) { + return numberA + numberB; + } } diff --git a/src/main/java/nl/isygameclient/util/Settings.java b/src/main/java/nl/isygameclient/util/Settings.java @@ -1,4 +1,4 @@ -package com.example.isygameclient.util; +package nl.isygameclient.util; import lombok.Data; @@ -6,8 +6,8 @@ import lombok.Data; @Data public class Settings { - private String title = "ISY Game Client"; - private boolean fullscreen = true; - private int screenHeight = 1080; - private int screenWidth = 1920; + private String title = "ISY Game Client"; + private boolean fullscreen = true; + private int screenHeight = 1080; + private int screenWidth = 1920; } diff --git a/src/main/java/nl/isygameclient/util/SettingsHandler.java b/src/main/java/nl/isygameclient/util/SettingsHandler.java @@ -1,4 +1,4 @@ -package com.example.isygameclient.util; +package nl.isygameclient.util; import java.io.FileInputStream; @@ -10,68 +10,66 @@ import java.util.Properties; public abstract class SettingsHandler { - private static Settings settings; + private static Settings settings; - public static Settings getSettings() { - if (settings == null) { - settings = new Settings(); - SettingsHandler.loadPropertiesIntoSettings(); - } - return settings; - } + public static Settings getSettings() { + if (settings == null) { + settings = new Settings(); + SettingsHandler.loadPropertiesIntoSettings(); + } + return settings; + } - private static Properties loadPropertiesFromFile() throws IOException { - Properties properties = new Properties(); - InputStream is = new FileInputStream("settings.properties"); - properties.load(is); - return properties; - } + private static Properties loadPropertiesFromFile() throws IOException { + Properties properties = new Properties(); + InputStream is = new FileInputStream("settings.properties"); + properties.load(is); + return properties; + } - public static void loadPropertiesIntoSettings() { - try { - Properties properties = loadPropertiesFromFile(); - Field[] fields = settings.getClass().getDeclaredFields(); - for (Field field : fields) { - field.setAccessible(true); - Object value; - if (field.getType().equals(String.class)) { - value = String.valueOf(properties.getProperty(field.getName())); - } else if (field.getType().equals(int.class)) { - value = Integer.parseInt(properties.getProperty(field.getName())); - } else if (field.getType().equals(float.class)) { - value = Float.parseFloat(properties.getProperty(field.getName())); - } else if (field.getType().equals(boolean.class)) { - value = Boolean.parseBoolean(properties.getProperty(field.getName())); - } else { - return; - } - field.set(settings, value); - field.setAccessible(false); - } - } catch (IllegalAccessException | NumberFormatException | IOException e) { - System.out.println("ERROR: Unable to load properties from file"); - e.printStackTrace(); - } - } + public static void loadPropertiesIntoSettings() { + try { + Properties properties = loadPropertiesFromFile(); + Field[] fields = settings.getClass().getDeclaredFields(); + for (Field field : fields) { + field.setAccessible(true); + Object value; + if (field.getType().equals(String.class)) { + value = String.valueOf(properties.getProperty(field.getName())); + } else if (field.getType().equals(int.class)) { + value = Integer.parseInt(properties.getProperty(field.getName())); + } else if (field.getType().equals(float.class)) { + value = Float.parseFloat(properties.getProperty(field.getName())); + } else if (field.getType().equals(boolean.class)) { + value = Boolean.parseBoolean(properties.getProperty(field.getName())); + } else { + return; + } + field.set(settings, value); + field.setAccessible(false); + } + } catch (IllegalAccessException | NumberFormatException | IOException e) { + System.out.println("ERROR: Unable to load properties from file"); + e.printStackTrace(); + } + } - public static void saveProperties() { - try { - FileOutputStream fos = new FileOutputStream("settings.properties"); - Properties properties = new Properties(); - Field[] fields = settings.getClass().getDeclaredFields(); - for (Field field : fields) { - field.setAccessible(true); - properties.put(field.getName(), String.valueOf(field.get(settings))); - } - properties.store(fos, "Application Settings"); - fos.flush(); - fos.close(); - - } catch (IOException | IllegalAccessException e) { - System.out.println("ERROR: Unable to save to properties file"); - e.printStackTrace(); - } - } + public static void saveProperties() { + try { + FileOutputStream fos = new FileOutputStream("settings.properties"); + Properties properties = new Properties(); + Field[] fields = settings.getClass().getDeclaredFields(); + for (Field field : fields) { + field.setAccessible(true); + properties.put(field.getName(), String.valueOf(field.get(settings))); + } + properties.store(fos, "Application Settings"); + fos.flush(); + fos.close(); + } catch (IOException | IllegalAccessException e) { + System.out.println("ERROR: Unable to save to properties file"); + e.printStackTrace(); + } + } } - diff --git a/src/main/resources/com/example/isygameclient/views/hello-view.fxml b/src/main/resources/com/example/isygameclient/views/hello-view.fxml @@ -1,14 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<?import javafx.geometry.*?> -<?import javafx.scene.control.*?> -<?import javafx.scene.layout.*?> - -<VBox alignment="CENTER" spacing="20.0" stylesheets="@../css/hello.css" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/16" fx:controller="com.example.isygameclient.controllers.HelloController"> - <padding> - <Insets bottom="20.0" left="20.0" right="20.0" top="20.0" /> - </padding> - - <Label fx:id="welcomeText" /> - <Button fx:id="welcomeButton" onAction="#onHelloButtonClick" text="Hello!" /> -</VBox> diff --git a/src/main/resources/com/example/isygameclient/css/hello.css b/src/main/resources/nl/isygameclient/css/hello.css diff --git a/src/main/resources/com/example/isygameclient/images/reversie_logo.png b/src/main/resources/nl/isygameclient/images/reversie_logo.png Binary files differ. diff --git a/src/main/resources/com/example/isygameclient/images/tictactoe_logo.png b/src/main/resources/nl/isygameclient/images/tictactoe_logo.png Binary files differ. diff --git a/src/main/resources/nl/isygameclient/views/hello-view.fxml b/src/main/resources/nl/isygameclient/views/hello-view.fxml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<?import javafx.geometry.*?> +<?import javafx.scene.control.*?> +<?import javafx.scene.layout.*?> + +<VBox alignment="CENTER" spacing="20.0" stylesheets="@../css/hello.css" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/16" fx:controller="nl.isygameclient.controllers.HelloController"> + <padding> + <Insets bottom="20.0" left="20.0" right="20.0" top="20.0" /> + </padding> + + <Label fx:id="welcomeText" /> + <Button fx:id="welcomeButton" onAction="#onHelloButtonClick" text="Hello!" /> +</VBox> diff --git a/src/test/java/com/example/isygameclient/models/SimpleCalculatorTest.java b/src/test/java/com/example/isygameclient/models/SimpleCalculatorTest.java @@ -1,19 +0,0 @@ -package com.example.isygameclient.models; - -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.*; - -class SimpleCalculatorTest { - @Test - void twoPlusTwoShouldEqualFour() { - var calculator = new SimpleCalculator(); - assertEquals(4, calculator.add(2,2)); - } - - @Test - void ThreePlusSevenShouldEqualTen() { - var calculator = new SimpleCalculator(); - assertEquals(10, calculator.add(3,7)); - } -} -\ No newline at end of file diff --git a/src/test/java/com/example/isygameclient/util/SettingsTest.java b/src/test/java/com/example/isygameclient/util/SettingsTest.java @@ -1,13 +0,0 @@ -package com.example.isygameclient.util; - -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.*; - -class SettingsTest { - - @Test - void ShouldGiveTitle() { - assertEquals(String.class, SettingsHandler.getSettings().getTitle().getClass()); - } -} -\ No newline at end of file diff --git a/src/test/java/nl/isygameclient/models/SimpleCalculatorTest.java b/src/test/java/nl/isygameclient/models/SimpleCalculatorTest.java @@ -0,0 +1,19 @@ +package nl.isygameclient.models; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.Test; + +class SimpleCalculatorTest { + @Test + void twoPlusTwoShouldEqualFour() { + var calculator = new SimpleCalculator(); + assertEquals(4, calculator.add(2, 2)); + } + + @Test + void ThreePlusSevenShouldEqualTen() { + var calculator = new SimpleCalculator(); + assertEquals(10, calculator.add(3, 7)); + } +} +\ No newline at end of file diff --git a/src/test/java/nl/isygameclient/util/SettingsTest.java b/src/test/java/nl/isygameclient/util/SettingsTest.java @@ -0,0 +1,13 @@ +package nl.isygameclient.util; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.Test; + +class SettingsTest { + + @Test + void ShouldGiveTitle() { + assertEquals(String.class, SettingsHandler.getSettings().getTitle().getClass()); + } +} +\ No newline at end of file