From 276ab47f26f2ce1bc9be6eed9ca492cc66f2b270 Mon Sep 17 00:00:00 2001 From: Not Zed Date: Tue, 28 Feb 2023 12:28:17 +1030 Subject: [PATCH] Added editor, such as it is. De-duplicated xml io and viewer classes. --- Makefile | 23 +- build.xml | 65 ++ .../classes/duskz/client/DataManager.java | 68 +- .../classes/duskz/client/Dusk.java | 6 +- .../duskz/client/fx/DataManagerFX.java | 129 +++- src/duskz.client/classes/module-info.java | 2 + .../classes/duskz/map/Locatable.java | 29 + .../classes/duskz/map}/Location.java | 2 +- .../classes/duskz/map}/TileMap.java | 138 ++-- .../classes/duskz/map/io}/Data.java | 2 +- .../classes/duskz/map/io}/Image.java | 2 +- .../classes/duskz/map/io}/Layer.java | 2 +- .../classes/duskz/map/io}/Map.java | 2 +- .../classes/duskz/map/io}/Object.java | 2 +- .../classes/duskz/map/io}/ObjectFactory.java | 2 +- .../classes/duskz/map/io}/Objectgroup.java | 2 +- .../classes/duskz/map/io}/Properties.java | 2 +- .../classes/duskz/map/io}/Property.java | 2 +- .../classes/duskz/map/io}/Tile.java | 2 +- .../classes/duskz/map/io}/Tileset.java | 2 +- .../classes/duskz/util}/PropertyLoader.java | 2 +- src/duskz.common/classes/module-info.java | 5 + .../classes/au/notzed/tilez/io/Data.java | 111 --- .../classes/au/notzed/tilez/io/Image.java | 161 ----- .../classes/au/notzed/tilez/io/Layer.java | 266 -------- .../classes/au/notzed/tilez/io/Map.java | 366 ---------- .../classes/au/notzed/tilez/io/Object.java | 240 ------- .../au/notzed/tilez/io/ObjectFactory.java | 119 ---- .../au/notzed/tilez/io/Objectgroup.java | 193 ------ .../au/notzed/tilez/io/Properties.java | 60 -- .../classes/au/notzed/tilez/io/Property.java | 83 --- .../classes/au/notzed/tilez/io/Tile.java | 131 ---- .../classes/au/notzed/tilez/io/Tileset.java | 279 -------- .../classes/duskz/server/entity/TileMap.java | 2 +- .../classes/duskz/server/entityz/Active.java | 12 +- .../duskz/server/entityz/Converter.java | 5 +- .../classes/duskz/server/entityz/Faction.java | 3 +- .../classes/duskz/server/entityz/Game.java | 9 +- .../classes/duskz/server/entityz/Mobile.java | 5 +- .../duskz/server/entityz/PlayerCommands.java | 11 +- .../duskz/server/entityz/PlayerState.java | 5 +- .../classes/duskz/server/entityz/Race.java | 3 +- .../classes/duskz/server/entityz/Thing.java | 37 +- src/duskz.server/classes/module-info.java | 1 - .../classes/duskz/editor}/DuskInfoView.java | 2 +- .../classes/duskz/editor}/LocationEditor.java | 4 +- .../classes/duskz/editor}/MapLayer.java | 2 +- .../classes/duskz/editor}/TZ.java | 2 +- .../classes/duskz/editor}/TextEditor.java | 2 +- .../classes/duskz/editor}/TileView.java | 2 +- .../classes/duskz/editor}/TileZ.java | 8 +- .../classes/duskz/proto/Junk.java | 0 .../classes/duskz/tool}/Convert.java | 2 +- .../duskz/tool/fx}/MapSelectionModel.java | 2 +- .../classes/duskz/tool/fx}/MapView.java | 124 +++- .../classes/duskz/tool/fx/TileAnimator.java | 59 ++ .../classes/duskz/viewer/MapViewer.java | 79 +++ .../classes/duskz/viewer}/Tiled.java | 641 +++++++++++------- src/duskz.tools/classes/module-info.java | 36 + 59 files changed, 1154 insertions(+), 2404 deletions(-) create mode 100644 build.xml create mode 100644 src/duskz.common/classes/duskz/map/Locatable.java rename src/{duskz.server/classes/duskz/server/entityz => duskz.common/classes/duskz/map}/Location.java (98%) rename src/{duskz.server/classes/duskz/server/entityz => duskz.common/classes/duskz/map}/TileMap.java (90%) rename src/{duskz.server/classes/duskz/io/tiled => duskz.common/classes/duskz/map/io}/Data.java (99%) rename src/{duskz.server/classes/duskz/io/tiled => duskz.common/classes/duskz/map/io}/Image.java (99%) rename src/{duskz.server/classes/duskz/io/tiled => duskz.common/classes/duskz/map/io}/Layer.java (99%) rename src/{duskz.server/classes/duskz/io/tiled => duskz.common/classes/duskz/map/io}/Map.java (99%) rename src/{duskz.server/classes/duskz/io/tiled => duskz.common/classes/duskz/map/io}/Object.java (99%) rename src/{duskz.server/classes/duskz/io/tiled => duskz.common/classes/duskz/map/io}/ObjectFactory.java (99%) rename src/{duskz.server/classes/duskz/io/tiled => duskz.common/classes/duskz/map/io}/Objectgroup.java (99%) rename src/{duskz.server/classes/duskz/io/tiled => duskz.common/classes/duskz/map/io}/Properties.java (98%) rename src/{duskz.server/classes/duskz/io/tiled => duskz.common/classes/duskz/map/io}/Property.java (98%) rename src/{duskz.server/classes/duskz/io/tiled => duskz.common/classes/duskz/map/io}/Tile.java (99%) rename src/{duskz.server/classes/duskz/io/tiled => duskz.common/classes/duskz/map/io}/Tileset.java (99%) rename src/{duskz.server/classes/duskz/server/entityz => duskz.common/classes/duskz/util}/PropertyLoader.java (99%) delete mode 100644 src/duskz.editor/classes/au/notzed/tilez/io/Data.java delete mode 100644 src/duskz.editor/classes/au/notzed/tilez/io/Image.java delete mode 100644 src/duskz.editor/classes/au/notzed/tilez/io/Layer.java delete mode 100644 src/duskz.editor/classes/au/notzed/tilez/io/Map.java delete mode 100644 src/duskz.editor/classes/au/notzed/tilez/io/Object.java delete mode 100644 src/duskz.editor/classes/au/notzed/tilez/io/ObjectFactory.java delete mode 100644 src/duskz.editor/classes/au/notzed/tilez/io/Objectgroup.java delete mode 100644 src/duskz.editor/classes/au/notzed/tilez/io/Properties.java delete mode 100644 src/duskz.editor/classes/au/notzed/tilez/io/Property.java delete mode 100644 src/duskz.editor/classes/au/notzed/tilez/io/Tile.java delete mode 100644 src/duskz.editor/classes/au/notzed/tilez/io/Tileset.java rename src/{duskz.editor/classes/au/notzed/tilez => duskz.tools/classes/duskz/editor}/DuskInfoView.java (98%) rename src/{duskz.editor/classes/au/notzed/tilez => duskz.tools/classes/duskz/editor}/LocationEditor.java (99%) rename src/{duskz.editor/classes/au/notzed/tilez => duskz.tools/classes/duskz/editor}/MapLayer.java (98%) rename src/{duskz.editor/classes/au/notzed/tilez => duskz.tools/classes/duskz/editor}/TZ.java (97%) rename src/{duskz.editor/classes/au/notzed/tilez => duskz.tools/classes/duskz/editor}/TextEditor.java (99%) rename src/{duskz.editor/classes/au/notzed/tilez => duskz.tools/classes/duskz/editor}/TileView.java (97%) rename src/{duskz.editor/classes/au/notzed/tilez => duskz.tools/classes/duskz/editor}/TileZ.java (92%) rename src/{duskz.server => duskz.tools}/classes/duskz/proto/Junk.java (100%) rename src/{duskz.server/classes/duskz/io => duskz.tools/classes/duskz/tool}/Convert.java (98%) rename src/{duskz.editor/classes/au/notzed/tilez => duskz.tools/classes/duskz/tool/fx}/MapSelectionModel.java (98%) rename src/{duskz.editor/classes/au/notzed/tilez => duskz.tools/classes/duskz/tool/fx}/MapView.java (79%) create mode 100644 src/duskz.tools/classes/duskz/tool/fx/TileAnimator.java create mode 100644 src/duskz.tools/classes/duskz/viewer/MapViewer.java rename src/{duskz.server/classes/duskz/io => duskz.tools/classes/duskz/viewer}/Tiled.java (51%) create mode 100644 src/duskz.tools/classes/module-info.java diff --git a/Makefile b/Makefile index 9488d4e..73bd8d8 100644 --- a/Makefile +++ b/Makefile @@ -5,11 +5,18 @@ dist_EXTRA= include config.make -java_MODULES = duskz.common duskz.client duskz.server +java_MODULES = \ + duskz.common \ + duskz.client \ + duskz.server \ + duskz.tools duskz.client_JDEPMOD = duskz.common duskz.server_JDEPMOD = duskz.common +duskz.editor_JDEPMOD = duskz.common duskz.client +duskz.viewer_JDEPMOD = duskz.common duskz.client + include java.make maven_central_JARS = \ @@ -36,15 +43,25 @@ include maven.make run-server-old: duskz.server cd game-2.7.3 && \ $(JAVA) \ - --module-path $(JAVAFX_HOME)/lib:../.lib:../bin/$(TARGET)/lib \ + --module-path ../.lib:../bin/$(TARGET)/lib \ -m duskz.server/duskz.server.DuskServer run-server: duskz.server $(JAVA) \ - --module-path $(JAVAFX_HOME)/lib:../.lib:../bin/$(TARGET)/lib \ + --module-path .lib:bin/$(TARGET)/lib \ -m duskz.server/duskz.server.entityz.GameServer game run-client: duskz.client $(JAVA) \ $(if $(JAVAMODPATH),--module-path $(subst $(S),:,$(JAVAMODPATH))) \ -m duskz.client/duskz.client.fx.DuskFX + +run-viewer: duskz.tools + $(JAVA) \ + $(if $(JAVAMODPATH),--module-path $(subst $(S),:,$(JAVAMODPATH))) \ + -m duskz.tools/duskz.viewer.MapViewer + +run-editor: duskz.tools + $(JAVA) \ + $(if $(JAVAMODPATH),--module-path $(subst $(S),:,$(JAVAMODPATH))) \ + -m duskz.tools/duskz.viewer.MapViewer diff --git a/build.xml b/build.xml new file mode 100644 index 0000000..200816d --- /dev/null +++ b/build.xml @@ -0,0 +1,65 @@ + + + + + + + + + + + Builds, tests, and runs the project DuskZ. + + + diff --git a/src/duskz.client/classes/duskz/client/DataManager.java b/src/duskz.client/classes/duskz/client/DataManager.java index 52a0249..3c7343f 100644 --- a/src/duskz.client/classes/duskz/client/DataManager.java +++ b/src/duskz.client/classes/duskz/client/DataManager.java @@ -31,6 +31,8 @@ import java.util.jar.Attributes; import java.util.jar.JarEntry; import java.util.jar.JarInputStream; import java.util.jar.Manifest; +import javafx.geometry.Rectangle2D; +import javafx.scene.image.ImageView; /** * Utility for loading game objects from jar file @@ -99,6 +101,28 @@ public class DataManager { return list.toArray(new ImageSet[list.size()]); } + public InputStream getInputStream(String path) throws IOException { + JarInputStream jis = null; + try { + jis = openJar(); + JarEntry je; + + System.out.println("Looking for: " + path); + + while ((je = jis.getNextJarEntry()) != null) { + System.out.println("je = " + je.getName()); + if (je.getName().equals(path)) + return jis; + } + jis.close(); + throw new FileNotFoundException(path); + } catch (IOException ex) { + if (jis != null) + jis.close(); + throw ex; + } + } + public class ImageSet { public String name; @@ -113,27 +137,27 @@ public class DataManager { public void load() throws IOException { } - - public InputStream getInputStream() throws IOException { - JarInputStream jis = null; - try { - jis = openJar(); - JarEntry je; - - System.out.println("Looking for: " + source); - - while ((je = jis.getNextJarEntry()) != null) { - System.out.println("je = " + je.getName()); - if (je.getName().equals(source)) - return jis; - } - jis.close(); - throw new FileNotFoundException(source); - } catch (IOException ex) { - if (jis != null) - jis.close(); - throw ex; - } - } + /* + public InputStream getInputStream() throws IOException { + JarInputStream jis = null; + try { + jis = openJar(); + JarEntry je; + + System.out.println("Looking for: " + source); + + while ((je = jis.getNextJarEntry()) != null) { + System.out.println("je = " + je.getName()); + if (je.getName().equals(source)) + return jis; + } + jis.close(); + throw new FileNotFoundException(source); + } catch (IOException ex) { + if (jis != null) + jis.close(); + throw ex; + } + }*/ } } diff --git a/src/duskz.client/classes/duskz/client/Dusk.java b/src/duskz.client/classes/duskz/client/Dusk.java index fbc0264..c63efd7 100644 --- a/src/duskz.client/classes/duskz/client/Dusk.java +++ b/src/duskz.client/classes/duskz/client/Dusk.java @@ -124,9 +124,9 @@ public class Dusk implements Runnable, DuskProtocol { } // Main entry point - //static public void main(String[] args) { - // new Dusk(); - //} + static public void main(String[] args) { + } + void connect() { throw new UnsupportedOperationException(); } diff --git a/src/duskz.client/classes/duskz/client/fx/DataManagerFX.java b/src/duskz.client/classes/duskz/client/fx/DataManagerFX.java index 041ee6c..8281c91 100644 --- a/src/duskz.client/classes/duskz/client/fx/DataManagerFX.java +++ b/src/duskz.client/classes/duskz/client/fx/DataManagerFX.java @@ -22,8 +22,14 @@ package duskz.client.fx; import duskz.client.DataManager; +import java.io.BufferedReader; +import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; import javafx.geometry.Rectangle2D; import javafx.scene.image.Image; import javafx.scene.image.ImageView; @@ -36,10 +42,119 @@ import javafx.scene.image.ImageView; */ public class DataManagerFX extends DataManager { + HashMap animset = new HashMap<>(); + public DataManagerFX(String source) { super(source); } + public boolean isAnimRoot(int id) { + return animset.containsKey(id); + } + + public AnimSetFX getAnimSet(int id) { + return animset.get(id); + } + + @Override + public void open() throws IOException { + super.open(); + + try (BufferedReader is = new BufferedReader(new InputStreamReader(getInputStream("tiles/anim")))) { + String line; + PropParser prop = new PropParser(); + + while ((line = is.readLine()) != null) { + if (!prop.setInput(line)) + continue; + + if (!prop.getProperty().startsWith("anim.")) + continue; + + AnimSetFX anim = new AnimSetFX(prop.getProperty().substring(5)); + List rects = new ArrayList<>(); + while (!prop.eof()) { + int tileid = prop.nextInt(); + int time = 250; + + if (prop.nextChar(':')) { + time = prop.nextInt(); + } + + if (anim.root == -1) + anim.root = tileid; + rects.add(createTile(tileid, 0, 0, 64, 64).getViewport()); + + if (!prop.nextChar(',')) + break; + } + if (anim.root != -1) { + anim.tiles = rects.toArray(new Rectangle2D[rects.size()]); + animset.put(anim.root, anim); + } + } + } catch (FileNotFoundException ex) { + } + /* final Rectangle2D[] anims = new Rectangle2D[2]; + anims[0] = data.createTile(305, 0, 0, tileSize, tileSize).getViewport(); + anims[1] = data.createTile(304, 0, 0, tileSize, tileSize).getViewport(); + final List animated = new ArrayList<>(); + */ + + } + + static class PropParser { + + String input; + String prop; + int eq; + int index; + + public boolean setInput(String input) { + this.input = input; + + eq = input.indexOf("="); + if (eq > 0) { + index = eq + 1; + prop = input.substring(0, eq); + return true; + } else { + prop = null; + return false; + } + } + + public String getProperty() { + return prop; + } + + public boolean eof() { + return index == -1 || index >= input.length(); + } + + public int nextInt() { + int val = 0; + while (!eof()) { + char c = input.charAt(index); + if (Character.isDigit(c)) { + val = val * 10 + Character.digit(c, 10); + index++; + } else { + return val; + } + } + return val; + } + + public boolean nextChar(char c) { + if (!eof() && input.charAt(index) == c) { + index++; + return true; + } + return false; + } + } + @Override protected ImageSet createImageSet() { return new ImageSetFX(); @@ -95,6 +210,18 @@ public class DataManagerFX extends DataManager { return new ImageView(); } + public class AnimSetFX { + + public String name; + public int root = -1; + public Rectangle2D[] tiles; + public int rate = 250; + + public AnimSetFX(String name) { + this.name = name; + } + } + public class ImageSetFX extends ImageSet { Image image; @@ -105,7 +232,7 @@ public class DataManagerFX extends DataManager { public void load() throws IOException { System.out.println("Load tileset " + name + " gid " + gid + " count " + count); - try (InputStream s = getInputStream()) { + try (InputStream s = getInputStream(this.source)) { image = new Image(s); } diff --git a/src/duskz.client/classes/module-info.java b/src/duskz.client/classes/module-info.java index 5c79a77..542a148 100644 --- a/src/duskz.client/classes/module-info.java +++ b/src/duskz.client/classes/module-info.java @@ -21,6 +21,8 @@ module duskz.client { requires java.logging; requires duskz.common; + requires java.desktop; // for old client? + requires javafx.graphics; requires javafx.controls; diff --git a/src/duskz.common/classes/duskz/map/Locatable.java b/src/duskz.common/classes/duskz/map/Locatable.java new file mode 100644 index 0000000..4a7a878 --- /dev/null +++ b/src/duskz.common/classes/duskz/map/Locatable.java @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2023 Michael Zucchi + * + * 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 2 + * 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ +package duskz.map; + +public interface Locatable { + + public int getX(); + + public int getY(); + + public void setX(int x); + + public void setY(int y); +} diff --git a/src/duskz.server/classes/duskz/server/entityz/Location.java b/src/duskz.common/classes/duskz/map/Location.java similarity index 98% rename from src/duskz.server/classes/duskz/server/entityz/Location.java rename to src/duskz.common/classes/duskz/map/Location.java index f41962d..9569a48 100644 --- a/src/duskz.server/classes/duskz/server/entityz/Location.java +++ b/src/duskz.common/classes/duskz/map/Location.java @@ -17,7 +17,7 @@ * along with DuskZ; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -package duskz.server.entityz; +package duskz.map; /** * Track position. diff --git a/src/duskz.server/classes/duskz/server/entityz/TileMap.java b/src/duskz.common/classes/duskz/map/TileMap.java similarity index 90% rename from src/duskz.server/classes/duskz/server/entityz/TileMap.java rename to src/duskz.common/classes/duskz/map/TileMap.java index f422465..de35e0b 100644 --- a/src/duskz.server/classes/duskz/server/entityz/TileMap.java +++ b/src/duskz.common/classes/duskz/map/TileMap.java @@ -20,15 +20,18 @@ /** * Changes */ -package duskz.server.entityz; +package duskz.map; -import duskz.server.entityz.PropertyLoader.PropertyEntry; +//import duskz.server.entityz.Thing; +import duskz.util.PropertyLoader; +import duskz.util.PropertyLoader.PropertyEntry; import duskz.util.Maths; import java.io.DataInputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; +import java.io.InputStream; import java.io.RandomAccessFile; import java.util.ArrayList; import java.util.HashMap; @@ -47,7 +50,7 @@ import java.util.zip.GZIPInputStream; * * @author notzed */ -public class TileMap implements Iterable { +public class TileMap implements Iterable { /** * Name of map for referencing @@ -191,6 +194,65 @@ public class TileMap implements Iterable { // TODO: gzip? public static final int MAGIC_LAYERED = 0x6d61707a; + /** + * Load just the map part of a map. + * + * TODO: sort something out with the alias stuff and loadLayered() + * + * @param is + * @param name + * @return + * @throws IOException + */ + public static TileMap loadLayeredMap(InputStream is, String name) throws IOException { + TileMap map; + + try (DataInputStream mapFile = new DataInputStream((is))) { + int magic = mapFile.readInt(); + int version = mapFile.readInt(); + int flags = mapFile.readInt(); + int cols = mapFile.readInt(); + int rows = mapFile.readInt(); + int groundLayer = mapFile.readInt(); + int layerCount = mapFile.readInt(); + + if (magic != MAGIC_LAYERED + || version != 0) { + throw new IOException("Invalid format/magic/unknown version"); + } + + System.out.println("Load map: " + name); + System.out.printf(" size: %dx%d\n", cols, rows); + System.out.printf(" groundLayer: %d\n", groundLayer); + System.out.printf(" layerCount: %d\n", layerCount); + + map = new TileMap(name, cols, rows); + + map.groundLayer = groundLayer; + map.layers = new TileLayer[layerCount]; + for (int l = 0; l < layerCount; l++) { + int tx = mapFile.readInt(); + int ty = mapFile.readInt(); + int twidth = mapFile.readInt(); + int theight = mapFile.readInt(); + TileLayer tl; + + System.out.printf(" layer %2d: at %3d,%3d size %3dx%3d\n", l, tx, ty, twidth, theight); + if (l == groundLayer) + tl = new TileLayer(tx, ty, twidth, theight, map.tiles); + else + tl = new TileLayer(tx, ty, twidth, theight); + + map.layers[l] = tl; + + for (int i = 0; i < twidth * theight; i++) { + tl.tiles[i] = mapFile.readShort(); + } + } + } + return map; + } + /** * Load a layered map. Format is: * magic: int @@ -488,10 +550,10 @@ public class TileMap implements Iterable { } public synchronized void addEntity(Thing o) { - if (inside(o.x, o.y)) { + if (inside(o.getX(), o.getY())) { //int index = o.x + o.y * cols; //entities[index] = Thing.append(entities[index], o); - Location l = new Location(o.x, o.y); + Location l = new Location(o.getX(), o.getY()); LinkedList ll = entities.get(l); if (ll == null) { ll = new LinkedList<>(); @@ -506,10 +568,10 @@ public class TileMap implements Iterable { } public synchronized void removeEntity(Thing o) { - if (inside(o.x, o.y)) { + if (inside(o.getX(), o.getY())) { //int index = o.x + o.y * cols; //entities[index] = Thing.remove(entities[index], o); - Location l = new Location(o.x, o.y); + Location l = new Location(o.getX(), o.getY()); LinkedList ll = entities.get(l); ll.remove(o); if (ll.isEmpty()) { @@ -521,8 +583,8 @@ public class TileMap implements Iterable { public synchronized void moveEntity(Thing o, int x, int y) { if (inside(x, y)) { removeEntity(o); - o.x = x; - o.y = y; + o.setX(x); + o.setY(y); addEntity(o); } } @@ -536,7 +598,7 @@ public class TileMap implements Iterable { * @param y1 * @return */ - public Iterable range(int x0, int y0, int x1, int y1) { + public Iterable range(int x0, int y0, int x1, int y1) { return new MapIterable(x0, y0, x1, y1); } @@ -548,7 +610,7 @@ public class TileMap implements Iterable { * @param radius * @return */ - public Iterable range(int x, int y, int radius) { + public Iterable range(int x, int y, int radius) { return new MapIterable(x - radius, y - radius, x + radius + 1, y + radius + 1); } @@ -632,7 +694,7 @@ public class TileMap implements Iterable { return hash; } - private class MapIterable implements Iterable { + private class MapIterable implements Iterable { int x0, y0, x1, y1; @@ -644,7 +706,7 @@ public class TileMap implements Iterable { } @Override - public Iterator iterator() { + public Iterator iterator() { return new MapIterator(x0, y0, x1, y1); } } @@ -689,12 +751,12 @@ public class TileMap implements Iterable { } } - public Iterator getIterator(int x0, int y0, int x1, int y1) { + public Iterator getIterator(int x0, int y0, int x1, int y1) { return new MapIterator(x0, y0, x1, y1); } @Override - public Iterator iterator() { + public Iterator iterator() { return getIterator(0, 0, cols, rows); } @@ -731,7 +793,7 @@ public class TileMap implements Iterable { public String direction; } - private class MapIterator implements Iterator { + private class MapIterator implements Iterator { int x0, y0, x1, y1; int x, y; @@ -876,7 +938,7 @@ public class TileMap implements Iterable { public interface MoveListener { - public boolean canMoveto(MapData md); + public boolean canMoveto(TileMap.MapData md); } /** @@ -1078,46 +1140,4 @@ public class TileMap implements Iterable { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } } - - public static void main(String[] args) { - TileMap map = new TileMap("test", 16, 16); - - /* - for (MapData md : map.look(5, 5, 10, 3)) { - System.out.printf(" %d,%d\n", md.x, md.y); - } - for (MapData md : map.look(15, 15, 0, 0)) { - System.out.printf(" %d,%d\n", md.x, md.y); - } - for (MapData md : map.look(15, 0, 0, 15)) { - System.out.printf(" %d,%d\n", md.x, md.y); - }*/ - - - MoveListener l = new MoveListener() { - @Override - public boolean canMoveto(MapData md) { - //System.out.printf("can move %d,%d\n", md.x, md.y); - return md.tile == 0; - } - }; - System.out.println("no obstacles"); - for (MoveData md : map.move(0, 0, 10, 10, 0, l)) { - System.out.printf(" %d,%d %s\n", md.x, md.y, md.direction); - } - - // put an obstacle in the way - for (int x = 0; x < 11; x++) { - map.setTile(x, 5, 1); - } - System.out.println("line in the way"); - for (MoveData md : map.move(0, 0, 10, 10, SKIP_END, l)) { - System.out.printf(" %d,%d %s\n", md.x, md.y, md.direction); - } - System.out.println("line in the way to last"); - for (MoveData md : map.move(0, 0, 1, 1, 0, l)) { - System.out.printf(" %d,%d %s\n", md.x, md.y, md.direction); - } - - } } diff --git a/src/duskz.server/classes/duskz/io/tiled/Data.java b/src/duskz.common/classes/duskz/map/io/Data.java similarity index 99% rename from src/duskz.server/classes/duskz/io/tiled/Data.java rename to src/duskz.common/classes/duskz/map/io/Data.java index ae109f9..0e9ec86 100644 --- a/src/duskz.server/classes/duskz/io/tiled/Data.java +++ b/src/duskz.common/classes/duskz/map/io/Data.java @@ -6,7 +6,7 @@ // -package duskz.io.tiled; +package duskz.map.io; import jakarta.xml.bind.annotation.XmlAccessType; import jakarta.xml.bind.annotation.XmlAccessorType; diff --git a/src/duskz.server/classes/duskz/io/tiled/Image.java b/src/duskz.common/classes/duskz/map/io/Image.java similarity index 99% rename from src/duskz.server/classes/duskz/io/tiled/Image.java rename to src/duskz.common/classes/duskz/map/io/Image.java index e1d8c0e..3193568 100644 --- a/src/duskz.server/classes/duskz/io/tiled/Image.java +++ b/src/duskz.common/classes/duskz/map/io/Image.java @@ -6,7 +6,7 @@ // -package duskz.io.tiled; +package duskz.map.io; import jakarta.xml.bind.annotation.XmlAccessType; import jakarta.xml.bind.annotation.XmlAccessorType; diff --git a/src/duskz.server/classes/duskz/io/tiled/Layer.java b/src/duskz.common/classes/duskz/map/io/Layer.java similarity index 99% rename from src/duskz.server/classes/duskz/io/tiled/Layer.java rename to src/duskz.common/classes/duskz/map/io/Layer.java index a9cdb40..6232030 100644 --- a/src/duskz.server/classes/duskz/io/tiled/Layer.java +++ b/src/duskz.common/classes/duskz/map/io/Layer.java @@ -6,7 +6,7 @@ // -package duskz.io.tiled; +package duskz.map.io; import jakarta.xml.bind.annotation.XmlAccessType; import jakarta.xml.bind.annotation.XmlAccessorType; diff --git a/src/duskz.server/classes/duskz/io/tiled/Map.java b/src/duskz.common/classes/duskz/map/io/Map.java similarity index 99% rename from src/duskz.server/classes/duskz/io/tiled/Map.java rename to src/duskz.common/classes/duskz/map/io/Map.java index 54d661e..2af7b33 100644 --- a/src/duskz.server/classes/duskz/io/tiled/Map.java +++ b/src/duskz.common/classes/duskz/map/io/Map.java @@ -6,7 +6,7 @@ // -package duskz.io.tiled; +package duskz.map.io; import jakarta.xml.bind.annotation.XmlAccessType; import jakarta.xml.bind.annotation.XmlAccessorType; diff --git a/src/duskz.server/classes/duskz/io/tiled/Object.java b/src/duskz.common/classes/duskz/map/io/Object.java similarity index 99% rename from src/duskz.server/classes/duskz/io/tiled/Object.java rename to src/duskz.common/classes/duskz/map/io/Object.java index 2f65ae8..b073901 100644 --- a/src/duskz.server/classes/duskz/io/tiled/Object.java +++ b/src/duskz.common/classes/duskz/map/io/Object.java @@ -6,7 +6,7 @@ // -package duskz.io.tiled; +package duskz.map.io; import jakarta.xml.bind.annotation.XmlAccessType; import jakarta.xml.bind.annotation.XmlAccessorType; diff --git a/src/duskz.server/classes/duskz/io/tiled/ObjectFactory.java b/src/duskz.common/classes/duskz/map/io/ObjectFactory.java similarity index 99% rename from src/duskz.server/classes/duskz/io/tiled/ObjectFactory.java rename to src/duskz.common/classes/duskz/map/io/ObjectFactory.java index e330cf9..c87e46d 100644 --- a/src/duskz.server/classes/duskz/io/tiled/ObjectFactory.java +++ b/src/duskz.common/classes/duskz/map/io/ObjectFactory.java @@ -6,7 +6,7 @@ // -package duskz.io.tiled; +package duskz.map.io; import jakarta.xml.bind.annotation.XmlRegistry; diff --git a/src/duskz.server/classes/duskz/io/tiled/Objectgroup.java b/src/duskz.common/classes/duskz/map/io/Objectgroup.java similarity index 99% rename from src/duskz.server/classes/duskz/io/tiled/Objectgroup.java rename to src/duskz.common/classes/duskz/map/io/Objectgroup.java index 069e644..92c3796 100644 --- a/src/duskz.server/classes/duskz/io/tiled/Objectgroup.java +++ b/src/duskz.common/classes/duskz/map/io/Objectgroup.java @@ -6,7 +6,7 @@ // -package duskz.io.tiled; +package duskz.map.io; import jakarta.xml.bind.annotation.XmlAccessType; import jakarta.xml.bind.annotation.XmlAccessorType; diff --git a/src/duskz.server/classes/duskz/io/tiled/Properties.java b/src/duskz.common/classes/duskz/map/io/Properties.java similarity index 98% rename from src/duskz.server/classes/duskz/io/tiled/Properties.java rename to src/duskz.common/classes/duskz/map/io/Properties.java index a2bdbca..89c143f 100644 --- a/src/duskz.server/classes/duskz/io/tiled/Properties.java +++ b/src/duskz.common/classes/duskz/map/io/Properties.java @@ -6,7 +6,7 @@ // -package duskz.io.tiled; +package duskz.map.io; import jakarta.xml.bind.annotation.XmlAccessType; import jakarta.xml.bind.annotation.XmlAccessorType; diff --git a/src/duskz.server/classes/duskz/io/tiled/Property.java b/src/duskz.common/classes/duskz/map/io/Property.java similarity index 98% rename from src/duskz.server/classes/duskz/io/tiled/Property.java rename to src/duskz.common/classes/duskz/map/io/Property.java index 9d115ae..2e91983 100644 --- a/src/duskz.server/classes/duskz/io/tiled/Property.java +++ b/src/duskz.common/classes/duskz/map/io/Property.java @@ -6,7 +6,7 @@ // -package duskz.io.tiled; +package duskz.map.io; import jakarta.xml.bind.annotation.XmlAccessType; import jakarta.xml.bind.annotation.XmlAccessorType; diff --git a/src/duskz.server/classes/duskz/io/tiled/Tile.java b/src/duskz.common/classes/duskz/map/io/Tile.java similarity index 99% rename from src/duskz.server/classes/duskz/io/tiled/Tile.java rename to src/duskz.common/classes/duskz/map/io/Tile.java index 8124af5..8aaad06 100644 --- a/src/duskz.server/classes/duskz/io/tiled/Tile.java +++ b/src/duskz.common/classes/duskz/map/io/Tile.java @@ -6,7 +6,7 @@ // -package duskz.io.tiled; +package duskz.map.io; import jakarta.xml.bind.annotation.XmlAccessType; import jakarta.xml.bind.annotation.XmlAccessorType; diff --git a/src/duskz.server/classes/duskz/io/tiled/Tileset.java b/src/duskz.common/classes/duskz/map/io/Tileset.java similarity index 99% rename from src/duskz.server/classes/duskz/io/tiled/Tileset.java rename to src/duskz.common/classes/duskz/map/io/Tileset.java index 8451f9b..26313a4 100644 --- a/src/duskz.server/classes/duskz/io/tiled/Tileset.java +++ b/src/duskz.common/classes/duskz/map/io/Tileset.java @@ -6,7 +6,7 @@ // -package duskz.io.tiled; +package duskz.map.io; import jakarta.xml.bind.annotation.XmlAccessType; import jakarta.xml.bind.annotation.XmlAccessorType; diff --git a/src/duskz.server/classes/duskz/server/entityz/PropertyLoader.java b/src/duskz.common/classes/duskz/util/PropertyLoader.java similarity index 99% rename from src/duskz.server/classes/duskz/server/entityz/PropertyLoader.java rename to src/duskz.common/classes/duskz/util/PropertyLoader.java index 0216bc6..cc0ce5d 100644 --- a/src/duskz.server/classes/duskz/server/entityz/PropertyLoader.java +++ b/src/duskz.common/classes/duskz/util/PropertyLoader.java @@ -17,7 +17,7 @@ * along with DuskZ; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -package duskz.server.entityz; +package duskz.util; import java.io.BufferedReader; import java.io.File; diff --git a/src/duskz.common/classes/module-info.java b/src/duskz.common/classes/module-info.java index eba8bac..4684294 100644 --- a/src/duskz.common/classes/module-info.java +++ b/src/duskz.common/classes/module-info.java @@ -1,6 +1,11 @@ module duskz.common { + requires java.desktop; + requires java.logging; + requires jakarta.xml.bind; exports duskz.protocol; exports duskz.util; + exports duskz.map; + exports duskz.map.io; } diff --git a/src/duskz.editor/classes/au/notzed/tilez/io/Data.java b/src/duskz.editor/classes/au/notzed/tilez/io/Data.java deleted file mode 100644 index c23d4ba..0000000 --- a/src/duskz.editor/classes/au/notzed/tilez/io/Data.java +++ /dev/null @@ -1,111 +0,0 @@ -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2013.02.27 at 01:07:39 PM CST -// - - -package au.notzed.tilez.io; - -import jakarta.xml.bind.annotation.XmlAccessType; -import jakarta.xml.bind.annotation.XmlAccessorType; -import jakarta.xml.bind.annotation.XmlAttribute; -import jakarta.xml.bind.annotation.XmlRootElement; -import jakarta.xml.bind.annotation.XmlType; -import jakarta.xml.bind.annotation.XmlValue; -import jakarta.xml.bind.annotation.adapters.NormalizedStringAdapter; -import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter; - -/** - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", propOrder = { - "value" -}) -@XmlRootElement(name = "data") -public class Data { - - @XmlAttribute(name = "encoding") - @XmlJavaTypeAdapter(NormalizedStringAdapter.class) - protected String encoding; - @XmlAttribute(name = "compression") - @XmlJavaTypeAdapter(NormalizedStringAdapter.class) - protected String compression; - @XmlValue - protected String value; - - /** - * Gets the value of the encoding property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getEncoding() { - return encoding; - } - - /** - * Sets the value of the encoding property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setEncoding(String value) { - this.encoding = value; - } - - /** - * Gets the value of the compression property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getCompression() { - return compression; - } - - /** - * Sets the value of the compression property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setCompression(String value) { - this.compression = value; - } - - /** - * Gets the value of the value property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getvalue() { - return value; - } - - /** - * Sets the value of the value property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setvalue(String value) { - this.value = value; - } - -} diff --git a/src/duskz.editor/classes/au/notzed/tilez/io/Image.java b/src/duskz.editor/classes/au/notzed/tilez/io/Image.java deleted file mode 100644 index b597b25..0000000 --- a/src/duskz.editor/classes/au/notzed/tilez/io/Image.java +++ /dev/null @@ -1,161 +0,0 @@ -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2013.02.27 at 01:07:39 PM CST -// - - -package au.notzed.tilez.io; - -import jakarta.xml.bind.annotation.XmlAccessType; -import jakarta.xml.bind.annotation.XmlAccessorType; -import jakarta.xml.bind.annotation.XmlAttribute; -import jakarta.xml.bind.annotation.XmlRootElement; -import jakarta.xml.bind.annotation.XmlType; -import jakarta.xml.bind.annotation.adapters.NormalizedStringAdapter; -import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter; - -/** - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", propOrder = { - "data" -}) -@XmlRootElement(name = "image") -public class Image { - - @XmlAttribute(name = "format") - @XmlJavaTypeAdapter(NormalizedStringAdapter.class) - protected String format; - @XmlAttribute(name = "id") - protected String id; - @XmlAttribute(name = "source") - @XmlJavaTypeAdapter(NormalizedStringAdapter.class) - protected String source; - @XmlAttribute(name = "trans") - protected String trans; - protected Data data; - - /** - * Gets the value of the format property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getFormat() { - return format; - } - - /** - * Sets the value of the format property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setFormat(String value) { - this.format = value; - } - - /** - * Gets the value of the id property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getId() { - return id; - } - - /** - * Sets the value of the id property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setId(String value) { - this.id = value; - } - - /** - * Gets the value of the source property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getSource() { - return source; - } - - /** - * Sets the value of the source property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setSource(String value) { - this.source = value; - } - - /** - * Gets the value of the trans property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getTrans() { - return trans; - } - - /** - * Sets the value of the trans property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setTrans(String value) { - this.trans = value; - } - - /** - * Gets the value of the data property. - * - * @return - * possible object is - * {@link Data } - * - */ - public Data getData() { - return data; - } - - /** - * Sets the value of the data property. - * - * @param value - * allowed object is - * {@link Data } - * - */ - public void setData(Data value) { - this.data = value; - } - -} diff --git a/src/duskz.editor/classes/au/notzed/tilez/io/Layer.java b/src/duskz.editor/classes/au/notzed/tilez/io/Layer.java deleted file mode 100644 index 82d4e33..0000000 --- a/src/duskz.editor/classes/au/notzed/tilez/io/Layer.java +++ /dev/null @@ -1,266 +0,0 @@ -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2013.02.27 at 01:07:39 PM CST -// - - -package au.notzed.tilez.io; - -import jakarta.xml.bind.annotation.XmlAccessType; -import jakarta.xml.bind.annotation.XmlAccessorType; -import jakarta.xml.bind.annotation.XmlAttribute; -import jakarta.xml.bind.annotation.XmlElement; -import jakarta.xml.bind.annotation.XmlRootElement; -import jakarta.xml.bind.annotation.XmlType; -import jakarta.xml.bind.annotation.adapters.NormalizedStringAdapter; -import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter; - -/** - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", propOrder = { - "properties", - "data" -}) -@XmlRootElement(name = "layer") -public class Layer { - - @XmlAttribute(name = "name", required = true) - @XmlJavaTypeAdapter(NormalizedStringAdapter.class) - protected String name; - @XmlAttribute(name = "width", required = true) - protected int width; - @XmlAttribute(name = "height", required = true) - protected int height; - @XmlAttribute(name = "x") - protected int x; - @XmlAttribute(name = "y") - protected int y; - @XmlAttribute(name = "opacity") - protected float opacity; - @XmlAttribute(name = "visible") - protected int visible; - protected Properties properties; - @XmlElement(required = true) - protected Data data; - - /** - * Gets the value of the name property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getName() { - return name; - } - - /** - * Sets the value of the name property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setName(String value) { - this.name = value; - } - - /** - * Gets the value of the width property. - * - * @return - * possible object is - * {@link String } - * - */ - public int getWidth() { - return width; - } - - /** - * Sets the value of the width property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setWidth(int value) { - this.width = value; - } - - /** - * Gets the value of the height property. - * - * @return - * possible object is - * {@link String } - * - */ - public int getHeight() { - return height; - } - - /** - * Sets the value of the height property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setHeight(int value) { - this.height = value; - } - - /** - * Gets the value of the x property. - * - * @return - * possible object is - * {@link String } - * - */ - public int getX() { - return x; - } - - /** - * Sets the value of the x property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setX(int value) { - this.x = value; - } - - /** - * Gets the value of the y property. - * - * @return - * possible object is - * {@link String } - * - */ - public int getY() { - return y; - } - - /** - * Sets the value of the y property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setY(int value) { - this.y = value; - } - - /** - * Gets the value of the opacity property. - * - * @return - * possible object is - * {@link String } - * - */ - public float getOpacity() { - return opacity; - } - - /** - * Sets the value of the opacity property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setOpacity(float value) { - this.opacity = value; - } - - /** - * Gets the value of the visible property. - * - * @return - * possible object is - * {@link String } - * - */ - public int getVisible() { - return visible; - } - - /** - * Sets the value of the visible property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setVisible(int value) { - this.visible = value; - } - - /** - * Gets the value of the properties property. - * - * @return - * possible object is - * {@link Properties } - * - */ - public Properties getProperties() { - return properties; - } - - /** - * Sets the value of the properties property. - * - * @param value - * allowed object is - * {@link Properties } - * - */ - public void setProperties(Properties value) { - this.properties = value; - } - - /** - * Gets the value of the data property. - * - * @return - * possible object is - * {@link Data } - * - */ - public Data getData() { - return data; - } - - /** - * Sets the value of the data property. - * - * @param value - * allowed object is - * {@link Data } - * - */ - public void setData(Data value) { - this.data = value; - } - -} diff --git a/src/duskz.editor/classes/au/notzed/tilez/io/Map.java b/src/duskz.editor/classes/au/notzed/tilez/io/Map.java deleted file mode 100644 index a60366f..0000000 --- a/src/duskz.editor/classes/au/notzed/tilez/io/Map.java +++ /dev/null @@ -1,366 +0,0 @@ -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2013.02.27 at 01:07:39 PM CST -// - - -package au.notzed.tilez.io; - -import jakarta.xml.bind.annotation.XmlAccessType; -import jakarta.xml.bind.annotation.XmlAccessorType; -import jakarta.xml.bind.annotation.XmlAttribute; -import jakarta.xml.bind.annotation.XmlElement; -import jakarta.xml.bind.annotation.XmlElements; -import jakarta.xml.bind.annotation.XmlRootElement; -import jakarta.xml.bind.annotation.XmlType; -import jakarta.xml.bind.annotation.adapters.CollapsedStringAdapter; -import jakarta.xml.bind.annotation.adapters.NormalizedStringAdapter; -import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter; -import java.util.ArrayList; -import java.util.List; - -/** - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", propOrder = { - "properties", - "tileset", - "layerOrObjectgroup" -}) -@XmlRootElement(name = "map") -public class Map { - - @XmlAttribute(name = "xmlns") - @XmlJavaTypeAdapter(NormalizedStringAdapter.class) - protected String xmlns; - @XmlAttribute(name = "xmlns:xsi") - @XmlJavaTypeAdapter(NormalizedStringAdapter.class) - protected String xmlnsXsi; - @XmlAttribute(name = "xsi:schemaLocation") - @XmlJavaTypeAdapter(NormalizedStringAdapter.class) - protected String xsiSchemaLocation; - @XmlAttribute(name = "version", required = true) - @XmlJavaTypeAdapter(NormalizedStringAdapter.class) - protected String version; - @XmlAttribute(name = "orientation", required = true) - @XmlJavaTypeAdapter(CollapsedStringAdapter.class) - protected String orientation; - @XmlAttribute(name = "width", required = true) - protected int width; - @XmlAttribute(name = "height", required = true) - protected int height; - @XmlAttribute(name = "tilewidth", required = true) - protected int tilewidth; - @XmlAttribute(name = "tileheight", required = true) - protected int tileheight; - protected Properties properties; - protected List tileset; - @XmlElements({ - @XmlElement(name = "layer", type = Layer.class), - @XmlElement(name = "objectgroup", type = Objectgroup.class) - }) - protected List layerOrObjectgroup; - - /** - * Gets the value of the xmlns property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getXmlns() { - return xmlns; - } - - /** - * Sets the value of the xmlns property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setXmlns(String value) { - this.xmlns = value; - } - - /** - * Gets the value of the xmlnsXsi property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getXmlnsXsi() { - return xmlnsXsi; - } - - /** - * Sets the value of the xmlnsXsi property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setXmlnsXsi(String value) { - this.xmlnsXsi = value; - } - - /** - * Gets the value of the xsiSchemaLocation property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getXsiSchemaLocation() { - return xsiSchemaLocation; - } - - /** - * Sets the value of the xsiSchemaLocation property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setXsiSchemaLocation(String value) { - this.xsiSchemaLocation = value; - } - - /** - * Gets the value of the version property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getVersion() { - return version; - } - - /** - * Sets the value of the version property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setVersion(String value) { - this.version = value; - } - - /** - * Gets the value of the orientation property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getOrientation() { - return orientation; - } - - /** - * Sets the value of the orientation property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setOrientation(String value) { - this.orientation = value; - } - - /** - * Gets the value of the width property. - * - * @return - * possible object is - * {@link String } - * - */ - public int getWidth() { - return width; - } - - /** - * Sets the value of the width property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setWidth(int value) { - this.width = value; - } - - /** - * Gets the value of the height property. - * - * @return - * possible object is - * {@link String } - * - */ - public int getHeight() { - return height; - } - - /** - * Sets the value of the height property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setHeight(int value) { - this.height = value; - } - - /** - * Gets the value of the tilewidth property. - * - * @return - * possible object is - * {@link String } - * - */ - public int getTilewidth() { - return tilewidth; - } - - /** - * Sets the value of the tilewidth property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setTilewidth(int value) { - this.tilewidth = value; - } - - /** - * Gets the value of the tileheight property. - * - * @return - * possible object is - * {@link String } - * - */ - public int getTileheight() { - return tileheight; - } - - /** - * Sets the value of the tileheight property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setTileheight(int value) { - this.tileheight = value; - } - - /** - * Gets the value of the properties property. - * - * @return - * possible object is - * {@link Properties } - * - */ - public Properties getProperties() { - return properties; - } - - /** - * Sets the value of the properties property. - * - * @param value - * allowed object is - * {@link Properties } - * - */ - public void setProperties(Properties value) { - this.properties = value; - } - - /** - * Gets the value of the tileset property. - * - *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the tileset property. - * - *

- * For example, to add a new item, do as follows: - *

-     *    getTileset().add(newItem);
-     * 
- * - * - *

- * Objects of the following type(s) are allowed in the list - * {@link Tileset } - * - * - */ - public List getTileset() { - if (tileset == null) { - tileset = new ArrayList(); - } - return this.tileset; - } - - /** - * Gets the value of the layerOrObjectgroup property. - * - *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the layerOrObjectgroup property. - * - *

- * For example, to add a new item, do as follows: - *

-     *    getLayerOrObjectgroup().add(newItem);
-     * 
- * - * - *

- * Objects of the following type(s) are allowed in the list - * {@link Layer } - * {@link Objectgroup } - * - * - */ - public List getLayerOrObjectgroup() { - if (layerOrObjectgroup == null) { - layerOrObjectgroup = new ArrayList(); - } - return this.layerOrObjectgroup; - } - -} diff --git a/src/duskz.editor/classes/au/notzed/tilez/io/Object.java b/src/duskz.editor/classes/au/notzed/tilez/io/Object.java deleted file mode 100644 index f05d376..0000000 --- a/src/duskz.editor/classes/au/notzed/tilez/io/Object.java +++ /dev/null @@ -1,240 +0,0 @@ -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2013.02.27 at 01:07:39 PM CST -// - - -package au.notzed.tilez.io; - -import jakarta.xml.bind.annotation.XmlAccessType; -import jakarta.xml.bind.annotation.XmlAccessorType; -import jakarta.xml.bind.annotation.XmlAttribute; -import jakarta.xml.bind.annotation.XmlRootElement; -import jakarta.xml.bind.annotation.XmlType; -import jakarta.xml.bind.annotation.adapters.NormalizedStringAdapter; -import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter; - - -/** - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", propOrder = { - "properties", - "image" -}) -@XmlRootElement(name = "object") -public class Object { - - @XmlAttribute(name = "name", required = true) - @XmlJavaTypeAdapter(NormalizedStringAdapter.class) - protected String name; - @XmlAttribute(name = "type", required = true) - @XmlJavaTypeAdapter(NormalizedStringAdapter.class) - protected String type; - @XmlAttribute(name = "x", required = true) - protected int x; - @XmlAttribute(name = "y", required = true) - protected int y; - @XmlAttribute(name = "width") - protected int width; - @XmlAttribute(name = "height") - protected int height; - protected Properties properties; - protected Image image; - - /** - * Gets the value of the name property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getName() { - return name; - } - - /** - * Sets the value of the name property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setName(String value) { - this.name = value; - } - - /** - * Gets the value of the type property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getType() { - return type; - } - - /** - * Sets the value of the type property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setType(String value) { - this.type = value; - } - - /** - * Gets the value of the x property. - * - * @return - * possible object is - * {@link String } - * - */ - public int getX() { - return x; - } - - /** - * Sets the value of the x property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setX(int value) { - this.x = value; - } - - /** - * Gets the value of the y property. - * - * @return - * possible object is - * {@link String } - * - */ - public int getY() { - return y; - } - - /** - * Sets the value of the y property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setY(int value) { - this.y = value; - } - - /** - * Gets the value of the width property. - * - * @return - * possible object is - * {@link String } - * - */ - public int getWidth() { - return width; - } - - /** - * Sets the value of the width property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setWidth(int value) { - this.width = value; - } - - /** - * Gets the value of the height property. - * - * @return - * possible object is - * {@link String } - * - */ - public int getHeight() { - return height; - } - - /** - * Sets the value of the height property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setHeight(int value) { - this.height = value; - } - - /** - * Gets the value of the properties property. - * - * @return - * possible object is - * {@link Properties } - * - */ - public Properties getProperties() { - return properties; - } - - /** - * Sets the value of the properties property. - * - * @param value - * allowed object is - * {@link Properties } - * - */ - public void setProperties(Properties value) { - this.properties = value; - } - - /** - * Gets the value of the image property. - * - * @return - * possible object is - * {@link Image } - * - */ - public Image getImage() { - return image; - } - - /** - * Sets the value of the image property. - * - * @param value - * allowed object is - * {@link Image } - * - */ - public void setImage(Image value) { - this.image = value; - } - -} diff --git a/src/duskz.editor/classes/au/notzed/tilez/io/ObjectFactory.java b/src/duskz.editor/classes/au/notzed/tilez/io/ObjectFactory.java deleted file mode 100644 index a9ce8ef..0000000 --- a/src/duskz.editor/classes/au/notzed/tilez/io/ObjectFactory.java +++ /dev/null @@ -1,119 +0,0 @@ -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2013.02.27 at 01:07:39 PM CST -// - - -package au.notzed.tilez.io; - -import jakarta.xml.bind.annotation.XmlRegistry; - - -/** - * This object contains factory methods for each - * Java content interface and Java element interface - * generated in the generated package. - *

An ObjectFactory allows you to programatically - * construct new instances of the Java representation - * for XML content. The Java representation of XML - * content can consist of schema derived interfaces - * and classes representing the binding of schema - * type definitions, element declarations and model - * groups. Factory methods for each of these are - * provided in this class. - * - */ -@XmlRegistry -public class ObjectFactory { - - - /** - * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: generated - * - */ - public ObjectFactory() { - } - - /** - * Create an instance of {@link Tileset } - * - */ - public Tileset createTileset() { - return new Tileset(); - } - - /** - * Create an instance of {@link Image } - * - */ - public Image createImage() { - return new Image(); - } - - /** - * Create an instance of {@link Tile } - * - */ - public Tile createTile() { - return new Tile(); - } - - /** - * Create an instance of {@link Properties } - * - */ - public Properties createProperties() { - return new Properties(); - } - - /** - * Create an instance of {@link Objectgroup } - * - */ - public Objectgroup createObjectgroup() { - return new Objectgroup(); - } - - /** - * Create an instance of {@link Object } - * - */ - public Object createObject() { - return new Object(); - } - - /** - * Create an instance of {@link Data } - * - */ - public Data createData() { - return new Data(); - } - - /** - * Create an instance of {@link Map } - * - */ - public Map createMap() { - return new Map(); - } - - /** - * Create an instance of {@link Layer } - * - */ - public Layer createLayer() { - return new Layer(); - } - - /** - * Create an instance of {@link Property } - * - */ - public Property createProperty() { - return new Property(); - } - -} diff --git a/src/duskz.editor/classes/au/notzed/tilez/io/Objectgroup.java b/src/duskz.editor/classes/au/notzed/tilez/io/Objectgroup.java deleted file mode 100644 index 452f77a..0000000 --- a/src/duskz.editor/classes/au/notzed/tilez/io/Objectgroup.java +++ /dev/null @@ -1,193 +0,0 @@ -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2013.02.27 at 01:07:39 PM CST -// - - -package au.notzed.tilez.io; - -import jakarta.xml.bind.annotation.XmlAccessType; -import jakarta.xml.bind.annotation.XmlAccessorType; -import jakarta.xml.bind.annotation.XmlAttribute; -import jakarta.xml.bind.annotation.XmlRootElement; -import jakarta.xml.bind.annotation.XmlType; -import jakarta.xml.bind.annotation.adapters.NormalizedStringAdapter; -import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter; -import java.util.ArrayList; -import java.util.List; - -/** - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", propOrder = { - "object" -}) -@XmlRootElement(name = "objectgroup") -public class Objectgroup { - - @XmlAttribute(name = "name", required = true) - @XmlJavaTypeAdapter(NormalizedStringAdapter.class) - protected String name; - @XmlAttribute(name = "width") - protected int width; - @XmlAttribute(name = "height") - protected int height; - @XmlAttribute(name = "x") - protected int x; - @XmlAttribute(name = "y") - protected int y; - protected List object; - - /** - * Gets the value of the name property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getName() { - return name; - } - - /** - * Sets the value of the name property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setName(String value) { - this.name = value; - } - - /** - * Gets the value of the width property. - * - * @return - * possible object is - * {@link String } - * - */ - public int getWidth() { - return width; - } - - /** - * Sets the value of the width property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setWidth(int value) { - this.width = value; - } - - /** - * Gets the value of the height property. - * - * @return - * possible object is - * {@link String } - * - */ - public int getHeight() { - return height; - } - - /** - * Sets the value of the height property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setHeight(int value) { - this.height = value; - } - - /** - * Gets the value of the x property. - * - * @return - * possible object is - * {@link String } - * - */ - public int getX() { - return x; - } - - /** - * Sets the value of the x property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setX(int value) { - this.x = value; - } - - /** - * Gets the value of the y property. - * - * @return - * possible object is - * {@link String } - * - */ - public int getY() { - return y; - } - - /** - * Sets the value of the y property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setY(int value) { - this.y = value; - } - - /** - * Gets the value of the object property. - * - *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the object property. - * - *

- * For example, to add a new item, do as follows: - *

-     *    getObject().add(newItem);
-     * 
- * - * - *

- * Objects of the following type(s) are allowed in the list - * {@link Object } - * - * - */ - public List getObject() { - if (object == null) { - object = new ArrayList(); - } - return this.object; - } - -} diff --git a/src/duskz.editor/classes/au/notzed/tilez/io/Properties.java b/src/duskz.editor/classes/au/notzed/tilez/io/Properties.java deleted file mode 100644 index e43733f..0000000 --- a/src/duskz.editor/classes/au/notzed/tilez/io/Properties.java +++ /dev/null @@ -1,60 +0,0 @@ -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2013.02.27 at 01:07:39 PM CST -// - - -package au.notzed.tilez.io; - -import jakarta.xml.bind.annotation.XmlAccessType; -import jakarta.xml.bind.annotation.XmlAccessorType; -import jakarta.xml.bind.annotation.XmlRootElement; -import jakarta.xml.bind.annotation.XmlType; -import java.util.ArrayList; -import java.util.List; - - -/** - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", propOrder = { - "property" -}) -@XmlRootElement(name = "properties") -public class Properties { - - protected List property; - - /** - * Gets the value of the property property. - * - *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the property property. - * - *

- * For example, to add a new item, do as follows: - *

-     *    getProperty().add(newItem);
-     * 
- * - * - *

- * Objects of the following type(s) are allowed in the list - * {@link Property } - * - * - */ - public List getProperty() { - if (property == null) { - property = new ArrayList(); - } - return this.property; - } - -} diff --git a/src/duskz.editor/classes/au/notzed/tilez/io/Property.java b/src/duskz.editor/classes/au/notzed/tilez/io/Property.java deleted file mode 100644 index 752e583..0000000 --- a/src/duskz.editor/classes/au/notzed/tilez/io/Property.java +++ /dev/null @@ -1,83 +0,0 @@ -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2013.02.27 at 01:07:39 PM CST -// - - -package au.notzed.tilez.io; - -import jakarta.xml.bind.annotation.XmlAccessType; -import jakarta.xml.bind.annotation.XmlAccessorType; -import jakarta.xml.bind.annotation.XmlAttribute; -import jakarta.xml.bind.annotation.XmlRootElement; -import jakarta.xml.bind.annotation.XmlType; -import jakarta.xml.bind.annotation.adapters.NormalizedStringAdapter; -import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter; - - -/** - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "") -@XmlRootElement(name = "property") -public class Property { - - @XmlAttribute(name = "name", required = true) - @XmlJavaTypeAdapter(NormalizedStringAdapter.class) - protected String name; - @XmlAttribute(name = "value", required = true) - @XmlJavaTypeAdapter(NormalizedStringAdapter.class) - protected String value; - - /** - * Gets the value of the name property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getName() { - return name; - } - - /** - * Sets the value of the name property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setName(String value) { - this.name = value; - } - - /** - * Gets the value of the value property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getValue() { - return value; - } - - /** - * Sets the value of the value property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setValue(String value) { - this.value = value; - } - -} diff --git a/src/duskz.editor/classes/au/notzed/tilez/io/Tile.java b/src/duskz.editor/classes/au/notzed/tilez/io/Tile.java deleted file mode 100644 index 151c6b3..0000000 --- a/src/duskz.editor/classes/au/notzed/tilez/io/Tile.java +++ /dev/null @@ -1,131 +0,0 @@ -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2013.02.27 at 01:07:39 PM CST -// - - -package au.notzed.tilez.io; - -import jakarta.xml.bind.annotation.XmlAccessType; -import jakarta.xml.bind.annotation.XmlAccessorType; -import jakarta.xml.bind.annotation.XmlAttribute; -import jakarta.xml.bind.annotation.XmlRootElement; -import jakarta.xml.bind.annotation.XmlType; - -/** - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", propOrder = { - "properties", - "image" -}) -@XmlRootElement(name = "tile") -public class Tile { - - @XmlAttribute(name = "id") - protected int id; - @XmlAttribute(name = "gid") - protected String gid; - protected Properties properties; - protected Image image; - - /** - * Gets the value of the id property. - * - * @return - * possible object is - * {@link String } - * - */ - public int getId() { - return id; - } - - /** - * Sets the value of the id property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setId(int value) { - this.id = value; - } - - /** - * Gets the value of the gid property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getGid() { - return gid; - } - - /** - * Sets the value of the gid property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setGid(String value) { - this.gid = value; - } - - /** - * Gets the value of the properties property. - * - * @return - * possible object is - * {@link Properties } - * - */ - public Properties getProperties() { - return properties; - } - - /** - * Sets the value of the properties property. - * - * @param value - * allowed object is - * {@link Properties } - * - */ - public void setProperties(Properties value) { - this.properties = value; - } - - /** - * Gets the value of the image property. - * - * @return - * possible object is - * {@link Image } - * - */ - public Image getImage() { - return image; - } - - /** - * Sets the value of the image property. - * - * @param value - * allowed object is - * {@link Image } - * - */ - public void setImage(Image value) { - this.image = value; - } - -} diff --git a/src/duskz.editor/classes/au/notzed/tilez/io/Tileset.java b/src/duskz.editor/classes/au/notzed/tilez/io/Tileset.java deleted file mode 100644 index 6a5bf9e..0000000 --- a/src/duskz.editor/classes/au/notzed/tilez/io/Tileset.java +++ /dev/null @@ -1,279 +0,0 @@ -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2013.02.27 at 01:07:39 PM CST -// - - -package au.notzed.tilez.io; - -import jakarta.xml.bind.annotation.XmlAccessType; -import jakarta.xml.bind.annotation.XmlAccessorType; -import jakarta.xml.bind.annotation.XmlAttribute; -import jakarta.xml.bind.annotation.XmlRootElement; -import jakarta.xml.bind.annotation.XmlType; -import jakarta.xml.bind.annotation.adapters.NormalizedStringAdapter; -import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter; -import java.util.ArrayList; -import java.util.List; - - -/** - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", propOrder = { - "image", - "tile" -}) -@XmlRootElement(name = "tileset") -public class Tileset { - - @XmlAttribute(name = "name") - @XmlJavaTypeAdapter(NormalizedStringAdapter.class) - protected String name; - @XmlAttribute(name = "firstgid", required = true) - protected int firstgid; - @XmlAttribute(name = "source") - @XmlJavaTypeAdapter(NormalizedStringAdapter.class) - protected String source; - @XmlAttribute(name = "tilewidth") - protected int tilewidth; - @XmlAttribute(name = "tileheight") - protected int tileheight; - @XmlAttribute(name = "spacing") - protected int spacing; - @XmlAttribute(name = "margin") - @XmlJavaTypeAdapter(NormalizedStringAdapter.class) - protected String margin; - protected List image; - protected List tile; - - /** - * Gets the value of the name property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getName() { - return name; - } - - /** - * Sets the value of the name property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setName(String value) { - this.name = value; - } - - /** - * Gets the value of the firstgid property. - * - * @return - * possible object is - * {@link String } - * - */ - public int getFirstgid() { - return firstgid; - } - - /** - * Sets the value of the firstgid property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setFirstgid(int value) { - this.firstgid = value; - } - - /** - * Gets the value of the source property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getSource() { - return source; - } - - /** - * Sets the value of the source property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setSource(String value) { - this.source = value; - } - - /** - * Gets the value of the tilewidth property. - * - * @return - * possible object is - * {@link String } - * - */ - public int getTilewidth() { - return tilewidth; - } - - /** - * Sets the value of the tilewidth property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setTilewidth(int value) { - this.tilewidth = value; - } - - /** - * Gets the value of the tileheight property. - * - * @return - * possible object is - * {@link String } - * - */ - public int getTileheight() { - return tileheight; - } - - /** - * Sets the value of the tileheight property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setTileheight(int value) { - this.tileheight = value; - } - - /** - * Gets the value of the spacing property. - * - * @return - * possible object is - * {@link String } - * - */ - public int getSpacing() { - return spacing; - } - - /** - * Sets the value of the spacing property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setSpacing(int value) { - this.spacing = value; - } - - /** - * Gets the value of the margin property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getMargin() { - return margin; - } - - /** - * Sets the value of the margin property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setMargin(String value) { - this.margin = value; - } - - /** - * Gets the value of the image property. - * - *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the image property. - * - *

- * For example, to add a new item, do as follows: - *

-     *    getImage().add(newItem);
-     * 
- * - * - *

- * Objects of the following type(s) are allowed in the list - * {@link Image } - * - * - */ - public List getImage() { - if (image == null) { - image = new ArrayList(); - } - return this.image; - } - - /** - * Gets the value of the tile property. - * - *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the tile property. - * - *

- * For example, to add a new item, do as follows: - *

-     *    getTile().add(newItem);
-     * 
- * - * - *

- * Objects of the following type(s) are allowed in the list - * {@link Tile } - * - * - */ - public List getTile() { - if (tile == null) { - tile = new ArrayList(); - } - return this.tile; - } - -} diff --git a/src/duskz.server/classes/duskz/server/entity/TileMap.java b/src/duskz.server/classes/duskz/server/entity/TileMap.java index 0e15b35..f595112 100644 --- a/src/duskz.server/classes/duskz/server/entity/TileMap.java +++ b/src/duskz.server/classes/duskz/server/entity/TileMap.java @@ -209,7 +209,7 @@ public class TileMap implements Iterable { System.out.printf(" size: %dx%d\n", cols, rows); System.out.printf(" groundLayer: %d\n", groundLayer); System.out.printf(" layerCount: %d\n", layerCount); - + map = new TileMap(path.getName(), cols, rows); map.groundLayer = groundLayer; diff --git a/src/duskz.server/classes/duskz/server/entityz/Active.java b/src/duskz.server/classes/duskz/server/entityz/Active.java index e3e8af1..698dd95 100644 --- a/src/duskz.server/classes/duskz/server/entityz/Active.java +++ b/src/duskz.server/classes/duskz/server/entityz/Active.java @@ -21,6 +21,8 @@ // fixme copyrihgts package duskz.server.entityz; +import duskz.map.Location; +import duskz.map.TileMap; import duskz.protocol.DuskMessage; import duskz.protocol.Wearing; import java.io.BufferedWriter; @@ -349,7 +351,7 @@ public abstract class Active extends Thing { public void addStat(int key, int value) { setStat(key, stats[key] + value); } - + public int getBonus(int key) { return bonus[key]; } @@ -727,7 +729,7 @@ public abstract class Active extends Thing { public void localisedChat(String msg) { //log.printMessage(Log.ALWAYS, inMessage); - for (TileMap.MapData md : map.range(x, y, game.viewRange)) { + for (TileMap.MapData md : map.range(x, y, game.viewRange)) { for (Thing o : md.entities) { if (o.getType() == Thing.TYPE_PLAYER) { Player p = (Player) o; @@ -926,7 +928,7 @@ public abstract class Active extends Thing { } // search by name - for (TileMap.MapData md : map.range(x, y, game.viewRange)) { + for (TileMap.MapData md : map.range(x, y, game.viewRange)) { for (Thing t : md.entities) { if (t.name.equalsIgnoreCase(name)) { boolean see = true; @@ -1413,9 +1415,9 @@ public abstract class Active extends Thing { /* * * So all this 'get the player object to implemeent the commands' seemed * like a good idea, but the code will bloat. - * + * * having it reusable is useful for scripts though. - * + * * Perhaps it shoudl be put into antoher class for reusability stake. */ public void fleeCommand() { diff --git a/src/duskz.server/classes/duskz/server/entityz/Converter.java b/src/duskz.server/classes/duskz/server/entityz/Converter.java index e367e40..be013a9 100644 --- a/src/duskz.server/classes/duskz/server/entityz/Converter.java +++ b/src/duskz.server/classes/duskz/server/entityz/Converter.java @@ -20,6 +20,7 @@ */ package duskz.server.entityz; +import duskz.map.TileMap; import duskz.protocol.Wearing; import java.io.BufferedReader; import java.io.BufferedWriter; @@ -218,7 +219,7 @@ public class Converter { case "givegp": dst.add("givegold", in.readLine()); break; - // nice: mob format is different ... + // nice: mob format is different ... case "wield": case "arms": case "legs": @@ -505,7 +506,7 @@ public class Converter { out.append("="); out.append(item.name); out.append('\n'); - + item.writeProperties(out); out.append("=end"); diff --git a/src/duskz.server/classes/duskz/server/entityz/Faction.java b/src/duskz.server/classes/duskz/server/entityz/Faction.java index e00a56c..34dbcef 100644 --- a/src/duskz.server/classes/duskz/server/entityz/Faction.java +++ b/src/duskz.server/classes/duskz/server/entityz/Faction.java @@ -29,6 +29,7 @@ */ package duskz.server.entityz; +import duskz.map.TileMap; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; @@ -141,7 +142,7 @@ public class Faction { Active enemy = null; double enemyrelation = 0; boolean visiblePlayer = false; - for (TileMap.MapData md : mob.map.range(mob.x, mob.y, game.viewRange - 1)) { + for (TileMap.MapData md : mob.map.range(mob.x, mob.y, game.viewRange - 1)) { for (Thing o : md.entities) { if (o.getType() == Thing.TYPE_MOBILE || o.getType() == Thing.TYPE_PLAYER) { Active lt = (Active) o; diff --git a/src/duskz.server/classes/duskz/server/entityz/Game.java b/src/duskz.server/classes/duskz/server/entityz/Game.java index d7860aa..cef2ab3 100644 --- a/src/duskz.server/classes/duskz/server/entityz/Game.java +++ b/src/duskz.server/classes/duskz/server/entityz/Game.java @@ -20,6 +20,9 @@ */ package duskz.server.entityz; +import duskz.map.Location; +import duskz.map.TileMap; +import duskz.util.PropertyLoader; import duskz.server.BlockedIPException; import java.io.BufferedReader; import java.io.BufferedWriter; @@ -112,7 +115,7 @@ public class Game { // All actives in game HashMap actives = new HashMap<>(); // - private final HashMap maps = new HashMap<>(); + private final HashMap> maps = new HashMap<>(); // private ArrayList battles = new ArrayList<>(); @@ -275,7 +278,7 @@ public class Game { scriptManager.start(); - // We're ready, time for 'onstart' script + // We're ready, time for 'onstart' script runScript(confDir, "onStart", "game", this); } @@ -301,7 +304,7 @@ public class Game { props.saveState(this); } - public TileMap getMap(String name) { + public TileMap getMap(String name) { return maps.get(name); } diff --git a/src/duskz.server/classes/duskz/server/entityz/Mobile.java b/src/duskz.server/classes/duskz/server/entityz/Mobile.java index 1176024..25b3101 100644 --- a/src/duskz.server/classes/duskz/server/entityz/Mobile.java +++ b/src/duskz.server/classes/duskz/server/entityz/Mobile.java @@ -20,6 +20,7 @@ */ package duskz.server.entityz; +import duskz.map.TileMap; import duskz.protocol.DuskMessage; import java.io.BufferedWriter; import java.io.IOException; @@ -52,7 +53,7 @@ public class Mobile extends Active { super(game); } - // onBattle script + // onBattle script @Override public int getType() { return TYPE_MOBILE; @@ -291,7 +292,7 @@ public class Mobile extends Active { boolean seePlayer = false; - for (TileMap.MapData md : map.range(x, y, game.viewRange)) { + for (TileMap.MapData md : map.range(x, y, game.viewRange)) { if (!md.entities.isEmpty() && canSee(md.x, md.y)) { for (Thing thing : md.entities) { if (thing instanceof Player) diff --git a/src/duskz.server/classes/duskz/server/entityz/PlayerCommands.java b/src/duskz.server/classes/duskz/server/entityz/PlayerCommands.java index 0184bf5..3551614 100644 --- a/src/duskz.server/classes/duskz/server/entityz/PlayerCommands.java +++ b/src/duskz.server/classes/duskz/server/entityz/PlayerCommands.java @@ -19,6 +19,9 @@ */ package duskz.server.entityz; +import duskz.map.Location; +import duskz.map.TileMap; + /** * This is a wrapper for the player object, which is passed to scripts. * @@ -67,7 +70,7 @@ public class PlayerCommands { public int getInt(String name) { return p.variables.getInteger(name, 0); } - + /** * Jump to a location * @param mapName @@ -76,11 +79,11 @@ public class PlayerCommands { */ public boolean jumpTo(String mapName, String mapAlias) { System.out.println("script: jumpto(" + mapName + ", " + mapAlias + ")"); - TileMap map = game.getMap(mapName); - + TileMap map = game.getMap(mapName); + if (map != null) { Location l = map.locationForAlias(mapAlias); - + if (l != null) { return p.jumpTo(map, l.x, l.y); } diff --git a/src/duskz.server/classes/duskz/server/entityz/PlayerState.java b/src/duskz.server/classes/duskz/server/entityz/PlayerState.java index ed0e04e..f410cfe 100644 --- a/src/duskz.server/classes/duskz/server/entityz/PlayerState.java +++ b/src/duskz.server/classes/duskz/server/entityz/PlayerState.java @@ -20,6 +20,7 @@ */ package duskz.server.entityz; +import duskz.map.TileMap; import duskz.protocol.DuskMessage; import duskz.protocol.DuskProtocol; import static duskz.protocol.DuskProtocol.FIELD_ENTITY_FLAGS; @@ -81,7 +82,7 @@ public class PlayerState implements DuskProtocol { /** * Last updated location */ - TileMap map; + TileMap map; int x; int y; /** @@ -225,7 +226,7 @@ public class PlayerState implements DuskProtocol { // FIXME: I think this is missing something here, i.e. some sort of object visibility check - for (TileMap.MapData md : map.range(x, y, player.game.viewRange)) { + for (TileMap.MapData md : map.range(x, y, player.game.viewRange)) { if (!md.entities.isEmpty() && player.canSee(md.x, md.y)) { for (Thing thing : md.entities) { VisibleThing here = left.remove(thing.ID); diff --git a/src/duskz.server/classes/duskz/server/entityz/Race.java b/src/duskz.server/classes/duskz/server/entityz/Race.java index e4984ef..83c2368 100644 --- a/src/duskz.server/classes/duskz/server/entityz/Race.java +++ b/src/duskz.server/classes/duskz/server/entityz/Race.java @@ -20,6 +20,7 @@ */ package duskz.server.entityz; +import duskz.util.PropertyLoader; import static duskz.server.entityz.Active.STAT_CON; import static duskz.server.entityz.Active.STAT_DEX; import static duskz.server.entityz.Active.STAT_HP; @@ -29,7 +30,7 @@ import static duskz.server.entityz.Active.STAT_MP; import static duskz.server.entityz.Active.STAT_MPMAX; import static duskz.server.entityz.Active.STAT_STR; import static duskz.server.entityz.Active.STAT_WIS; -import duskz.server.entityz.PropertyLoader.PropertyEntry; +import duskz.util.PropertyLoader.PropertyEntry; import java.io.File; import java.io.IOException; diff --git a/src/duskz.server/classes/duskz/server/entityz/Thing.java b/src/duskz.server/classes/duskz/server/entityz/Thing.java index 0a891af..ab1d63c 100644 --- a/src/duskz.server/classes/duskz/server/entityz/Thing.java +++ b/src/duskz.server/classes/duskz/server/entityz/Thing.java @@ -20,9 +20,12 @@ */ package duskz.server.entityz; +import duskz.map.Locatable; +import duskz.map.TileMap; +import duskz.util.PropertyLoader; import duskz.protocol.DuskMessage; import duskz.protocol.EntityUpdateMessage; -import duskz.server.entityz.PropertyLoader.PropertyEntry; +import duskz.util.PropertyLoader.PropertyEntry; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; @@ -39,7 +42,7 @@ import java.util.Comparator; * * @author Michael Zucchi */ -public abstract class Thing implements Cloneable { +public abstract class Thing implements Cloneable, Locatable { /** * Every non-abstract sub-class of thing needs a unique @@ -85,7 +88,7 @@ public abstract class Thing implements Cloneable { * /** * Map object belongs to */ - public TileMap map; + public TileMap map; /** * Location on map */ @@ -115,7 +118,7 @@ public abstract class Thing implements Cloneable { } /* - * + * */ @Override public boolean equals(Object obj) { @@ -132,6 +135,26 @@ public abstract class Thing implements Cloneable { return hash; } + @Override + public int getX() { + return x; + } + + @Override + public int getY() { + return y; + } + + @Override + public void setX(int x) { + this.x = x; + } + + @Override + public void setY(int y) { + this.y = y; + } + public int getImage() { return image; } @@ -192,13 +215,13 @@ public abstract class Thing implements Cloneable { this.map = game.getMap(value); break; case "x": - this.x = Integer.valueOf(value); + this.x = Integer.parseInt(value); break; case "y": - this.y = Integer.valueOf(value); + this.y = Integer.parseInt(value); break; case "image": - this.image = Integer.valueOf(value); + this.image = Integer.parseInt(value); break; default: //System.out.println("unknown property: " + name + " on class " + getClass().getSimpleName()); diff --git a/src/duskz.server/classes/module-info.java b/src/duskz.server/classes/module-info.java index 8eeade9..979f666 100644 --- a/src/duskz.server/classes/module-info.java +++ b/src/duskz.server/classes/module-info.java @@ -23,5 +23,4 @@ module duskz.server { requires java.desktop; requires java.logging; - requires jakarta.xml.bind; } diff --git a/src/duskz.editor/classes/au/notzed/tilez/DuskInfoView.java b/src/duskz.tools/classes/duskz/editor/DuskInfoView.java similarity index 98% rename from src/duskz.editor/classes/au/notzed/tilez/DuskInfoView.java rename to src/duskz.tools/classes/duskz/editor/DuskInfoView.java index b6ccad5..b99ac98 100644 --- a/src/duskz.editor/classes/au/notzed/tilez/DuskInfoView.java +++ b/src/duskz.tools/classes/duskz/editor/DuskInfoView.java @@ -15,7 +15,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package au.notzed.tilez; +package duskz.editor; import java.io.File; import java.io.IOException; diff --git a/src/duskz.editor/classes/au/notzed/tilez/LocationEditor.java b/src/duskz.tools/classes/duskz/editor/LocationEditor.java similarity index 99% rename from src/duskz.editor/classes/au/notzed/tilez/LocationEditor.java rename to src/duskz.tools/classes/duskz/editor/LocationEditor.java index 98a97fd..36b9e1b 100644 --- a/src/duskz.editor/classes/au/notzed/tilez/LocationEditor.java +++ b/src/duskz.tools/classes/duskz/editor/LocationEditor.java @@ -15,9 +15,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package au.notzed.tilez; +package duskz.editor; -import duskz.server.entityz.TileMap; +import duskz.map.TileMap; import java.io.IOException; import java.nio.charset.Charset; import java.nio.file.Files; diff --git a/src/duskz.editor/classes/au/notzed/tilez/MapLayer.java b/src/duskz.tools/classes/duskz/editor/MapLayer.java similarity index 98% rename from src/duskz.editor/classes/au/notzed/tilez/MapLayer.java rename to src/duskz.tools/classes/duskz/editor/MapLayer.java index 23c4818..a97bb74 100644 --- a/src/duskz.editor/classes/au/notzed/tilez/MapLayer.java +++ b/src/duskz.tools/classes/duskz/editor/MapLayer.java @@ -15,7 +15,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package au.notzed.tilez; +package duskz.editor; import javafx.geometry.Orientation; import javafx.scene.control.ListView; diff --git a/src/duskz.editor/classes/au/notzed/tilez/TZ.java b/src/duskz.tools/classes/duskz/editor/TZ.java similarity index 97% rename from src/duskz.editor/classes/au/notzed/tilez/TZ.java rename to src/duskz.tools/classes/duskz/editor/TZ.java index 06fdc01..a4b6ab0 100644 --- a/src/duskz.editor/classes/au/notzed/tilez/TZ.java +++ b/src/duskz.tools/classes/duskz/editor/TZ.java @@ -15,7 +15,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package au.notzed.tilez; +package duskz.editor; import java.util.concurrent.Executors; import java.util.concurrent.ThreadPoolExecutor; diff --git a/src/duskz.editor/classes/au/notzed/tilez/TextEditor.java b/src/duskz.tools/classes/duskz/editor/TextEditor.java similarity index 99% rename from src/duskz.editor/classes/au/notzed/tilez/TextEditor.java rename to src/duskz.tools/classes/duskz/editor/TextEditor.java index b535b3a..b5fb833 100644 --- a/src/duskz.editor/classes/au/notzed/tilez/TextEditor.java +++ b/src/duskz.tools/classes/duskz/editor/TextEditor.java @@ -15,7 +15,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package au.notzed.tilez; +package duskz.editor; import java.io.IOException; import java.nio.charset.Charset; diff --git a/src/duskz.editor/classes/au/notzed/tilez/TileView.java b/src/duskz.tools/classes/duskz/editor/TileView.java similarity index 97% rename from src/duskz.editor/classes/au/notzed/tilez/TileView.java rename to src/duskz.tools/classes/duskz/editor/TileView.java index 847ee64..7fa7788 100644 --- a/src/duskz.editor/classes/au/notzed/tilez/TileView.java +++ b/src/duskz.tools/classes/duskz/editor/TileView.java @@ -15,7 +15,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package au.notzed.tilez; +package duskz.editor; import javafx.scene.layout.FlowPane; diff --git a/src/duskz.editor/classes/au/notzed/tilez/TileZ.java b/src/duskz.tools/classes/duskz/editor/TileZ.java similarity index 92% rename from src/duskz.editor/classes/au/notzed/tilez/TileZ.java rename to src/duskz.tools/classes/duskz/editor/TileZ.java index be26693..5373236 100644 --- a/src/duskz.editor/classes/au/notzed/tilez/TileZ.java +++ b/src/duskz.tools/classes/duskz/editor/TileZ.java @@ -15,9 +15,11 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package au.notzed.tilez; +package duskz.editor; import duskz.client.fx.DataManagerFX; +import duskz.tool.fx.MapSelectionModel; +import duskz.tool.fx.MapView; import java.io.IOException; import java.util.logging.Level; import java.util.logging.Logger; @@ -68,9 +70,9 @@ public class TileZ extends Application { data.open(); mapView.loadMap(data, mappath); - locationEditor.setMap(mapView.map); + locationEditor.setMap(mapView.getMap()); - mapView.selectionModel.boundsProperty.addListener(new ChangeListener() { + mapView.getSelectionModel().boundsProperty().addListener(new ChangeListener() { @Override public void changed(ObservableValue ov, MapSelectionModel.Bounds t, MapSelectionModel.Bounds t1) { if (t1 != null) { diff --git a/src/duskz.server/classes/duskz/proto/Junk.java b/src/duskz.tools/classes/duskz/proto/Junk.java similarity index 100% rename from src/duskz.server/classes/duskz/proto/Junk.java rename to src/duskz.tools/classes/duskz/proto/Junk.java diff --git a/src/duskz.server/classes/duskz/io/Convert.java b/src/duskz.tools/classes/duskz/tool/Convert.java similarity index 98% rename from src/duskz.server/classes/duskz/io/Convert.java rename to src/duskz.tools/classes/duskz/tool/Convert.java index 027ac01..d584803 100644 --- a/src/duskz.server/classes/duskz/io/Convert.java +++ b/src/duskz.tools/classes/duskz/tool/Convert.java @@ -17,7 +17,7 @@ * along with DuskZ; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -package duskz.io; +package duskz.tool; import java.io.BufferedReader; import java.io.File; diff --git a/src/duskz.editor/classes/au/notzed/tilez/MapSelectionModel.java b/src/duskz.tools/classes/duskz/tool/fx/MapSelectionModel.java similarity index 98% rename from src/duskz.editor/classes/au/notzed/tilez/MapSelectionModel.java rename to src/duskz.tools/classes/duskz/tool/fx/MapSelectionModel.java index 268b199..61418b0 100644 --- a/src/duskz.editor/classes/au/notzed/tilez/MapSelectionModel.java +++ b/src/duskz.tools/classes/duskz/tool/fx/MapSelectionModel.java @@ -15,7 +15,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package au.notzed.tilez; +package duskz.tool.fx; import javafx.beans.property.ObjectProperty; import javafx.beans.property.SimpleObjectProperty; diff --git a/src/duskz.editor/classes/au/notzed/tilez/MapView.java b/src/duskz.tools/classes/duskz/tool/fx/MapView.java similarity index 79% rename from src/duskz.editor/classes/au/notzed/tilez/MapView.java rename to src/duskz.tools/classes/duskz/tool/fx/MapView.java index 99970fa..26a1bee 100644 --- a/src/duskz.editor/classes/au/notzed/tilez/MapView.java +++ b/src/duskz.tools/classes/duskz/tool/fx/MapView.java @@ -15,15 +15,18 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package au.notzed.tilez; +package duskz.tool.fx; import duskz.client.fx.DataManagerFX; -import duskz.server.entityz.TileMap; +import duskz.map.TileMap; import java.io.File; import java.io.IOException; +import java.io.InputStream; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; -import java.util.concurrent.Future; +import java.util.Map.Entry; +import javafx.animation.Animation; import javafx.application.Platform; import javafx.beans.value.ChangeListener; import javafx.beans.value.ObservableValue; @@ -33,6 +36,7 @@ import javafx.geometry.Orientation; import javafx.scene.Node; import javafx.scene.control.ScrollBar; import javafx.scene.image.ImageView; +import javafx.scene.input.MouseButton; import javafx.scene.input.MouseEvent; import javafx.scene.layout.BorderPane; import javafx.scene.layout.Pane; @@ -41,6 +45,7 @@ import javafx.scene.layout.StackPane; import javafx.scene.paint.Color; import javafx.scene.shape.Rectangle; import javafx.scene.text.Text; +import javafx.util.Duration; /** * @@ -53,7 +58,7 @@ public class MapView extends Region implements ChangeListener { DataManagerFX data; // TODO: tilesize on DataManagerFX int tileSize = 32; - double scale = 1; + double scale = 0.5; Pane graphics; Pane alias; StackPane stack; @@ -63,7 +68,6 @@ public class MapView extends Region implements ChangeListener { MapSelectionModel selectionModel = new MapSelectionModel(); public MapView() { - graphics = new Pane(); graphics.setManaged(false); graphics.setScaleX(scale); @@ -99,8 +103,42 @@ public class MapView extends Region implements ChangeListener { }); stack.addEventHandler(MouseEvent.ANY, new EventHandler() { + double startx, starty; + double hstart, vstart; + boolean inpan = false; + public void handle(MouseEvent t) { - if (t.getEventType() == MouseEvent.MOUSE_CLICKED) { + + if (t.getEventType() == MouseEvent.MOUSE_PRESSED) { + if (t.getButton() == MouseButton.SECONDARY) { + startx = t.getX(); + starty = t.getY(); + hstart = hbar.getValue(); + vstart = vbar.getValue(); + inpan = true; + t.consume(); + } + } else if (t.getEventType() == MouseEvent.MOUSE_DRAGGED) { + //if (t.getButton() == MouseButton.MIDDLE) { + if (inpan) { + double dx = t.getX() - startx; + double dy = t.getY() - starty; + + // oh that's right, fx scrollbars are kind of fucked up, they don't reflect the range + // the same way as every other toolkit in existance, ho hum. + double fixh = (hbar.getMax() + hbar.getVisibleAmount()) / hbar.getMax(); + double fixv = (vbar.getMax() + vbar.getVisibleAmount()) / vbar.getMax(); + hbar.setValue(hstart - dx * fixh); + vbar.setValue(vstart - dy * fixv); + t.consume(); + } + //} + } else if (t.getEventType() == MouseEvent.MOUSE_RELEASED) { + if (inpan) { + inpan = false; + t.consume(); + } + } else if (t.getEventType() == MouseEvent.MOUSE_CLICKED) { int tx = (int) ((getOriginX() + t.getX()) / tileSize / scale); int ty = (int) ((getOriginY() + t.getY()) / tileSize / scale); @@ -116,6 +154,7 @@ public class MapView extends Region implements ChangeListener { } double oldw, oldh; int vcols, vrows; + HashMap animators = new HashMap<>(); @Override protected void layoutChildren() { @@ -172,13 +211,24 @@ public class MapView extends Region implements ChangeListener { System.out.println("trnaslate changed"); } - void loadMap(DataManagerFX data, String path) throws IOException { + public void loadMap(DataManagerFX data, String name) throws IOException { this.data = data; - map = TileMap.loadLayered(new File(path)); + + try (InputStream is = data.getInputStream("maps/" + name)) { + map = TileMap.loadLayeredMap(is, name); + } updateMap(); requestLayout(); } + public MapSelectionModel getSelectionModel() { + return selectionModel; + } + + public TileMap getMap() { + return map; + } + @Override protected double computePrefHeight(double d) { //if (map == null) @@ -210,11 +260,11 @@ public class MapView extends Region implements ChangeListener { return v; } - int getTileX() { + public int getTileX() { return (int) (getOriginX() / tileSize / scale); } - int getTileY() { + public int getTileY() { return (int) (getOriginY() / tileSize / scale); } @@ -248,6 +298,8 @@ public class MapView extends Region implements ChangeListener { oldvcols = vcols; oldvrows = vrows; + final HashMap> animated = new HashMap<>(); + for (int l = 0; l < map.getLayerCount(); l++) { for (int y = 0; y < vrows; y++) { int ty = y + y0; @@ -258,6 +310,17 @@ public class MapView extends Region implements ChangeListener { int tileid = map.getTile(l, tx, ty); if (tileid != 0) { data.updateTile(iv, tileid, tileSize, tileSize); + + // FIXME: put in some animation controller code + if (data.isAnimRoot(tileid)) { + List list = animated.get(tileid); + if (list == null) { + list = new ArrayList<>(); + animated.put(tileid, list); + } + list.add(iv); + } + iv.setVisible(true); } else { iv.setVisible(false); @@ -270,7 +333,7 @@ public class MapView extends Region implements ChangeListener { // Check for meta data on map region List nodes = new ArrayList(); - boolean overlayOld = true; + boolean overlayOld = false; // HACK: check for old map shit if (overlayOld) { @@ -341,21 +404,38 @@ public class MapView extends Region implements ChangeListener { alias.getChildren().setAll(nodes); + // Load animation stuff + for (Entry> e : animated.entrySet()) { + int root = e.getKey(); + TileAnimator animator = animators.get(root); + DataManagerFX.AnimSetFX set = data.getAnimSet(root); + if (animator == null) { + animator = new TileAnimator(e.getValue(), Duration.millis(set.rate * set.tiles.length), set.tiles); + animators.put(root, animator); + animator.setCycleCount(Animation.INDEFINITE); + animator.play(); + System.out.println("create animator for " + root); + } else { + animator.setNodes(e.getValue()); + System.out.println("update animator for " + root); + } + } } - Future f; + /* + Future f; - void updateThread() { - int y0 = (int) (vbar.getValue() / tileSize / scale); - int x0 = (int) (hbar.getValue() / tileSize / scale); + void updateThread() { + int y0 = (int) (vbar.getValue() / tileSize / scale); + int x0 = (int) (hbar.getValue() / tileSize / scale); - if (f != null) { - if (f.cancel(false)) { - System.out.println("pending cancelled"); - } - } + if (f != null) { + if (f.cancel(false)) { + System.out.println("pending cancelled"); + } + } - f = TZ.single.submit(new Update(x0, y0, 1, vcols, vrows)); - } + f = TZ.single.submit(new Update(x0, y0, 1, vcols, vrows)); + }*/ class Update implements Runnable { diff --git a/src/duskz.tools/classes/duskz/tool/fx/TileAnimator.java b/src/duskz.tools/classes/duskz/tool/fx/TileAnimator.java new file mode 100644 index 0000000..a3db00e --- /dev/null +++ b/src/duskz.tools/classes/duskz/tool/fx/TileAnimator.java @@ -0,0 +1,59 @@ +/* + * This file is part of DuskZ, a graphical mud engine. + * + * Copyright (C) 2013 Michael Zucchi + * + * DuskZ 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. + * + * DuskZ 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 DuskZ. If not, see . + */ +package duskz.tool.fx; + +import java.util.List; +import javafx.animation.Transition; +import javafx.geometry.Rectangle2D; +import javafx.scene.image.ImageView; +import javafx.util.Duration; + +/** + * Animates a set of tiles by switching the viewport on the texture. + * + * @author Michael Zucchi + */ +public class TileAnimator extends Transition { + + Rectangle2D[] viewports; + List nodes; + + public TileAnimator(List nodes, Duration duration, Rectangle2D[] images) { + setCycleDuration(duration); + this.viewports = images; + this.nodes = nodes; + } + + public void setNodes(List nodes) { + this.nodes = nodes; + + // Track the current time properly + double d = getCurrentTime().toMillis() /getCycleDuration().toMillis(); + + interpolate(d); + } + + @Override + protected void interpolate(double d) { + int index = Math.min(viewports.length - 1, (int) (d * viewports.length)); + + for (ImageView node : nodes) + node.setViewport(viewports[index]); + } +} diff --git a/src/duskz.tools/classes/duskz/viewer/MapViewer.java b/src/duskz.tools/classes/duskz/viewer/MapViewer.java new file mode 100644 index 0000000..6de2844 --- /dev/null +++ b/src/duskz.tools/classes/duskz/viewer/MapViewer.java @@ -0,0 +1,79 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package duskz.viewer; + +import duskz.tool.fx.MapView; +import duskz.client.fx.DataManagerFX; +import java.io.IOException; +import java.util.logging.Level; +import java.util.logging.Logger; +import javafx.application.Application; +import javafx.scene.Scene; +import javafx.scene.layout.BorderPane; +import javafx.stage.Stage; + +/** + * + * @author Michael Zucchi + */ +public class MapViewer extends Application { + + MapView mapView; + DataManagerFX data; + static final String tag = "mapviewer"; + + @Override + public void start(Stage stage) { + BorderPane root = new BorderPane(); + + root.setCenter(mapView = new MapView()); + + Scene scene = new Scene(root, 768, 512); + + stage.setTitle("TileZ"); + stage.setScene(scene); + stage.show(); + + String datapath = "/home/notzed/house.jar"; + String mappath = "main"; + + try { + data = new DataManagerFX(datapath); + data.open(); + mapView.loadMap(data, mappath); + + // locationEditor.setMap(mapView.map); + + /* + mapView.selectionModel.boundsProperty.addListener(new ChangeListener() { + @Override + public void changed(ObservableValue ov, MapSelectionModel.Bounds t, MapSelectionModel.Bounds t1) { + if (t1 != null) { + locationEditor.setTileX(t1.left); + locationEditor.setTileY(t1.top); + oldInfo.setLocation(t1.left, t1.top); + } else { + locationEditor.setTileX(-1); + locationEditor.setTileY(-1); + } + } + });*/ + } catch (IOException ex) { + Logger.getLogger(tag).log(Level.SEVERE, null, ex); + } + } + + /** + * The main() method is ignored in correctly deployed JavaFX + * application. main() serves only as fallback in case the + * application can not be launched through deployment artifacts, + * e.g., in IDEs with limited FX support. NetBeans ignores main(). + * + * @param args the command line arguments + */ + public static void main(String[] args) { + launch(args); + } +} diff --git a/src/duskz.server/classes/duskz/io/Tiled.java b/src/duskz.tools/classes/duskz/viewer/Tiled.java similarity index 51% rename from src/duskz.server/classes/duskz/io/Tiled.java rename to src/duskz.tools/classes/duskz/viewer/Tiled.java index c5ca39d..6058e77 100644 --- a/src/duskz.server/classes/duskz/io/Tiled.java +++ b/src/duskz.tools/classes/duskz/viewer/Tiled.java @@ -20,19 +20,10 @@ /** * Changes */ -package duskz.io; - -import duskz.server.entity.TileMap; -import duskz.io.tiled.Data; -import duskz.io.tiled.Image; -import duskz.io.tiled.Layer; -import duskz.io.tiled.Map; -import duskz.io.tiled.Property; -import duskz.io.tiled.Tile; -import duskz.io.tiled.Tileset; +package duskz.viewer; + import jakarta.xml.bind.JAXBContext; import jakarta.xml.bind.JAXBException; -import jakarta.xml.bind.Marshaller; import jakarta.xml.bind.Unmarshaller; import java.awt.Graphics2D; import java.awt.image.BufferedImage; @@ -51,6 +42,8 @@ import java.nio.ByteOrder; import java.nio.charset.Charset; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; import java.util.List; import java.util.jar.Attributes; import java.util.jar.JarEntry; @@ -63,14 +56,19 @@ import java.util.zip.GZIPOutputStream; import javax.imageio.ImageIO; import javax.imageio.stream.ImageInputStream; import javax.imageio.stream.MemoryCacheImageInputStream; +import duskz.map.io.*; +import java.util.Map.Entry; + /** * Tiled loader/converter. This is only experimental at this stage. * + * @author notzed */ public class Tiled { static byte[] map64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".getBytes(Charset.forName("US-ASCII")); static byte[] unmap64 = new byte[256]; + public static final int MAGIC_LAYERED = 0x6d61707a; static { for (int i = 0; i < 256; i++) @@ -197,106 +195,107 @@ public class Tiled { return ImageIO.read(is); } - static void testexport() throws IOException { - File path = new File("/home/notzed/src/DuskRPG/DuskFiles/Dusk2.7.3/shortmap"); + /* + static void testexport() throws IOException { + File path = new File("/home/notzed/src/DuskRPG/DuskFiles/Dusk2.7.3/shortmap"); - TileMap map = TileMap.loadMap(path, TileMap.FORMAT_SHORT); - int width = map.getCols(); - int height = map.getRows(); - int len = width * height; + TileMap map = TileMap.loadMap(path, TileMap.FORMAT_SHORT); + int width = map.getCols(); + int height = map.getRows(); + int len = width * height; - System.out.println("Map size: " + width + "," + height); + System.out.println("Map size: " + width + "," + height); - duskz.io.tiled.Map tmap = new duskz.io.tiled.Map(); + duskz.io.tiled.Map tmap = new duskz.io.tiled.Map(); - tmap.setWidth(width); - tmap.setHeight(height); - tmap.setOrientation("orthogonal"); - tmap.setVersion("1.0"); - tmap.setTilewidth(32); - tmap.setTileheight(32); + tmap.setWidth(width); + tmap.setHeight(height); + tmap.setOrientation("orthogonal"); + tmap.setVersion("1.0"); + tmap.setTilewidth(32); + tmap.setTileheight(32); - Tileset tset = new Tileset(); - tmap.getTileset().add(tset); + Tileset tset = new Tileset(); + tmap.getTileset().add(tset); - tset.setTileheight(32); - tset.setTilewidth(32); - tset.setFirstgid(0); - tset.setName("dusk-map"); + tset.setTileheight(32); + tset.setTilewidth(32); + tset.setFirstgid(0); + tset.setName("dusk-map"); - // Add tile set - BufferedImage tiles = ImageIO.read(new File("/home/notzed/src/DuskRPG/DuskFiles/Dusk2.7.3/www/rc/somedusk/images/map.png")); - int tileWidth = 32; - int tileHeight = 32; - int imageWidth = tiles.getWidth(); - for (int x = 0; x * tileWidth < imageWidth; x++) { - BufferedImage tile = tiles.getSubimage(x * tileWidth, 0, tileWidth, tileHeight); + // Add tile set + BufferedImage tiles = ImageIO.read(new File("/home/notzed/src/DuskRPG/DuskFiles/Dusk2.7.3/www/rc/somedusk/images/map.png")); + int tileWidth = 32; + int tileHeight = 32; + int imageWidth = tiles.getWidth(); + for (int x = 0; x * tileWidth < imageWidth; x++) { + BufferedImage tile = tiles.getSubimage(x * tileWidth, 0, tileWidth, tileHeight); - Image timage = new Image(); - Data idata = new Data(); + Image timage = new Image(); + Data idata = new Data(); - idata.setEncoding("base64"); - idata.setvalue(encodeImage(tile)); - timage.setData(idata); - timage.setFormat("png"); + idata.setEncoding("base64"); + idata.setvalue(encodeImage(tile)); + timage.setData(idata); + timage.setFormat("png"); - Tile ttile = new Tile(); - ttile.setId(x); - ttile.setImage(timage); + Tile ttile = new Tile(); + ttile.setId(x); + ttile.setImage(timage); - tset.getTile().add(ttile); - } + tset.getTile().add(ttile); + } - // Add layer - Layer layer = new Layer(); + // Add layer + Layer layer = new Layer(); - tmap.getLayerOrObjectgroup().add(layer); + tmap.getLayerOrObjectgroup().add(layer); - layer.setName("base"); - layer.setVisible(1); - layer.setOpacity(1); - layer.setWidth(map.getCols()); - layer.setHeight(map.getRows()); + layer.setName("base"); + layer.setVisible(1); + layer.setOpacity(1); + layer.setWidth(map.getCols()); + layer.setHeight(map.getRows()); - Data d = new Data(); + Data d = new Data(); - layer.setData(d); + layer.setData(d); - d.setCompression("gzip"); - d.setEncoding("base64"); + d.setCompression("gzip"); + d.setEncoding("base64"); - // First convert to ints - ByteBuffer bb = ByteBuffer.allocate(len * 4).order(ByteOrder.LITTLE_ENDIAN); + // First convert to ints + ByteBuffer bb = ByteBuffer.allocate(len * 4).order(ByteOrder.LITTLE_ENDIAN); - for (int y = 0; y < height; y++) { - for (int x = 0; x < width; x++) { - bb.putInt(map.getTile(x, y)); - } - } - bb.rewind(); - - d.setvalue(encodeArray(bb.array())); - //d.setvalue("dummy"); - try { - JAXBContext jc = JAXBContext.newInstance(Map.class); - //Unmarshaller u = jc.createUnmarshaller(); - //Object element = u.unmarshal(new File("foo.xml")); - Marshaller m = jc.createMarshaller(); + for (int y = 0; y < height; y++) { + for (int x = 0; x < width; x++) { + bb.putInt(map.getTile(x, y)); + } + } + bb.rewind(); - m.setProperty("jaxb.formatted.output", true); + d.setvalue(encodeArray(bb.array())); + //d.setvalue("dummy"); + try { + JAXBContext jc = JAXBContext.newInstance(Map.class); + //Unmarshaller u = jc.createUnmarshaller(); + //Object element = u.unmarshal(new File("foo.xml")); + Marshaller m = jc.createMarshaller(); - m.marshal(tmap, new File("/home/notzed/tiled-test.tmx")); + m.setProperty("jaxb.formatted.output", true); - } catch (JAXBException ex) { - Logger.getLogger(Tiled.class.getName()).log(Level.SEVERE, null, ex); - } - System.out.println("done"); + m.marshal(tmap, new File("/home/notzed/tiled-test.tmx")); - } + } catch (JAXBException ex) { + Logger.getLogger(Tiled.class.getName()).log(Level.SEVERE, null, ex); + } + System.out.println("done"); + } + */ static class TileInfo { int id; @@ -304,6 +303,26 @@ public class Tiled { String move; String see; String action; + // animation meta-data + List anim = new ArrayList<>(); + } + + static class AnimGroup { + + String name; + int rate = 250; + HashMap> sets = new HashMap<>(); + } + + static class AnimInfo implements Comparable { + + int tileid; + int seq; + + @Override + public int compareTo(AnimInfo t) { + return Integer.compare(seq, t.seq); + } } static void testimport(File src, File dst) throws IOException { @@ -372,6 +391,9 @@ public class Tiled { case "action": ti.action = p.getValue(); break; + case "anim": + ti.anim.add(p.getValue()); + break; } } } @@ -397,44 +419,141 @@ public class Tiled { jos.closeEntry(); } } + { + int tileWidth = tmap.getTilewidth(); + int tileHeight = tmap.getTileheight(); + + for (java.lang.Object o : tmap.getLayerOrObjectgroup()) { + if (o instanceof Objectgroup) { + Objectgroup og = (Objectgroup) o; + for (duskz.map.io.Object oo : og.getObject()) { + int ox = oo.getX() / tileWidth; + int oy = oo.getY() / tileHeight; + int ow = oo.getWidth() / tileWidth; + int oh = oo.getHeight() / tileHeight; + + if (oo.getProperties() != null) { + for (Property op : oo.getProperties().getProperty()) { + String name = op.getName(); + String value = op.getValue(); + switch (name) { + case "alias": + case "goto": + case "able": + case "visible": + for (int y = 0; y < oh; y++) { + for (int x = 0; x < ow; x++) { + System.out.printf("%d.%d.%s=%s\n", ox + x, oy + y, name, value); + } + } + break; + } + } + } + } + } + } + } - TileMap map = new TileMap("main", tmap.getWidth(), tmap.getHeight()); - - int lid = 0; + { + //TileMap map = new TileMap("main", tmap.getWidth(), tmap.getHeight()); + int lid = 0; + + int nlayers = 0; + int groundid = 0; + int mwidth = 0; + int mheight = 0; + // TODO: take layer size as max of all + for (java.lang.Object o : tmap.getLayerOrObjectgroup()) { + if (o instanceof Layer) { + Layer l = (Layer) o; - for (Object o : tmap.getLayerOrObjectgroup()) { - if (o instanceof Layer) { - Layer l = (Layer) o; + if (l.getName() != null && l.getName().equals("ground")) { + mwidth = l.getWidth(); + mheight = l.getHeight(); + groundid = nlayers; + } - // FIXME: remap map? - //l.getData().getvalue(); + nlayers++; + } + } - // encoding blah blah + // Write layered map + JarEntry je = new JarEntry("maps/main"); + jos.putNextEntry(je); - InputStream is = decodeArray(l.getData().getvalue()); - ImageInputStream dis = new MemoryCacheImageInputStream(is); + { + DataOutputStream dos = new DataOutputStream(jos); + dos.writeInt(MAGIC_LAYERED); + dos.writeInt(0); + dos.writeInt(0); + dos.writeInt(mwidth); + dos.writeInt(mheight); + dos.writeInt(groundid); + dos.writeInt(nlayers); + + int layerid = 0; + for (java.lang.Object o : tmap.getLayerOrObjectgroup()) { + if (o instanceof Layer) { + Layer l = (Layer) o; + int lwidth = l.getWidth(); + int lheight = l.getHeight(); + int len = l.getWidth() * l.getHeight(); + int layer[] = new int[len]; + + // Read in layer and perform some optimisation on it + try (ImageInputStream dis = new MemoryCacheImageInputStream(decodeArray(l.getData().getvalue()))) { + dis.setByteOrder(ByteOrder.LITTLE_ENDIAN); + for (int i = 0; i < len; i++) { + layer[i] = dis.readInt(); + } - dis.setByteOrder(ByteOrder.LITTLE_ENDIAN); + } - // Convert to shorts - JarEntry je = new JarEntry("maps/0-" + lid + "-" + l.getName()); - jos.putNextEntry(je); + // Find bounds of used squares (if not ground layer) + int minx = lwidth - 1; + int maxx = 0; + int miny = lheight - 1; + int maxy = 0; + + if (layerid != groundid) { + for (int y = 0; y < lheight; y++) { + for (int x = 0; x < lwidth; x++) { + if (layer[x + y * lwidth] != 0) { + minx = Math.min(x, minx); + miny = Math.min(y, miny); + maxx = Math.max(x, maxx); + maxy = Math.max(y, maxy); + } + } + } + } else { + minx = 0; + maxx = lwidth - 1; + miny = 0; + maxy = lheight - 1; + } - DataOutputStream dos = new DataOutputStream(jos); - dos.writeInt(l.getWidth()); - dos.writeInt(l.getHeight()); - for (int y = 0; y < l.getHeight(); y++) { - for (int x = 0; x < l.getWidth(); x++) { - int t = dis.readInt(); - dos.writeShort(t); - //System.out.printf("%3d\n", t); + System.out.printf("Writing layer %d '%s' at %d,%d size %d,%d\n", + layerid, l.getName(), minx, miny, maxx - minx + 1, maxy - miny + 1); + + // Write out used area + dos.writeInt(minx); + dos.writeInt(miny); + dos.writeInt(maxx - minx + 1); + dos.writeInt(maxy - miny + 1); + for (int y = miny; y <= maxy; y++) { + for (int x = minx; x <= maxx; x++) { + dos.writeShort(layer[x + y * lwidth]); + } + } } + + layerid++; } dos.flush(); - //dos.close(); - - jos.closeEntry(); } + jos.closeEntry(); } // Add tile script names @@ -457,6 +576,65 @@ public class Tiled { jos.closeEntry(); } + { + JarEntry je = new JarEntry("tiles/anim"); + jos.putNextEntry(je); + PrintStream ps = new PrintStream(jos); + HashMap anims = new HashMap<>(); + for (TileInfo ti : tileInfo) { + for (String a : ti.anim) { + // group,set,seq,[,time] + String[] as = a.split(","); + if (as != null && as.length > 2) { + String key = as[0].trim(); + String setkey = as[1].trim(); + AnimGroup ag = anims.get(key); + if (ag == null) { + ag = new AnimGroup(); + ag.name = key; + anims.put(key, ag); + } + AnimInfo ai = new AnimInfo(); + ai.tileid = ti.id; + ai.seq = Integer.valueOf(as[2]); + if (as.length > 3 && ai.tileid == 0) { + ag.rate = Integer.valueOf(as[3]); + } + List set = ag.sets.get(setkey); + if (set == null) { + set = new ArrayList<>(); + ag.sets.put(setkey, set); + } + set.add(ai); + } + } + } + for (Entry ae : anims.entrySet()) { + AnimGroup ag = ae.getValue(); + String key = ae.getKey(); + + ps.format("anim.%s=%d", key, ag.rate); + // default timing + + for (Entry> as : ag.sets.entrySet()) { + List set = as.getValue(); + boolean first = true; + + ps.format(";"); + Collections.sort(set); + for (AnimInfo a : set) { + if (!first) + ps.print(","); + first = false; + ps.format("%d", a.tileid); + } + } + ps.println(); + } + ps.flush(); + jos.closeEntry(); + } + // Build tileset manifest - nope in manifest if (false) { int setid = 0; @@ -541,129 +719,130 @@ public class Tiled { Logger.getLogger(Tiled.class.getName()).log(Level.SEVERE, null, ex); } } - - static void tiledToDusk(File src, File dst) throws IOException { - try { - JAXBContext jc = JAXBContext.newInstance(Map.class); - Unmarshaller u = jc.createUnmarshaller(); - Map tmap = (Map) u.unmarshal(src); - - System.out.println("Loaded map size: " + tmap.getWidth() + "x" + tmap.getHeight()); - - List tileInfo = new ArrayList<>(); - int tid = 0; - - // TODO: write out tileset info somewhere - - - TileMap map = new TileMap(dst.getName(), tmap.getWidth(), tmap.getHeight()); - - int lid = 0; - - int nlayers = 0; - int groundid = 0; - int twidth = 0; - int theight = 0; - for (Object o : tmap.getLayerOrObjectgroup()) { - if (o instanceof Layer) { - Layer l = (Layer) o; - - if (l.getName() != null && l.getName().equals("ground")) { - twidth = l.getWidth(); - theight = l.getHeight(); - groundid = nlayers; - } - - nlayers++; - } - } - - if (twidth == 0 || theight == 0) - throw new IOException("Couldn't find a layer called 'ground'"); - - System.out.printf("Found %d layers\n", nlayers); - System.out.printf("Ground on layer %d\n", groundid); - // Create map - try (DataOutputStream dos = new DataOutputStream(new FileOutputStream(dst))) { - // Write header - dos.writeInt(TileMap.MAGIC_LAYERED); - dos.writeInt(0); - dos.writeInt(0); - dos.writeInt(twidth); - dos.writeInt(theight); - dos.writeInt(groundid); - dos.writeInt(nlayers); - - int layerid = 0; - for (Object o : tmap.getLayerOrObjectgroup()) { - if (o instanceof Layer) { - Layer l = (Layer) o; - int lwidth = l.getWidth(); - int lheight = l.getHeight(); - int len = l.getWidth() * l.getHeight(); - int layer[] = new int[len]; - - // Read in layer and perform some optimisation on it - try (ImageInputStream dis = new MemoryCacheImageInputStream(decodeArray(l.getData().getvalue()))) { - dis.setByteOrder(ByteOrder.LITTLE_ENDIAN); - for (int i = 0; i < len; i++) { - layer[i] = dis.readInt(); - } - - } - - // Find bounds of used squares (if not ground layer) - int minx = lwidth - 1; - int maxx = 0; - int miny = lheight - 1; - int maxy = 0; - - if (layerid != groundid) { - for (int y = 0; y < lheight; y++) { - for (int x = 0; x < lwidth; x++) { - if (layer[x + y * lwidth] != 0) { - minx = Math.min(x, minx); - miny = Math.min(y, miny); - maxx = Math.max(x, maxx); - maxy = Math.max(y, maxy); - } - } - } - } else { - minx = 0; - maxx = lwidth - 1; - miny = 0; - maxy = lheight - 1; - } - - System.out.printf("Writing layer %d '%s' at %d,%d size %d,%d\n", - layerid, l.getName(), minx, miny, maxx - minx + 1, maxy - miny + 1); - - // Write out used area - dos.writeInt(minx); - dos.writeInt(miny); - dos.writeInt(maxx - minx + 1); - dos.writeInt(maxy - miny + 1); - for (int y = miny; y <= maxy; y++) { - for (int x = minx; x <= maxx; x++) { - dos.writeShort(layer[x + y * lwidth]); - } - } - } - - layerid++; - } - } - - } catch (JAXBException ex) { - Logger.getLogger(Tiled.class.getName()).log(Level.SEVERE, null, ex); - } - } + /* + static void tiledToDusk(File src, File dst) throws IOException { + try { + JAXBContext jc = JAXBContext.newInstance(Map.class); + Unmarshaller u = jc.createUnmarshaller(); + Map tmap = (Map) u.unmarshal(src); + + System.out.println("Loaded map size: " + tmap.getWidth() + "x" + tmap.getHeight()); + + List tileInfo = new ArrayList<>(); + int tid = 0; + + // TODO: write out tileset info somewhere + + + TileMap map = new TileMap(dst.getName(), tmap.getWidth(), tmap.getHeight()); + + int lid = 0; + + int nlayers = 0; + int groundid = 0; + int twidth = 0; + int theight = 0; + for (Object o : tmap.getLayerOrObjectgroup()) { + if (o instanceof Layer) { + Layer l = (Layer) o; + + if (l.getName() != null && l.getName().equals("ground")) { + twidth = l.getWidth(); + theight = l.getHeight(); + groundid = nlayers; + } + + nlayers++; + } + } + + if (twidth == 0 || theight == 0) + throw new IOException("Couldn't find a layer called 'ground'"); + + System.out.printf("Found %d layers\n", nlayers); + System.out.printf("Ground on layer %d\n", groundid); + // Create map + try (DataOutputStream dos = new DataOutputStream(new FileOutputStream(dst))) { + // Write header + dos.writeInt(TileMap.MAGIC_LAYERED); + dos.writeInt(0); + dos.writeInt(0); + dos.writeInt(twidth); + dos.writeInt(theight); + dos.writeInt(groundid); + dos.writeInt(nlayers); + + int layerid = 0; + for (Object o : tmap.getLayerOrObjectgroup()) { + if (o instanceof Layer) { + Layer l = (Layer) o; + int lwidth = l.getWidth(); + int lheight = l.getHeight(); + int len = l.getWidth() * l.getHeight(); + int layer[] = new int[len]; + + // Read in layer and perform some optimisation on it + try (ImageInputStream dis = new MemoryCacheImageInputStream(decodeArray(l.getData().getvalue()))) { + dis.setByteOrder(ByteOrder.LITTLE_ENDIAN); + for (int i = 0; i < len; i++) { + layer[i] = dis.readInt(); + } + + } + + // Find bounds of used squares (if not ground layer) + int minx = lwidth - 1; + int maxx = 0; + int miny = lheight - 1; + int maxy = 0; + + if (layerid != groundid) { + for (int y = 0; y < lheight; y++) { + for (int x = 0; x < lwidth; x++) { + if (layer[x + y * lwidth] != 0) { + minx = Math.min(x, minx); + miny = Math.min(y, miny); + maxx = Math.max(x, maxx); + maxy = Math.max(y, maxy); + } + } + } + } else { + minx = 0; + maxx = lwidth - 1; + miny = 0; + maxy = lheight - 1; + } + + System.out.printf("Writing layer %d '%s' at %d,%d size %d,%d\n", + layerid, l.getName(), minx, miny, maxx - minx + 1, maxy - miny + 1); + + // Write out used area + dos.writeInt(minx); + dos.writeInt(miny); + dos.writeInt(maxx - minx + 1); + dos.writeInt(maxy - miny + 1); + for (int y = miny; y <= maxy; y++) { + for (int x = minx; x <= maxx; x++) { + dos.writeShort(layer[x + y * lwidth]); + } + } + } + + layerid++; + } + } + + } catch (JAXBException ex) { + Logger.getLogger(Tiled.class.getName()).log(Level.SEVERE, null, ex); + } + } + * */ // test load/save itled format map public static void main(String[] args) throws IOException { - //testimport(new File("/home/notzed/house.tmx"), - // new File("/home/notzed/house.jar")); + testimport(new File("/home/notzed/dusk/maps/main.tmx"), + new File("/home/notzed/house.jar")); //tiledToDusk(new File("/home/notzed/test-map.tmx"), // new File("/home/notzed/test-map.bin")); //tiledToDusk(new File("/home/notzed/dusk/maps/dusk.tmx"), @@ -671,7 +850,7 @@ public class Tiled { //tiledToDusk(new File("/home/notzed/dusk/maps/do-drop-inn.tmx"), // new File("/home/notzed/src/DuskRPG/DuskFiles/DuskX/defMaps/do-drop-inn")); //testexport(); - //(new File("/home/notzed/dusk/maps/main.tmx"), + //tiledToDusk(new File("/home/notzed/dusk/maps/main.tmx"), // new File("/home/notzed/dusk/game/defMaps/main")); } } diff --git a/src/duskz.tools/classes/module-info.java b/src/duskz.tools/classes/module-info.java new file mode 100644 index 0000000..0c4740b --- /dev/null +++ b/src/duskz.tools/classes/module-info.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2023 Michael Zucchi + * + * 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 2 + * 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +module duskz.tools { + + requires java.scripting; + + requires javafx.graphics; + requires javafx.controls; + requires java.desktop; + requires java.logging; + requires jakarta.xml.bind; + + requires duskz.common; + requires duskz.client; + + exports duskz.tool; + + exports duskz.viewer to javafx.graphics; + exports duskz.editor to javafx.graphics; +} -- 2.39.2