diff options
Diffstat (limited to 'tools/tmwcon')
-rw-r--r-- | tools/tmwcon/.gitignore | 2 | ||||
-rw-r--r-- | tools/tmwcon/MANIFEST.MF | 3 | ||||
-rw-r--r-- | tools/tmwcon/README | 11 | ||||
-rwxr-xr-x | tools/tmwcon/build.xml | 30 | ||||
-rw-r--r-- | tools/tmwcon/src/converter/Main.java | 103 | ||||
-rw-r--r-- | tools/tmwcon/src/converter/Process.java | 246 | ||||
-rw-r--r-- | tools/tmwcon/src/converter/WLKInterface.java | 31 | ||||
-rw-r--r-- | tools/tmwcon/tiled-core.jar | bin | 52337 -> 0 bytes | |||
-rw-r--r-- | tools/tmwcon/tmw.jar | bin | 2764 -> 0 bytes |
9 files changed, 0 insertions, 426 deletions
diff --git a/tools/tmwcon/.gitignore b/tools/tmwcon/.gitignore deleted file mode 100644 index 056686cf..00000000 --- a/tools/tmwcon/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/build -/converter.jar diff --git a/tools/tmwcon/MANIFEST.MF b/tools/tmwcon/MANIFEST.MF deleted file mode 100644 index 2cdfdcd8..00000000 --- a/tools/tmwcon/MANIFEST.MF +++ /dev/null @@ -1,3 +0,0 @@ -Manifest-Version: 1.0 -Main-Class: converter.Main -Class-Path: tiled-core.jar tmw.jar diff --git a/tools/tmwcon/README b/tools/tmwcon/README deleted file mode 100644 index e3a4a31a..00000000 --- a/tools/tmwcon/README +++ /dev/null @@ -1,11 +0,0 @@ -Dependencies: - - * ant (recent version) - * J2SE 5 or higher (or equivalent) - * Tiled core jar file (in this directory) - * TMW Tiled plugin jar (in this directory) - -Compilation and Usage: - Run - make maps - from the top level of the server data. diff --git a/tools/tmwcon/build.xml b/tools/tmwcon/build.xml deleted file mode 100755 index 26497f8e..00000000 --- a/tools/tmwcon/build.xml +++ /dev/null @@ -1,30 +0,0 @@ -<project name="TMWServ to eAthena Converter" default="dist"> - <description> - A tool to convert map data from TMWServ format to eAthena format - </description> - <!-- set global properties for this build --> - - <target name="init"> - <!-- Create the time stamp --> - <tstamp/> - <!-- Create the build directory structure used by compile --> - <mkdir dir="build"/> - </target> - - <target name="compile" depends="init" description="Compile the source"> - <javac source="1.5" target="1.5" srcdir="src" destdir="build" - deprecation="on" classpath="tiled-core.jar;tmw.jar"/> - </target> - - <target name="dist" depends="compile" description="Generate the distribution"> - <jar - jarfile="converter.jar" - manifest="MANIFEST.MF" - basedir="build" - /> - </target> - - <target name="clean" description="Clean up the build directory" > - <delete dir="build"/> - </target> -</project> diff --git a/tools/tmwcon/src/converter/Main.java b/tools/tmwcon/src/converter/Main.java deleted file mode 100644 index cb226776..00000000 --- a/tools/tmwcon/src/converter/Main.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Converter from Tiled .tmx files to tmwAthena .wlk and mob/warp scripts - * Copyright (c) 2008 Jared Adams - * Copyright (c) 2011 Ben Longbons - * License: GNU GPL, v2 or later - */ - -package converter; - -import java.io.*; -import java.util.*; - -import tiled.io.xml.*; - -public class Main { - public static XMLMapTransformer reader = null; - - private static tiled.core.Map loadMap(File file) { - tiled.core.Map map = null; - try { - map = reader.readMap(file.getAbsolutePath()); - } catch (Exception e) { - e.printStackTrace(); - } - - return map; - } - - public static boolean isTMX(File in) { - if (in.isDirectory()) return false; - - return in.getName().matches(".*\\.tmx(\\.gz)?$"); - } - - public static Collection<File> getTMXFiles(File directory) { - if (!directory.isDirectory()) return Collections.emptyList(); - - List<File> ret = new Vector<File>(); - - for (File f : directory.listFiles()) { - if (f.isDirectory()) { - ret.addAll(getTMXFiles(f)); - } else if (isTMX(f)) { - ret.add(f); - } - } - - return ret; - } - - public static PrintWriter getWriter(File f) { - try { - f.getParentFile().mkdir(); - f.createNewFile(); - return new PrintWriter(f); - } catch (Exception e) { - e.printStackTrace(); - } - - return null; - } - - public static String getName(File folder, File file) { - String path = folder.getAbsolutePath(); - String name = file.getAbsolutePath(); - if (name.startsWith(path)) name = name.substring(path.length() + 1); - if (name.endsWith(".gz")) name = name.substring(0, name.length() - 3); - if (name.endsWith(".tmx")) name = name.substring(0, name.length() - 4); - return name; - } - - public static void main(String[] args) throws IOException { - if (args.length != 2) { - System.out.println("Usage: java Converter client-data-dir server-data-dir"); - System.exit(1); - } - - File client_data = new File(args[0]); - File server_data = new File(args[1]); - - reader = new XMLMapTransformer(); - - PrintWriter summary = new PrintWriter("converter.txt"); - - Process.setServerData(server_data); - - File folder = new File(client_data, "maps/"); - - Collection<File> tmxs = getTMXFiles(folder); - ArrayList<String> folders = new ArrayList<String>(); - String name; - for (File f : tmxs) { - name = getName(folder, f); - System.out.printf("== %s ==\n", name); - folders.add(Process.processMap(name, loadMap(f), f, summary)); - } - - summary.flush(); - summary.close(); - - Process.writeMasterImport(folders); - } -} diff --git a/tools/tmwcon/src/converter/Process.java b/tools/tmwcon/src/converter/Process.java deleted file mode 100644 index 2e0a8646..00000000 --- a/tools/tmwcon/src/converter/Process.java +++ /dev/null @@ -1,246 +0,0 @@ -/* - * Converter from Tiled .tmx files to tmwAthena .wlk and mob/warp scripts - * Copyright (c) 2008, 2011 Jared Adams - * Copyright (c) 2011 Ben Longbons - * License: GNU GPL, v2 or later - */ - -package converter; - -import java.awt.*; -import java.io.*; -import java.util.Iterator; -import java.util.Properties; -import java.util.TreeSet; -import java.util.ArrayList; -import java.util.List; -import java.util.Collections; - -import tiled.core.*; -import tiled.plugins.tmw.*; - -public class Process { - // both were formerly (hard-coded) "\t", for different reasons - // Note: don't use println, as we want only '\n' - private static final String SEPARATOR = "|"; - private static final String INDENTATION = " "; - - private static final String mobFile = "_mobs.txt"; - private static final String warpFile = "_warps.txt"; - private static final String importFile = "_import.txt"; - private static File server_data; - private static File script_directory; - private static File wlkFolder; - - private static WLKInterface wlk = null; - - public static void setServerData(File folder) { - server_data = folder; - script_directory = new File(server_data, "npc/"); - wlkFolder = new File(server_data, "data/"); - wlk = new WLKInterface(); - } - - private static String getProp(Properties props, String name, String def) { - if (name == null) return def; - for (java.util.Map.Entry<Object, Object> entry : props.entrySet()) { - if (name.equalsIgnoreCase(entry.getKey().toString())) { - return entry.getValue().toString(); - } - } - return def; - } - - private static int getProp(Properties props, String name, int def) { - if (name == null) return def; - try { - return Integer.parseInt(getProp(props, name, "?")); - } catch (Exception e) {} - return def; - } - - private static int[] resolveBounds(Rectangle in, boolean warp) { - int x = in.x / 32; - int y = in.y / 32; - int width = in.width / 32; - int height = in.height / 32; - if (!warp) { - if (width > 1) --width; - if (height > 1) --height; - } - x += width / 2; - y += height / 2; - if (warp) { - width -= 2; - height -= 2; - } - return new int[]{x, y, width, height}; - } - - private static void handleWarp(PrintWriter out, String map, String name, Rectangle bounds, Properties props) { - if (out == null) return; - String dest = getProp(props, "dest_map", null); - if (dest == null) return; - int x = getProp(props, "dest_x", -1); - if (x < 0) return; - int y = getProp(props, "dest_y", -1); - if (y < 0) return; - int[] shape = resolveBounds(bounds, true); - System.out.printf("Usable warp found: %s\n", name); - out.printf("%s.gat,%d,%d" + SEPARATOR + "warp" + SEPARATOR + "%s" + SEPARATOR + "%d,%d,%s.gat,%d,%d\n", - map, shape[0], shape[1], name, shape[2], shape[3], dest, x / 32, y / 32); - } - - private static int handleMob(PrintWriter out, String map, String name, Rectangle bounds, Properties props) { - if (out == null) return -1; - int mob = getProp(props, "monster_id", -1); - if (mob < 0) return -1; - mob += 1002; - int max = getProp(props, "max_beings", 1); - int time1 = getProp(props, "eA_spawn", 0); - int time2 = getProp(props, "eA_death", 0); - int[] shape = resolveBounds(bounds, false); - System.out.printf("Usable mob found: %s (%d)\n", name, mob); - out.printf("%s.gat,%d,%d,%d,%d" + SEPARATOR + "monster" + SEPARATOR + "%s" + SEPARATOR + "%d,%d,%d,%d,Mob%s::On%d\n", - map, shape[0], shape[1], shape[2], shape[3], name, mob, max, time1, time2, map, mob); - return mob; - } - - private static void processObject(MapObject mo, String map, PrintWriter warpOut, PrintWriter mobOut, TreeSet<Integer> mobs) { - if (mo == null) return; - String name = mo.getName(); - String type = mo.getType(); - Rectangle bounds = new Rectangle(mo.getBounds()); - Properties props = mo.getProperties(); - - if (type.equalsIgnoreCase("warp")) { - handleWarp(warpOut, map, name, bounds, props); - } else if (type.equalsIgnoreCase("spawn")) { - mobs.add(handleMob(mobOut, map, name, bounds, props)); - } - } - - private static void processObjects(Iterator<MapObject> objs, String map, PrintWriter warpOut, PrintWriter mobOut, TreeSet<Integer> mobs) { - MapObject mo; - while (objs.hasNext()) { - mo = objs.next(); - if (mo == null) continue; - processObject(mo, map, warpOut, mobOut, mobs); - } - } - - private static void processFiles(File folder, List<String> out) { - for (File f : folder.listFiles()) { - if (f.isDirectory()) { - processFiles(folder, out); - } else if (!f.getName().equals(importFile)) { - out.add("npc: " + f.getPath().substring(server_data.getPath().length() + 1)); - } - } - } - - private static void makeInclude(String name, String title, File folder) { - File _import = new File(folder, importFile); - List<String> output_elements = new ArrayList<String>(); - processFiles(folder, output_elements); - PrintWriter importOut = Main.getWriter(_import); - importOut.printf("// Map %s: %s\n", name, title); - importOut.print("// This file is generated automatically. All manually changes will be removed when running the Converter.\n"); - importOut.printf("map: %s.gat\n", name); - Collections.sort(output_elements); - for (String s : output_elements) - if (!s.endsWith("~")) - importOut.print(s + "\n"); - importOut.flush(); - importOut.close(); - } - - public static String processMap(String name, Map map, File mapFile, PrintWriter summary) { - if (name == null) return null; - if (map == null) return null; - - Properties props = map.getProperties(); - String title = getProp(props, "name", "unnamed map " + name); - - String folderName = "npc/" + name; - - File folder = new File(script_directory, name); - - System.out.println(title); - - File wlkFile = new File(wlkFolder, name + ".wlk"); - - if (wlkFile.exists() && mapFile.lastModified() < wlkFile.lastModified()) { - System.out.println("Up to date, skipping"); - makeInclude(name, title, folder); - return folderName; - } - - if (summary != null) { - summary.printf("Name: %s: '%s'\n", name, title); - summary.printf("Music: '%s'\n", getProp(props, "music", "")); - summary.printf("Minimap: '%s'\n", getProp(props, "minimap", "")); - } - - if (wlk != null) wlk.write(name, map, wlkFile); - - PrintWriter warpOut = Main.getWriter(new File(folder, warpFile)); - PrintWriter mobOut = Main.getWriter(new File(folder, mobFile)); - - warpOut.print("// This file is generated automatically. All manually changes will be removed when running the Converter.\n"); - warpOut.printf("// %s warps\n\n", title); - mobOut.print("// This file is generated automatically. All manually changes will be removed when running the Converter.\n"); - mobOut.printf("// %s mobs\n\n", title); - - TreeSet<Integer> mobs = new TreeSet<Integer>(); - processObjects(map.getObjects(), name, warpOut, mobOut, mobs); - for (MapLayer layer : map) { - if (layer instanceof ObjectGroup) { - processObjects(((ObjectGroup) layer).getObjects(), name, warpOut, mobOut, mobs); - } - } - - warpOut.flush(); - warpOut.close(); - - System.out.println("Starting mob points"); - mobOut.printf("\n\n%s.gat,0,0,0" + SEPARATOR + "script" + SEPARATOR + "Mob%1$s" + SEPARATOR + "-1,{\n", name); - for (int mob : mobs) { - if (mob == -1) continue; - mobOut.printf("On%d:\n", mob); - mobOut.printf(INDENTATION + "set @mobID, %d;\n", mob); - mobOut.printf(INDENTATION + "callfunc \"MobPoints\";\n"); - mobOut.printf(INDENTATION + "end;\n\n"); - } - mobOut.printf(INDENTATION + "end;\n}\n"); - System.out.println("Finished mob points"); - - mobOut.flush(); - mobOut.close(); - - makeInclude(name, title, folder); - - return folderName; - } - - public static void writeMasterImport(ArrayList<String> folders) { - File master = new File(script_directory, importFile); - PrintWriter out = Main.getWriter(master); - if (out == null) return; - - List<String> output_elements = new ArrayList<String>(); - - output_elements.add("// This file is generated automatically. All manually changes will be removed when running the Converter.\n"); - for (String folder : folders) { - if (folder == null) continue; - output_elements.add("import: " + folder + "/_import.txt"); - } - - Collections.sort(output_elements); - for (String s : output_elements) - out.print(s + "\n"); - - out.flush(); - out.close(); - } -} diff --git a/tools/tmwcon/src/converter/WLKInterface.java b/tools/tmwcon/src/converter/WLKInterface.java deleted file mode 100644 index 29436fbf..00000000 --- a/tools/tmwcon/src/converter/WLKInterface.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Converter from Tiled .tmx files to tmwAthena .wlk and mob/warp scripts - * Copyright (c) 2008 Jared Adams - * Copyright (c) 2011 Ben Longbons - * License: GNU GPL, v2 or later - */ - -package converter; - -import java.io.*; - -import tiled.core.*; -import tiled.plugins.tmw.*; - -public class WLKInterface { - public WLKInterface() { - // See if the writer is available - WLKWriter.class.getName(); - } - - public void write(String name, Map map, File wlk) { - try { - wlk.createNewFile(); - WLKWriter.writeMap(map, new FileOutputStream(wlk)); - System.out.println("WLK written"); - } catch (Exception e) { - System.out.println("Problem writing WLK file:"); - e.printStackTrace(); - } - } -} diff --git a/tools/tmwcon/tiled-core.jar b/tools/tmwcon/tiled-core.jar Binary files differdeleted file mode 100644 index 78d44bc0..00000000 --- a/tools/tmwcon/tiled-core.jar +++ /dev/null diff --git a/tools/tmwcon/tmw.jar b/tools/tmwcon/tmw.jar Binary files differdeleted file mode 100644 index 2ffa74dc..00000000 --- a/tools/tmwcon/tmw.jar +++ /dev/null |