If specified, swap in a background image from ui.error_background in
getdown.txt or the errorbgimage param in the applet if getdown fails.
This commit is contained in:
@@ -65,7 +65,6 @@ import com.samskivert.util.ArrayIntSet;
|
|||||||
import com.samskivert.util.RunAnywhere;
|
import com.samskivert.util.RunAnywhere;
|
||||||
import com.samskivert.util.StringUtil;
|
import com.samskivert.util.StringUtil;
|
||||||
import com.threerings.getdown.Log;
|
import com.threerings.getdown.Log;
|
||||||
import com.threerings.getdown.launcher.MultipleGetdownRunning;
|
|
||||||
import com.threerings.getdown.launcher.RotatingBackgrounds;
|
import com.threerings.getdown.launcher.RotatingBackgrounds;
|
||||||
import com.threerings.getdown.util.ConfigUtil;
|
import com.threerings.getdown.util.ConfigUtil;
|
||||||
import com.threerings.getdown.util.FileUtil;
|
import com.threerings.getdown.util.FileUtil;
|
||||||
@@ -101,6 +100,9 @@ public class Application
|
|||||||
/** Background image specifiers for {@link RotatingBackgrounds}. */
|
/** Background image specifiers for {@link RotatingBackgrounds}. */
|
||||||
public String[] rotatingBackgrounds;
|
public String[] rotatingBackgrounds;
|
||||||
|
|
||||||
|
/** The error background image for {@link RotatingBackgrounds}. */
|
||||||
|
public String errorBackground;
|
||||||
|
|
||||||
/** The path (relative to the appdir) to a single background image. */
|
/** The path (relative to the appdir) to a single background image. */
|
||||||
public String backgroundImage;
|
public String backgroundImage;
|
||||||
|
|
||||||
@@ -582,6 +584,7 @@ public class Application
|
|||||||
}
|
}
|
||||||
ui.progressImage = (String)cdata.get("ui.progress_image");
|
ui.progressImage = (String)cdata.get("ui.progress_image");
|
||||||
ui.rotatingBackgrounds = ConfigUtil.getMultiValue(cdata, "ui.rotating_background");
|
ui.rotatingBackgrounds = ConfigUtil.getMultiValue(cdata, "ui.rotating_background");
|
||||||
|
ui.errorBackground = (String)cdata.get("ui.error_background");
|
||||||
_dockIconPath = (String)cdata.get("ui.mac_dock_icon");
|
_dockIconPath = (String)cdata.get("ui.mac_dock_icon");
|
||||||
if (_dockIconPath == null) {
|
if (_dockIconPath == null) {
|
||||||
_dockIconPath = "../desktop.icns"; // use a sensible default
|
_dockIconPath = "../desktop.icns"; // use a sensible default
|
||||||
|
|||||||
@@ -114,8 +114,7 @@ public abstract class Getdown extends Thread
|
|||||||
}
|
}
|
||||||
String errmsg = "The directory in which this application is installed:\n" + dir +
|
String errmsg = "The directory in which this application is installed:\n" + dir +
|
||||||
"\nis invalid. The directory must not contain the '!' character. Please reinstall.";
|
"\nis invalid. The directory must not contain the '!' character. Please reinstall.";
|
||||||
updateStatus(errmsg);
|
fail(errmsg);
|
||||||
_dead = true;
|
|
||||||
}
|
}
|
||||||
_app = new Application(appDir, appId, signers, useLocks());
|
_app = new Application(appDir, appId, signers, useLocks());
|
||||||
_startup = System.currentTimeMillis();
|
_startup = System.currentTimeMillis();
|
||||||
@@ -151,8 +150,7 @@ public abstract class Getdown extends Thread
|
|||||||
if (path.equals(".")) {
|
if (path.equals(".")) {
|
||||||
path = System.getProperty("user.dir");
|
path = System.getProperty("user.dir");
|
||||||
}
|
}
|
||||||
updateStatus(MessageUtil.tcompose("m.readonly_error", path));
|
fail(MessageUtil.tcompose("m.readonly_error", path));
|
||||||
_dead = true;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -186,8 +184,7 @@ public abstract class Getdown extends Thread
|
|||||||
"m.init_error", MessageUtil.taint(msg), _ifc.installError);
|
"m.init_error", MessageUtil.taint(msg), _ifc.installError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
updateStatus(msg);
|
fail(msg);
|
||||||
_dead = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -477,9 +474,8 @@ public abstract class Getdown extends Thread
|
|||||||
}
|
}
|
||||||
// Since we're dead, clear off the 'time remaining' label along with displaying the
|
// Since we're dead, clear off the 'time remaining' label along with displaying the
|
||||||
// error message
|
// error message
|
||||||
setStatus(msg, 0, -1L, true);
|
fail(msg);
|
||||||
_app.releaseLock();
|
_app.releaseLock();
|
||||||
_dead = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -775,10 +771,12 @@ public abstract class Getdown extends Thread
|
|||||||
/**
|
/**
|
||||||
* Creates our user interface, which we avoid doing unless we actually have to update
|
* Creates our user interface, which we avoid doing unless we actually have to update
|
||||||
* something.
|
* something.
|
||||||
|
*
|
||||||
|
* @param reinit - if the interface should be reinitialized if it already exists.
|
||||||
*/
|
*/
|
||||||
protected void createInterface (boolean force)
|
protected void createInterface (final boolean reinit)
|
||||||
{
|
{
|
||||||
if (_silent || (_container != null && !force)) {
|
if (_silent || (_container != null && !reinit)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -788,19 +786,29 @@ public abstract class Getdown extends Thread
|
|||||||
_container = createContainer();
|
_container = createContainer();
|
||||||
_status = new StatusPanel(_msgs);
|
_status = new StatusPanel(_msgs);
|
||||||
_container.add(_status, BorderLayout.CENTER);
|
_container.add(_status, BorderLayout.CENTER);
|
||||||
|
initInterface();
|
||||||
|
} else if (reinit) {
|
||||||
|
initInterface();
|
||||||
}
|
}
|
||||||
RotatingBackgrounds newBackgrounds = getBackground();
|
|
||||||
if (_background == null || newBackgrounds.getNumImages() > 0) {
|
|
||||||
// Leave the old _background in place if there is an ond one to leave in place
|
|
||||||
// and the new getdown.txt didn't yield any images.
|
|
||||||
_background = newBackgrounds;
|
|
||||||
}
|
|
||||||
_status.init(_ifc, _background, getProgressImage());
|
|
||||||
showContainer();
|
showContainer();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the interface with the current UpdateInterface and backgrounds.
|
||||||
|
*/
|
||||||
|
protected void initInterface ()
|
||||||
|
{
|
||||||
|
RotatingBackgrounds newBackgrounds = getBackground();
|
||||||
|
if (_background == null || newBackgrounds.getNumImages() > 0) {
|
||||||
|
// Leave the old _background in place if there is an old one to leave in place
|
||||||
|
// and the new getdown.txt didn't yield any images.
|
||||||
|
_background = newBackgrounds;
|
||||||
|
}
|
||||||
|
_status.init(_ifc, _background, getProgressImage());
|
||||||
|
}
|
||||||
|
|
||||||
protected RotatingBackgrounds getBackground ()
|
protected RotatingBackgrounds getBackground ()
|
||||||
{
|
{
|
||||||
if (_ifc.rotatingBackgrounds != null) {
|
if (_ifc.rotatingBackgrounds != null) {
|
||||||
@@ -808,7 +816,8 @@ public abstract class Getdown extends Thread
|
|||||||
Log.warning("ui.background_image and ui.rotating_background were both specified. " +
|
Log.warning("ui.background_image and ui.rotating_background were both specified. " +
|
||||||
"The rotating images are being used.");
|
"The rotating images are being used.");
|
||||||
}
|
}
|
||||||
return new RotatingBackgrounds(_ifc.rotatingBackgrounds, Getdown.this);
|
return new RotatingBackgrounds(_ifc.rotatingBackgrounds, _ifc.errorBackground,
|
||||||
|
Getdown.this);
|
||||||
} else if (_ifc.backgroundImage != null) {
|
} else if (_ifc.backgroundImage != null) {
|
||||||
return new RotatingBackgrounds(loadImage(_ifc.backgroundImage));
|
return new RotatingBackgrounds(loadImage(_ifc.backgroundImage));
|
||||||
} else {
|
} else {
|
||||||
@@ -837,6 +846,14 @@ public abstract class Getdown extends Thread
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the status to indicate getdown has failed for the reason in <code>message</code>.
|
||||||
|
*/
|
||||||
|
protected void fail(String message){
|
||||||
|
_dead = true;
|
||||||
|
setStatus(message, 0, -1L, true);
|
||||||
|
}
|
||||||
|
|
||||||
protected void setStatus (
|
protected void setStatus (
|
||||||
final String message, final int percent, final long remaining, boolean createUI)
|
final String message, final int percent, final long remaining, boolean createUI)
|
||||||
{
|
{
|
||||||
@@ -847,13 +864,17 @@ public abstract class Getdown extends Thread
|
|||||||
EventQueue.invokeLater(new Runnable() {
|
EventQueue.invokeLater(new Runnable() {
|
||||||
public void run () {
|
public void run () {
|
||||||
if (_status == null) {
|
if (_status == null) {
|
||||||
Log.info("Dropping status '" + message + "'.");
|
if (message != null) {
|
||||||
|
Log.info("Dropping status '" + message + "'.");
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (message != null) {
|
if (message != null) {
|
||||||
_status.setStatus(message);
|
_status.setStatus(message, _dead);
|
||||||
}
|
}
|
||||||
if (percent >= 0) {
|
if (_dead) {
|
||||||
|
_status.setProgress(0, -1L);
|
||||||
|
} else if (percent >= 0) {
|
||||||
_status.setProgress(percent, remaining);
|
_status.setProgress(percent, remaining);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,7 +50,8 @@ public class GetdownApplet extends JApplet
|
|||||||
// signer
|
// signer
|
||||||
String appbase = getParameter("appbase");
|
String appbase = getParameter("appbase");
|
||||||
String appname = getParameter("appname");
|
String appname = getParameter("appname");
|
||||||
String imgpath = getParameter("bgimage");;
|
String imgpath = getParameter("bgimage");
|
||||||
|
String errorimgpath = getParameter("errorbgimage");
|
||||||
if (appbase == null) {
|
if (appbase == null) {
|
||||||
appbase = "";
|
appbase = "";
|
||||||
}
|
}
|
||||||
@@ -62,7 +63,7 @@ public class GetdownApplet extends JApplet
|
|||||||
if (imgpath == null) {
|
if (imgpath == null) {
|
||||||
bgimages = new RotatingBackgrounds();
|
bgimages = new RotatingBackgrounds();
|
||||||
} else if (imgpath.indexOf(",") > -1) {
|
} else if (imgpath.indexOf(",") > -1) {
|
||||||
bgimages = new RotatingBackgrounds(imgpath.split(","), this);
|
bgimages = new RotatingBackgrounds(imgpath.split(","), errorimgpath, this);
|
||||||
} else {
|
} else {
|
||||||
bgimages = new RotatingBackgrounds(loadImage(imgpath));
|
bgimages = new RotatingBackgrounds(loadImage(imgpath));
|
||||||
}
|
}
|
||||||
@@ -159,7 +160,7 @@ public class GetdownApplet extends JApplet
|
|||||||
public void start ()
|
public void start ()
|
||||||
{
|
{
|
||||||
if (_errmsg != null) {
|
if (_errmsg != null) {
|
||||||
_getdown.updateStatus(_errmsg);
|
_getdown.fail(_errmsg);
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
_getdown.start();
|
_getdown.start();
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ public class RotatingBackgrounds
|
|||||||
percentages = new int[] { 0 };
|
percentages = new int[] { 0 };
|
||||||
minDisplayTime = new int[] { 0 };
|
minDisplayTime = new int[] { 0 };
|
||||||
images = new Image[] { background };
|
images = new Image[] { background };
|
||||||
|
errorImage = images[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -32,7 +33,7 @@ public class RotatingBackgrounds
|
|||||||
* time when the next should be shown. In that case, it's left up until its been there for its
|
* time when the next should be shown. In that case, it's left up until its been there for its
|
||||||
* minimum display time and then the next one gets to come up.
|
* minimum display time and then the next one gets to come up.
|
||||||
*/
|
*/
|
||||||
public RotatingBackgrounds (String[] backgrounds, ImageLoader loader)
|
public RotatingBackgrounds (String[] backgrounds, String errorBackground, ImageLoader loader)
|
||||||
{
|
{
|
||||||
percentages = new int[backgrounds.length];
|
percentages = new int[backgrounds.length];
|
||||||
minDisplayTime = new int[backgrounds.length];
|
minDisplayTime = new int[backgrounds.length];
|
||||||
@@ -55,6 +56,11 @@ public class RotatingBackgrounds
|
|||||||
}
|
}
|
||||||
percentages[ii] = (int)((ii/(float)backgrounds.length) * 100);
|
percentages[ii] = (int)((ii/(float)backgrounds.length) * 100);
|
||||||
}
|
}
|
||||||
|
if (errorBackground == null) {
|
||||||
|
errorImage = images[0];
|
||||||
|
} else {
|
||||||
|
errorImage = loader.loadImage(errorBackground);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -75,6 +81,14 @@ public class RotatingBackgrounds
|
|||||||
return images[current];
|
return images[current];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the image to display if an error has caused getdown to fail.
|
||||||
|
*/
|
||||||
|
public Image getErrorImage ()
|
||||||
|
{
|
||||||
|
return errorImage;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the number of images in this RotatingBackgrounds
|
* @return the number of images in this RotatingBackgrounds
|
||||||
*/
|
*/
|
||||||
@@ -97,6 +111,9 @@ public class RotatingBackgrounds
|
|||||||
|
|
||||||
protected Image[] images;
|
protected Image[] images;
|
||||||
|
|
||||||
|
/** The image to display if getdown has failed due to an error. */
|
||||||
|
protected Image errorImage;
|
||||||
|
|
||||||
/** Percentage at which each image should be displayed. */
|
/** Percentage at which each image should be displayed. */
|
||||||
protected int[] percentages;
|
protected int[] percentages;
|
||||||
|
|
||||||
|
|||||||
@@ -113,8 +113,9 @@ public class StatusPanel extends JComponent
|
|||||||
/**
|
/**
|
||||||
* Displays the specified status string.
|
* Displays the specified status string.
|
||||||
*/
|
*/
|
||||||
public void setStatus (String status)
|
public void setStatus (String status, boolean displayError)
|
||||||
{
|
{
|
||||||
|
_displayError = displayError;
|
||||||
status = xlate(status);
|
status = xlate(status);
|
||||||
_newlab = new Label(status, _ifc.statusText, _font);
|
_newlab = new Label(status, _ifc.statusText, _font);
|
||||||
_newlab.setTargetWidth(Math.min(_ifc.status.width, getWidth() - _ifc.status.x*2));
|
_newlab.setTargetWidth(Math.min(_ifc.status.width, getWidth() - _ifc.status.x*2));
|
||||||
@@ -131,7 +132,12 @@ public class StatusPanel extends JComponent
|
|||||||
super.paintComponent(g);
|
super.paintComponent(g);
|
||||||
Graphics2D gfx = (Graphics2D)g;
|
Graphics2D gfx = (Graphics2D)g;
|
||||||
|
|
||||||
Image img = _bg.getImage(_progress);
|
Image img;
|
||||||
|
if (_displayError) {
|
||||||
|
img = _bg.getErrorImage();
|
||||||
|
} else {
|
||||||
|
img = _bg.getImage(_progress);
|
||||||
|
}
|
||||||
if (img != null) {
|
if (img != null) {
|
||||||
gfx.drawImage(img, 0, 0, null);
|
gfx.drawImage(img, 0, 0, null);
|
||||||
} else {
|
} else {
|
||||||
@@ -263,6 +269,7 @@ public class StatusPanel extends JComponent
|
|||||||
protected ResourceBundle _msgs;
|
protected ResourceBundle _msgs;
|
||||||
|
|
||||||
protected int _progress = 0;
|
protected int _progress = 0;
|
||||||
|
protected boolean _displayError;
|
||||||
protected Label _label, _newlab;
|
protected Label _label, _newlab;
|
||||||
protected Label _plabel, _newplab;
|
protected Label _plabel, _newplab;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user