Bug 11: Separate Pixel Backend LibGDX into a separate Git repository
This commit is contained in:
parent
447bd5ee3a
commit
a3ab0f0b81
2
.gitignore
vendored
2
.gitignore
vendored
@ -4,8 +4,6 @@ gradle-app.setting
|
||||
/build/
|
||||
/android/build/
|
||||
/core/build/
|
||||
/pixel/build/
|
||||
/pixel-backend-libgdx/build/
|
||||
/lwjgl2/build/
|
||||
/lwjgl3/build/
|
||||
/html/build/
|
||||
|
@ -58,8 +58,7 @@ dependencies {
|
||||
implementation "com.github.MrStahlfelge.gdx-websockets:common:$websocketVersion"
|
||||
implementation project(':core')
|
||||
implementation "com.pixelgamelibrary:pixel:$pixelVersion"
|
||||
implementation project(':pixel-backend-libgdx')
|
||||
//implementation "com.openeggbert.gdx:gdx-storage:0.0.0-SNAPSHOT"
|
||||
implementation "com.pixelgamelibrary:pixel-backend-libgdx:$pixelVersion"
|
||||
|
||||
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-arm64-v8a"
|
||||
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi-v7a"
|
||||
|
@ -5,8 +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.backend.libgdx.PixelLibGDXBackend;
|
||||
import com.pixelgamelibrary.api.Pixel;
|
||||
import com.pixelgamelibrary.backend.libgdx.PixelBackendLibGDX;
|
||||
|
||||
/** Launches the Android application. */
|
||||
public class AndroidLauncher extends AndroidApplication {
|
||||
@ -15,7 +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());
|
||||
Pixel.initBackend(new PixelBackendLibGDX());
|
||||
initialize(new OpenEggbertGame(), configuration);
|
||||
}
|
||||
}
|
@ -61,9 +61,7 @@ configure(subprojects - project(':android')) {
|
||||
subprojects {
|
||||
version = '0.0.0-SNAPSHOT'
|
||||
ext.appName = 'open-eggbert'
|
||||
if (project.name == 'pixel-backend-libgdx') {
|
||||
ext.appName = 'pixel-backend-libgdx'
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven { url 'https://s01.oss.sonatype.org' }
|
||||
|
@ -19,7 +19,7 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.openeggbert.core.configuration;
|
||||
|
||||
import com.pixelgamelibrary.Pixel;
|
||||
import com.pixelgamelibrary.api.Pixel;
|
||||
import com.openeggbert.core.main.OpenEggbertException;
|
||||
|
||||
/**
|
||||
|
@ -36,11 +36,11 @@ 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.pixelgamelibrary.storage.Storage;
|
||||
import com.pixelgamelibrary.api.storage.Storage;
|
||||
import com.openeggbert.core.configuration.OpenEggbertDisplayMode;
|
||||
import com.pixelgamelibrary.Game;
|
||||
import com.pixelgamelibrary.api.Game;
|
||||
import com.openeggbert.core.utils.OpenEggbertUtils;
|
||||
import com.pixelgamelibrary.Pixel;
|
||||
import com.pixelgamelibrary.api.Pixel;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
@ -19,8 +19,8 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.openeggbert.core.mod;
|
||||
|
||||
import com.pixelgamelibrary.api.XmlElement;
|
||||
import com.pixelgamelibrary.Pixel;
|
||||
import com.pixelgamelibrary.api.interfaces.XmlElement;
|
||||
import com.pixelgamelibrary.api.Pixel;
|
||||
import com.openeggbert.core.release.Release;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -19,7 +19,7 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.openeggbert.core.mod;
|
||||
|
||||
import com.pixelgamelibrary.api.XmlElement;
|
||||
import com.pixelgamelibrary.api.interfaces.XmlElement;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.openeggbert.core.mod;
|
||||
|
||||
import com.pixelgamelibrary.api.XmlElement;
|
||||
import com.pixelgamelibrary.api.interfaces.XmlElement;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -25,7 +25,7 @@ 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.Screen;
|
||||
import com.pixelgamelibrary.api.Screen;
|
||||
import com.openeggbert.core.gamespace.GameFileType;
|
||||
import com.openeggbert.core.main.OpenEggbertGame;
|
||||
import com.openeggbert.core.utils.OpenEggbertUtils;
|
||||
|
@ -21,8 +21,8 @@ package com.openeggbert.core.utils;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.files.FileHandle;
|
||||
import com.pixelgamelibrary.Pixel;
|
||||
import com.pixelgamelibrary.Platform;
|
||||
import com.pixelgamelibrary.api.Pixel;
|
||||
import com.pixelgamelibrary.api.Platform;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -50,7 +50,8 @@ dependencies {
|
||||
|
||||
implementation project(':core')
|
||||
implementation "com.pixelgamelibrary:pixel:$pixelVersion:sources"
|
||||
implementation project(':pixel-backend-libgdx')
|
||||
api "com.pixelgamelibrary:pixel-backend-libgdx:$pixelVersion"
|
||||
implementation "com.pixelgamelibrary:pixel-backend-libgdx:$pixelVersion:sources"
|
||||
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,7 +150,6 @@ task dist(dependsOn: [clean, compileGwt]) {
|
||||
task addSource {
|
||||
doLast {
|
||||
sourceSets.main.compileClasspath += files(project(':core').sourceSets.main.allJava.srcDirs)
|
||||
sourceSets.main.compileClasspath += files(project(':pixel-backend-libgdx').sourceSets.main.allJava.srcDirs)
|
||||
sourceSets.main.compileClasspath += files("../core/build/generated/sources/annotationProcessor/java/main")
|
||||
|
||||
}
|
||||
|
@ -23,8 +23,8 @@
|
||||
<inherits name="com.github.czyzby.websocket.GdxWebSocketGwt" />
|
||||
<inherits name="com.github.czyzby.websocket.GdxWebSocketSerialization" />
|
||||
<inherits name="com.openeggbert.core.main.OpenEggbertGame" />
|
||||
<inherits name="com.pixelgamelibrary" />
|
||||
<inherits name="com.pixelgamelibrary.backend.libgdx.PixelLibGDXBackend" />
|
||||
<inherits name="com.pixelgamelibrary.pixelapi" />
|
||||
<inherits name="com.pixelgamelibrary.backend.pixelbackendlibgdx" />
|
||||
<inherits name="formic" />
|
||||
<inherits name="guacamole_gdx_gwt" />
|
||||
<inherits name="libgdx-utils" />
|
||||
|
@ -6,8 +6,8 @@ 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.pixelgamelibrary.Pixel;
|
||||
import com.pixelgamelibrary.backend.libgdx.PixelLibGDXBackend;
|
||||
import com.pixelgamelibrary.api.Pixel;
|
||||
import com.pixelgamelibrary.backend.libgdx.PixelBackendLibGDX;
|
||||
|
||||
/** Launches the GWT application. */
|
||||
public class GwtLauncher extends GwtApplication {
|
||||
@ -20,7 +20,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());
|
||||
Pixel.initBackend(new PixelBackendLibGDX());
|
||||
return new GwtApplicationConfiguration(ScreenResolution.VGA.getWidth(), ScreenResolution.VGA.getHeight());
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ dependencies {
|
||||
|
||||
implementation project(':core')
|
||||
implementation "com.pixelgamelibrary:pixel:$pixelVersion"
|
||||
implementation project(':pixel-backend-libgdx')
|
||||
implementation "com.pixelgamelibrary:pixel-backend-libgdx:$pixelVersion"
|
||||
}
|
||||
|
||||
def jarName = "${appName}-${version}.jar"
|
||||
|
@ -25,14 +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.backend.libgdx.PixelLibGDXBackend;
|
||||
import com.pixelgamelibrary.api.Pixel;
|
||||
import com.pixelgamelibrary.backend.libgdx.PixelBackendLibGDX;
|
||||
import java.util.Optional;
|
||||
|
||||
/** Launches the desktop (LWJGL3) application. */
|
||||
public class Lwjgl3Launcher {
|
||||
public static void main(String[] args) {
|
||||
Pixel.initBackend(new PixelLibGDXBackend());
|
||||
Pixel.initBackend(new PixelBackendLibGDX());
|
||||
if (StartupHelper.startNewJvmIfRequired()) return; // This handles macOS support and helps on Windows.
|
||||
createApplication();
|
||||
}
|
||||
|
@ -19,7 +19,7 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.openeggbert.lwjgl3.debugging;
|
||||
|
||||
import com.pixelgamelibrary.storage.command.CommandLineScanner;
|
||||
import com.pixelgamelibrary.api.storage.command.CommandLineScanner;
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
|
@ -19,9 +19,9 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.openeggbert.lwjgl3.debugging;
|
||||
|
||||
import com.pixelgamelibrary.storage.command.StorageCommandLine;
|
||||
import com.pixelgamelibrary.storage.command.StorageCommandLineScanner;
|
||||
import com.pixelgamelibrary.storage.map.MemoryStorage;
|
||||
import com.pixelgamelibrary.api.storage.command.StorageCommandLine;
|
||||
import com.pixelgamelibrary.api.storage.command.StorageCommandLineScanner;
|
||||
import com.pixelgamelibrary.api.storage.map.MemoryStorage;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -1,32 +0,0 @@
|
||||
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
|
||||
//eclipse.project.name = appName + '-core'
|
||||
eclipse.project.name = 'pixel-backend-libgdx'
|
||||
|
||||
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 "com.pixelgamelibrary:pixel:$pixelVersion"
|
||||
}
|
||||
|
||||
test {
|
||||
useJUnitPlatform {
|
||||
}
|
||||
}
|
@ -1,82 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Pixel: Game library.
|
||||
// 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
|
||||
// <https://www.gnu.org/licenses/> or write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.pixelgamelibrary.backend.libgdx;
|
||||
|
||||
import com.badlogic.gdx.Application;
|
||||
import static com.badlogic.gdx.Application.ApplicationType.Android;
|
||||
import static com.badlogic.gdx.Application.ApplicationType.Desktop;
|
||||
import static com.badlogic.gdx.Application.ApplicationType.WebGL;
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.pixelgamelibrary.PixelException;
|
||||
import com.pixelgamelibrary.Platform;
|
||||
import com.pixelgamelibrary.api.AppI;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author robertvokac
|
||||
*/
|
||||
public class AppLibGDXImpl implements AppI {
|
||||
|
||||
|
||||
@Override
|
||||
public void exit() {
|
||||
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
|
||||
}
|
||||
|
||||
@Override
|
||||
public Platform getPlatform() {
|
||||
Application.ApplicationType applicationType = Gdx.app.getType();
|
||||
switch (applicationType) {
|
||||
case Desktop:
|
||||
return Platform.DESKTOP;
|
||||
case Android:
|
||||
return Platform.ANDROID;
|
||||
case WebGL:
|
||||
return Platform.WEB;
|
||||
default:
|
||||
throw new PixelException("Unsupported platform: " + applicationType);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void log(String msg) {
|
||||
Application app = Gdx.app;
|
||||
if (app != null) {
|
||||
Gdx.app.log(getClass().getName(), msg);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(String msg) {
|
||||
|
||||
Application app = Gdx.app;
|
||||
if (app != null) {
|
||||
Gdx.app.error(getClass().getName(), msg);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(String msg) {
|
||||
Application app = Gdx.app;
|
||||
if (app != null) {
|
||||
Gdx.app.debug(getClass().getName(), msg);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Pixel: Game library.
|
||||
// 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
|
||||
// <https://www.gnu.org/licenses/> or write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.pixelgamelibrary.backend.libgdx;
|
||||
|
||||
import com.pixelgamelibrary.api.AssetI;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author robertvokac
|
||||
*/
|
||||
public class AssetLibGDXImpl implements AssetI {
|
||||
|
||||
|
||||
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Pixel: Game library.
|
||||
// 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
|
||||
// <https://www.gnu.org/licenses/> or write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.pixelgamelibrary.backend.libgdx;
|
||||
|
||||
import com.pixelgamelibrary.api.AudioI;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author robertvokac
|
||||
*/
|
||||
public class AudioLibGDXImpl implements AudioI {
|
||||
|
||||
|
||||
|
||||
}
|
@ -1,62 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Pixel: Game library.
|
||||
// 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
|
||||
// <https://www.gnu.org/licenses/> or write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.pixelgamelibrary.backend.libgdx;
|
||||
|
||||
import com.badlogic.gdx.utils.XmlReader;
|
||||
import com.pixelgamelibrary.api.XmlElement;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author robertvokac
|
||||
*/
|
||||
public class ElementLibGDXImpl implements XmlElement {
|
||||
|
||||
private final XmlReader.Element element;
|
||||
|
||||
public ElementLibGDXImpl(com.badlogic.gdx.utils.XmlReader.Element element) {
|
||||
this.element = element;
|
||||
}
|
||||
|
||||
@Override
|
||||
public XmlElement getChildByName(String name) {
|
||||
XmlReader.Element child = element.getChildByName(name);
|
||||
return child == null ? null : new ElementLibGDXImpl(child);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String get(String elementName) {
|
||||
return element.get(elementName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getChildCount() {
|
||||
return element.getChildCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public XmlElement getChild(int i) {
|
||||
XmlReader.Element child = element.getChild(i);
|
||||
return child == null ? null : new ElementLibGDXImpl(child); }
|
||||
|
||||
@Override
|
||||
public String getText() {
|
||||
return element.getText();
|
||||
}
|
||||
}
|
@ -1,97 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Pixel: Game library.
|
||||
// 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
|
||||
// <https://www.gnu.org/licenses/> or write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.pixelgamelibrary.backend.libgdx;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.Graphics;
|
||||
import com.pixelgamelibrary.WindowMode;
|
||||
import com.pixelgamelibrary.PixelException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import com.pixelgamelibrary.api.GraphicsI;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author robertvokac
|
||||
*/
|
||||
public class GraphicsLibGDXImpl implements GraphicsI {
|
||||
|
||||
|
||||
@Override
|
||||
public String setDisplayMode(boolean fullscreen, boolean window) {
|
||||
|
||||
if (fullscreen) {
|
||||
Graphics.Monitor currentMonitor = Gdx.graphics.getMonitor();
|
||||
Graphics.DisplayMode displayModeFromLibGdx = Gdx.graphics.getDisplayMode(currentMonitor);
|
||||
if (originalDisplayMode == null) {
|
||||
originalDisplayMode = displayModeFromLibGdx;
|
||||
}
|
||||
|
||||
Graphics.DisplayMode foundVgaDisplayMode = null;
|
||||
////
|
||||
// System.out.println("started loading all display modes");
|
||||
List<Graphics.DisplayMode> vgaDisplayModes = Arrays
|
||||
.asList(Gdx.graphics.getDisplayModes(currentMonitor))
|
||||
.stream()
|
||||
.filter(d -> d.width == 640 && d.height == 480)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
//fixme
|
||||
// foundVgaDisplayMode = vgaDisplayModes.stream()
|
||||
// .sorted((a, b) -> Integer.valueOf(a.refreshRate).compareTo(b.refreshRate)).findFirst().get();
|
||||
// System.out.println("ended loading all display modes");
|
||||
// System.out.println(foundVgaDisplayMode.refreshRate);
|
||||
// System.out.println(foundVgaDisplayMode.width);
|
||||
// System.out.println(foundVgaDisplayMode.height);
|
||||
////
|
||||
if (!Gdx.graphics.setFullscreenMode(foundVgaDisplayMode == null ? displayModeFromLibGdx : foundVgaDisplayMode)) {
|
||||
Gdx.app.error("InitScreen", "Switching to fullscreen mode failed.");
|
||||
return null;
|
||||
}
|
||||
return WindowMode.FULLSCREEN;
|
||||
|
||||
}
|
||||
if (window) {
|
||||
setToOriginalDisplayMode();
|
||||
Gdx.graphics.setWindowedMode(640, 480);
|
||||
return WindowMode.WINDOW;
|
||||
}
|
||||
throw new PixelException("Unsupported DisplayMode: fullscreen=" + fullscreen + " window=" + window);
|
||||
|
||||
}
|
||||
@Override
|
||||
public boolean setToOriginalDisplayMode() {
|
||||
if (originalDisplayMode == null) {
|
||||
//nothing to do
|
||||
return true;
|
||||
}
|
||||
if (!Gdx.graphics.setFullscreenMode(originalDisplayMode)) {
|
||||
Gdx.app.error("DefinitiveFrameworkLibGdxImpl", "Switching to original display mode failed.");
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private Graphics.DisplayMode originalDisplayMode = null;
|
||||
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Pixel: Game library.
|
||||
// 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
|
||||
// <https://www.gnu.org/licenses/> or write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.pixelgamelibrary.backend.libgdx;
|
||||
|
||||
import com.pixelgamelibrary.api.InputI;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author robertvokac
|
||||
*/
|
||||
public class InputLibGDXImpl implements InputI {
|
||||
|
||||
|
||||
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Pixel: Game library.
|
||||
// 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
|
||||
// <https://www.gnu.org/licenses/> or write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.pixelgamelibrary.backend.libgdx;
|
||||
|
||||
import com.pixelgamelibrary.api.NetI;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author robertvokac
|
||||
*/
|
||||
public class NetLibGDXImpl implements NetI {
|
||||
|
||||
|
||||
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
<?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>
|
@ -1,121 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Pixel: Game library.
|
||||
// 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
|
||||
// <https://www.gnu.org/licenses/> or write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.pixelgamelibrary.backend.libgdx;
|
||||
|
||||
import com.badlogic.gdx.Application;
|
||||
import static com.badlogic.gdx.Application.ApplicationType.Desktop;
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.pixelgamelibrary.PixelException;
|
||||
import com.pixelgamelibrary.Platform;
|
||||
import com.pixelgamelibrary.api.AppI;
|
||||
import com.pixelgamelibrary.api.AssetI;
|
||||
import com.pixelgamelibrary.api.AudioI;
|
||||
import com.pixelgamelibrary.api.GraphicsI;
|
||||
import com.pixelgamelibrary.api.InputI;
|
||||
import com.pixelgamelibrary.api.UtilsI;
|
||||
import com.pixelgamelibrary.api.StorageI;
|
||||
import com.pixelgamelibrary.api.NetI;
|
||||
import com.pixelgamelibrary.api.PixelBackend;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author robertvokac
|
||||
*/
|
||||
public class PixelLibGDXBackend implements PixelBackend {
|
||||
|
||||
private AppI pixelAppLibGdxImpl = null;
|
||||
private GraphicsI pixelGraphicsLibGdxImpl = null;
|
||||
private AudioI pixelAudioLibGdxImpl = null;
|
||||
private InputI pixelInputLibGdxImpl = null;
|
||||
private NetI pixelNetLibGdxImpl = null;
|
||||
private AssetI pixelAssetLibGdxImpl = null;
|
||||
private StorageI pixelStorageLibGdxImpl = null;
|
||||
private UtilsI pixelUtilsLibGdxImpl = null;
|
||||
|
||||
|
||||
@Override
|
||||
public GraphicsI graphics() {
|
||||
if (pixelGraphicsLibGdxImpl == null) {
|
||||
pixelGraphicsLibGdxImpl = new GraphicsLibGDXImpl();
|
||||
}
|
||||
return pixelGraphicsLibGdxImpl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AudioI audio() {
|
||||
|
||||
if (pixelAudioLibGdxImpl == null) {
|
||||
pixelAudioLibGdxImpl = new AudioLibGDXImpl();
|
||||
}
|
||||
return pixelAudioLibGdxImpl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputI input() {
|
||||
|
||||
if (pixelInputLibGdxImpl == null) {
|
||||
pixelInputLibGdxImpl = new InputLibGDXImpl();
|
||||
}
|
||||
return pixelInputLibGdxImpl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NetI net() {
|
||||
|
||||
if (pixelNetLibGdxImpl == null) {
|
||||
pixelNetLibGdxImpl = new NetLibGDXImpl();
|
||||
}
|
||||
return pixelNetLibGdxImpl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AssetI asset() {
|
||||
|
||||
if (pixelAssetLibGdxImpl == null) {
|
||||
pixelAssetLibGdxImpl = new AssetLibGDXImpl();
|
||||
}
|
||||
return pixelAssetLibGdxImpl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StorageI storage() {
|
||||
|
||||
if (pixelStorageLibGdxImpl == null) {
|
||||
pixelStorageLibGdxImpl = new StorageLibGDXImpl();
|
||||
}
|
||||
return pixelStorageLibGdxImpl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UtilsI utils() {
|
||||
|
||||
if (pixelUtilsLibGdxImpl == null) {
|
||||
pixelUtilsLibGdxImpl = new UtilsLibGDXImpl();
|
||||
}
|
||||
return pixelUtilsLibGdxImpl; }
|
||||
|
||||
@Override
|
||||
public AppI app() {
|
||||
if (pixelAppLibGdxImpl == null) {
|
||||
pixelAppLibGdxImpl = new AppLibGDXImpl();
|
||||
}
|
||||
return pixelAppLibGdxImpl; }
|
||||
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Pixel: Game library.
|
||||
// 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
|
||||
// <https://www.gnu.org/licenses/> or write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.pixelgamelibrary.backend.libgdx;
|
||||
|
||||
import com.pixelgamelibrary.api.StorageI;
|
||||
import com.pixelgamelibrary.backend.libgdx.storage.StorageFactory;
|
||||
import com.pixelgamelibrary.storage.Storage;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author robertvokac
|
||||
*/
|
||||
public class StorageLibGDXImpl implements StorageI {
|
||||
|
||||
@Override
|
||||
public Storage getStorage() {
|
||||
return StorageFactory.getStorage();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -1,49 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Pixel: Game library.
|
||||
// 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
|
||||
// <https://www.gnu.org/licenses/> or write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.pixelgamelibrary.backend.libgdx;
|
||||
|
||||
import com.badlogic.gdx.utils.Base64Coder;
|
||||
import com.badlogic.gdx.utils.XmlReader;
|
||||
import com.pixelgamelibrary.api.XmlElement;
|
||||
import com.pixelgamelibrary.api.UtilsI;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author robertvokac
|
||||
*/
|
||||
public class UtilsLibGDXImpl implements UtilsI {
|
||||
|
||||
@Override
|
||||
public XmlElement parseXml(String xmlString) {
|
||||
XmlReader.Element root = new XmlReader().parse(xmlString);
|
||||
return new ElementLibGDXImpl(root);
|
||||
|
||||
}
|
||||
|
||||
public byte[] decodeBase64AsByteArray(String string) {
|
||||
return Base64Coder.decode(string);
|
||||
}
|
||||
|
||||
public String encodeToBase64(byte[] data) {
|
||||
return String.valueOf(Base64Coder.encode(data));
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Pixel: Game library.
|
||||
// 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
|
||||
// <https://www.gnu.org/licenses/> or write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.pixelgamelibrary.backend.libgdx.storage;
|
||||
|
||||
import com.pixelgamelibrary.Platform;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author robertvokac
|
||||
*/
|
||||
public class AndroidStorage extends DesktopAndroidStorage {
|
||||
|
||||
public AndroidStorage() {
|
||||
}
|
||||
|
||||
public Platform getPlatform() {
|
||||
return Platform.ANDROID;
|
||||
}
|
||||
}
|
@ -1,134 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Pixel: Game library.
|
||||
// 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
|
||||
// <https://www.gnu.org/licenses/> or write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.pixelgamelibrary.backend.libgdx.storage;
|
||||
|
||||
import com.pixelgamelibrary.Platform;
|
||||
import com.pixelgamelibrary.storage.Storage;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author robertvokac
|
||||
*/
|
||||
public abstract class DesktopAndroidStorage implements Storage {
|
||||
|
||||
public DesktopAndroidStorage() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Platform getPlatform() {
|
||||
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
|
||||
}
|
||||
|
||||
@Override
|
||||
public String cd(String path) {
|
||||
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
|
||||
}
|
||||
|
||||
@Override
|
||||
public String mkdir(String name) {
|
||||
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
|
||||
}
|
||||
|
||||
@Override
|
||||
public String pwd() {
|
||||
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> ls(String path) {
|
||||
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
|
||||
}
|
||||
|
||||
@Override
|
||||
public int depth(String path) {
|
||||
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
|
||||
}
|
||||
|
||||
@Override
|
||||
public String touch(String name) {
|
||||
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean rm(String name) {
|
||||
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
|
||||
}
|
||||
|
||||
@Override
|
||||
public String cp(String source, String target) {
|
||||
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
|
||||
}
|
||||
|
||||
@Override
|
||||
public String mv(String source, String target) {
|
||||
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
|
||||
}
|
||||
|
||||
@Override
|
||||
public String readtext(String name) {
|
||||
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] readbin(String name) {
|
||||
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
|
||||
}
|
||||
|
||||
@Override
|
||||
public String savetext(String name, String text) {
|
||||
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
|
||||
}
|
||||
|
||||
@Override
|
||||
public String savebin(String name, byte[] data) {
|
||||
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean exists(String name) {
|
||||
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isfile(String name) {
|
||||
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isdir(String name) {
|
||||
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
|
||||
}
|
||||
|
||||
@Override
|
||||
public String debug() {
|
||||
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flush() {
|
||||
//nothing to do
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean rmdir(String dirname) {
|
||||
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
|
||||
}
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Pixel: Game library.
|
||||
// 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
|
||||
// <https://www.gnu.org/licenses/> or write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.pixelgamelibrary.backend.libgdx.storage;
|
||||
|
||||
import com.pixelgamelibrary.Platform;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author robertvokac
|
||||
*/
|
||||
public class DesktopStorage extends DesktopAndroidStorage {
|
||||
|
||||
public DesktopStorage() {
|
||||
}
|
||||
|
||||
public Platform getPlatform() {
|
||||
return Platform.DESKTOP;
|
||||
}
|
||||
}
|
@ -1,100 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Pixel: Game library.
|
||||
// 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
|
||||
// <https://www.gnu.org/licenses/> or write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.pixelgamelibrary.backend.libgdx.storage;
|
||||
|
||||
import com.badlogic.gdx.Preferences;
|
||||
import com.pixelgamelibrary.storage.map.SimpleMap;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author robertvokac
|
||||
*/
|
||||
public class SimpleLocalStorageMap implements SimpleMap {
|
||||
|
||||
private final Preferences preferences;
|
||||
|
||||
public SimpleLocalStorageMap(Preferences preferencesIn) {
|
||||
this.preferences = preferencesIn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putString(String key, String val) {
|
||||
preferences.putString(key, val);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void put(Map<String, String> map) {
|
||||
preferences.put(map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getString(String key) {
|
||||
return preferences.getString(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getString(String key, String defaultValue) {
|
||||
return preferences.getString(key, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getReadOnlyMap() {
|
||||
Map<String, ?> map = preferences.get();
|
||||
Map<String, String> result = new HashMap<>();
|
||||
for (String key : map.keySet()) {
|
||||
Object o = map.get(key);
|
||||
if (o instanceof String) {
|
||||
result.put(key, (String) o);
|
||||
}
|
||||
}
|
||||
return Collections.unmodifiableMap(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(String key) {
|
||||
return preferences.contains(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
preferences.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(String key) {
|
||||
preferences.remove(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flush() {
|
||||
preferences.flush();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> keyList() {
|
||||
return preferences.get().keySet().stream().collect(Collectors.toList());
|
||||
}
|
||||
|
||||
}
|
@ -1,62 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Pixel: Game library.
|
||||
// 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
|
||||
// <https://www.gnu.org/licenses/> or write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.pixelgamelibrary.backend.libgdx.storage;
|
||||
|
||||
import com.pixelgamelibrary.storage.map.MemoryStorage;
|
||||
import com.pixelgamelibrary.Pixel;
|
||||
import com.pixelgamelibrary.Platform;
|
||||
import com.pixelgamelibrary.storage.Storage;
|
||||
import com.pixelgamelibrary.storage.StorageException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author robertvokac
|
||||
*/
|
||||
public class StorageFactory {
|
||||
|
||||
private StorageFactory() {
|
||||
//Not meant to be instantiated.
|
||||
}
|
||||
private static Storage storage = null;
|
||||
|
||||
public static Storage getStorage() {
|
||||
final Platform platform = Pixel.app().getPlatform();
|
||||
if (storage == null) {
|
||||
storage = new MemoryStorage();
|
||||
}
|
||||
if (storage == null) {
|
||||
|
||||
if (platform.isDesktop()) {
|
||||
storage = new DesktopStorage();
|
||||
}
|
||||
if (platform.isAndroid()) {
|
||||
storage = new AndroidStorage();
|
||||
}
|
||||
if (platform.isWeb()) {
|
||||
storage = new WebGLStorage();
|
||||
}
|
||||
}
|
||||
if (storage == null) {
|
||||
throw new StorageException("Platform is not supported: " + platform);
|
||||
}
|
||||
return storage;
|
||||
}
|
||||
|
||||
}
|
@ -1,49 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Pixel: Game library.
|
||||
// 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
|
||||
// <https://www.gnu.org/licenses/> or write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.pixelgamelibrary.backend.libgdx.storage;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.Preferences;
|
||||
import com.pixelgamelibrary.Platform;
|
||||
import com.pixelgamelibrary.storage.map.MapStorage;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author robertvokac
|
||||
*/
|
||||
public class WebGLStorage extends MapStorage {
|
||||
|
||||
public Platform getPlatform() {
|
||||
return Platform.WEB;
|
||||
}
|
||||
|
||||
public WebGLStorage() {
|
||||
this("pixel.libgdx.webGL.Local-Storage");
|
||||
}
|
||||
|
||||
public WebGLStorage(String preferencesName) {
|
||||
this(Gdx.app.getPreferences(preferencesName));
|
||||
}
|
||||
|
||||
public WebGLStorage(Preferences preferences) {
|
||||
super(new SimpleLocalStorageMap(preferences));
|
||||
}
|
||||
|
||||
}
|
@ -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-backend-libgdx'
|
||||
include 'lwjgl3', 'android', 'html', 'core'
|
||||
|
Reference in New Issue
Block a user