2022-02-04 17:44:02 +00:00
|
|
|
package love.distributedrebirth.gdxapp;
|
2022-01-28 11:00:59 +00:00
|
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
import com.badlogic.gdx.Game;
|
|
|
|
import com.badlogic.gdx.Gdx;
|
|
|
|
import com.badlogic.gdx.Screen;
|
|
|
|
import com.badlogic.gdx.Input.Keys;
|
|
|
|
import com.badlogic.gdx.graphics.OrthographicCamera;
|
|
|
|
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
|
|
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
|
|
|
import com.badlogic.gdx.utils.ScreenUtils;
|
|
|
|
|
|
|
|
import imgui.ImGui;
|
|
|
|
import imgui.type.ImBoolean;
|
2022-02-04 13:39:25 +00:00
|
|
|
import love.distributedrebirth.bassboonyd.BãßBȍőnAuthorInfoʸᴰ;
|
2022-02-04 17:44:02 +00:00
|
|
|
import love.distributedrebirth.gdxapp.matrix4d.ScreenMatrix4D;
|
|
|
|
import love.distributedrebirth.gdxapp.music.MusicManager;
|
|
|
|
import love.distributedrebirth.gdxapp.music.MusicPlayerRenderer;
|
|
|
|
import love.distributedrebirth.gdxapp.music.MusicSongType;
|
2022-02-05 13:43:14 +00:00
|
|
|
import love.distributedrebirth.gdxapp.screen.SystemBasePartRenderer;
|
2022-02-04 17:44:02 +00:00
|
|
|
import love.distributedrebirth.gdxapp.screen.BasicConsoleRenderer;
|
|
|
|
import love.distributedrebirth.gdxapp.screen.HebrewWalletRenderer;
|
|
|
|
import love.distributedrebirth.gdxapp.screen.ScreenCredits;
|
|
|
|
import love.distributedrebirth.gdxapp.screen.ScreenDefault;
|
|
|
|
import love.distributedrebirth.gdxapp.screen.ScreenHelp;
|
|
|
|
import love.distributedrebirth.gdxapp.screen.ScreenIntro;
|
|
|
|
import love.distributedrebirth.gdxapp.screen.ScreenIntroMission;
|
2022-02-04 22:17:52 +00:00
|
|
|
import love.distributedrebirth.gdxapp.screen.ScreenLoading;
|
2022-02-04 17:44:02 +00:00
|
|
|
import love.distributedrebirth.gdxapp.screen.ScreenUnicode4D;
|
2022-02-05 13:43:14 +00:00
|
|
|
import love.distributedrebirth.gdxapp.screen.SystemBaseGlyphRenderer;
|
2022-02-06 16:19:05 +00:00
|
|
|
import love.distributedrebirth.numberxd.base2t.Base2Terminator;
|
2022-02-03 13:21:08 +00:00
|
|
|
import love.distributedrebirth.numberxd.base2t.part.warp.TOSWarpCore;
|
2022-02-05 16:00:19 +00:00
|
|
|
import love.distributedrebirth.numberxd.base2t.part.warp.TOSWarpCoreDriver;
|
|
|
|
import love.distributedrebirth.numberxd.base2t.part.warp.WaterBucket;
|
2022-02-06 16:39:15 +00:00
|
|
|
import love.distributedrebirth.numberxd.glyph.BaseGlyphSet;
|
2022-01-28 11:00:59 +00:00
|
|
|
import net.spookygames.gdx.nativefilechooser.NativeFileChooser;
|
|
|
|
|
2022-01-29 04:50:02 +00:00
|
|
|
/**
|
2022-01-31 12:40:01 +00:00
|
|
|
* Main loop render dispatcher and event handling.
|
2022-01-29 04:50:02 +00:00
|
|
|
*/
|
2022-02-04 13:39:25 +00:00
|
|
|
@BãßBȍőnAuthorInfoʸᴰ(name = "willemtsade", copyright = "©Δ∞ 仙上主天")
|
2022-02-06 23:09:29 +00:00
|
|
|
public class GDXAppMain extends Game {
|
2022-02-04 22:17:52 +00:00
|
|
|
private int lazyIntCnt = 33;
|
2022-01-28 11:00:59 +00:00
|
|
|
private List<String> args;
|
|
|
|
public NativeFileChooser fileChooser;
|
|
|
|
public SpriteBatch batch;
|
|
|
|
public BitmapFont font;
|
|
|
|
public OrthographicCamera camera;
|
2022-01-31 22:05:27 +00:00
|
|
|
public final int viewWidth;
|
|
|
|
public final int viewHeight;
|
2022-01-28 11:00:59 +00:00
|
|
|
public MusicManager music;
|
|
|
|
|
|
|
|
private Map<Class<? extends Screen>,Screen> screens;
|
2022-01-28 13:04:24 +00:00
|
|
|
private Map<Class<? extends ImGuiRenderer>,ImGuiRenderer> widgets;
|
2022-01-28 11:00:59 +00:00
|
|
|
private ImBoolean showImGuiDemo = new ImBoolean(false);
|
|
|
|
private ImBoolean showMusicPlayer = new ImBoolean(false);
|
|
|
|
private ImBoolean showHebrewWallet = new ImBoolean(false);
|
2022-02-05 13:43:14 +00:00
|
|
|
private ImBoolean showSystemBasePart = new ImBoolean(false);
|
|
|
|
private ImBoolean showSystemGlyphPart = new ImBoolean(false);
|
2022-01-28 13:04:24 +00:00
|
|
|
private ImBoolean showBasicConsole = new ImBoolean(false);
|
2022-01-28 11:00:59 +00:00
|
|
|
|
2022-02-06 23:09:29 +00:00
|
|
|
public GDXAppMain(List<String> args, int viewWidth, int viewHeight, NativeFileChooser fileChooser) {
|
2022-01-28 11:00:59 +00:00
|
|
|
this.args = args;
|
2022-01-31 22:05:27 +00:00
|
|
|
this.viewWidth = viewWidth;
|
|
|
|
this.viewHeight = viewHeight;
|
2022-01-28 11:00:59 +00:00
|
|
|
this.fileChooser = fileChooser;
|
|
|
|
}
|
|
|
|
|
2022-02-04 22:17:52 +00:00
|
|
|
private void lazyInit() {
|
|
|
|
if (lazyIntCnt > 0) {
|
|
|
|
lazyIntCnt--;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
ImGuiSetup.init();
|
|
|
|
|
2022-02-05 16:00:19 +00:00
|
|
|
try {
|
|
|
|
if (args.contains("warpcore-load")) {
|
|
|
|
System.out.println("warpcore-load: requested");
|
2022-02-05 16:23:12 +00:00
|
|
|
WaterBucket bucket = TOSWarpCoreDriver.newInstance().createReader().readFile("./warpcore.xml");
|
2022-02-05 16:00:19 +00:00
|
|
|
TOSWarpCore.INSTANCE.BãßArmWarpCore(bucket);
|
|
|
|
}
|
|
|
|
if (args.contains("warpcore-save")) {
|
|
|
|
System.out.println("warpcore-save: requested");
|
|
|
|
WaterBucket bucket = TOSWarpCore.INSTANCE.BãßCurrentWarpCore();
|
2022-02-05 16:23:12 +00:00
|
|
|
TOSWarpCoreDriver.newInstance().createWriter().writeFile(bucket, "./warpcore.xml");
|
2022-02-05 16:00:19 +00:00
|
|
|
}
|
|
|
|
} catch (Exception e) {
|
|
|
|
throw new RuntimeException(e);
|
2022-02-04 22:17:52 +00:00
|
|
|
}
|
|
|
|
if (!args.contains("warpcore-nolock")) {
|
|
|
|
TOSWarpCore.INSTANCE.BãßLockWarpCipher();
|
2022-02-05 16:00:19 +00:00
|
|
|
} else {
|
|
|
|
System.out.println("warpcore-nolock: requested");
|
2022-02-04 22:17:52 +00:00
|
|
|
}
|
|
|
|
|
2022-02-06 16:19:05 +00:00
|
|
|
// ref to init, remove later...
|
|
|
|
BaseGlyphSet.values()[0].BãßAuthorCopyright();
|
|
|
|
Base2Terminator.INSTANCE.BãßAuthorCopyright();
|
|
|
|
|
2022-02-04 22:17:52 +00:00
|
|
|
if (args.contains("full-screen")) {
|
2022-02-05 16:00:19 +00:00
|
|
|
System.out.println("full-screen: requested");
|
2022-02-04 22:17:52 +00:00
|
|
|
Gdx.graphics.setFullscreenMode(Gdx.graphics.getDisplayMode());
|
|
|
|
}
|
2022-02-05 16:00:19 +00:00
|
|
|
if (args.contains("intro-skip")) {
|
|
|
|
System.out.println("intro-skip: requested");
|
2022-02-04 22:17:52 +00:00
|
|
|
selectScreen(ScreenDefault.class);
|
|
|
|
music.play(MusicSongType.BACKGROUND);
|
|
|
|
} else {
|
|
|
|
selectScreen(ScreenIntro.class);
|
|
|
|
}
|
2022-02-05 16:00:19 +00:00
|
|
|
|
2022-02-04 22:17:52 +00:00
|
|
|
}
|
|
|
|
|
2022-01-28 11:00:59 +00:00
|
|
|
public void create() {
|
|
|
|
batch = new SpriteBatch();
|
|
|
|
font = new BitmapFont();
|
|
|
|
camera = new OrthographicCamera();
|
|
|
|
|
|
|
|
camera.setToOrtho(false, viewWidth, viewHeight);
|
|
|
|
camera.update();
|
|
|
|
batch.setProjectionMatrix(camera.combined);
|
|
|
|
|
2022-02-05 16:00:19 +00:00
|
|
|
boolean musicStop = args.contains("music-stop");
|
|
|
|
if (musicStop) {
|
|
|
|
System.out.println("music-stop: requested");
|
|
|
|
}
|
2022-01-28 11:00:59 +00:00
|
|
|
music = new MusicManager();
|
2022-02-05 16:00:19 +00:00
|
|
|
music.init(musicStop);
|
2022-01-28 11:00:59 +00:00
|
|
|
|
2022-02-04 22:17:52 +00:00
|
|
|
screens = new HashMap<>();
|
2022-01-28 13:04:24 +00:00
|
|
|
widgets = new HashMap<>();
|
2022-02-04 22:17:52 +00:00
|
|
|
|
2022-01-28 13:04:24 +00:00
|
|
|
putWidget(new MusicPlayerRenderer(this));
|
|
|
|
putWidget(new HebrewWalletRenderer(this));
|
2022-02-05 13:43:14 +00:00
|
|
|
putWidget(new SystemBasePartRenderer(this));
|
|
|
|
putWidget(new SystemBaseGlyphRenderer(this));
|
2022-01-28 13:04:24 +00:00
|
|
|
putWidget(new BasicConsoleRenderer(this));
|
2022-01-28 11:00:59 +00:00
|
|
|
|
2022-02-04 22:17:52 +00:00
|
|
|
putScreen(new ScreenLoading(this));
|
2022-01-28 11:00:59 +00:00
|
|
|
putScreen(new ScreenIntro(this));
|
|
|
|
putScreen(new ScreenIntroMission(this));
|
|
|
|
putScreen(new ScreenDefault(this));
|
|
|
|
putScreen(new ScreenCredits(this));
|
|
|
|
putScreen(new ScreenHelp(this));
|
|
|
|
putScreen(new ScreenMatrix4D(this));
|
|
|
|
putScreen(new ScreenUnicode4D(this));
|
|
|
|
|
2022-02-04 22:17:52 +00:00
|
|
|
selectScreen(ScreenLoading.class);
|
2022-01-28 11:00:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void dispose() {
|
|
|
|
ImGuiSetup.dispose();
|
|
|
|
for (Screen screen:screens.values()) {
|
|
|
|
screen.dispose();
|
|
|
|
}
|
|
|
|
music.dispose();
|
|
|
|
batch.dispose();
|
|
|
|
font.dispose();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void putScreen(Screen screen) {
|
|
|
|
screens.put(screen.getClass(), screen);
|
|
|
|
}
|
|
|
|
|
2022-01-28 13:04:24 +00:00
|
|
|
private void putWidget(ImGuiRenderer widget) {
|
|
|
|
widgets.put(widget.getClass(), widget);
|
|
|
|
}
|
|
|
|
|
2022-01-28 11:00:59 +00:00
|
|
|
public void selectScreen(Class<? extends Screen> screenClass) {
|
|
|
|
Screen screen = screens.get(screenClass);
|
|
|
|
if (screen == null) {
|
|
|
|
throw new NullPointerException("Unknow screen: "+screenClass);
|
|
|
|
}
|
|
|
|
setScreen(screen);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void render() {
|
|
|
|
ScreenUtils.clear(0f, 0f, 0f, 1f, true);
|
2022-02-04 22:17:52 +00:00
|
|
|
if (screen instanceof ScreenLoading) {
|
|
|
|
screen.render(Gdx.graphics.getDeltaTime());
|
|
|
|
lazyInit();
|
|
|
|
return;
|
|
|
|
}
|
2022-01-28 11:00:59 +00:00
|
|
|
ImGuiSetup.imGuiImp.newFrame();
|
|
|
|
ImGui.newFrame();
|
|
|
|
if (hasMainMenu()) {
|
|
|
|
renderMenu();
|
|
|
|
}
|
|
|
|
if (showImGuiDemo.get()) {
|
|
|
|
ImGui.showDemoWindow(showImGuiDemo);
|
|
|
|
}
|
|
|
|
if (showMusicPlayer.get()) {
|
2022-01-28 13:04:24 +00:00
|
|
|
widgets.get(MusicPlayerRenderer.class).render(showMusicPlayer);
|
2022-01-28 11:00:59 +00:00
|
|
|
}
|
|
|
|
if (showHebrewWallet.get()) {
|
2022-01-28 13:04:24 +00:00
|
|
|
widgets.get(HebrewWalletRenderer.class).render(showHebrewWallet);
|
|
|
|
}
|
2022-02-05 13:43:14 +00:00
|
|
|
if (showSystemBasePart.get()) {
|
|
|
|
widgets.get(SystemBasePartRenderer.class).render(showSystemBasePart);
|
|
|
|
}
|
|
|
|
if (showSystemGlyphPart.get()) {
|
|
|
|
widgets.get(SystemBaseGlyphRenderer.class).render(showSystemGlyphPart);
|
2022-01-31 00:12:29 +00:00
|
|
|
}
|
2022-01-28 13:04:24 +00:00
|
|
|
if (showBasicConsole.get()) {
|
|
|
|
widgets.get(BasicConsoleRenderer.class).render(showBasicConsole);
|
2022-01-28 11:00:59 +00:00
|
|
|
}
|
|
|
|
if (screen != null) {
|
|
|
|
screen.render(Gdx.graphics.getDeltaTime());
|
|
|
|
}
|
|
|
|
if (Gdx.input.isKeyPressed(Keys.ESCAPE)) {
|
|
|
|
selectScreen(ScreenDefault.class);
|
|
|
|
}
|
|
|
|
ImGui.render();
|
|
|
|
ImGuiSetup.imGuiGlImp.renderDrawData(ImGui.getDrawData());
|
|
|
|
}
|
|
|
|
|
|
|
|
private void renderMenu() {
|
|
|
|
ImGui.beginMainMenuBar();
|
|
|
|
if (ImGui.beginMenu("Demo")) {
|
2022-01-31 22:05:27 +00:00
|
|
|
if (Gdx.graphics.isFullscreen()) {
|
|
|
|
if (ImGui.menuItem("Window Mode")) {
|
|
|
|
Gdx.graphics.setWindowedMode(viewWidth, viewHeight);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (ImGui.menuItem("Full Screen")) {
|
|
|
|
Gdx.graphics.setFullscreenMode(Gdx.graphics.getDisplayMode());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ImGui.separator();
|
2022-01-28 11:00:59 +00:00
|
|
|
if (ImGui.menuItem("Matrix4D")) {
|
|
|
|
selectScreen(ScreenMatrix4D.class);
|
|
|
|
}
|
|
|
|
if (ImGui.menuItem("Unicode4D")) {
|
|
|
|
selectScreen(ScreenUnicode4D.class);
|
|
|
|
}
|
|
|
|
ImGui.separator();
|
2022-01-28 13:04:24 +00:00
|
|
|
if (ImGui.menuItem("Exit")) {
|
|
|
|
dispose();
|
|
|
|
System.exit(0);
|
|
|
|
}
|
|
|
|
ImGui.endMenu();
|
|
|
|
}
|
|
|
|
if (ImGui.beginMenu("Widgets")) {
|
|
|
|
if (ImGui.menuItem("ImGui Demo")) {
|
2022-01-28 11:00:59 +00:00
|
|
|
showImGuiDemo.set(true);
|
|
|
|
}
|
|
|
|
ImGui.separator();
|
2022-01-28 13:04:24 +00:00
|
|
|
if (ImGui.menuItem("Hebrew Wallet")) {
|
|
|
|
showHebrewWallet.set(true);
|
|
|
|
}
|
2022-02-05 13:43:14 +00:00
|
|
|
ImGui.separator();
|
2022-01-31 00:12:29 +00:00
|
|
|
if (ImGui.menuItem("Base Part")) {
|
2022-02-05 13:43:14 +00:00
|
|
|
showSystemBasePart.set(true);
|
|
|
|
}
|
|
|
|
if (ImGui.menuItem("Base Glyph")) {
|
|
|
|
showSystemGlyphPart.set(true);
|
2022-01-31 00:12:29 +00:00
|
|
|
}
|
2022-02-05 13:43:14 +00:00
|
|
|
ImGui.separator();
|
2022-01-28 13:04:24 +00:00
|
|
|
if (ImGui.menuItem("Basic Console")) {
|
|
|
|
showBasicConsole.set(true);
|
2022-01-28 11:00:59 +00:00
|
|
|
}
|
|
|
|
if (ImGui.menuItem("Music Player")) {
|
|
|
|
showMusicPlayer.set(true);
|
|
|
|
}
|
|
|
|
ImGui.endMenu();
|
|
|
|
}
|
|
|
|
if (ImGui.beginMenu("Help")) {
|
|
|
|
if (ImGui.menuItem("Credits")) {
|
|
|
|
selectScreen(ScreenCredits.class);
|
|
|
|
}
|
|
|
|
ImGui.separator();
|
|
|
|
if (ImGui.menuItem("Help")) {
|
|
|
|
selectScreen(ScreenHelp.class);
|
|
|
|
}
|
|
|
|
ImGui.endMenu();
|
|
|
|
}
|
|
|
|
ImGui.endMainMenuBar();
|
|
|
|
}
|
|
|
|
|
|
|
|
private boolean hasMainMenu() {
|
|
|
|
Screen screen = getScreen();
|
|
|
|
if (screen == null) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (ScreenIntro.class.equals(screen.getClass())) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (ScreenIntroMission.class.equals(screen.getClass())) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (ScreenCredits.class.equals(screen.getClass())) {
|
|
|
|
return false;
|
|
|
|
}
|
2022-01-31 22:05:27 +00:00
|
|
|
if (ScreenHelp.class.equals(screen.getClass())) {
|
|
|
|
return false;
|
|
|
|
}
|
2022-01-28 11:00:59 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|