Pixel GDX Backend moved to a separate module

This commit is contained in:
Robert Vokac 2024-09-03 20:17:44 +02:00
parent 86037833c8
commit 4d4e0b3c6e
No known key found for this signature in database
GPG Key ID: C459E1E4B4A986BB
32 changed files with 73 additions and 7 deletions

1
.gitignore vendored
View File

@ -5,6 +5,7 @@ gradle-app.setting
/android/build/
/core/build/
/pixel/build/
/pixel-libgdx-backend/build/
/lwjgl2/build/
/lwjgl3/build/
/html/build/

View File

@ -58,6 +58,7 @@ dependencies {
implementation "com.github.MrStahlfelge.gdx-websockets:common:$websocketVersion"
implementation project(':core')
implementation project(':pixel')
implementation project(':pixel-libgdx-backend')
//implementation "com.openeggbert.gdx:gdx-storage:0.0.0-SNAPSHOT"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-arm64-v8a"

View File

@ -5,6 +5,8 @@ import android.os.Bundle;
import com.badlogic.gdx.backends.android.AndroidApplication;
import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration;
import com.openeggbert.core.main.OpenEggbertGame;
import com.pixelgamelibrary.Pixel;
import com.pixelgamelibrary.backends.libgdx.PixelLibGDXBackend;
/** Launches the Android application. */
public class AndroidLauncher extends AndroidApplication {
@ -13,6 +15,7 @@ public class AndroidLauncher extends AndroidApplication {
super.onCreate(savedInstanceState);
AndroidApplicationConfiguration configuration = new AndroidApplicationConfiguration();
configuration.useImmersiveMode = true; // Recommended, but not required.
Pixel.initBackend(new PixelLibGDXBackend());
initialize(new OpenEggbertGame(), configuration);
}
}

View File

@ -61,6 +61,9 @@ subprojects {
if (project.name == 'pixel') {
ext.appName = 'pixel'
}
if (project.name == 'pixel-libgdx-backend') {
ext.appName = 'pixel-libgdx-backend'
}
repositories {
mavenCentral()
maven { url 'https://s01.oss.sonatype.org' }

View File

@ -37,12 +37,10 @@ import com.openeggbert.core.mod.ModIdentification;
import com.openeggbert.core.screen.GameSpaceListScreen;
import com.openeggbert.core.screen.InitScreen;
import com.pixelgamelibrary.storage.Storage;
import com.pixelgamelibrary.backends.libgdx.storage.StorageFactory;
import com.openeggbert.core.configuration.OpenEggbertDisplayMode;
import com.pixelgamelibrary.Game;
import com.openeggbert.core.utils.OpenEggbertUtils;
import com.pixelgamelibrary.Pixel;
import com.pixelgamelibrary.backends.libgdx.PixelLibGDXBackend;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
@ -84,13 +82,12 @@ public class OpenEggbertGame extends Game {
public OpenEggbertGame(GameSpace gameSpace, String absolutePathOfRootDirectoryIn) {
this.gameSpace = gameSpace;
this.absolutePathOfRootDirectory = absolutePathOfRootDirectoryIn;
Pixel.setBackend(new PixelLibGDXBackend());
}
public Storage getStorage() {
if(storage == null) {
this.storage = StorageFactory.getStorage();
this.storage = Pixel.storage().getStorage();
}
return storage;
}

View File

@ -49,6 +49,7 @@ dependencies {
implementation "de.golfgl.gdxcontrollerutils:gdx-controllerutils-mapping:$controllerMappingVersion:sources"
implementation project(':core')
implementation project(':pixel')
implementation project(':pixel-libgdx-backend')
implementation("com.badlogicgames.gdx-controllers:gdx-controllers-gwt:$gdxControllersVersion:sources"){exclude group: "com.badlogicgames.gdx", module: "gdx-backend-gwt"}
implementation("com.badlogicgames.gdx:gdx-box2d-gwt:$gdxVersion:sources") {exclude group: "com.google.gwt", module: "gwt-user"}
implementation("com.github.crykn.guacamole:gdx-gwt:$guacamoleVersion:sources"){exclude group: "com.badlogicgames.gdx", module: "gdx-backend-gwt"}
@ -149,6 +150,7 @@ task addSource {
doLast {
sourceSets.main.compileClasspath += files(project(':core').sourceSets.main.allJava.srcDirs)
sourceSets.main.compileClasspath += files(project(':pixel').sourceSets.main.allJava.srcDirs)
sourceSets.main.compileClasspath += files(project(':pixel-libgdx-backend').sourceSets.main.allJava.srcDirs)
sourceSets.main.compileClasspath += files("../core/build/generated/sources/annotationProcessor/java/main")
}

View File

@ -24,6 +24,7 @@
<inherits name="com.github.czyzby.websocket.GdxWebSocketSerialization" />
<inherits name="com.openeggbert.core.main.OpenEggbertGame" />
<inherits name="com.pixelgamelibrary.Pixel" />
<inherits name="com.pixelgamelibrary.backends.libgdx.PixelLibGDXBackend" />
<!--<inherits name="com.openeggbert.gdx.storage.GdxStorageMainClass" />-->
<inherits name="formic" />
<inherits name="guacamole_gdx_gwt" />

View File

@ -5,6 +5,8 @@ import com.badlogic.gdx.backends.gwt.GwtApplication;
import com.badlogic.gdx.backends.gwt.GwtApplicationConfiguration;
import com.openeggbert.core.configuration.ScreenResolution;
import com.openeggbert.core.main.OpenEggbertGame;
import com.pixelgamelibrary.Pixel;
import com.pixelgamelibrary.backends.libgdx.PixelLibGDXBackend;
/** Launches the GWT application. */
public class GwtLauncher extends GwtApplication {
@ -17,6 +19,7 @@ public class GwtLauncher extends GwtApplication {
//return cfg;
// If you want a fixed size application, comment out the above resizable section,
// and uncomment below:
Pixel.initBackend(new PixelLibGDXBackend());
return new GwtApplicationConfiguration(ScreenResolution.VGA.getWidth(), ScreenResolution.VGA.getHeight());
}

View File

@ -34,6 +34,7 @@ dependencies {
//implementation "com.openeggbert.gdx:gdx-storage:0.0.0-SNAPSHOT"
implementation project(':core')
implementation project(':pixel')
implementation project(':pixel-libgdx-backend')
}
def jarName = "${appName}-${version}.jar"

View File

@ -25,11 +25,14 @@ import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration;
import com.openeggbert.core.configuration.ScreenResolution;
import com.openeggbert.core.main.OpenEggbertGame;
import com.openeggbert.core.gamespace.GameSpace;
import com.pixelgamelibrary.Pixel;
import com.pixelgamelibrary.backends.libgdx.PixelLibGDXBackend;
import java.util.Optional;
/** Launches the desktop (LWJGL3) application. */
public class Lwjgl3Launcher {
public static void main(String[] args) {
Pixel.initBackend(new PixelLibGDXBackend());
if (StartupHelper.startNewJvmIfRequired()) return; // This handles macOS support and helps on Windows.
createApplication();
}

View File

@ -0,0 +1,32 @@
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
//eclipse.project.name = appName + '-core'
eclipse.project.name = 'pixel-libgdx-backend'
sourceSets.test.java.srcDirs = [ "src/test/java/" ]
dependencies {
api "com.badlogicgames.gdx-controllers:gdx-controllers-core:$gdxControllersVersion"
api "com.badlogicgames.gdx:gdx-ai:$aiVersion"
api "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
api "com.badlogicgames.gdx:gdx:$gdxVersion"
api "com.github.MrStahlfelge.gdx-websockets:core:$websocketVersion"
api "com.github.MrStahlfelge.gdx-websockets:serialization:$websocketSerializationVersion"
api "com.github.crykn.guacamole:core:$guacamoleVersion"
api "com.github.crykn.guacamole:gdx:$guacamoleVersion"
api "com.github.tommyettinger:formic:$formicVersion"
api "com.github.tommyettinger:libgdx-utils-box2d:$utilsBox2dVersion"
api "com.github.tommyettinger:libgdx-utils:$utilsVersion"
api "de.golfgl.gdxcontrollerutils:gdx-controllerutils-mapping:$controllerMappingVersion"
api "games.rednblack.miniaudio:miniaudio:$miniaudioVersion"
//api "com.openeggbert.gdx:gdx-storage:0.0.0-SNAPSHOT"
annotationProcessor "org.projectlombok:lombok:$lombokVersion"
compileOnly "org.projectlombok:lombok:$lombokVersion"
testImplementation "org.junit.jupiter:junit-jupiter-api:5.10.3"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.10.3"
implementation project(':pixel')
}
test {
useJUnitPlatform {
}
}

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.11.0//EN" "https://www.gwtproject.org/doctype/2.11.0/gwt-module.dtd">
<module>
<!-- Paths to source are relative to this file and separated by slashes ('/'). -->
<source path="" />
<!-- Reflection includes may be needed for your code or library code. Each value is separated by periods ('.'). -->
<!-- You can include a full package by not including the name of a type at the end. -->
</module>

View File

@ -20,6 +20,8 @@
package com.pixelgamelibrary.backends.libgdx;
import com.pixelgamelibrary.api.StorageI;
import com.pixelgamelibrary.backends.libgdx.storage.StorageFactory;
import com.pixelgamelibrary.storage.Storage;
/**
*
@ -27,6 +29,11 @@ import com.pixelgamelibrary.api.StorageI;
*/
public class StorageLibGDXImpl implements StorageI {
@Override
public Storage getStorage() {
return StorageFactory.getStorage();
}
}

View File

@ -79,7 +79,7 @@ public class Pixel {
}
////
public static void setBackend(PixelBackend pixelBackend) {
public static void initBackend(PixelBackend pixelBackend) {
if (isBackendSet()) {
throw new PixelException("Pixel Backend was already set");
}

View File

@ -19,10 +19,12 @@
///////////////////////////////////////////////////////////////////////////////////////////////
package com.pixelgamelibrary.api;
import com.pixelgamelibrary.storage.Storage;
/**
*
* @author robertvokac
*/
public interface StorageI {
Storage getStorage();
}

View File

@ -1,4 +1,4 @@
// A list of which subprojects to load as part of the same larger project.
// You can remove Strings from the list and reload the Gradle project
// if you want to temporarily disable a subproject.
include 'lwjgl3', 'android', 'html', 'core', 'pixel'
include 'lwjgl3', 'android', 'html', 'core', 'pixel', 'pixel-libgdx-backend'