summaryrefslogtreecommitdiff
path: root/tmwcon/src/converter/Main.java
diff options
context:
space:
mode:
authorBen Longbons <b.r.longbons@gmail.com>2012-07-11 14:16:02 -0700
committerBen Longbons <b.r.longbons@gmail.com>2012-07-19 11:04:33 -0700
commitca3569870496f8c6018c4394c22e36afdb84e369 (patch)
treecc6516b38af8f55ff1853990137189258486f968 /tmwcon/src/converter/Main.java
parent498038d2413f5f809c67f56b4fd7f2db6a96bc13 (diff)
downloadtools-ca3569870496f8c6018c4394c22e36afdb84e369.tar.gz
tools-ca3569870496f8c6018c4394c22e36afdb84e369.tar.bz2
tools-ca3569870496f8c6018c4394c22e36afdb84e369.tar.xz
tools-ca3569870496f8c6018c4394c22e36afdb84e369.zip
Add a tmx-to-wlk converter that handles CSV (in Python), and run it.
Some of the _mobs files changed due to bugs in the maps, which I fixed. Remove the old Java version.
Diffstat (limited to 'tmwcon/src/converter/Main.java')
-rw-r--r--tmwcon/src/converter/Main.java103
1 files changed, 0 insertions, 103 deletions
diff --git a/tmwcon/src/converter/Main.java b/tmwcon/src/converter/Main.java
deleted file mode 100644
index cb22677..0000000
--- a/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);
- }
-}