diff --git a/src/java/com/threerings/getdown/data/Application.java b/src/java/com/threerings/getdown/data/Application.java index 8575eb0..fdb4d9b 100644 --- a/src/java/com/threerings/getdown/data/Application.java +++ b/src/java/com/threerings/getdown/data/Application.java @@ -1,5 +1,5 @@ // -// $Id: Application.java,v 1.17 2004/07/26 21:24:59 mdb Exp $ +// $Id: Application.java,v 1.18 2004/07/26 22:57:03 mdb Exp $ package com.threerings.getdown.data; @@ -59,19 +59,22 @@ public class Application public Rectangle progress; /** The color of the progress text. */ - public Color progressText; + public Color progressText = Color.black; /** The color of the progress bar. */ - public Color progressBar; + public Color progressBar = new Color(0x6699CC); /** The dimensions of the status display. */ public Rectangle status; /** The color of the status text. */ - public Color statusText; + public Color statusText = Color.black; /** The path (relative to the appdir) to the background image. */ public String background; + + /** The color of the text shadow. */ + public Color textShadow; } /** Used by {@link #verifyMetadata} to communicate status in @@ -273,17 +276,14 @@ public class Application // parse and return our application config UpdateInterface ui = new UpdateInterface(); ui.name = (String)cdata.get("ui.name"); - ui.progress = parseRect( - "ui.progress", (String)cdata.get("ui.progress")); + ui.progress = parseRect(cdata, "ui.progress"); ui.progressText = parseColor( - "ui.progress_text", (String)cdata.get("ui.progress_text"), - Color.white); + cdata, "ui.progress_text", ui.progressText); ui.progressBar = parseColor( - "ui.progress_bar", (String)cdata.get("ui.progress_bar"), - new Color(0x6699CC)); - ui.status = parseRect("ui.progress", (String)cdata.get("ui.status")); - ui.statusText = parseColor( - "ui.status_text", (String)cdata.get("ui.status_text"), Color.white); + cdata, "ui.progress_bar", ui.progressBar); + ui.status = parseRect(cdata, "ui.progress"); + ui.statusText = parseColor(cdata, "ui.status_text", ui.statusText); + ui.textShadow = parseColor(cdata, "ui.text_shadow", ui.textShadow); ui.background = (String)cdata.get("ui.background"); return ui; } @@ -649,8 +649,9 @@ public class Application } /** Used to parse rectangle specifications from the config file. */ - protected Rectangle parseRect (String name, String value) + protected Rectangle parseRect (HashMap cdata, String name) { + String value = (String)cdata.get(name); if (!StringUtil.blank(value)) { int[] v = StringUtil.parseIntArray(value); if (v != null && v.length == 4) { @@ -664,8 +665,9 @@ public class Application } /** Used to parse color specifications from the config file. */ - protected Color parseColor (String name, String value, Color defcolor) + protected Color parseColor (HashMap cdata, String name, Color defcolor) { + String value = (String)cdata.get(name); if (!StringUtil.blank(value)) { try { return new Color(Integer.parseInt(value, 16)); diff --git a/src/java/com/threerings/getdown/launcher/Getdown.java b/src/java/com/threerings/getdown/launcher/Getdown.java index cc967e9..2a44843 100644 --- a/src/java/com/threerings/getdown/launcher/Getdown.java +++ b/src/java/com/threerings/getdown/launcher/Getdown.java @@ -1,5 +1,5 @@ // -// $Id: Getdown.java,v 1.17 2004/07/26 21:24:59 mdb Exp $ +// $Id: Getdown.java,v 1.18 2004/07/26 22:57:03 mdb Exp $ package com.threerings.getdown.launcher; @@ -44,13 +44,33 @@ public class Getdown extends Thread public Getdown (File appDir) { super("Getdown"); + try { + _msgs = ResourceBundle.getBundle("com.threerings.getdown.messages"); + } catch (Exception e) { + // welcome to hell, where java can't cope with a classpath + // that contains jars that live in a directory that contains a + // !, at least the same bug happens on all platforms + String dir = appDir.toString(); + if (dir.equals(".")) { + dir = System.getProperty("user.dir"); + } + String errmsg = "The directory in which this application is " + + "installed:\n" + dir + "\nis invalid. The directory " + + "must not contain the '!' character. Please reinstall."; + updateStatus(errmsg); + } _app = new Application(appDir); - _msgs = ResourceBundle.getBundle("com.threerings.getdown.messages"); _startup = System.currentTimeMillis(); } public void run () { + // if we have no messages, just bail because we're hosed; the + // error message will be displayed to the user already + if (_msgs == null) { + return; + } + try { // first parses our application deployment file try { @@ -316,17 +336,15 @@ public class Getdown extends Thread System.exit(-1); } -// // tee our output into a file in the application directory -// File log = new File(appDir, "getdown.log"); -// try { -// FileOutputStream fout = new FileOutputStream(log); -// System.setOut(new PrintStream( -// new TeeOutputStream(System.out, fout))); -// System.setErr(new PrintStream( -// new TeeOutputStream(System.err, fout))); -// } catch (IOException ioe) { -// Log.warning("Unable to redirect output to '" + log + "': " + ioe); -// } + // pipe our output into a file in the application directory + File log = new File(appDir, "launcher.log"); + try { + FileOutputStream fout = new FileOutputStream(log); + System.setOut(new PrintStream(fout)); + System.setErr(new PrintStream(fout)); + } catch (IOException ioe) { + Log.warning("Unable to redirect output to '" + log + "': " + ioe); + } try { Getdown app = new Getdown(appDir); diff --git a/src/java/com/threerings/getdown/launcher/StatusPanel.java b/src/java/com/threerings/getdown/launcher/StatusPanel.java index 146ce81..db746d2 100644 --- a/src/java/com/threerings/getdown/launcher/StatusPanel.java +++ b/src/java/com/threerings/getdown/launcher/StatusPanel.java @@ -1,5 +1,5 @@ // -// $Id: StatusPanel.java,v 1.10 2004/07/26 18:59:00 mdb Exp $ +// $Id: StatusPanel.java,v 1.11 2004/07/26 22:57:03 mdb Exp $ package com.threerings.getdown.launcher; @@ -81,8 +81,10 @@ public class StatusPanel extends JComponent String label = MessageFormat.format(msg, new Object[] { new Integer(percent), remstr }); _newplab = new Label(label, _ifc.progressText, _font); - _newplab.setAlternateColor(_shadow); - _newplab.setStyle(Label.SHADOW); + if (_ifc.textShadow != null) { + _newplab.setAlternateColor(_ifc.textShadow); + _newplab.setStyle(Label.SHADOW); + } repaint(); } @@ -94,8 +96,10 @@ public class StatusPanel extends JComponent status = xlate(status); _newlab = new Label(status, _ifc.statusText, _font); _newlab.setTargetWidth(_spos.width); - _newlab.setAlternateColor(_shadow); - _newlab.setStyle(Label.SHADOW); + if (_ifc.textShadow != null) { + _newlab.setAlternateColor(_ifc.textShadow); + _newlab.setStyle(Label.SHADOW); + } repaint(); } @@ -108,6 +112,7 @@ public class StatusPanel extends JComponent if (_bgimg != null) { gfx.drawImage(_bgimg, 0, 0, null); } else { + gfx.setColor(getBackground()); gfx.fillRect(0, 0, getWidth(), getHeight()); } @@ -196,6 +201,14 @@ public class StatusPanel extends JComponent /** Used by {@link #setStatus}, and {@link #setProgress}. */ protected String get (String key) { + // if we have no _msgs that means we're probably recovering from a + // failure to load the translation messages in the first place, so + // just give them their key back because it's probably an english + // string; whee! + if (_msgs == null) { + return key; + } + // if this string is tainted, we don't translate it, instead we // simply remove the taint character and return it to the caller if (key.startsWith(MessageUtil.TAINT_CHAR)) { @@ -219,7 +232,6 @@ public class StatusPanel extends JComponent protected Label _label, _newlab; protected Label _plabel, _newplab; - protected Color _shadow = new Color(0x16486D); protected UpdateInterface _ifc; protected long[] _remain = new long[4];