diff --git a/build.gradle b/build.gradle index 73e07d6..4331aaf 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,7 @@ plugins { id 'checkstyle' } group 'io.rpg' -version '1.0' +version '1.0.0' repositories { mavenCentral() @@ -81,13 +81,20 @@ run { jlink { imageZip = project.file("${buildDir}/distributions/app-${javafx.platform.classifier}.zip") options = ['--strip-debug', '--compress', '2', '--no-header-files', '--no-man-pages'] + + jpackage { + icon = 'src/main/resources/io/rpg/app.png' + appVersion = "1.0.0" + } + launcher { - name = 'app' + name = 'RPG-IO' jvmArgs = ['--add-exports=javafx.graphics/com.sun.javafx.scene=io.rpg'] } forceMerge('log4j-api') } + jlinkZip { group = 'distribution' } diff --git a/configurations/demo-config-2/locations/location-4/objects/boxer.json b/configurations/demo-config-2/locations/location-4/objects/boxer.json index 55b4ec8..8d23941 100644 --- a/configurations/demo-config-2/locations/location-4/objects/boxer.json +++ b/configurations/demo-config-2/locations/location-4/objects/boxer.json @@ -9,7 +9,7 @@ "condition": { "tag": "whatever", "type": "defeat-opponent", - "opponent-tag": "zombie-2" + "opponent-tag": "zombie-4" } }, "onRightClick": { diff --git a/docs/resources.md b/docs/resources.md index 2b0fee7..4ace318 100644 --- a/docs/resources.md +++ b/docs/resources.md @@ -1,4 +1,5 @@ # Resources * Default popup backgrounds and buttons: [Wood button vector created by upklyak - www.freepik.com](https://www.freepik.com/vectors/wood-button>) -* Coin: [Money sign vector created by rawpixel.com - www.freepik.com]("https://www.freepik.com/vectors/money-sign">) \ No newline at end of file +* Coin: [Money sign vector created by rawpixel.com - www.freepik.com]("https://www.freepik.com/vectors/money-sign">) +* Characters: [by segel](https://opengameart.org/users/segel) (not all :D) diff --git a/src/main/java/io/rpg/Main.java b/src/main/java/io/rpg/Main.java index a4ee2f0..0ba2eda 100644 --- a/src/main/java/io/rpg/Main.java +++ b/src/main/java/io/rpg/Main.java @@ -2,14 +2,16 @@ import com.kkafara.rt.Result; import io.rpg.wrapper.WrapperController; -import java.io.IOException; import javafx.application.Application; +import javafx.scene.image.Image; import javafx.stage.Stage; import org.apache.logging.log4j.Level; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.core.config.Configurator; +import java.io.IOException; + /** * Entry point of the app. */ @@ -20,6 +22,11 @@ public class Main extends Application { public void start(Stage stage) throws IOException { Configurator.setRootLevel(Level.WARN); String path = getParameters().getNamed().get("config"); + + stage.setTitle("RPG-IO"); + + stage.getIcons().add(new Image((Main.class.getResource("app.png").toString()))); + if (path == null) { WrapperController wrapperController = WrapperController.load(); wrapperController.show(stage); diff --git a/src/main/java/io/rpg/controller/Controller.java b/src/main/java/io/rpg/controller/Controller.java index 1e554a8..e682df8 100644 --- a/src/main/java/io/rpg/controller/Controller.java +++ b/src/main/java/io/rpg/controller/Controller.java @@ -140,16 +140,16 @@ else if (tagToLocationViewMap.size() != tagToLocationModelMap.size()) @Override public void onKeyboardEvent(KeyboardEvent event) { - // TODO: implement event handling logger.trace("Controller notified on key pressed from " + event.source()); - //TODO: call Player::set...Pressed depending on keyCode and whether the key was pressed or released KeyEvent payload = event.payload(); if (payload.getEventType() == KeyEvent.KEY_PRESSED) { switch (payload.getCode()) { - case E -> - popupController.openInventoryPopup(playerController.getPlayer().getInventory(), getWindowCenterX(), getWindowCenterY(), playerController.getPlayer()); + case E -> { + stopPlayer(); + popupController.openInventoryPopup(playerController.getPlayer().getInventory(), getWindowCenterX(), getWindowCenterY(), playerController.getPlayer()); + } } } } diff --git a/src/main/java/io/rpg/model/actions/ActionEngine.java b/src/main/java/io/rpg/model/actions/ActionEngine.java index 467cf15..499adcc 100644 --- a/src/main/java/io/rpg/model/actions/ActionEngine.java +++ b/src/main/java/io/rpg/model/actions/ActionEngine.java @@ -96,13 +96,11 @@ public void acceptQuizResult(GameObject opponent, boolean correct, int pointsCou } else { controller.getPopupController().hidePopup(); } + opponent.setOnLeftClickAction(Action.VOID); } else { controller.getPopupController().hidePopup(); logger.info("Wrong answer provided"); } - - // TODO: better action disabling - opponent.setOnLeftClickAction(Action.VOID); } public void onAction(GameEndAction action) { diff --git a/src/main/java/io/rpg/view/popups/BattleReflexPopup.java b/src/main/java/io/rpg/view/popups/BattleReflexPopup.java index fafee3f..cc68543 100644 --- a/src/main/java/io/rpg/view/popups/BattleReflexPopup.java +++ b/src/main/java/io/rpg/view/popups/BattleReflexPopup.java @@ -128,7 +128,7 @@ public BattleReflexPopup(int pointsPerSecond, BiConsumer callb timer.schedule(new TimerTask() { public void run() { - Platform.runLater(() -> timerTick()); + timerTick(); } }, 1000, 1000); button.setOnAction((event) -> { @@ -154,8 +154,8 @@ public String generateRandomSequence(int length) { private void timerTick() { timeToCountDown--; if (timeToCountDown < 0) { - timer.cancel(); lose(); + timer.cancel(); return; } timerDots[timeToCountDown].setImage(new Image(PathUtils.resolvePathToJFXFormat( @@ -164,15 +164,18 @@ private void timerTick() { } public void win() { - callback.accept(true, timeToCountDown * pointsPerSecond); + Platform.runLater(() -> callback.accept(true, timeToCountDown * pointsPerSecond)); timer.cancel(); } public void lose() { - callback.accept(false, 0); + Platform.runLater(() -> callback.accept(false, 0)); } public void setCloseButtonActionListener(EventHandler value) { - button.setOnAction(value); + button.setOnAction(event -> { + timer.cancel(); + value.handle(event); + }); } } diff --git a/src/main/java/io/rpg/wrapper/WrapperController.java b/src/main/java/io/rpg/wrapper/WrapperController.java index 41e12c5..7b6140a 100644 --- a/src/main/java/io/rpg/wrapper/WrapperController.java +++ b/src/main/java/io/rpg/wrapper/WrapperController.java @@ -117,7 +117,7 @@ private void onLoadClick() { loadGame(path).ifOk( g -> { game = g; - game.setOnEnd(() -> show(stage)); +// game.setOnEnd(() -> show(stage)); } ); } diff --git a/src/main/resources/io/rpg/app.icns b/src/main/resources/io/rpg/app.icns new file mode 100644 index 0000000..f86be15 Binary files /dev/null and b/src/main/resources/io/rpg/app.icns differ diff --git a/src/main/resources/io/rpg/app.png b/src/main/resources/io/rpg/app.png new file mode 100644 index 0000000..f86be15 Binary files /dev/null and b/src/main/resources/io/rpg/app.png differ