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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
package NET.worlds.scape;
import NET.worlds.console.Console;
import NET.worlds.network.URL;
import java.io.File;
import java.io.IOException;
public class MultiManifestAction extends Action implements LoadedURLSelf {
private String _directory;
private static Object classCookie = new Object();
private String[] _files;
private File _dir;
private int _curFile;
private String _file;
@Override
public Object properties(int index, int offset, int mode, Object value) throws NoSuchPropertyException {
Object ret = null;
switch (index - offset) {
case 0:
if (mode == 0) {
ret = StringPropertyEditor.make(new Property(this, index, "Directory"));
} else if (mode == 1) {
if (this._directory == null) {
this._directory = new String();
}
ret = new String(this._directory);
} else if (mode == 2) {
this._directory = ((String)value).trim();
}
break;
default:
ret = super.properties(index, offset + 1, mode, value);
}
return ret;
}
@Override
public void saveState(Saver s) throws IOException {
s.saveVersion(0, classCookie);
super.saveState(s);
s.saveString(this._directory);
}
@Override
public void restoreState(Restorer r) throws IOException, TooNewException {
switch (r.restoreVersion(classCookie)) {
case 0:
super.restoreState(r);
this._directory = r.restoreString();
return;
default:
throw new TooNewException();
}
}
@Override
public Persister trigger(Event e, Persister seqId) {
if (seqId == null) {
System.out.println("MMAState:starting");
this._dir = new File(this._directory);
this._files = this._dir.list(new ExtensionFilter(".world"));
this._curFile = 0;
this.startFile();
}
return this._curFile >= this._files.length ? null : this;
}
public void startFile() {
if (this._curFile >= this._files.length) {
System.out.println("MMAState:Done");
} else {
this._file = new File(this._dir, this._files[this._curFile]).getAbsolutePath();
System.out.println("MMAState:Loading: " + this._file);
World.load(URL.make(this._file), this);
}
}
@Override
public void loadedURLSelf(URLSelf o, URL url, String err) {
if (err == null && o instanceof World) {
World w = (World)o;
String mftname = this._file.substring(0, this._file.lastIndexOf(".world")) + ".mft";
System.out.println("MMAState:Manifesting: " + mftname);
try {
Manifest mft = new Manifest(mftname);
mft.saveProps(w);
mft.done();
} catch (Exception var7) {
var7.printStackTrace(System.out);
}
if (w != Pilot.getActive().getWorld()) {
w.discard();
}
} else {
if (err == null) {
err = Console.message("No-contain-world");
o.decRef();
}
Console.println(Console.message("Cant-load-remote") + url + "' ");
}
this._curFile++;
this.startFile();
}
}
|