Skip to content

Commit

Permalink
Build 0.1.26
Browse files Browse the repository at this point in the history
Build 0.1.26 Beta
  • Loading branch information
HackusatePvP committed Jun 14, 2024
2 parents cfb791d + 4e3d329 commit 6a46587
Show file tree
Hide file tree
Showing 43 changed files with 1,762 additions and 260 deletions.
674 changes: 674 additions & 0 deletions LICENSE.md

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
27 changes: 0 additions & 27 deletions changes/CHANGELOG.md

This file was deleted.

2 changes: 1 addition & 1 deletion dependency-reduced-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>me.piitex</groupId>
<artifactId>RenJava</artifactId>
<name>RenJava</name>
<version>0.1.0-SNAPSHOT</version>
<version>0.1.26-SNAPSHOT</version>
<build>
<resources>
<resource>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>me.piitex</groupId>
<artifactId>RenJava</artifactId>
<version>0.1.0-SNAPSHOT</version>
<version>0.1.26-SNAPSHOT</version>
<name>RenJava</name>

<properties>
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/me/piitex/renjava/Launch.java
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down Expand Up @@ -102,8 +101,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 constructor.
Object o = clazz.getDeclaredConstructor().newInstance();
RenJava renJava = (RenJava) o;
if (renJava.getClass().isAnnotationPresent(Game.class)) {
Expand Down Expand Up @@ -138,7 +138,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());
}
Expand Down
135 changes: 114 additions & 21 deletions src/main/java/me/piitex/renjava/RenJava.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -24,20 +25,15 @@
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;
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.ImageOverlay;
import me.piitex.renjava.gui.overlay.TextFlowOverlay;
import me.piitex.renjava.loggers.RenLogger;
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
Expand Down Expand Up @@ -118,6 +114,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);
Expand Down Expand Up @@ -369,31 +366,52 @@ 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();

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);
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);

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;
}

Expand Down Expand Up @@ -441,7 +459,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) {
Expand Down Expand Up @@ -474,23 +492,98 @@ 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
// 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);

return null;
VerticalLayout displayBox = new VerticalLayout(300, 400);
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", 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", 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
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", themeColor, 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() {
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;
}

Expand Down
35 changes: 13 additions & 22 deletions src/main/java/me/piitex/renjava/RenLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
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;
;

public class RenLoader {
private final RenJava renJava;
Expand All @@ -21,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;
Expand All @@ -32,22 +29,24 @@ 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.");
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, "/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();
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.");
}
for (File file : new File(System.getProperty("user.dir")).listFiles()) {
if (file.getName().endsWith(".txt.lck")) {
file.delete();
}
}
}

private void setupGame() {
Expand All @@ -64,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()) {
Expand All @@ -73,16 +74,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();
}
Expand Down
Loading

0 comments on commit 6a46587

Please sign in to comment.