From 081873a202e51e3a90e95a4da1a499e8c15ae77e Mon Sep 17 00:00:00 2001 From: Robert Vokac Date: Fri, 16 Aug 2024 16:03:08 +0200 Subject: [PATCH] Refactoring III --- .../com/openeggbert/core/main/OpenEggbertGame.java | 10 +++++----- .../java/com/openeggbert/core/screens/TestScreen.java | 6 +++--- .../java/com/openeggbert/lwjgl3/Lwjgl3Launcher.java | 5 ++--- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/core/src/main/java/com/openeggbert/core/main/OpenEggbertGame.java b/core/src/main/java/com/openeggbert/core/main/OpenEggbertGame.java index 5ca7d63..73262b0 100644 --- a/core/src/main/java/com/openeggbert/core/main/OpenEggbertGame.java +++ b/core/src/main/java/com/openeggbert/core/main/OpenEggbertGame.java @@ -55,7 +55,7 @@ public class OpenEggbertGame extends Game { private Texture image; private GameSpace gameSpace = null; - private String currentDirectory; + private String absolutePathOfRootDirectory; private SpriteBatch batch; private ShapeRenderer shapeRenderer; @@ -75,13 +75,13 @@ public class OpenEggbertGame extends Game { this(null, null); } - public OpenEggbertGame(String currentDirectory) { - this(null, currentDirectory); + public OpenEggbertGame(String absolutePathOfRootDirectoryIn) { + this(null, absolutePathOfRootDirectoryIn); } - public OpenEggbertGame(GameSpace gameSpace, String currentDirectory) { + public OpenEggbertGame(GameSpace gameSpace, String absolutePathOfRootDirectoryIn) { this.gameSpace = gameSpace; - this.currentDirectory = currentDirectory; + this.absolutePathOfRootDirectory = absolutePathOfRootDirectoryIn; } diff --git a/core/src/main/java/com/openeggbert/core/screens/TestScreen.java b/core/src/main/java/com/openeggbert/core/screens/TestScreen.java index 07a2c2f..b161ce9 100644 --- a/core/src/main/java/com/openeggbert/core/screens/TestScreen.java +++ b/core/src/main/java/com/openeggbert/core/screens/TestScreen.java @@ -55,7 +55,7 @@ public class TestScreen extends AbstractOpenEggbertScreen { public void renderOpenEggbertScreen(float delta) { ScreenUtils.clear(0.15f, 0.15f, 0.2f, 1f); game.getBatch().begin(); - Function removeCurrentDir = i -> i == null ? null : i.replace(game.getCurrentDirectory() + "/", ""); + Function removeCurrentDir = i -> i == null ? null : i.replace(game.getAbsolutePathOfRootDirectory()+ "/", ""); if (Gdx.app.getType() == Application.ApplicationType.Desktop && game.getGameSpace() != null) { BitmapFont font; font = new BitmapFont(); @@ -75,10 +75,10 @@ public class TestScreen extends AbstractOpenEggbertScreen { font.draw(game.getBatch(), "getSoundDirectory=" + removeCurrentDir.apply(game.getGameSpace().getSoundDirectory()), 40, x); } - if (game.getCurrentDirectory() != null) { + if (game.getAbsolutePathOfRootDirectory()!= null) { BitmapFont font; font = new BitmapFont(); - font.draw(game.getBatch(), game.getCurrentDirectory(), 40, 340); + font.draw(game.getBatch(), game.getAbsolutePathOfRootDirectory(), 40, 340); } batch.draw(game.getImage(), 40, 400); game.getBatch().end(); diff --git a/lwjgl3/src/main/java/com/openeggbert/lwjgl3/Lwjgl3Launcher.java b/lwjgl3/src/main/java/com/openeggbert/lwjgl3/Lwjgl3Launcher.java index cb5e2dd..ee72172 100644 --- a/lwjgl3/src/main/java/com/openeggbert/lwjgl3/Lwjgl3Launcher.java +++ b/lwjgl3/src/main/java/com/openeggbert/lwjgl3/Lwjgl3Launcher.java @@ -22,6 +22,7 @@ package com.openeggbert.lwjgl3; import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application; import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration; +import com.openeggbert.core.compatibility.ScreenResolution; import com.openeggbert.core.main.OpenEggbertGame; import com.openeggbert.core.entity.common.GameSpace; import java.util.Optional; @@ -34,8 +35,6 @@ public class Lwjgl3Launcher { } private static Lwjgl3Application createApplication() { - //System.getProperties().put("GAME_SPACE_DIRECTORY", "/rv/data/desktop/code/code.nanoboot.org/nanoboot/open-eggbert/assets/open-eggbert-legacy-assets/speedy_blupi_I"); - Optional gameSpace = DesktopUtils.tryToLoadGameSpace(); String currentDirectory = DesktopUtils.getPathOfDirectoryWhereJarIsRunning(); final OpenEggbertGame openEggbertGame = gameSpace.isPresent() ? new OpenEggbertGame(gameSpace.get(), currentDirectory) : new OpenEggbertGame(currentDirectory); @@ -51,7 +50,7 @@ public class Lwjgl3Launcher { //// If you remove the above line and set Vsync to false, you can get unlimited FPS, which can be //// useful for testing performance, but can also be very stressful to some hardware. //// You may also need to configure GPU drivers to fully disable Vsync; this can cause screen tearing. - configuration.setWindowedMode(640, 480); + configuration.setWindowedMode(ScreenResolution.VGA.getWidth(), ScreenResolution.VGA.getHeight()); configuration.setWindowIcon("libgdx128.png", "libgdx64.png", "libgdx32.png", "libgdx16.png"); return configuration; }