-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
marcin.sciesinski
committed
Feb 1, 2021
1 parent
dba1278
commit c09ccec
Showing
7 changed files
with
195 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
apply plugin: "java" | ||
apply plugin: "maven" | ||
apply plugin: "signing" | ||
apply plugin: "maven-publish" | ||
|
||
sourceCompatibility = 1.7 | ||
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8' | ||
|
||
sourceSets.main.java.srcDirs = ["src/"] | ||
sourceSets.main.resources.srcDirs = ["resources/"] | ||
sourceSets.test.java.srcDirs = ["test/"] | ||
sourceSets.test.resources.srcDirs = ["test-resources/"] | ||
|
||
|
||
sourceSets.main.java.srcDirs = ["src/"] | ||
|
||
archivesBaseName = "libgdx-gemp-lib-artemis" | ||
|
||
eclipse.project.name = "libgdx-gemp-lib-artemis" | ||
|
||
task javadocJar(type: Jar) { | ||
classifier 'javadoc' | ||
from javadoc | ||
} | ||
|
||
task sourcesJar(type: Jar) { | ||
classifier 'sources' | ||
from sourceSets.main.allSource | ||
} | ||
|
||
artifacts { | ||
archives javadocJar, sourcesJar | ||
} | ||
|
||
publishing { | ||
publications { | ||
mavenJava(MavenPublication) { | ||
pom { | ||
name = "libgdx-graph" | ||
description = "libGDX utility library" | ||
url = "https://github.com/MarcinSc/libgdx-gemp-lib" | ||
licenses { | ||
license { | ||
name = "The MIT License (MIT)" | ||
url = "https://mit-license.org/" | ||
} | ||
} | ||
developers { | ||
developer { | ||
id = "MarcinSc" | ||
name = "Marcin Sciesinski" | ||
email = "[email protected]" | ||
} | ||
} | ||
scm { | ||
connection = "[email protected]:MarcinSc/libgdx-gemp-lib.git" | ||
developerConnection = "[email protected]:MarcinSc/libgdx-gemp-lib.git" | ||
url = "https://github.com/MarcinSc/libgdx-gemp-lib" | ||
} | ||
} | ||
|
||
from components.java | ||
artifact javadocJar | ||
artifact sourcesJar | ||
} | ||
} | ||
|
||
repositories { | ||
maven { | ||
name = "OSSRH" | ||
url = "https://oss.sonatype.org/service/local/staging/deploy/maven2/" | ||
credentials { | ||
username = System.getenv("MAVEN_USERNAME") | ||
password = System.getenv("MAVEN_PASSWORD") | ||
} | ||
} | ||
} | ||
} | ||
|
||
signing { | ||
sign publishing.publications | ||
} |
9 changes: 9 additions & 0 deletions
9
libgdx-gemp-lib-artemis/resources/com/gempukku/libgdx/lib-artemis.gwt.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit trunk//EN" | ||
"http://google-web-toolkit.googlecode.com/svn/trunk/distro-source/core/src/gwt-module.dtd"> | ||
<module> | ||
<source path="lib/template/artemis"/> | ||
<extend-configuration-property name="gdx.reflect.include" | ||
value="com.gempukku.libgdx.lib.template.artemis.EntityDef"/> | ||
<extend-configuration-property name="gdx.reflect.include" value="com.artemis.Component"/> | ||
</module> |
50 changes: 50 additions & 0 deletions
50
...lib-artemis/src/com/gempukku/libgdx/lib/template/artemis/ArtemisTemplateEntityLoader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package com.gempukku.libgdx.lib.template.artemis; | ||
|
||
import com.badlogic.gdx.Application; | ||
import com.badlogic.gdx.Gdx; | ||
import com.badlogic.gdx.assets.loaders.FileHandleResolver; | ||
import com.badlogic.gdx.files.FileHandle; | ||
import com.badlogic.gdx.utils.Json; | ||
import com.badlogic.gdx.utils.JsonValue; | ||
import com.badlogic.gdx.utils.JsonWriter; | ||
import com.gempukku.libgdx.lib.template.JsonTemplateLoader; | ||
|
||
public class ArtemisTemplateEntityLoader { | ||
public static EntityDef loadTemplate(String file, Json json, FileHandleResolver resolver) { | ||
JsonValue jsonValue = JsonTemplateLoader.loadTemplateFromFile(file, resolver); | ||
return convertToArtemis(jsonValue, json); | ||
} | ||
|
||
public static EntityDef loadTemplate(FileHandle fileHandle, Json json, FileHandleResolver resolver) { | ||
JsonValue jsonValue = JsonTemplateLoader.loadTemplateFromFile(fileHandle, resolver); | ||
return convertToArtemis(jsonValue, json); | ||
} | ||
|
||
public static EntityDef convertToArtemis(JsonValue jsonValue, Json json) { | ||
JsonValue artemisJson = convertToArtemisEntityJson(jsonValue); | ||
if (Gdx.app.getLogLevel() >= Application.LOG_DEBUG) | ||
Gdx.app.debug("ArtemisTemplate", artemisJson.toJson(JsonWriter.OutputType.json)); | ||
return json.readValue(EntityDef.class, artemisJson); | ||
} | ||
|
||
public static JsonValue convertToArtemisEntityJson(JsonValue value) { | ||
JsonValue result = new JsonValue(JsonValue.ValueType.object); | ||
JsonValue componentsArray = new JsonValue(JsonValue.ValueType.array); | ||
JsonValue lastChild = null; | ||
for (JsonValue jsonValue : value) { | ||
String name = jsonValue.name(); | ||
jsonValue.addChild("class", new JsonValue(name)); | ||
if (lastChild == null) { | ||
lastChild = jsonValue; | ||
componentsArray.addChild(lastChild); | ||
} else { | ||
lastChild.next = jsonValue; | ||
jsonValue.parent = result; | ||
lastChild = jsonValue; | ||
} | ||
} | ||
componentsArray.size = value.size; | ||
result.addChild("components", componentsArray); | ||
return result; | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
libgdx-gemp-lib-artemis/src/com/gempukku/libgdx/lib/template/artemis/ArtemisWorldJson.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.gempukku.libgdx.lib.template.artemis; | ||
|
||
import com.artemis.Component; | ||
import com.artemis.World; | ||
import com.badlogic.gdx.utils.Json; | ||
import com.badlogic.gdx.utils.JsonWriter; | ||
import com.badlogic.gdx.utils.reflect.ClassReflection; | ||
|
||
public class ArtemisWorldJson extends Json { | ||
private World world; | ||
|
||
public ArtemisWorldJson(World world) { | ||
this.world = world; | ||
} | ||
|
||
public ArtemisWorldJson(JsonWriter.OutputType outputType, World world) { | ||
super(outputType); | ||
this.world = world; | ||
} | ||
|
||
@Override | ||
protected Object newInstance(Class type) { | ||
if (ClassReflection.isAssignableFrom(Component.class, type)) | ||
return world.createComponent(type); | ||
return super.newInstance(type); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
libgdx-gemp-lib-artemis/src/com/gempukku/libgdx/lib/template/artemis/EntityDef.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.gempukku.libgdx.lib.template.artemis; | ||
|
||
import com.artemis.Component; | ||
import com.badlogic.gdx.utils.Array; | ||
|
||
public class EntityDef { | ||
private Array<Component> components; | ||
|
||
public Array<Component> getComponents() { | ||
return components; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
include 'libgdx-gemp-lib', 'libgdx-gemp-lib-ashley', 'libgdx-gemp-lib-test' | ||
include 'libgdx-gemp-lib', 'libgdx-gemp-lib-ashley', 'libgdx-gemp-lib-artemis', 'libgdx-gemp-lib-test' |