diff options
author | Nao Pross <naopross@thearcway.org> | 2018-12-15 17:25:29 +0100 |
---|---|---|
committer | Nao Pross <naopross@thearcway.org> | 2018-12-15 17:25:29 +0100 |
commit | d583d3c56a2643a7130e82094e1fda623b00f07f (patch) | |
tree | b5a36dd31401be4e8f0f2d778c43b95dff0ed335 | |
parent | Remove Gson dependency start custom libjtmx implementation (diff) | |
download | Subconscious-java-d583d3c56a2643a7130e82094e1fda623b00f07f.tar.gz Subconscious-java-d583d3c56a2643a7130e82094e1fda623b00f07f.zip |
Add initial XML obj representation for Map
Diffstat (limited to '')
-rw-r--r-- | src/libjtmx/Map.java | 68 | ||||
-rw-r--r-- | src/libjtmx/TileSet.java | 6 | ||||
-rw-r--r-- | src/libjtmx/module-info.java | 1 |
3 files changed, 74 insertions, 1 deletions
diff --git a/src/libjtmx/Map.java b/src/libjtmx/Map.java index d9333a8..70ff9b0 100644 --- a/src/libjtmx/Map.java +++ b/src/libjtmx/Map.java @@ -2,9 +2,75 @@ package libjtmx; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementWrapper; import javax.xml.bind.annotation.XmlRootElement; -@XmlRootElement +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Unmarshaller; + +import java.io.InputStream; + +import java.awt.Color; + +import java.util.List; + + +@XmlRootElement(name = "map") public class Map { + public enum Orientation { + ORTHOGONAL, + ISOMETRIC, + STAGGERED, + HEXAGONAL + } + + public enum RenderOrder { + RIGHT_DOWN, + RIGHT_UP, + LEFT_DOWN, + LEFT_UP + } + + /* attributes */ + String version; + String tiledVersion; + + Orientation orientation; + RenderOrder renderOrder; + + int width; + int height; + + int tileWidth; + int tileHeight; + + // hex is not supported yet + /* + int hexSideLenght; + Axis staggerAxis; + String staggerIndex; + */ + + Color backgroundColor; + + /* elements */ + List<TileSet> tileSets; + + private Map() {} + + public static Map load(InputStream is) { + Map map = null; + + try { + JAXBContext context = JAXBContext.newInstance(Map.class); + Unmarshaller unmarshaller = context.createUnmarshaller(); + + map = (Map) unmarshaller.unmarshal(is); + } catch (JAXBException ex) { + ex.printStackTrace(); + } + return map; + } }
\ No newline at end of file diff --git a/src/libjtmx/TileSet.java b/src/libjtmx/TileSet.java new file mode 100644 index 0000000..3d1991c --- /dev/null +++ b/src/libjtmx/TileSet.java @@ -0,0 +1,6 @@ +package libjtmx; + + +public class TileSet { + +}
\ No newline at end of file diff --git a/src/libjtmx/module-info.java b/src/libjtmx/module-info.java index 4dc4197..4da9418 100644 --- a/src/libjtmx/module-info.java +++ b/src/libjtmx/module-info.java @@ -1,3 +1,4 @@ module libjtmx { requires java.xml.bind; + requires java.desktop; }
\ No newline at end of file |