From 94d8bc131c6b80315e59c80163063560d32c50bb Mon Sep 17 00:00:00 2001 From: Robert Vokac Date: Wed, 11 Sep 2024 21:24:37 +0200 Subject: [PATCH] Bug 13: Separate Pixel Game Library (API) into a separate Git repository --- README.md | 6 + android/build.gradle | 2 +- build.gradle | 9 +- core/build.gradle | 3 +- gradle.properties | 1 + html/build.gradle | 5 +- .../com/openeggbert/GdxDefinition.gwt.xml | 3 +- .../java/com/openeggbert/gwt/GwtLauncher.java | 1 + lwjgl3/build.gradle | 4 +- pixel-backend-libgdx/build.gradle | 2 +- pixel/build.gradle | 31 -- .../main/java/com/pixelgamelibrary/Game.java | 29 -- .../java/com/pixelgamelibrary/Pixel.gwt.xml | 9 - .../main/java/com/pixelgamelibrary/Pixel.java | 99 ----- .../com/pixelgamelibrary/PixelException.java | 33 -- .../java/com/pixelgamelibrary/Platform.java | 32 -- .../java/com/pixelgamelibrary/Screen.java | 28 -- .../java/com/pixelgamelibrary/WindowMode.java | 34 -- .../java/com/pixelgamelibrary/api/AppI.java | 44 --- .../java/com/pixelgamelibrary/api/AssetI.java | 28 -- .../java/com/pixelgamelibrary/api/AudioI.java | 28 -- .../com/pixelgamelibrary/api/GraphicsI.java | 30 -- .../java/com/pixelgamelibrary/api/InputI.java | 28 -- .../java/com/pixelgamelibrary/api/NetI.java | 28 -- .../pixelgamelibrary/api/PixelBackend.java | 41 --- .../com/pixelgamelibrary/api/StorageI.java | 30 -- .../java/com/pixelgamelibrary/api/UtilsI.java | 41 --- .../com/pixelgamelibrary/api/XmlElement.java | 33 -- .../com/pixelgamelibrary/storage/Storage.java | 105 ------ .../storage/StorageException.java | 34 -- .../storage/command/BaseCommand.java | 63 ---- .../storage/command/CommandLineScanner.java | 29 -- .../storage/command/StorageCommand.java | 38 -- .../storage/command/StorageCommandLine.java | 225 ------------ .../command/StorageCommandLineScanner.java | 55 --- .../storage/command/StorageCommandResult.java | 68 ---- .../storage/map/MapFileType.java | 47 --- .../storage/map/MapStorage.java | 344 ------------------ .../storage/map/MapStorageCompression.java | 28 -- .../storage/map/MemoryStorage.java | 39 -- .../storage/map/SimpleJavaMap.java | 93 ----- .../storage/map/SimpleMap.java | 50 --- .../test/java/com/pixelgamelibrary/.gitkeep | 1 - settings.gradle | 2 +- 44 files changed, 24 insertions(+), 1859 deletions(-) delete mode 100644 pixel/build.gradle delete mode 100644 pixel/src/main/java/com/pixelgamelibrary/Game.java delete mode 100644 pixel/src/main/java/com/pixelgamelibrary/Pixel.gwt.xml delete mode 100644 pixel/src/main/java/com/pixelgamelibrary/Pixel.java delete mode 100644 pixel/src/main/java/com/pixelgamelibrary/PixelException.java delete mode 100644 pixel/src/main/java/com/pixelgamelibrary/Platform.java delete mode 100644 pixel/src/main/java/com/pixelgamelibrary/Screen.java delete mode 100644 pixel/src/main/java/com/pixelgamelibrary/WindowMode.java delete mode 100644 pixel/src/main/java/com/pixelgamelibrary/api/AppI.java delete mode 100644 pixel/src/main/java/com/pixelgamelibrary/api/AssetI.java delete mode 100644 pixel/src/main/java/com/pixelgamelibrary/api/AudioI.java delete mode 100644 pixel/src/main/java/com/pixelgamelibrary/api/GraphicsI.java delete mode 100644 pixel/src/main/java/com/pixelgamelibrary/api/InputI.java delete mode 100644 pixel/src/main/java/com/pixelgamelibrary/api/NetI.java delete mode 100644 pixel/src/main/java/com/pixelgamelibrary/api/PixelBackend.java delete mode 100644 pixel/src/main/java/com/pixelgamelibrary/api/StorageI.java delete mode 100644 pixel/src/main/java/com/pixelgamelibrary/api/UtilsI.java delete mode 100644 pixel/src/main/java/com/pixelgamelibrary/api/XmlElement.java delete mode 100644 pixel/src/main/java/com/pixelgamelibrary/storage/Storage.java delete mode 100644 pixel/src/main/java/com/pixelgamelibrary/storage/StorageException.java delete mode 100644 pixel/src/main/java/com/pixelgamelibrary/storage/command/BaseCommand.java delete mode 100644 pixel/src/main/java/com/pixelgamelibrary/storage/command/CommandLineScanner.java delete mode 100644 pixel/src/main/java/com/pixelgamelibrary/storage/command/StorageCommand.java delete mode 100644 pixel/src/main/java/com/pixelgamelibrary/storage/command/StorageCommandLine.java delete mode 100644 pixel/src/main/java/com/pixelgamelibrary/storage/command/StorageCommandLineScanner.java delete mode 100644 pixel/src/main/java/com/pixelgamelibrary/storage/command/StorageCommandResult.java delete mode 100644 pixel/src/main/java/com/pixelgamelibrary/storage/map/MapFileType.java delete mode 100644 pixel/src/main/java/com/pixelgamelibrary/storage/map/MapStorage.java delete mode 100644 pixel/src/main/java/com/pixelgamelibrary/storage/map/MapStorageCompression.java delete mode 100644 pixel/src/main/java/com/pixelgamelibrary/storage/map/MemoryStorage.java delete mode 100644 pixel/src/main/java/com/pixelgamelibrary/storage/map/SimpleJavaMap.java delete mode 100644 pixel/src/main/java/com/pixelgamelibrary/storage/map/SimpleMap.java delete mode 100644 pixel/src/test/java/com/pixelgamelibrary/.gitkeep diff --git a/README.md b/README.md index de5fea1..5b56a81 100644 --- a/README.md +++ b/README.md @@ -44,3 +44,9 @@ Useful Gradle tasks and flags: Note that most tasks that are not specific to a single project can be run with `name:` prefix, where the `name` should be replaced with the ID of a specific project. For example, `core:clean` removes `build` folder only from the `core` project. + +## FAQ + +How to clean Gradle cache + +`./gradlew clean build --refresh-dependencies` diff --git a/android/build.gradle b/android/build.gradle index 8252705..7aeaf73 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -57,7 +57,7 @@ dependencies { implementation "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion" implementation "com.github.MrStahlfelge.gdx-websockets:common:$websocketVersion" implementation project(':core') - implementation project(':pixel') + implementation "com.pixelgamelibrary:pixel:$pixelVersion" implementation project(':pixel-backend-libgdx') //implementation "com.openeggbert.gdx:gdx-storage:0.0.0-SNAPSHOT" diff --git a/build.gradle b/build.gradle index 7437d0f..25a3720 100644 --- a/build.gradle +++ b/build.gradle @@ -2,6 +2,7 @@ buildscript { repositories { mavenCentral() maven { url 'https://s01.oss.sonatype.org' } + maven { url 'https://repo.openeggbert.com' } gradlePluginPortal() mavenLocal() google() @@ -60,9 +61,6 @@ configure(subprojects - project(':android')) { subprojects { version = '0.0.0-SNAPSHOT' ext.appName = 'open-eggbert' - if (project.name == 'pixel') { - ext.appName = 'pixel' - } if (project.name == 'pixel-backend-libgdx') { ext.appName = 'pixel-backend-libgdx' } @@ -74,6 +72,11 @@ subprojects { maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' } maven { url 'https://s01.oss.sonatype.org/content/repositories/snapshots/' } maven { url 'https://jitpack.io' } + + maven { url 'https://repo.openeggbert.com' } + maven { url 'https://repo.openeggbert.com/releases/' } + maven { url 'https://repo.openeggbert.com/snapshots/' } + } } diff --git a/core/build.gradle b/core/build.gradle index 0685568..528f14c 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -22,7 +22,8 @@ dependencies { 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') + api "com.pixelgamelibrary:pixel:$pixelVersion" + } test { diff --git a/gradle.properties b/gradle.properties index b90cd82..8803282 100644 --- a/gradle.properties +++ b/gradle.properties @@ -18,3 +18,4 @@ android.enableR8.fullMode=false gwtFrameworkVersion=2.11.0 gwtPluginVersion=1.1.29 gdxVersion=1.12.1 +pixelVersion=0.0.0-SNAPSHOT diff --git a/html/build.gradle b/html/build.gradle index 64aacb9..bac3220 100644 --- a/html/build.gradle +++ b/html/build.gradle @@ -47,13 +47,13 @@ dependencies { implementation "com.github.tommyettinger:libgdx-utils:$utilsVersion:sources" implementation "com.google.jsinterop:jsinterop-annotations:2.0.2:sources" implementation "de.golfgl.gdxcontrollerutils:gdx-controllerutils-mapping:$controllerMappingVersion:sources" + implementation project(':core') - implementation project(':pixel') + implementation "com.pixelgamelibrary:pixel:$pixelVersion:sources" implementation project(':pixel-backend-libgdx') 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"} - //implementation "com.openeggbert.gdx:gdx-storage:0.0.0-SNAPSHOT" } @@ -149,7 +149,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').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") diff --git a/html/src/main/java/com/openeggbert/GdxDefinition.gwt.xml b/html/src/main/java/com/openeggbert/GdxDefinition.gwt.xml index 41d116e..843af01 100644 --- a/html/src/main/java/com/openeggbert/GdxDefinition.gwt.xml +++ b/html/src/main/java/com/openeggbert/GdxDefinition.gwt.xml @@ -23,9 +23,8 @@ - + - diff --git a/html/src/main/java/com/openeggbert/gwt/GwtLauncher.java b/html/src/main/java/com/openeggbert/gwt/GwtLauncher.java index 69eb6e1..4470c54 100644 --- a/html/src/main/java/com/openeggbert/gwt/GwtLauncher.java +++ b/html/src/main/java/com/openeggbert/gwt/GwtLauncher.java @@ -5,6 +5,7 @@ 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.badlogic.gdx.ai.GdxLogger; import com.pixelgamelibrary.Pixel; import com.pixelgamelibrary.backend.libgdx.PixelLibGDXBackend; diff --git a/lwjgl3/build.gradle b/lwjgl3/build.gradle index 5b55854..4196a41 100644 --- a/lwjgl3/build.gradle +++ b/lwjgl3/build.gradle @@ -31,9 +31,9 @@ dependencies { implementation "com.github.MrStahlfelge.gdx-websockets:common:$websocketVersion" implementation "com.github.crykn.guacamole:gdx-desktop:$guacamoleVersion" implementation "games.rednblack.miniaudio:miniaudio:$miniaudioVersion:natives-desktop" - //implementation "com.openeggbert.gdx:gdx-storage:0.0.0-SNAPSHOT" + implementation project(':core') - implementation project(':pixel') + implementation "com.pixelgamelibrary:pixel:$pixelVersion" implementation project(':pixel-backend-libgdx') } diff --git a/pixel-backend-libgdx/build.gradle b/pixel-backend-libgdx/build.gradle index 8f0026b..034dc70 100644 --- a/pixel-backend-libgdx/build.gradle +++ b/pixel-backend-libgdx/build.gradle @@ -23,7 +23,7 @@ dependencies { 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') + implementation "com.pixelgamelibrary:pixel:$pixelVersion" } test { diff --git a/pixel/build.gradle b/pixel/build.gradle deleted file mode 100644 index 580904b..0000000 --- a/pixel/build.gradle +++ /dev/null @@ -1,31 +0,0 @@ -[compileJava, compileTestJava]*.options*.encoding = 'UTF-8' -//eclipse.project.name = appName + '-core' -eclipse.project.name = 'pixel' - -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" -} - -test { - useJUnitPlatform { - } -} diff --git a/pixel/src/main/java/com/pixelgamelibrary/Game.java b/pixel/src/main/java/com/pixelgamelibrary/Game.java deleted file mode 100644 index 01bac8c..0000000 --- a/pixel/src/main/java/com/pixelgamelibrary/Game.java +++ /dev/null @@ -1,29 +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 -// or write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -/////////////////////////////////////////////////////////////////////////////////////////////// -package com.pixelgamelibrary; - -/** - * - * @author robertvokac - */ -public abstract class Game extends com.badlogic.gdx.Game { - - -} diff --git a/pixel/src/main/java/com/pixelgamelibrary/Pixel.gwt.xml b/pixel/src/main/java/com/pixelgamelibrary/Pixel.gwt.xml deleted file mode 100644 index 8dd5046..0000000 --- a/pixel/src/main/java/com/pixelgamelibrary/Pixel.gwt.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/pixel/src/main/java/com/pixelgamelibrary/Pixel.java b/pixel/src/main/java/com/pixelgamelibrary/Pixel.java deleted file mode 100644 index 89e8c3d..0000000 --- a/pixel/src/main/java/com/pixelgamelibrary/Pixel.java +++ /dev/null @@ -1,99 +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 -// or write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -/////////////////////////////////////////////////////////////////////////////////////////////// -package com.pixelgamelibrary; - -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.NetI; -import com.pixelgamelibrary.api.PixelBackend; -import com.pixelgamelibrary.api.StorageI; -import com.pixelgamelibrary.api.UtilsI; - -/** - * - * @author robertvokac - */ -public class Pixel { - - private static PixelBackend INSTANCE = null; - - private Pixel() { - //Not meant to be instantiated. - } - - private static PixelBackend get() { - return getBackend(); - } - - //// - public static AppI app() { - return get().app(); - } - - public static GraphicsI graphics() { - return get().graphics(); - } - - public static AudioI audio() { - return get().audio(); - } - - public static InputI input() { - return get().input(); - } - - public static NetI net() { - return get().net(); - } - - public static AssetI asset() { - return get().asset(); - } - - public static StorageI storage() { - return get().storage(); - } - - public static UtilsI utils() { - return get().utils(); - } - //// - - public static void initBackend(PixelBackend pixelBackend) { - if (isBackendSet()) { - throw new PixelException("Pixel Backend was already set"); - } - INSTANCE = pixelBackend; - } - - private static PixelBackend getBackend() { - if (!isBackendSet()) { - throw new PixelException("Pixel Backend was not set"); - } - return INSTANCE; - } - - public static boolean isBackendSet() { - return INSTANCE != null; - } -} diff --git a/pixel/src/main/java/com/pixelgamelibrary/PixelException.java b/pixel/src/main/java/com/pixelgamelibrary/PixelException.java deleted file mode 100644 index f3177a4..0000000 --- a/pixel/src/main/java/com/pixelgamelibrary/PixelException.java +++ /dev/null @@ -1,33 +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 -// or write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -/////////////////////////////////////////////////////////////////////////////////////////////// - -package com.pixelgamelibrary; - -/** - * - * @author robertvokac - */ -public class PixelException extends RuntimeException{ - - public PixelException(String string) { - super(string); - } - -} diff --git a/pixel/src/main/java/com/pixelgamelibrary/Platform.java b/pixel/src/main/java/com/pixelgamelibrary/Platform.java deleted file mode 100644 index d6ba1a8..0000000 --- a/pixel/src/main/java/com/pixelgamelibrary/Platform.java +++ /dev/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 -// or write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -/////////////////////////////////////////////////////////////////////////////////////////////// -package com.pixelgamelibrary; - -/** - * - * @author robertvokac - */ -public enum Platform { - DESKTOP, ANDROID, WEB; - public boolean isDesktop() {return this == DESKTOP;} - public boolean isAndroid() {return this == ANDROID;} - public boolean isWeb() {return this == WEB;} - -} diff --git a/pixel/src/main/java/com/pixelgamelibrary/Screen.java b/pixel/src/main/java/com/pixelgamelibrary/Screen.java deleted file mode 100644 index 6d23fcb..0000000 --- a/pixel/src/main/java/com/pixelgamelibrary/Screen.java +++ /dev/null @@ -1,28 +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 -// or write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -/////////////////////////////////////////////////////////////////////////////////////////////// -package com.pixelgamelibrary; - -/** - * - * @author robertvokac - */ -public abstract class Screen extends com.badlogic.gdx.ScreenAdapter { - -} diff --git a/pixel/src/main/java/com/pixelgamelibrary/WindowMode.java b/pixel/src/main/java/com/pixelgamelibrary/WindowMode.java deleted file mode 100644 index f42ff33..0000000 --- a/pixel/src/main/java/com/pixelgamelibrary/WindowMode.java +++ /dev/null @@ -1,34 +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 -// or write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -/////////////////////////////////////////////////////////////////////////////////////////////// -package com.pixelgamelibrary; - -/** - * - * @author robertvokac - */ -public class WindowMode { - - private WindowMode() { - //Not meant to be instantiated. - } - - public static final String WINDOW = "WINDOW"; - public static final String FULLSCREEN = "FULLSCREEN"; -} diff --git a/pixel/src/main/java/com/pixelgamelibrary/api/AppI.java b/pixel/src/main/java/com/pixelgamelibrary/api/AppI.java deleted file mode 100644 index 9e5c2cb..0000000 --- a/pixel/src/main/java/com/pixelgamelibrary/api/AppI.java +++ /dev/null @@ -1,44 +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 -// or write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -/////////////////////////////////////////////////////////////////////////////////////////////// -package com.pixelgamelibrary.api; - -import com.pixelgamelibrary.Platform; - -/** - * - * @author robertvokac - */ -public interface AppI { - Platform getPlatform(); - - default boolean isOneOfPlatforms(Platform ... platforms) { - for(Platform p: platforms) { - if(getPlatform() == p) { - return true; - } - } - return false; - } - void exit(); - void log(String msg); - void error(String msg); - void debug(String msg); - -} diff --git a/pixel/src/main/java/com/pixelgamelibrary/api/AssetI.java b/pixel/src/main/java/com/pixelgamelibrary/api/AssetI.java deleted file mode 100644 index c831dd0..0000000 --- a/pixel/src/main/java/com/pixelgamelibrary/api/AssetI.java +++ /dev/null @@ -1,28 +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 -// or write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -/////////////////////////////////////////////////////////////////////////////////////////////// -package com.pixelgamelibrary.api; - -/** - * - * @author robertvokac - */ -public interface AssetI { - -} diff --git a/pixel/src/main/java/com/pixelgamelibrary/api/AudioI.java b/pixel/src/main/java/com/pixelgamelibrary/api/AudioI.java deleted file mode 100644 index 70ab3f9..0000000 --- a/pixel/src/main/java/com/pixelgamelibrary/api/AudioI.java +++ /dev/null @@ -1,28 +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 -// or write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -/////////////////////////////////////////////////////////////////////////////////////////////// -package com.pixelgamelibrary.api; - -/** - * - * @author robertvokac - */ -public interface AudioI { - -} diff --git a/pixel/src/main/java/com/pixelgamelibrary/api/GraphicsI.java b/pixel/src/main/java/com/pixelgamelibrary/api/GraphicsI.java deleted file mode 100644 index bb3fd12..0000000 --- a/pixel/src/main/java/com/pixelgamelibrary/api/GraphicsI.java +++ /dev/null @@ -1,30 +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 -// or write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -/////////////////////////////////////////////////////////////////////////////////////////////// -package com.pixelgamelibrary.api; - -/** - * - * @author robertvokac - */ -public interface GraphicsI { - boolean setToOriginalDisplayMode(); - String setDisplayMode(boolean fullscreen, boolean window); - -} diff --git a/pixel/src/main/java/com/pixelgamelibrary/api/InputI.java b/pixel/src/main/java/com/pixelgamelibrary/api/InputI.java deleted file mode 100644 index 9ec8893..0000000 --- a/pixel/src/main/java/com/pixelgamelibrary/api/InputI.java +++ /dev/null @@ -1,28 +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 -// or write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -/////////////////////////////////////////////////////////////////////////////////////////////// -package com.pixelgamelibrary.api; - -/** - * - * @author robertvokac - */ -public interface InputI { - -} diff --git a/pixel/src/main/java/com/pixelgamelibrary/api/NetI.java b/pixel/src/main/java/com/pixelgamelibrary/api/NetI.java deleted file mode 100644 index f2debc3..0000000 --- a/pixel/src/main/java/com/pixelgamelibrary/api/NetI.java +++ /dev/null @@ -1,28 +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 -// or write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -/////////////////////////////////////////////////////////////////////////////////////////////// -package com.pixelgamelibrary.api; - -/** - * - * @author robertvokac - */ -public interface NetI { - -} diff --git a/pixel/src/main/java/com/pixelgamelibrary/api/PixelBackend.java b/pixel/src/main/java/com/pixelgamelibrary/api/PixelBackend.java deleted file mode 100644 index abd524a..0000000 --- a/pixel/src/main/java/com/pixelgamelibrary/api/PixelBackend.java +++ /dev/null @@ -1,41 +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 -// or write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -/////////////////////////////////////////////////////////////////////////////////////////////// -package com.pixelgamelibrary.api; - -import com.pixelgamelibrary.Platform; - -/** - * - * @author robertvokac - */ -public interface PixelBackend { - - - - AppI app(); - GraphicsI graphics(); - AudioI audio(); - InputI input(); - NetI net(); - AssetI asset(); - StorageI storage(); - UtilsI utils(); - -} diff --git a/pixel/src/main/java/com/pixelgamelibrary/api/StorageI.java b/pixel/src/main/java/com/pixelgamelibrary/api/StorageI.java deleted file mode 100644 index f8ee616..0000000 --- a/pixel/src/main/java/com/pixelgamelibrary/api/StorageI.java +++ /dev/null @@ -1,30 +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 -// or write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -/////////////////////////////////////////////////////////////////////////////////////////////// -package com.pixelgamelibrary.api; - -import com.pixelgamelibrary.storage.Storage; - -/** - * - * @author robertvokac - */ -public interface StorageI { - Storage getStorage(); -} diff --git a/pixel/src/main/java/com/pixelgamelibrary/api/UtilsI.java b/pixel/src/main/java/com/pixelgamelibrary/api/UtilsI.java deleted file mode 100644 index 6a31226..0000000 --- a/pixel/src/main/java/com/pixelgamelibrary/api/UtilsI.java +++ /dev/null @@ -1,41 +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 -// or write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -/////////////////////////////////////////////////////////////////////////////////////////////// -package com.pixelgamelibrary.api; - -import com.badlogic.gdx.utils.Base64Coder; - -/** - * - * @author robertvokac - */ -public interface UtilsI { - XmlElement parseXml(String xmlString); - default String decodeBase64AsString(String string) { - return new String(decodeBase64AsByteArray(string)); - } - - byte[] decodeBase64AsByteArray(String string); - - default String encodeToBase64(String string) { - return encodeToBase64(string.getBytes()); - } - - String encodeToBase64(byte[] data); -} diff --git a/pixel/src/main/java/com/pixelgamelibrary/api/XmlElement.java b/pixel/src/main/java/com/pixelgamelibrary/api/XmlElement.java deleted file mode 100644 index 30a4760..0000000 --- a/pixel/src/main/java/com/pixelgamelibrary/api/XmlElement.java +++ /dev/null @@ -1,33 +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 -// or write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -/////////////////////////////////////////////////////////////////////////////////////////////// -package com.pixelgamelibrary.api; - -/** - * - * @author robertvokac - */ -public interface XmlElement { - XmlElement getChildByName(String name); - String get(String elementName); - int getChildCount(); - XmlElement getChild(int i); - String getText(); - -} diff --git a/pixel/src/main/java/com/pixelgamelibrary/storage/Storage.java b/pixel/src/main/java/com/pixelgamelibrary/storage/Storage.java deleted file mode 100644 index 836a11d..0000000 --- a/pixel/src/main/java/com/pixelgamelibrary/storage/Storage.java +++ /dev/null @@ -1,105 +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 -// or write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -/////////////////////////////////////////////////////////////////////////////////////////////// -package com.pixelgamelibrary.storage; - -import com.pixelgamelibrary.Platform; -import java.util.List; - -/** - * - * @author robertvokac - */ -public interface Storage { - - Platform getPlatform(); - - public String cd(String path); - - default String cd() { - cd("/"); - mkdir("home"); - cd("home"); - mkdir(uname()); - cd(uname()); - return ""; - } - - public String mkdir(String argument); - default String mkdirmore(String... argument) { -// System.out.println("argumentCount=" + argument.length); -// for(String z: argument){System.out.println(z);} - if(argument.length == 0) { - return "Missing argument"; - } - for(String n:argument) { - String result = mkdir(n); - if(!result.isEmpty()) { - return result; - } - } - return ""; - } - - public String pwd(); - - public List ls(String workingDirectory); - - default List ls() { - return ls(pwd()); - } - - public int depth(String path); - - default int depth() { - return depth(pwd()); - } - - public String touch(String name); - - public boolean rm(String name); - - public boolean rmdir(String dirname); - - public String cp(String source, String target); - - public String mv(String source, String target); - - public String readtext(String name); - - public byte[] readbin(String name); - - public String savetext(String name, String text); - - public String savebin(String name, byte[] data); - - public boolean exists(String name); - - public boolean isfile(String name); - - public boolean isdir(String name); - - public String debug(); - - public void flush(); - - default String uname() {return OPENEGGBERT;} - static final String OPENEGGBERT = "openeggbert"; - -} diff --git a/pixel/src/main/java/com/pixelgamelibrary/storage/StorageException.java b/pixel/src/main/java/com/pixelgamelibrary/storage/StorageException.java deleted file mode 100644 index c24f9d9..0000000 --- a/pixel/src/main/java/com/pixelgamelibrary/storage/StorageException.java +++ /dev/null @@ -1,34 +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 -// or write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -/////////////////////////////////////////////////////////////////////////////////////////////// -package com.pixelgamelibrary.storage; - -import com.pixelgamelibrary.PixelException; - -/** - * - * @author robertvokac - */ -public class StorageException extends PixelException { - - public StorageException(String string) { - super(string); - } - -} diff --git a/pixel/src/main/java/com/pixelgamelibrary/storage/command/BaseCommand.java b/pixel/src/main/java/com/pixelgamelibrary/storage/command/BaseCommand.java deleted file mode 100644 index 97e3197..0000000 --- a/pixel/src/main/java/com/pixelgamelibrary/storage/command/BaseCommand.java +++ /dev/null @@ -1,63 +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 -// or write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -/////////////////////////////////////////////////////////////////////////////////////////////// -package com.pixelgamelibrary.storage.command; - -import java.util.function.Function; - -/** - * - * @author robertvokac - */ -public class BaseCommand implements StorageCommand { - - private StorageCommandLine storageCommandLine = null; - private String name; - private final Function function; - - public BaseCommand( - StorageCommandLine storageCommandLineIn, String nameIn, Function functionIn - ) { - setStorageCommandLine(storageCommandLineIn); - this.name = nameIn; - this.function = functionIn; - - } - - @Override - public final void setStorageCommandLine(StorageCommandLine storageCommandLineIn) { - storageCommandLine = storageCommandLineIn; - } - - @Override - public final StorageCommandLine getStorageCommandLine() { - return storageCommandLine; - } - - @Override - public String getName() { - return name; - } - - @Override - public StorageCommandResult execute(String commandWithArguments) { - return function.apply(commandWithArguments); - } - -} diff --git a/pixel/src/main/java/com/pixelgamelibrary/storage/command/CommandLineScanner.java b/pixel/src/main/java/com/pixelgamelibrary/storage/command/CommandLineScanner.java deleted file mode 100644 index 2d59506..0000000 --- a/pixel/src/main/java/com/pixelgamelibrary/storage/command/CommandLineScanner.java +++ /dev/null @@ -1,29 +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 -// or write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -/////////////////////////////////////////////////////////////////////////////////////////////// -package com.pixelgamelibrary.storage.command; - -/** - * - * @author robertvokac - */ -public interface CommandLineScanner { - String nextLine(); - -} diff --git a/pixel/src/main/java/com/pixelgamelibrary/storage/command/StorageCommand.java b/pixel/src/main/java/com/pixelgamelibrary/storage/command/StorageCommand.java deleted file mode 100644 index 79ea625..0000000 --- a/pixel/src/main/java/com/pixelgamelibrary/storage/command/StorageCommand.java +++ /dev/null @@ -1,38 +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 -// or write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -/////////////////////////////////////////////////////////////////////////////////////////////// -package com.pixelgamelibrary.storage.command; - -/** - * - * @author robertvokac - */ -public interface StorageCommand { - - public String getName(); - - StorageCommandResult execute(String arguments); - StorageCommandLine getStorageCommandLine(); - - void setStorageCommandLine(StorageCommandLine storageCommandLine); - static StorageCommandResult emptyNewResult() { - return new StorageCommandResult(); - } - -} diff --git a/pixel/src/main/java/com/pixelgamelibrary/storage/command/StorageCommandLine.java b/pixel/src/main/java/com/pixelgamelibrary/storage/command/StorageCommandLine.java deleted file mode 100644 index 6727cca..0000000 --- a/pixel/src/main/java/com/pixelgamelibrary/storage/command/StorageCommandLine.java +++ /dev/null @@ -1,225 +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 -// or write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -/////////////////////////////////////////////////////////////////////////////////////////////// -package com.pixelgamelibrary.storage.command; - -import com.pixelgamelibrary.storage.Storage; -import java.util.Arrays; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; -import java.util.Optional; -import java.util.function.Consumer; -import java.util.function.Function; -import java.util.stream.Collectors; - -/** - * - * @author robertvokac - */ -public class StorageCommandLine { - - private String user; - private String hostname; - private Storage storage; - // - private boolean exited = false; - // - private long startNanoTime = System.nanoTime(); - - public String getCommandLineStart() { - return user + "@" + hostname + ":" + storage.pwd() + "$ "; - } - - private String extractArgument(String arguments, int argumentIndex) { - if(arguments.isEmpty()) { - return arguments; - } - String[] array = arguments.split(" "); - if (argumentIndex > (array.length)) { - return ""; - } - return array[argumentIndex + 1]; - } - - public StorageCommandLine(String userIn, String hostnameIn, Storage storageIn) { - - this.user = userIn; - this.hostname = hostnameIn; - this.storage = storageIn; - - addCommand("date", arguments -> provideOutput(result -> result.setOutput(new Date().toString()))); - addCommand("whoami", arguments -> provideOutput(result -> result.setOutput(user))); - addCommand("uptime", arguments -> provideOutput(result - -> result.setOutput( - new Date().toString().substring(11, 19) + " up " - + (System.nanoTime() - startNanoTime) / 1000000000l / 60l - + " minutes" - + ", 1 user" - ))); - - addCommand("hostname", arguments -> provideOutput(result -> result.setOutput(hostname))); - addCommand("test", arguments-> provideOutput(result-> result.setOutput((extractArgument(arguments, 0))))); - addCommand("uname", arguments -> provideOutput(result -> result.setOutput( - "LinuxBashCommandLinePartialEmulation" - + ((extractArgument(arguments, 0).equals("-a")) - ? (hostname + " 0.0.0 (" - + new Date().toString() + ")") - : "") - ))); - - addCommand("ls", arguments -> provideOutput(result -> result.setOutput(storage - .ls() - .stream() - .map(l -> { - String[] a = l.split("/"); - return a[a.length - 1]; - } - ).collect(Collectors.joining("\n"))))); - - addCommand("pwd", arguments -> provideOutput(result -> result.setOutput(storage.pwd()))); - addCommand("depth", arguments -> provideOutput(result -> result.setOutput(storage.depth()))); - - addCommand("mkdir", arguments -> provideOutput(result - -> { - String string = storage.mkdirmore(extractArguments(arguments)); - if (string.isEmpty()) { - result.setOutput("New directory was successfully created"); - - } else { - result.setErrorOutput("Creating new directory failed: " + string); - - } - } - )); - - commands.keySet().stream().map(k -> commands.get(k)).forEach(c -> c.setStorageCommandLine(this)); - } - - private String[] extractArguments(String arguments) { - return Arrays.asList(arguments.split(" ")).stream() - .filter(a->!a.isEmpty()) - .toArray(String[]::new); - } - - private StorageCommandResult provideOutput(Consumer consumer) { - - StorageCommandResult result = StorageCommand.emptyNewResult(); - consumer.accept(result); - return result; - } - - private void addCommand(String nameIn, Function functionIn) { - StorageCommand storageCommand = new BaseCommand(this, nameIn, functionIn); - commands.put(storageCommand.getName(), storageCommand); - } - - private final Map commands = new HashMap<>(); - - public String getUser() { - return user; - } - - public String getHostname() { - return hostname; - } - - public Storage getStorage() { - return storage; - } - - public boolean isExited() { - return exited; - } - - public StorageCommandResult execute(String commandWithArguments) { - - String[] arguments = commandWithArguments.split(" "); - String command = arguments.length == 0 ? "" : arguments[0]; - - StorageCommand storageCommand = commands.get(command); - if (storageCommand != null) { - return storageCommand.execute(commandWithArguments.substring(command.length())); - } - - int argumentCount = arguments.length - 1; - //System.out.println("argumentCount=" + argumentCount); - Optional argument1 = Optional.ofNullable(argumentCount >= 1 ? arguments[1] : null); - Optional argument2 = Optional.ofNullable(argumentCount >= 2 ? arguments[2] : null); - - StorageCommandResult finalResult = new StorageCommandResult(); - switch (command) { - - case "touch": - - String r = storage.touch(argument1.get()); - if (r.isEmpty()) { - finalResult.setOutput("New file was successfully created"); - } else { - finalResult.setErrorOutput("Creating new directory failed: " + r); - } - - break; - case "readtext": - - String rr = storage.readtext(argument1.get()); - if (rr != null) { - finalResult.setOutput("Text file was successfully loaded" + "\n\n" + rr); - } else { - finalResult.setErrorOutput("Loading text file failed:"); - } - - break; - - case "savetext": - - String result = storage.savetext(argument1.get(), argument2.get()); - if (result.isEmpty()) { - finalResult.setOutput("Text file was successfully saved"); - } else { - finalResult.setErrorOutput("Saving text file failed: " + result); - } - - break; - case "cd": - String rrr = argument1.isEmpty() ? storage.cd() : storage.cd(argument1.get()); - if (rrr.isEmpty()) { - finalResult.setOutput("Changing working directory was successfully created"); - } else { - finalResult.setErrorOutput("Changing working directory failed: " + rrr); - } - - break; - case "debug": - finalResult.setOutput(storage.debug()); - - break; - - case "exit": - exited = true; - finalResult.setOutput("Exited"); - break; - default: { - finalResult.setErrorOutput("Unsupported command: " + command); - } - } - return finalResult; - } - -} diff --git a/pixel/src/main/java/com/pixelgamelibrary/storage/command/StorageCommandLineScanner.java b/pixel/src/main/java/com/pixelgamelibrary/storage/command/StorageCommandLineScanner.java deleted file mode 100644 index 00647f4..0000000 --- a/pixel/src/main/java/com/pixelgamelibrary/storage/command/StorageCommandLineScanner.java +++ /dev/null @@ -1,55 +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 -// or write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -/////////////////////////////////////////////////////////////////////////////////////////////// -package com.pixelgamelibrary.storage.command; - -/** - * - * @author robertvokac - */ -public class StorageCommandLineScanner { - - public StorageCommandLineScanner(StorageCommandLine storageCommandLine, CommandLineScanner scanner) { - - while (true) { - System.out.print(storageCommandLine.getCommandLineStart()); - String argument = scanner.nextLine(); - - StorageCommandResult result = storageCommandLine.execute(argument); - if (result.isError()) { - printError(result.getOutput()); - } else { - print(result.getOutput()); - - } - if (storageCommandLine.isExited()) { - break; - } - } - } - - private static void print(String msg) { - System.out.println(msg); - } - - private static void printError(String msg) { - System.err.println(msg); - } - -} diff --git a/pixel/src/main/java/com/pixelgamelibrary/storage/command/StorageCommandResult.java b/pixel/src/main/java/com/pixelgamelibrary/storage/command/StorageCommandResult.java deleted file mode 100644 index d85c9b2..0000000 --- a/pixel/src/main/java/com/pixelgamelibrary/storage/command/StorageCommandResult.java +++ /dev/null @@ -1,68 +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 -// or write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -/////////////////////////////////////////////////////////////////////////////////////////////// -package com.pixelgamelibrary.storage.command; - -/** - * - * @author robertvokac - */ -public class StorageCommandResult { - - public StorageCommandResult() { - this(""); - } - - public StorageCommandResult(String output) { - this(output, false); - } - - public StorageCommandResult(String output, boolean error) { - this.output = output; - this.error = error; - } - - public String getOutput() { - return output; - } - - public boolean isError() { - return error; - } - - public void setOutput(int output) { - setOutput(String.valueOf(output)); - } - - public void setErrorOutput(String output) { - this.output = output; - setError(true); - } - - public void setOutput(String output) { - this.output = output; - } - - public void setError(boolean error) { - this.error = error; - } - - private String output; - private boolean error; -} diff --git a/pixel/src/main/java/com/pixelgamelibrary/storage/map/MapFileType.java b/pixel/src/main/java/com/pixelgamelibrary/storage/map/MapFileType.java deleted file mode 100644 index 38f36bb..0000000 --- a/pixel/src/main/java/com/pixelgamelibrary/storage/map/MapFileType.java +++ /dev/null @@ -1,47 +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 -// or write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -/////////////////////////////////////////////////////////////////////////////////////////////// -package com.pixelgamelibrary.storage.map; - -import com.pixelgamelibrary.storage.StorageException; - - -/** - * - * @author robertvokac - */ -public enum MapFileType { - FILE, DIRECTORY; - - public static MapFileType ofKey(String key, SimpleMap map) { - if (!map.contains(key)) { - throw new StorageException("Map does not contain key: " + key); - } - String value = map.getString(key); - if (value.startsWith(FILE.name())) { - return FILE; - } - if (value.startsWith(DIRECTORY.name())) { - return DIRECTORY; - } - throw new StorageException("Unsupported MapFileType for key in the map: " + key); - - } - -} diff --git a/pixel/src/main/java/com/pixelgamelibrary/storage/map/MapStorage.java b/pixel/src/main/java/com/pixelgamelibrary/storage/map/MapStorage.java deleted file mode 100644 index 297745f..0000000 --- a/pixel/src/main/java/com/pixelgamelibrary/storage/map/MapStorage.java +++ /dev/null @@ -1,344 +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 -// or write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -/////////////////////////////////////////////////////////////////////////////////////////////// -package com.pixelgamelibrary.storage.map; - -import com.badlogic.gdx.Gdx; -import com.pixelgamelibrary.Pixel; -import com.pixelgamelibrary.Platform; -import com.pixelgamelibrary.storage.StorageException; -import com.pixelgamelibrary.storage.Storage; -import java.util.List; -import java.util.stream.Collectors; - -/** - * - * @author robertvokac - */ -public class MapStorage implements Storage { - - private final SimpleMap map; - - private final MapStorageCompression mapStorageCompression; - public MapStorage(SimpleMap mapIn) { - this(mapIn, MapStorageCompression.NONE); - } - public MapStorage(SimpleMap mapIn, MapStorageCompression mapStorageCompressionIn) { - this.map = mapIn; - this.mapStorageCompression = mapStorageCompressionIn; - mkdir("/"); - - } - - private String workingDirectory = "/"; - - @Override - public Platform getPlatform() { - return null; - } - - private String convertToAbsolutePathIfNeeded(String path) { - if (path.startsWith(SLASH)) { - return path; - } - - return workingDirectory + (workingDirectory.equals("/") ? "" : SLASH) + path; - } - - private static final String TWO_DOTS = ".."; - - @Override - public String cd(String path) { -// System.out.println("path="+path); - String absolutePath = path.equals(TWO_DOTS) ? getParentPath(workingDirectory) : convertToAbsolutePathIfNeeded(path); - - if (!exists(absolutePath)) { - final String msg = "Path does not exist: " + absolutePath; - logError(msg); - return msg; - } - if (!isdir(absolutePath)) { - final String msg = "Path is not directory: " + absolutePath; - logError(msg); - return msg; - } - - workingDirectory = absolutePath; - return ""; - } - private static final String SLASH = "/"; - - @Override - public String mkdir(String path) { - if(path.isEmpty()) { - String msg = "Missing argument"; - logError(msg); - return msg; - } - String absolutePath = convertToAbsolutePathIfNeeded(path); - final String parentPath = getParentPath(absolutePath); - if (!path.equals(SLASH) && !exists(parentPath)) { - var msg = "Cannot create new directory, because parent path does not exist: " + parentPath; - logError(msg); - return msg; - } - if (!path.equals(SLASH) && !isdir(parentPath)) { - var msg = "Cannot create new directory, because parent path is not directory: " + parentPath; - logError(msg); - return msg; - } - if (exists(absolutePath)) { - var msg = "Cannot create new directory, because path already exists: " + absolutePath; - logError(msg); - return msg; - } - map.putString(absolutePath, MapFileType.DIRECTORY + EIGHT_COLONS); - - return ""; - - } - private static final String EIGHT_COLONS = "::::::::"; - - private static String getParentPath(String path) { -// System.out.println("getParentPath()"); - if (path == null) { - throw new StorageException("Path is null"); - } - if (path.trim().isEmpty()) { - throw new StorageException("Path is empty"); - } - - if (path.equals("/")) { - return path; - } - String[] array = path.split(SLASH); - if (array.length == 2) { - return SLASH; - } - return path.substring(0, path.length() - 1 - array[array.length - 1].length()); - } - - @Override - public String pwd() { - return workingDirectory; - } - - @Override - public int depth(String path) { - String absolutePath = convertToAbsolutePathIfNeeded(path); - if (absolutePath.equals(SLASH)) { - return 0; - } - String[] array = absolutePath.split(SLASH); - return array.length -1; - } - - @Override - public List ls(String path) { - int currentDepth = depth(path); - return map - .keyList() - .stream() - .filter(key -> key.startsWith(workingDirectory)) - .filter(key -> depth(key) == (currentDepth + 1)) - .collect(Collectors.toList()); - } - - @Override - public String touch(String path) { - return touch(path, ""); - } - - public String touch(String path, String content) { - String absolutePath = convertToAbsolutePathIfNeeded(path); - final String parentPath = getParentPath(absolutePath); - if (!exists(parentPath)) { - var msg = "Cannot create new file, because parent path does not exist: " + parentPath; - logError(msg); - return msg; - } - if (!isdir(parentPath)) { - var msg = "Cannot create new file, because parent path is not directory: " + parentPath; - logError(msg); - return msg; - } - if (exists(absolutePath)) { - var msg = "Cannot create new file, because path already exists: " + absolutePath; - logError(msg); - return msg; - } - map.putString(absolutePath, MapFileType.FILE + EIGHT_COLONS + content); - - return ""; - } - - @Override - public boolean rm(String path) { - String absolutePath = convertToAbsolutePathIfNeeded(path); - - if (!map.contains(absolutePath)) { - logError("Cannot remove file, because it does not exist: " + absolutePath); - return false; - } - map.remove(absolutePath); - return true; - } - - @Override - public String cp(String source, String target) { - return moveOrCp(source, target, false, true); - } - - @Override - public String mv(String source, String target) { - return moveOrCp(source, target, true, false); - } - - private String moveOrCp(String source, String target, boolean move, boolean cp) { - if (move && cp) { - throw new StorageException("move == true && cp == true"); - } - if (!move && !cp) { - throw new StorageException("move != true && cp != true"); - } - String absolutePathSource = convertToAbsolutePathIfNeeded(source); - String absolutePathTarget = convertToAbsolutePathIfNeeded(target); - String targetParentPath = getParentPath(absolutePathTarget); - - if (!exists(absolutePathSource)) { - final String msg = "absolutePathSource does not exist: " + absolutePathSource; - logError(msg); - return msg; - } - if (isdir(absolutePathSource)) { - final String msg = "absolutePathSource is directory: " + absolutePathSource; - logError(msg); - return msg; - } - if (!exists(targetParentPath)) { - final String msg = "targetParentPath does not exist: " + absolutePathSource; - logError(msg); - return msg; - } - if (!isdir(targetParentPath)) { - final String msg = "targetParentPath is not directory: " + absolutePathSource; - logError(msg); - return msg; - } - String contentOfSourceFile = map.getString(absolutePathSource); - String result = touch(absolutePathTarget); - if (!result.isEmpty()) { - var msg = "Creating new file failed: " + absolutePathTarget; - logError(msg); - return msg; - } - map.remove(absolutePathTarget); - map.putString(absolutePathTarget, contentOfSourceFile); - if (move) { - map.remove(absolutePathSource); - } - return ""; - } - - @Override - public String readtext(String path) { - String absolutePath = convertToAbsolutePathIfNeeded(path); - if (!exists(absolutePath)) { - logError("absolutePathSource does not exist: " + absolutePath); - return null; - } - if (isdir(absolutePath)) { - logError("absolutePathSource is directory: " + absolutePath); - return null; - } - String value = map.getString(absolutePath); - return value.split(EIGHT_COLONS)[1]; - } - - @Override - public byte[] readbin(String path) { - String absolutePath = convertToAbsolutePathIfNeeded(path); - - String text = readtext(absolutePath); - if (!text.startsWith(BINARYFILE)) { - logError("File is not binary:" + absolutePath); - return null; - } - text = text.substring(BINARYFILE.length()); - return Pixel.utils().decodeBase64AsByteArray(text); - } - private static final String BINARYFILE = "BINARYFILE"; - - @Override - public String savetext(String name, String text) { - return touch(name, text); - } - - @Override - public String savebin(String name, byte[] data) { - return savetext(name, BINARYFILE + Pixel.utils().encodeToBase64(data)); - } - - @Override - public boolean exists(String name) { - return map.contains(convertToAbsolutePathIfNeeded(name)); - } - - @Override - public boolean isfile(String name) { - return filetype(name) == MapFileType.FILE; - } - - @Override - public boolean isdir(String name) { - return filetype(name) == MapFileType.DIRECTORY; - } - - public MapFileType filetype(String name) { - return MapFileType.ofKey(convertToAbsolutePathIfNeeded(name), map); - } - - @Override - public String debug() { - StringBuilder sb = new StringBuilder(); - for(String key: map.keyList()) { - sb - .append(key) - .append("=") - .append(map.getString(key)) - .append("\n"); - } - return sb.toString(); - } - - @Override - public void flush() { - map.flush(); - } - - @Override - public boolean rmdir(String dirname) { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody - } - - private void logError(String msg) { - Pixel.app().error(msg); - } - -} diff --git a/pixel/src/main/java/com/pixelgamelibrary/storage/map/MapStorageCompression.java b/pixel/src/main/java/com/pixelgamelibrary/storage/map/MapStorageCompression.java deleted file mode 100644 index af92680..0000000 --- a/pixel/src/main/java/com/pixelgamelibrary/storage/map/MapStorageCompression.java +++ /dev/null @@ -1,28 +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 -// or write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -/////////////////////////////////////////////////////////////////////////////////////////////// -package com.pixelgamelibrary.storage.map; - -/** - * - * @author robertvokac - */ -public enum MapStorageCompression { - NONE; -} diff --git a/pixel/src/main/java/com/pixelgamelibrary/storage/map/MemoryStorage.java b/pixel/src/main/java/com/pixelgamelibrary/storage/map/MemoryStorage.java deleted file mode 100644 index 5ec8486..0000000 --- a/pixel/src/main/java/com/pixelgamelibrary/storage/map/MemoryStorage.java +++ /dev/null @@ -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 -// or write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -/////////////////////////////////////////////////////////////////////////////////////////////// -package com.pixelgamelibrary.storage.map; - -import com.pixelgamelibrary.Platform; - -/** - * - * @author robertvokac - */ -public class MemoryStorage extends MapStorage { - - @Override - public Platform getPlatform() { - return null; - } - - public MemoryStorage() { - super(new SimpleJavaMap()); - } - -} diff --git a/pixel/src/main/java/com/pixelgamelibrary/storage/map/SimpleJavaMap.java b/pixel/src/main/java/com/pixelgamelibrary/storage/map/SimpleJavaMap.java deleted file mode 100644 index 5f88f67..0000000 --- a/pixel/src/main/java/com/pixelgamelibrary/storage/map/SimpleJavaMap.java +++ /dev/null @@ -1,93 +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 -// or write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -/////////////////////////////////////////////////////////////////////////////////////////////// -package com.pixelgamelibrary.storage.map; - -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 SimpleJavaMap implements SimpleMap { - - private final Map map; - - public SimpleJavaMap() { - this(new HashMap<>()); - } - public SimpleJavaMap(Map mapIn) { - this.map = mapIn; - } - - @Override - public void putString(String key, String val) { - map.put(key, val); - } - - @Override - public void put(Map map) { - for (String key : map.keySet()) { - putString(key, map.get(key)); - } - } - - @Override - public String getString(String key) { - return map.get(key); - } - - @Override - public String getString(String key, String defaultValue) { - return contains(key) ? getString(key) : defaultValue; - } - - @Override - public Map getReadOnlyMap() { - return Collections.unmodifiableMap(map); - } - - @Override - public boolean contains(String key) { - return map.containsKey(key); - } - - @Override - public void clear() { - map.clear(); - } - - @Override - public void remove(String key) { - map.remove(key); - } - - @Override - public void flush() { - //nothing to do - } - @Override - public List keyList() { - return map.keySet().stream().collect(Collectors.toList()); - } -} diff --git a/pixel/src/main/java/com/pixelgamelibrary/storage/map/SimpleMap.java b/pixel/src/main/java/com/pixelgamelibrary/storage/map/SimpleMap.java deleted file mode 100644 index ec01fa1..0000000 --- a/pixel/src/main/java/com/pixelgamelibrary/storage/map/SimpleMap.java +++ /dev/null @@ -1,50 +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 -// or write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -/////////////////////////////////////////////////////////////////////////////////////////////// -package com.pixelgamelibrary.storage.map; - -import java.util.List; -import java.util.Map; - -/** - * - * @author robertvokac - */ -public interface SimpleMap { - - public void putString(String key, String val); - - public void put(Map map); - - public String getString(String key); - - public String getString(String key, String defaultValue); - - public Map getReadOnlyMap(); - - public boolean contains(String key); - - public void clear(); - - public void remove(String key); - - public void flush(); - - public List keyList(); -} diff --git a/pixel/src/test/java/com/pixelgamelibrary/.gitkeep b/pixel/src/test/java/com/pixelgamelibrary/.gitkeep deleted file mode 100644 index 8d1c8b6..0000000 --- a/pixel/src/test/java/com/pixelgamelibrary/.gitkeep +++ /dev/null @@ -1 +0,0 @@ - diff --git a/settings.gradle b/settings.gradle index e0ee968..da5a7ea 100644 --- a/settings.gradle +++ b/settings.gradle @@ -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', 'pixel-backend-libgdx' +include 'lwjgl3', 'android', 'html', 'core', 'pixel-backend-libgdx'