|
@@ -3,18 +3,19 @@ package xyz.tbvns.ui.Elements;
|
|
import com.badlogic.gdx.Gdx;
|
|
import com.badlogic.gdx.Gdx;
|
|
import imgui.ImGui;
|
|
import imgui.ImGui;
|
|
import imgui.flag.ImGuiWindowFlags;
|
|
import imgui.flag.ImGuiWindowFlags;
|
|
|
|
+import org.lwjgl.PointerBuffer;
|
|
import org.lwjgl.util.tinyfd.TinyFileDialogs;
|
|
import org.lwjgl.util.tinyfd.TinyFileDialogs;
|
|
-import tv.wunderbox.nfd.awt.AwtFileDialog;
|
|
|
|
-import tv.wunderbox.nfd.nfd.NfdFileDialog;
|
|
|
|
import xyz.tbvns.Editor.ModelsManager;
|
|
import xyz.tbvns.Editor.ModelsManager;
|
|
import xyz.tbvns.Models.Animation;
|
|
import xyz.tbvns.Models.Animation;
|
|
import xyz.tbvns.Models.GDModel;
|
|
import xyz.tbvns.Models.GDModel;
|
|
import xyz.tbvns.ui.Element;
|
|
import xyz.tbvns.ui.Element;
|
|
import xyz.tbvns.ui.Renderable;
|
|
import xyz.tbvns.ui.Renderable;
|
|
|
|
|
|
|
|
+import javax.swing.filechooser.FileNameExtensionFilter;
|
|
import java.awt.*;
|
|
import java.awt.*;
|
|
import java.io.File;
|
|
import java.io.File;
|
|
import java.nio.ByteBuffer;
|
|
import java.nio.ByteBuffer;
|
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
@@ -25,7 +26,7 @@ public class ModelsList implements Element {
|
|
ImGui.setWindowSize(200, Gdx.graphics.getHeight() - 19 - 200);
|
|
ImGui.setWindowSize(200, Gdx.graphics.getHeight() - 19 - 200);
|
|
ImGui.setWindowPos(0, 19);
|
|
ImGui.setWindowPos(0, 19);
|
|
|
|
|
|
- ImGui.beginTabBar("modelbar");
|
|
|
|
|
|
+ ImGui.beginTabBar("animationBar");
|
|
modelsTab();
|
|
modelsTab();
|
|
ImGui.endTabBar();
|
|
ImGui.endTabBar();
|
|
|
|
|
|
@@ -34,14 +35,14 @@ public class ModelsList implements Element {
|
|
}
|
|
}
|
|
|
|
|
|
public void modelsTab() {
|
|
public void modelsTab() {
|
|
- ImGui.beginTabItem("Models");
|
|
|
|
|
|
+ ImGui.beginTabItem("Assets");
|
|
loadButton();
|
|
loadButton();
|
|
- modelsButtons();
|
|
|
|
|
|
+ animationButtons();
|
|
ImGui.endTabItem();
|
|
ImGui.endTabItem();
|
|
}
|
|
}
|
|
|
|
|
|
public void loadButton() {
|
|
public void loadButton() {
|
|
- if (ImGui.button("Load a model")) {
|
|
|
|
|
|
+ if (ImGui.button("Load an animation")) {
|
|
try {
|
|
try {
|
|
String path = TinyFileDialogs.tinyfd_selectFolderDialog("Select animation folder:", System.getProperty("user.home"));
|
|
String path = TinyFileDialogs.tinyfd_selectFolderDialog("Select animation folder:", System.getProperty("user.home"));
|
|
if (path!=null) {
|
|
if (path!=null) {
|
|
@@ -55,9 +56,29 @@ public class ModelsList implements Element {
|
|
throw new RuntimeException(e);
|
|
throw new RuntimeException(e);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ if (ImGui.button("Load a model")) {
|
|
|
|
+ try {
|
|
|
|
+ FileDialog fd = new FileDialog((Frame) null, "Save File", FileDialog.SAVE);
|
|
|
|
+ fd.setFile("*.obj");
|
|
|
|
+ fd.setFilenameFilter((dir, name) -> {
|
|
|
|
+ if (name.endsWith(".obj")) {
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+ return false;
|
|
|
|
+ });
|
|
|
|
+ fd.setMode(FileDialog.LOAD);
|
|
|
|
+ fd.setVisible(true);
|
|
|
|
+
|
|
|
|
+ if (fd.getFile() != null) {
|
|
|
|
+ ModelsManager.addModel(new File(fd.getDirectory() + "/" + fd.getFile()));
|
|
|
|
+ }
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ throw new RuntimeException(e);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
- public void modelsButtons() {
|
|
|
|
|
|
+ public void animationButtons() {
|
|
List<Renderable> renderables = new ArrayList<>();
|
|
List<Renderable> renderables = new ArrayList<>();
|
|
for (GDModel model : ModelsManager.models) {
|
|
for (GDModel model : ModelsManager.models) {
|
|
renderables.add(model);
|
|
renderables.add(model);
|