X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fxwt%2FMain.java;h=590d126d0b3fa82f39527b50fb659d1f8a04a36f;hb=a81a151e639664cb340cf3726f9e8b9c77d125fb;hp=92d0b77bf256c57e7ee41822f08c5881fef5348b;hpb=37e6e2575609494ff0ef1714eee0c7cdf99e18e7;p=org.ibex.core.git diff --git a/src/org/xwt/Main.java b/src/org/xwt/Main.java index 92d0b77..590d126 100644 --- a/src/org/xwt/Main.java +++ b/src/org/xwt/Main.java @@ -1,4 +1,4 @@ -// 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.*; @@ -8,6 +8,7 @@ import java.awt.*; 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 { @@ -58,6 +59,7 @@ public class Main { else break; startargs++; } + /* FIXME final String instancename = args.length > startargs + 1 ? args[startargs + 1] : "main"; Platform.forceLoad(); @@ -65,17 +67,19 @@ public class Main { 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"; @@ -89,9 +93,10 @@ public class Main { 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"; } @@ -101,14 +106,22 @@ public class Main { 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; } @@ -118,7 +131,7 @@ public class Main { //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);