瀏覽代碼

Merge remote-tracking branch 'origin/master'

tbvns 5 月之前
父節點
當前提交
f26e30a0e2

+ 16 - 0
PowerGDEditor/src/main/java/xyz/tbvns/GeometryDash/GeometryDashProcess.java

@@ -0,0 +1,16 @@
+package xyz.tbvns.GeometryDash;
+
+import oshi.SystemInfo;
+import oshi.software.os.OSProcess;
+
+public class GeometryDashProcess {
+    public static boolean isRunning() {
+        SystemInfo info = new SystemInfo();
+        for (OSProcess process : info.getOperatingSystem().getProcesses()) {
+            if (process.getName().contains("GeometryDash")) {
+                return true;
+            }
+        }
+        return false;
+    }
+}

+ 2 - 4
PowerGDEditor/src/main/java/xyz/tbvns/GeometryDash/Render.java

@@ -22,7 +22,6 @@ import static xyz.tbvns.GDConstant.*;
 @Slf4j
 public class Render {
     public double currentPercent;
-    public double currentDistance;
     public HashMap<GDInstance, Integer> animationToCurrentframe = new HashMap<>();
 
     public String fullRender(double fps) throws CloneNotSupportedException {
@@ -35,9 +34,8 @@ public class Render {
             double realDistancePerFrame = (speed / fps) * 30;
             double distancePerFramePercent = realDistancePerFrame / LevelInfo.getLevel().getMaxPos() / 30;
             currentPercent += distancePerFramePercent;
-            currentDistance += realDistancePerFrame;
 
-            Vector3f cameraTranslation = new Vector3f((float) (currentPercent * LevelInfo.getLevel().getMaxPos()), 0, 5); //TODO: make that move with the player
+            Vector3f cameraTranslation = new Vector3f((float) -(currentPercent * LevelInfo.getLevel().getMaxPos()), 0, 30); //TODO: make that move with the player
             camera.translation(cameraTranslation); //TODO: make that follow a new camera path editor
             builder.add(1, 1, X_PROPERTY_ID, projectPoint(camera, new Vector4f(cameraTranslation.x, cameraTranslation.y, cameraTranslation.z - 1, 1)).x * 16 * 30, Y_PROPERTY_ID,projectPoint(camera, new Vector4f(cameraTranslation.x, cameraTranslation.y, cameraTranslation.z - 1, 1)).y * 9 * 30);
 
@@ -70,7 +68,7 @@ public class Render {
                             Vector3 translation = instance.getInstance().transform.getTranslation(Vector3.Zero);
                             vector.add(translation.x * 30, translation.y * 30, translation.z * 30, 0);
                             Vector4f projected = projectPoint(camera, vector);
-                            builder.add(1, POINT_OBJECT_ID, X_PROPERTY_ID, projected.x * 30, Y_PROPERTY_ID, projected.y * 30);
+                            builder.add(1, POINT_OBJECT_ID, X_PROPERTY_ID, projected.x, Y_PROPERTY_ID, projected.y);
                         }
                     }
                 }

+ 4 - 3
PowerGDEditor/src/main/java/xyz/tbvns/Main.java

@@ -20,6 +20,7 @@ import org.joml.Vector4d;
 import org.joml.Vector4dc;
 import org.lwjgl.opengl.GL11;
 import xyz.tbvns.Editor.ModelsManager;
+import xyz.tbvns.GeometryDash.GeometryDashProcess;
 import xyz.tbvns.Inputs.Shortcut;
 import xyz.tbvns.Inputs.inputManager;
 import xyz.tbvns.LWJGL3.CustomViewport;
@@ -53,9 +54,9 @@ public class Main extends ApplicationAdapter {
         Ui.initImGui();
         UIManager.loadUi();
         UIManager.getActiveUI().put(LevelSelector.class, true);
-        TexturesManager.idFileMap.size();
+
         batch = new ModelBatch();
-        camera = new PerspectiveCamera(60, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
+        camera = new PerspectiveCamera(80, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
         camera.far = 1000;
         camera.near = 0.01f;
         camera.position.set(10, 2, 30);
@@ -81,7 +82,7 @@ public class Main extends ApplicationAdapter {
 
     @Override
     public void render() {
-        BulletManager.update();
+//        BulletManager.update();
 
         Gdx.gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
         Gdx.gl.glClearColor(0.1f, 0.1f, 0.1f, 1);

+ 9 - 3
PowerGDEditor/src/main/java/xyz/tbvns/ui/MenuBarTabs/SaveMenu.java

@@ -3,11 +3,13 @@ package xyz.tbvns.ui.MenuBarTabs;
 import imgui.ImGui;
 import xyz.tbvns.DataManager;
 import xyz.tbvns.Decoder;
+import xyz.tbvns.GeometryDash.GeometryDashProcess;
 import xyz.tbvns.GeometryDash.Render;
 import xyz.tbvns.LevelInfo;
 import xyz.tbvns.Main;
 import xyz.tbvns.ui.MenuBarTab;
 import xyz.tbvns.ui.UIManager;
+import xyz.tbvns.ui.Windows.GDRunningErrorWindow;
 import xyz.tbvns.ui.Windows.LevelSelector;
 
 public class SaveMenu implements MenuBarTab {
@@ -16,9 +18,13 @@ public class SaveMenu implements MenuBarTab {
         if (ImGui.beginMenu("Files")) {
             if (ImGui.menuItem("Save", "CTRL S")) {
                 try {
-                    LevelInfo.setLevelString(new Render().fullRender(24));
-                    LevelInfo.getLevel().setEncodedLevelString(Decoder.encodeLevel(LevelInfo.getLevelString()));
-                    DataManager.saveLevel(LevelInfo.getLevel());
+                    if (!GeometryDashProcess.isRunning()) {
+                        LevelInfo.setLevelString(new Render().fullRender(24));
+                        LevelInfo.getLevel().setEncodedLevelString(Decoder.encodeLevel(LevelInfo.getLevelString()));
+                        DataManager.saveLevel(LevelInfo.getLevel());
+                    } else {
+                        UIManager.getActiveUI().put(GDRunningErrorWindow.class, true);
+                    }
                 } catch (Exception e) {
                     throw new RuntimeException(e);
                 }

+ 23 - 0
PowerGDEditor/src/main/java/xyz/tbvns/ui/Windows/GDRunningErrorWindow.java

@@ -0,0 +1,23 @@
+package xyz.tbvns.ui.Windows;
+
+import imgui.ImGui;
+import imgui.ImGuiStyle;
+import imgui.flag.ImGuiCol;
+import xyz.tbvns.ui.Element;
+import xyz.tbvns.ui.UIManager;
+
+public class GDRunningErrorWindow implements Element {
+    @Override
+    public void render() {
+        ImGui.pushStyleColor(ImGuiCol.TitleBgActive, 255, 0, 0, 255);
+        ImGui.pushStyleColor(ImGuiCol.TitleBg, 150, 0, 0, 255);
+        ImGui.pushStyleColor(ImGuiCol.TitleBgCollapsed, 100, 50, 50, 255);
+        ImGui.begin("Error:");
+        ImGui.text("GeometryDash is running !\nPlease close GeometryDash before saving.");
+        if (ImGui.button("Close")) {
+            UIManager.getActiveUI().put(GDRunningErrorWindow.class, false);
+        }
+        ImGui.end();
+        ImGui.popStyleColor(3);
+    }
+}