diff --git a/android/src/main/java/com/openeggbert/android/AndroidLauncher.java b/android/src/main/java/com/openeggbert/android/AndroidLauncher.java
index f4f3fff..7e3ca74 100644
--- a/android/src/main/java/com/openeggbert/android/AndroidLauncher.java
+++ b/android/src/main/java/com/openeggbert/android/AndroidLauncher.java
@@ -4,9 +4,11 @@ import android.os.Bundle;
import com.badlogic.gdx.backends.android.AndroidApplication;
import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration;
+import com.openeggbert.core.main.OpenEggbertApplication;
import com.openeggbert.core.main.OpenEggbertGame;
import com.pixelgamelibrary.api.Pixel;
import com.pixelgamelibrary.backend.libgdx.PixelBackendLibGDX;
+import com.pixelgamelibrary.backend.libgdx.game.LibGdxGame;
/** Launches the Android application. */
public class AndroidLauncher extends AndroidApplication {
@@ -16,6 +18,6 @@ public class AndroidLauncher extends AndroidApplication {
AndroidApplicationConfiguration configuration = new AndroidApplicationConfiguration();
configuration.useImmersiveMode = true; // Recommended, but not required.
Pixel.initBackend(new PixelBackendLibGDX());
- initialize(new OpenEggbertGame(), configuration);
+ initialize(new LibGdxGame(new OpenEggbertApplication().createGame()), configuration);
}
}
\ No newline at end of file
diff --git a/core/src/main/java/com/openeggbert/core/configuration/ConfigDef.java b/core/src/main/java/com/openeggbert/core/configuration/ConfigDef.java
index 235df64..ae5c338 100644
--- a/core/src/main/java/com/openeggbert/core/configuration/ConfigDef.java
+++ b/core/src/main/java/com/openeggbert/core/configuration/ConfigDef.java
@@ -20,7 +20,6 @@
package com.openeggbert.core.configuration;
import com.openeggbert.core.main.OpenEggbertException;
-import com.openeggbert.core.utils.OpenEggbertUtils;
import com.pixelgamelibrary.api.Pixel;
import java.util.HashMap;
import java.util.Map;
diff --git a/core/src/main/java/com/openeggbert/core/configuration/OpenEggbertDisplayMode.java b/core/src/main/java/com/openeggbert/core/configuration/OpenEggbertDisplayMode.java
index 88107d5..608f191 100644
--- a/core/src/main/java/com/openeggbert/core/configuration/OpenEggbertDisplayMode.java
+++ b/core/src/main/java/com/openeggbert/core/configuration/OpenEggbertDisplayMode.java
@@ -21,6 +21,7 @@ package com.openeggbert.core.configuration;
import com.pixelgamelibrary.api.Pixel;
import com.openeggbert.core.main.OpenEggbertException;
+import com.pixelgamelibrary.api.WindowMode;
/**
*
@@ -63,9 +64,9 @@ public enum OpenEggbertDisplayMode {
}
public static OpenEggbertDisplayMode setDisplayMode(OpenEggbertDisplayMode displayMode) {
- String result = Pixel.graphics().setDisplayMode(displayMode == FULLSCREEN, displayMode == WINDOW);
+ WindowMode result = Pixel.graphics().setDisplayMode(displayMode == FULLSCREEN, displayMode == WINDOW);
- return result == null ? null : OpenEggbertDisplayMode.valueOf(result);
+ return result == null ? null : OpenEggbertDisplayMode.valueOf(result.name());
}
public OpenEggbertDisplayMode flip() {
diff --git a/core/src/main/java/com/openeggbert/core/main/OpenEggbertGame.gwt.xml b/core/src/main/java/com/openeggbert/core/main/OpenEggbertApplication.gwt.xml
similarity index 100%
rename from core/src/main/java/com/openeggbert/core/main/OpenEggbertGame.gwt.xml
rename to core/src/main/java/com/openeggbert/core/main/OpenEggbertApplication.gwt.xml
diff --git a/core/src/main/java/com/openeggbert/core/main/OpenEggbertApplication.java b/core/src/main/java/com/openeggbert/core/main/OpenEggbertApplication.java
new file mode 100644
index 0000000..ef072b7
--- /dev/null
+++ b/core/src/main/java/com/openeggbert/core/main/OpenEggbertApplication.java
@@ -0,0 +1,57 @@
+///////////////////////////////////////////////////////////////////////////////////////////////
+// Open Eggbert: Free recreation of the computer game Speedy Eggbert.
+// Copyright (C) 2024 the original author or authors.
+//
+// This program is free software: you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation, either version 3
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see
+// or write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+///////////////////////////////////////////////////////////////////////////////////////////////
+package com.openeggbert.core.main;
+
+import com.openeggbert.core.gamespace.GameSpace;
+import com.pixelgamelibrary.api.GameI;
+import com.pixelgamelibrary.api.PixelApplication;
+import java.util.Map;
+
+/**
+ * {@link com.badlogic.gdx.ApplicationListener} implementation shared by all
+ * platforms.
+ */
+public class OpenEggbertApplication extends PixelApplication {
+
+ private static final String GAME_SPACE = "gameSpace";
+ private static final String ABSOLUTE_PATH_OF_ROOT_DIRECTORY_IN = "absolutePathOfRootDirectoryIn";
+
+ @Override
+ public GameI createGameViaMap(Map objects) {
+
+ String absolutePathOfRootDirectoryIn = null;
+ GameSpace gameSpace = null;
+ if (objects.containsKey(ABSOLUTE_PATH_OF_ROOT_DIRECTORY_IN)) {
+ absolutePathOfRootDirectoryIn = (String) objects.get(ABSOLUTE_PATH_OF_ROOT_DIRECTORY_IN);
+ }
+ if (objects.containsKey(GAME_SPACE)) {
+ gameSpace = (GameSpace) objects.get(GAME_SPACE);
+ }
+
+ if (absolutePathOfRootDirectoryIn != null) {
+
+ return gameSpace == null ? new OpenEggbertGame(absolutePathOfRootDirectoryIn) : new OpenEggbertGame(gameSpace, absolutePathOfRootDirectoryIn);
+ } else {
+ return new OpenEggbertGame();
+ }
+
+ }
+
+}
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 b4646da..3633fb1 100644
--- a/core/src/main/java/com/openeggbert/core/main/OpenEggbertGame.java
+++ b/core/src/main/java/com/openeggbert/core/main/OpenEggbertGame.java
@@ -1,25 +1,5 @@
-///////////////////////////////////////////////////////////////////////////////////////////////
-// Open Eggbert: Free recreation of the computer game Speedy Eggbert.
-// Copyright (C) 2024 the original author or authors.
-//
-// This program is free software: you can redistribute it and/or
-// modify it under the terms of the GNU General Public License
-// as published by the Free Software Foundation, either version 3
-// of the License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see
-// or write to the Free Software
-// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-///////////////////////////////////////////////////////////////////////////////////////////////
package com.openeggbert.core.main;
-import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Camera;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
@@ -28,14 +8,14 @@ import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.utils.ObjectMap;
import com.badlogic.gdx.utils.viewport.Viewport;
import com.openeggbert.core.configuration.ConfigDef;
+import com.openeggbert.core.configuration.OpenEggbertDisplayMode;
import com.openeggbert.core.gamespace.GameSpace;
import com.openeggbert.core.mod.Mod;
import com.openeggbert.core.mod.ModIdentification;
import com.openeggbert.core.screen.GameSpaceListScreen;
import com.openeggbert.core.screen.InitScreen;
-import com.openeggbert.core.configuration.OpenEggbertDisplayMode;
-import com.pixelgamelibrary.api.Game;
import com.openeggbert.core.utils.OpenEggbertUtils;
+import com.pixelgamelibrary.api.GameAdapter;
import com.pixelgamelibrary.api.Pixel;
import com.pixelgamelibrary.api.storage.FileHandle;
import java.util.ArrayList;
@@ -44,11 +24,11 @@ import java.util.Optional;
import lombok.Data;
/**
- * {@link com.badlogic.gdx.ApplicationListener} implementation shared by all
- * platforms.
+ *
+ * @author robertvokac
*/
@Data
-public class OpenEggbertGame extends Game {
+public class OpenEggbertGame extends GameAdapter {
private Texture image;
private GameSpace gameSpace = null;
@@ -77,6 +57,7 @@ public class OpenEggbertGame extends Game {
public OpenEggbertGame(GameSpace gameSpace, String absolutePathOfRootDirectoryIn) {
this.gameSpace = gameSpace;
this.absolutePathOfRootDirectory = absolutePathOfRootDirectoryIn;
+ Pixel.app().setGame(this);
}
@@ -85,41 +66,40 @@ public class OpenEggbertGame extends Game {
// viewport = new FitViewport(640,480);
// viewport.apply();
//camera = new OrthographicCamera();
-
- //.setToOrtho(false,640,480);
+ //.setToOrtho(false,640,480);
System.out.println("Searching mods");
// for(FileHandle f:Gdx.files.internal(".").list()) {
// System.out.println("assets contains also: " + f.name());
// }
-
com.pixelgamelibrary.api.storage.FileHandle embeddedModsDirectory = Pixel.asset().getAssets().file("/embedded_mods");
System.out.println("embeddedModsDirectory.exists=" + embeddedModsDirectory.exists());
System.out.println("embeddedModsDirectory.list().size()=" + embeddedModsDirectory.list().size());
- embeddedModsDirectory.list().forEach(e->System.out.println(e.path()));
-
- Pixel.asset().getAssets().list().forEach(e->System.out.println(e));
-
-
+ embeddedModsDirectory.list().forEach(e -> System.out.println(e.path()));
+
+ Pixel.asset().getAssets().list().forEach(e -> System.out.println(e));
+
for (FileHandle embeddedModGroup : embeddedModsDirectory.list()) {
- if(embeddedModGroup.name().equals("README.md"))continue;
+ if (embeddedModGroup.name().equals("README.md")) {
+ continue;
+ }
System.out.println("Found group " + embeddedModGroup.name());
for (FileHandle embeddedMod : embeddedModGroup.list()) {
System.out.println("Found mod " + embeddedMod.name());
-
+
FileHandle modXml = null;
- for(FileHandle file: embeddedMod.list()) {
- if(file.name().equals("mod.xml")) {
+ for (FileHandle file : embeddedMod.list()) {
+ if (file.name().equals("mod.xml")) {
modXml = file;
}
}
-
+
if (modXml == null) {
continue;
}
System.out.println("Found mod: " + embeddedMod.name());
-
+
Mod mod = new Mod(modXml.readString());
embeddedMods.add(mod);
System.out.println("embeddedMods.size(): " + embeddedMods.size());
@@ -133,6 +113,7 @@ public class OpenEggbertGame extends Game {
image = new Texture("libgdx.png");
shapeRenderer = new ShapeRenderer();
font = new BitmapFont();
+ System.out.println("Going to set screen");
setScreen(gameSpace == null ? new GameSpaceListScreen(this) : new InitScreen(this));
}
@@ -178,8 +159,9 @@ public class OpenEggbertGame extends Game {
return Optional.empty();
}
}
+
public Mod loadMod(ModIdentification modIdentification) {
- return embeddedMods.stream().filter(m->m.getIdentification().asString().equals(modIdentification.asString())).findFirst().get();
+ return embeddedMods.stream().filter(m -> m.getIdentification().asString().equals(modIdentification.asString())).findFirst().get();
}
}
diff --git a/core/src/main/java/com/openeggbert/core/screen/AbstractGameScreen.java b/core/src/main/java/com/openeggbert/core/screen/AbstractGameScreen.java
index 6873287..569309c 100644
--- a/core/src/main/java/com/openeggbert/core/screen/AbstractGameScreen.java
+++ b/core/src/main/java/com/openeggbert/core/screen/AbstractGameScreen.java
@@ -30,7 +30,7 @@ import com.openeggbert.core.main.OpenEggbertGame;
*
* @author robertvokac
*/
-public class AbstractGameScreen extends AbstractOpenEggbertScreen {
+public class AbstractGameScreen extends OpenEggbertScreen {
public AbstractGameScreen(OpenEggbertGame openEggbertGame) {
super(openEggbertGame);
diff --git a/core/src/main/java/com/openeggbert/core/screen/DemoScreen.java b/core/src/main/java/com/openeggbert/core/screen/DemoScreen.java
index f5db914..8b032e6 100644
--- a/core/src/main/java/com/openeggbert/core/screen/DemoScreen.java
+++ b/core/src/main/java/com/openeggbert/core/screen/DemoScreen.java
@@ -31,7 +31,7 @@ import java.util.Optional;
*
* @author robertvokac
*/
-public class DemoScreen extends AbstractOpenEggbertScreen {
+public class DemoScreen extends OpenEggbertScreen {
public DemoScreen(OpenEggbertGame openEggbertGame) {
super(openEggbertGame);
diff --git a/core/src/main/java/com/openeggbert/core/screen/GameSpaceListScreen.java b/core/src/main/java/com/openeggbert/core/screen/GameSpaceListScreen.java
index ddcfb35..fce0699 100644
--- a/core/src/main/java/com/openeggbert/core/screen/GameSpaceListScreen.java
+++ b/core/src/main/java/com/openeggbert/core/screen/GameSpaceListScreen.java
@@ -29,6 +29,7 @@ import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.utils.ScreenUtils;
import com.openeggbert.core.gamespace.GameSpace;
+import com.openeggbert.core.main.OpenEggbertApplication;
import com.openeggbert.core.main.OpenEggbertGame;
import com.openeggbert.core.mod.Mod;
import com.openeggbert.core.mod.ModType;
@@ -44,7 +45,7 @@ import lombok.ToString;
*
* @author robertvokac
*/
-public class GameSpaceListScreen extends AbstractOpenEggbertScreen {
+public class GameSpaceListScreen extends OpenEggbertScreen {
private int pageNumber = 1;
private final int pageSize = 5;
@@ -85,6 +86,10 @@ public class GameSpaceListScreen extends AbstractOpenEggbertScreen {
@Override
public void show() {
+ System.out.println("Calling : GameSpaceListScreen : show");
+ try{
+throw new RuntimeException();
+ } catch (Exception e) {e.printStackTrace();}
Gdx.input.setInputProcessor(new InputAdapter() {
public boolean touchUp(int screenX, int screenY, int pointer, int button) {
@@ -184,6 +189,7 @@ public class GameSpaceListScreen extends AbstractOpenEggbertScreen {
@Override
public void renderOpenEggbertScreen(float delta) {
+ System.out.println("Calling : GameSpaceListScreen : renderOpenEggbertScreen");
//Gdx.app.log(getClass().getName(), game.getStorage().debug());
timeSeconds += Gdx.graphics.getRawDeltaTime();
diff --git a/core/src/main/java/com/openeggbert/core/screen/InitScreen.java b/core/src/main/java/com/openeggbert/core/screen/InitScreen.java
index 41ecbe5..e9524dd 100644
--- a/core/src/main/java/com/openeggbert/core/screen/InitScreen.java
+++ b/core/src/main/java/com/openeggbert/core/screen/InitScreen.java
@@ -34,7 +34,7 @@ import java.util.Optional;
*
* @author robertvokac
*/
-public class InitScreen extends AbstractOpenEggbertScreen {
+public class InitScreen extends OpenEggbertScreen {
private float timeSeconds = 0f;
diff --git a/core/src/main/java/com/openeggbert/core/screen/AbstractOpenEggbertScreen.java b/core/src/main/java/com/openeggbert/core/screen/OpenEggbertScreen.java
similarity index 96%
rename from core/src/main/java/com/openeggbert/core/screen/AbstractOpenEggbertScreen.java
rename to core/src/main/java/com/openeggbert/core/screen/OpenEggbertScreen.java
index c5c4eaf..bfebf69 100644
--- a/core/src/main/java/com/openeggbert/core/screen/AbstractOpenEggbertScreen.java
+++ b/core/src/main/java/com/openeggbert/core/screen/OpenEggbertScreen.java
@@ -25,10 +25,10 @@ import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
-import com.pixelgamelibrary.api.Screen;
import com.openeggbert.core.gamespace.GameFileType;
import com.openeggbert.core.main.OpenEggbertGame;
import com.openeggbert.core.utils.OpenEggbertUtils;
+import com.pixelgamelibrary.api.ScreenAdapter;
import java.util.List;
import java.util.Optional;
@@ -36,12 +36,12 @@ import java.util.Optional;
*
* @author robertvokac
*/
-public abstract class AbstractOpenEggbertScreen extends Screen {
+public abstract class OpenEggbertScreen extends ScreenAdapter {
protected OpenEggbertGame game;
protected SpriteBatch batch;
- public AbstractOpenEggbertScreen(OpenEggbertGame openEggbertGame) {
+ public OpenEggbertScreen(OpenEggbertGame openEggbertGame) {
this.game = openEggbertGame;
this.batch = openEggbertGame.getBatch();
loadBackgroundTextureIfNeeded();
diff --git a/core/src/main/java/com/openeggbert/core/screen/TestScreen.java b/core/src/main/java/com/openeggbert/core/screen/TestScreen.java
index 63a2e6d..e1305fc 100644
--- a/core/src/main/java/com/openeggbert/core/screen/TestScreen.java
+++ b/core/src/main/java/com/openeggbert/core/screen/TestScreen.java
@@ -32,7 +32,7 @@ import java.util.function.Function;
*
* @author robertvokac
*/
-public class TestScreen extends AbstractOpenEggbertScreen {
+public class TestScreen extends OpenEggbertScreen {
public TestScreen(OpenEggbertGame openEggbertGame) {
super(openEggbertGame);
diff --git a/html/src/main/java/com/openeggbert/GdxDefinition.gwt.xml b/html/src/main/java/com/openeggbert/GdxDefinition.gwt.xml
index 5e0f193..17d0924 100644
--- a/html/src/main/java/com/openeggbert/GdxDefinition.gwt.xml
+++ b/html/src/main/java/com/openeggbert/GdxDefinition.gwt.xml
@@ -22,7 +22,7 @@
-
+
diff --git a/html/src/main/java/com/openeggbert/gwt/GwtLauncher.java b/html/src/main/java/com/openeggbert/gwt/GwtLauncher.java
index 2e23422..05d71ae 100644
--- a/html/src/main/java/com/openeggbert/gwt/GwtLauncher.java
+++ b/html/src/main/java/com/openeggbert/gwt/GwtLauncher.java
@@ -6,8 +6,10 @@ import com.badlogic.gdx.backends.gwt.GwtApplicationConfiguration;
import com.openeggbert.core.configuration.ScreenResolution;
import com.openeggbert.core.main.OpenEggbertGame;
import com.badlogic.gdx.ai.GdxLogger;
+import com.openeggbert.core.main.OpenEggbertApplication;
import com.pixelgamelibrary.api.Pixel;
import com.pixelgamelibrary.backend.libgdx.PixelBackendLibGDX;
+import com.pixelgamelibrary.backend.libgdx.game.LibGdxGame;
/** Launches the GWT application. */
public class GwtLauncher extends GwtApplication {
@@ -26,6 +28,6 @@ public class GwtLauncher extends GwtApplication {
@Override
public ApplicationListener createApplicationListener () {
- return new OpenEggbertGame();
+ return new LibGdxGame(new OpenEggbertApplication().createGame());
}
}
diff --git a/lwjgl3/src/main/java/com/openeggbert/lwjgl3/Lwjgl3Launcher.java b/lwjgl3/src/main/java/com/openeggbert/lwjgl3/Lwjgl3Launcher.java
index 62675e7..a7f4304 100644
--- a/lwjgl3/src/main/java/com/openeggbert/lwjgl3/Lwjgl3Launcher.java
+++ b/lwjgl3/src/main/java/com/openeggbert/lwjgl3/Lwjgl3Launcher.java
@@ -23,11 +23,13 @@ package com.openeggbert.lwjgl3;
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application;
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration;
import com.openeggbert.core.configuration.ScreenResolution;
-import com.openeggbert.core.main.OpenEggbertGame;
+import com.openeggbert.core.main.OpenEggbertApplication;
import com.openeggbert.core.gamespace.GameSpace;
import com.pixelgamelibrary.api.Pixel;
import com.pixelgamelibrary.backend.libgdx.PixelBackendLibGDX;
import java.util.Optional;
+import com.pixelgamelibrary.api.GameI;
+import com.pixelgamelibrary.backend.libgdx.game.LibGdxGame;
/** Launches the desktop (LWJGL3) application. */
public class Lwjgl3Launcher {
@@ -40,8 +42,17 @@ public class Lwjgl3Launcher {
private static Lwjgl3Application createApplication() {
Optional gameSpace = DesktopUtils.tryToLoadGameSpace();
String currentDirectory = DesktopUtils.getPathOfDirectoryWhereJarIsRunning();
- final OpenEggbertGame openEggbertGame = gameSpace.isPresent() ? new OpenEggbertGame(gameSpace.get(), currentDirectory) : new OpenEggbertGame(currentDirectory);
- return new Lwjgl3Application(openEggbertGame, getDefaultConfiguration());
+ OpenEggbertApplication openEggbertApplication = new OpenEggbertApplication();
+
+ GameI game;
+ if (gameSpace.isPresent()) {
+ game = openEggbertApplication.createGame("gameSpace", gameSpace.get(), "currentDirectory", currentDirectory);
+ } else {
+ game = openEggbertApplication.createGame("currentDirectory", currentDirectory);
+ }
+
+ LibGdxGame libGdxGame = new LibGdxGame(game);
+ return new Lwjgl3Application(libGdxGame, getDefaultConfiguration());
}
private static Lwjgl3ApplicationConfiguration getDefaultConfiguration() {