-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlib_ParseSceneList.js
74 lines (66 loc) · 2.08 KB
/
lib_ParseSceneList.js
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// KEEP UP-TO-DATE WITH PYTHON VERSION
function parseSceneList(lines)
{
var sceneList =
{
//Array of obj {scene: scene, type: type}
allScenes: new Array(),
afxScenes: new Array(),
flaScenes: new Array(),
swfScenes: new Array(),
manualScenes: new Array()
};
var insideBlock = true;
//Prepass to check if START is used later and block sholdn't start from first line
for (var i = 0; i < lines.length; i++)
{
var line = lines[i];
if (line === "START")
{
insideBlock = false;
break;
} else if (line === "END")
{
break;
}
}
for (var i = 0; i < lines.length; i++)
{
var line = lines[i];
//Toggle should scenes be read
if (!insideBlock && line === "START")
{
insideBlock = true;
continue;
}
else if (insideBlock && line === "END")
{
insideBlock = false;
continue;
}
if (!insideBlock) continue;
//Skip comments and empty lines
if (line.length === 0 || line.charAt(0) === "#") continue;
var sceneAndType = line.split(":", 2);
if (sceneAndType.length !== 2) throw "Scene list is malformed at line '" + i + "': expected scene:type."
switch(sceneAndType[1])
{
case "afx":
sceneList.afxScenes.push(sceneAndType[0]);
break;
case "fla":
sceneList.flaScenes.push(sceneAndType[0]);
break;
case "swf":
sceneList.swfScenes.push(sceneAndType[0]);
break;
case "man":
sceneList.manualScenes.push(sceneAndType[0]);
break;
default:
throw "Scene list is malformed at line '" + i + "': unknown scene type '" + sceneAndType[1] + "'";
}
sceneList.allScenes.push({name: sceneAndType[0], type: sceneAndType[1]});
}
return sceneList;
}