From 61d399fee827ecd25e939eedfd7426415ce43902 Mon Sep 17 00:00:00 2001 From: Madzi Date: Mon, 12 Sep 2022 18:44:13 +0200 Subject: [PATCH 01/19] Test changes --- .travis.yml | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 462fb99..0000000 --- a/.travis.yml +++ /dev/null @@ -1,5 +0,0 @@ -language: java -jdk: - - oraclejdk10 -# - oraclejdk7 -# - openjdk6 From 19ea95a2869efca693116bf87c1bb3210961be28 Mon Sep 17 00:00:00 2001 From: Madzi Date: Thu, 22 Sep 2022 21:02:22 +0200 Subject: [PATCH 02/19] Provide template for desktop application --- .gitignore | 3 + docs/index.adoc | 1 + ifml.player/pom.xml | 208 -------------- .../src/main/java/ifml/player/PlayerApp.java | 24 -- .../src/main/java/ifml/player/main.fxml | 14 - .../main/java/ifml/player/package-info.java | 4 - .../main/java/ifml/player/view/MainView.java | 21 -- .../java/ifml/player/view/package-info.java | 4 - ifml.player/src/main/java/module-info.java | 11 - ifml.player/src/main/resources/main.fxml | 34 --- pom.xml | 264 ++++++++---------- readme.adoc | 8 - src/main/java/ifml3/app/Ifml3App.java | 21 ++ src/main/java/module-info.java | 5 + src/main/resources/lang/ifml3.properties | 0 toolchanis.xml | 18 -- 16 files changed, 153 insertions(+), 487 deletions(-) create mode 100644 docs/index.adoc delete mode 100644 ifml.player/pom.xml delete mode 100644 ifml.player/src/main/java/ifml/player/PlayerApp.java delete mode 100644 ifml.player/src/main/java/ifml/player/main.fxml delete mode 100644 ifml.player/src/main/java/ifml/player/package-info.java delete mode 100644 ifml.player/src/main/java/ifml/player/view/MainView.java delete mode 100644 ifml.player/src/main/java/ifml/player/view/package-info.java delete mode 100644 ifml.player/src/main/java/module-info.java delete mode 100644 ifml.player/src/main/resources/main.fxml delete mode 100644 readme.adoc create mode 100644 src/main/java/ifml3/app/Ifml3App.java create mode 100644 src/main/java/module-info.java create mode 100644 src/main/resources/lang/ifml3.properties delete mode 100644 toolchanis.xml diff --git a/.gitignore b/.gitignore index b237d4c..6e04921 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,6 @@ target/ # Idea .idea/ *.iml + +# NetBeans +nb-configuration.xml diff --git a/docs/index.adoc b/docs/index.adoc new file mode 100644 index 0000000..d260c53 --- /dev/null +++ b/docs/index.adoc @@ -0,0 +1 @@ += ЯРИЛ (Язык Разметки Интерактивной Литературы) v 3.0 diff --git a/ifml.player/pom.xml b/ifml.player/pom.xml deleted file mode 100644 index 8ed92f8..0000000 --- a/ifml.player/pom.xml +++ /dev/null @@ -1,208 +0,0 @@ - - - 4.0.0 - - - ifml - ifml - 3.1.0.0-SNAPSHOT - .. - - - ifml.player - - IFML::PLAYER - Player for Interctive Fiction Markup Language - - - ${project.build.directory}/modules - ifml.player - ifml.player.PlayerApp - - - - - - org.apache.maven.plugins - maven-toolchains-plugin - - - - open11 - 11 - - - - - - - toolchain - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - - ${java.version} - ${java.version} - ${java.version} - - - - org.ow2.asm - asm - 6.2.1 - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - copy-dependencies - prepare-package - - copy-dependencies - - - ${modules.dir} - runtime - - - - - - - org.apache.maven.plugins - maven-jar-plugin - - ${modules.dir} - - - - - org.apache.maven.plugins - maven-enforcer-plugin - - - enforce-maven - - enforce - - - - - 3.5.0 - - - - - - - - - org.codehaus.mojo - exec-maven-plugin - - - - exec - - - - - ${java.home}/bin/java - - --module-path - ${modules.dir} - --module - ${moduleName}/${mainClass} - - - - - - org.moditect - moditect-maven-plugin - - - create-runtime-image - package - - create-runtime-image - - - - ${modules.dir} - - - ${moduleName} - - - ${mainClass} - ${moduleName}/${mainClass} - - 2 - true - ${project.build.directory}/jlink-image - - - - - - - - - - org.openjfx - javafx-base - - - - org.openjfx - javafx-graphics - - - - org.openjfx - javafx-controls - - - - org.openjfx - javafx-fxml - - - - org.openjfx - javafx-web - - - - org.slf4j - slf4j-api - - - - org.slf4j - slf4j-simple - - - - org.junit.jupiter - junit-jupiter-api - - - - org.junit.jupiter - junit-jupiter-engine - - - - \ No newline at end of file diff --git a/ifml.player/src/main/java/ifml/player/PlayerApp.java b/ifml.player/src/main/java/ifml/player/PlayerApp.java deleted file mode 100644 index 0e5ae7c..0000000 --- a/ifml.player/src/main/java/ifml/player/PlayerApp.java +++ /dev/null @@ -1,24 +0,0 @@ -package ifml.player; - -import javafx.application.Application; -import javafx.fxml.FXMLLoader; -import javafx.scene.Parent; -import javafx.scene.Scene; -import javafx.stage.Stage; - -public class PlayerApp extends Application { - - @Override - public void start(final Stage primaryStage) throws Exception { - if (primaryStage == null) { System.exit(-1); } - Parent root = FXMLLoader.load(PlayerApp.class.getClassLoader().getResource("main.fxml")); - primaryStage.setTitle("PIF"); - primaryStage.setScene(new Scene(root, 800.0, 600.0)); - primaryStage.show(); - } - - public static void main(String[] args) { - launch(PlayerApp.class, args); - } - -} diff --git a/ifml.player/src/main/java/ifml/player/main.fxml b/ifml.player/src/main/java/ifml/player/main.fxml deleted file mode 100644 index 40c1f9f..0000000 --- a/ifml.player/src/main/java/ifml/player/main.fxml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - diff --git a/ifml.player/src/main/java/ifml/player/package-info.java b/ifml.player/src/main/java/ifml/player/package-info.java deleted file mode 100644 index 515c648..0000000 --- a/ifml.player/src/main/java/ifml/player/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * Interactive Fiction Markup Language. - */ -package ifml.player; diff --git a/ifml.player/src/main/java/ifml/player/view/MainView.java b/ifml.player/src/main/java/ifml/player/view/MainView.java deleted file mode 100644 index 08b07b8..0000000 --- a/ifml.player/src/main/java/ifml/player/view/MainView.java +++ /dev/null @@ -1,21 +0,0 @@ -package ifml.player.view; - -import java.net.URL; -import java.util.ResourceBundle; - -import javafx.fxml.FXML; -import javafx.fxml.Initializable; -import javafx.scene.web.WebView; - -public class MainView implements Initializable { - - @FXML - private WebView webView; - - @Override - public void initialize(URL location, ResourceBundle resources) { - var webEngine = webView.getEngine(); - webEngine.loadContent("BODY"); - } - -} diff --git a/ifml.player/src/main/java/ifml/player/view/package-info.java b/ifml.player/src/main/java/ifml/player/view/package-info.java deleted file mode 100644 index f2d3250..0000000 --- a/ifml.player/src/main/java/ifml/player/view/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * Controllers for FXML files. - */ -package ifml.player.view; diff --git a/ifml.player/src/main/java/module-info.java b/ifml.player/src/main/java/module-info.java deleted file mode 100644 index 6f6ec4f..0000000 --- a/ifml.player/src/main/java/module-info.java +++ /dev/null @@ -1,11 +0,0 @@ -module ifml.player { - requires java.base; - requires javafx.base; - requires javafx.graphics; - requires javafx.controls; - requires javafx.fxml; - requires javafx.web; - exports ifml.player; - exports ifml.player.view; - opens ifml.player.view to javafx.fxml; -} diff --git a/ifml.player/src/main/resources/main.fxml b/ifml.player/src/main/resources/main.fxml deleted file mode 100644 index 051d2ec..0000000 --- a/ifml.player/src/main/resources/main.fxml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
-
diff --git a/pom.xml b/pom.xml index 9f401d2..0a3704b 100644 --- a/pom.xml +++ b/pom.xml @@ -1,88 +1,38 @@ - + + 4.0.0 ifml - ifml - 3.1.0.0-SNAPSHOT - pom + ifml3 + 1.0.1-SNAPSHOT + jar - IFML - Interctive Fiction Markup Language + IFML3 + Interctive Fiction Markup Language (version 3) IFML - - ifml.player - - - UTF-8 - 11 + UTF-8 + ${encoding} + 17 ${java.version} ${java.version} - 11 - 1.8.0-beta2 - 5.3.1 + . + ifml3.app.Ifml3App - - org.openjfx - javafx-base - ${javafx.version} - - - - org.openjfx - javafx-graphics - ${javafx.version} - - org.openjfx javafx-controls - ${javafx.version} - - - - org.openjfx - javafx-fxml - ${javafx.version} - - - - org.openjfx - javafx-web - ${javafx.version} - - - - org.slf4j - slf4j-api - ${slf4j.version} - - - - org.slf4j - slf4j-simple - ${slf4j.version} - - - - org.junit.jupiter - junit-jupiter-api - ${junit.jupiter.version} - - - - org.junit.jupiter - junit-jupiter-engine - ${junit.jupiter.version} + 18.0.1 @@ -90,98 +40,72 @@ - - org.apache.maven.plugins - maven-toolchains-plugin - 1.1 - - - - org.apache.maven.plugins - maven-clean-plugin - 3.1.0 - - org.apache.maven.plugins maven-compiler-plugin - 3.8.0 - - - - org.apache.maven.plugins - maven-dependency-plugin - 3.1.1 + 3.10.1 - - org.apache.maven.plugins - maven-deploy-plugin - 2.8.2 + org.openjfx + javafx-maven-plugin + 0.0.8 - - org.apache.maven.plugins - maven-install-plugin - 2.5.2 - - - - org.apache.maven.plugins - maven-jar-plugin - 3.1.0 - - - - org.apache.maven.plugins - maven-resources-plugin - 3.1.0 - - - - org.apache.maven.plugins - maven-site-plugin - 3.7.1 - - - - org.apache.maven.plugins - maven-surefire-plugin - 2.22.0 - - - - org.apache.maven.plugins - maven-failsafe-plugin - 2.22.0 - - - - org.apache.maven.plugins - maven-enforcer-plugin - 3.0.0-M2 - - - - org.codehaus.mojo - exec-maven-plugin - - - - org.moditect - moditect-maven-plugin - 1.0.0.Beta1 + com.gluonhq + gluonfx-maven-plugin + 1.0.15 + + + org.openjfx + javafx-maven-plugin + + ${exec.mainClass} + + + + com.gluonhq + gluonfx-maven-plugin + + ${gluonfx.target} + ${exec.mainClass} + + lang.ifml3 + + + + + + + org.openjfx + javafx-controls + + + + + org.apache.maven.plugins + maven-jxr-plugin + 3.3.0 + + + aggregate + false + + aggregate + + + + org.codehaus.mojo versions-maven-plugin - 2.7 + 2.11.0 false @@ -198,4 +122,62 @@ - \ No newline at end of file + + + site-support + + + src/site + + + + + + org.apache.maven.plugins + maven-site-plugin + 4.0.0-M3 + + + + + + toolchains-support + + + ${user.home}/.m2/toolchains.xml + + + + + + org.apache.maven.plugins + maven-toolchains-plugin + 3.1.0 + + + + + + + + + + ifml3 + IFML3 + file:///home/de/Workspace/github/ifml3/target + + + + github + https://github.com/IFML2/ifml3/issues + + + github + https://github.com/IFML2/ifml3/actions + + + scm:git:https://github.com/IFML2/ifml3.git + scm:git:git@github.com:IFML2/ifml3.git + https://github.com/IFML2/ifml3 + + diff --git a/readme.adoc b/readme.adoc deleted file mode 100644 index 5f41f6f..0000000 --- a/readme.adoc +++ /dev/null @@ -1,8 +0,0 @@ -= IFML3 - -Interactive Fiction Markup Language v 3.0 - -== How to build -* put `toolchains.xml` to you `MAVEN_HOME` folder (usualy it's `~/.m2`) -* update `toolchains.xml` with your installed JDK informations -* use `mvn clean package` to package application with *jlink* diff --git a/src/main/java/ifml3/app/Ifml3App.java b/src/main/java/ifml3/app/Ifml3App.java new file mode 100644 index 0000000..1070734 --- /dev/null +++ b/src/main/java/ifml3/app/Ifml3App.java @@ -0,0 +1,21 @@ +package ifml3.app; + +import javafx.application.Application; +import javafx.scene.Scene; +import javafx.scene.layout.BorderPane; +import javafx.stage.Stage; + +public class Ifml3App extends Application { + + @Override + public void start(final Stage stage) throws Exception { + BorderPane pane = new BorderPane(); + Scene scene = new Scene(pane, 800.0, 600.0); + stage.setScene(scene); + stage.show(); + } + + public static void main(final String... args) { + launch(args); + } +} diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java new file mode 100644 index 0000000..98e9597 --- /dev/null +++ b/src/main/java/module-info.java @@ -0,0 +1,5 @@ +module ifml3.app { + requires javafx.controls; + + exports ifml3.app; +} diff --git a/src/main/resources/lang/ifml3.properties b/src/main/resources/lang/ifml3.properties new file mode 100644 index 0000000..e69de29 diff --git a/toolchanis.xml b/toolchanis.xml deleted file mode 100644 index 4b716bf..0000000 --- a/toolchanis.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - jdk - - open11 - 11 - openjdk - - - C:\Program Files\Java\jdk-11\ - - - - - From f3eefc1c403fa003f86b39fd789f230389c9e6ab Mon Sep 17 00:00:00 2001 From: Madzi Date: Thu, 22 Sep 2022 23:29:25 +0200 Subject: [PATCH 03/19] add actions --- .github/workflows/build-linux.yaml | 40 ++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 .github/workflows/build-linux.yaml diff --git a/.github/workflows/build-linux.yaml b/.github/workflows/build-linux.yaml new file mode 100644 index 0000000..ec43608 --- /dev/null +++ b/.github/workflows/build-linux.yaml @@ -0,0 +1,40 @@ +name: Build Linux + +on: + push: + branches: [master, develop] + pull_request: + branches: [master, develop] + + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Setup GraalVM environment + uses: DeLaGuardo/setup-graalvm@master + with: + graalvm: '21.2.0' + java: 'java11' + - name: APT update + run: sudo apt update + - name: Install libraries + run: sudo apt install libasound2-dev libavcodec-dev libavformat-dev libavutil-dev libgl-dev libgtk-3-dev libpango1.0-dev libxtst-dev + - name: Make staging directory + run: mkdir staging + - name: Build JAR with Maven + run: mvn -B package + - name: Copy JAR to staging + run: cp target/*.jar staging + - name: Gluon Build + run: mvn -Pdesktop gluonfx:build gluonfx:package + env: + GRAALVM_HOME: ${{ env.JAVA_HOME }} + - name: Copy native image to staging + run: cp -r target/gluonfx/x86_64-linux/Resistor* staging + - name: Upload + uses: actions/upload-artifact@v2 + with: + name: Package + path: staging From bb3f19ebbfb75f66beb890768c934ae24c0abea5 Mon Sep 17 00:00:00 2001 From: Madzi Date: Thu, 22 Sep 2022 23:32:14 +0200 Subject: [PATCH 04/19] fix java version --- .github/workflows/build-linux.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-linux.yaml b/.github/workflows/build-linux.yaml index ec43608..8f500a5 100644 --- a/.github/workflows/build-linux.yaml +++ b/.github/workflows/build-linux.yaml @@ -15,8 +15,8 @@ jobs: - name: Setup GraalVM environment uses: DeLaGuardo/setup-graalvm@master with: - graalvm: '21.2.0' - java: 'java11' + graalvm: '22.1.0.2' + java: 'java17' - name: APT update run: sudo apt update - name: Install libraries From a2d3ff69dc83ab83bbf419d84afdc8903c53e877 Mon Sep 17 00:00:00 2001 From: Madzi Date: Thu, 22 Sep 2022 23:33:49 +0200 Subject: [PATCH 05/19] use latest version --- .github/workflows/build-linux.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-linux.yaml b/.github/workflows/build-linux.yaml index 8f500a5..ea1e606 100644 --- a/.github/workflows/build-linux.yaml +++ b/.github/workflows/build-linux.yaml @@ -15,7 +15,7 @@ jobs: - name: Setup GraalVM environment uses: DeLaGuardo/setup-graalvm@master with: - graalvm: '22.1.0.2' + graalvm: '22.2.0' java: 'java17' - name: APT update run: sudo apt update From db3827c74cfb3e54e899f32f37abe1e481b559e2 Mon Sep 17 00:00:00 2001 From: Madzi Date: Thu, 22 Sep 2022 23:36:18 +0200 Subject: [PATCH 06/19] remove profile --- .github/workflows/build-linux.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-linux.yaml b/.github/workflows/build-linux.yaml index ea1e606..cdf691b 100644 --- a/.github/workflows/build-linux.yaml +++ b/.github/workflows/build-linux.yaml @@ -28,7 +28,7 @@ jobs: - name: Copy JAR to staging run: cp target/*.jar staging - name: Gluon Build - run: mvn -Pdesktop gluonfx:build gluonfx:package + run: mvn gluonfx:build gluonfx:package env: GRAALVM_HOME: ${{ env.JAVA_HOME }} - name: Copy native image to staging From 226361eeca0d7dab7191d5e0c922420daabfb61e Mon Sep 17 00:00:00 2001 From: Madzi Date: Fri, 23 Sep 2022 08:25:38 +0200 Subject: [PATCH 07/19] Fix build pipeline --- .github/workflows/build-linux.yaml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-linux.yaml b/.github/workflows/build-linux.yaml index cdf691b..deb9f5c 100644 --- a/.github/workflows/build-linux.yaml +++ b/.github/workflows/build-linux.yaml @@ -6,17 +6,18 @@ on: pull_request: branches: [master, develop] - jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: Setup GraalVM environment - uses: DeLaGuardo/setup-graalvm@master - with: - graalvm: '22.2.0' - java: 'java17' + - name: Install SDKMAN + run: curl -s "https://get.sdkman.io" | bash + run: source "$HOME/.sdkman/bin/sdkman-init.sh" + - name: Setup GluonVM environment + run: sdk i java 22.1.0.1.r17-gln + - name: Setup GRAALVM_HOME + run: export GRAALVM_HOME="$HOME/.sdkman/candidates/java/22.1.0.1.r17-gln/" - name: APT update run: sudo apt update - name: Install libraries From 6ec3488b8ca98a57c40552c6dbb4228c7c2a0f6d Mon Sep 17 00:00:00 2001 From: Madzi Date: Fri, 23 Sep 2022 08:27:56 +0200 Subject: [PATCH 08/19] Export SDKMAN installation path --- .github/workflows/build-linux.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-linux.yaml b/.github/workflows/build-linux.yaml index deb9f5c..34de470 100644 --- a/.github/workflows/build-linux.yaml +++ b/.github/workflows/build-linux.yaml @@ -13,6 +13,7 @@ jobs: - uses: actions/checkout@v2 - name: Install SDKMAN run: curl -s "https://get.sdkman.io" | bash + - name: Export SDK installation run: source "$HOME/.sdkman/bin/sdkman-init.sh" - name: Setup GluonVM environment run: sdk i java 22.1.0.1.r17-gln From 4bce1bfb6db962bbd02227935d8eb677bd3f0318 Mon Sep 17 00:00:00 2001 From: Madzi Date: Fri, 23 Sep 2022 08:33:57 +0200 Subject: [PATCH 09/19] Use sdkman action --- .github/workflows/build-linux.yaml | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build-linux.yaml b/.github/workflows/build-linux.yaml index 34de470..60e2b38 100644 --- a/.github/workflows/build-linux.yaml +++ b/.github/workflows/build-linux.yaml @@ -11,14 +11,18 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: Install SDKMAN - run: curl -s "https://get.sdkman.io" | bash - - name: Export SDK installation - run: source "$HOME/.sdkman/bin/sdkman-init.sh" - - name: Setup GluonVM environment - run: sdk i java 22.1.0.1.r17-gln + - uses: sdkman/sdkman-action@master + id: sdkman + with: + candidate: java + version: 22.1.0.1.r17-gln + - uses: actions/setup-java@v1 + id: setup-java + with: + java-version: 17 + jdkFile: ${{ steps.sdkman.outputs.file }} - name: Setup GRAALVM_HOME - run: export GRAALVM_HOME="$HOME/.sdkman/candidates/java/22.1.0.1.r17-gln/" + run: export GRAALVM_HOME="$JAVA_HOME" - name: APT update run: sudo apt update - name: Install libraries From b416727bfe2b8971c8903f7ea80454a013c279d6 Mon Sep 17 00:00:00 2001 From: Madzi Date: Fri, 23 Sep 2022 08:48:54 +0200 Subject: [PATCH 10/19] Fix staging path --- .github/workflows/build-linux.yaml | 2 +- pom.xml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-linux.yaml b/.github/workflows/build-linux.yaml index 60e2b38..9a6b355 100644 --- a/.github/workflows/build-linux.yaml +++ b/.github/workflows/build-linux.yaml @@ -38,7 +38,7 @@ jobs: env: GRAALVM_HOME: ${{ env.JAVA_HOME }} - name: Copy native image to staging - run: cp -r target/gluonfx/x86_64-linux/Resistor* staging + run: cp -r target/gluonfx/x86_64-linux/IFML* staging - name: Upload uses: actions/upload-artifact@v2 with: diff --git a/pom.xml b/pom.xml index 0a3704b..0afd999 100644 --- a/pom.xml +++ b/pom.xml @@ -38,6 +38,7 @@ + ifml3 From 034bc9eb189d4da5c1fe12b8f56e50eeede882f3 Mon Sep 17 00:00:00 2001 From: Madzi Date: Fri, 23 Sep 2022 08:53:03 +0200 Subject: [PATCH 11/19] Add package for windows --- .github/workflows/package-ubuntu.yaml | 42 +++++++++++++++++++ ...{build-linux.yaml => package-windows.yaml} | 0 2 files changed, 42 insertions(+) create mode 100644 .github/workflows/package-ubuntu.yaml rename .github/workflows/{build-linux.yaml => package-windows.yaml} (100%) diff --git a/.github/workflows/package-ubuntu.yaml b/.github/workflows/package-ubuntu.yaml new file mode 100644 index 0000000..9d3a64d --- /dev/null +++ b/.github/workflows/package-ubuntu.yaml @@ -0,0 +1,42 @@ +name: Build Linux + +on: + push: + branches: [master, develop] + pull_request: + branches: [master, develop] + +jobs: + build: + runs-on: windows-latest + steps: + - uses: actions/checkout@v2 + - uses: sdkman/sdkman-action@master + id: sdkman + with: + candidate: java + version: 22.1.0.1.r17-gln + - uses: actions/setup-java@v1 + id: setup-java + with: + java-version: 17 + jdkFile: ${{ steps.sdkman.outputs.file }} + - name: Setup GRAALVM_HOME + run: export GRAALVM_HOME="$JAVA_HOME" + - name: Make staging directory + run: mkdir staging + - name: Build JAR with Maven + run: mvn -B package + - name: Copy JAR to staging + run: cp target/*.jar staging + - name: Gluon Build + run: mvn gluonfx:build gluonfx:package + env: + GRAALVM_HOME: ${{ env.JAVA_HOME }} + - name: Copy native image to staging + run: cp -r target/gluonfx/x86_64-windows/*.exe staging + - name: Upload + uses: actions/upload-artifact@v2 + with: + name: Package + path: staging diff --git a/.github/workflows/build-linux.yaml b/.github/workflows/package-windows.yaml similarity index 100% rename from .github/workflows/build-linux.yaml rename to .github/workflows/package-windows.yaml From 0ff9aefeb87c2a108d27676b3286c22b0ca0919b Mon Sep 17 00:00:00 2001 From: Madzi Date: Fri, 23 Sep 2022 09:00:17 +0200 Subject: [PATCH 12/19] Fix windows package and add builds --- .github/workflows/build-for-ubuntu.yaml | 33 +++++++++++++++++++ .github/workflows/build-for-windows.yaml | 29 ++++++++++++++++ ...e-windows.yaml => package-for-ubuntu.yaml} | 2 +- ...e-ubuntu.yaml => package-for-windows.yaml} | 4 +-- 4 files changed, 65 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/build-for-ubuntu.yaml create mode 100644 .github/workflows/build-for-windows.yaml rename .github/workflows/{package-windows.yaml => package-for-ubuntu.yaml} (98%) rename .github/workflows/{package-ubuntu.yaml => package-for-windows.yaml} (93%) diff --git a/.github/workflows/build-for-ubuntu.yaml b/.github/workflows/build-for-ubuntu.yaml new file mode 100644 index 0000000..5866860 --- /dev/null +++ b/.github/workflows/build-for-ubuntu.yaml @@ -0,0 +1,33 @@ +name: Package for Ubuntu + +on: + push: + branches: [master, develop] + pull_request: + branches: [master, develop] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: sdkman/sdkman-action@master + id: sdkman + with: + candidate: java + version: 22.1.0.1.r17-gln + - uses: actions/setup-java@v1 + id: setup-java + with: + java-version: 17 + jdkFile: ${{ steps.sdkman.outputs.file }} + - name: Setup GRAALVM_HOME + run: export GRAALVM_HOME="$JAVA_HOME" + - name: APT update + run: sudo apt update + - name: Install libraries + run: sudo apt install libasound2-dev libavcodec-dev libavformat-dev libavutil-dev libgl-dev libgtk-3-dev libpango1.0-dev libxtst-dev + - name: Make staging directory + run: mkdir staging + - name: Build JAR with Maven + run: mvn -B install diff --git a/.github/workflows/build-for-windows.yaml b/.github/workflows/build-for-windows.yaml new file mode 100644 index 0000000..a078583 --- /dev/null +++ b/.github/workflows/build-for-windows.yaml @@ -0,0 +1,29 @@ +name: Package for Windows + +on: + push: + branches: [master, develop] + pull_request: + branches: [master, develop] + +jobs: + build: + runs-on: windows-latest + steps: + - uses: actions/checkout@v2 + - uses: sdkman/sdkman-action@master + id: sdkman + with: + candidate: java + version: 22.1.0.1.r17-gln + - uses: actions/setup-java@v1 + id: setup-java + with: + java-version: 17 + jdkFile: ${{ steps.sdkman.outputs.file }} + - name: Setup GRAALVM_HOME + run: set GRAALVM_HOME=$JAVA_HOME + - name: Make staging directory + run: mkdir staging + - name: Build JAR with Maven + run: mvn -B install diff --git a/.github/workflows/package-windows.yaml b/.github/workflows/package-for-ubuntu.yaml similarity index 98% rename from .github/workflows/package-windows.yaml rename to .github/workflows/package-for-ubuntu.yaml index 9a6b355..8d7234c 100644 --- a/.github/workflows/package-windows.yaml +++ b/.github/workflows/package-for-ubuntu.yaml @@ -1,4 +1,4 @@ -name: Build Linux +name: Package for Ubuntu on: push: diff --git a/.github/workflows/package-ubuntu.yaml b/.github/workflows/package-for-windows.yaml similarity index 93% rename from .github/workflows/package-ubuntu.yaml rename to .github/workflows/package-for-windows.yaml index 9d3a64d..aa9214e 100644 --- a/.github/workflows/package-ubuntu.yaml +++ b/.github/workflows/package-for-windows.yaml @@ -1,4 +1,4 @@ -name: Build Linux +name: Package for Windows on: push: @@ -22,7 +22,7 @@ jobs: java-version: 17 jdkFile: ${{ steps.sdkman.outputs.file }} - name: Setup GRAALVM_HOME - run: export GRAALVM_HOME="$JAVA_HOME" + run: set GRAALVM_HOME=$JAVA_HOME - name: Make staging directory run: mkdir staging - name: Build JAR with Maven From 353780b9a09c1befcf868cb08c1dc7ee77895302 Mon Sep 17 00:00:00 2001 From: Madzi Date: Fri, 23 Sep 2022 09:06:41 +0200 Subject: [PATCH 13/19] Fix workflows names --- .github/workflows/build-for-ubuntu.yaml | 2 +- .github/workflows/build-for-windows.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-for-ubuntu.yaml b/.github/workflows/build-for-ubuntu.yaml index 5866860..6cc0181 100644 --- a/.github/workflows/build-for-ubuntu.yaml +++ b/.github/workflows/build-for-ubuntu.yaml @@ -1,4 +1,4 @@ -name: Package for Ubuntu +name: Build for Ubuntu on: push: diff --git a/.github/workflows/build-for-windows.yaml b/.github/workflows/build-for-windows.yaml index a078583..c70263d 100644 --- a/.github/workflows/build-for-windows.yaml +++ b/.github/workflows/build-for-windows.yaml @@ -1,4 +1,4 @@ -name: Package for Windows +name: Build for Windows on: push: From d549127462eec58196b8c868652bcb7eca54e162 Mon Sep 17 00:00:00 2001 From: Madzi Date: Fri, 23 Sep 2022 16:38:15 +0200 Subject: [PATCH 14/19] prepare for documentation site --- docs/index.adoc | 1 - pom.xml | 77 +++++++++++++++++++++++++++++++-- src/site/asciidoc/ifml3.adoc | 1 + src/site/ru/asciidoc/ifml3.adoc | 1 + src/site/site.xml | 13 ++++++ 5 files changed, 89 insertions(+), 4 deletions(-) delete mode 100644 docs/index.adoc create mode 100644 src/site/asciidoc/ifml3.adoc create mode 100644 src/site/ru/asciidoc/ifml3.adoc create mode 100644 src/site/site.xml diff --git a/docs/index.adoc b/docs/index.adoc deleted file mode 100644 index d260c53..0000000 --- a/docs/index.adoc +++ /dev/null @@ -1 +0,0 @@ -= ЯРИЛ (Язык Разметки Интерактивной Литературы) v 3.0 diff --git a/pom.xml b/pom.xml index 0afd999..554a592 100644 --- a/pom.xml +++ b/pom.xml @@ -34,6 +34,16 @@ javafx-controls 18.0.1 + + org.jruby + jruby + 9.3.8.0 + + + org.asciidoctor + asciidoctorj + 2.5.6 + @@ -46,6 +56,26 @@ maven-compiler-plugin 3.10.1 + + org.apache.maven.plugins + maven-surefire-plugin + 3.0.0-M7 + + + org.apache.maven.plugins + maven-failsafe-plugin + 3.0.0-M7 + + + org.apache.maven.plugins + maven-site-plugin + 3.12.1 + + + org.asciidoctor + asciidoctor-maven-plugin + 2.2.2 + org.openjfx javafx-maven-plugin @@ -136,7 +166,46 @@ org.apache.maven.plugins maven-site-plugin - 4.0.0-M3 + + true + true + false + en,ru + ${encoding} + ${encoding} + + + asciidoctor-diagram + + + font + rouge + 3 + + + + + + org.asciidoctor + asciidoctor-maven-plugin + 2.2.2 + + + org.jruby + jruby + 9.3.8.0 + + + org.asciidoctor + asciidoctorj + 2.5.6 + + + org.asciidoctor + asciidoctorj-diagram + 2.2.3 + + @@ -164,18 +233,20 @@ ifml3 - IFML3 - file:///home/de/Workspace/github/ifml3/target + scm:git:git@github.com:IFML2/ifml3.git + github https://github.com/IFML2/ifml3/issues + github https://github.com/IFML2/ifml3/actions + scm:git:https://github.com/IFML2/ifml3.git scm:git:git@github.com:IFML2/ifml3.git diff --git a/src/site/asciidoc/ifml3.adoc b/src/site/asciidoc/ifml3.adoc new file mode 100644 index 0000000..ff33635 --- /dev/null +++ b/src/site/asciidoc/ifml3.adoc @@ -0,0 +1 @@ += Interactive Fiction Markup Language (version 3.0) diff --git a/src/site/ru/asciidoc/ifml3.adoc b/src/site/ru/asciidoc/ifml3.adoc new file mode 100644 index 0000000..3fff31d --- /dev/null +++ b/src/site/ru/asciidoc/ifml3.adoc @@ -0,0 +1 @@ += Язык Разметки Интерактивной Литературы (верисия 3.0) diff --git a/src/site/site.xml b/src/site/site.xml new file mode 100644 index 0000000..7603f62 --- /dev/null +++ b/src/site/site.xml @@ -0,0 +1,13 @@ + + + + + + + + + org.apache.maven.skins + maven-fluido-skin + 1.11.1 + + From 7356725f119c3a63385d477aabb1f67f274c1627 Mon Sep 17 00:00:00 2001 From: Madzi Date: Fri, 23 Sep 2022 16:44:22 +0200 Subject: [PATCH 15/19] fix branch name for publishing --- pom.xml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pom.xml b/pom.xml index 554a592..6bc3adb 100644 --- a/pom.xml +++ b/pom.xml @@ -163,6 +163,14 @@ + + org.apache.maven.plugins + maven-scm-publish-plugin + 3.1.0 + + gh-pages + + org.apache.maven.plugins maven-site-plugin From 33df88fa7a03a1704df02f4443d173b9db614aa0 Mon Sep 17 00:00:00 2001 From: Madzi Date: Fri, 17 Feb 2023 18:22:06 +0100 Subject: [PATCH 16/19] Add base schema --- pom.xml | 18 +++++ .../java/ifml3/api/ComponentConnector.java | 11 +++ .../api/internal/BaseComponentConnector.java | 11 +++ .../ifml3/api/internal/BaseSubscriber.java | 37 +++++++++ src/main/java/ifml3/app/Ifml3App.java | 33 +++++++- src/main/java/ifml3/app/view/MainView.java | 10 ++- .../java/ifml3/app/view/ui/UIComponent.java | 8 ++ .../app/view/ui/internal/PlayerComponent.java | 72 +++++++++++++++++ src/main/java/ifml3/engine/Engine.java | 8 ++ src/main/java/ifml3/engine/EngineCommand.java | 10 +++ src/main/java/ifml3/engine/EngineMessage.java | 7 ++ .../ifml3/engine/internal/SimpleEngine.java | 32 ++++++++ src/main/java/ifml3/lexer/Dictionary.java | 11 +++ src/main/java/ifml3/lexer/Lexer.java | 14 ++++ src/main/java/ifml3/lexer/Phrase.java | 5 ++ .../java/ifml3/lexer/dictionary/Word.java | 12 +++ .../lexer/dictionary/internal/NounWord.java | 11 +++ .../dictionary/internal/UnknownWord.java | 11 +++ .../lexer/dictionary/internal/VerbWord.java | 11 +++ .../lexer/internal/SimpleDictionary.java | 51 ++++++++++++ .../ifml3/lexer/internal/SimpleLexer.java | 80 +++++++++++++++++++ src/main/java/ifml3/lexer/package-info.java | 4 + src/main/java/ifml3/story/Story.java | 32 -------- src/main/java/ifml3/story/package-info.java | 4 - src/main/java/ifml3/ui/TextSanitizer.java | 6 ++ src/main/java/ifml3/ui/UserCommand.java | 7 ++ src/main/java/ifml3/ui/UserInterface.java | 8 ++ src/main/java/ifml3/ui/UserMessage.java | 7 ++ .../ifml3/ui/internal/UserTextSanitizer.java | 11 +++ src/main/java/module-info.java | 3 + .../ifml3/app/i18n/ResourceBundleTest.java | 2 +- src/test/java/ifml3/ui/TextSanitizerTest.java | 25 ++++++ 32 files changed, 533 insertions(+), 39 deletions(-) create mode 100644 src/main/java/ifml3/api/ComponentConnector.java create mode 100644 src/main/java/ifml3/api/internal/BaseComponentConnector.java create mode 100644 src/main/java/ifml3/api/internal/BaseSubscriber.java create mode 100644 src/main/java/ifml3/app/view/ui/UIComponent.java create mode 100644 src/main/java/ifml3/app/view/ui/internal/PlayerComponent.java create mode 100644 src/main/java/ifml3/engine/Engine.java create mode 100644 src/main/java/ifml3/engine/EngineCommand.java create mode 100644 src/main/java/ifml3/engine/EngineMessage.java create mode 100644 src/main/java/ifml3/engine/internal/SimpleEngine.java create mode 100644 src/main/java/ifml3/lexer/Dictionary.java create mode 100644 src/main/java/ifml3/lexer/Lexer.java create mode 100644 src/main/java/ifml3/lexer/Phrase.java create mode 100644 src/main/java/ifml3/lexer/dictionary/Word.java create mode 100644 src/main/java/ifml3/lexer/dictionary/internal/NounWord.java create mode 100644 src/main/java/ifml3/lexer/dictionary/internal/UnknownWord.java create mode 100644 src/main/java/ifml3/lexer/dictionary/internal/VerbWord.java create mode 100644 src/main/java/ifml3/lexer/internal/SimpleDictionary.java create mode 100644 src/main/java/ifml3/lexer/internal/SimpleLexer.java create mode 100644 src/main/java/ifml3/lexer/package-info.java delete mode 100644 src/main/java/ifml3/story/Story.java delete mode 100644 src/main/java/ifml3/story/package-info.java create mode 100644 src/main/java/ifml3/ui/TextSanitizer.java create mode 100644 src/main/java/ifml3/ui/UserCommand.java create mode 100644 src/main/java/ifml3/ui/UserInterface.java create mode 100644 src/main/java/ifml3/ui/UserMessage.java create mode 100644 src/main/java/ifml3/ui/internal/UserTextSanitizer.java create mode 100644 src/test/java/ifml3/ui/TextSanitizerTest.java diff --git a/pom.xml b/pom.xml index 3b31928..7c78226 100644 --- a/pom.xml +++ b/pom.xml @@ -35,6 +35,16 @@ javafx-controls 18.0.1 + + org.slf4j + slf4j-api + 2.0.6 + + + org.slf4j + slf4j-simple + 2.0.6 + org.jruby jruby @@ -116,6 +126,14 @@ org.openjfx javafx-controls + + org.slf4j + slf4j-api + + + org.slf4j + slf4j-simple + diff --git a/src/main/java/ifml3/api/ComponentConnector.java b/src/main/java/ifml3/api/ComponentConnector.java new file mode 100644 index 0000000..e712bee --- /dev/null +++ b/src/main/java/ifml3/api/ComponentConnector.java @@ -0,0 +1,11 @@ +package ifml3.api; + +import java.util.concurrent.Flow.Publisher; +import java.util.concurrent.Flow.Subscriber; + +public interface ComponentConnector { + + Subscriber subscriber(); + + Publisher publisher(); +} diff --git a/src/main/java/ifml3/api/internal/BaseComponentConnector.java b/src/main/java/ifml3/api/internal/BaseComponentConnector.java new file mode 100644 index 0000000..25f6081 --- /dev/null +++ b/src/main/java/ifml3/api/internal/BaseComponentConnector.java @@ -0,0 +1,11 @@ +package ifml3.api.internal; + +import ifml3.api.ComponentConnector; +import java.util.concurrent.Flow.Publisher; +import java.util.concurrent.Flow.Subscriber; + +public record BaseComponentConnector( + Subscriber subscriber, + Publisher publisher +) implements ComponentConnector { +} diff --git a/src/main/java/ifml3/api/internal/BaseSubscriber.java b/src/main/java/ifml3/api/internal/BaseSubscriber.java new file mode 100644 index 0000000..495dcbf --- /dev/null +++ b/src/main/java/ifml3/api/internal/BaseSubscriber.java @@ -0,0 +1,37 @@ +package ifml3.api.internal; + +import java.util.concurrent.Flow.Subscriber; +import java.util.concurrent.Flow.Subscription; +import java.util.function.Consumer; + +public class BaseSubscriber implements Subscriber { + + private final Consumer consumer; + + private Subscription subscription; + + public BaseSubscriber(final Consumer consumer) { + this.consumer = consumer; + } + + @Override + public void onSubscribe(final Subscription subscription) { + this.subscription = subscription; + this.subscription.request(1L); + } + + @Override + public void onNext(final T item) { + consumer.accept(item); + subscription.request(1L); + } + + @Override + public void onError(final Throwable throwable) { + throw new IllegalStateException(throwable); + } + + @Override + public void onComplete() { + } +} diff --git a/src/main/java/ifml3/app/Ifml3App.java b/src/main/java/ifml3/app/Ifml3App.java index cb73d92..048aa79 100644 --- a/src/main/java/ifml3/app/Ifml3App.java +++ b/src/main/java/ifml3/app/Ifml3App.java @@ -5,23 +5,54 @@ import ifml3.app.i18n.Translation; import ifml3.app.view.MainView; import ifml3.app.view.View; +import ifml3.app.view.ui.internal.PlayerComponent; +import ifml3.engine.Engine; +import ifml3.engine.internal.SimpleEngine; +import ifml3.lexer.Lexer; +import ifml3.lexer.internal.SimpleLexer; import java.util.ResourceBundle; import javafx.application.Application; import javafx.stage.Stage; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class Ifml3App extends Application { + private static final Logger logger = LoggerFactory.getLogger(Ifml3App.class); + private Translation translation; private View view; + private PlayerComponent player; + private Lexer lexer; + private Engine engine; @Override public void init() { + logger.info("Initialization..."); this.translation = new AppTranslation(ResourceBundle.getBundle("lang/ifml3")); - this.view = new MainView(translation); + final var mainView = new MainView(translation); + this.view = mainView; + this.player = mainView.player(); + this.lexer = new SimpleLexer(); + this.engine = new SimpleEngine(); + connectComponents(); + } + + private void connectComponents() { + logger.info("Connect components"); + final var playerConnector = player.uiConnector(); + final var uiConnector = lexer.uiConnector(); + final var engineConnector = lexer.engineConnector(); + final var lexerConnector = engine.lexerConnector(); + playerConnector.publisher().subscribe(uiConnector.subscriber()); + uiConnector.publisher().subscribe(playerConnector.subscriber()); + lexerConnector.publisher().subscribe(engineConnector.subscriber()); + engineConnector.publisher().subscribe(lexerConnector.subscriber()); } @Override public void start(final Stage stage) throws Exception { + logger.info("Start application"); stage.setScene(view.scene()); stage.setTitle(translation.message(AppMessage.APP_TITLE)); stage.show(); diff --git a/src/main/java/ifml3/app/view/MainView.java b/src/main/java/ifml3/app/view/MainView.java index 4e831a7..3bf7d07 100644 --- a/src/main/java/ifml3/app/view/MainView.java +++ b/src/main/java/ifml3/app/view/MainView.java @@ -1,7 +1,9 @@ package ifml3.app.view; +import ifml3.api.ComponentConnector; import ifml3.app.i18n.AppMessage; import ifml3.app.i18n.Translation; +import ifml3.app.view.ui.internal.PlayerComponent; import javafx.scene.Scene; import javafx.scene.control.ComboBox; import javafx.scene.control.Label; @@ -14,10 +16,12 @@ public class MainView implements View { private final Translation translation; private final Scene scene; + private final PlayerComponent player; public MainView(final Translation translation) { this.translation = translation; - final var pane = new BorderPane(label("center"), menuBar(), label("right"), inputLine(), treeView()); + this.player = new PlayerComponent(); + final var pane = new BorderPane(player.get(), menuBar(), label("right"), inputLine(), treeView()); scene = new Scene(pane, 800.0, 600.0); } @@ -26,6 +30,10 @@ public Scene scene() { return scene; } + public PlayerComponent player() { + return player; + } + private Label label(final String text) { return new Label(text); } diff --git a/src/main/java/ifml3/app/view/ui/UIComponent.java b/src/main/java/ifml3/app/view/ui/UIComponent.java new file mode 100644 index 0000000..519729e --- /dev/null +++ b/src/main/java/ifml3/app/view/ui/UIComponent.java @@ -0,0 +1,8 @@ +package ifml3.app.view.ui; + +import javafx.scene.Parent; + +public interface UIComponent { + + Parent get(); +} diff --git a/src/main/java/ifml3/app/view/ui/internal/PlayerComponent.java b/src/main/java/ifml3/app/view/ui/internal/PlayerComponent.java new file mode 100644 index 0000000..1d8cf3f --- /dev/null +++ b/src/main/java/ifml3/app/view/ui/internal/PlayerComponent.java @@ -0,0 +1,72 @@ +package ifml3.app.view.ui.internal; + +import ifml3.api.ComponentConnector; +import ifml3.api.internal.BaseComponentConnector; +import ifml3.api.internal.BaseSubscriber; +import ifml3.app.view.ui.UIComponent; +import ifml3.ui.TextSanitizer; +import ifml3.ui.UserCommand; +import ifml3.ui.UserInterface; +import ifml3.ui.UserMessage; +import ifml3.ui.internal.UserTextSanitizer; +import java.util.concurrent.Flow.Subscriber; +import java.util.concurrent.SubmissionPublisher; +import javafx.event.ActionEvent; +import javafx.scene.Parent; +import javafx.scene.control.TextArea; +import javafx.scene.control.TextField; +import javafx.scene.layout.VBox; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class PlayerComponent implements UIComponent, UserInterface { + + private static final Logger logger = LoggerFactory.getLogger(PlayerComponent.class); + + private final SubmissionPublisher publisher; + private final Subscriber subscriber; + private final TextSanitizer sanitizer; + private final ComponentConnector connector; + private final VBox vBox; + private final TextArea textArea; + private final TextField textField; + + public PlayerComponent() { + // @todo at least sanitizer should be as dependency + this.sanitizer = new UserTextSanitizer(); + this.publisher = new SubmissionPublisher<>(); + this.textArea = new TextArea(); + this.textArea.setEditable(false); + this.textArea.setPrefRowCount(1_000); + this.textField = new TextField(); + this.textField.setOnAction(this::processCommand); + this.vBox = new VBox(textArea, textField); + this.subscriber = new BaseSubscriber<>(this::processMessage); + this.connector = new BaseComponentConnector<>(subscriber, publisher); + } + + @Override + public Parent get() { + return vBox; + } + + @Override + public ComponentConnector uiConnector() { + return connector; + } + + private void processCommand(final ActionEvent event) { + final var text = textField.getText(); + logger.info("Input from user: '{}'", text); + textField.setText(""); + textArea.appendText("> " + text + "\n"); + final var input = sanitizer.sanitize(text); + // @todo preprocessing needed + publisher.submit(() -> input); + } + + private void processMessage(final UserMessage message) { + logger.info("Get message for user: {}", message); + textArea.appendText("\n" + message.message() + "\n\n"); + } +} diff --git a/src/main/java/ifml3/engine/Engine.java b/src/main/java/ifml3/engine/Engine.java new file mode 100644 index 0000000..bc4fe31 --- /dev/null +++ b/src/main/java/ifml3/engine/Engine.java @@ -0,0 +1,8 @@ +package ifml3.engine; + +import ifml3.api.ComponentConnector; + +public interface Engine { + + ComponentConnector lexerConnector(); +} diff --git a/src/main/java/ifml3/engine/EngineCommand.java b/src/main/java/ifml3/engine/EngineCommand.java new file mode 100644 index 0000000..7dd545f --- /dev/null +++ b/src/main/java/ifml3/engine/EngineCommand.java @@ -0,0 +1,10 @@ +package ifml3.engine; + +import ifml3.lexer.Phrase; +import java.util.Collection; + +@FunctionalInterface +public interface EngineCommand { + + Collection phrases(); +} diff --git a/src/main/java/ifml3/engine/EngineMessage.java b/src/main/java/ifml3/engine/EngineMessage.java new file mode 100644 index 0000000..4a1e2f2 --- /dev/null +++ b/src/main/java/ifml3/engine/EngineMessage.java @@ -0,0 +1,7 @@ +package ifml3.engine; + +@FunctionalInterface +public interface EngineMessage { + + String message(); +} diff --git a/src/main/java/ifml3/engine/internal/SimpleEngine.java b/src/main/java/ifml3/engine/internal/SimpleEngine.java new file mode 100644 index 0000000..ca611e0 --- /dev/null +++ b/src/main/java/ifml3/engine/internal/SimpleEngine.java @@ -0,0 +1,32 @@ +package ifml3.engine.internal; + +import ifml3.api.ComponentConnector; +import ifml3.api.internal.BaseComponentConnector; +import ifml3.api.internal.BaseSubscriber; +import ifml3.engine.Engine; +import ifml3.engine.EngineCommand; +import ifml3.engine.EngineMessage; +import java.util.concurrent.Flow.Subscriber; +import java.util.concurrent.SubmissionPublisher; + +public class SimpleEngine implements Engine { + + private final SubmissionPublisher publisher; + private final Subscriber subscriber; + private final ComponentConnector connector; + + public SimpleEngine() { + publisher = new SubmissionPublisher(); + subscriber = new BaseSubscriber<>(this::processCommand); + connector = new BaseComponentConnector<>(subscriber, publisher); + } + + @Override + public ComponentConnector lexerConnector() { + return connector; + } + + private void processCommand(final EngineCommand command) { + publisher.submit("engine: непонятная команда."); + } +} diff --git a/src/main/java/ifml3/lexer/Dictionary.java b/src/main/java/ifml3/lexer/Dictionary.java new file mode 100644 index 0000000..8f3d658 --- /dev/null +++ b/src/main/java/ifml3/lexer/Dictionary.java @@ -0,0 +1,11 @@ +package ifml3.lexer; + +import ifml3.lexer.dictionary.Word; +import java.util.Set; + +public interface Dictionary { + + Set find(String text); + + Set findOrAdd(String text); +} diff --git a/src/main/java/ifml3/lexer/Lexer.java b/src/main/java/ifml3/lexer/Lexer.java new file mode 100644 index 0000000..7600974 --- /dev/null +++ b/src/main/java/ifml3/lexer/Lexer.java @@ -0,0 +1,14 @@ +package ifml3.lexer; + +import ifml3.api.ComponentConnector; +import ifml3.engine.EngineCommand; +import ifml3.engine.EngineMessage; +import ifml3.ui.UserCommand; +import ifml3.ui.UserMessage; + +public interface Lexer { + + ComponentConnector uiConnector(); + + ComponentConnector engineConnector(); +} diff --git a/src/main/java/ifml3/lexer/Phrase.java b/src/main/java/ifml3/lexer/Phrase.java new file mode 100644 index 0000000..bb1b40b --- /dev/null +++ b/src/main/java/ifml3/lexer/Phrase.java @@ -0,0 +1,5 @@ +package ifml3.lexer; + +public interface Phrase { + +} diff --git a/src/main/java/ifml3/lexer/dictionary/Word.java b/src/main/java/ifml3/lexer/dictionary/Word.java new file mode 100644 index 0000000..bd94e57 --- /dev/null +++ b/src/main/java/ifml3/lexer/dictionary/Word.java @@ -0,0 +1,12 @@ +package ifml3.lexer.dictionary; + +public interface Word { + + String text(); + + Word initForm(); + + default boolean isInitForm() { + return this == initForm(); + } +} diff --git a/src/main/java/ifml3/lexer/dictionary/internal/NounWord.java b/src/main/java/ifml3/lexer/dictionary/internal/NounWord.java new file mode 100644 index 0000000..dd1916c --- /dev/null +++ b/src/main/java/ifml3/lexer/dictionary/internal/NounWord.java @@ -0,0 +1,11 @@ +package ifml3.lexer.dictionary.internal; + +import ifml3.lexer.dictionary.Word; + +public record NounWord(String text) implements Word { + + @Override + public Word initForm() { + return this; + } +} diff --git a/src/main/java/ifml3/lexer/dictionary/internal/UnknownWord.java b/src/main/java/ifml3/lexer/dictionary/internal/UnknownWord.java new file mode 100644 index 0000000..619eba8 --- /dev/null +++ b/src/main/java/ifml3/lexer/dictionary/internal/UnknownWord.java @@ -0,0 +1,11 @@ +package ifml3.lexer.dictionary.internal; + +import ifml3.lexer.dictionary.Word; + +public record UnknownWord(String text) implements Word { + + @Override + public Word initForm() { + return this; + } +} diff --git a/src/main/java/ifml3/lexer/dictionary/internal/VerbWord.java b/src/main/java/ifml3/lexer/dictionary/internal/VerbWord.java new file mode 100644 index 0000000..009c2e9 --- /dev/null +++ b/src/main/java/ifml3/lexer/dictionary/internal/VerbWord.java @@ -0,0 +1,11 @@ +package ifml3.lexer.dictionary.internal; + +import ifml3.lexer.dictionary.Word; + +public record VerbWord(String text) implements Word { + + @Override + public Word initForm() { + return this; + } +} diff --git a/src/main/java/ifml3/lexer/internal/SimpleDictionary.java b/src/main/java/ifml3/lexer/internal/SimpleDictionary.java new file mode 100644 index 0000000..d54fec8 --- /dev/null +++ b/src/main/java/ifml3/lexer/internal/SimpleDictionary.java @@ -0,0 +1,51 @@ +package ifml3.lexer.internal; + +import ifml3.lexer.Dictionary; +import ifml3.lexer.dictionary.Word; +import ifml3.lexer.dictionary.internal.UnknownWord; +import java.util.Collections; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class SimpleDictionary implements Dictionary { + + private static final Logger logger = LoggerFactory.getLogger(SimpleDictionary.class); + + private Map> words; + + public SimpleDictionary() { + this(new ConcurrentHashMap<>()); + } + + public SimpleDictionary(Map> words) { + this.words = words; + } + + @Override + public Set find(final String text) { + logger.info("Try to find word: {}", text); + if (words.containsKey(text)) { + return words.get(text); + } + logger.info("not found"); + return Collections.emptySet(); + } + + @Override + public Set findOrAdd(final String text) { + logger.info("Try to find word: {}", text); + if (words.containsKey(text)) { + return words.get(text); + } + logger.info("now found will be added as unkown word: {}", text); + final var set = new HashSet(); + final var word = new UnknownWord(text); + set.add(word); + words.put(text, set); + return set; + } +} diff --git a/src/main/java/ifml3/lexer/internal/SimpleLexer.java b/src/main/java/ifml3/lexer/internal/SimpleLexer.java new file mode 100644 index 0000000..1c94f4f --- /dev/null +++ b/src/main/java/ifml3/lexer/internal/SimpleLexer.java @@ -0,0 +1,80 @@ +package ifml3.lexer.internal; + +import ifml3.api.ComponentConnector; +import ifml3.api.internal.BaseComponentConnector; +import ifml3.api.internal.BaseSubscriber; +import ifml3.engine.EngineCommand; +import ifml3.engine.EngineMessage; +import ifml3.lexer.Dictionary; +import ifml3.lexer.Lexer; +import ifml3.lexer.Phrase; +import ifml3.lexer.dictionary.Word; +import ifml3.ui.UserCommand; +import ifml3.ui.UserMessage; +import java.util.Collection; +import java.util.Collections; +import java.util.Set; +import java.util.concurrent.Flow.Subscriber; +import java.util.concurrent.SubmissionPublisher; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class SimpleLexer implements Lexer { + + private static final Logger logger = LoggerFactory.getLogger(SimpleLexer.class); + + private final Dictionary dictionary; + private final SubmissionPublisher uiPublisher; + private final Subscriber uiSubscriber; + private final ComponentConnector uiConnector; + private final SubmissionPublisher enginePublisher; + private final Subscriber engineSubscriber; + private final ComponentConnector engineConnector; + + public SimpleLexer() { + this.dictionary = new SimpleDictionary(); + this.uiPublisher = new SubmissionPublisher<>(); + this.uiSubscriber = new BaseSubscriber<>(this::processUserCommand); + this.uiConnector = new BaseComponentConnector<>(uiSubscriber, uiPublisher); + this.enginePublisher = new SubmissionPublisher<>(); + this.engineSubscriber = new BaseSubscriber<>(this::processEngineMessage); + this.engineConnector = new BaseComponentConnector<>(engineSubscriber, enginePublisher); + } + + @Override + public ComponentConnector uiConnector() { + return uiConnector; + } + + @Override + public ComponentConnector engineConnector() { + return engineConnector; + } + + private void processUserCommand(final UserCommand command) { + logger.info("Got command from user: {}", command); + final var text = command.command(); + final var wordSets = Stream.of(text.split(" ")) + .map(dictionary::find) + .collect(Collectors.toList()); + final var phrases = toPhrases(wordSets); + if (null == phrases || phrases.isEmpty()) { + uiPublisher.submit(() -> "мне не понятно: " + text); + } else { + enginePublisher.submit(() -> phrases); + } + } + + private void processEngineMessage(final EngineMessage message) { + logger.info("Got message from engine: {}", message); + // @todo: process possible templates + uiPublisher.submit(() -> message.message()); + } + + private Collection toPhrases(final Collection> wordSets) { + // @todo: logic to build phrases + return Collections.emptyList(); + } +} diff --git a/src/main/java/ifml3/lexer/package-info.java b/src/main/java/ifml3/lexer/package-info.java new file mode 100644 index 0000000..89281e3 --- /dev/null +++ b/src/main/java/ifml3/lexer/package-info.java @@ -0,0 +1,4 @@ +/** + * The dictionary. + */ +package ifml3.lexer.dictionary; diff --git a/src/main/java/ifml3/story/Story.java b/src/main/java/ifml3/story/Story.java deleted file mode 100644 index 745611f..0000000 --- a/src/main/java/ifml3/story/Story.java +++ /dev/null @@ -1,32 +0,0 @@ -package ifml3.story; - -public class Story { - - private String name; - - private Story(Builder builder) { - this.name = builder.name; - } - - public String name() { - return name; - } - - public static Builder buidler() { - return new Builder(); - } - - public static class Builder { - - private String name; - - public Builder name(final String name) { - this.name = name; - return this; - } - - public Story build() { - return new Story(this); - } - } -} diff --git a/src/main/java/ifml3/story/package-info.java b/src/main/java/ifml3/story/package-info.java deleted file mode 100644 index 01021c9..0000000 --- a/src/main/java/ifml3/story/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * Story classes. - */ -package ifml3.story; diff --git a/src/main/java/ifml3/ui/TextSanitizer.java b/src/main/java/ifml3/ui/TextSanitizer.java new file mode 100644 index 0000000..f634cab --- /dev/null +++ b/src/main/java/ifml3/ui/TextSanitizer.java @@ -0,0 +1,6 @@ +package ifml3.ui; + +public interface TextSanitizer { + + String sanitize(String text); +} diff --git a/src/main/java/ifml3/ui/UserCommand.java b/src/main/java/ifml3/ui/UserCommand.java new file mode 100644 index 0000000..31b7a93 --- /dev/null +++ b/src/main/java/ifml3/ui/UserCommand.java @@ -0,0 +1,7 @@ +package ifml3.ui; + +@FunctionalInterface +public interface UserCommand { + + String command(); +} diff --git a/src/main/java/ifml3/ui/UserInterface.java b/src/main/java/ifml3/ui/UserInterface.java new file mode 100644 index 0000000..202fd2f --- /dev/null +++ b/src/main/java/ifml3/ui/UserInterface.java @@ -0,0 +1,8 @@ +package ifml3.ui; + +import ifml3.api.ComponentConnector; + +public interface UserInterface { + + ComponentConnector uiConnector(); +} diff --git a/src/main/java/ifml3/ui/UserMessage.java b/src/main/java/ifml3/ui/UserMessage.java new file mode 100644 index 0000000..083c0f2 --- /dev/null +++ b/src/main/java/ifml3/ui/UserMessage.java @@ -0,0 +1,7 @@ +package ifml3.ui; + +@FunctionalInterface +public interface UserMessage { + + String message(); +} diff --git a/src/main/java/ifml3/ui/internal/UserTextSanitizer.java b/src/main/java/ifml3/ui/internal/UserTextSanitizer.java new file mode 100644 index 0000000..8cf2264 --- /dev/null +++ b/src/main/java/ifml3/ui/internal/UserTextSanitizer.java @@ -0,0 +1,11 @@ +package ifml3.ui.internal; + +import ifml3.ui.TextSanitizer; + +public class UserTextSanitizer implements TextSanitizer { + + @Override + public String sanitize(final String text) { + return text.replaceAll("\\.", ""); + } +} diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java index 98e9597..1c7c298 100644 --- a/src/main/java/module-info.java +++ b/src/main/java/module-info.java @@ -1,5 +1,8 @@ module ifml3.app { requires javafx.controls; + requires java.base; + requires org.slf4j; + requires org.slf4j.simple; exports ifml3.app; } diff --git a/src/test/java/ifml3/app/i18n/ResourceBundleTest.java b/src/test/java/ifml3/app/i18n/ResourceBundleTest.java index 756cd60..797892d 100644 --- a/src/test/java/ifml3/app/i18n/ResourceBundleTest.java +++ b/src/test/java/ifml3/app/i18n/ResourceBundleTest.java @@ -2,8 +2,8 @@ import java.util.ResourceBundle; import java.util.stream.Stream; -import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/src/test/java/ifml3/ui/TextSanitizerTest.java b/src/test/java/ifml3/ui/TextSanitizerTest.java new file mode 100644 index 0000000..6e6e7b5 --- /dev/null +++ b/src/test/java/ifml3/ui/TextSanitizerTest.java @@ -0,0 +1,25 @@ +package ifml3.ui; + +import ifml3.ui.internal.UserTextSanitizer; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +@DisplayName("Text Sanitizer") +public class TextSanitizerTest { + + @Test + @DisplayName("can process simple text") + public void testSimpleText() { + final var sanitizer = new UserTextSanitizer(); + Assertions.assertEquals("просто текст", sanitizer.sanitize("просто текст")); + } + + @Test + @DisplayName("can remove dots") + public void testRemoveDots() { + final var sanitizer = new UserTextSanitizer(); + Assertions.assertEquals("ну, не очень так", sanitizer.sanitize("ну, не очень... так.")); + } +} From 32110f674cd2b8e9ccce8a57dd63e714bbb5a750 Mon Sep 17 00:00:00 2001 From: Dmitry Eliseev Date: Wed, 14 May 2025 21:51:10 +0200 Subject: [PATCH 17/19] Change structure Signed-off-by:Dmitry Eliseev --- .mvn/wrapper/maven-wrapper.properties | 19 ++ mvnw | 259 ++++++++++++++++++ mvnw.cmd | 149 ++++++++++ pom.xml | 79 ++++-- .../java/ifml3/api/ComponentConnector.java | 11 - .../api/connector/ComponentConnector.java | 16 ++ .../api/connector/engine/EngineMessage.java | 5 + .../internal/BaseComponentConnector.java | 4 +- .../internal/BaseSubscriber.java | 2 +- .../ifml3/api/connector/ui/UIMessage.java | 5 + src/main/java/ifml3/api/engine/Engine.java | 8 + .../ifml3/api/engine/component/Component.java | 8 + .../java/ifml3/api/engine/entity/Entity.java | 44 +++ .../ifml3/api/engine/entity/EntityPool.java | 30 ++ .../ifml3/api/engine/internal/BaseEngine.java | 34 +++ .../java/ifml3/api/engine/system/System.java | 9 + src/main/java/ifml3/api/i18n/I18N.java | 20 ++ .../i18n/internal/AppI18N.java} | 7 +- .../java/ifml3/api/i18n/package-info.java | 4 + src/main/java/ifml3/app/Ifml3App.java | 7 +- src/main/java/ifml3/app/i18n/AppMessage.java | 2 +- src/main/java/ifml3/app/i18n/Translation.java | 13 - src/main/java/ifml3/app/view/MainView.java | 8 +- .../app/view/ui/internal/PlayerComponent.java | 7 +- src/main/java/ifml3/engine/Engine.java | 2 +- .../ifml3/engine/internal/SimpleEngine.java | 7 +- src/main/java/ifml3/infra/package-info.java | 4 + src/main/java/ifml3/lexer/Lexer.java | 2 +- .../ifml3/lexer/internal/SimpleLexer.java | 6 +- src/main/java/ifml3/ui/UserInterface.java | 2 +- src/main/java/module-info.java | 1 + 31 files changed, 696 insertions(+), 78 deletions(-) create mode 100644 .mvn/wrapper/maven-wrapper.properties create mode 100755 mvnw create mode 100644 mvnw.cmd delete mode 100644 src/main/java/ifml3/api/ComponentConnector.java create mode 100644 src/main/java/ifml3/api/connector/ComponentConnector.java create mode 100644 src/main/java/ifml3/api/connector/engine/EngineMessage.java rename src/main/java/ifml3/api/{ => connector}/internal/BaseComponentConnector.java (74%) rename src/main/java/ifml3/api/{ => connector}/internal/BaseSubscriber.java (95%) create mode 100644 src/main/java/ifml3/api/connector/ui/UIMessage.java create mode 100644 src/main/java/ifml3/api/engine/Engine.java create mode 100644 src/main/java/ifml3/api/engine/component/Component.java create mode 100644 src/main/java/ifml3/api/engine/entity/Entity.java create mode 100644 src/main/java/ifml3/api/engine/entity/EntityPool.java create mode 100644 src/main/java/ifml3/api/engine/internal/BaseEngine.java create mode 100644 src/main/java/ifml3/api/engine/system/System.java create mode 100644 src/main/java/ifml3/api/i18n/I18N.java rename src/main/java/ifml3/{app/i18n/AppTranslation.java => api/i18n/internal/AppI18N.java} (67%) create mode 100644 src/main/java/ifml3/api/i18n/package-info.java delete mode 100644 src/main/java/ifml3/app/i18n/Translation.java create mode 100644 src/main/java/ifml3/infra/package-info.java diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 0000000..2733d28 --- /dev/null +++ b/.mvn/wrapper/maven-wrapper.properties @@ -0,0 +1,19 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +wrapperVersion=3.3.2 +distributionType=only-script +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/4.0.0-rc-3/apache-maven-4.0.0-rc-3-bin.zip diff --git a/mvnw b/mvnw new file mode 100755 index 0000000..19529dd --- /dev/null +++ b/mvnw @@ -0,0 +1,259 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Apache Maven Wrapper startup batch script, version 3.3.2 +# +# Optional ENV vars +# ----------------- +# JAVA_HOME - location of a JDK home dir, required when download maven via java source +# MVNW_REPOURL - repo url base for downloading maven distribution +# MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven +# MVNW_VERBOSE - true: enable verbose log; debug: trace the mvnw script; others: silence the output +# ---------------------------------------------------------------------------- + +set -euf +[ "${MVNW_VERBOSE-}" != debug ] || set -x + +# OS specific support. +native_path() { printf %s\\n "$1"; } +case "$(uname)" in +CYGWIN* | MINGW*) + [ -z "${JAVA_HOME-}" ] || JAVA_HOME="$(cygpath --unix "$JAVA_HOME")" + native_path() { cygpath --path --windows "$1"; } + ;; +esac + +# set JAVACMD and JAVACCMD +set_java_home() { + # For Cygwin and MinGW, ensure paths are in Unix format before anything is touched + if [ -n "${JAVA_HOME-}" ]; then + if [ -x "$JAVA_HOME/jre/sh/java" ]; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACCMD="$JAVA_HOME/jre/sh/javac" + else + JAVACMD="$JAVA_HOME/bin/java" + JAVACCMD="$JAVA_HOME/bin/javac" + + if [ ! -x "$JAVACMD" ] || [ ! -x "$JAVACCMD" ]; then + echo "The JAVA_HOME environment variable is not defined correctly, so mvnw cannot run." >&2 + echo "JAVA_HOME is set to \"$JAVA_HOME\", but \"\$JAVA_HOME/bin/java\" or \"\$JAVA_HOME/bin/javac\" does not exist." >&2 + return 1 + fi + fi + else + JAVACMD="$( + 'set' +e + 'unset' -f command 2>/dev/null + 'command' -v java + )" || : + JAVACCMD="$( + 'set' +e + 'unset' -f command 2>/dev/null + 'command' -v javac + )" || : + + if [ ! -x "${JAVACMD-}" ] || [ ! -x "${JAVACCMD-}" ]; then + echo "The java/javac command does not exist in PATH nor is JAVA_HOME set, so mvnw cannot run." >&2 + return 1 + fi + fi +} + +# hash string like Java String::hashCode +hash_string() { + str="${1:-}" h=0 + while [ -n "$str" ]; do + char="${str%"${str#?}"}" + h=$(((h * 31 + $(LC_CTYPE=C printf %d "'$char")) % 4294967296)) + str="${str#?}" + done + printf %x\\n $h +} + +verbose() { :; } +[ "${MVNW_VERBOSE-}" != true ] || verbose() { printf %s\\n "${1-}"; } + +die() { + printf %s\\n "$1" >&2 + exit 1 +} + +trim() { + # MWRAPPER-139: + # Trims trailing and leading whitespace, carriage returns, tabs, and linefeeds. + # Needed for removing poorly interpreted newline sequences when running in more + # exotic environments such as mingw bash on Windows. + printf "%s" "${1}" | tr -d '[:space:]' +} + +# parse distributionUrl and optional distributionSha256Sum, requires .mvn/wrapper/maven-wrapper.properties +while IFS="=" read -r key value; do + case "${key-}" in + distributionUrl) distributionUrl=$(trim "${value-}") ;; + distributionSha256Sum) distributionSha256Sum=$(trim "${value-}") ;; + esac +done <"${0%/*}/.mvn/wrapper/maven-wrapper.properties" +[ -n "${distributionUrl-}" ] || die "cannot read distributionUrl property in ${0%/*}/.mvn/wrapper/maven-wrapper.properties" + +case "${distributionUrl##*/}" in +maven-mvnd-*bin.*) + MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ + case "${PROCESSOR_ARCHITECTURE-}${PROCESSOR_ARCHITEW6432-}:$(uname -a)" in + *AMD64:CYGWIN* | *AMD64:MINGW*) distributionPlatform=windows-amd64 ;; + :Darwin*x86_64) distributionPlatform=darwin-amd64 ;; + :Darwin*arm64) distributionPlatform=darwin-aarch64 ;; + :Linux*x86_64*) distributionPlatform=linux-amd64 ;; + *) + echo "Cannot detect native platform for mvnd on $(uname)-$(uname -m), use pure java version" >&2 + distributionPlatform=linux-amd64 + ;; + esac + distributionUrl="${distributionUrl%-bin.*}-$distributionPlatform.zip" + ;; +maven-mvnd-*) MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ ;; +*) MVN_CMD="mvn${0##*/mvnw}" _MVNW_REPO_PATTERN=/org/apache/maven/ ;; +esac + +# apply MVNW_REPOURL and calculate MAVEN_HOME +# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-,maven-mvnd--}/ +[ -z "${MVNW_REPOURL-}" ] || distributionUrl="$MVNW_REPOURL$_MVNW_REPO_PATTERN${distributionUrl#*"$_MVNW_REPO_PATTERN"}" +distributionUrlName="${distributionUrl##*/}" +distributionUrlNameMain="${distributionUrlName%.*}" +distributionUrlNameMain="${distributionUrlNameMain%-bin}" +MAVEN_USER_HOME="${MAVEN_USER_HOME:-${HOME}/.m2}" +MAVEN_HOME="${MAVEN_USER_HOME}/wrapper/dists/${distributionUrlNameMain-}/$(hash_string "$distributionUrl")" + +exec_maven() { + unset MVNW_VERBOSE MVNW_USERNAME MVNW_PASSWORD MVNW_REPOURL || : + exec "$MAVEN_HOME/bin/$MVN_CMD" "$@" || die "cannot exec $MAVEN_HOME/bin/$MVN_CMD" +} + +if [ -d "$MAVEN_HOME" ]; then + verbose "found existing MAVEN_HOME at $MAVEN_HOME" + exec_maven "$@" +fi + +case "${distributionUrl-}" in +*?-bin.zip | *?maven-mvnd-?*-?*.zip) ;; +*) die "distributionUrl is not valid, must match *-bin.zip or maven-mvnd-*.zip, but found '${distributionUrl-}'" ;; +esac + +# prepare tmp dir +if TMP_DOWNLOAD_DIR="$(mktemp -d)" && [ -d "$TMP_DOWNLOAD_DIR" ]; then + clean() { rm -rf -- "$TMP_DOWNLOAD_DIR"; } + trap clean HUP INT TERM EXIT +else + die "cannot create temp dir" +fi + +mkdir -p -- "${MAVEN_HOME%/*}" + +# Download and Install Apache Maven +verbose "Couldn't find MAVEN_HOME, downloading and installing it ..." +verbose "Downloading from: $distributionUrl" +verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName" + +# select .zip or .tar.gz +if ! command -v unzip >/dev/null; then + distributionUrl="${distributionUrl%.zip}.tar.gz" + distributionUrlName="${distributionUrl##*/}" +fi + +# verbose opt +__MVNW_QUIET_WGET=--quiet __MVNW_QUIET_CURL=--silent __MVNW_QUIET_UNZIP=-q __MVNW_QUIET_TAR='' +[ "${MVNW_VERBOSE-}" != true ] || __MVNW_QUIET_WGET='' __MVNW_QUIET_CURL='' __MVNW_QUIET_UNZIP='' __MVNW_QUIET_TAR=v + +# normalize http auth +case "${MVNW_PASSWORD:+has-password}" in +'') MVNW_USERNAME='' MVNW_PASSWORD='' ;; +has-password) [ -n "${MVNW_USERNAME-}" ] || MVNW_USERNAME='' MVNW_PASSWORD='' ;; +esac + +if [ -z "${MVNW_USERNAME-}" ] && command -v wget >/dev/null; then + verbose "Found wget ... using wget" + wget ${__MVNW_QUIET_WGET:+"$__MVNW_QUIET_WGET"} "$distributionUrl" -O "$TMP_DOWNLOAD_DIR/$distributionUrlName" || die "wget: Failed to fetch $distributionUrl" +elif [ -z "${MVNW_USERNAME-}" ] && command -v curl >/dev/null; then + verbose "Found curl ... using curl" + curl ${__MVNW_QUIET_CURL:+"$__MVNW_QUIET_CURL"} -f -L -o "$TMP_DOWNLOAD_DIR/$distributionUrlName" "$distributionUrl" || die "curl: Failed to fetch $distributionUrl" +elif set_java_home; then + verbose "Falling back to use Java to download" + javaSource="$TMP_DOWNLOAD_DIR/Downloader.java" + targetZip="$TMP_DOWNLOAD_DIR/$distributionUrlName" + cat >"$javaSource" <<-END + public class Downloader extends java.net.Authenticator + { + protected java.net.PasswordAuthentication getPasswordAuthentication() + { + return new java.net.PasswordAuthentication( System.getenv( "MVNW_USERNAME" ), System.getenv( "MVNW_PASSWORD" ).toCharArray() ); + } + public static void main( String[] args ) throws Exception + { + setDefault( new Downloader() ); + java.nio.file.Files.copy( java.net.URI.create( args[0] ).toURL().openStream(), java.nio.file.Paths.get( args[1] ).toAbsolutePath().normalize() ); + } + } + END + # For Cygwin/MinGW, switch paths to Windows format before running javac and java + verbose " - Compiling Downloader.java ..." + "$(native_path "$JAVACCMD")" "$(native_path "$javaSource")" || die "Failed to compile Downloader.java" + verbose " - Running Downloader.java ..." + "$(native_path "$JAVACMD")" -cp "$(native_path "$TMP_DOWNLOAD_DIR")" Downloader "$distributionUrl" "$(native_path "$targetZip")" +fi + +# If specified, validate the SHA-256 sum of the Maven distribution zip file +if [ -n "${distributionSha256Sum-}" ]; then + distributionSha256Result=false + if [ "$MVN_CMD" = mvnd.sh ]; then + echo "Checksum validation is not supported for maven-mvnd." >&2 + echo "Please disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2 + exit 1 + elif command -v sha256sum >/dev/null; then + if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | sha256sum -c >/dev/null 2>&1; then + distributionSha256Result=true + fi + elif command -v shasum >/dev/null; then + if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | shasum -a 256 -c >/dev/null 2>&1; then + distributionSha256Result=true + fi + else + echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available." >&2 + echo "Please install either command, or disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2 + exit 1 + fi + if [ $distributionSha256Result = false ]; then + echo "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised." >&2 + echo "If you updated your Maven version, you need to update the specified distributionSha256Sum property." >&2 + exit 1 + fi +fi + +# unzip and move +if command -v unzip >/dev/null; then + unzip ${__MVNW_QUIET_UNZIP:+"$__MVNW_QUIET_UNZIP"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -d "$TMP_DOWNLOAD_DIR" || die "failed to unzip" +else + tar xzf${__MVNW_QUIET_TAR:+"$__MVNW_QUIET_TAR"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -C "$TMP_DOWNLOAD_DIR" || die "failed to untar" +fi +printf %s\\n "$distributionUrl" >"$TMP_DOWNLOAD_DIR/$distributionUrlNameMain/mvnw.url" +mv -- "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" "$MAVEN_HOME" || [ -d "$MAVEN_HOME" ] || die "fail to move MAVEN_HOME" + +clean || : +exec_maven "$@" diff --git a/mvnw.cmd b/mvnw.cmd new file mode 100644 index 0000000..b150b91 --- /dev/null +++ b/mvnw.cmd @@ -0,0 +1,149 @@ +<# : batch portion +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM http://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Apache Maven Wrapper startup batch script, version 3.3.2 +@REM +@REM Optional ENV vars +@REM MVNW_REPOURL - repo url base for downloading maven distribution +@REM MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven +@REM MVNW_VERBOSE - true: enable verbose log; others: silence the output +@REM ---------------------------------------------------------------------------- + +@IF "%__MVNW_ARG0_NAME__%"=="" (SET __MVNW_ARG0_NAME__=%~nx0) +@SET __MVNW_CMD__= +@SET __MVNW_ERROR__= +@SET __MVNW_PSMODULEP_SAVE=%PSModulePath% +@SET PSModulePath= +@FOR /F "usebackq tokens=1* delims==" %%A IN (`powershell -noprofile "& {$scriptDir='%~dp0'; $script='%__MVNW_ARG0_NAME__%'; icm -ScriptBlock ([Scriptblock]::Create((Get-Content -Raw '%~f0'))) -NoNewScope}"`) DO @( + IF "%%A"=="MVN_CMD" (set __MVNW_CMD__=%%B) ELSE IF "%%B"=="" (echo %%A) ELSE (echo %%A=%%B) +) +@SET PSModulePath=%__MVNW_PSMODULEP_SAVE% +@SET __MVNW_PSMODULEP_SAVE= +@SET __MVNW_ARG0_NAME__= +@SET MVNW_USERNAME= +@SET MVNW_PASSWORD= +@IF NOT "%__MVNW_CMD__%"=="" (%__MVNW_CMD__% %*) +@echo Cannot start maven from wrapper >&2 && exit /b 1 +@GOTO :EOF +: end batch / begin powershell #> + +$ErrorActionPreference = "Stop" +if ($env:MVNW_VERBOSE -eq "true") { + $VerbosePreference = "Continue" +} + +# calculate distributionUrl, requires .mvn/wrapper/maven-wrapper.properties +$distributionUrl = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionUrl +if (!$distributionUrl) { + Write-Error "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties" +} + +switch -wildcard -casesensitive ( $($distributionUrl -replace '^.*/','') ) { + "maven-mvnd-*" { + $USE_MVND = $true + $distributionUrl = $distributionUrl -replace '-bin\.[^.]*$',"-windows-amd64.zip" + $MVN_CMD = "mvnd.cmd" + break + } + default { + $USE_MVND = $false + $MVN_CMD = $script -replace '^mvnw','mvn' + break + } +} + +# apply MVNW_REPOURL and calculate MAVEN_HOME +# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-,maven-mvnd--}/ +if ($env:MVNW_REPOURL) { + $MVNW_REPO_PATTERN = if ($USE_MVND) { "/org/apache/maven/" } else { "/maven/mvnd/" } + $distributionUrl = "$env:MVNW_REPOURL$MVNW_REPO_PATTERN$($distributionUrl -replace '^.*'+$MVNW_REPO_PATTERN,'')" +} +$distributionUrlName = $distributionUrl -replace '^.*/','' +$distributionUrlNameMain = $distributionUrlName -replace '\.[^.]*$','' -replace '-bin$','' +$MAVEN_HOME_PARENT = "$HOME/.m2/wrapper/dists/$distributionUrlNameMain" +if ($env:MAVEN_USER_HOME) { + $MAVEN_HOME_PARENT = "$env:MAVEN_USER_HOME/wrapper/dists/$distributionUrlNameMain" +} +$MAVEN_HOME_NAME = ([System.Security.Cryptography.MD5]::Create().ComputeHash([byte[]][char[]]$distributionUrl) | ForEach-Object {$_.ToString("x2")}) -join '' +$MAVEN_HOME = "$MAVEN_HOME_PARENT/$MAVEN_HOME_NAME" + +if (Test-Path -Path "$MAVEN_HOME" -PathType Container) { + Write-Verbose "found existing MAVEN_HOME at $MAVEN_HOME" + Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" + exit $? +} + +if (! $distributionUrlNameMain -or ($distributionUrlName -eq $distributionUrlNameMain)) { + Write-Error "distributionUrl is not valid, must end with *-bin.zip, but found $distributionUrl" +} + +# prepare tmp dir +$TMP_DOWNLOAD_DIR_HOLDER = New-TemporaryFile +$TMP_DOWNLOAD_DIR = New-Item -Itemtype Directory -Path "$TMP_DOWNLOAD_DIR_HOLDER.dir" +$TMP_DOWNLOAD_DIR_HOLDER.Delete() | Out-Null +trap { + if ($TMP_DOWNLOAD_DIR.Exists) { + try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } + catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } + } +} + +New-Item -Itemtype Directory -Path "$MAVEN_HOME_PARENT" -Force | Out-Null + +# Download and Install Apache Maven +Write-Verbose "Couldn't find MAVEN_HOME, downloading and installing it ..." +Write-Verbose "Downloading from: $distributionUrl" +Write-Verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName" + +$webclient = New-Object System.Net.WebClient +if ($env:MVNW_USERNAME -and $env:MVNW_PASSWORD) { + $webclient.Credentials = New-Object System.Net.NetworkCredential($env:MVNW_USERNAME, $env:MVNW_PASSWORD) +} +[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 +$webclient.DownloadFile($distributionUrl, "$TMP_DOWNLOAD_DIR/$distributionUrlName") | Out-Null + +# If specified, validate the SHA-256 sum of the Maven distribution zip file +$distributionSha256Sum = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionSha256Sum +if ($distributionSha256Sum) { + if ($USE_MVND) { + Write-Error "Checksum validation is not supported for maven-mvnd. `nPlease disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." + } + Import-Module $PSHOME\Modules\Microsoft.PowerShell.Utility -Function Get-FileHash + if ((Get-FileHash "$TMP_DOWNLOAD_DIR/$distributionUrlName" -Algorithm SHA256).Hash.ToLower() -ne $distributionSha256Sum) { + Write-Error "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised. If you updated your Maven version, you need to update the specified distributionSha256Sum property." + } +} + +# unzip and move +Expand-Archive "$TMP_DOWNLOAD_DIR/$distributionUrlName" -DestinationPath "$TMP_DOWNLOAD_DIR" | Out-Null +Rename-Item -Path "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" -NewName $MAVEN_HOME_NAME | Out-Null +try { + Move-Item -Path "$TMP_DOWNLOAD_DIR/$MAVEN_HOME_NAME" -Destination $MAVEN_HOME_PARENT | Out-Null +} catch { + if (! (Test-Path -Path "$MAVEN_HOME" -PathType Container)) { + Write-Error "fail to move MAVEN_HOME" + } +} finally { + try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } + catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } +} + +Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" diff --git a/pom.xml b/pom.xml index 7c78226..09bc004 100644 --- a/pom.xml +++ b/pom.xml @@ -22,10 +22,14 @@ ${encoding} 17 gluon - ${java.version} - ${java.version} + 24 + 24 . ifml3.app.Ifml3App + 24.0.1 + 2.0.17 + 10.0.0.0 + 3.0.0 @@ -33,27 +37,27 @@ org.openjfx javafx-controls - 18.0.1 + ${version.library.javafx} + + + org.slf4j + slf4j-api + ${version.library.slf4j} + + + org.slf4j + slf4j-simple + ${version.library.slf4j} - - org.slf4j - slf4j-api - 2.0.6 - - - org.slf4j - slf4j-simple - 2.0.6 - org.jruby jruby - 9.3.8.0 + ${version.library.jruby} org.asciidoctor asciidoctorj - 2.5.6 + ${version.library.asciidoctorj} @@ -65,27 +69,27 @@ org.apache.maven.plugins maven-compiler-plugin - 3.10.1 + 3.14.0 org.apache.maven.plugins maven-surefire-plugin - 3.0.0-M7 + 3.5.3 org.apache.maven.plugins maven-failsafe-plugin - 3.0.0-M7 + 3.5.3 org.apache.maven.plugins maven-site-plugin - 3.12.1 + 3.21.0 org.asciidoctor asciidoctor-maven-plugin - 2.2.2 + 3.2.0 org.openjfx @@ -95,7 +99,7 @@ com.gluonhq gluonfx-maven-plugin - 1.0.15 + 1.0.26 @@ -237,22 +241,22 @@ org.asciidoctor asciidoctor-maven-plugin - 2.2.2 + 3.2.0 org.jruby jruby - 9.3.8.0 + ${version.library.jruby} org.asciidoctor asciidoctorj - 2.5.6 + ${version.library.asciidoctorj} org.asciidoctor asciidoctorj-diagram - 2.2.3 + 2.3.2 @@ -291,6 +295,31 @@ + + native + + + + org.graalvm.buildtools + native-maven-plugin + 0.10.6 + true + + + build-native + + compile-no-fork + + package + + + + ifml3.app.Ifml3App + + + + + diff --git a/src/main/java/ifml3/api/ComponentConnector.java b/src/main/java/ifml3/api/ComponentConnector.java deleted file mode 100644 index e712bee..0000000 --- a/src/main/java/ifml3/api/ComponentConnector.java +++ /dev/null @@ -1,11 +0,0 @@ -package ifml3.api; - -import java.util.concurrent.Flow.Publisher; -import java.util.concurrent.Flow.Subscriber; - -public interface ComponentConnector { - - Subscriber subscriber(); - - Publisher publisher(); -} diff --git a/src/main/java/ifml3/api/connector/ComponentConnector.java b/src/main/java/ifml3/api/connector/ComponentConnector.java new file mode 100644 index 0000000..08bcc95 --- /dev/null +++ b/src/main/java/ifml3/api/connector/ComponentConnector.java @@ -0,0 +1,16 @@ +package ifml3.api.connector; + +import ifml3.api.connector.internal.BaseComponentConnector; +import java.util.concurrent.Flow.Publisher; +import java.util.concurrent.Flow.Subscriber; + +public interface ComponentConnector { + + Subscriber subscriber(); + + Publisher publisher(); + + static ComponentConnector create(final Subscriber in, final Publisher out) { + return new BaseComponentConnector<>(in, out); + } +} diff --git a/src/main/java/ifml3/api/connector/engine/EngineMessage.java b/src/main/java/ifml3/api/connector/engine/EngineMessage.java new file mode 100644 index 0000000..cbae89c --- /dev/null +++ b/src/main/java/ifml3/api/connector/engine/EngineMessage.java @@ -0,0 +1,5 @@ +package ifml3.api.connector.engine; + +public interface EngineMessage { + +} diff --git a/src/main/java/ifml3/api/internal/BaseComponentConnector.java b/src/main/java/ifml3/api/connector/internal/BaseComponentConnector.java similarity index 74% rename from src/main/java/ifml3/api/internal/BaseComponentConnector.java rename to src/main/java/ifml3/api/connector/internal/BaseComponentConnector.java index 25f6081..0ecfc2b 100644 --- a/src/main/java/ifml3/api/internal/BaseComponentConnector.java +++ b/src/main/java/ifml3/api/connector/internal/BaseComponentConnector.java @@ -1,6 +1,6 @@ -package ifml3.api.internal; +package ifml3.api.connector.internal; -import ifml3.api.ComponentConnector; +import ifml3.api.connector.ComponentConnector; import java.util.concurrent.Flow.Publisher; import java.util.concurrent.Flow.Subscriber; diff --git a/src/main/java/ifml3/api/internal/BaseSubscriber.java b/src/main/java/ifml3/api/connector/internal/BaseSubscriber.java similarity index 95% rename from src/main/java/ifml3/api/internal/BaseSubscriber.java rename to src/main/java/ifml3/api/connector/internal/BaseSubscriber.java index 495dcbf..5fc5dd9 100644 --- a/src/main/java/ifml3/api/internal/BaseSubscriber.java +++ b/src/main/java/ifml3/api/connector/internal/BaseSubscriber.java @@ -1,4 +1,4 @@ -package ifml3.api.internal; +package ifml3.api.connector.internal; import java.util.concurrent.Flow.Subscriber; import java.util.concurrent.Flow.Subscription; diff --git a/src/main/java/ifml3/api/connector/ui/UIMessage.java b/src/main/java/ifml3/api/connector/ui/UIMessage.java new file mode 100644 index 0000000..65c56a5 --- /dev/null +++ b/src/main/java/ifml3/api/connector/ui/UIMessage.java @@ -0,0 +1,5 @@ +package ifml3.api.connector.ui; + +public interface UIMessage { + +} diff --git a/src/main/java/ifml3/api/engine/Engine.java b/src/main/java/ifml3/api/engine/Engine.java new file mode 100644 index 0000000..76b4516 --- /dev/null +++ b/src/main/java/ifml3/api/engine/Engine.java @@ -0,0 +1,8 @@ +package ifml3.api.engine; + +/** + * Story Engine. + */ +public interface Engine { + +} diff --git a/src/main/java/ifml3/api/engine/component/Component.java b/src/main/java/ifml3/api/engine/component/Component.java new file mode 100644 index 0000000..0dd91ec --- /dev/null +++ b/src/main/java/ifml3/api/engine/component/Component.java @@ -0,0 +1,8 @@ +package ifml3.api.engine; + +/** + * Entity component. + */ +public interface Component { + +} diff --git a/src/main/java/ifml3/api/engine/entity/Entity.java b/src/main/java/ifml3/api/engine/entity/Entity.java new file mode 100644 index 0000000..9b71996 --- /dev/null +++ b/src/main/java/ifml3/api/engine/entity/Entity.java @@ -0,0 +1,44 @@ +package ifml3.api.engine.entity; + +import ifml3.api.engine.Component; +import java.util.Map; +import java.util.UUID; +import java.util.concurrent.ConcurrentHashMap; + +/** + * Story entity. + */ +public class Entity { + + private final UUID id; + private final Map, Component> components; + + public Entity() { + this(UUID.randomUUID()); + } + + public Entity(final UUID id) { + this.id = id; + this.components = new ConcurrentHashMap(); + } + + public UUID id() { + return id; + } + + public boolean has(final Class type) { + return components.containsKey(type); + } + + public void put(final Class type, final C value) { + components.put(type, value); + } + + public C get(final Class type) { + return type.cast(components.get(type)); + } + + public void remove(final Class type) { + components.remove(type); + } +} diff --git a/src/main/java/ifml3/api/engine/entity/EntityPool.java b/src/main/java/ifml3/api/engine/entity/EntityPool.java new file mode 100644 index 0000000..124b705 --- /dev/null +++ b/src/main/java/ifml3/api/engine/entity/EntityPool.java @@ -0,0 +1,30 @@ +package ifml3.api.engine.entity; + +import java.util.Collection; +import java.util.Map; +import java.util.UUID; +import java.util.concurrent.ConcurrentHashMap; + +/** + * Entites. + */ +public class EntityPool { + + private final Map entities; + + public EntityPool() { + entities = new ConcurrentHashMap<>(); + } + + public void add(final Entity entity) { + entities.put(entity.id(), entity); + } + + public Entity findById(final UUID id) { + return entities.get(id); + } + + public Collection findAll() { + return entities.values(); + } +} diff --git a/src/main/java/ifml3/api/engine/internal/BaseEngine.java b/src/main/java/ifml3/api/engine/internal/BaseEngine.java new file mode 100644 index 0000000..c8d1041 --- /dev/null +++ b/src/main/java/ifml3/api/engine/internal/BaseEngine.java @@ -0,0 +1,34 @@ +package ifml3.api.engine.internal; + +import ifml3.api.connector.ComponentConnector; +import ifml3.api.connector.engine.EngineMessage; +import ifml3.api.connector.internal.BaseSubscriber; +import ifml3.api.connector.ui.UIMessage; +import ifml3.api.engine.Engine; +import java.util.concurrent.Flow; +import java.util.concurrent.SubmissionPublisher; + +public class BaseEngine implements Engine, ComponentConnector { + + private final SubmissionPublisher publisher; + private final Flow.Subscriber subscriber; + + public BaseEngine() { + this.publisher = new SubmissionPublisher<>(); + this.subscriber = new BaseSubscriber<>(this::process); + } + + @Override + public Flow.Subscriber subscriber() { + return subscriber; + } + + @Override + public Flow.Publisher publisher() { + return publisher; + } + + private void process(final UIMessage message) { + //FIXME + } +} diff --git a/src/main/java/ifml3/api/engine/system/System.java b/src/main/java/ifml3/api/engine/system/System.java new file mode 100644 index 0000000..bdc51b7 --- /dev/null +++ b/src/main/java/ifml3/api/engine/system/System.java @@ -0,0 +1,9 @@ +package ifml3.api.engine; + +/** + * System for engine. + */ +public interface System { + + void update(long dt); +} diff --git a/src/main/java/ifml3/api/i18n/I18N.java b/src/main/java/ifml3/api/i18n/I18N.java new file mode 100644 index 0000000..8066a2e --- /dev/null +++ b/src/main/java/ifml3/api/i18n/I18N.java @@ -0,0 +1,20 @@ +package ifml3.api.i18n; + +import ifml3.api.i18n.internal.AppI18N; +import java.util.ResourceBundle; + +@FunctionalInterface +public interface I18N { + + String message(Message message); + + @FunctionalInterface + interface Message { + + String key(); + } + + static I18N create(final ResourceBundle bundle) { + return new AppI18N(bundle); + } +} diff --git a/src/main/java/ifml3/app/i18n/AppTranslation.java b/src/main/java/ifml3/api/i18n/internal/AppI18N.java similarity index 67% rename from src/main/java/ifml3/app/i18n/AppTranslation.java rename to src/main/java/ifml3/api/i18n/internal/AppI18N.java index d3fb690..5a5312c 100644 --- a/src/main/java/ifml3/app/i18n/AppTranslation.java +++ b/src/main/java/ifml3/api/i18n/internal/AppI18N.java @@ -1,13 +1,14 @@ -package ifml3.app.i18n; +package ifml3.api.i18n.internal; +import ifml3.api.i18n.I18N; import java.util.Objects; import java.util.ResourceBundle; -public class AppTranslation implements Translation { +public class AppI18N implements I18N { private final ResourceBundle bundle; - public AppTranslation(final ResourceBundle bundle) { + public AppI18N(final ResourceBundle bundle) { this.bundle = bundle; } diff --git a/src/main/java/ifml3/api/i18n/package-info.java b/src/main/java/ifml3/api/i18n/package-info.java new file mode 100644 index 0000000..03a7df8 --- /dev/null +++ b/src/main/java/ifml3/api/i18n/package-info.java @@ -0,0 +1,4 @@ +/** + * Internalization classes. + */ +package ifml3.api.i18n; diff --git a/src/main/java/ifml3/app/Ifml3App.java b/src/main/java/ifml3/app/Ifml3App.java index 048aa79..0fa3fe5 100644 --- a/src/main/java/ifml3/app/Ifml3App.java +++ b/src/main/java/ifml3/app/Ifml3App.java @@ -1,8 +1,6 @@ package ifml3.app; import ifml3.app.i18n.AppMessage; -import ifml3.app.i18n.AppTranslation; -import ifml3.app.i18n.Translation; import ifml3.app.view.MainView; import ifml3.app.view.View; import ifml3.app.view.ui.internal.PlayerComponent; @@ -15,12 +13,13 @@ import javafx.stage.Stage; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import ifml3.api.i18n.I18N; public class Ifml3App extends Application { private static final Logger logger = LoggerFactory.getLogger(Ifml3App.class); - private Translation translation; + private I18N translation; private View view; private PlayerComponent player; private Lexer lexer; @@ -29,7 +28,7 @@ public class Ifml3App extends Application { @Override public void init() { logger.info("Initialization..."); - this.translation = new AppTranslation(ResourceBundle.getBundle("lang/ifml3")); + this.translation = I18N.create(ResourceBundle.getBundle("lang/ifml3")); final var mainView = new MainView(translation); this.view = mainView; this.player = mainView.player(); diff --git a/src/main/java/ifml3/app/i18n/AppMessage.java b/src/main/java/ifml3/app/i18n/AppMessage.java index 950706a..c175a94 100644 --- a/src/main/java/ifml3/app/i18n/AppMessage.java +++ b/src/main/java/ifml3/app/i18n/AppMessage.java @@ -1,6 +1,6 @@ package ifml3.app.i18n; -import ifml3.app.i18n.Translation.Message; +import ifml3.api.i18n.I18N.Message; public enum AppMessage implements Message { APP_TITLE("app.title"), diff --git a/src/main/java/ifml3/app/i18n/Translation.java b/src/main/java/ifml3/app/i18n/Translation.java deleted file mode 100644 index eee49f6..0000000 --- a/src/main/java/ifml3/app/i18n/Translation.java +++ /dev/null @@ -1,13 +0,0 @@ -package ifml3.app.i18n; - -@FunctionalInterface -public interface Translation { - - String message(Message message); - - @FunctionalInterface - interface Message { - - String key(); - } -} diff --git a/src/main/java/ifml3/app/view/MainView.java b/src/main/java/ifml3/app/view/MainView.java index 3bf7d07..67be5d7 100644 --- a/src/main/java/ifml3/app/view/MainView.java +++ b/src/main/java/ifml3/app/view/MainView.java @@ -1,8 +1,7 @@ package ifml3.app.view; -import ifml3.api.ComponentConnector; +import ifml3.api.connector.ComponentConnector; import ifml3.app.i18n.AppMessage; -import ifml3.app.i18n.Translation; import ifml3.app.view.ui.internal.PlayerComponent; import javafx.scene.Scene; import javafx.scene.control.ComboBox; @@ -11,14 +10,15 @@ import javafx.scene.control.MenuBar; import javafx.scene.control.TreeView; import javafx.scene.layout.BorderPane; +import ifml3.api.i18n.I18N; public class MainView implements View { - private final Translation translation; + private final I18N translation; private final Scene scene; private final PlayerComponent player; - public MainView(final Translation translation) { + public MainView(final I18N translation) { this.translation = translation; this.player = new PlayerComponent(); final var pane = new BorderPane(player.get(), menuBar(), label("right"), inputLine(), treeView()); diff --git a/src/main/java/ifml3/app/view/ui/internal/PlayerComponent.java b/src/main/java/ifml3/app/view/ui/internal/PlayerComponent.java index 1d8cf3f..835edbf 100644 --- a/src/main/java/ifml3/app/view/ui/internal/PlayerComponent.java +++ b/src/main/java/ifml3/app/view/ui/internal/PlayerComponent.java @@ -1,8 +1,7 @@ package ifml3.app.view.ui.internal; -import ifml3.api.ComponentConnector; -import ifml3.api.internal.BaseComponentConnector; -import ifml3.api.internal.BaseSubscriber; +import ifml3.api.connector.ComponentConnector; +import ifml3.api.connector.internal.BaseSubscriber; import ifml3.app.view.ui.UIComponent; import ifml3.ui.TextSanitizer; import ifml3.ui.UserCommand; @@ -42,7 +41,7 @@ public PlayerComponent() { this.textField.setOnAction(this::processCommand); this.vBox = new VBox(textArea, textField); this.subscriber = new BaseSubscriber<>(this::processMessage); - this.connector = new BaseComponentConnector<>(subscriber, publisher); + this.connector = ComponentConnector.create(subscriber, publisher); } @Override diff --git a/src/main/java/ifml3/engine/Engine.java b/src/main/java/ifml3/engine/Engine.java index bc4fe31..c97a340 100644 --- a/src/main/java/ifml3/engine/Engine.java +++ b/src/main/java/ifml3/engine/Engine.java @@ -1,6 +1,6 @@ package ifml3.engine; -import ifml3.api.ComponentConnector; +import ifml3.api.connector.ComponentConnector; public interface Engine { diff --git a/src/main/java/ifml3/engine/internal/SimpleEngine.java b/src/main/java/ifml3/engine/internal/SimpleEngine.java index ca611e0..cb107c0 100644 --- a/src/main/java/ifml3/engine/internal/SimpleEngine.java +++ b/src/main/java/ifml3/engine/internal/SimpleEngine.java @@ -1,8 +1,7 @@ package ifml3.engine.internal; -import ifml3.api.ComponentConnector; -import ifml3.api.internal.BaseComponentConnector; -import ifml3.api.internal.BaseSubscriber; +import ifml3.api.connector.ComponentConnector; +import ifml3.api.connector.internal.BaseSubscriber; import ifml3.engine.Engine; import ifml3.engine.EngineCommand; import ifml3.engine.EngineMessage; @@ -18,7 +17,7 @@ public class SimpleEngine implements Engine { public SimpleEngine() { publisher = new SubmissionPublisher(); subscriber = new BaseSubscriber<>(this::processCommand); - connector = new BaseComponentConnector<>(subscriber, publisher); + connector = ComponentConnector.create(subscriber, publisher); } @Override diff --git a/src/main/java/ifml3/infra/package-info.java b/src/main/java/ifml3/infra/package-info.java new file mode 100644 index 0000000..8757052 --- /dev/null +++ b/src/main/java/ifml3/infra/package-info.java @@ -0,0 +1,4 @@ +/** + * Infrastructure classes. + */ +package ifml3.infra; diff --git a/src/main/java/ifml3/lexer/Lexer.java b/src/main/java/ifml3/lexer/Lexer.java index 7600974..52fe079 100644 --- a/src/main/java/ifml3/lexer/Lexer.java +++ b/src/main/java/ifml3/lexer/Lexer.java @@ -1,6 +1,6 @@ package ifml3.lexer; -import ifml3.api.ComponentConnector; +import ifml3.api.connector.ComponentConnector; import ifml3.engine.EngineCommand; import ifml3.engine.EngineMessage; import ifml3.ui.UserCommand; diff --git a/src/main/java/ifml3/lexer/internal/SimpleLexer.java b/src/main/java/ifml3/lexer/internal/SimpleLexer.java index 1c94f4f..47af1d2 100644 --- a/src/main/java/ifml3/lexer/internal/SimpleLexer.java +++ b/src/main/java/ifml3/lexer/internal/SimpleLexer.java @@ -1,8 +1,8 @@ package ifml3.lexer.internal; -import ifml3.api.ComponentConnector; -import ifml3.api.internal.BaseComponentConnector; -import ifml3.api.internal.BaseSubscriber; +import ifml3.api.connector.ComponentConnector; +import ifml3.api.connector.internal.BaseComponentConnector; +import ifml3.api.connector.internal.BaseSubscriber; import ifml3.engine.EngineCommand; import ifml3.engine.EngineMessage; import ifml3.lexer.Dictionary; diff --git a/src/main/java/ifml3/ui/UserInterface.java b/src/main/java/ifml3/ui/UserInterface.java index 202fd2f..f7d9f87 100644 --- a/src/main/java/ifml3/ui/UserInterface.java +++ b/src/main/java/ifml3/ui/UserInterface.java @@ -1,6 +1,6 @@ package ifml3.ui; -import ifml3.api.ComponentConnector; +import ifml3.api.connector.ComponentConnector; public interface UserInterface { diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java index 1c7c298..85f1c58 100644 --- a/src/main/java/module-info.java +++ b/src/main/java/module-info.java @@ -1,4 +1,5 @@ module ifml3.app { + requires javafx.base; requires javafx.controls; requires java.base; requires org.slf4j; From eb8a8877be2729c7dff61b68f1475755835d147c Mon Sep 17 00:00:00 2001 From: Dmitry Eliseev Date: Wed, 14 May 2025 22:10:24 +0200 Subject: [PATCH 18/19] Fix pipelines Signed-off-by:Dmitry Eliseev --- .github/workflows/build-for-ubuntu.yaml | 2 +- .github/workflows/build-for-windows.yaml | 2 +- .github/workflows/package-for-ubuntu.yaml | 2 +- .github/workflows/package-for-windows.yaml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-for-ubuntu.yaml b/.github/workflows/build-for-ubuntu.yaml index 6cc0181..580e05f 100644 --- a/.github/workflows/build-for-ubuntu.yaml +++ b/.github/workflows/build-for-ubuntu.yaml @@ -15,7 +15,7 @@ jobs: id: sdkman with: candidate: java - version: 22.1.0.1.r17-gln + version: 24.0.1-graal - uses: actions/setup-java@v1 id: setup-java with: diff --git a/.github/workflows/build-for-windows.yaml b/.github/workflows/build-for-windows.yaml index c70263d..8e946a2 100644 --- a/.github/workflows/build-for-windows.yaml +++ b/.github/workflows/build-for-windows.yaml @@ -15,7 +15,7 @@ jobs: id: sdkman with: candidate: java - version: 22.1.0.1.r17-gln + version: 24.0.1-graal - uses: actions/setup-java@v1 id: setup-java with: diff --git a/.github/workflows/package-for-ubuntu.yaml b/.github/workflows/package-for-ubuntu.yaml index 8d7234c..8df8fe5 100644 --- a/.github/workflows/package-for-ubuntu.yaml +++ b/.github/workflows/package-for-ubuntu.yaml @@ -15,7 +15,7 @@ jobs: id: sdkman with: candidate: java - version: 22.1.0.1.r17-gln + version: 24.0.1-graal - uses: actions/setup-java@v1 id: setup-java with: diff --git a/.github/workflows/package-for-windows.yaml b/.github/workflows/package-for-windows.yaml index aa9214e..144a646 100644 --- a/.github/workflows/package-for-windows.yaml +++ b/.github/workflows/package-for-windows.yaml @@ -15,7 +15,7 @@ jobs: id: sdkman with: candidate: java - version: 22.1.0.1.r17-gln + version: 24.0.1-graal - uses: actions/setup-java@v1 id: setup-java with: From ac19760ee60f2c80181990015ab276fac4d181d1 Mon Sep 17 00:00:00 2001 From: Dmitry Eliseev Date: Wed, 14 May 2025 22:12:37 +0200 Subject: [PATCH 19/19] Fix version Signed-off-by:Dmitry Eliseev --- .github/workflows/build-for-ubuntu.yaml | 2 +- .github/workflows/build-for-windows.yaml | 2 +- .github/workflows/package-for-ubuntu.yaml | 2 +- .github/workflows/package-for-windows.yaml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-for-ubuntu.yaml b/.github/workflows/build-for-ubuntu.yaml index 580e05f..2dd2184 100644 --- a/.github/workflows/build-for-ubuntu.yaml +++ b/.github/workflows/build-for-ubuntu.yaml @@ -19,7 +19,7 @@ jobs: - uses: actions/setup-java@v1 id: setup-java with: - java-version: 17 + java-version: 24 jdkFile: ${{ steps.sdkman.outputs.file }} - name: Setup GRAALVM_HOME run: export GRAALVM_HOME="$JAVA_HOME" diff --git a/.github/workflows/build-for-windows.yaml b/.github/workflows/build-for-windows.yaml index 8e946a2..568a7a8 100644 --- a/.github/workflows/build-for-windows.yaml +++ b/.github/workflows/build-for-windows.yaml @@ -19,7 +19,7 @@ jobs: - uses: actions/setup-java@v1 id: setup-java with: - java-version: 17 + java-version: 24 jdkFile: ${{ steps.sdkman.outputs.file }} - name: Setup GRAALVM_HOME run: set GRAALVM_HOME=$JAVA_HOME diff --git a/.github/workflows/package-for-ubuntu.yaml b/.github/workflows/package-for-ubuntu.yaml index 8df8fe5..967e9be 100644 --- a/.github/workflows/package-for-ubuntu.yaml +++ b/.github/workflows/package-for-ubuntu.yaml @@ -19,7 +19,7 @@ jobs: - uses: actions/setup-java@v1 id: setup-java with: - java-version: 17 + java-version: 24 jdkFile: ${{ steps.sdkman.outputs.file }} - name: Setup GRAALVM_HOME run: export GRAALVM_HOME="$JAVA_HOME" diff --git a/.github/workflows/package-for-windows.yaml b/.github/workflows/package-for-windows.yaml index 144a646..1f57746 100644 --- a/.github/workflows/package-for-windows.yaml +++ b/.github/workflows/package-for-windows.yaml @@ -19,7 +19,7 @@ jobs: - uses: actions/setup-java@v1 id: setup-java with: - java-version: 17 + java-version: 24 jdkFile: ${{ steps.sdkman.outputs.file }} - name: Setup GRAALVM_HOME run: set GRAALVM_HOME=$JAVA_HOME