DEADSOFTWARE

Add desktop debug option
authorfredboy <fredboy@protonmail.com>
Sat, 20 Apr 2024 15:37:01 +0000 (22:37 +0700)
committerfredboy <fredboy@protonmail.com>
Sat, 20 Apr 2024 15:37:01 +0000 (22:37 +0700)
core/src/ru/deadsoftware/cavedroid/CaveGame.java
desktop/build.gradle
desktop/src/ru/deadsoftware/cavedroid/desktop/DesktopLauncher.java

index 1c1679145d6a70bf8a73948ace2e76f3f3ba06c0..42533236e2794d906b6392480ecbd593f4dc5c25 100644 (file)
@@ -1,5 +1,6 @@
 package ru.deadsoftware.cavedroid;
 
+import com.badlogic.gdx.Application;
 import com.badlogic.gdx.Game;
 import com.badlogic.gdx.Gdx;
 import ru.deadsoftware.cavedroid.game.GameItems;
@@ -52,6 +53,12 @@ public class CaveGame extends Game {
         mMainConfig.setHeight(height);
         mMainConfig.setShowInfo(mDebug);
         mMainConfig.setAssetsPackPath(mAssetsPackPath);
+
+        if (mDebug) {
+            Gdx.app.setLogLevel(Application.LOG_DEBUG);
+        } else {
+            Gdx.app.setLogLevel(Application.LOG_ERROR);
+        }
     }
 
     public void newGame(int gameMode) {
index 57fae418b7fbd7e2f47c036681b5f841f9991a05..94e48c3ebf7ff14595b2d925a2770d567a44479a 100644 (file)
@@ -13,6 +13,7 @@ task run(dependsOn: classes, type: JavaExec) {
     standardInput = System.in
     workingDir = project.assetsDir
     ignoreExitValue = true as JavaExecSpec
+    args "--debug"
 }
 
 task runTouch(dependsOn: classes, type: JavaExec) {
@@ -21,7 +22,7 @@ task runTouch(dependsOn: classes, type: JavaExec) {
     standardInput = System.in
     workingDir = project.assetsDir
     ignoreExitValue = true as JavaExecSpec
-    args "--touch"
+    args "--touch --debug"
 }
 
 task debug(dependsOn: classes, type: JavaExec) {
index 025beb484ed0e573abf795d267d3705feac6ee7b..fe78235dd8fe5bc0ec937561b82ae1a9b4f6e87e 100644 (file)
@@ -6,35 +6,37 @@ import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration;
 import ru.deadsoftware.cavedroid.CaveGame;
 
 class DesktopLauncher {
-       public static void main (String[] arg) {
-               Lwjgl3ApplicationConfiguration config = new Lwjgl3ApplicationConfiguration();
-               config.setWindowIcon(Files.FileType.Internal, "icons/icon256.png", "icons/icon128.png");
+    public static void main(String[] arg) {
+        Lwjgl3ApplicationConfiguration config = new Lwjgl3ApplicationConfiguration();
+        config.setWindowIcon(Files.FileType.Internal, "icons/icon256.png", "icons/icon128.png");
         config.setTitle("CaveDroid");
-               config.setWindowedMode(960, 540);
-               config.useVsync(true);
+        config.setWindowedMode(960, 540);
+        config.useVsync(true);
 
-               boolean touch = false;
-               String assetsPath = null;
+        boolean touch = false;
+        boolean debug = false;
+        String assetsPath = null;
 
-               for (String anArg : arg) {
+        for (String anArg : arg) {
             if (anArg.equals("--touch")) {
                 touch = true;
             }
 
-                       if (anArg.startsWith("--assets")) {
-                               String[] splitArg = anArg.split("=");
-                               if (splitArg.length >= 2) {
-                                       assetsPath = splitArg[1];
-                               }
-                       }
-               }
-
-        new Lwjgl3Application(
-                               new CaveGame(
-                                               System.getProperty("user.home") + "/.cavedroid",
-                                               touch,
-                                               assetsPath),
-                               config
-               );
-       }
+            if (anArg.equals("--debug")) {
+                debug = true;
+            }
+
+            if (anArg.startsWith("--assets")) {
+                String[] splitArg = anArg.split("=");
+                if (splitArg.length >= 2) {
+                    assetsPath = splitArg[1];
+                }
+            }
+        }
+
+        CaveGame caveGame = new CaveGame(System.getProperty("user.home") + "/.cavedroid", touch, assetsPath);
+        caveGame.setDebug(debug);
+
+        new Lwjgl3Application(caveGame, config);
+    }
 }