JME JavaFX Launcher
Requires: Java 11
An implementation of a JavaFX launcher that replaces the built-in Settings Dialog. Very similar to the “Fallout 4” style launcher, whereby when you start the game you get the launcher first before playing the game.
The launcher allows the user to select:
- Full Screen Mode
- Resolution
- Anistropic Filtering
- Anti-Aliasing
- Ambient Occlusion
- Bloom
- Depth of Field
These settings and filters are applied (or not) automatically.
Settings are saved as JSON and are therefore persistent. The launcher is customizable and will also allow you to restart your game. This means the user can also modify things in-game (e.g. anistropic filtering or something that requires a restart).
This also serves as a “working version” of how to go about creating a launcher yourself - something a lot of people have been interested in doing.
import com.jme3.app.SimpleApplication;
import com.jme3.input.KeyInput;
import com.jme3.input.controls.ActionListener;
import com.jme3.input.controls.KeyTrigger;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.post.FilterPostProcessor;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Box;
import java.io.File;
public class Main extends SimpleApplication implements ActionListener {
public static void main(String... args) {
JfxLauncher.initialize(Main.class);
JfxLauncher.getInstance().setTitle("Some Amazing Game");
JfxLauncher.getInstance().setSettingsFile(new File("./settings.json"));
JfxLauncher.getInstance().show();
}
@Override
public void simpleInitApp() {
FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
viewPort.addProcessor(fpp);
JfxLauncher.getInstance().applySettings(fpp);
// create a scene...
Geometry box = new Geometry("Box", new Box(1,1,1));
box.setMaterial(new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"));
box.getMaterial().setColor("Color", ColorRGBA.Blue);
rootNode.attachChild(box);
// add a keybinding to test restart mode.
inputManager.addMapping("restart", new KeyTrigger(KeyInput.KEY_R));
inputManager.addListener(this, "restart");
}
@Override
public void onAction(String name, boolean isPressed, float tpf) {
if (name.equals("restart") && !isPressed) {
JfxLauncher.getInstance().setRestart(true);
stop(true);
}
}
}
Source Code
Source code is - as always - available on GitHub. It will also be made available on jMonkeyStore as soon as I get a moment to add it.
https://github.com/jayfella/jme-jfx-launcher
Demonstration App
Download and double-click the jar to run, or
java -jar jme-jfx-launcher-1.0-all.jar
https://github.com/jayfella/jme-jfx-launcher/releases/download/1.0.1/jme-jfx-launcher-1.0.1-all.jar