diff --git a/PROJECT.md b/PROJECT.md index 6681816..ebc1a2e 100644 --- a/PROJECT.md +++ b/PROJECT.md @@ -1,11 +1,11 @@ ## This is a [libGDX](https://libgdx.com/) project generated with [gdx-liftoff](https://github.com/libgdx/gdx-liftoff). -# Platforms +# Project Modules -FNF:JE is designed to run on multiple different platforms. Below are the different modules that hold the code for each one. +FNF:JE has many different submodules to organize the environment. - `funkin`: The core part of the game's code. This is where all the game logic is implemented. -- `flixelgdx`: Custom framework that bridges [HaxeFlixel](https://haxeflixel.com/) and is based on libGDX. This is where the HaxeFlixel-like API is implemented. +- `flixelgdx`: Custom framework that bridges [HaxeFlixel](https://haxeflixel.com/) to Java and is based on libGDX. This is where the HaxeFlixel-like API is implemented. - `polyverse`: Custom library for adding modding capabilities to the game. - `lwjgl3`: Primary desktop platform using [LWJGL3](https://www.lwjgl.org/). This is what launches the desktop versions of the game! - `android`: Android mobile platform. This requires the Android SDK, which can be downloaded and configured simply by running the universal [setup file](setup/android_setup.sh)! @@ -34,7 +34,7 @@ The Gradle wrapper was included, so you can run Gradle tasks using `gradlew.bat` - `clean`: removes `build` folders, which store compiled classes and built archives. - `eclipse`: generates Eclipse project data. - `idea`: generates IntelliJ project data. -- `funkin:exportModSDK`: Exports the game's API and its dependencies as `.jar` files to the assets folder. +- `funkin:exportModSDK`: exports the game's API and its dependencies as `.jar` files to the assets folder. - `lwjgl3:jar`: builds the game's runnable jar, which can be found at `lwjgl3/build/libs`. - `lwjgl3:run`: starts the desktop version of the game. - `test`: runs unit tests (if any). diff --git a/flixelgdx/src/main/java/me/stringdotjar/flixelgdx/FlixelGame.java b/flixelgdx/src/main/java/me/stringdotjar/flixelgdx/FlixelGame.java index cfca1f4..8d1b17a 100644 --- a/flixelgdx/src/main/java/me/stringdotjar/flixelgdx/FlixelGame.java +++ b/flixelgdx/src/main/java/me/stringdotjar/flixelgdx/FlixelGame.java @@ -19,6 +19,8 @@ import me.stringdotjar.flixelgdx.util.FlixelConstants; import me.stringdotjar.flixelgdx.util.FlixelRuntimeUtil; +import java.awt.EventQueue; + import static me.stringdotjar.flixelgdx.signal.FlixelSignalData.RenderSignalData; /** @@ -217,6 +219,23 @@ public void dispose() { Flixel.Signals.postGameClose.dispatch(); } + /** + * Configurers Flixel's crash handler to safely catch uncaught exceptions and gracefully close the game. + */ + protected void configureCrashHandler() { + Thread.setDefaultUncaughtExceptionHandler((thread, throwable) -> { + String logs = FlixelRuntimeUtil.getFullExceptionMessage(throwable); + String msg = "There was an uncaught exception on thread \"" + thread.getName() + "\"!\n" + logs; + Flixel.error(FlixelConstants.System.LOG_TAG, msg); + FlixelRuntimeUtil.showErrorAlert("Uncaught Exception", msg); + dispose(); + // Only use Gdx.app.exit() on non-iOS platforms to avoid App Store guideline violations! + if (Gdx.app.getType() != Application.ApplicationType.iOS) { + Gdx.app.exit(); + } + }); + } + public String getTitle() { return title; } @@ -252,20 +271,4 @@ public Texture getBgTexture() { public boolean isMinimized() { return isMinimized; } - - /** - * Configurers Flixel's crash handler to safely catch uncaught exceptions and gracefully close the game. - */ - protected void configureCrashHandler() { - Thread.setDefaultUncaughtExceptionHandler((thread, throwable) -> { - String logs = FlixelRuntimeUtil.getFullExceptionMessage(throwable); - String msg = "There was an uncaught exception on thread \"" + thread.getName() + "\"!\n" + logs; - Flixel.error(FlixelConstants.System.LOG_TAG, msg); - dispose(); - // Only use Gdx.app.exit() on non-iOS platforms to avoid App Store guideline violations! - if (Gdx.app.getType() != Application.ApplicationType.iOS) { - Gdx.app.exit(); - } - }); - } } diff --git a/flixelgdx/src/main/java/me/stringdotjar/flixelgdx/util/FlixelRuntimeUtil.java b/flixelgdx/src/main/java/me/stringdotjar/flixelgdx/util/FlixelRuntimeUtil.java index 4d8a48c..a321235 100644 --- a/flixelgdx/src/main/java/me/stringdotjar/flixelgdx/util/FlixelRuntimeUtil.java +++ b/flixelgdx/src/main/java/me/stringdotjar/flixelgdx/util/FlixelRuntimeUtil.java @@ -1,5 +1,8 @@ package me.stringdotjar.flixelgdx.util; +import javax.swing.JOptionPane; +import java.awt.EventQueue; + /** * Utility class for handling operation related to the runtime environment, including OS detection, * extracting runtime information, obtaining information from exceptions, and other related tasks. @@ -52,5 +55,48 @@ public static String getFullExceptionMessage(Throwable exception) { return messageBuilder.toString(); } + /** + * Displays a new general info alert window with the given title and message. + * + * @param title The title of the alert window. + * @param message The message content to display in the alert window. + */ + public static void showInfoAlert(String title, Object message) { + showAlert(title, message, JOptionPane.INFORMATION_MESSAGE); + } + + /** + * Displays a new warning alert window with the given title and message. + * + * @param title The title of the alert window. + * @param message The message content to display in the alert window. + */ + public static void showWarningAlert(String title, Object message) { + showAlert(title, message, JOptionPane.WARNING_MESSAGE); + } + + /** + * Displays a new error alert window with the given title and message. + * + * @param title The title of the alert window. + * @param message The message content to display in the alert window. + */ + public static void showErrorAlert(String title, Object message) { + showAlert(title, message, JOptionPane.ERROR_MESSAGE); + } + + /** + * Displays a new alert window with the given title, message, and type. + * + * @param title The title of the alert window. + * @param message The message content to display in the alert window. + * @param type The type of alert (e.g., JOptionPane.INFORMATION_MESSAGE). + */ + public static void showAlert(String title, Object message, int type) { + EventQueue.invokeLater(() -> { + JOptionPane.showMessageDialog(null, message, title, type); + }); + } + private FlixelRuntimeUtil() {} } diff --git a/funkin/src/main/java/me/stringdotjar/funkin/FunkinGame.java b/funkin/src/main/java/me/stringdotjar/funkin/FunkinGame.java index 33ac973..9f424ae 100644 --- a/funkin/src/main/java/me/stringdotjar/funkin/FunkinGame.java +++ b/funkin/src/main/java/me/stringdotjar/funkin/FunkinGame.java @@ -55,7 +55,7 @@ public void onWindowUnfocused() { super.onWindowUnfocused(); lastVolume = Flixel.getMasterVolume(); Flixel.setMasterVolume(0.008f); - Polyverse.forEachScript(SystemScript.class, SystemScript::onWindowUnfocused); + Polyverse.forEachScriptSuccessor(SystemScript.class, SystemScript::onWindowUnfocused); } @Override @@ -63,7 +63,7 @@ public void onWindowMinimized(boolean iconified) { super.onWindowMinimized(iconified); lastVolume = Flixel.getMasterVolume(); Flixel.setMasterVolume(0); - Polyverse.forEachScript(SystemScript.class, script -> script.onWindowMinimized(iconified)); + Polyverse.forEachScriptSuccessor(SystemScript.class, script -> script.onWindowMinimized(iconified)); } private void configurePolyverse() {