summaryrefslogtreecommitdiff
path: root/tools/tmwcon/src/converter/Process.java
diff options
context:
space:
mode:
Diffstat (limited to 'tools/tmwcon/src/converter/Process.java')
-rw-r--r--tools/tmwcon/src/converter/Process.java37
1 files changed, 19 insertions, 18 deletions
diff --git a/tools/tmwcon/src/converter/Process.java b/tools/tmwcon/src/converter/Process.java
index 92fa3da4..ab2eb801 100644
--- a/tools/tmwcon/src/converter/Process.java
+++ b/tools/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();