summaryrefslogtreecommitdiff
path: root/NET/worlds/scape/MultiManifestAction.java
diff options
context:
space:
mode:
authorFuwn <[email protected]>2026-02-12 22:33:32 -0800
committerFuwn <[email protected]>2026-02-12 22:33:32 -0800
commitc7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9 (patch)
treedf9f48bf128a6c0186a8e91857d6ff30fe0e9f18 /NET/worlds/scape/MultiManifestAction.java
downloadworldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.tar.xz
worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.zip
Initial commit
Diffstat (limited to 'NET/worlds/scape/MultiManifestAction.java')
-rw-r--r--NET/worlds/scape/MultiManifestAction.java112
1 files changed, 112 insertions, 0 deletions
diff --git a/NET/worlds/scape/MultiManifestAction.java b/NET/worlds/scape/MultiManifestAction.java
new file mode 100644
index 0000000..4852d36
--- /dev/null
+++ b/NET/worlds/scape/MultiManifestAction.java
@@ -0,0 +1,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();
+ }
+}