From c1fdecd8692e21b59a720eca1a3617cb5eb7c07f Mon Sep 17 00:00:00 2001 From: fredboy Date: Sat, 20 Apr 2024 22:37:01 +0700 Subject: [PATCH] Add desktop debug option --- .../ru/deadsoftware/cavedroid/CaveGame.java | 7 +++ desktop/build.gradle | 3 +- .../cavedroid/desktop/DesktopLauncher.java | 50 ++++++++++--------- 3 files changed, 35 insertions(+), 25 deletions(-) diff --git a/core/src/ru/deadsoftware/cavedroid/CaveGame.java b/core/src/ru/deadsoftware/cavedroid/CaveGame.java index 1c16791..4253323 100644 --- a/core/src/ru/deadsoftware/cavedroid/CaveGame.java +++ b/core/src/ru/deadsoftware/cavedroid/CaveGame.java @@ -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) { diff --git a/desktop/build.gradle b/desktop/build.gradle index 57fae41..94e48c3 100644 --- a/desktop/build.gradle +++ b/desktop/build.gradle @@ -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) { diff --git a/desktop/src/ru/deadsoftware/cavedroid/desktop/DesktopLauncher.java b/desktop/src/ru/deadsoftware/cavedroid/desktop/DesktopLauncher.java index 025beb4..fe78235 100644 --- a/desktop/src/ru/deadsoftware/cavedroid/desktop/DesktopLauncher.java +++ b/desktop/src/ru/deadsoftware/cavedroid/desktop/DesktopLauncher.java @@ -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); + } } -- 2.29.2