|
@@ -6,8 +6,12 @@ import com.badlogic.gdx.graphics.g3d.ModelInstance;
|
|
|
import imgui.ImGui;
|
|
|
import imgui.extension.imguizmo.ImGuizmo;
|
|
|
import imgui.flag.ImGuiWindowFlags;
|
|
|
+import imgui.type.ImInt;
|
|
|
import imgui.type.ImString;
|
|
|
import xyz.tbvns.Editor.ModelsManager;
|
|
|
+import xyz.tbvns.LevelInfo;
|
|
|
+import xyz.tbvns.Main;
|
|
|
+import xyz.tbvns.Models.GDInstance;
|
|
|
import xyz.tbvns.Models.GDModel;
|
|
|
import xyz.tbvns.ui.Element;
|
|
|
|
|
@@ -15,31 +19,64 @@ import java.util.HashMap;
|
|
|
import java.util.Random;
|
|
|
|
|
|
public class Timeline implements Element {
|
|
|
- private HashMap<ModelInstance, String> name = new HashMap<>();
|
|
|
- private HashMap<ModelInstance, String> id = new HashMap<>();
|
|
|
|
|
|
@Override
|
|
|
public void render() {
|
|
|
ImGui.begin("TimeMenu", ImGuiWindowFlags.NoDecoration | ImGuiWindowFlags.NoMove | ImGuiWindowFlags.NoBringToFrontOnFocus);
|
|
|
+ float[] pos = new float[]{Main.getCamera().position.x / (LevelInfo.getLevel().getMaxPos() / 30) * 100};
|
|
|
+ ImGui.pushItemWidth(ImGui.getWindowWidth() - 16);
|
|
|
+ ImGui.sliderFloat("##Slider%", pos, 0, 100);
|
|
|
+ Main.getCamera().position.set((pos[0] / 100) * (LevelInfo.getLevel().getMaxPos() / 30), Main.getCamera().position.y, Main.getCamera().position.z);
|
|
|
ImGui.setWindowSize(Gdx.graphics.getWidth(), 201);
|
|
|
ImGui.setWindowPos(0, Gdx.graphics.getHeight() - 201);
|
|
|
- //TODO: replace every model with an object that contains the following information:
|
|
|
- // - start and en frame
|
|
|
- // - FPS for animation
|
|
|
- // - keyframes for positions and scale
|
|
|
- // - name
|
|
|
- // - id (unique)
|
|
|
- // - more thing if I have an idea later
|
|
|
+
|
|
|
+ ImGui.pushItemWidth(200);
|
|
|
+ ImGui.labelText("##", "Name:");
|
|
|
+ ImGui.sameLine();
|
|
|
+ ImGui.pushItemWidth(100);
|
|
|
+ ImGui.labelText("##", "FPS:");
|
|
|
+ ImGui.sameLine();
|
|
|
+ ImGui.pushItemWidth(100);
|
|
|
+ ImGui.labelText("##", "Frame skip:");
|
|
|
+ ImGui.sameLine();
|
|
|
+ ImGui.pushItemWidth(100);
|
|
|
+ ImGui.labelText("##", "Start frame:");
|
|
|
+
|
|
|
for (ModelInstance model : ModelsManager.getLoadedModels()) {
|
|
|
- ImString string;
|
|
|
- if (name.containsKey(model)) {
|
|
|
- string = new ImString(name.get(model));
|
|
|
- } else {
|
|
|
- string = new ImString(((GDModel) model.userData).getName() + "-" + new Random().nextInt(1000, 9999));
|
|
|
- id.put(model, "##" + new Random().nextInt(1000, 9999999));
|
|
|
+ GDInstance instance = ((GDInstance) model.userData);
|
|
|
+ ImString name = new ImString(instance.getName());
|
|
|
+ ImGui.pushItemWidth(200);
|
|
|
+ ImGui.inputText("##name" + instance.getId(), name);
|
|
|
+ instance.setName(name.get());
|
|
|
+
|
|
|
+ ImGui.sameLine();
|
|
|
+ ImInt fps = new ImInt(instance.getFps());
|
|
|
+ ImGui.pushItemWidth(100);
|
|
|
+ ImGui.inputInt("##fps" + instance.getId(), fps);
|
|
|
+ instance.setFps(fps.get());
|
|
|
+
|
|
|
+ if (instance.isAnimation()) {
|
|
|
+ ImGui.sameLine();
|
|
|
+ ImInt skipFrame = new ImInt(instance.getFrameSkip());
|
|
|
+ ImGui.pushItemWidth(100);
|
|
|
+ ImGui.inputInt("##frameSkip" + instance.getId(), skipFrame);
|
|
|
+ instance.setFrameSkip(skipFrame.get());
|
|
|
+
|
|
|
+ ImGui.sameLine();
|
|
|
+ ImInt startFrame = new ImInt(instance.getStart());
|
|
|
+ ImGui.pushItemWidth(100);
|
|
|
+ ImGui.inputInt("##startFrame" + instance.getId(), startFrame);
|
|
|
+ instance.setStart(startFrame.get());
|
|
|
+
|
|
|
+ ImGui.sameLine();
|
|
|
+ if (ImGui.checkbox("Expand", instance.isExpanded())) {
|
|
|
+ instance.setExpanded(!instance.isExpanded());
|
|
|
+ }
|
|
|
}
|
|
|
- ImGui.inputText(id.get(model), string);
|
|
|
- name.put(model, new String(string.getData()));
|
|
|
+ }
|
|
|
+
|
|
|
+ if (ModelsManager.getLoadedModels().size() == 0) {
|
|
|
+ ImGui.text("No models loaded.\nTry adding some.");
|
|
|
}
|
|
|
|
|
|
ImGui.end();
|