Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions PROJECT.md
Original file line number Diff line number Diff line change
@@ -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. <u>This requires the Android SDK, which can be downloaded and configured simply by running the universal [setup file](setup/android_setup.sh)!</u>
Expand Down Expand Up @@ -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).
Expand Down
35 changes: 19 additions & 16 deletions flixelgdx/src/main/java/me/stringdotjar/flixelgdx/FlixelGame.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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();
}
});
}
}
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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() {}
}
4 changes: 2 additions & 2 deletions funkin/src/main/java/me/stringdotjar/funkin/FunkinGame.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ 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
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() {
Expand Down