2002/06/05 22:14:14
[org.ibex.core.git] / src / org / xwt / Main.java
index f96bdf1..3faf54f 100644 (file)
@@ -94,6 +94,8 @@ public class Main extends Applet {
                     if (Log.on) Log.log(Main.class, "downloading xwar");
                     origin = args[startargs];
                     URL u = new URL(args[startargs]);
+                    if (!u.getFile().endsWith(".xwar"))
+                        Platform.criticalAbort("archive filenames must end with \".xwar\"");
                     try {
                         originAddr = InetAddress.getByName(u.getHost());
                         // FIXME: use XMLRPC resolver?
@@ -111,12 +113,32 @@ public class Main extends Applet {
                     File f = new File(args[startargs]);
                     origin = "file://" + f.getAbsolutePath();
                     if (f.isDirectory()) Resources.loadDirectory(f);
-                    else Resources.loadArchive(new FileInputStream(f));
+                    else {
+                        if (!args[startargs].endsWith(".xwar"))
+                            Platform.criticalAbort("archive filenames must end with \".xwar\"");
+                        Resources.loadArchive(new FileInputStream(f));
+                    }
                 }
             }
 
             if (Log.on) Log.log(Main.class, "done loading initial xwar");
             doneDownloading = true;
+
+            MessageQueue.add(new Message() {
+                    public void perform() {
+                        Picture splash = Box.getPicture("splash");
+                        if (splash != null) {
+                            SplashScreen.splashScreenPicture = splash;
+                            SplashScreen.surf.backbuffer.drawPicture(splash, 0, 0,
+                                                                     SplashScreen.surf.backbuffer.getWidth(), SplashScreen.surf.backbuffer.getHeight(),
+                                                                     0, 0, splash.getWidth(), splash.getHeight());
+                            SplashScreen.surf.blit(SplashScreen.surf.backbuffer, 0, 0, 0, 0,
+                                                   SplashScreen.surf.backbuffer.getWidth(), SplashScreen.surf.backbuffer.getHeight());
+                            updateSplashScreen();
+                        }
+                    }
+                });
+
             initialTemplate = Template.getTemplate(instancename, null);
 
             MessageQueue.add(new Message() {
@@ -145,8 +167,9 @@ public class Main extends Applet {
 
     /** encapsulates the splash screen */
     private static class SplashScreen {
-        static Surface surf;
-        
+        public static Surface surf;
+        public static Picture splashScreenPicture;
+
         // the position of the progress bar on the splash screen
         static int barX = 5;
         static int barY = 0;
@@ -195,7 +218,13 @@ public class Main extends Applet {
 
             int barPos;
 
-            surf.backbuffer.drawPicture(splashScreenPicture, barX, barY - 20, barX + barW, barY + barH, barX, barY - 20, barX + barW, barY + barH);
+            surf.backbuffer.setClip(barX, barY - 20, barX + barW, barY + barH);
+            surf.backbuffer.drawPicture(splashScreenPicture, 0, 0,
+                                        surf.backbuffer.getWidth(), surf.backbuffer.getHeight(),
+                                        0, 0, splashScreenPicture.getWidth(), splashScreenPicture.getHeight());
+            surf.backbuffer.drawPicture(splashScreenPicture, 0, 0);
+            surf.backbuffer.setClip(0, 0, surf.backbuffer.getWidth(), surf.backbuffer.getHeight());
+
             if (!doneDownloading) {
                 float z = (float)barW / (float)2.0;
                 float x = (float) (  ((float)Resources.bytesDownloaded) / 5000000.0   );
@@ -234,8 +263,6 @@ public class Main extends Applet {
             //surf = null;
         }
 
-        private static Picture splashScreenPicture;
-
         private static String splashScreen_gif_base64_1 =
             "R0lGODlhigEUAecAAAICCBIWEi4yLkZKRhoeGj5CPgICJhIWUiYqJjo+OgYEOg4WTjI2Mg4S" +
             "EQ4OXwoODR4iHlJWVDY6NgICDgkGThYeXiouKgoSQhIWSk5STg4OJkJGQiImIhceWgICEgQC" +