forked from dfabulich/choicescript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerator.js
More file actions
27 lines (22 loc) · 873 Bytes
/
generator.js
File metadata and controls
27 lines (22 loc) · 873 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
var dir = arguments[0] || "web/mygame/scenes";
load("web/scene.js");
load("web/util.js");
load("headless.js");
var list = new java.io.File(dir).listFiles();
var i = list.length;
while (i--) {
if (!/\.txt$/.test(list[i].getName())) continue;
var inputMod = list[i].lastModified();
var outputMod = new java.io.File(list[i].getAbsolutePath()+".js").lastModified();
if (inputMod <= outputMod) {
print(list[i] + " up to date");
continue;
}
print(list[i]);
var str = slurpFile(list[i]);
var scene = new Scene();
scene.loadLines(str);
var writer = new java.io.BufferedWriter(new java.io.OutputStreamWriter(new java.io.FileOutputStream(list[i].getAbsolutePath()+".js"), "UTF-8"));
writer.write("window.stats.scene.loadLinesFast(" + scene.temps.choice_crc + ", " + toJson(scene.lines)+ ", " + toJson(scene.labels) + ");");
writer.close();
}