Demo UI fixes and launch options
This commit is contained in:
parent
37175e0fee
commit
45879c1992
|
@ -18,6 +18,7 @@ import imgui.type.ImBoolean;
|
|||
import love.distributedrebirth.demo4d.matrix4d.ScreenMatrix4D;
|
||||
import love.distributedrebirth.demo4d.music.MusicManager;
|
||||
import love.distributedrebirth.demo4d.music.MusicPlayerRenderer;
|
||||
import love.distributedrebirth.demo4d.music.MusicSongType;
|
||||
import love.distributedrebirth.demo4d.screen.BasePartRenderer;
|
||||
import love.distributedrebirth.demo4d.screen.BasicConsoleRenderer;
|
||||
import love.distributedrebirth.demo4d.screen.HebrewWalletRenderer;
|
||||
|
@ -40,8 +41,8 @@ public class Demo4DMain extends Game {
|
|||
public SpriteBatch batch;
|
||||
public BitmapFont font;
|
||||
public OrthographicCamera camera;
|
||||
public final int viewWidth = 800;
|
||||
public final int viewHeight = 600;
|
||||
public final int viewWidth;
|
||||
public final int viewHeight;
|
||||
public MusicManager music;
|
||||
|
||||
private Map<Class<? extends Screen>,Screen> screens;
|
||||
|
@ -52,8 +53,10 @@ public class Demo4DMain extends Game {
|
|||
private ImBoolean showBasePart = new ImBoolean(false);
|
||||
private ImBoolean showBasicConsole = new ImBoolean(false);
|
||||
|
||||
public Demo4DMain(List<String> args, NativeFileChooser fileChooser) {
|
||||
public Demo4DMain(List<String> args, int viewWidth, int viewHeight, NativeFileChooser fileChooser) {
|
||||
this.args = args;
|
||||
this.viewWidth = viewWidth;
|
||||
this.viewHeight = viewHeight;
|
||||
this.fileChooser = fileChooser;
|
||||
}
|
||||
|
||||
|
@ -67,7 +70,7 @@ public class Demo4DMain extends Game {
|
|||
batch.setProjectionMatrix(camera.combined);
|
||||
|
||||
music = new MusicManager();
|
||||
music.init();
|
||||
music.init(args.contains("no-music"));
|
||||
|
||||
ImGuiSetup.init();
|
||||
widgets = new HashMap<>();
|
||||
|
@ -85,11 +88,15 @@ public class Demo4DMain extends Game {
|
|||
putScreen(new ScreenMatrix4D(this));
|
||||
putScreen(new ScreenUnicode4D(this));
|
||||
|
||||
if (args.contains("default")) {
|
||||
if (args.contains("no-intro")) {
|
||||
selectScreen(ScreenDefault.class);
|
||||
music.play(MusicSongType.BACKGROUND);
|
||||
} else {
|
||||
selectScreen(ScreenIntro.class);
|
||||
}
|
||||
if (args.contains("full-screen")) {
|
||||
Gdx.graphics.setFullscreenMode(Gdx.graphics.getDisplayMode());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -155,6 +162,16 @@ public class Demo4DMain extends Game {
|
|||
private void renderMenu() {
|
||||
ImGui.beginMainMenuBar();
|
||||
if (ImGui.beginMenu("Demo")) {
|
||||
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();
|
||||
if (ImGui.menuItem("Matrix4D")) {
|
||||
selectScreen(ScreenMatrix4D.class);
|
||||
}
|
||||
|
@ -186,9 +203,6 @@ public class Demo4DMain extends Game {
|
|||
if (ImGui.menuItem("Music Player")) {
|
||||
showMusicPlayer.set(true);
|
||||
}
|
||||
if (ImGui.menuItem("Stop Music")) {
|
||||
music.stop();
|
||||
}
|
||||
ImGui.endMenu();
|
||||
}
|
||||
if (ImGui.beginMenu("Help")) {
|
||||
|
@ -218,6 +232,9 @@ public class Demo4DMain extends Game {
|
|||
if (ScreenCredits.class.equals(screen.getClass())) {
|
||||
return false;
|
||||
}
|
||||
if (ScreenHelp.class.equals(screen.getClass())) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ public class MusicManager {
|
|||
private final List<MusicSong> backgroundSongs;
|
||||
private final NextSongListener nextSongListener;
|
||||
private MusicSong currentSong = null;
|
||||
private boolean noMusic = false;
|
||||
|
||||
public MusicManager() {
|
||||
backgroundSongs = new ArrayList<>();
|
||||
|
@ -34,7 +35,8 @@ public class MusicManager {
|
|||
backgroundSongs.add(new MusicSong(music, file.name()));
|
||||
}
|
||||
|
||||
public void init() {
|
||||
public void init(boolean noMusic) {
|
||||
this.noMusic = noMusic;
|
||||
addBackgroundMusic(Gdx.files.internal("music/sanctumwave-risen.mp3"));
|
||||
addBackgroundMusic(Gdx.files.internal("music/sanctumwave-devine-intellect.mp3"));
|
||||
addBackgroundMusic(Gdx.files.internal("music/theselfhelpgroup-temple-os.mp3"));
|
||||
|
@ -53,12 +55,8 @@ public class MusicManager {
|
|||
return backgroundSongs;
|
||||
}
|
||||
|
||||
public String getCurrentSongName() {
|
||||
if (currentSong != null) {
|
||||
return currentSong.getName();
|
||||
} else {
|
||||
return "None";
|
||||
}
|
||||
public MusicSong getCurrentSong() {
|
||||
return currentSong;
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
|
@ -71,8 +69,10 @@ public class MusicManager {
|
|||
MusicSong nextSong = null;
|
||||
if (MusicSongType.INTRO.equals(type)) {
|
||||
nextSong = introSong;
|
||||
play(nextSong);
|
||||
} else if (MusicSongType.CREDITS.equals(type)) {
|
||||
nextSong = creditsSong;
|
||||
play(nextSong);
|
||||
} else {
|
||||
int currentBackground = backgroundSongs.indexOf(currentSong);
|
||||
if (currentBackground == -1) {
|
||||
|
@ -80,9 +80,11 @@ public class MusicManager {
|
|||
} else {
|
||||
nextSong = currentSong;
|
||||
}
|
||||
}
|
||||
if (!noMusic) {
|
||||
play(nextSong);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void play(MusicSong song) {
|
||||
if (song == null) {
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package love.distributedrebirth.demo4d.music;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.files.FileHandle;
|
||||
|
||||
|
@ -21,8 +23,14 @@ import net.spookygames.gdx.nativefilechooser.NativeFileChooserConfiguration;
|
|||
*/
|
||||
public class MusicPlayerRenderer extends ImGuiRendererMain {
|
||||
|
||||
private final NativeFileChooserConfiguration fileChooserConfig;
|
||||
|
||||
public MusicPlayerRenderer(Demo4DMain main) {
|
||||
super(main);
|
||||
fileChooserConfig = new NativeFileChooserConfiguration();
|
||||
fileChooserConfig.directory = Gdx.files.absolute(System.getProperty("user.home"));
|
||||
fileChooserConfig.mimeFilter = "audio/*";
|
||||
fileChooserConfig.title = "Choose audio file";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -32,11 +40,14 @@ public class MusicPlayerRenderer extends ImGuiRendererMain {
|
|||
ImGui.begin("Music Player", widgetOpen);
|
||||
|
||||
ImGui.text("Current Song:");
|
||||
MusicSong currentSong = main.music.getCurrentSong();
|
||||
if (currentSong != null) {
|
||||
ImGui.sameLine();
|
||||
ImGui.text(main.music.getCurrentSongName());
|
||||
ImGui.text(currentSong.getName());
|
||||
}
|
||||
ImGui.separator();
|
||||
if (ImGui.button("Play")) {
|
||||
main.music.play(MusicSongType.BACKGROUND);
|
||||
main.music.play(currentSong);
|
||||
}
|
||||
ImGui.sameLine();
|
||||
if (ImGui.button("<")) {
|
||||
|
@ -52,26 +63,7 @@ public class MusicPlayerRenderer extends ImGuiRendererMain {
|
|||
}
|
||||
ImGui.sameLine();
|
||||
if (ImGui.button("Add")) {
|
||||
NativeFileChooserConfiguration conf = new NativeFileChooserConfiguration();
|
||||
conf.directory = Gdx.files.absolute(System.getProperty("user.home"));
|
||||
conf.mimeFilter = "audio/*";
|
||||
conf.title = "Choose audio file";
|
||||
main.fileChooser.chooseFile(conf, new NativeFileChooserCallback() {
|
||||
|
||||
@Override
|
||||
public void onFileChosen(FileHandle file) {
|
||||
main.music.addBackgroundMusic(file);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancellation() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Exception exception) {
|
||||
}
|
||||
});
|
||||
|
||||
main.fileChooser.chooseFile(fileChooserConfig, NativeFileChooserCallbackAdapter.onFileChosen(v -> main.music.addBackgroundMusic(v)));
|
||||
}
|
||||
int flags = ImGuiTableFlags.ScrollX | ImGuiTableFlags.RowBg | ImGuiTableFlags.BordersOuter | ImGuiTableFlags.BordersV;
|
||||
ImGui.beginTable("playlist", 3, flags);
|
||||
|
@ -98,4 +90,28 @@ public class MusicPlayerRenderer extends ImGuiRendererMain {
|
|||
|
||||
ImGui.end();
|
||||
}
|
||||
|
||||
static class NativeFileChooserCallbackAdapter implements NativeFileChooserCallback {
|
||||
|
||||
@Override
|
||||
public void onFileChosen(FileHandle file) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancellation() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Exception exception) {
|
||||
}
|
||||
|
||||
static NativeFileChooserCallbackAdapter onFileChosen(Consumer<FileHandle> eater) {
|
||||
return new NativeFileChooserCallbackAdapter() {
|
||||
@Override
|
||||
public void onFileChosen(FileHandle file) {
|
||||
eater.accept(file);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package love.distributedrebirth.demo4d.screen;
|
|||
import com.badlogic.gdx.Screen;
|
||||
|
||||
import love.distributedrebirth.demo4d.Demo4DMain;
|
||||
import love.distributedrebirth.demo4d.music.MusicSongType;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -61,4 +62,14 @@ public class ScreenHelp extends ScrollScreenAdapter {
|
|||
protected Class<? extends Screen> getNextScreen(Demo4DMain main) {
|
||||
return ScreenDefault.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void show () {
|
||||
main.music.play(MusicSongType.INTRO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hide () {
|
||||
main.music.play(MusicSongType.BACKGROUND);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
package love.distributedrebirth.demo4d.desktop;
|
||||
|
||||
/**
|
||||
* Desktop game app base config.
|
||||
*
|
||||
* @author willemtsade ©Δ∞ 仙上主天
|
||||
*/
|
||||
public final class DesktopConfig {
|
||||
|
||||
public static int WINDOW_WIDTH = 1024;
|
||||
public static int WINDOW_HEIGHT = 768;
|
||||
public static String WINDOW_TITLE = "demo⁴ᴰ";
|
||||
public static String[] WINDOW_ICONS = {
|
||||
"icon/window-128.png",
|
||||
"icon/window-32.png",
|
||||
"icon/window-16.png"
|
||||
};
|
||||
|
||||
public static void printBootMessage() {
|
||||
System.out.println("==========================");
|
||||
System.out.println(" @Ω\u4ed9⁴ ˧꜏⋇꜊꜔ ⁴ﷲΩ@ ");
|
||||
System.out.println(" ©Δ∞ 仙上主天 ");
|
||||
System.out.println("בְּרֵאשִׁית :o: יְסוֺד :o: יִשְׂרָאֵל");
|
||||
System.out.println("==========================");
|
||||
System.out.println("Welcome to the matrix;");
|
||||
System.out.println("Starting demo⁴ᴰ now...");
|
||||
}
|
||||
}
|
|
@ -4,6 +4,7 @@ import java.util.Arrays;
|
|||
import java.util.List;
|
||||
|
||||
import com.badlogic.gdx.Files.FileType;
|
||||
import com.badlogic.gdx.Game;
|
||||
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application;
|
||||
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration;
|
||||
|
||||
|
@ -11,37 +12,23 @@ import love.distributedrebirth.demo4d.Demo4DMain;
|
|||
import net.spookygames.gdx.nativefilechooser.desktop.DesktopFileChooser;
|
||||
|
||||
/**
|
||||
* Desktop game app launcher.
|
||||
*
|
||||
* @author willemtsade ©Δ∞ 仙上主天
|
||||
*
|
||||
*/
|
||||
public class DesktopLauncher {
|
||||
|
||||
private static String WINDOW_TITLE = "demo⁴ᴰ";
|
||||
private static String[] WINDOW_ICONS = {
|
||||
"icon/window-128.png",
|
||||
"icon/window-32.png",
|
||||
"icon/window-16.png"
|
||||
};
|
||||
|
||||
public static void main (String[] arg) {
|
||||
printMessage();
|
||||
List<String> args = Arrays.asList(arg);
|
||||
public static void main(String[] arg) {
|
||||
DesktopConfig.printBootMessage();
|
||||
Lwjgl3ApplicationConfiguration config = new Lwjgl3ApplicationConfiguration();
|
||||
config.setMaxNetThreads(Runtime.getRuntime().availableProcessors());
|
||||
config.setTitle(WINDOW_TITLE);
|
||||
config.setWindowedMode(800, 600);
|
||||
config.setWindowIcon(FileType.Internal, WINDOW_ICONS);
|
||||
new Lwjgl3Application(new Demo4DMain(args, new DesktopFileChooser()), config);
|
||||
}
|
||||
|
||||
private static void printMessage() {
|
||||
System.out.println("==========================");
|
||||
System.out.println(" @Ω\u4ed9⁴ ˧꜏⋇꜊꜔ ⁴ﷲΩ@ ");
|
||||
System.out.println(" ©Δ∞ 仙上主天 ");
|
||||
System.out.println("בְּרֵאשִׁית :o: יְסוֺד :o: יִשְׂרָאֵל");
|
||||
System.out.println("==========================");
|
||||
System.out.println("Welcome to the matrix;");
|
||||
System.out.println("Starting demo⁴ᴰ now...");
|
||||
config.setTitle(DesktopConfig.WINDOW_TITLE);
|
||||
config.setWindowIcon(FileType.Internal, DesktopConfig.WINDOW_ICONS);
|
||||
config.setWindowedMode(DesktopConfig.WINDOW_WIDTH, DesktopConfig.WINDOW_HEIGHT);
|
||||
List<String> args = Arrays.asList(arg);
|
||||
DesktopFileChooser aop0 = new DesktopFileChooser();
|
||||
Game app = new Demo4DMain(args, DesktopConfig.WINDOW_WIDTH, DesktopConfig.WINDOW_HEIGHT, aop0);
|
||||
Lwjgl3Application launcher = new Lwjgl3Application(app, config);
|
||||
launcher.exit();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue