summaryrefslogtreecommitdiff
path: root/tmwcon/src/converter
diff options
context:
space:
mode:
Diffstat (limited to 'tmwcon/src/converter')
-rw-r--r--tmwcon/src/converter/Main.java42
-rw-r--r--tmwcon/src/converter/Process.java37
-rw-r--r--tmwcon/src/converter/WLKInterface.java2
3 files changed, 36 insertions, 45 deletions
diff --git a/tmwcon/src/converter/Main.java b/tmwcon/src/converter/Main.java
index 80dfe30..ab7786a 100644
--- a/tmwcon/src/converter/Main.java
+++ b/tmwcon/src/converter/Main.java
@@ -66,45 +66,35 @@ public class Main {
return name;
}
- public static void run(String[] args, int unused) {
- reader = new XMLMapTransformer();
+ 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);
+ }
- PrintWriter summary = null;
+ File client_data = new File(args[0]);
+ File server_data = new File(args[1]);
- try {
- File temp = new File("summary.txt");
- temp.createNewFile();
- summary = new PrintWriter(temp);
- } catch (Exception e) {
- System.out.println("Problem opening summary file for writing:");
- e.printStackTrace();
- }
+ reader = new XMLMapTransformer();
+
+ PrintWriter summary = new PrintWriter("converter.txt");
- File folder = new File("server-data/data/");
- folder.mkdirs();
- Process.prepWLK(folder);
+ Process.setServerData(server_data);
- folder = new File("tmwdata/maps/");
+ File folder = new File(client_data, "maps/");
Collection<File> tmxs = getTMXFiles(folder);
- Vector<String> folders = new Vector<String>();
+ ArrayList<String> folders = new ArrayList<String>();
String name;
for (File f : tmxs) {
name = getName(folder, f);
System.out.printf("== %s ==\n", name);
- if (summary != null) summary.printf("== %s ==\n", name);
folders.add(Process.processMap(name, loadMap(f), f, summary));
}
- if (summary != null) {
- summary.flush();
- summary.close();
- }
-
- Process.writeMasterImport(folders.toArray(new String[0]));
- }
+ summary.flush();
+ summary.close();
- public static void main(String[] args) {
- run(args, 0);
+ Process.writeMasterImport(folders);
}
}
diff --git a/tmwcon/src/converter/Process.java b/tmwcon/src/converter/Process.java
index 92fa3da..ab2eb80 100644
--- a/tmwcon/src/converter/Process.java
+++ b/tmwcon/src/converter/Process.java
@@ -18,21 +18,20 @@ import tiled.core.*;
import tiled.plugins.tmw.*;
public class Process {
- private static final String baseFolder = "server-data/";
- private static final File _baseFolder = new File(baseFolder);
- private static final String scriptDirectory = "npc/";
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 prepWLK(File folder) {
- wlkFolder = folder;
- try {
- wlk = new WLKInterface();
- } catch (NoClassDefFoundError ncdfe) {}
+ 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) {
@@ -81,7 +80,8 @@ public class Process {
if (y < 0) return;
int[] shape = resolveBounds(bounds, true);
System.out.printf("Usable warp found: %s\n", name);
- out.printf("%s.gat,%d,%d\twarp\t%s\t%d,%d,%s.gat,%d,%d\n", map, shape[0], shape[1], name, shape[2], shape[3], dest, x / 32, y / 32);
+ out.printf("%s.gat,%d,%d\twarp\t%s\t%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) {
@@ -94,7 +94,8 @@ public class Process {
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\tmonster\t%s\t%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);
+ out.printf("%s.gat,%d,%d,%d,%d\tmonster\t%s\t%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;
}
@@ -126,7 +127,7 @@ public class Process {
if (f.isDirectory()) {
processFiles(folder, out);
} else if (!f.getName().equals(importFile)) {
- out.add("npc: " + f.getPath().substring(_baseFolder.getPath().length() + 1));
+ out.add("npc: " + f.getPath().substring(server_data.getPath().length() + 1));
}
}
}
@@ -137,7 +138,8 @@ public class Process {
processFiles(folder, output_elements);
PrintWriter importOut = Main.getWriter(_import);
importOut.printf("// Map %s: %s\n", name, title);
- importOut.printf("// This file is generated automatically. All manually changes will be removed when running the Converter.\nmap: %s.gat\n", name);
+ importOut.printf("// 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)
importOut.println(s);
@@ -152,10 +154,9 @@ public class Process {
Properties props = map.getProperties();
String title = getProp(props, "name", "");
- String folderName = scriptDirectory + name;
+ String folderName = "npc/" + name;
- File folder = new File(baseFolder + folderName);
- folder.mkdirs();
+ File folder = new File(script_directory, name);
System.out.println(title);
@@ -209,8 +210,8 @@ public class Process {
return folderName;
}
- public static void writeMasterImport(String[] folders) {
- File master = new File(baseFolder + scriptDirectory + "_import.txt");
+ public static void writeMasterImport(ArrayList<String> folders) {
+ File master = new File(script_directory, importFile);
PrintWriter out = Main.getWriter(master);
if (out == null) return;
@@ -224,7 +225,7 @@ public class Process {
Collections.sort(output_elements);
for (String s : output_elements)
- out.println(s);
+ out.println(s);
out.flush();
out.close();
diff --git a/tmwcon/src/converter/WLKInterface.java b/tmwcon/src/converter/WLKInterface.java
index b9e0cb2..1673524 100644
--- a/tmwcon/src/converter/WLKInterface.java
+++ b/tmwcon/src/converter/WLKInterface.java
@@ -22,7 +22,7 @@ public class WLKInterface {
WLKWriter.writeMap(map, new FileOutputStream(wlk));
System.out.println("WLK written");
} catch (Exception e) {
- System.out.println("Prolem writing WLK file:");
+ System.out.println("Problem writing WLK file:");
e.printStackTrace();
}
}