diff --git a/src/java/com/threerings/getdown/data/Application.java b/src/java/com/threerings/getdown/data/Application.java index fdb4d9b..dc9b2fd 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.18 2004/07/26 22:57:03 mdb Exp $ +// $Id: Application.java,v 1.19 2004/07/26 23:27:46 mdb Exp $ package com.threerings.getdown.data; @@ -56,7 +56,7 @@ public class Application public String name; /** The dimensions of the progress bar. */ - public Rectangle progress; + public Rectangle progress = new Rectangle(5, 5, 300, 15); /** The color of the progress text. */ public Color progressText = Color.black; @@ -65,7 +65,7 @@ public class Application public Color progressBar = new Color(0x6699CC); /** The dimensions of the status display. */ - public Rectangle status; + public Rectangle status = new Rectangle(5, 25, 300, 100); /** The color of the status text. */ public Color statusText = Color.black; @@ -276,12 +276,12 @@ public class Application // parse and return our application config UpdateInterface ui = new UpdateInterface(); ui.name = (String)cdata.get("ui.name"); - ui.progress = parseRect(cdata, "ui.progress"); + ui.progress = parseRect(cdata, "ui.progress", ui.progress); ui.progressText = parseColor( cdata, "ui.progress_text", ui.progressText); ui.progressBar = parseColor( cdata, "ui.progress_bar", ui.progressBar); - ui.status = parseRect(cdata, "ui.progress"); + ui.status = parseRect(cdata, "ui.status", ui.status); 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"); @@ -649,7 +649,7 @@ public class Application } /** Used to parse rectangle specifications from the config file. */ - protected Rectangle parseRect (HashMap cdata, String name) + protected Rectangle parseRect (HashMap cdata, String name, Rectangle def) { String value = (String)cdata.get(name); if (!StringUtil.blank(value)) { @@ -661,11 +661,11 @@ public class Application value + "'."); } } - return null; + return def; } /** Used to parse color specifications from the config file. */ - protected Color parseColor (HashMap cdata, String name, Color defcolor) + protected Color parseColor (HashMap cdata, String name, Color def) { String value = (String)cdata.get(name); if (!StringUtil.blank(value)) { @@ -676,7 +676,7 @@ public class Application value + "'."); } } - return defcolor; + return def; } protected File _appdir; diff --git a/src/java/com/threerings/getdown/launcher/Getdown.java b/src/java/com/threerings/getdown/launcher/Getdown.java index 2a44843..330ae5a 100644 --- a/src/java/com/threerings/getdown/launcher/Getdown.java +++ b/src/java/com/threerings/getdown/launcher/Getdown.java @@ -1,11 +1,10 @@ // -// $Id: Getdown.java,v 1.18 2004/07/26 22:57:03 mdb Exp $ +// $Id: Getdown.java,v 1.19 2004/07/26 23:27:46 mdb Exp $ package com.threerings.getdown.launcher; import java.awt.BorderLayout; import java.awt.EventQueue; -import java.awt.Rectangle; import java.awt.image.BufferedImage; import javax.imageio.ImageIO; @@ -261,18 +260,12 @@ public class Getdown extends Thread return; } - Rectangle ppos = (_ifc.progress == null) ? DEFAULT_PPOS : _ifc.progress; - Rectangle spos = (_ifc.status == null) ? DEFAULT_STATUS : _ifc.status; - Rectangle bounds = ppos.union(spos); - bounds.grow(5, 5); - // if we have a background image, load it up BufferedImage bgimg = null; if (!StringUtil.blank(_ifc.background)) { File bgpath = _app.getLocalPath(_ifc.background); try { bgimg = ImageIO.read(bgpath); - bounds.setRect(0, 0, bgimg.getWidth(), bgimg.getHeight()); } catch (IOException ioe) { Log.warning("Failed to read UI background [path=" + bgpath + ", error=" + ioe + "]."); @@ -288,7 +281,7 @@ public class Getdown extends Thread _frame.getContentPane().removeAll(); } _frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - _status = new StatusPanel(_msgs, bounds, bgimg, ppos, spos, _ifc); + _status = new StatusPanel(_msgs, _ifc, bgimg); _frame.getContentPane().add(_status, BorderLayout.CENTER); _frame.pack(); SwingUtil.centerWindow(_frame); @@ -373,9 +366,4 @@ public class Getdown extends Thread protected static final int MAX_LOOPS = 5; protected static final long MIN_EXIST_TIME = 5000L; - - protected static final Rectangle DEFAULT_PPOS = - new Rectangle(5, 5, 300, 15); - protected static final Rectangle DEFAULT_STATUS = - new Rectangle(5, 25, 300, 100); } diff --git a/src/java/com/threerings/getdown/launcher/StatusPanel.java b/src/java/com/threerings/getdown/launcher/StatusPanel.java index db746d2..f0b9224 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.11 2004/07/26 22:57:03 mdb Exp $ +// $Id: StatusPanel.java,v 1.12 2004/07/26 23:27:46 mdb Exp $ package com.threerings.getdown.launcher; @@ -31,16 +31,19 @@ import com.threerings.getdown.data.Application.UpdateInterface; */ public class StatusPanel extends JComponent { - public StatusPanel (ResourceBundle msgs, Rectangle bounds, - BufferedImage bgimg, Rectangle ppos, Rectangle spos, - UpdateInterface ifc) + public StatusPanel (ResourceBundle msgs, UpdateInterface ifc, + BufferedImage bgimg) { _msgs = msgs; - _bgimg = bgimg; - _psize = new Dimension(bounds.width, bounds.height); - _ppos = ppos; - _spos = spos; _ifc = ifc; + _bgimg = bgimg; + if (bgimg == null) { + Rectangle bounds = ifc.progress.union(ifc.status); + bounds.grow(5, 5); + _psize = bounds.getSize(); + } else { + _psize = new Dimension(bgimg.getWidth(), bgimg.getHeight()); + } } /** @@ -95,7 +98,7 @@ public class StatusPanel extends JComponent { status = xlate(status); _newlab = new Label(status, _ifc.statusText, _font); - _newlab.setTargetWidth(_spos.width); + _newlab.setTargetWidth(_ifc.status.width); if (_ifc.textShadow != null) { _newlab.setAlternateColor(_ifc.textShadow); _newlab.setStyle(Label.SHADOW); @@ -131,13 +134,15 @@ public class StatusPanel extends JComponent } gfx.setColor(_ifc.progressBar); - gfx.fillRect(_ppos.x, _ppos.y, _progress * _ppos.width / 100, - _ppos.height); + gfx.fillRect(_ifc.progress.x, _ifc.progress.y, + _progress * _ifc.progress.width / 100, + _ifc.progress.height); if (_plabel != null) { - int xmarg = (_ppos.width - _plabel.getSize().width)/2; - int ymarg = (_ppos.height - _plabel.getSize().height)/2; - _plabel.render(gfx, _ppos.x + xmarg, _ppos.y + ymarg); + int xmarg = (_ifc.progress.width - _plabel.getSize().width)/2; + int ymarg = (_ifc.progress.height - _plabel.getSize().height)/2; + _plabel.render(gfx, _ifc.progress.x + xmarg, + _ifc.progress.y + ymarg); } if (_label != null) { @@ -145,12 +150,14 @@ public class StatusPanel extends JComponent // want to align the label with the bottom of its region // rather than the top int ly; - if (_spos.y > _ppos.y) { - ly = _spos.y; + if (_ifc.status.y > _ifc.progress.y) { + ly = _ifc.status.y; } else { - ly = _spos.y + (_spos.height - _label.getSize().height); + ly = _ifc.status.y + (_ifc.status.height - + _label.getSize().height); } - _label.render(gfx, _spos.x, ly); + System.out.println("Rendering " + _ifc.status + "/" + ly); + _label.render(gfx, _ifc.status.x, ly); } SwingUtil.restoreAntiAliasing(gfx, oalias); @@ -224,7 +231,6 @@ public class StatusPanel extends JComponent protected BufferedImage _bgimg; protected Dimension _psize; - protected Rectangle _ppos, _spos; protected ResourceBundle _msgs;