import java.awt.Container;
import java.awt.Dimension;
import java.awt.EventQueue;
+import java.awt.Graphics;
import java.awt.GraphicsEnvironment;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.image.BufferedImage;
import java.io.BufferedReader;
import java.io.File;
+import java.io.FileInputStream;
import java.io.FileNotFoundException;
+import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.net.HttpURLConnection;
+import java.net.MalformedURLException;
import java.net.URL;
import java.util.*;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLayeredPane;
+import javax.swing.JPanel;
import com.samskivert.swing.util.SwingUtil;
import com.threerings.getdown.data.*;
throw new IOException("m.java_download_failed");
}
+ // on Windows, if the local JVM is in use, we will not be able to replace it with an
+ // updated JVM; we detect this by attempting to rename the java.dll to its same name, which
+ // will fail on Windows for in use files; hackery!
+ File javaLocalDir = new File(_app.getAppDir(), LaunchUtil.LOCAL_JAVA_DIR+File.separator);
+ File javaDll = new File(javaLocalDir, "bin" + File.separator + "java.dll");
+ if (javaDll.exists()) {
+ if (!javaDll.renameTo(javaDll)) {
+ log.info("Cannot update local Java VM as it is in use.");
+ return;
+ }
+ log.info("Can update local Java VM as it is not in use.");
+ }
+
reportTrackingEvent("jvm_start", -1);
updateStatus("m.downloading_java");
if (_silent || (_container != null && !reinit)) {
return;
}
-
+/*
EventQueue.invokeLater(new Runnable() {
public void run () {
+*/
if (_container == null || reinit) {
if (_container == null) {
_container = createContainer();
}
configureContainer();
_layers = new JLayeredPane();
+
+
+
+ // added in the instant display of a splashscreen
+ try {
+ readConfig(false);
+ Graphics g = _container.getGraphics();
+ String imageFile = _ifc.backgroundImage;
+ BufferedImage bgImage = loadImage(_ifc.backgroundImage);
+ int bwidth = bgImage.getWidth();
+ int bheight = bgImage.getHeight();
+
+ instantSplashPane = new JPanel() {
+ @Override
+ protected void paintComponent(Graphics g)
+ {
+ super.paintComponent(g);
+ // attempt to draw a background image...
+ if (bgImage != null) {
+ g.drawImage(bgImage, 0, 0, this);
+ }
+ }
+ };
+
+ instantSplashPane.setSize(bwidth,bheight);
+ instantSplashPane.setPreferredSize(new Dimension(bwidth,bheight));
+
+ _layers.add(instantSplashPane, Integer.valueOf(0));
+
+ _container.setPreferredSize(new Dimension(bwidth,bheight));
+ } catch (Exception e) {
+ log.warning("Failed to set instant background image", "bg", _ifc.backgroundImage);
+ }
+
+
+
_container.add(_layers, BorderLayout.CENTER);
_patchNotes = new JButton(new AbstractAction(_msgs.getString("m.patch_notes")) {
@Override public void actionPerformed (ActionEvent event) {
_patchNotes.setFont(StatusPanel.FONT);
_layers.add(_patchNotes);
_status = new StatusPanel(_msgs);
- _layers.add(_status);
+ _layers.add(_status, Integer.valueOf(10));
initInterface();
}
showContainer();
+/*
}
});
+*/
}
/**
protected RotatingBackgrounds getBackground ()
{
- if (_ifc.rotatingBackgrounds != null) {
+ if (_ifc.rotatingBackgrounds != null && _ifc.rotatingBackgrounds.size() > 0) {
if (_ifc.backgroundImage != null) {
log.warning("ui.background_image and ui.rotating_background were both specified. " +
- "The rotating images are being used.");
+ "The background image is being used.");
}
- return new RotatingBackgrounds(_ifc.rotatingBackgrounds, _ifc.errorBackground,
- Getdown.this);
+ return new RotatingBackgrounds(_ifc.rotatingBackgrounds, _ifc.errorBackground, Getdown.this);
} else if (_ifc.backgroundImage != null) {
return new RotatingBackgrounds(loadImage(_ifc.backgroundImage));
} else {
}
};
- public void setStartupFilesFromParameterString(String p) {
- String q = "\"";
- if (p != null && p.length() > 0) {
- String[] filenames;
- if (p.startsWith(q) && p.endsWith(q)) {
- filenames = p.substring(1,p.length()-1).split("\" \"");
- } else {
- filenames = new String[]{p};
- }
- for (int i = 0; i < filenames.length; i++) {
- String filename = filenames[i];
- String ext = null;
- int j = filename.lastIndexOf('.');
- if (j > -1) {
- ext = filename.substring(j+1);
- }
- // jvp files
- if (ext.equals("jvp")) {
- File f = new File(filename);
- if (f.exists()) {
- _app.addStartupFile(f);
- }
- }
- // jvl files
- if (ext.equals("jvl")) {
- // Do stuff with the appbase here!
- }
- }
- }
- }
-
protected Application _app;
protected Application.UpdateInterface _ifc = new Application.UpdateInterface(Config.EMPTY);
protected ResourceBundle _msgs;
protected Container _container;
protected JLayeredPane _layers;
+ protected JPanel instantSplashPane;
protected StatusPanel _status;
protected JButton _patchNotes;
protected AbortPanel _abort;
protected static final int MAX_LOOPS = 5;
protected static final long FALLBACK_CHECK_TIME = 1000L;
+
}