From 63e321de9bae91f440e0d73775af4081bc86044b Mon Sep 17 00:00:00 2001 From: Hackusate_PvP Date: Wed, 8 May 2024 12:43:37 -0500 Subject: [PATCH 01/30] Added example project. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 259a42c..d1655b3 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ Visual novel game engine based off of [RenPy](https://www.renpy.org/) built with **Community** - [Website]() (Not yet created), [Discord]() (Not yet created), [YouTube](https://www.youtube.com/channel/UC4iv_X0Pi8FoHFMUHBkHw1A) +-[HeroAdventure](https://github.com/HackusatePvP/HeroAdventure) This an example project that is used for testing the framework. ## Project Requirements - [Java-17](https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html) (You can typically download this within your IDE) From df7c1ddd5a33c70126fd552296e17cdd23965854 Mon Sep 17 00:00:00 2001 From: Hackusate_PvP Date: Thu, 16 May 2024 07:54:30 -0500 Subject: [PATCH 02/30] Added overlay event handling. --- .../defaults/MenuClickEventListener.java | 56 ++++++++- .../events/types/OverlayClickEvent.java | 24 ++++ .../events/types/OverlayExitEvent.java | 23 ++++ .../events/types/OverlayHoverEvent.java | 23 ++++ .../events/types/SceneRenderEvent.java | 2 +- .../java/me/piitex/renjava/gui/Element.java | 26 +++- .../renjava/gui/overlay/ButtonOverlay.java | 77 ++++++------ .../renjava/gui/overlay/ImageOverlay.java | 26 ++++ .../gui/overlay/InputFieldOverlay.java | 25 ++++ .../piitex/renjava/gui/overlay/Overlay.java | 10 ++ .../renjava/gui/overlay/SliderOverlay.java | 116 ++++++++++++++++++ .../renjava/gui/overlay/TextFlowOverlay.java | 36 +++++- .../renjava/gui/overlay/TextOverlay.java | 25 ++++ .../gui/overlay/events/IOverlayClick.java | 8 ++ .../gui/overlay/events/IOverlayHover.java | 8 ++ src/main/java/module-info.java | 1 + 16 files changed, 442 insertions(+), 44 deletions(-) create mode 100644 src/main/java/me/piitex/renjava/events/types/OverlayClickEvent.java create mode 100644 src/main/java/me/piitex/renjava/events/types/OverlayExitEvent.java create mode 100644 src/main/java/me/piitex/renjava/events/types/OverlayHoverEvent.java create mode 100644 src/main/java/me/piitex/renjava/gui/overlay/SliderOverlay.java create mode 100644 src/main/java/me/piitex/renjava/gui/overlay/events/IOverlayClick.java create mode 100644 src/main/java/me/piitex/renjava/gui/overlay/events/IOverlayHover.java diff --git a/src/main/java/me/piitex/renjava/events/defaults/MenuClickEventListener.java b/src/main/java/me/piitex/renjava/events/defaults/MenuClickEventListener.java index e1990e2..e31818d 100644 --- a/src/main/java/me/piitex/renjava/events/defaults/MenuClickEventListener.java +++ b/src/main/java/me/piitex/renjava/events/defaults/MenuClickEventListener.java @@ -2,14 +2,17 @@ import javafx.application.Platform; import javafx.scene.control.Button; +import javafx.scene.image.ImageView; import me.piitex.renjava.RenJava; +import me.piitex.renjava.events.types.*; +import me.piitex.renjava.gui.exceptions.ImageNotFoundException; +import me.piitex.renjava.gui.overlay.ButtonOverlay; +import me.piitex.renjava.gui.overlay.Overlay; import me.piitex.renjava.loggers.RenLogger; import me.piitex.renjava.api.saves.Save; import me.piitex.renjava.events.EventListener; import me.piitex.renjava.events.Listener; -import me.piitex.renjava.events.types.ButtonClickEvent; -import me.piitex.renjava.events.types.GameStartEvent; import me.piitex.renjava.gui.Menu; import me.piitex.renjava.gui.StageType; @@ -110,4 +113,53 @@ public void onButtonClick(ButtonClickEvent event) { } } + @Listener + public void onOverlayClick(OverlayClickEvent event) { + Overlay overlay = event.getOverlay(); + + if (overlay.getOnClick() != null) { + overlay.getOnClick().onClick(event); + } + } + + @Listener + public void onOverlayHover(OverlayHoverEvent event) { + Overlay overlay = event.getOverlay(); + + if (overlay.getOnHover() != null) { + overlay.getOnHover().onHover(event); + } + + if (overlay instanceof ButtonOverlay buttonOverlay) { + Button button = buttonOverlay.getButton(); + + if (buttonOverlay.isHover()) { + if (buttonOverlay.getHoverColor() != null) { + button.setTextFill(buttonOverlay.getHoverColor()); + } + if (buttonOverlay.getHoverImage() != null) { + try { + button.setGraphic(new ImageView(buttonOverlay.getHoverImage().build())); + } catch (ImageNotFoundException e) { + RenLogger.LOGGER.error(e.getMessage()); + } + } + } + } + } + + @Listener + public void onOverlayExit(OverlayExitEvent event) { + Overlay overlay = event.getOverlay(); + + if (overlay instanceof ButtonOverlay buttonOverlay) { + Button button = buttonOverlay.getButton(); + button.setTextFill(buttonOverlay.getTextFill()); + button.setStyle(button.getStyle()); // Re-init the style (hopefully this forces the button back to normal.) + if (buttonOverlay.getImage() != null) { + button.setGraphic(new ImageView(buttonOverlay.getImage().getImage())); + } + } + } + } diff --git a/src/main/java/me/piitex/renjava/events/types/OverlayClickEvent.java b/src/main/java/me/piitex/renjava/events/types/OverlayClickEvent.java new file mode 100644 index 0000000..d260a36 --- /dev/null +++ b/src/main/java/me/piitex/renjava/events/types/OverlayClickEvent.java @@ -0,0 +1,24 @@ +package me.piitex.renjava.events.types; + +import javafx.scene.input.MouseEvent; +import me.piitex.renjava.events.Event; +import me.piitex.renjava.gui.overlay.Overlay; + +public class OverlayClickEvent extends Event { + private final Overlay overlay; + private final MouseEvent event; + + + public OverlayClickEvent(Overlay overlay, MouseEvent event) { + this.overlay = overlay; + this.event = event; + } + + public Overlay getOverlay() { + return overlay; + } + + public MouseEvent getHandler() { + return event; + } +} diff --git a/src/main/java/me/piitex/renjava/events/types/OverlayExitEvent.java b/src/main/java/me/piitex/renjava/events/types/OverlayExitEvent.java new file mode 100644 index 0000000..1af55fb --- /dev/null +++ b/src/main/java/me/piitex/renjava/events/types/OverlayExitEvent.java @@ -0,0 +1,23 @@ +package me.piitex.renjava.events.types; + +import javafx.scene.input.MouseEvent; +import me.piitex.renjava.events.Event; +import me.piitex.renjava.gui.overlay.Overlay; + +public class OverlayExitEvent extends Event { + private final Overlay overlay; + private final MouseEvent event; + + public OverlayExitEvent(Overlay overlay, MouseEvent event) { + this.overlay = overlay; + this.event = event; + } + + public Overlay getOverlay() { + return overlay; + } + + public MouseEvent getHandler() { + return event; + } +} diff --git a/src/main/java/me/piitex/renjava/events/types/OverlayHoverEvent.java b/src/main/java/me/piitex/renjava/events/types/OverlayHoverEvent.java new file mode 100644 index 0000000..d23a68f --- /dev/null +++ b/src/main/java/me/piitex/renjava/events/types/OverlayHoverEvent.java @@ -0,0 +1,23 @@ +package me.piitex.renjava.events.types; + +import javafx.scene.input.MouseEvent; +import me.piitex.renjava.events.Event; +import me.piitex.renjava.gui.overlay.Overlay; + +public class OverlayHoverEvent extends Event { + private final Overlay overlay; + private final MouseEvent mouseEvent; + + public OverlayHoverEvent(Overlay overlay, MouseEvent event) { + this.overlay = overlay; + this.mouseEvent = event; + } + + public Overlay getOverlay() { + return overlay; + } + + public MouseEvent getHandler() { + return mouseEvent; + } +} diff --git a/src/main/java/me/piitex/renjava/events/types/SceneRenderEvent.java b/src/main/java/me/piitex/renjava/events/types/SceneRenderEvent.java index f74da8f..58261a7 100644 --- a/src/main/java/me/piitex/renjava/events/types/SceneRenderEvent.java +++ b/src/main/java/me/piitex/renjava/events/types/SceneRenderEvent.java @@ -20,4 +20,4 @@ public RenScene getRenScene() { public Scene getScene() { return scene; } -} +} \ No newline at end of file diff --git a/src/main/java/me/piitex/renjava/gui/Element.java b/src/main/java/me/piitex/renjava/gui/Element.java index 769e09b..51c06dc 100644 --- a/src/main/java/me/piitex/renjava/gui/Element.java +++ b/src/main/java/me/piitex/renjava/gui/Element.java @@ -3,13 +3,18 @@ import javafx.scene.Node; import javafx.scene.control.Button; +import javafx.scene.control.Slider; import javafx.scene.image.Image; import javafx.scene.image.ImageView; import javafx.scene.layout.Pane; import javafx.scene.text.Font; import javafx.scene.text.Text; import javafx.scene.text.TextFlow; +import me.piitex.renjava.RenJava; import me.piitex.renjava.api.scenes.transitions.Transitions; +import me.piitex.renjava.events.types.OverlayClickEvent; +import me.piitex.renjava.events.types.OverlayExitEvent; +import me.piitex.renjava.events.types.OverlayHoverEvent; import me.piitex.renjava.gui.overlay.*; import me.piitex.renjava.loggers.RenLogger; @@ -25,7 +30,6 @@ public Element(Overlay overlay) { double scaleY = overlay.scaleY(); if (scaleX > 0) { overlay.setWidth(overlay.width() * scaleX); - overlay.setX(overlay.x() * scaleX); } if (scaleY > 0) { @@ -65,8 +69,16 @@ public Element(Overlay overlay) { textFlow.setTranslateX(textFlowOverlay.x()); textFlow.setTranslateY(textFlowOverlay.y()); this.node = textFlow; + } else if (overlay instanceof SliderOverlay sliderOverlay) { + Slider slider = new Slider(sliderOverlay.width(), sliderOverlay.height(), 4); + slider.setPrefSize(sliderOverlay.width(), sliderOverlay.height()); + slider.setBlockIncrement(sliderOverlay.getBlockIncrement()); + this.node = slider; } + // Handle specific input + handleInput(); + // Render transition for specific overlay. if (overlay.getTransition() != null) { setTransition(overlay.getTransition()); @@ -89,6 +101,18 @@ public void render(Pane root) { root.getChildren().add(node); } + private void handleInput() { + node.setOnMouseEntered(event -> { + RenJava.callEvent(new OverlayHoverEvent(overlay, event)); + }); + node.setOnMouseClicked(event -> { + RenJava.callEvent(new OverlayClickEvent(overlay, event)); + }); + node.setOnMouseExited(event -> { + RenJava.callEvent(new OverlayExitEvent(overlay, event)); + }); + } + public Node getNode() { return node; } diff --git a/src/main/java/me/piitex/renjava/gui/overlay/ButtonOverlay.java b/src/main/java/me/piitex/renjava/gui/overlay/ButtonOverlay.java index 2821d80..fc4fb36 100644 --- a/src/main/java/me/piitex/renjava/gui/overlay/ButtonOverlay.java +++ b/src/main/java/me/piitex/renjava/gui/overlay/ButtonOverlay.java @@ -10,6 +10,8 @@ import javafx.scene.text.Font; import me.piitex.renjava.RenJava; import me.piitex.renjava.gui.Menu; +import me.piitex.renjava.gui.overlay.events.IOverlayClick; +import me.piitex.renjava.gui.overlay.events.IOverlayHover; import me.piitex.renjava.loggers.RenLogger; import me.piitex.renjava.api.loaders.ImageLoader; import me.piitex.renjava.api.scenes.transitions.Transitions; @@ -36,6 +38,9 @@ public class ButtonOverlay implements Overlay { private int borderWidth = 0; private int backgroundRadius = 0; + private IOverlayHover iOverlayHover; + private IOverlayClick iOverlayClick; + private double x = 1, y = 1; private double maxHeight, maxWidth; private final double xScale, yScale; @@ -48,15 +53,6 @@ public ButtonOverlay(String id, String text, Color textFill, double xScale, doub this.yScale = y; } - public ButtonOverlay(String id, String text, Color textFill, Font font, double xScale, double yScale) { - this.id = id; - this.text = text; - this.textFill = textFill; - this.font = font; - this.xScale = x; - this.yScale = y; - } - /** * Create a button with only text. * @@ -90,7 +86,7 @@ public ButtonOverlay(String id, String text, Color textFill, double x, double y, * @param xScale X-Axis scale of the button. * @param yScale Y-Axis scale of the button. */ - public ButtonOverlay(String id, String text, Font font, Color textFill, double x, double y, double xScale, double yScale) { + public ButtonOverlay(String id, String text, Color textFill, Font font, double x, double y, double xScale, double yScale) { this.id = id; this.text = text; this.font = font; @@ -111,7 +107,7 @@ public ButtonOverlay(String id, String text, Font font, Color textFill, double x * @param xScale X-Axis scale of the button. * @param yScale Y-Axis scale of the button. */ - public ButtonOverlay(String id, String text, Font font, Color textFill, double xScale, double yScale) { + public ButtonOverlay(String id, String text, Color textFill, Font font, double xScale, double yScale) { this.id = id; this.text = text; this.font = font; @@ -120,7 +116,7 @@ public ButtonOverlay(String id, String text, Font font, Color textFill, double x this.yScale = yScale; } - public ButtonOverlay(String id, String text, Font font, Color textFill, Color backgroundColor, Color borderColor, double xScale, double yScale) { + public ButtonOverlay(String id, String text, Color textFill, Font font, Color backgroundColor, Color borderColor, double xScale, double yScale) { this.id = id; this.text = text; this.font = font; @@ -131,7 +127,7 @@ public ButtonOverlay(String id, String text, Font font, Color textFill, Color ba this.borderColor = borderColor; } - public ButtonOverlay(String id, String text, Font font, Color textFill, Color backgroundColor, Color borderColor, boolean hover, double xScale, double yScale) { + public ButtonOverlay(String id, String text, Color textFill, Font font, Color backgroundColor, Color borderColor, boolean hover, double xScale, double yScale) { this.id = id; this.text = text; this.font = font; @@ -143,7 +139,7 @@ public ButtonOverlay(String id, String text, Font font, Color textFill, Color ba this.hover = hover; } - public ButtonOverlay(String id, String text, Font font, Color textFill, Color backgroundColor, Color borderColor, Color hoverColor, double xScale, double yScale) { + public ButtonOverlay(String id, String text, Color textFill, Font font, Color backgroundColor, Color borderColor, Color hoverColor, double xScale, double yScale) { this.id = id; this.text = text; this.font = font; @@ -237,6 +233,10 @@ public ButtonOverlay(Button button) { this.yScale = button.getScaleY(); } + public Button getButton() { + return button; + } + public String getId() { return id; } @@ -396,6 +396,27 @@ public Transitions getTransition() { return transitions; } + @Override + public void setOnclick(IOverlayClick iOverlayClick) { + this.iOverlayClick = iOverlayClick; + } + + @Override + public void setOnHover(IOverlayHover iOverlayHover) { + this.iOverlayHover = iOverlayHover; + } + + @Override + public IOverlayClick getOnClick() { + return iOverlayClick; + } + + @Override + public IOverlayHover getOnHover() { + return iOverlayHover; + } + + public void setTransitions(Transitions transitions) { this.transitions = transitions; } @@ -491,31 +512,6 @@ public Button build() { inLine += "-fx-border-width: " + borderWidth + "; "; inLine += "-fx-background-radius: " + backgroundRadius + ";"; - // https://stackoverflow.com/questions/30680570/javafx-button-border-and-hover - if (hover) { - AtomicReference atomicInLine = new AtomicReference<>(inLine); - button.setOnMouseEntered(mouseEvent -> { - if (hoverColor != null) { - button.setTextFill(hoverColor); - button.setStyle(atomicInLine.get()); - } - if (hoverImage != null) { - try { - button.setGraphic(new ImageView(hoverImage.build())); - } catch (ImageNotFoundException e) { - RenLogger.LOGGER.error(e.getMessage()); - } - } - }); - button.setOnMouseExited(mouseEvent -> { - button.setTextFill(textFill); - button.setStyle(atomicInLine.get()); - if (image != null) { - button.setGraphic(new ImageView(image.getImage())); - } - }); - } - button.setStyle(inLine); if (x != 0 && y != 0) { @@ -529,6 +525,9 @@ public Button build() { ButtonClickEvent event = new ButtonClickEvent(RenJava.getInstance().getPlayer().getCurrentScene(), button); RenJava.callEvent(event); }); + + this.button = button; + return button; } diff --git a/src/main/java/me/piitex/renjava/gui/overlay/ImageOverlay.java b/src/main/java/me/piitex/renjava/gui/overlay/ImageOverlay.java index a36bf6d..72c1f01 100644 --- a/src/main/java/me/piitex/renjava/gui/overlay/ImageOverlay.java +++ b/src/main/java/me/piitex/renjava/gui/overlay/ImageOverlay.java @@ -3,6 +3,8 @@ import javafx.scene.image.Image; import javafx.scene.image.WritableImage; import me.piitex.renjava.RenJava; +import me.piitex.renjava.gui.overlay.events.IOverlayClick; +import me.piitex.renjava.gui.overlay.events.IOverlayHover; import me.piitex.renjava.loggers.RenLogger; import me.piitex.renjava.api.loaders.ImageLoader; import me.piitex.renjava.api.scenes.transitions.Transitions; @@ -18,6 +20,10 @@ public class ImageOverlay implements Overlay { private boolean preserveRatio = true; private String fileName; + private IOverlayHover iOverlayHover; + + private IOverlayClick iOverlayClick; + private Transitions transitions; public ImageOverlay(Image image) { @@ -178,6 +184,26 @@ public Transitions getTransition() { return transitions; } + @Override + public void setOnclick(IOverlayClick iOverlayClick) { + this.iOverlayClick = iOverlayClick; + } + + @Override + public void setOnHover(IOverlayHover iOverlayHover) { + this.iOverlayHover = iOverlayHover; + } + + @Override + public IOverlayClick getOnClick() { + return iOverlayClick; + } + + @Override + public IOverlayHover getOnHover() { + return iOverlayHover; + } + public ImageOverlay setTransitions(Transitions transitions) { this.transitions = transitions; return this; diff --git a/src/main/java/me/piitex/renjava/gui/overlay/InputFieldOverlay.java b/src/main/java/me/piitex/renjava/gui/overlay/InputFieldOverlay.java index d67aa39..f2ba264 100644 --- a/src/main/java/me/piitex/renjava/gui/overlay/InputFieldOverlay.java +++ b/src/main/java/me/piitex/renjava/gui/overlay/InputFieldOverlay.java @@ -3,6 +3,8 @@ import javafx.scene.control.TextField; import me.piitex.renjava.api.loaders.FontLoader; import me.piitex.renjava.api.scenes.transitions.Transitions; +import me.piitex.renjava.gui.overlay.events.IOverlayClick; +import me.piitex.renjava.gui.overlay.events.IOverlayHover; public class InputFieldOverlay implements Overlay { private double x; @@ -12,6 +14,9 @@ public class InputFieldOverlay implements Overlay { private final FontLoader fontLoader; private Transitions transitions; + private IOverlayClick iOverlayClick; + private IOverlayHover iOverlayHover; + public InputFieldOverlay(double x, double y, FontLoader fontLoader) { this.x = x; this.y = y; @@ -83,6 +88,26 @@ public Transitions getTransition() { return transitions; } + @Override + public void setOnclick(IOverlayClick iOverlayClick) { + this.iOverlayClick = iOverlayClick; + } + + @Override + public void setOnHover(IOverlayHover iOverlayHover) { + this.iOverlayHover = iOverlayHover; + } + + @Override + public IOverlayClick getOnClick() { + return iOverlayClick; + } + + @Override + public IOverlayHover getOnHover() { + return iOverlayHover; + } + public void setTransitions(Transitions transitions) { this.transitions = transitions; } diff --git a/src/main/java/me/piitex/renjava/gui/overlay/Overlay.java b/src/main/java/me/piitex/renjava/gui/overlay/Overlay.java index 7a1efb8..4e86cee 100644 --- a/src/main/java/me/piitex/renjava/gui/overlay/Overlay.java +++ b/src/main/java/me/piitex/renjava/gui/overlay/Overlay.java @@ -1,6 +1,8 @@ package me.piitex.renjava.gui.overlay; import me.piitex.renjava.api.scenes.transitions.Transitions; +import me.piitex.renjava.gui.overlay.events.IOverlayClick; +import me.piitex.renjava.gui.overlay.events.IOverlayHover; public interface Overlay { @@ -29,4 +31,12 @@ public interface Overlay { void setHeight(double height); Transitions getTransition(); + + void setOnclick(IOverlayClick iOverlayClick); + + void setOnHover(IOverlayHover iOverlayHover); + + IOverlayClick getOnClick(); + + IOverlayHover getOnHover(); } diff --git a/src/main/java/me/piitex/renjava/gui/overlay/SliderOverlay.java b/src/main/java/me/piitex/renjava/gui/overlay/SliderOverlay.java new file mode 100644 index 0000000..00e9f67 --- /dev/null +++ b/src/main/java/me/piitex/renjava/gui/overlay/SliderOverlay.java @@ -0,0 +1,116 @@ +package me.piitex.renjava.gui.overlay; + +import me.piitex.renjava.api.scenes.transitions.Transitions; +import me.piitex.renjava.gui.overlay.events.IOverlayClick; +import me.piitex.renjava.gui.overlay.events.IOverlayHover; + +public class SliderOverlay implements Overlay { + private double x, y; + private double width, height; + private double scaleX, scaleY; + private double blockIncrement; + + private IOverlayHover iOverlayHover; + private IOverlayClick iOverlayClick; + + public SliderOverlay(int width, int height, double x, double y) { + this.width = width; + this.height = height; + this.x = x; + this.y = y; + } + + public double getBlockIncrement() { + return blockIncrement; + } + + public void setBlockIncrement(double blockIncrement) { + this.blockIncrement = blockIncrement; + } + + @Override + public double x() { + return x; + } + + @Override + public double y() { + return y; + } + + @Override + public void setX(double x) { + this.x = x; + } + + @Override + public void setY(double y) { + this.y = y; + } + + @Override + public double scaleX() { + return scaleX; + } + + @Override + public double scaleY() { + return scaleY; + } + + @Override + public void setScaleX(double scaleX) { + this.scaleX = scaleX; + } + + @Override + public void setScaleY(double scaleY) { + this.scaleY = scaleY; + } + + @Override + public double width() { + return width; + } + + @Override + public double height() { + return height; + } + + @Override + public void setWidth(double width) { + this.width = width; + } + + @Override + public void setHeight(double height) { + this.height = height; + } + + @Override + public Transitions getTransition() { + return null; + } + + @Override + public void setOnclick(IOverlayClick iOverlayClick) { + this.iOverlayClick = iOverlayClick; + } + + @Override + public void setOnHover(IOverlayHover iOverlayHover) { + this.iOverlayHover = iOverlayHover; + } + + @Override + public IOverlayClick getOnClick() { + return iOverlayClick; + } + + @Override + public IOverlayHover getOnHover() { + return iOverlayHover; + } + +} diff --git a/src/main/java/me/piitex/renjava/gui/overlay/TextFlowOverlay.java b/src/main/java/me/piitex/renjava/gui/overlay/TextFlowOverlay.java index aa2e109..72e843f 100644 --- a/src/main/java/me/piitex/renjava/gui/overlay/TextFlowOverlay.java +++ b/src/main/java/me/piitex/renjava/gui/overlay/TextFlowOverlay.java @@ -5,7 +5,10 @@ import javafx.scene.text.Font; import javafx.scene.text.Text; import javafx.scene.text.TextFlow; +import me.piitex.renjava.api.loaders.FontLoader; import me.piitex.renjava.api.scenes.transitions.Transitions; +import me.piitex.renjava.gui.overlay.events.IOverlayClick; +import me.piitex.renjava.gui.overlay.events.IOverlayHover; import java.util.LinkedList; @@ -15,7 +18,10 @@ public class TextFlowOverlay implements Overlay { private double scaleX, scaleY; private Transitions transitions; private Font font; - private Color textColor; + private Color textColor = Color.BLACK; + + private IOverlayClick iOverlayClick; + private IOverlayHover iOverlayHover; private LinkedList texts = new LinkedList<>(); @@ -27,6 +33,13 @@ public TextFlowOverlay(String text, int width, int height) { texts.add(new Text(text)); } + public TextFlowOverlay(String text, FontLoader fontLoader, int width, int height) { + this.texts.add(new Text(text)); + this.font = fontLoader.getFont(); + this.width = width; + this.height = height; + } + public TextFlowOverlay(Text text, int width, int height) { this.width = width; this.height = height; @@ -119,6 +132,27 @@ public Transitions getTransition() { return transitions; } + @Override + public void setOnclick(IOverlayClick iOverlayClick) { + this.iOverlayClick = iOverlayClick; + } + + @Override + public void setOnHover(IOverlayHover iOverlayHover) { + this.iOverlayHover = iOverlayHover; + } + + @Override + public IOverlayClick getOnClick() { + return iOverlayClick; + } + + @Override + public IOverlayHover getOnHover() { + return iOverlayHover; + } + + public void setTransitions(Transitions transitions) { this.transitions = transitions; } diff --git a/src/main/java/me/piitex/renjava/gui/overlay/TextOverlay.java b/src/main/java/me/piitex/renjava/gui/overlay/TextOverlay.java index 86f0647..29298e9 100644 --- a/src/main/java/me/piitex/renjava/gui/overlay/TextOverlay.java +++ b/src/main/java/me/piitex/renjava/gui/overlay/TextOverlay.java @@ -4,6 +4,8 @@ import javafx.scene.text.Text; import me.piitex.renjava.api.loaders.FontLoader; import me.piitex.renjava.api.scenes.transitions.Transitions; +import me.piitex.renjava.gui.overlay.events.IOverlayClick; +import me.piitex.renjava.gui.overlay.events.IOverlayHover; public class TextOverlay implements Overlay { private final Text text; @@ -14,6 +16,9 @@ public class TextOverlay implements Overlay { private double width, height; private Transitions transitions; + private IOverlayClick iOverlayClick; + private IOverlayHover iOverlayHover; + public TextOverlay(String text, double x, double y) { this.text = new Text(text); this.x = x; @@ -113,6 +118,26 @@ public Transitions getTransition() { return transitions; } + @Override + public void setOnclick(IOverlayClick iOverlayClick) { + this.iOverlayClick = iOverlayClick; + } + + @Override + public void setOnHover(IOverlayHover iOverlayHover) { + this.iOverlayHover = iOverlayHover; + } + + @Override + public IOverlayClick getOnClick() { + return iOverlayClick; + } + + @Override + public IOverlayHover getOnHover() { + return iOverlayHover; + } + public void setTransitions(Transitions transitions) { this.transitions = transitions; } diff --git a/src/main/java/me/piitex/renjava/gui/overlay/events/IOverlayClick.java b/src/main/java/me/piitex/renjava/gui/overlay/events/IOverlayClick.java new file mode 100644 index 0000000..3c4b2c2 --- /dev/null +++ b/src/main/java/me/piitex/renjava/gui/overlay/events/IOverlayClick.java @@ -0,0 +1,8 @@ +package me.piitex.renjava.gui.overlay.events; + +import me.piitex.renjava.events.types.OverlayClickEvent; + +public interface IOverlayClick { + + void onClick(OverlayClickEvent event); +} diff --git a/src/main/java/me/piitex/renjava/gui/overlay/events/IOverlayHover.java b/src/main/java/me/piitex/renjava/gui/overlay/events/IOverlayHover.java new file mode 100644 index 0000000..adf4606 --- /dev/null +++ b/src/main/java/me/piitex/renjava/gui/overlay/events/IOverlayHover.java @@ -0,0 +1,8 @@ +package me.piitex.renjava.gui.overlay.events; + +import me.piitex.renjava.events.types.OverlayHoverEvent; + +public interface IOverlayHover { + + void onHover(OverlayHoverEvent event); +} diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java index 313bf8b..0f71203 100644 --- a/src/main/java/module-info.java +++ b/src/main/java/module-info.java @@ -42,6 +42,7 @@ exports me.piitex.renjava.api.scenes.animation; exports me.piitex.renjava.addons; exports me.piitex.renjava.loggers; + exports me.piitex.renjava.gui.overlay.events; opens me.piitex.renjava.loggers; exports me.piitex.renjava.api; opens me.piitex.renjava.api; From e9b98c3f0cc2f4158a1f3a8397990b930e331a8f Mon Sep 17 00:00:00 2001 From: Hackusate_PvP Date: Thu, 16 May 2024 07:54:56 -0500 Subject: [PATCH 03/30] Re-organized parameter order for ButtonOverlay. --- src/main/java/me/piitex/renjava/RenJava.java | 12 ++++++------ .../api/scenes/types/choices/ChoiceScene.java | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/me/piitex/renjava/RenJava.java b/src/main/java/me/piitex/renjava/RenJava.java index fde09ac..9c4a807 100644 --- a/src/main/java/me/piitex/renjava/RenJava.java +++ b/src/main/java/me/piitex/renjava/RenJava.java @@ -378,11 +378,11 @@ public Menu buildSideMenu() { Color hoverColor = getConfiguration().getHoverColor(); - ButtonOverlay startButton = new ButtonOverlay("menu-start-button", "Start", uiFont, Color.BLACK, Color.TRANSPARENT, Color.TRANSPARENT, hoverColor, 1, 1); - ButtonOverlay loadButton = new ButtonOverlay("menu-load-button", "Load", uiFont, Color.BLACK, Color.TRANSPARENT, Color.TRANSPARENT, hoverColor, 1, 1); - ButtonOverlay saveButton = new ButtonOverlay("menu-save-button", "Save", uiFont, Color.BLACK, Color.TRANSPARENT, Color.TRANSPARENT, hoverColor, 1, 1); - ButtonOverlay optionsButton = new ButtonOverlay("menu-preference-button", "Preferences", uiFont, Color.BLACK, Color.TRANSPARENT, Color.TRANSPARENT, hoverColor, 1, 1); - ButtonOverlay aboutButton = new ButtonOverlay("menu-about-button", "About", uiFont, Color.BLACK, Color.TRANSPARENT, Color.TRANSPARENT, hoverColor, 1, 1); + ButtonOverlay startButton = new ButtonOverlay("menu-start-button", "Start", Color.BLACK, uiFont, Color.TRANSPARENT, Color.TRANSPARENT, hoverColor, 1, 1); + ButtonOverlay loadButton = new ButtonOverlay("menu-load-button", "Load", Color.BLACK, uiFont, Color.TRANSPARENT, Color.TRANSPARENT, hoverColor, 1, 1); + ButtonOverlay saveButton = new ButtonOverlay("menu-save-button", "Save", Color.BLACK, uiFont, Color.TRANSPARENT, Color.TRANSPARENT, hoverColor, 1, 1); + ButtonOverlay optionsButton = new ButtonOverlay("menu-preference-button", "Preferences", Color.BLACK, uiFont, Color.TRANSPARENT, Color.TRANSPARENT, hoverColor, 1, 1); + ButtonOverlay aboutButton = new ButtonOverlay("menu-about-button", "About", Color.BLACK, uiFont, Color.TRANSPARENT, Color.TRANSPARENT, hoverColor, 1, 1); // Create vbox for the buttons. You can also do an HBox VerticalLayout layout = new VerticalLayout(400, 500); @@ -441,7 +441,7 @@ public Menu buildLoadMenu(int page) { HorizontalLayout pageLayout = new HorizontalLayout(100, 100); while (pageIndex < pageViewMax) { pageIndex++; - ButtonOverlay pageButton = new ButtonOverlay("page-" + pageIndex, pageIndex + "", new FontLoader(getConfiguration().getUiFont(), 26).getFont(), Color.BLACK, 1, 1); + ButtonOverlay pageButton = new ButtonOverlay("page-" + pageIndex, pageIndex + "", Color.BLACK, new FontLoader(getConfiguration().getUiFont(), 26).getFont(), 1, 1); pageButton.setBackgroundColor(Color.TRANSPARENT); pageButton.setBorderColor(Color.TRANSPARENT); if (page == pageIndex) { diff --git a/src/main/java/me/piitex/renjava/api/scenes/types/choices/ChoiceScene.java b/src/main/java/me/piitex/renjava/api/scenes/types/choices/ChoiceScene.java index dcfde87..ce36992 100644 --- a/src/main/java/me/piitex/renjava/api/scenes/types/choices/ChoiceScene.java +++ b/src/main/java/me/piitex/renjava/api/scenes/types/choices/ChoiceScene.java @@ -216,7 +216,7 @@ private Button getChoiceButton(Choice choice, Image image) { @NotNull private static ButtonOverlay getButtonOverlay(Choice choice) { - ButtonOverlay buttonOverlay = new ButtonOverlay(choice.getId(), choice.getText(), RenJava.getInstance().getConfiguration().getChoiceButtonFont().getFont(), Color.BLACK, 0, 0, 1, 1); + ButtonOverlay buttonOverlay = new ButtonOverlay(choice.getId(), choice.getText(), Color.BLACK, RenJava.getInstance().getConfiguration().getChoiceButtonFont().getFont(), 0, 0, 1, 1); buttonOverlay.setBorderColor(Color.TRANSPARENT); buttonOverlay.setBackgroundColor(Color.TRANSPARENT); buttonOverlay.setHover(true); From 97bd14779473d06145d8da052e7f7e7d8c550ea9 Mon Sep 17 00:00:00 2001 From: Hackusate_PvP Date: Thu, 16 May 2024 07:55:10 -0500 Subject: [PATCH 04/30] Deleted files. --- changes/CHANGELOG.md | 27 -------------------------- src/main/resources/game/css/choice.css | 11 ----------- 2 files changed, 38 deletions(-) delete mode 100644 changes/CHANGELOG.md delete mode 100644 src/main/resources/game/css/choice.css diff --git a/changes/CHANGELOG.md b/changes/CHANGELOG.md deleted file mode 100644 index f35f5e5..0000000 --- a/changes/CHANGELOG.md +++ /dev/null @@ -1,27 +0,0 @@ -All changes regarding the project and API will be documented here. The latest version wIll always be on top. - -Changes here are made when the RenJava project was still private. -## Build 0.0.261 -- Expanded documentation. -- If a [Character]() class implements [PersistentData]() the class wll automatically register itself as a data class. -- [Story]()'s will now update and refresh automatically. - - Added abstract void `init` which is used to create the scenes for the story. - - Stories have been reverted back to abstraction. More testing will be required before making a final decision on the layout. -- - -## Build 0.0.153 -- Added [Container]() which supports layouts and additional alignment features. - - Started implementation of the save functionality. All classes which contain data you want to save must be implemented with `PersistentData`. - All fields that contain the data you want to save cannot be final and must be annotated with `@Data`. -- Re-structured [Story]() class. Story class use to be abstract however upon testing and feedback it will work the same as scenes. JavaDoc has been updated to reflect these changes. -- The RenJava [Player]() will now automatically track the stories when they start. -- Expanded [StageType]() -- Duration for splash-screens is now configurable. -- Completed buttons for choices in the [ChoiceScene]() -- Expanded documentation. - -### TODO / BUGS -- PreferenceScreen still incomplete. -- Tracks not fully implemented. -- Save/Load screens not implemented. -- RPA files not supported (will be the case for the foreseeable future) \ No newline at end of file diff --git a/src/main/resources/game/css/choice.css b/src/main/resources/game/css/choice.css deleted file mode 100644 index 1d3086c..0000000 --- a/src/main/resources/game/css/choice.css +++ /dev/null @@ -1,11 +0,0 @@ -.button{ - -fx-border-color: transparent; - -fx-border-width: 0; - -fx-background-radius: 0; - -fx-background-color: transparent; - -fx-text-fill: white; -} - .button:hover { - -fx-text-fill: white; - -fix-background-image:url("../images/gui/button/choice_hover_background.png") -} From 7bddc1dc04c355ec25e2766b5ff23a55bb412fd7 Mon Sep 17 00:00:00 2001 From: Hackusate_PvP Date: Thu, 16 May 2024 07:55:27 -0500 Subject: [PATCH 05/30] Fixed READEME.md typo. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d1655b3..3a51fb2 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ Visual novel game engine based off of [RenPy](https://www.renpy.org/) built with **Community** - [Website]() (Not yet created), [Discord]() (Not yet created), [YouTube](https://www.youtube.com/channel/UC4iv_X0Pi8FoHFMUHBkHw1A) --[HeroAdventure](https://github.com/HackusatePvP/HeroAdventure) This an example project that is used for testing the framework. +- [HeroAdventure](https://github.com/HackusatePvP/HeroAdventure) This an example project that is used for testing the framework. ## Project Requirements - [Java-17](https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html) (You can typically download this within your IDE) From 9a02bd5bf057004b5d73dfd3194413fe5c1cc3d3 Mon Sep 17 00:00:00 2001 From: Hackusate_PvP Date: Mon, 20 May 2024 17:31:34 -0500 Subject: [PATCH 06/30] Fixed about screen and added OverlayEventListener. --- src/main/java/me/piitex/renjava/RenJava.java | 33 +++++++--- .../defaults/MenuClickEventListener.java | 50 +------------- .../events/defaults/OverlayEventListener.java | 65 +++++++++++++++++++ 3 files changed, 91 insertions(+), 57 deletions(-) create mode 100644 src/main/java/me/piitex/renjava/events/defaults/OverlayEventListener.java diff --git a/src/main/java/me/piitex/renjava/RenJava.java b/src/main/java/me/piitex/renjava/RenJava.java index 9c4a807..e5656a5 100644 --- a/src/main/java/me/piitex/renjava/RenJava.java +++ b/src/main/java/me/piitex/renjava/RenJava.java @@ -4,6 +4,7 @@ import javafx.application.Platform; import javafx.scene.paint.Color; import javafx.scene.text.Font; +import javafx.scene.text.Text; import javafx.stage.Stage; import javafx.stage.StageStyle; import me.piitex.renjava.addons.Addon; @@ -24,10 +25,7 @@ import me.piitex.renjava.events.Event; import me.piitex.renjava.events.EventListener; import me.piitex.renjava.events.Listener; -import me.piitex.renjava.events.defaults.GameFlowEventListener; -import me.piitex.renjava.events.defaults.MenuClickEventListener; -import me.piitex.renjava.events.defaults.ScenesEventListener; -import me.piitex.renjava.events.defaults.StoryHandlerEventListener; +import me.piitex.renjava.events.defaults.*; import me.piitex.renjava.events.types.ShutdownEvent; import me.piitex.renjava.gui.exceptions.ImageNotFoundException; @@ -36,6 +34,7 @@ import me.piitex.renjava.gui.layouts.impl.VerticalLayout; import me.piitex.renjava.gui.overlay.ButtonOverlay; import me.piitex.renjava.gui.StageType; +import me.piitex.renjava.gui.overlay.HyperlinkOverlay; import me.piitex.renjava.gui.overlay.ImageOverlay; import me.piitex.renjava.gui.overlay.TextFlowOverlay; import me.piitex.renjava.loggers.RenLogger; @@ -118,6 +117,7 @@ protected void init() { this.registerListener(new GameFlowEventListener()); this.registerListener(new StoryHandlerEventListener()); this.registerListener(new ScenesEventListener()); + registerListener(new OverlayEventListener()); this.registerData(player); this.registerData(tracks); new RenLoader(this); @@ -479,18 +479,35 @@ public Menu buildSettingsMenu() { } public Menu buildAboutMenu() { - Menu menu = new Menu(1920, 1080, new ImageOverlay("gui/overlay/main_menu.png")); + Menu menu = new Menu(1920, 1080, new ImageOverlay("gui/main_menu.png")); - Font font = new FontLoader(getConfiguration().getDefaultFont().getFont(), 20).getFont(); + Font font = new FontLoader(getConfiguration().getDefaultFont().getFont(), 24).getFont(); TextFlowOverlay aboutText = new TextFlowOverlay("RenJava is inspired by RenPy and built with JavaFX. This project is free for commercial use and open sourced." + - "Credits to the contributors for JavaFX for making this project possible. Credits to RenPy for making the best visual novel engine.", 500, 500); + "Credits to the contributors for JavaFX for making this project possible. Credits to RenPy for making the best visual novel engine. " + + "RenJava is licensed under the GNU GPLv3 by using and distributing this software you agree to these terms. " + + "Additionally, RenJava uses software which may have additional licenses, all of which are open sourced. ", 1300, 500); aboutText.setFont(font); aboutText.setX(500); aboutText.setY(300); - menu.addOverlay(aboutText); + TextFlowOverlay buildInfo = new TextFlowOverlay("Do not re-distribute this software without explicit permission from the author.",1300, 700); + buildInfo.setX(500); + buildInfo.setY(600); + buildInfo.setFont(font); + Text spacer = new Text(System.lineSeparator()); + buildInfo.getTexts().add(spacer); + buildInfo.getTexts().add(new Text("RenJava Build Version: " + getBuildVersion())); + buildInfo.getTexts().add(spacer); + buildInfo.getTexts().add(new Text("Game Version: " + getVersion())); + buildInfo.getTexts().add(spacer); + buildInfo.getTexts().add(new Text("Author: " + getAuthor())); + menu.addOverlay(buildInfo); + + HyperlinkOverlay renJavaLink = new HyperlinkOverlay("You can download RenJava for free here.", "https://github.com/HackusatePvP/RenJava", new FontLoader(font, 24), 500, 750); + menu.addOverlay(renJavaLink); + return menu; } diff --git a/src/main/java/me/piitex/renjava/events/defaults/MenuClickEventListener.java b/src/main/java/me/piitex/renjava/events/defaults/MenuClickEventListener.java index e31818d..fb14938 100644 --- a/src/main/java/me/piitex/renjava/events/defaults/MenuClickEventListener.java +++ b/src/main/java/me/piitex/renjava/events/defaults/MenuClickEventListener.java @@ -46,6 +46,7 @@ public void onButtonClick(ButtonClickEvent event) { settings.addMenu(renJava.buildSideMenu()); settings.render(); + renJava.setStage(renJava.getStage(), StageType.OPTIONS_MENU); } if (button.getId().equalsIgnoreCase("menu-about-button")) { Menu about = renJava.buildAboutMenu(); @@ -113,53 +114,4 @@ public void onButtonClick(ButtonClickEvent event) { } } - @Listener - public void onOverlayClick(OverlayClickEvent event) { - Overlay overlay = event.getOverlay(); - - if (overlay.getOnClick() != null) { - overlay.getOnClick().onClick(event); - } - } - - @Listener - public void onOverlayHover(OverlayHoverEvent event) { - Overlay overlay = event.getOverlay(); - - if (overlay.getOnHover() != null) { - overlay.getOnHover().onHover(event); - } - - if (overlay instanceof ButtonOverlay buttonOverlay) { - Button button = buttonOverlay.getButton(); - - if (buttonOverlay.isHover()) { - if (buttonOverlay.getHoverColor() != null) { - button.setTextFill(buttonOverlay.getHoverColor()); - } - if (buttonOverlay.getHoverImage() != null) { - try { - button.setGraphic(new ImageView(buttonOverlay.getHoverImage().build())); - } catch (ImageNotFoundException e) { - RenLogger.LOGGER.error(e.getMessage()); - } - } - } - } - } - - @Listener - public void onOverlayExit(OverlayExitEvent event) { - Overlay overlay = event.getOverlay(); - - if (overlay instanceof ButtonOverlay buttonOverlay) { - Button button = buttonOverlay.getButton(); - button.setTextFill(buttonOverlay.getTextFill()); - button.setStyle(button.getStyle()); // Re-init the style (hopefully this forces the button back to normal.) - if (buttonOverlay.getImage() != null) { - button.setGraphic(new ImageView(buttonOverlay.getImage().getImage())); - } - } - } - } diff --git a/src/main/java/me/piitex/renjava/events/defaults/OverlayEventListener.java b/src/main/java/me/piitex/renjava/events/defaults/OverlayEventListener.java new file mode 100644 index 0000000..a65aff3 --- /dev/null +++ b/src/main/java/me/piitex/renjava/events/defaults/OverlayEventListener.java @@ -0,0 +1,65 @@ +package me.piitex.renjava.events.defaults; + +import javafx.scene.control.Button; +import javafx.scene.image.ImageView; +import me.piitex.renjava.events.EventListener; +import me.piitex.renjava.events.Listener; +import me.piitex.renjava.events.types.OverlayClickEvent; +import me.piitex.renjava.events.types.OverlayExitEvent; +import me.piitex.renjava.events.types.OverlayHoverEvent; +import me.piitex.renjava.gui.exceptions.ImageNotFoundException; +import me.piitex.renjava.gui.overlay.ButtonOverlay; +import me.piitex.renjava.gui.overlay.Overlay; +import me.piitex.renjava.loggers.RenLogger; + +public class OverlayEventListener implements EventListener { + + @Listener + public void onOverlayClick(OverlayClickEvent event) { + Overlay overlay = event.getOverlay(); + + if (overlay.getOnClick() != null) { + overlay.getOnClick().onClick(event); + } + } + + @Listener + public void onOverlayHover(OverlayHoverEvent event) { + Overlay overlay = event.getOverlay(); + + if (overlay.getOnHover() != null) { + overlay.getOnHover().onHover(event); + } + + if (overlay instanceof ButtonOverlay buttonOverlay) { + Button button = buttonOverlay.getButton(); + + if (buttonOverlay.isHover()) { + if (buttonOverlay.getHoverColor() != null) { + button.setTextFill(buttonOverlay.getHoverColor()); + } + if (buttonOverlay.getHoverImage() != null) { + try { + button.setGraphic(new ImageView(buttonOverlay.getHoverImage().build())); + } catch (ImageNotFoundException e) { + RenLogger.LOGGER.error(e.getMessage()); + } + } + } + } + } + + @Listener + public void onOverlayExit(OverlayExitEvent event) { + Overlay overlay = event.getOverlay(); + + if (overlay instanceof ButtonOverlay buttonOverlay) { + Button button = buttonOverlay.getButton(); + button.setTextFill(buttonOverlay.getTextFill()); + button.setStyle(button.getStyle()); // Re-init the style (hopefully this forces the button back to normal.) + if (buttonOverlay.getImage() != null) { + button.setGraphic(new ImageView(buttonOverlay.getImage().getImage())); + } + } + } +} From 313670ae9bbc97b145e9f76648483da21ebf0545 Mon Sep 17 00:00:00 2001 From: Hackusate_PvP Date: Mon, 20 May 2024 17:31:56 -0500 Subject: [PATCH 07/30] Added GNU GPLv3 license. --- LICENSE.md | 674 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 674 insertions(+) create mode 100644 LICENSE.md diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..6b111d1 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + +Copyright (C) 2007 Free Software Foundation, Inc. +Everyone is permitted to copy and distribute verbatim copies +of this license document, but changing it is not allowed. + + Preamble + +The GNU General Public License is a free, copyleft license for +software and other kinds of works. + +The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + +When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + +To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + +For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + +Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + +For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + +Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + +Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + +The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + +0. Definitions. + +"This License" refers to version 3 of the GNU General Public License. + +"Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + +"The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + +To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + +A "covered work" means either the unmodified Program or a work based +on the Program. + +To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + +To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + +An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + +1. Source Code. + +The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + +A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + +The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + +The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + +The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + +The Corresponding Source for a work in source code form is that +same work. + +2. Basic Permissions. + +All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + +You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + +Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + +3. Protecting Users' Legal Rights From Anti-Circumvention Law. + +No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + +When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + +4. Conveying Verbatim Copies. + +You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + +You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + +5. Conveying Modified Source Versions. + +You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + +A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + +6. Conveying Non-Source Forms. + +You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + +A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + +A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + +"Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + +If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + +The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + +Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + +7. Additional Terms. + +"Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + +When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + +Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + +All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + +If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + +Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + +8. Termination. + +You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + +However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + +Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + +Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + +9. Acceptance Not Required for Having Copies. + +You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + +10. Automatic Licensing of Downstream Recipients. + +Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + +An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + +You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + +11. Patents. + +A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + +A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + +Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + +In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + +If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + +If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + +A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + +Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + +12. No Surrender of Others' Freedom. + +If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + +13. Use with the GNU Affero General Public License. + +Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + +14. Revised Versions of this License. + +The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + +If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + +Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + +15. Disclaimer of Warranty. + +THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + +16. Limitation of Liability. + +IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + +17. Interpretation of Sections 15 and 16. + +If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + +If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + +To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + +If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + +You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + +The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. From 0bef1db1362af8f352faa074e153e6912c9717ec Mon Sep 17 00:00:00 2001 From: Hackusate_PvP Date: Mon, 20 May 2024 17:32:24 -0500 Subject: [PATCH 08/30] Fonts will no longer preload when application starts. --- src/main/java/me/piitex/renjava/RenLoader.java | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/src/main/java/me/piitex/renjava/RenLoader.java b/src/main/java/me/piitex/renjava/RenLoader.java index 79ce034..0056c24 100644 --- a/src/main/java/me/piitex/renjava/RenLoader.java +++ b/src/main/java/me/piitex/renjava/RenLoader.java @@ -8,7 +8,6 @@ import me.piitex.renjava.api.music.Track; import me.piitex.renjava.configuration.SettingsProperties; import me.piitex.renjava.loggers.RenLogger; -; public class RenLoader { private final RenJava renJava; @@ -32,8 +31,6 @@ public RenLoader(RenJava renJava) { private void setupMain() { RenLogger.LOGGER.info("Checking game environment..."); - - File gameDirectory = new File(System.getProperty("user.dir") + "/game/"); if (gameDirectory.mkdir()) { RenLogger.LOGGER.error("Game directory does not exist. The game will not work properly, please move all assets into the newly created game directory."); @@ -43,11 +40,6 @@ private void setupMain() { if (renJavaDirectory.mkdir()) { RenLogger.LOGGER.warn("RenJava folder does not exist. User settings will be reset to defaults."); } - for (File file : new File(System.getProperty("user.dir")).listFiles()) { - if (file.getName().endsWith(".txt.lck")) { - file.delete(); - } - } } private void setupGame() { @@ -73,16 +65,6 @@ private void setupGame() { if (fontsDirectory.mkdir()) { RenLogger.LOGGER.warn("Fonts folder does not exist, creating..."); } - - RenLogger.LOGGER.info("Loading fonts..."); - int fonts = 0; - for (File file : fontsDirectory.listFiles()) { - if (file.getName().endsWith(".ttf")) { - fonts++; - new FontLoader(file.getName()); - } - } - RenLogger.LOGGER.info("Loaded " + fonts + " font(s)."); File cssDirectory = new File(directory, "/css/"); cssDirectory.mkdir(); } From 6f6acda40fd89069a67c7a0ce3144a7a98df82f3 Mon Sep 17 00:00:00 2001 From: Hackusate_PvP Date: Mon, 20 May 2024 17:34:30 -0500 Subject: [PATCH 09/30] Separated positional overlay code into regions. Added HyperlinkOverlay --- .../java/me/piitex/renjava/gui/Element.java | 43 ++++++--- src/main/java/me/piitex/renjava/gui/Menu.java | 7 +- .../renjava/gui/overlay/ButtonOverlay.java | 2 +- .../renjava/gui/overlay/HyperlinkOverlay.java | 93 +++++++++++++++++++ .../renjava/gui/overlay/ImageOverlay.java | 2 +- .../gui/overlay/InputFieldOverlay.java | 2 +- .../piitex/renjava/gui/overlay/Overlay.java | 17 ---- .../me/piitex/renjava/gui/overlay/Region.java | 19 ++++ .../renjava/gui/overlay/SliderOverlay.java | 63 ++++--------- .../renjava/gui/overlay/TextFlowOverlay.java | 9 +- .../renjava/gui/overlay/TextOverlay.java | 2 +- 11 files changed, 177 insertions(+), 82 deletions(-) create mode 100644 src/main/java/me/piitex/renjava/gui/overlay/HyperlinkOverlay.java create mode 100644 src/main/java/me/piitex/renjava/gui/overlay/Region.java diff --git a/src/main/java/me/piitex/renjava/gui/Element.java b/src/main/java/me/piitex/renjava/gui/Element.java index 51c06dc..947a7d2 100644 --- a/src/main/java/me/piitex/renjava/gui/Element.java +++ b/src/main/java/me/piitex/renjava/gui/Element.java @@ -3,6 +3,7 @@ import javafx.scene.Node; import javafx.scene.control.Button; +import javafx.scene.control.Hyperlink; import javafx.scene.control.Slider; import javafx.scene.image.Image; import javafx.scene.image.ImageView; @@ -26,18 +27,21 @@ public class Element { public Element(Overlay overlay) { this.overlay = overlay; //FIXME: When scaling the height and width the x and y positions need to be scaled to match the modified width and height. - double scaleX = overlay.scaleX(); - double scaleY = overlay.scaleY(); - if (scaleX > 0) { - overlay.setWidth(overlay.width() * scaleX); - overlay.setX(overlay.x() * scaleX); - } - if (scaleY > 0) { - overlay.setHeight(overlay.height() * scaleY); - overlay.setY(overlay.y() * scaleY); + + if (overlay instanceof Region region) { + double scaleX = region.scaleX(); + double scaleY = region.scaleY(); + if (scaleX > 0) { + region.setWidth(region.width() * scaleX); + overlay.setX(overlay.x() * scaleX); + } + if (scaleY > 0) { + region.setHeight(region.height() * scaleY); + overlay.setY(overlay.y() * scaleY); + } } if (overlay instanceof ImageOverlay imageOverlay) { - RenLogger.LOGGER.debug("Processing " + imageOverlay.getFileName()); + RenLogger.LOGGER.debug("Processing {}", imageOverlay.getFileName()); Image image = imageOverlay.getImage(); ImageView imageView = new ImageView(image); imageView.setPreserveRatio(true); @@ -70,10 +74,23 @@ public Element(Overlay overlay) { textFlow.setTranslateY(textFlowOverlay.y()); this.node = textFlow; } else if (overlay instanceof SliderOverlay sliderOverlay) { - Slider slider = new Slider(sliderOverlay.width(), sliderOverlay.height(), 4); - slider.setPrefSize(sliderOverlay.width(), sliderOverlay.height()); - slider.setBlockIncrement(sliderOverlay.getBlockIncrement()); + //TODO Finish sliders + Slider slider = new Slider(sliderOverlay.getMinValue(), sliderOverlay.getMaxValue(), sliderOverlay.getCurrentValue()); + slider.setTranslateX(sliderOverlay.x()); + slider.setTranslateY(sliderOverlay.y()); this.node = slider; + } else if (overlay instanceof HyperlinkOverlay hyperlinkOverlay) { + Hyperlink hyperlink = new Hyperlink(hyperlinkOverlay.getLabel()); + hyperlink.setTranslateX(hyperlinkOverlay.x()); + hyperlink.setTranslateY(hyperlinkOverlay.y()); + if (hyperlinkOverlay.getFont() != null) { + hyperlink.setFont(hyperlinkOverlay.getFont().getFont()); + } + hyperlink.setOnAction(actionEvent -> { + RenJava.getInstance().getHost().showDocument(hyperlinkOverlay.getLink()); + }); + + this.node = hyperlink; } // Handle specific input diff --git a/src/main/java/me/piitex/renjava/gui/Menu.java b/src/main/java/me/piitex/renjava/gui/Menu.java index e977d55..d49d5ad 100644 --- a/src/main/java/me/piitex/renjava/gui/Menu.java +++ b/src/main/java/me/piitex/renjava/gui/Menu.java @@ -7,6 +7,7 @@ import javafx.stage.Stage; import me.piitex.renjava.RenJava; +import me.piitex.renjava.gui.overlay.Region; import me.piitex.renjava.loggers.RenLogger; import me.piitex.renjava.api.scenes.RenScene; import me.piitex.renjava.api.scenes.transitions.Transitions; @@ -249,8 +250,10 @@ public Pane render(@Nullable Pane root, @Nullable RenScene renScene, boolean ren RenLogger.LOGGER.info("Rendering overlays..."); for (Overlay overlay : overlays) { - overlay.setScaleX(scaleX); - overlay.setScaleY(scaleY); + if (overlay instanceof Region region) { + region.setScaleX(scaleX); + region.setScaleY(scaleY); + } new Element(overlay).render(root); } diff --git a/src/main/java/me/piitex/renjava/gui/overlay/ButtonOverlay.java b/src/main/java/me/piitex/renjava/gui/overlay/ButtonOverlay.java index fc4fb36..16bd529 100644 --- a/src/main/java/me/piitex/renjava/gui/overlay/ButtonOverlay.java +++ b/src/main/java/me/piitex/renjava/gui/overlay/ButtonOverlay.java @@ -20,7 +20,7 @@ import java.util.concurrent.atomic.AtomicReference; -public class ButtonOverlay implements Overlay { +public class ButtonOverlay implements Overlay, Region { private Button button; private Transitions transitions; private Menu menu; diff --git a/src/main/java/me/piitex/renjava/gui/overlay/HyperlinkOverlay.java b/src/main/java/me/piitex/renjava/gui/overlay/HyperlinkOverlay.java new file mode 100644 index 0000000..7c9b2c4 --- /dev/null +++ b/src/main/java/me/piitex/renjava/gui/overlay/HyperlinkOverlay.java @@ -0,0 +1,93 @@ +package me.piitex.renjava.gui.overlay; + +import me.piitex.renjava.api.loaders.FontLoader; +import me.piitex.renjava.api.scenes.transitions.Transitions; +import me.piitex.renjava.gui.overlay.events.IOverlayClick; +import me.piitex.renjava.gui.overlay.events.IOverlayHover; + +public class HyperlinkOverlay implements Overlay { + private final String label; + private final String link; + private FontLoader font; + private double x, y; + + private Transitions transitions; + private IOverlayHover iOverlayHover; + private IOverlayClick iOverlayClick; + + public HyperlinkOverlay(String label, String link, double x, double y) { + this.label = label; + this.link = link; + this.x = x; + this.y = y; + } + + public HyperlinkOverlay(String label, String link, FontLoader font, double x, double y) { + this.label = label; + this.link = link; + this.font = font; + this.x = x; + this.y = y; + } + + public String getLabel() { + return label; + } + + public String getLink() { + return link; + } + + public FontLoader getFont() { + return font; + } + + public void setFont(FontLoader font) { + this.font = font; + } + + @Override + public double x() { + return x; + } + + @Override + public double y() { + return y; + } + + @Override + public void setX(double x) { + this.x = x; + } + + @Override + public void setY(double y) { + this.y = y; + } + + @Override + public Transitions getTransition() { + return transitions; + } + + @Override + public void setOnclick(IOverlayClick iOverlayClick) { + this.iOverlayClick = iOverlayClick; + } + + @Override + public void setOnHover(IOverlayHover iOverlayHover) { + this.iOverlayHover = iOverlayHover; + } + + @Override + public IOverlayClick getOnClick() { + return iOverlayClick; + } + + @Override + public IOverlayHover getOnHover() { + return iOverlayHover; + } +} diff --git a/src/main/java/me/piitex/renjava/gui/overlay/ImageOverlay.java b/src/main/java/me/piitex/renjava/gui/overlay/ImageOverlay.java index 72c1f01..6aaddd2 100644 --- a/src/main/java/me/piitex/renjava/gui/overlay/ImageOverlay.java +++ b/src/main/java/me/piitex/renjava/gui/overlay/ImageOverlay.java @@ -10,7 +10,7 @@ import me.piitex.renjava.api.scenes.transitions.Transitions; import me.piitex.renjava.gui.exceptions.ImageNotFoundException; -public class ImageOverlay implements Overlay { +public class ImageOverlay implements Overlay, Region { private Image image; private double x; private double y; diff --git a/src/main/java/me/piitex/renjava/gui/overlay/InputFieldOverlay.java b/src/main/java/me/piitex/renjava/gui/overlay/InputFieldOverlay.java index f2ba264..abd57a7 100644 --- a/src/main/java/me/piitex/renjava/gui/overlay/InputFieldOverlay.java +++ b/src/main/java/me/piitex/renjava/gui/overlay/InputFieldOverlay.java @@ -6,7 +6,7 @@ import me.piitex.renjava.gui.overlay.events.IOverlayClick; import me.piitex.renjava.gui.overlay.events.IOverlayHover; -public class InputFieldOverlay implements Overlay { +public class InputFieldOverlay implements Overlay, Region { private double x; private double y; private double scaleX, scaleY; diff --git a/src/main/java/me/piitex/renjava/gui/overlay/Overlay.java b/src/main/java/me/piitex/renjava/gui/overlay/Overlay.java index 4e86cee..91a158a 100644 --- a/src/main/java/me/piitex/renjava/gui/overlay/Overlay.java +++ b/src/main/java/me/piitex/renjava/gui/overlay/Overlay.java @@ -5,7 +5,6 @@ import me.piitex.renjava.gui.overlay.events.IOverlayHover; public interface Overlay { - double x(); double y(); @@ -14,22 +13,6 @@ public interface Overlay { void setY(double y); - double scaleX(); - - double scaleY(); - - void setScaleX(double scaleX); - - void setScaleY(double scaleY); - - double width(); - - double height(); - - void setWidth(double width); - - void setHeight(double height); - Transitions getTransition(); void setOnclick(IOverlayClick iOverlayClick); diff --git a/src/main/java/me/piitex/renjava/gui/overlay/Region.java b/src/main/java/me/piitex/renjava/gui/overlay/Region.java new file mode 100644 index 0000000..376e020 --- /dev/null +++ b/src/main/java/me/piitex/renjava/gui/overlay/Region.java @@ -0,0 +1,19 @@ +package me.piitex.renjava.gui.overlay; + +public interface Region { + double scaleX(); + + double scaleY(); + + void setScaleX(double scaleX); + + void setScaleY(double scaleY); + + double width(); + + double height(); + + void setWidth(double width); + + void setHeight(double height); +} diff --git a/src/main/java/me/piitex/renjava/gui/overlay/SliderOverlay.java b/src/main/java/me/piitex/renjava/gui/overlay/SliderOverlay.java index 00e9f67..1d85585 100644 --- a/src/main/java/me/piitex/renjava/gui/overlay/SliderOverlay.java +++ b/src/main/java/me/piitex/renjava/gui/overlay/SliderOverlay.java @@ -5,21 +5,34 @@ import me.piitex.renjava.gui.overlay.events.IOverlayHover; public class SliderOverlay implements Overlay { + private final double maxValue, minValue, currentValue; private double x, y; - private double width, height; - private double scaleX, scaleY; private double blockIncrement; private IOverlayHover iOverlayHover; private IOverlayClick iOverlayClick; - public SliderOverlay(int width, int height, double x, double y) { - this.width = width; - this.height = height; + public SliderOverlay(double maxValue, double minValue, double currentValue, double x, double y) { + // Sliders don't have regions like images or buttons do. + this.maxValue = maxValue; + this.minValue = minValue; + this.currentValue = currentValue; this.x = x; this.y = y; } + public double getMaxValue() { + return maxValue; + } + + public double getMinValue() { + return minValue; + } + + public double getCurrentValue() { + return currentValue; + } + public double getBlockIncrement() { return blockIncrement; } @@ -48,46 +61,6 @@ public void setY(double y) { this.y = y; } - @Override - public double scaleX() { - return scaleX; - } - - @Override - public double scaleY() { - return scaleY; - } - - @Override - public void setScaleX(double scaleX) { - this.scaleX = scaleX; - } - - @Override - public void setScaleY(double scaleY) { - this.scaleY = scaleY; - } - - @Override - public double width() { - return width; - } - - @Override - public double height() { - return height; - } - - @Override - public void setWidth(double width) { - this.width = width; - } - - @Override - public void setHeight(double height) { - this.height = height; - } - @Override public Transitions getTransition() { return null; diff --git a/src/main/java/me/piitex/renjava/gui/overlay/TextFlowOverlay.java b/src/main/java/me/piitex/renjava/gui/overlay/TextFlowOverlay.java index 72e843f..269665a 100644 --- a/src/main/java/me/piitex/renjava/gui/overlay/TextFlowOverlay.java +++ b/src/main/java/me/piitex/renjava/gui/overlay/TextFlowOverlay.java @@ -1,5 +1,7 @@ package me.piitex.renjava.gui.overlay; +import javafx.scene.SubScene; +import javafx.scene.control.Hyperlink; import javafx.scene.paint.Color; import javafx.scene.paint.Paint; import javafx.scene.text.Font; @@ -12,7 +14,7 @@ import java.util.LinkedList; -public class TextFlowOverlay implements Overlay { +public class TextFlowOverlay implements Overlay, Region { private double x; private double y; private double scaleX, scaleY; @@ -165,10 +167,14 @@ public LinkedList getTexts() { public TextFlow build() { TextFlow textFlow = new TextFlow(); for (Text text : texts) { + // Not the best way to go about this + text = new Text(text.getText().replace("\\n", System.lineSeparator())); + if (font != null) { text.setFont(font); } text.setFill(textColor); + textFlow.getChildren().add(text); } @@ -176,4 +182,5 @@ public TextFlow build() { return textFlow; } + } diff --git a/src/main/java/me/piitex/renjava/gui/overlay/TextOverlay.java b/src/main/java/me/piitex/renjava/gui/overlay/TextOverlay.java index 29298e9..fb1bf53 100644 --- a/src/main/java/me/piitex/renjava/gui/overlay/TextOverlay.java +++ b/src/main/java/me/piitex/renjava/gui/overlay/TextOverlay.java @@ -7,7 +7,7 @@ import me.piitex.renjava.gui.overlay.events.IOverlayClick; import me.piitex.renjava.gui.overlay.events.IOverlayHover; -public class TextOverlay implements Overlay { +public class TextOverlay implements Overlay, Region { private final Text text; private FontLoader fontLoader; private double x; From 1cde3dcdd176cedbe6dc7b45d63e59c897c7271f Mon Sep 17 00:00:00 2001 From: Hackusate_PvP Date: Mon, 20 May 2024 17:34:50 -0500 Subject: [PATCH 10/30] Code cleanup. --- src/main/java/me/piitex/renjava/Launch.java | 4 +- .../me/piitex/renjava/api/saves/Save.java | 55 +------------------ .../defaults/GameFlowEventListener.java | 1 - .../me/piitex/renjava/utils/RPAArchive.java | 7 +++ 4 files changed, 11 insertions(+), 56 deletions(-) diff --git a/src/main/java/me/piitex/renjava/Launch.java b/src/main/java/me/piitex/renjava/Launch.java index e13f2e3..fd93949 100644 --- a/src/main/java/me/piitex/renjava/Launch.java +++ b/src/main/java/me/piitex/renjava/Launch.java @@ -102,8 +102,9 @@ private static void loadClass(Class clazz, String[] args) { System.err.println("Could retrieve runtime information."); } - try { + + // Creates a new instance of the application and executes the conductor. Object o = clazz.getDeclaredConstructor().newInstance(); RenJava renJava = (RenJava) o; if (renJava.getClass().isAnnotationPresent(Game.class)) { @@ -138,7 +139,6 @@ private static void loadClass(Class clazz, String[] args) { renJava.init(); // Initialize game launch(args); - //c.getDeclaredConstructor().newInstance(); } catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) { System.err.println("ERROR: Could initialize the RenJava framework: " + e.getMessage()); } diff --git a/src/main/java/me/piitex/renjava/api/saves/Save.java b/src/main/java/me/piitex/renjava/api/saves/Save.java index 8b74775..3a0c4e3 100644 --- a/src/main/java/me/piitex/renjava/api/saves/Save.java +++ b/src/main/java/me/piitex/renjava/api/saves/Save.java @@ -69,16 +69,11 @@ public void write() { if (field.isAnnotationPresent(Data.class)) { SectionKeyValue mapSection = handleMap(data, field); if (mapSection != null) { -// System.out.println("Map Section: "); - -// System.out.println(mapSection); rootSection.addSubSection(mapSection); continue; } - // Handle fields try { -// System.out.println("Processing field: " + field.getName()); Object object = field.get(data); if (object == null) { RenLogger.LOGGER.warn("Value for '" + field.getName() + "' is null. Will not process data."); @@ -122,7 +117,6 @@ public void write() { private SectionKeyValue handleMap(PersistentData data, Field field) { if (field.getGenericType().getTypeName().contains("Map<")) { try { -// System.out.println("Map type: " + field.getGenericType().getTypeName()); SectionKeyValue sectionKeyValue = new SectionKeyValue(field.getName()); reconstructMap(sectionKeyValue, data, field); return sectionKeyValue; @@ -136,7 +130,6 @@ private SectionKeyValue handleMap(PersistentData data, Field field) { private void reconstructMap(SectionKeyValue sectionKeyValue, PersistentData data, Field field) throws IllegalAccessException { Map map = (Map) field.get(data); map.entrySet().forEach(objectObjectEntry -> { -// System.out.println("Reconstructing entry..."); sectionKeyValue.addKeyValue(objectObjectEntry.getKey().toString(), objectObjectEntry.getValue().toString()); }); } @@ -144,9 +137,6 @@ private void reconstructMap(SectionKeyValue sectionKeyValue, PersistentData data // Loads save file public void load(boolean process) { - // Collect and set string data to class data. - // First loop the registered data and find the string data which corresponds with the data. - String fullData = null; try { fullData = new Scanner(file).useDelimiter("\\Z").next(); @@ -169,16 +159,13 @@ public void load(boolean process) { String[] classSplit = fullData.split(clazzName + ":"); String fields = classSplit[1]; -// System.out.println("Class Split: " + classSplit[1]); String[] fieldSplit = fields.split("\n"); for (String field : fieldSplit) { -// System.out.println("Field: " + field); if (field.trim().isEmpty()) continue; String[] keyValueSplit = field.split(":"); String key = keyValueSplit[0]; if (keyValueSplit.length == 1) { if (key.startsWith(" ") || key.startsWith("\t")) { -// System.out.println("Mapping found: " + key.trim()); mapSection = new SectionKeyValue(key.trim()); rootSection.addSubSection(mapSection); continue; @@ -188,7 +175,6 @@ public void load(boolean process) { } String value = keyValueSplit[1]; if ((key.startsWith(" ") || key.startsWith("\t")) && value.trim().isEmpty()) { -// System.out.println("Mapping found: " + key.trim()); mapSection = new SectionKeyValue(key.trim()); rootSection.addSubSection(mapSection); } else if (value.trim().isEmpty()) { @@ -197,11 +183,7 @@ public void load(boolean process) { if (mapSection != null) { mapSection.addKeyValue(key.trim(), value.trim()); } -// System.out.println("Mapping entry found: " + key.trim() + "," + value.trim()); } else if (key.startsWith("\t") || key.startsWith(" ")){ - // Handle generic entry - - // Check if entry is an array if (value.contains(",") || value.contains("[")) { if (value.contains("[")) { value = value.replace("[", "").replace("]", ""); @@ -217,7 +199,6 @@ public void load(boolean process) { processSection(persistentData, rootSection); } else { if (rootSection.getSection().contains("me.piitex.renjava.api.player.Player")) { -// System.out.println("Mapping scene..."); sceneSection = rootSection; } } @@ -226,57 +207,28 @@ public void load(boolean process) { public void processSection(PersistentData persistentData, SectionKeyValue rootSection) { - // Data is the full data string - // me.piitex.SomeData: - // field1: value1 - // map: - // key: value - // - - // Next set the mapping to the fields List fields = new ArrayList<>(List.of(persistentData.getClass().getDeclaredFields())); fields.addAll(List.of(persistentData.getClass().getFields())); for (Field field : fields) { if (field.isAnnotationPresent(Data.class)) { - //System.out.println("Processing Field: " + field.getName()); field.setAccessible(true); if (field.getGenericType().getTypeName().contains("Map<")) { // This is a map load. Scan for subsections if the field name matches. Add all data for (SectionKeyValue subSection : rootSection.getSubSections()) { if (subSection.getSection().equalsIgnoreCase(field.getName())) { // Convert Map to whatever the map of the object is - // Set the current values to whatever the load file is deconstructMap(subSection, persistentData, field); - -// try { -// System.out.println("Map: " + field.get(persistentData).toString()); -// } catch (IllegalAccessException e) { -// throw new RuntimeException(e); -// } - } } } String keyToSet = (String) rootSection.getKeyValueMap().keySet().stream().filter(key -> key.toString().equalsIgnoreCase(field.getName())).findAny().orElse(null); if (keyToSet != null) { -// System.out.println("Key To Set: " + keyToSet); try { - // Casting string might not be a good idea. String value = (String) rootSection.getKeyValueMap().get(keyToSet); - -// System.out.println("Setting values for: " + field.getName()); setField(field, persistentData, value.strip()); - - // Testing checks -// if (field.getName().equalsIgnoreCase("currentStory")) { -// System.out.println("Current Story: " + field.get(persistentData)); -// } -// if (field.getName().equalsIgnoreCase("currentScene")) { -// System.out.println("Current Scene: " + field.get(persistentData)); -// } } catch (NoSuchFieldException | IllegalAccessException e) { RenLogger.LOGGER.trace(e.getMessage()); } @@ -296,7 +248,6 @@ private void deconstructMap(SectionKeyValue subSection, PersistentData data, Fie } if (objectMap == null) { -// System.out.println("Map was null. Defaulting..."); objectMap = new HashMap<>(); } @@ -304,8 +255,6 @@ private void deconstructMap(SectionKeyValue subSection, PersistentData data, Fie // TODO: 3/3/2024 Convert generic map type to actual type using the Mapper class Map finalObjectMap = objectMap; subSection.getKeyValueMap().forEach((key, value) -> { -// System.out.println("Setting map..."); -// System.out.println(key + ": " + value); finalObjectMap.put(key, value); }); } @@ -363,8 +312,8 @@ public ImageOverlay buildPreview(int page) { // Since the Renpy assets account for Text they made a transparency space. // To circumvent this extra space we need to add the length of the space so everything is properly aligned. - saveImage.setX(15); - saveImage.setY(15); + saveImage.setX(15); // Position inside the button + saveImage.setY(15); // Position inside the button // Get whatever page they are on return saveImage; diff --git a/src/main/java/me/piitex/renjava/events/defaults/GameFlowEventListener.java b/src/main/java/me/piitex/renjava/events/defaults/GameFlowEventListener.java index ba9951b..bd6931d 100644 --- a/src/main/java/me/piitex/renjava/events/defaults/GameFlowEventListener.java +++ b/src/main/java/me/piitex/renjava/events/defaults/GameFlowEventListener.java @@ -44,7 +44,6 @@ public void onMouseClick(MouseClickEvent event) { Logger logger = RenLogger.LOGGER; // Only do this if it's not the title screen or any other menu screen - boolean gameMenu = stageType == StageType.IMAGE_SCENE || stageType == StageType.INPUT_SCENE || stageType == StageType.CHOICE_SCENE || stageType == StageType.INTERACTABLE_SCENE || stageType == StageType.ANIMATION_SCENE; switch (button) { diff --git a/src/main/java/me/piitex/renjava/utils/RPAArchive.java b/src/main/java/me/piitex/renjava/utils/RPAArchive.java index 7f8b722..884f9a1 100644 --- a/src/main/java/me/piitex/renjava/utils/RPAArchive.java +++ b/src/main/java/me/piitex/renjava/utils/RPAArchive.java @@ -7,7 +7,9 @@ import org.apache.commons.io.filefilter.RegexFileFilter; import java.io.File; +import java.io.IOException; import java.util.Collection; +import java.util.zip.ZipFile; /** * For archive files I want it to be similar to how RenPY works so I decided to just use the .rpa format. @@ -25,7 +27,12 @@ public RPAArchive(RenJava renJava) { for (File file : files) { if (file.getName().endsWith(".rpa")) { RenLogger.LOGGER.info("Loading archive: " + file.getName()); + try { + ZipFile zipFile = new ZipFile(file); + } catch (IOException e) { + throw new RuntimeException(e); + } } } } From a3b48af73ea2581ff77e3348ef4ebb22c4539a68 Mon Sep 17 00:00:00 2001 From: Hackusate_PvP Date: Thu, 23 May 2024 11:18:45 -0500 Subject: [PATCH 11/30] Fading transitions can now fade to different colors. --- .../transitions/types/FadingTransition.java | 17 ++++++++++ .../defaults/GameFlowEventListener.java | 12 +++++++ src/main/java/me/piitex/renjava/gui/Menu.java | 33 ++++++++++++++----- 3 files changed, 53 insertions(+), 9 deletions(-) diff --git a/src/main/java/me/piitex/renjava/api/scenes/transitions/types/FadingTransition.java b/src/main/java/me/piitex/renjava/api/scenes/transitions/types/FadingTransition.java index ae24078..881b6b0 100644 --- a/src/main/java/me/piitex/renjava/api/scenes/transitions/types/FadingTransition.java +++ b/src/main/java/me/piitex/renjava/api/scenes/transitions/types/FadingTransition.java @@ -2,6 +2,7 @@ import javafx.animation.FadeTransition; import javafx.scene.Node; +import javafx.scene.paint.Color; import javafx.util.Duration; import me.piitex.renjava.loggers.RenLogger; import me.piitex.renjava.api.scenes.transitions.Transitions; @@ -15,9 +16,20 @@ public class FadingTransition extends Transitions { private FadeTransition fadeTransition; + private Color color = Color.BLACK; + // Cheap hack private static FadingTransition previousTranition = null; + public FadingTransition(double fromValue, double toValue, double duration, Color color) { + super(duration); + this.fromValue = fromValue; + this.toValue = toValue; + this.cycleCount = 1; + this.autoReverse = false; + this.color = color; + } + public FadingTransition(double fromValue, double toValue, int cycleCount, boolean autoReverse, double duration) { super(duration); this.fromValue = fromValue; @@ -26,6 +38,7 @@ public FadingTransition(double fromValue, double toValue, int cycleCount, boolea this.autoReverse = autoReverse; } + public double getFromValue() { return fromValue; } @@ -42,6 +55,10 @@ public boolean isAutoReverse() { return autoReverse; } + public Color getColor() { + return color; + } + @Override public void play(Node node) { // Remove logger diff --git a/src/main/java/me/piitex/renjava/events/defaults/GameFlowEventListener.java b/src/main/java/me/piitex/renjava/events/defaults/GameFlowEventListener.java index bd6931d..0f7f3d2 100644 --- a/src/main/java/me/piitex/renjava/events/defaults/GameFlowEventListener.java +++ b/src/main/java/me/piitex/renjava/events/defaults/GameFlowEventListener.java @@ -1,10 +1,15 @@ package me.piitex.renjava.events.defaults; +import javafx.geometry.Insets; import javafx.scene.input.KeyCode; import javafx.scene.input.MouseButton; +import javafx.scene.layout.Background; +import javafx.scene.layout.BackgroundFill; +import javafx.scene.layout.CornerRadii; import javafx.scene.layout.Pane; import javafx.stage.Stage; import me.piitex.renjava.RenJava; +import me.piitex.renjava.api.scenes.transitions.types.FadingTransition; import me.piitex.renjava.loggers.RenLogger; import me.piitex.renjava.api.player.Player; import me.piitex.renjava.api.scenes.RenScene; @@ -21,6 +26,7 @@ import me.piitex.renjava.tasks.KeyHeldTask; import org.slf4j.Logger;; +import java.awt.*; import java.util.Timer; @@ -222,6 +228,12 @@ private void playNextScene() { if (scene.getEndTransition() != null && !player.isTransitionPlaying()) { player.setTransitionPlaying(true); Pane pane = previousMenu.getPane(); + if (scene.getEndTransition() instanceof FadingTransition fadingTransition) { + BackgroundFill backgroundFill = new BackgroundFill(fadingTransition.getColor(), new CornerRadii(1), new Insets(0, 0, 0, 0)); + pane.setBackground(new Background(backgroundFill)); + pane.getScene().setFill(fadingTransition.getColor()); + renJava.getStage().getScene().setFill(fadingTransition.getColor()); + } scene.getEndTransition().play(pane); // Starts transition. } else { nextScene.render(nextScene.build(true)); diff --git a/src/main/java/me/piitex/renjava/gui/Menu.java b/src/main/java/me/piitex/renjava/gui/Menu.java index d49d5ad..366f0c0 100644 --- a/src/main/java/me/piitex/renjava/gui/Menu.java +++ b/src/main/java/me/piitex/renjava/gui/Menu.java @@ -7,6 +7,7 @@ import javafx.stage.Stage; import me.piitex.renjava.RenJava; +import me.piitex.renjava.api.scenes.transitions.types.FadingTransition; import me.piitex.renjava.gui.overlay.Region; import me.piitex.renjava.loggers.RenLogger; import me.piitex.renjava.api.scenes.RenScene; @@ -228,12 +229,6 @@ public Pane render(@Nullable Pane root, @Nullable RenScene renScene, boolean ren root.setMinHeight(height * scaleY); } - // Background fill is used for fade ins. - if (renderFadeInFill) { - BackgroundFill backgroundFill = new BackgroundFill(BLACK, new CornerRadii(1), new Insets(0, 0, 0, 0)); - root.setBackground(new Background(backgroundFill)); - } - if (backgroundImage != null) { ImageOverlay backGroundImageOverlay = backgroundImage; @@ -290,14 +285,34 @@ public Pane render(@Nullable Pane root, @Nullable RenScene renScene, boolean ren this.pane = root; - if (renderFadeOutFill) { - scene.setFill(BLACK); // Scene fill is used for fade outs. - } // Apply transition to root if (renScene != null && renScene.getStartTransition() != null) { Transitions transitions = renScene.getStartTransition(); + + if (transitions instanceof FadingTransition fadingTransition) { + // Background fill is used for fade ins. + if (renderFadeInFill) { + BackgroundFill backgroundFill = new BackgroundFill(fadingTransition.getColor(), new CornerRadii(1), new Insets(0, 0, 0, 0)); + root.setBackground(new Background(backgroundFill)); + } + if (renderFadeOutFill) { + scene.setFill(fadingTransition.getColor()); // Scene fill is used for fade outs. + } + + } + transitions.play(root); + } else { + // Background fill is used for fade ins. Defaults to black + if (renderFadeInFill) { + BackgroundFill backgroundFill = new BackgroundFill(BLACK, new CornerRadii(1), new Insets(0, 0, 0, 0)); + root.setBackground(new Background(backgroundFill)); + } + if (renderFadeOutFill) { + scene.setFill(BLACK); // Scene fill is used for fade outs. + } + } if (renScene != null) { renScene.setStage(stage); From 10dcb27cb905428d574c936a6ade50b6e4549326 Mon Sep 17 00:00:00 2001 From: Hackusate_PvP Date: Thu, 23 May 2024 11:19:14 -0500 Subject: [PATCH 12/30] Sliders will now implement css file automatically. --- .../java/me/piitex/renjava/gui/Element.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/main/java/me/piitex/renjava/gui/Element.java b/src/main/java/me/piitex/renjava/gui/Element.java index 947a7d2..37f1011 100644 --- a/src/main/java/me/piitex/renjava/gui/Element.java +++ b/src/main/java/me/piitex/renjava/gui/Element.java @@ -19,6 +19,9 @@ import me.piitex.renjava.gui.overlay.*; import me.piitex.renjava.loggers.RenLogger; +import java.io.File; +import java.net.MalformedURLException; + public class Element { private final Overlay overlay; private Node node; @@ -78,6 +81,22 @@ public Element(Overlay overlay) { Slider slider = new Slider(sliderOverlay.getMinValue(), sliderOverlay.getMaxValue(), sliderOverlay.getCurrentValue()); slider.setTranslateX(sliderOverlay.x()); slider.setTranslateY(sliderOverlay.y()); + slider.setBlockIncrement(sliderOverlay.getBlockIncrement()); + + // To design sliders we NEED a css file which contains the styling. I'm not able to inline this via code which sucks. + // Hopefully the slider gets improvements in JavaFX. + + // Check if they have css files + File sliderCss = new File(System.getProperty("user.dir") + "/game/css/slider.css"); + if (!sliderCss.exists()) { + RenLogger.LOGGER.error("Slider css file does not exist. Please run or copy the css files from RSDK. Without a slider css file, the sliders won't properly be designed."); + } else { + try { + slider.getStylesheets().add(sliderCss.toURI().toURL().toExternalForm()); + } catch (MalformedURLException e) { + throw new RuntimeException(e); + } + } this.node = slider; } else if (overlay instanceof HyperlinkOverlay hyperlinkOverlay) { Hyperlink hyperlink = new Hyperlink(hyperlinkOverlay.getLabel()); From d439938613ad9771157abb0e7d3a01e39cd41af8 Mon Sep 17 00:00:00 2001 From: Hackusate_PvP Date: Fri, 24 May 2024 12:16:51 -0500 Subject: [PATCH 13/30] Added MouseReleaseEvent for overlays and SliderChangeEvent. --- .../java/me/piitex/renjava/gui/Element.java | 29 ++++++++++++++++--- .../renjava/gui/overlay/ButtonOverlay.java | 16 ++++++++-- .../renjava/gui/overlay/HyperlinkOverlay.java | 12 ++++++++ .../renjava/gui/overlay/ImageOverlay.java | 13 ++++++++- .../gui/overlay/InputFieldOverlay.java | 12 ++++++++ .../piitex/renjava/gui/overlay/Overlay.java | 5 ++++ .../renjava/gui/overlay/SliderOverlay.java | 22 ++++++++++++++ .../renjava/gui/overlay/TextFlowOverlay.java | 12 ++++++++ .../renjava/gui/overlay/TextOverlay.java | 12 ++++++++ .../overlay/events/IOverlayClickRelease.java | 7 +++++ .../gui/overlay/events/ISliderChange.java | 8 +++++ 11 files changed, 141 insertions(+), 7 deletions(-) create mode 100644 src/main/java/me/piitex/renjava/gui/overlay/events/IOverlayClickRelease.java create mode 100644 src/main/java/me/piitex/renjava/gui/overlay/events/ISliderChange.java diff --git a/src/main/java/me/piitex/renjava/gui/Element.java b/src/main/java/me/piitex/renjava/gui/Element.java index 37f1011..4a63cfa 100644 --- a/src/main/java/me/piitex/renjava/gui/Element.java +++ b/src/main/java/me/piitex/renjava/gui/Element.java @@ -13,9 +13,7 @@ import javafx.scene.text.TextFlow; import me.piitex.renjava.RenJava; import me.piitex.renjava.api.scenes.transitions.Transitions; -import me.piitex.renjava.events.types.OverlayClickEvent; -import me.piitex.renjava.events.types.OverlayExitEvent; -import me.piitex.renjava.events.types.OverlayHoverEvent; +import me.piitex.renjava.events.types.*; import me.piitex.renjava.gui.overlay.*; import me.piitex.renjava.loggers.RenLogger; @@ -82,7 +80,6 @@ public Element(Overlay overlay) { slider.setTranslateX(sliderOverlay.x()); slider.setTranslateY(sliderOverlay.y()); slider.setBlockIncrement(sliderOverlay.getBlockIncrement()); - // To design sliders we NEED a css file which contains the styling. I'm not able to inline this via code which sucks. // Hopefully the slider gets improvements in JavaFX. @@ -97,6 +94,15 @@ public Element(Overlay overlay) { throw new RuntimeException(e); } } + // Handle slider events + slider.setOnMouseReleased(event -> { + SliderChangeEvent changeEvent = new SliderChangeEvent(sliderOverlay, slider.getValue()); + sliderOverlay.getSliderChange().onSliderChange(changeEvent); + RenJava.callEvent(changeEvent); + + RenJava.callEvent(new OverlayClickReleaseEvent(overlay, event)); + }); + this.node = slider; } else if (overlay instanceof HyperlinkOverlay hyperlinkOverlay) { Hyperlink hyperlink = new Hyperlink(hyperlinkOverlay.getLabel()); @@ -137,6 +143,16 @@ public void render(Pane root) { root.getChildren().add(node); } + public void render(Pane root, double width, double height) { + if (transitions != null) { + transitions.play(node); + } + + + + root.getChildren().add(node); + } + private void handleInput() { node.setOnMouseEntered(event -> { RenJava.callEvent(new OverlayHoverEvent(overlay, event)); @@ -147,6 +163,11 @@ private void handleInput() { node.setOnMouseExited(event -> { RenJava.callEvent(new OverlayExitEvent(overlay, event)); }); + if (node.getOnMouseReleased() == null) { + node.setOnMouseReleased(event -> { + RenJava.callEvent(new OverlayClickReleaseEvent(overlay, event)); + }); + } } public Node getNode() { diff --git a/src/main/java/me/piitex/renjava/gui/overlay/ButtonOverlay.java b/src/main/java/me/piitex/renjava/gui/overlay/ButtonOverlay.java index 16bd529..03a74f6 100644 --- a/src/main/java/me/piitex/renjava/gui/overlay/ButtonOverlay.java +++ b/src/main/java/me/piitex/renjava/gui/overlay/ButtonOverlay.java @@ -11,6 +11,7 @@ import me.piitex.renjava.RenJava; import me.piitex.renjava.gui.Menu; import me.piitex.renjava.gui.overlay.events.IOverlayClick; +import me.piitex.renjava.gui.overlay.events.IOverlayClickRelease; import me.piitex.renjava.gui.overlay.events.IOverlayHover; import me.piitex.renjava.loggers.RenLogger; import me.piitex.renjava.api.loaders.ImageLoader; @@ -34,12 +35,13 @@ public class ButtonOverlay implements Overlay, Region { private Color borderColor; private Color hoverColor; private ImageLoader hoverImage; - private boolean hover; + private boolean hover = true; private int borderWidth = 0; private int backgroundRadius = 0; private IOverlayHover iOverlayHover; private IOverlayClick iOverlayClick; + private IOverlayClickRelease iOverlayClickRelease; private double x = 1, y = 1; private double maxHeight, maxWidth; @@ -148,7 +150,6 @@ public ButtonOverlay(String id, String text, Color textFill, Font font, Color ba this.yScale = yScale; this.backgroundColor = backgroundColor; this.borderColor = borderColor; - this.hover = true; this.hoverColor = hoverColor; } @@ -406,6 +407,11 @@ public void setOnHover(IOverlayHover iOverlayHover) { this.iOverlayHover = iOverlayHover; } + @Override + public void setOnClickRelease(IOverlayClickRelease iOverlayClickRelease) { + this.iOverlayClickRelease = iOverlayClickRelease; + } + @Override public IOverlayClick getOnClick() { return iOverlayClick; @@ -416,6 +422,11 @@ public IOverlayHover getOnHover() { return iOverlayHover; } + @Override + public IOverlayClickRelease getOnRelease() { + return iOverlayClickRelease; + } + public void setTransitions(Transitions transitions) { this.transitions = transitions; @@ -495,6 +506,7 @@ public Button build() { button.setPrefHeight(maxHeight); } if (maxWidth > 0) { + button.setMinWidth(maxWidth); button.setMaxWidth(maxWidth); button.setPrefWidth(maxWidth); } diff --git a/src/main/java/me/piitex/renjava/gui/overlay/HyperlinkOverlay.java b/src/main/java/me/piitex/renjava/gui/overlay/HyperlinkOverlay.java index 7c9b2c4..ffb299c 100644 --- a/src/main/java/me/piitex/renjava/gui/overlay/HyperlinkOverlay.java +++ b/src/main/java/me/piitex/renjava/gui/overlay/HyperlinkOverlay.java @@ -3,6 +3,7 @@ import me.piitex.renjava.api.loaders.FontLoader; import me.piitex.renjava.api.scenes.transitions.Transitions; import me.piitex.renjava.gui.overlay.events.IOverlayClick; +import me.piitex.renjava.gui.overlay.events.IOverlayClickRelease; import me.piitex.renjava.gui.overlay.events.IOverlayHover; public class HyperlinkOverlay implements Overlay { @@ -14,6 +15,7 @@ public class HyperlinkOverlay implements Overlay { private Transitions transitions; private IOverlayHover iOverlayHover; private IOverlayClick iOverlayClick; + private IOverlayClickRelease iOverlayClickRelease; public HyperlinkOverlay(String label, String link, double x, double y) { this.label = label; @@ -81,6 +83,11 @@ public void setOnHover(IOverlayHover iOverlayHover) { this.iOverlayHover = iOverlayHover; } + @Override + public void setOnClickRelease(IOverlayClickRelease iOverlayClickRelease) { + this.iOverlayClickRelease = iOverlayClickRelease; + } + @Override public IOverlayClick getOnClick() { return iOverlayClick; @@ -90,4 +97,9 @@ public IOverlayClick getOnClick() { public IOverlayHover getOnHover() { return iOverlayHover; } + + @Override + public IOverlayClickRelease getOnRelease() { + return iOverlayClickRelease; + } } diff --git a/src/main/java/me/piitex/renjava/gui/overlay/ImageOverlay.java b/src/main/java/me/piitex/renjava/gui/overlay/ImageOverlay.java index 6aaddd2..70085d9 100644 --- a/src/main/java/me/piitex/renjava/gui/overlay/ImageOverlay.java +++ b/src/main/java/me/piitex/renjava/gui/overlay/ImageOverlay.java @@ -4,6 +4,7 @@ import javafx.scene.image.WritableImage; import me.piitex.renjava.RenJava; import me.piitex.renjava.gui.overlay.events.IOverlayClick; +import me.piitex.renjava.gui.overlay.events.IOverlayClickRelease; import me.piitex.renjava.gui.overlay.events.IOverlayHover; import me.piitex.renjava.loggers.RenLogger; import me.piitex.renjava.api.loaders.ImageLoader; @@ -21,8 +22,8 @@ public class ImageOverlay implements Overlay, Region { private String fileName; private IOverlayHover iOverlayHover; - private IOverlayClick iOverlayClick; + private IOverlayClickRelease iOverlayClickRelease; private Transitions transitions; @@ -194,6 +195,11 @@ public void setOnHover(IOverlayHover iOverlayHover) { this.iOverlayHover = iOverlayHover; } + @Override + public void setOnClickRelease(IOverlayClickRelease iOverlayClickRelease) { + this.iOverlayClickRelease = iOverlayClickRelease; + } + @Override public IOverlayClick getOnClick() { return iOverlayClick; @@ -204,6 +210,11 @@ public IOverlayHover getOnHover() { return iOverlayHover; } + @Override + public IOverlayClickRelease getOnRelease() { + return iOverlayClickRelease; + } + public ImageOverlay setTransitions(Transitions transitions) { this.transitions = transitions; return this; diff --git a/src/main/java/me/piitex/renjava/gui/overlay/InputFieldOverlay.java b/src/main/java/me/piitex/renjava/gui/overlay/InputFieldOverlay.java index abd57a7..17f3cfb 100644 --- a/src/main/java/me/piitex/renjava/gui/overlay/InputFieldOverlay.java +++ b/src/main/java/me/piitex/renjava/gui/overlay/InputFieldOverlay.java @@ -4,6 +4,7 @@ import me.piitex.renjava.api.loaders.FontLoader; import me.piitex.renjava.api.scenes.transitions.Transitions; import me.piitex.renjava.gui.overlay.events.IOverlayClick; +import me.piitex.renjava.gui.overlay.events.IOverlayClickRelease; import me.piitex.renjava.gui.overlay.events.IOverlayHover; public class InputFieldOverlay implements Overlay, Region { @@ -16,6 +17,7 @@ public class InputFieldOverlay implements Overlay, Region { private IOverlayClick iOverlayClick; private IOverlayHover iOverlayHover; + private IOverlayClickRelease iOverlayClickRelease; public InputFieldOverlay(double x, double y, FontLoader fontLoader) { this.x = x; @@ -98,6 +100,11 @@ public void setOnHover(IOverlayHover iOverlayHover) { this.iOverlayHover = iOverlayHover; } + @Override + public void setOnClickRelease(IOverlayClickRelease iOverlayClickRelease) { + this.iOverlayClickRelease = iOverlayClickRelease; + } + @Override public IOverlayClick getOnClick() { return iOverlayClick; @@ -108,6 +115,11 @@ public IOverlayHover getOnHover() { return iOverlayHover; } + @Override + public IOverlayClickRelease getOnRelease() { + return iOverlayClickRelease; + } + public void setTransitions(Transitions transitions) { this.transitions = transitions; } diff --git a/src/main/java/me/piitex/renjava/gui/overlay/Overlay.java b/src/main/java/me/piitex/renjava/gui/overlay/Overlay.java index 91a158a..6b07661 100644 --- a/src/main/java/me/piitex/renjava/gui/overlay/Overlay.java +++ b/src/main/java/me/piitex/renjava/gui/overlay/Overlay.java @@ -2,6 +2,7 @@ import me.piitex.renjava.api.scenes.transitions.Transitions; import me.piitex.renjava.gui.overlay.events.IOverlayClick; +import me.piitex.renjava.gui.overlay.events.IOverlayClickRelease; import me.piitex.renjava.gui.overlay.events.IOverlayHover; public interface Overlay { @@ -19,7 +20,11 @@ public interface Overlay { void setOnHover(IOverlayHover iOverlayHover); + void setOnClickRelease(IOverlayClickRelease iOverlayClickRelease); + IOverlayClick getOnClick(); IOverlayHover getOnHover(); + + IOverlayClickRelease getOnRelease(); } diff --git a/src/main/java/me/piitex/renjava/gui/overlay/SliderOverlay.java b/src/main/java/me/piitex/renjava/gui/overlay/SliderOverlay.java index 1d85585..cc0fb2a 100644 --- a/src/main/java/me/piitex/renjava/gui/overlay/SliderOverlay.java +++ b/src/main/java/me/piitex/renjava/gui/overlay/SliderOverlay.java @@ -2,15 +2,19 @@ import me.piitex.renjava.api.scenes.transitions.Transitions; import me.piitex.renjava.gui.overlay.events.IOverlayClick; +import me.piitex.renjava.gui.overlay.events.IOverlayClickRelease; import me.piitex.renjava.gui.overlay.events.IOverlayHover; +import me.piitex.renjava.gui.overlay.events.ISliderChange; public class SliderOverlay implements Overlay { private final double maxValue, minValue, currentValue; private double x, y; private double blockIncrement; + private ISliderChange iSliderChange; private IOverlayHover iOverlayHover; private IOverlayClick iOverlayClick; + private IOverlayClickRelease iOverlayClickRelease; public SliderOverlay(double maxValue, double minValue, double currentValue, double x, double y) { // Sliders don't have regions like images or buttons do. @@ -66,6 +70,14 @@ public Transitions getTransition() { return null; } + public void setOnSliderChange(ISliderChange iSliderChange) { + this.iSliderChange = iSliderChange; + } + + public ISliderChange getSliderChange() { + return iSliderChange; + } + @Override public void setOnclick(IOverlayClick iOverlayClick) { this.iOverlayClick = iOverlayClick; @@ -76,6 +88,11 @@ public void setOnHover(IOverlayHover iOverlayHover) { this.iOverlayHover = iOverlayHover; } + @Override + public void setOnClickRelease(IOverlayClickRelease iOverlayClickRelease) { + this.iOverlayClickRelease = iOverlayClickRelease; + } + @Override public IOverlayClick getOnClick() { return iOverlayClick; @@ -86,4 +103,9 @@ public IOverlayHover getOnHover() { return iOverlayHover; } + @Override + public IOverlayClickRelease getOnRelease() { + return iOverlayClickRelease; + } + } diff --git a/src/main/java/me/piitex/renjava/gui/overlay/TextFlowOverlay.java b/src/main/java/me/piitex/renjava/gui/overlay/TextFlowOverlay.java index 269665a..0cc6ddb 100644 --- a/src/main/java/me/piitex/renjava/gui/overlay/TextFlowOverlay.java +++ b/src/main/java/me/piitex/renjava/gui/overlay/TextFlowOverlay.java @@ -10,6 +10,7 @@ import me.piitex.renjava.api.loaders.FontLoader; import me.piitex.renjava.api.scenes.transitions.Transitions; import me.piitex.renjava.gui.overlay.events.IOverlayClick; +import me.piitex.renjava.gui.overlay.events.IOverlayClickRelease; import me.piitex.renjava.gui.overlay.events.IOverlayHover; import java.util.LinkedList; @@ -24,6 +25,7 @@ public class TextFlowOverlay implements Overlay, Region { private IOverlayClick iOverlayClick; private IOverlayHover iOverlayHover; + private IOverlayClickRelease iOverlayClickRelease; private LinkedList texts = new LinkedList<>(); @@ -144,6 +146,11 @@ public void setOnHover(IOverlayHover iOverlayHover) { this.iOverlayHover = iOverlayHover; } + @Override + public void setOnClickRelease(IOverlayClickRelease iOverlayClickRelease) { + this.iOverlayClickRelease = iOverlayClickRelease; + } + @Override public IOverlayClick getOnClick() { return iOverlayClick; @@ -154,6 +161,11 @@ public IOverlayHover getOnHover() { return iOverlayHover; } + @Override + public IOverlayClickRelease getOnRelease() { + return iOverlayClickRelease; + } + public void setTransitions(Transitions transitions) { this.transitions = transitions; diff --git a/src/main/java/me/piitex/renjava/gui/overlay/TextOverlay.java b/src/main/java/me/piitex/renjava/gui/overlay/TextOverlay.java index fb1bf53..824a02c 100644 --- a/src/main/java/me/piitex/renjava/gui/overlay/TextOverlay.java +++ b/src/main/java/me/piitex/renjava/gui/overlay/TextOverlay.java @@ -5,6 +5,7 @@ import me.piitex.renjava.api.loaders.FontLoader; import me.piitex.renjava.api.scenes.transitions.Transitions; import me.piitex.renjava.gui.overlay.events.IOverlayClick; +import me.piitex.renjava.gui.overlay.events.IOverlayClickRelease; import me.piitex.renjava.gui.overlay.events.IOverlayHover; public class TextOverlay implements Overlay, Region { @@ -18,6 +19,7 @@ public class TextOverlay implements Overlay, Region { private IOverlayClick iOverlayClick; private IOverlayHover iOverlayHover; + private IOverlayClickRelease iOverlayClickRelease; public TextOverlay(String text, double x, double y) { this.text = new Text(text); @@ -128,6 +130,11 @@ public void setOnHover(IOverlayHover iOverlayHover) { this.iOverlayHover = iOverlayHover; } + @Override + public void setOnClickRelease(IOverlayClickRelease iOverlayClickRelease) { + this.iOverlayClickRelease = iOverlayClickRelease; + } + @Override public IOverlayClick getOnClick() { return iOverlayClick; @@ -138,6 +145,11 @@ public IOverlayHover getOnHover() { return iOverlayHover; } + @Override + public IOverlayClickRelease getOnRelease() { + return iOverlayClickRelease; + } + public void setTransitions(Transitions transitions) { this.transitions = transitions; } diff --git a/src/main/java/me/piitex/renjava/gui/overlay/events/IOverlayClickRelease.java b/src/main/java/me/piitex/renjava/gui/overlay/events/IOverlayClickRelease.java new file mode 100644 index 0000000..1c31ad1 --- /dev/null +++ b/src/main/java/me/piitex/renjava/gui/overlay/events/IOverlayClickRelease.java @@ -0,0 +1,7 @@ +package me.piitex.renjava.gui.overlay.events; + +import me.piitex.renjava.events.types.OverlayClickReleaseEvent; + +public interface IOverlayClickRelease { + void onClickRelease(OverlayClickReleaseEvent event); +} diff --git a/src/main/java/me/piitex/renjava/gui/overlay/events/ISliderChange.java b/src/main/java/me/piitex/renjava/gui/overlay/events/ISliderChange.java new file mode 100644 index 0000000..d32678d --- /dev/null +++ b/src/main/java/me/piitex/renjava/gui/overlay/events/ISliderChange.java @@ -0,0 +1,8 @@ +package me.piitex.renjava.gui.overlay.events; + +import me.piitex.renjava.events.types.SliderChangeEvent; + +public interface ISliderChange { + + void onSliderChange(SliderChangeEvent event); +} From 16a08ffa45bfc93a7391825b7966ff9014ed6f1d Mon Sep 17 00:00:00 2001 From: Hackusate_PvP Date: Fri, 24 May 2024 12:19:17 -0500 Subject: [PATCH 14/30] Elements will be resized to match layout width. --- .../me/piitex/renjava/gui/layouts/Layout.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/main/java/me/piitex/renjava/gui/layouts/Layout.java b/src/main/java/me/piitex/renjava/gui/layouts/Layout.java index 2944702..06c106e 100644 --- a/src/main/java/me/piitex/renjava/gui/layouts/Layout.java +++ b/src/main/java/me/piitex/renjava/gui/layouts/Layout.java @@ -7,6 +7,7 @@ import javafx.scene.layout.VBox; import me.piitex.renjava.gui.Element; import me.piitex.renjava.gui.overlay.Overlay; +import me.piitex.renjava.gui.overlay.Region; import java.util.Collection; import java.util.LinkedHashSet; @@ -28,8 +29,17 @@ protected Layout(Pane pane) { } public void render(Pane root) { + pane.setTranslateX(x); + pane.setTranslateY(y); + pane.setPrefSize(width, height); for (Overlay overlay : getOverlays()) { // Check if the layout should be a scroll pane. + + // Update overlay sizes + if (overlay instanceof Region region) { + region.setWidth(pane.getWidth()); + } + if (isScrollbar()) { ScrollPane scrollPane = new ScrollPane(pane); BorderPane subRoot = new BorderPane(scrollPane); @@ -42,9 +52,6 @@ public void render(Pane root) { pane.getChildren().add(sub); } } - pane.setTranslateX(x); - pane.setTranslateY(y); - pane.setPrefSize(width, height); if (pane instanceof HBox hBox) { hBox.setSpacing(spacing); } else if (pane instanceof VBox vBox) { @@ -122,6 +129,10 @@ public void addChildLayout(Layout layout) { this.childLayouts.add(layout); } + public void addChildLayouts(Layout... layouts) { + this.childLayouts.addAll(List.of(layouts)); + } + public LinkedHashSet getChildLayouts() { return childLayouts; } From 0592727e4fb9fb587a552c40d3026e7a9d29dade Mon Sep 17 00:00:00 2001 From: Hackusate_PvP Date: Fri, 24 May 2024 12:19:45 -0500 Subject: [PATCH 15/30] Added events SliderChangeEvent and OverlayClickReleaseEvent. --- .../events/defaults/OverlayEventListener.java | 18 ++++++++++--- .../types/OverlayClickReleaseEvent.java | 23 ++++++++++++++++ .../events/types/SliderChangeEvent.java | 26 +++++++++++++++++++ 3 files changed, 64 insertions(+), 3 deletions(-) create mode 100644 src/main/java/me/piitex/renjava/events/types/OverlayClickReleaseEvent.java create mode 100644 src/main/java/me/piitex/renjava/events/types/SliderChangeEvent.java diff --git a/src/main/java/me/piitex/renjava/events/defaults/OverlayEventListener.java b/src/main/java/me/piitex/renjava/events/defaults/OverlayEventListener.java index a65aff3..78817a6 100644 --- a/src/main/java/me/piitex/renjava/events/defaults/OverlayEventListener.java +++ b/src/main/java/me/piitex/renjava/events/defaults/OverlayEventListener.java @@ -2,11 +2,10 @@ import javafx.scene.control.Button; import javafx.scene.image.ImageView; +import me.piitex.renjava.RenJava; import me.piitex.renjava.events.EventListener; import me.piitex.renjava.events.Listener; -import me.piitex.renjava.events.types.OverlayClickEvent; -import me.piitex.renjava.events.types.OverlayExitEvent; -import me.piitex.renjava.events.types.OverlayHoverEvent; +import me.piitex.renjava.events.types.*; import me.piitex.renjava.gui.exceptions.ImageNotFoundException; import me.piitex.renjava.gui.overlay.ButtonOverlay; import me.piitex.renjava.gui.overlay.Overlay; @@ -37,6 +36,9 @@ public void onOverlayHover(OverlayHoverEvent event) { if (buttonOverlay.isHover()) { if (buttonOverlay.getHoverColor() != null) { button.setTextFill(buttonOverlay.getHoverColor()); + } else { + System.out.println("Setting default hover color for: " + buttonOverlay.getId()); + button.setTextFill(RenJava.getInstance().getConfiguration().getHoverColor()); } if (buttonOverlay.getHoverImage() != null) { try { @@ -45,10 +47,20 @@ public void onOverlayHover(OverlayHoverEvent event) { RenLogger.LOGGER.error(e.getMessage()); } } + } else { + System.out.println("No hover was set for overlay"); } } } + @Listener + public void onOverlayRelease(OverlayClickReleaseEvent event) { + Overlay overlay = event.getOverlay(); + if (overlay.getOnRelease() != null) { + overlay.getOnRelease().onClickRelease(event); + } + } + @Listener public void onOverlayExit(OverlayExitEvent event) { Overlay overlay = event.getOverlay(); diff --git a/src/main/java/me/piitex/renjava/events/types/OverlayClickReleaseEvent.java b/src/main/java/me/piitex/renjava/events/types/OverlayClickReleaseEvent.java new file mode 100644 index 0000000..7c5859c --- /dev/null +++ b/src/main/java/me/piitex/renjava/events/types/OverlayClickReleaseEvent.java @@ -0,0 +1,23 @@ +package me.piitex.renjava.events.types; + +import javafx.scene.input.MouseEvent; +import me.piitex.renjava.events.Event; +import me.piitex.renjava.gui.overlay.Overlay; + +public class OverlayClickReleaseEvent extends Event { + private final Overlay overlay; + private final MouseEvent event; + + public OverlayClickReleaseEvent(Overlay overlay, MouseEvent event) { + this.overlay = overlay; + this.event = event; + } + + public Overlay getOverlay() { + return overlay; + } + + public MouseEvent getHandler() { + return event; + } +} diff --git a/src/main/java/me/piitex/renjava/events/types/SliderChangeEvent.java b/src/main/java/me/piitex/renjava/events/types/SliderChangeEvent.java new file mode 100644 index 0000000..a95199e --- /dev/null +++ b/src/main/java/me/piitex/renjava/events/types/SliderChangeEvent.java @@ -0,0 +1,26 @@ +package me.piitex.renjava.events.types; + +import me.piitex.renjava.events.Event; +import me.piitex.renjava.gui.overlay.SliderOverlay; + +public class SliderChangeEvent extends Event { + private final SliderOverlay sliderOverlay; + private double value; + + public SliderChangeEvent(SliderOverlay sliderOverlay, double value) { + this.sliderOverlay = sliderOverlay; + this.value = value; + } + + public SliderOverlay getSliderOverlay() { + return sliderOverlay; + } + + public double getValue() { + return value; + } + + public void setValue(double value) { + this.value = value; + } +} From 4493a11a551d5d1fa91c51722a5e43f2e877dd93 Mon Sep 17 00:00:00 2001 From: Hackusate_PvP Date: Fri, 24 May 2024 12:20:20 -0500 Subject: [PATCH 16/30] Changed volume setting from int to double. --- .../me/piitex/renjava/configuration/SettingsProperties.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/me/piitex/renjava/configuration/SettingsProperties.java b/src/main/java/me/piitex/renjava/configuration/SettingsProperties.java index 85160ba..c9edd1b 100644 --- a/src/main/java/me/piitex/renjava/configuration/SettingsProperties.java +++ b/src/main/java/me/piitex/renjava/configuration/SettingsProperties.java @@ -8,7 +8,7 @@ public class SettingsProperties { private final File file; - private int volume = 50; // Don't want to ear blast people right off the start so half volume should work. + private double volume = 50; // Don't want to ear blast people right off the start so half volume should work. private boolean fullscreen = false; private boolean skipTransitions = false; private boolean skipUnseenText = false; @@ -44,7 +44,7 @@ public SettingsProperties() { } catch (IOException e) { throw new RuntimeException(e); } - this.volume = Integer.parseInt(properties.getProperty("volume")); + this.volume = Double.parseDouble(properties.getProperty("volume")); this.fullscreen = Boolean.parseBoolean(properties.getProperty("fullscreen")); this.skipTransitions = Boolean.parseBoolean(properties.getProperty("transitions")); this.skipUnseenText = Boolean.parseBoolean(properties.getProperty("skip-unseen-text")); @@ -55,7 +55,7 @@ public double getVolume() { return volume; } - public void setVolume(int volume) { + public void setVolume(double volume) { this.volume = volume; write("volume", volume + ""); } From 6905cb7a1ada89b389bf7abd0ae4914e603791cd Mon Sep 17 00:00:00 2001 From: Hackusate_PvP Date: Fri, 24 May 2024 12:20:58 -0500 Subject: [PATCH 17/30] Started implementation of the settings screen. --- src/main/java/me/piitex/renjava/RenJava.java | 62 ++++++++++++++++++-- 1 file changed, 57 insertions(+), 5 deletions(-) diff --git a/src/main/java/me/piitex/renjava/RenJava.java b/src/main/java/me/piitex/renjava/RenJava.java index e5656a5..ae26d0c 100644 --- a/src/main/java/me/piitex/renjava/RenJava.java +++ b/src/main/java/me/piitex/renjava/RenJava.java @@ -32,11 +32,8 @@ import me.piitex.renjava.gui.Menu; import me.piitex.renjava.gui.layouts.impl.HorizontalLayout; import me.piitex.renjava.gui.layouts.impl.VerticalLayout; -import me.piitex.renjava.gui.overlay.ButtonOverlay; +import me.piitex.renjava.gui.overlay.*; import me.piitex.renjava.gui.StageType; -import me.piitex.renjava.gui.overlay.HyperlinkOverlay; -import me.piitex.renjava.gui.overlay.ImageOverlay; -import me.piitex.renjava.gui.overlay.TextFlowOverlay; import me.piitex.renjava.loggers.RenLogger; import org.jetbrains.annotations.NotNull; import org.slf4j.Logger; @@ -474,8 +471,63 @@ private static ButtonOverlay getButtonOverlay(int page, int index) { } public Menu buildSettingsMenu() { + Menu menu = new Menu(1920, 1080, new ImageOverlay("gui/main_menu.png")); + + // 1 hbox 3 vboxes + + // Display Rollback Skip + // Windowed Disabled Unseen Text + // Full screen Enabled After Choices + // Right Transitions + + + HorizontalLayout rootLayout = new HorizontalLayout(1200, 600); + rootLayout.setX(600); + rootLayout.setY(200); + rootLayout.setSpacing(100); + + VerticalLayout displayBox = new VerticalLayout(300, 400); + TextOverlay displayText = new TextOverlay("Display", getConfiguration().getUiFont(), 0, 0); + ButtonOverlay windowButton = new ButtonOverlay("windowed-display", "Windowed", Color.BLACK, getConfiguration().getUiFont().getFont(), 0,0,1,1); + ButtonOverlay fullscreenButton = new ButtonOverlay("windowed-fullscreen", "Fullscreen", Color.BLACK, getConfiguration().getUiFont().getFont(), 0,0,1,1); + displayBox.addOverlays(displayText, windowButton, fullscreenButton); + + VerticalLayout rollbackBox = new VerticalLayout(300, 400); + TextOverlay rollbackText = new TextOverlay("Rollback", getConfiguration().getUiFont(), 0, 0); + ButtonOverlay disabledButton = new ButtonOverlay("disabled-rollback", "Disabled", Color.BLACK, getConfiguration().getUiFont().getFont(), 0,0,1,1); + ButtonOverlay leftButton = new ButtonOverlay("left-rollback", "Left", Color.BLACK, getConfiguration().getUiFont().getFont(), 0,0,1,1); + ButtonOverlay rightButton = new ButtonOverlay("right-rollback", "Right", Color.BLACK, getConfiguration().getUiFont().getFont(), 0,0,1,1); + rollbackBox.addOverlays(rollbackText, disabledButton, leftButton, rightButton); + + VerticalLayout skipBox = new VerticalLayout(300, 400); + TextOverlay skipText = new TextOverlay("Skip", getConfiguration().getUiFont(), 0, 0); + ButtonOverlay unseenTextButton = new ButtonOverlay("unseen-skip", "Unseen Text", Color.BLACK, getConfiguration().getUiFont().getFont(), 0,0,1,1); + ButtonOverlay afterChoicesButton = new ButtonOverlay("after-skip", "After Choices", Color.BLACK, getConfiguration().getUiFont().getFont(), 0,0,1,1); + ButtonOverlay transitionButton = new ButtonOverlay("transitions-skip", "Transitions", Color.BLACK, getConfiguration().getUiFont().getFont(), 0,0,1,1); + skipBox.addOverlays(skipText, unseenTextButton, afterChoicesButton, transitionButton); - return null; + // Add all to root layout + rootLayout.addChildLayouts(displayBox, rollbackBox, skipBox); + + menu.addLayout(rootLayout); + + // Music sliders + VerticalLayout musicBox = new VerticalLayout(400, 600); + musicBox.setX(700); + musicBox.setY(800); + TextOverlay musicVolumeText = new TextOverlay("Music Volume", getConfiguration().getUiFont(), 0, 0); + SliderOverlay musicVolumeSlider = new SliderOverlay(100, 0, getSettings().getVolume(), 0,0); + musicVolumeSlider.setBlockIncrement(10); + musicVolumeSlider.setOnSliderChange(event -> { + // Event used when slider changes value + System.out.println("Volume: " + event.getValue()); + getSettings().setVolume(event.getValue()); + }); + musicBox.addOverlays(musicVolumeText, musicVolumeSlider); + + menu.addLayout(musicBox); + + return menu; } public Menu buildAboutMenu() { From 77f1aba329e041d917e585f2ae9f7982b16c22f7 Mon Sep 17 00:00:00 2001 From: Hackusate_PvP Date: Fri, 24 May 2024 15:03:19 -0500 Subject: [PATCH 18/30] Application will no longer start if the image or gui folders don't exist. --- src/main/java/me/piitex/renjava/RenLoader.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/main/java/me/piitex/renjava/RenLoader.java b/src/main/java/me/piitex/renjava/RenLoader.java index 0056c24..8e825a4 100644 --- a/src/main/java/me/piitex/renjava/RenLoader.java +++ b/src/main/java/me/piitex/renjava/RenLoader.java @@ -4,7 +4,6 @@ import java.util.Properties; import javafx.application.Platform; -import me.piitex.renjava.api.loaders.FontLoader; import me.piitex.renjava.api.music.Track; import me.piitex.renjava.configuration.SettingsProperties; import me.piitex.renjava.loggers.RenLogger; @@ -20,8 +19,7 @@ public RenLoader(RenJava renJava) { setupMain(); setupGame(); if (shutdown) { - // Shutdown application. - RenLogger.LOGGER.error("Game assets do not exist. Please download default assets and place them inside the 'game' folder."); + // Shutdown application if startup fails. Platform.exit(); System.exit(0); return; @@ -33,9 +31,18 @@ private void setupMain() { RenLogger.LOGGER.info("Checking game environment..."); File gameDirectory = new File(System.getProperty("user.dir") + "/game/"); if (gameDirectory.mkdir()) { - RenLogger.LOGGER.error("Game directory does not exist. The game will not work properly, please move all assets into the newly created game directory."); + RenLogger.LOGGER.error("Game assets do not exist. Please download default assets and place them inside the 'game/images/gui' folder."); shutdown = true; } + + // Verify GUI folder + File guiDirectory = new File(gameDirectory, "/gui/"); + if (!guiDirectory.exists() || guiDirectory.listFiles().length == 0) { + RenLogger.LOGGER.error("GUI directory does not exist. The game will not work properly, please move all assets into the newly created gui directory."); + guiDirectory.mkdir(); + shutdown = true; + } + File renJavaDirectory = new File(System.getProperty("user.dir") + "/renjava/"); if (renJavaDirectory.mkdir()) { RenLogger.LOGGER.warn("RenJava folder does not exist. User settings will be reset to defaults."); @@ -56,6 +63,8 @@ private void setupGame() { File imageDirectory = new File(directory, "/images/"); if (imageDirectory.mkdir()) { RenLogger.LOGGER.warn("Images folder does not exist, creating..."); + RenLogger.LOGGER.error("Default assets do not exist. Please run RSDK to install these assets or download them from RenPy."); + shutdown = true; } File savesDirectory = new File(directory, "/saves/"); if (savesDirectory.mkdir()) { From dfe431055cc181cf9f9082eba085c33dc20415b9 Mon Sep 17 00:00:00 2001 From: Hackusate_PvP Date: Fri, 24 May 2024 15:06:29 -0500 Subject: [PATCH 19/30] Fixed wrong directory typo. --- src/main/java/me/piitex/renjava/RenLoader.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/me/piitex/renjava/RenLoader.java b/src/main/java/me/piitex/renjava/RenLoader.java index 8e825a4..2597132 100644 --- a/src/main/java/me/piitex/renjava/RenLoader.java +++ b/src/main/java/me/piitex/renjava/RenLoader.java @@ -36,7 +36,7 @@ private void setupMain() { } // Verify GUI folder - File guiDirectory = new File(gameDirectory, "/gui/"); + File guiDirectory = new File(gameDirectory, "/images/gui/"); if (!guiDirectory.exists() || guiDirectory.listFiles().length == 0) { RenLogger.LOGGER.error("GUI directory does not exist. The game will not work properly, please move all assets into the newly created gui directory."); guiDirectory.mkdir(); From 4edf662daf3e59b26daeacf45b397696880c2ffb Mon Sep 17 00:00:00 2001 From: Hackusate_PvP Date: Mon, 27 May 2024 19:13:16 -0500 Subject: [PATCH 20/30] Fixed issue where images would resize to defaults when exiting hover area. --- .../events/defaults/OverlayEventListener.java | 16 ++++++++++------ .../renjava/gui/overlay/ButtonOverlay.java | 6 +++--- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/main/java/me/piitex/renjava/events/defaults/OverlayEventListener.java b/src/main/java/me/piitex/renjava/events/defaults/OverlayEventListener.java index 78817a6..3107ca3 100644 --- a/src/main/java/me/piitex/renjava/events/defaults/OverlayEventListener.java +++ b/src/main/java/me/piitex/renjava/events/defaults/OverlayEventListener.java @@ -1,6 +1,7 @@ package me.piitex.renjava.events.defaults; import javafx.scene.control.Button; +import javafx.scene.image.Image; import javafx.scene.image.ImageView; import me.piitex.renjava.RenJava; import me.piitex.renjava.events.EventListener; @@ -41,11 +42,10 @@ public void onOverlayHover(OverlayHoverEvent event) { button.setTextFill(RenJava.getInstance().getConfiguration().getHoverColor()); } if (buttonOverlay.getHoverImage() != null) { - try { - button.setGraphic(new ImageView(buttonOverlay.getHoverImage().build())); - } catch (ImageNotFoundException e) { - RenLogger.LOGGER.error(e.getMessage()); - } + Image bg = buttonOverlay.getHoverImage().getImage(); + ImageView imageView = new ImageView(bg); + imageView.setFitHeight(buttonOverlay.height()); + imageView.setFitWidth(buttonOverlay.width()); } } else { System.out.println("No hover was set for overlay"); @@ -70,7 +70,11 @@ public void onOverlayExit(OverlayExitEvent event) { button.setTextFill(buttonOverlay.getTextFill()); button.setStyle(button.getStyle()); // Re-init the style (hopefully this forces the button back to normal.) if (buttonOverlay.getImage() != null) { - button.setGraphic(new ImageView(buttonOverlay.getImage().getImage())); + //button.setGraphic(new ImageView(buttonOverlay.getImage().getImage())); + Image bg = buttonOverlay.getImage().getImage(); + ImageView imageView = new ImageView(bg); + imageView.setFitHeight(buttonOverlay.height()); + imageView.setFitWidth(buttonOverlay.width()); } } } diff --git a/src/main/java/me/piitex/renjava/gui/overlay/ButtonOverlay.java b/src/main/java/me/piitex/renjava/gui/overlay/ButtonOverlay.java index 03a74f6..e9da18d 100644 --- a/src/main/java/me/piitex/renjava/gui/overlay/ButtonOverlay.java +++ b/src/main/java/me/piitex/renjava/gui/overlay/ButtonOverlay.java @@ -34,7 +34,7 @@ public class ButtonOverlay implements Overlay, Region { private Color backgroundColor; private Color borderColor; private Color hoverColor; - private ImageLoader hoverImage; + private ImageOverlay hoverImage; private boolean hover = true; private int borderWidth = 0; private int backgroundRadius = 0; @@ -299,11 +299,11 @@ public void setHoverColor(Color hoverColor) { this.hover = true; } - public ImageLoader getHoverImage() { + public ImageOverlay getHoverImage() { return hoverImage; } - public void setHoverImage(ImageLoader hoverImage) { + public void setHoverImage(ImageOverlay hoverImage) { this.hoverImage = hoverImage; this.hover = true; } From 7559e8e454f862f0dec507c39e9a41eacd04b61c Mon Sep 17 00:00:00 2001 From: Hackusate_PvP Date: Sat, 1 Jun 2024 14:12:48 -0500 Subject: [PATCH 21/30] Added boolean parameter to main menus and theme colors. --- src/main/java/me/piitex/renjava/RenJava.java | 36 +++++++++++-------- .../configuration/RenJavaConfiguration.java | 19 ++++++++++ .../defaults/MenuClickEventListener.java | 10 +++--- .../java/me/piitex/renjava/gui/GuiLoader.java | 4 +-- 4 files changed, 48 insertions(+), 21 deletions(-) diff --git a/src/main/java/me/piitex/renjava/RenJava.java b/src/main/java/me/piitex/renjava/RenJava.java index ae26d0c..c06eed3 100644 --- a/src/main/java/me/piitex/renjava/RenJava.java +++ b/src/main/java/me/piitex/renjava/RenJava.java @@ -366,9 +366,14 @@ public void buildStage(Stage stage) { public abstract Menu buildSplashScreen(); - public abstract Menu buildTitleScreen(); + /** + * This method is used to build and design the main menu screen. + * @param rightClickMenu True if the user is in the right-clicked main menu. False if they are at the title screen. + * @return A new {@link Menu} of the configured screen. + */ + public abstract Menu buildTitleScreen(boolean rightClickMenu); - public Menu buildSideMenu() { + public Menu buildSideMenu(boolean rightClickedMenu) { Menu menu = new Menu(1920, 1080, new ImageOverlay("gui/overlay/main_menu.png")); Font uiFont = RenJava.getInstance().getConfiguration().getUiFont().getFont(); @@ -473,6 +478,9 @@ private static ButtonOverlay getButtonOverlay(int page, int index) { public Menu buildSettingsMenu() { Menu menu = new Menu(1920, 1080, new ImageOverlay("gui/main_menu.png")); + Color themeColor = getConfiguration().getThemeColor(); + Color subColor = getConfiguration().getSubColor(); + // 1 hbox 3 vboxes // Display Rollback Skip @@ -487,23 +495,23 @@ public Menu buildSettingsMenu() { rootLayout.setSpacing(100); VerticalLayout displayBox = new VerticalLayout(300, 400); - TextOverlay displayText = new TextOverlay("Display", getConfiguration().getUiFont(), 0, 0); - ButtonOverlay windowButton = new ButtonOverlay("windowed-display", "Windowed", Color.BLACK, getConfiguration().getUiFont().getFont(), 0,0,1,1); - ButtonOverlay fullscreenButton = new ButtonOverlay("windowed-fullscreen", "Fullscreen", Color.BLACK, getConfiguration().getUiFont().getFont(), 0,0,1,1); + TextOverlay displayText = new TextOverlay("Display", themeColor, getConfiguration().getUiFont(), 0, 0); + ButtonOverlay windowButton = new ButtonOverlay("windowed-display", "Windowed", subColor, getConfiguration().getUiFont().getFont(), 0,0,1,1); + ButtonOverlay fullscreenButton = new ButtonOverlay("windowed-fullscreen", "Fullscreen", subColor, getConfiguration().getUiFont().getFont(), 0,0,1,1); displayBox.addOverlays(displayText, windowButton, fullscreenButton); VerticalLayout rollbackBox = new VerticalLayout(300, 400); - TextOverlay rollbackText = new TextOverlay("Rollback", getConfiguration().getUiFont(), 0, 0); - ButtonOverlay disabledButton = new ButtonOverlay("disabled-rollback", "Disabled", Color.BLACK, getConfiguration().getUiFont().getFont(), 0,0,1,1); - ButtonOverlay leftButton = new ButtonOverlay("left-rollback", "Left", Color.BLACK, getConfiguration().getUiFont().getFont(), 0,0,1,1); - ButtonOverlay rightButton = new ButtonOverlay("right-rollback", "Right", Color.BLACK, getConfiguration().getUiFont().getFont(), 0,0,1,1); + TextOverlay rollbackText = new TextOverlay("Rollback", themeColor, getConfiguration().getUiFont(), 0, 0); + ButtonOverlay disabledButton = new ButtonOverlay("disabled-rollback", "Disabled", subColor, getConfiguration().getUiFont().getFont(), 0,0,1,1); + ButtonOverlay leftButton = new ButtonOverlay("left-rollback", "Left", subColor, getConfiguration().getUiFont().getFont(), 0,0,1,1); + ButtonOverlay rightButton = new ButtonOverlay("right-rollback", "Right", subColor, getConfiguration().getUiFont().getFont(), 0,0,1,1); rollbackBox.addOverlays(rollbackText, disabledButton, leftButton, rightButton); VerticalLayout skipBox = new VerticalLayout(300, 400); - TextOverlay skipText = new TextOverlay("Skip", getConfiguration().getUiFont(), 0, 0); - ButtonOverlay unseenTextButton = new ButtonOverlay("unseen-skip", "Unseen Text", Color.BLACK, getConfiguration().getUiFont().getFont(), 0,0,1,1); - ButtonOverlay afterChoicesButton = new ButtonOverlay("after-skip", "After Choices", Color.BLACK, getConfiguration().getUiFont().getFont(), 0,0,1,1); - ButtonOverlay transitionButton = new ButtonOverlay("transitions-skip", "Transitions", Color.BLACK, getConfiguration().getUiFont().getFont(), 0,0,1,1); + TextOverlay skipText = new TextOverlay("Skip", themeColor, getConfiguration().getUiFont(), 0, 0); + ButtonOverlay unseenTextButton = new ButtonOverlay("unseen-skip", "Unseen Text", subColor, getConfiguration().getUiFont().getFont(), 0,0,1,1); + ButtonOverlay afterChoicesButton = new ButtonOverlay("after-skip", "After Choices", subColor, getConfiguration().getUiFont().getFont(), 0,0,1,1); + ButtonOverlay transitionButton = new ButtonOverlay("transitions-skip", "Transitions", subColor, getConfiguration().getUiFont().getFont(), 0,0,1,1); skipBox.addOverlays(skipText, unseenTextButton, afterChoicesButton, transitionButton); // Add all to root layout @@ -515,7 +523,7 @@ public Menu buildSettingsMenu() { VerticalLayout musicBox = new VerticalLayout(400, 600); musicBox.setX(700); musicBox.setY(800); - TextOverlay musicVolumeText = new TextOverlay("Music Volume", getConfiguration().getUiFont(), 0, 0); + TextOverlay musicVolumeText = new TextOverlay("Music Volume", themeColor, getConfiguration().getUiFont(), 0, 0); SliderOverlay musicVolumeSlider = new SliderOverlay(100, 0, getSettings().getVolume(), 0,0); musicVolumeSlider.setBlockIncrement(10); musicVolumeSlider.setOnSliderChange(event -> { diff --git a/src/main/java/me/piitex/renjava/configuration/RenJavaConfiguration.java b/src/main/java/me/piitex/renjava/configuration/RenJavaConfiguration.java index b0bf024..500ba9b 100644 --- a/src/main/java/me/piitex/renjava/configuration/RenJavaConfiguration.java +++ b/src/main/java/me/piitex/renjava/configuration/RenJavaConfiguration.java @@ -12,6 +12,9 @@ public class RenJavaConfiguration { private final int height; private final ImageLoader gameIcon; + private Color themeColor = Color.BLACK; + private Color subColor = Color.DARKGRAY; + private FontLoader defaultFont; private FontLoader dialogueFont; private FontLoader uiFont; @@ -80,6 +83,22 @@ public ImageLoader getGameIcon() { return gameIcon; } + public Color getThemeColor() { + return themeColor; + } + + public void setThemeColor(Color themeColor) { + this.themeColor = themeColor; + } + + public Color getSubColor() { + return subColor; + } + + public void setSubColor(Color subColor) { + this.subColor = subColor; + } + public FontLoader getDialogueFont() { if (dialogueFont != null) { return dialogueFont; diff --git a/src/main/java/me/piitex/renjava/events/defaults/MenuClickEventListener.java b/src/main/java/me/piitex/renjava/events/defaults/MenuClickEventListener.java index fb14938..96af7cc 100644 --- a/src/main/java/me/piitex/renjava/events/defaults/MenuClickEventListener.java +++ b/src/main/java/me/piitex/renjava/events/defaults/MenuClickEventListener.java @@ -36,21 +36,21 @@ public void onButtonClick(ButtonClickEvent event) { if (button.getId().equalsIgnoreCase("menu-load-button")) { // NOTE: 10/20/2023 new LoadScreenView(new ImageLoader("gui/overlay/game_menu.png")).build(renJava.getStage(), true); Menu menu = renJava.buildLoadMenu(1); // Builds first page - menu.addMenu(renJava.buildSideMenu()); + menu.addMenu(renJava.buildSideMenu(true)); menu.render(); renJava.setStage(renJava.getStage(), StageType.LOAD_MENU); // Update stage type } if (button.getId().equalsIgnoreCase("menu-preference-button")) { //new PreferenceScreenView(new ImageLoader("gui/overlay/game_menu.png")).build(renJava.getStage(), true); Menu settings = renJava.buildSettingsMenu(); - settings.addMenu(renJava.buildSideMenu()); + settings.addMenu(renJava.buildSideMenu(true)); settings.render(); renJava.setStage(renJava.getStage(), StageType.OPTIONS_MENU); } if (button.getId().equalsIgnoreCase("menu-about-button")) { Menu about = renJava.buildAboutMenu(); - about.addMenu(renJava.buildSideMenu()); + about.addMenu(renJava.buildSideMenu(renJava.getPlayer().isRightClickMenu())); about.render(); renJava.setStage(renJava.getStage(), StageType.ABOUT_MENU); @@ -58,7 +58,7 @@ public void onButtonClick(ButtonClickEvent event) { if (button.getId().equalsIgnoreCase("menu-save-button")) { //new Save(1, renJava.getPlayer().getCurrentStory().getId(), renJava.getPlayer().getCurrentScene().getId()); Menu menu = renJava.buildLoadMenu(1); // Builds first page - menu.addMenu(renJava.buildSideMenu()); + menu.addMenu(renJava.buildSideMenu(renJava.getPlayer().isRightClickMenu())); menu.render(); renJava.setStage(renJava.getStage(), StageType.SAVE_MENU); @@ -108,7 +108,7 @@ public void onButtonClick(ButtonClickEvent event) { // Re-render Menu menu = renJava.buildLoadMenu(1); // Builds first page - menu.addMenu(renJava.buildSideMenu()); + menu.addMenu(renJava.buildSideMenu(true)); menu.render(); renJava.setStage(renJava.getStage(), StageType.SAVE_MENU); // Update stage type } diff --git a/src/main/java/me/piitex/renjava/gui/GuiLoader.java b/src/main/java/me/piitex/renjava/gui/GuiLoader.java index 9cbfcab..7938930 100644 --- a/src/main/java/me/piitex/renjava/gui/GuiLoader.java +++ b/src/main/java/me/piitex/renjava/gui/GuiLoader.java @@ -88,7 +88,7 @@ private void buildMainMenu() { stage = new Stage(); renJava.buildStage(stage); // Builds the stage parameters (Game Window) - Menu menu = renJava.buildTitleScreen(); + Menu menu = renJava.buildTitleScreen(false); MainMenuBuildEvent event = new MainMenuBuildEvent(menu); RenJava.callEvent(event); @@ -100,7 +100,7 @@ private void buildMainMenu() { menu.setBackgroundImage(new ImageOverlay("gui/main_menu.png")); } - Menu sideMenu = renJava.buildSideMenu(); + Menu sideMenu = renJava.buildSideMenu(false); SideMenuBuildEvent sideMenuBuildEvent = new SideMenuBuildEvent(sideMenu); RenJava.callEvent(sideMenuBuildEvent); From 871a44f73a50df783d7b7542be80c2ca857ad542 Mon Sep 17 00:00:00 2001 From: Hackusate_PvP Date: Sat, 1 Jun 2024 14:13:38 -0500 Subject: [PATCH 22/30] Added ability to change text fill color. --- .../java/me/piitex/renjava/gui/Element.java | 3 +++ .../renjava/gui/overlay/TextOverlay.java | 22 +++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/main/java/me/piitex/renjava/gui/Element.java b/src/main/java/me/piitex/renjava/gui/Element.java index 4a63cfa..b8a2c8b 100644 --- a/src/main/java/me/piitex/renjava/gui/Element.java +++ b/src/main/java/me/piitex/renjava/gui/Element.java @@ -61,6 +61,9 @@ public Element(Overlay overlay) { Font font = textOverlay.getFontLoader().getFont(); text.setFont(font); } + if (textOverlay.getTextFillColor() != null) { + text.setFill(textOverlay.getTextFillColor()); + } text.setTranslateX(textOverlay.x()); text.setTranslateY(textOverlay.y()); this.node = text; diff --git a/src/main/java/me/piitex/renjava/gui/overlay/TextOverlay.java b/src/main/java/me/piitex/renjava/gui/overlay/TextOverlay.java index 824a02c..f8eb207 100644 --- a/src/main/java/me/piitex/renjava/gui/overlay/TextOverlay.java +++ b/src/main/java/me/piitex/renjava/gui/overlay/TextOverlay.java @@ -1,6 +1,7 @@ package me.piitex.renjava.gui.overlay; +import javafx.scene.paint.Color; import javafx.scene.text.Text; import me.piitex.renjava.api.loaders.FontLoader; import me.piitex.renjava.api.scenes.transitions.Transitions; @@ -10,6 +11,7 @@ public class TextOverlay implements Overlay, Region { private final Text text; + private Color textFillColor; private FontLoader fontLoader; private double x; private double y; @@ -27,6 +29,13 @@ public TextOverlay(String text, double x, double y) { this.y = y; } + public TextOverlay(String text, Color textFillColor, double x, double y) { + this.text = new Text(text); + this.textFillColor = textFillColor; + this.x = x; + this.y = y; + } + public TextOverlay(String text, FontLoader fontLoader, double x, double y) { this.text = new Text(text); this.fontLoader = fontLoader; @@ -34,6 +43,15 @@ public TextOverlay(String text, FontLoader fontLoader, double x, double y) { this.y = y; } + public TextOverlay(String text, Color textFillColor, FontLoader fontLoader, double x, double y) { + this.text = new Text(text); + this.textFillColor = textFillColor; + this.fontLoader = fontLoader; + this.x = x; + this.y = y; + } + + public TextOverlay(Text text, double x, double y) { this.text = text; this.x = x; @@ -51,6 +69,10 @@ public Text getText() { return text; } + public Color getTextFillColor() { + return textFillColor; + } + @Override public double x() { return x; From 0cca5e183d459109be25bf71b262474385741216 Mon Sep 17 00:00:00 2001 From: HackusatePvP Date: Fri, 14 Jun 2024 08:53:16 -0500 Subject: [PATCH 23/30] Forgot to add missing parameters to updated framework functions. --- .../renjava/events/defaults/MenuClickEventListener.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/main/java/me/piitex/renjava/events/defaults/MenuClickEventListener.java b/src/main/java/me/piitex/renjava/events/defaults/MenuClickEventListener.java index 96af7cc..4bcc64f 100644 --- a/src/main/java/me/piitex/renjava/events/defaults/MenuClickEventListener.java +++ b/src/main/java/me/piitex/renjava/events/defaults/MenuClickEventListener.java @@ -2,13 +2,9 @@ import javafx.application.Platform; import javafx.scene.control.Button; -import javafx.scene.image.ImageView; import me.piitex.renjava.RenJava; import me.piitex.renjava.events.types.*; -import me.piitex.renjava.gui.exceptions.ImageNotFoundException; -import me.piitex.renjava.gui.overlay.ButtonOverlay; -import me.piitex.renjava.gui.overlay.Overlay; import me.piitex.renjava.loggers.RenLogger; import me.piitex.renjava.api.saves.Save; import me.piitex.renjava.events.EventListener; @@ -22,6 +18,7 @@ public class MenuClickEventListener implements EventListener { @Listener public void onButtonClick(ButtonClickEvent event) { Button button = event.getButton(); + if (button.getId().equalsIgnoreCase("menu-start-button")) { RenLogger.LOGGER.info("Creating new game..."); renJava.createBaseData(); @@ -36,14 +33,14 @@ public void onButtonClick(ButtonClickEvent event) { if (button.getId().equalsIgnoreCase("menu-load-button")) { // NOTE: 10/20/2023 new LoadScreenView(new ImageLoader("gui/overlay/game_menu.png")).build(renJava.getStage(), true); Menu menu = renJava.buildLoadMenu(1); // Builds first page - menu.addMenu(renJava.buildSideMenu(true)); + menu.addMenu(renJava.buildSideMenu(renJava.getPlayer().isRightClickMenu())); menu.render(); renJava.setStage(renJava.getStage(), StageType.LOAD_MENU); // Update stage type } if (button.getId().equalsIgnoreCase("menu-preference-button")) { //new PreferenceScreenView(new ImageLoader("gui/overlay/game_menu.png")).build(renJava.getStage(), true); Menu settings = renJava.buildSettingsMenu(); - settings.addMenu(renJava.buildSideMenu(true)); + settings.addMenu(renJava.buildSideMenu(renJava.getPlayer().isRightClickMenu())); settings.render(); renJava.setStage(renJava.getStage(), StageType.OPTIONS_MENU); From c9b4dfc035c3404d4ffd8ffa873551ee679e1c9d Mon Sep 17 00:00:00 2001 From: HackusatePvP Date: Fri, 14 Jun 2024 08:54:46 -0500 Subject: [PATCH 24/30] Save button will no longer appear on the main menu. --- src/main/java/me/piitex/renjava/RenJava.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/me/piitex/renjava/RenJava.java b/src/main/java/me/piitex/renjava/RenJava.java index c06eed3..96286b0 100644 --- a/src/main/java/me/piitex/renjava/RenJava.java +++ b/src/main/java/me/piitex/renjava/RenJava.java @@ -391,7 +391,11 @@ public Menu buildSideMenu(boolean rightClickedMenu) { layout.setX(50); layout.setY(250); layout.setSpacing(20); - layout.addOverlays(startButton, loadButton, saveButton, optionsButton, aboutButton); + layout.addOverlays(startButton, loadButton); + if (rightClickedMenu) { + layout.addOverlays(saveButton); + } + layout.addOverlays(optionsButton, aboutButton); // You don't have to add the button overlays just add the layout which already contains the overlays. menu.addLayout(layout); From bdfb517b836ac7e5cf619fa302ed6e49134e7d78 Mon Sep 17 00:00:00 2001 From: HackusatePvP Date: Fri, 14 Jun 2024 08:56:20 -0500 Subject: [PATCH 25/30] More missing updates. --- .../piitex/renjava/events/defaults/GameFlowEventListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/me/piitex/renjava/events/defaults/GameFlowEventListener.java b/src/main/java/me/piitex/renjava/events/defaults/GameFlowEventListener.java index 0f7f3d2..0686492 100644 --- a/src/main/java/me/piitex/renjava/events/defaults/GameFlowEventListener.java +++ b/src/main/java/me/piitex/renjava/events/defaults/GameFlowEventListener.java @@ -118,7 +118,7 @@ public void onKeyPress(KeyPressEvent event) { } if (code == KeyCode.CONTROL) { - playNextScene(); + skipHeld = true; } } From a332e9583d57c1171d188cf2e97fdc93cb3cffba Mon Sep 17 00:00:00 2001 From: HackusatePvP Date: Fri, 14 Jun 2024 08:56:48 -0500 Subject: [PATCH 26/30] More missing updates. --- .../events/defaults/GameFlowEventListener.java | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/main/java/me/piitex/renjava/events/defaults/GameFlowEventListener.java b/src/main/java/me/piitex/renjava/events/defaults/GameFlowEventListener.java index 0686492..1ed093f 100644 --- a/src/main/java/me/piitex/renjava/events/defaults/GameFlowEventListener.java +++ b/src/main/java/me/piitex/renjava/events/defaults/GameFlowEventListener.java @@ -1,5 +1,6 @@ package me.piitex.renjava.events.defaults; +import javafx.application.Platform; import javafx.geometry.Insets; import javafx.scene.input.KeyCode; import javafx.scene.input.MouseButton; @@ -23,18 +24,12 @@ import me.piitex.renjava.events.types.*; import me.piitex.renjava.gui.Menu; import me.piitex.renjava.gui.StageType; -import me.piitex.renjava.tasks.KeyHeldTask; import org.slf4j.Logger;; -import java.awt.*; -import java.util.Timer; - public class GameFlowEventListener implements EventListener { // Also experimental, task that runs while the ctrl key is held. Maybe I can change this to a do while or something... I'm not sure. - private KeyHeldTask heldTask; - - private final Timer timer = new Timer(); + private boolean skipHeld = false; private static final RenJava renJava = RenJava.getInstance(); @@ -70,8 +65,8 @@ public void onMouseClick(MouseClickEvent event) { // Open Main Menu if (!player.isRightClickMenu()) { logger.info("Player is not in menu, opening menu..."); - Menu menu = renJava.buildTitleScreen(); - menu.addMenu(renJava.buildSideMenu()); + Menu menu = renJava.buildTitleScreen(true); + menu.addMenu(renJava.buildSideMenu(true)); MainMenuBuildEvent buildEvent = new MainMenuBuildEvent(menu); RenJava.callEvent(buildEvent); @@ -211,7 +206,7 @@ private void playNextScene() { } if (scene.getIndex() == story.getLastIndex()) { - logger.info("Calling story end event..."); + //logger.info("Calling story end event..."); StoryEndEvent storyEndEvent = new StoryEndEvent(story); RenJava.callEvent(storyEndEvent); return; From bb3a4569979f758ff85d3743fe65874f2787a7eb Mon Sep 17 00:00:00 2001 From: HackusatePvP Date: Fri, 14 Jun 2024 09:51:29 -0500 Subject: [PATCH 27/30] Added return/quit button to side menu. --- src/main/java/me/piitex/renjava/RenJava.java | 12 +++++++ .../defaults/MenuClickEventListener.java | 36 +++++++++++-------- 2 files changed, 33 insertions(+), 15 deletions(-) diff --git a/src/main/java/me/piitex/renjava/RenJava.java b/src/main/java/me/piitex/renjava/RenJava.java index 96286b0..4aa3174 100644 --- a/src/main/java/me/piitex/renjava/RenJava.java +++ b/src/main/java/me/piitex/renjava/RenJava.java @@ -400,6 +400,18 @@ public Menu buildSideMenu(boolean rightClickedMenu) { // You don't have to add the button overlays just add the layout which already contains the overlays. menu.addLayout(layout); + ButtonOverlay returnButton; + + + if (getStageType() == StageType.MAIN_MENU) { + returnButton = new ButtonOverlay("menu-quit-button", "Quit", Color.BLACK, uiFont, Color.TRANSPARENT, Color.TRANSPARENT, hoverColor, 1, 1); + } else { + returnButton = new ButtonOverlay("menu-return-button", "Return", Color.BLACK, uiFont, Color.TRANSPARENT, Color.TRANSPARENT, hoverColor, 1, 1); + } + returnButton.setX(25); + returnButton.setY(1000); + menu.addOverlay(returnButton); + return menu; } diff --git a/src/main/java/me/piitex/renjava/events/defaults/MenuClickEventListener.java b/src/main/java/me/piitex/renjava/events/defaults/MenuClickEventListener.java index 4bcc64f..565ea6e 100644 --- a/src/main/java/me/piitex/renjava/events/defaults/MenuClickEventListener.java +++ b/src/main/java/me/piitex/renjava/events/defaults/MenuClickEventListener.java @@ -18,6 +18,7 @@ public class MenuClickEventListener implements EventListener { @Listener public void onButtonClick(ButtonClickEvent event) { Button button = event.getButton(); + boolean rightClicked = renJava.getPlayer().isRightClickMenu(); if (button.getId().equalsIgnoreCase("menu-start-button")) { RenLogger.LOGGER.info("Creating new game..."); @@ -31,34 +32,28 @@ public void onButtonClick(ButtonClickEvent event) { renJava.start(); } if (button.getId().equalsIgnoreCase("menu-load-button")) { - // NOTE: 10/20/2023 new LoadScreenView(new ImageLoader("gui/overlay/game_menu.png")).build(renJava.getStage(), true); + renJava.setStage(renJava.getStage(), StageType.LOAD_MENU); Menu menu = renJava.buildLoadMenu(1); // Builds first page - menu.addMenu(renJava.buildSideMenu(renJava.getPlayer().isRightClickMenu())); + menu.addMenu(renJava.buildSideMenu(rightClicked)); menu.render(); - renJava.setStage(renJava.getStage(), StageType.LOAD_MENU); // Update stage type } if (button.getId().equalsIgnoreCase("menu-preference-button")) { - //new PreferenceScreenView(new ImageLoader("gui/overlay/game_menu.png")).build(renJava.getStage(), true); + renJava.setStage(renJava.getStage(), StageType.OPTIONS_MENU); Menu settings = renJava.buildSettingsMenu(); - settings.addMenu(renJava.buildSideMenu(renJava.getPlayer().isRightClickMenu())); - + settings.addMenu(renJava.buildSideMenu(rightClicked)); settings.render(); - renJava.setStage(renJava.getStage(), StageType.OPTIONS_MENU); } if (button.getId().equalsIgnoreCase("menu-about-button")) { + renJava.setStage(renJava.getStage(), StageType.ABOUT_MENU); Menu about = renJava.buildAboutMenu(); - about.addMenu(renJava.buildSideMenu(renJava.getPlayer().isRightClickMenu())); - + about.addMenu(renJava.buildSideMenu(rightClicked)); about.render(); - renJava.setStage(renJava.getStage(), StageType.ABOUT_MENU); } if (button.getId().equalsIgnoreCase("menu-save-button")) { - //new Save(1, renJava.getPlayer().getCurrentStory().getId(), renJava.getPlayer().getCurrentScene().getId()); + renJava.setStage(renJava.getStage(), StageType.SAVE_MENU); Menu menu = renJava.buildLoadMenu(1); // Builds first page - menu.addMenu(renJava.buildSideMenu(renJava.getPlayer().isRightClickMenu())); + menu.addMenu(renJava.buildSideMenu(rightClicked)); menu.render(); - - renJava.setStage(renJava.getStage(), StageType.SAVE_MENU); } if (button.getId().equalsIgnoreCase("menu-quit-button")) { renJava.getAddonLoader().disable(); @@ -104,10 +99,21 @@ public void onButtonClick(ButtonClickEvent event) { save.write(); // Re-render + renJava.setStage(renJava.getStage(), StageType.SAVE_MENU); Menu menu = renJava.buildLoadMenu(1); // Builds first page menu.addMenu(renJava.buildSideMenu(true)); menu.render(); - renJava.setStage(renJava.getStage(), StageType.SAVE_MENU); // Update stage type + } + if (button.getId().equalsIgnoreCase("menu-return-button")) { + if (renJava.getStageType() == StageType.MAIN_MENU) { + renJava.getAddonLoader().disable(); + Platform.exit(); + return; + } + renJava.setStage(renJava.getStage(), StageType.MAIN_MENU); + Menu menu = renJava.buildTitleScreen(rightClicked); + menu.addMenu(renJava.buildSideMenu(rightClicked)); + menu.render(); } } From 06c416af20fdd74b82641aa40c84f0e4510a80c2 Mon Sep 17 00:00:00 2001 From: HackusatePvP Date: Fri, 14 Jun 2024 10:14:41 -0500 Subject: [PATCH 28/30] Fixed NPE issue when right-clicking on the main menu. --- .../me/piitex/renjava/events/defaults/GameFlowEventListener.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/me/piitex/renjava/events/defaults/GameFlowEventListener.java b/src/main/java/me/piitex/renjava/events/defaults/GameFlowEventListener.java index 1ed093f..8857f59 100644 --- a/src/main/java/me/piitex/renjava/events/defaults/GameFlowEventListener.java +++ b/src/main/java/me/piitex/renjava/events/defaults/GameFlowEventListener.java @@ -80,6 +80,7 @@ public void onMouseClick(MouseClickEvent event) { } else { // Return to previous screen RenScene renScene = player.getCurrentScene(); + if (renScene == null) return; Menu menu = renScene.build(true); SceneBuildEvent sceneBuildEvent = new SceneBuildEvent(renScene, menu); RenJava.callEvent(sceneBuildEvent); From 9cac3f7c700df53ee3373b90b622d527537fa95d Mon Sep 17 00:00:00 2001 From: HackusatePvP Date: Fri, 14 Jun 2024 10:15:07 -0500 Subject: [PATCH 29/30] Code cleanup. --- src/main/java/me/piitex/renjava/Launch.java | 3 +-- src/main/java/me/piitex/renjava/events/Cancellable.java | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/me/piitex/renjava/Launch.java b/src/main/java/me/piitex/renjava/Launch.java index fd93949..a276d52 100644 --- a/src/main/java/me/piitex/renjava/Launch.java +++ b/src/main/java/me/piitex/renjava/Launch.java @@ -72,7 +72,6 @@ public static void main(String[] args) { } private static void loadClass(Class clazz, String[] args) { - //FIXME: For performance save the path of the main class to reduce loading time try { File file = new File(System.getProperty("user.dir") + "/renjava/build.info"); if (!file.exists()) { @@ -104,7 +103,7 @@ private static void loadClass(Class clazz, String[] args) { try { - // Creates a new instance of the application and executes the conductor. + // Creates a new instance of the application and executes the constructor. Object o = clazz.getDeclaredConstructor().newInstance(); RenJava renJava = (RenJava) o; if (renJava.getClass().isAnnotationPresent(Game.class)) { diff --git a/src/main/java/me/piitex/renjava/events/Cancellable.java b/src/main/java/me/piitex/renjava/events/Cancellable.java index 21083d0..c2f08f1 100644 --- a/src/main/java/me/piitex/renjava/events/Cancellable.java +++ b/src/main/java/me/piitex/renjava/events/Cancellable.java @@ -3,5 +3,6 @@ public interface Cancellable { void setCancelled(boolean cancelled); + boolean isCancelled(); } From 4e3d32929e11ccf2a906528f53c6fbe8b30fd803 Mon Sep 17 00:00:00 2001 From: HackusatePvP Date: Fri, 14 Jun 2024 10:16:16 -0500 Subject: [PATCH 30/30] Pom's for next build. --- dependency-reduced-pom.xml | 2 +- pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dependency-reduced-pom.xml b/dependency-reduced-pom.xml index dc8d22d..d2bfac9 100644 --- a/dependency-reduced-pom.xml +++ b/dependency-reduced-pom.xml @@ -4,7 +4,7 @@ me.piitex RenJava RenJava - 0.1.0-SNAPSHOT + 0.1.26-SNAPSHOT diff --git a/pom.xml b/pom.xml index d6ebc2a..90abb5e 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ me.piitex RenJava - 0.1.0-SNAPSHOT + 0.1.26-SNAPSHOT RenJava