Refactoring III

This commit is contained in:
Robert Vokac 2024-08-16 16:03:08 +02:00
parent de52e662a9
commit 081873a202
No known key found for this signature in database
GPG Key ID: C459E1E4B4A986BB
3 changed files with 10 additions and 11 deletions

View File

@ -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;
}

View File

@ -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<String, String> removeCurrentDir = i -> i == null ? null : i.replace(game.getCurrentDirectory() + "/", "");
Function<String, String> 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();

View File

@ -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> 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;
}