-// Copyright 2002 Adam Megacz, see the COPYING file for licensing [GPL]
+// Copyright 2003 Adam Megacz, see the COPYING file for licensing [GPL]
package org.xwt;
import java.net.*;
import org.bouncycastle.util.encoders.Base64;
import org.xwt.js.*;
import org.xwt.util.*;
+import org.xwt.translators.*;
/** Entry point for the XWT Engine; handles splash screen, initial xwar loading, and argument processing */
public class Main {
else break;
startargs++;
}
+ /* FIXME
final String instancename = args.length > startargs + 1 ? args[startargs + 1] : "main";
Platform.forceLoad();
InputStream is = Platform.getBuiltinInputStream();
if (is == null) Platform.criticalAbort("unable to load builtin.xwar");
- Resources.loadArchive(is);
if (Log.on) Log.log(Main.class, "loading scar image");
PNG png = PNG.decode(new ByteArrayInputStream(Resources.getResource("org.xwt.builtin.scar.png")), "bundled scar image");
Surface.scarPicture = Platform.createPicture(png.getData(), png.getWidth(), png.getHeight());
String initialTemplate = "main";
+ Res initialRR = null;
+ // FIXME: after applying initial template, check numsurfaces; if zero, exit
if (args.length > startargs) {
if (args[startargs].startsWith("http://")) {
if (Log.on) Log.log(Main.class, "downloading xwar");
+ initialRR = Res.stringToRes("file:" + args[startargs] + "!");
origin = args[startargs];
initialTemplate = "org.xwt.builtin.splash";
File f = new File(args[startargs]);
origin = "file:" + f.getAbsolutePath();
if (f.isDirectory()) {
- Resources.loadDirectory(f);
+ initialRR = Res.stringToRes("file:" + args[startargs]);
Surface.scarAllSurfacesFromNowOn = true;
} else {
+ initialRR = Res.stringToRes("file:" + args[startargs] + "!");
initialTemplate = "org.xwt.builtin.splash";
}
if (Log.on) Log.log(Main.class, "instantiating " + initialTemplate);
final String initialTemplate_f = initialTemplate;
+ final Res initialRR_f = initialRR;
ThreadMessage.newthread(new JS.Callable() {
public Object call(JS.Array args) throws JS.Exn {
Box b = new Box();
- Template.getTemplate(initialTemplate_f, null).apply(b, null, null, null, 0, 0);
- doneInitializing = true;
- if (Surface.allSurfaces.size() == 0) {
- Log.log(this, "exiting because all surfaces are gone");
- Platform.exit();
+ try {
+ Template t = Template.buildTemplate(Res.stringToRes("file:.").getInputStream(), "RESOURCE");
+ t.apply(b, (Vec)null, (Vec)null, (JS.Callable)null, 0, 0, initialRR_f);
+ //FIXME
+ //Template.getTemplate(initialTemplate_f, null).apply(b, (Vec)null, (Vec)null, (JS.Callable)null, 0, 0, initialRR_f);
+ doneInitializing = true;
+ if (Surface.allSurfaces.size() == 0) {
+ Log.log(this, "exiting because all surfaces are gone");
+ Platform.exit();
+ }
+ } catch (Exception e) {
+ Log.log(Main.class, e);
}
return null;
}
//if (Log.on) Log.log(Main.class, "main thread blocking on new semaphore");
//new org.xwt.util.Semaphore().block();
Platform.running();
-
+ */
} catch (Throwable e) {
e.printStackTrace();
Platform.criticalAbort("exception in Main.main(): " + e);