Fixed a bug, cleaned things up a bit more.
This commit is contained in:
@@ -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;
|
package com.threerings.getdown.data;
|
||||||
|
|
||||||
@@ -56,7 +56,7 @@ public class Application
|
|||||||
public String name;
|
public String name;
|
||||||
|
|
||||||
/** The dimensions of the progress bar. */
|
/** The dimensions of the progress bar. */
|
||||||
public Rectangle progress;
|
public Rectangle progress = new Rectangle(5, 5, 300, 15);
|
||||||
|
|
||||||
/** The color of the progress text. */
|
/** The color of the progress text. */
|
||||||
public Color progressText = Color.black;
|
public Color progressText = Color.black;
|
||||||
@@ -65,7 +65,7 @@ public class Application
|
|||||||
public Color progressBar = new Color(0x6699CC);
|
public Color progressBar = new Color(0x6699CC);
|
||||||
|
|
||||||
/** The dimensions of the status display. */
|
/** The dimensions of the status display. */
|
||||||
public Rectangle status;
|
public Rectangle status = new Rectangle(5, 25, 300, 100);
|
||||||
|
|
||||||
/** The color of the status text. */
|
/** The color of the status text. */
|
||||||
public Color statusText = Color.black;
|
public Color statusText = Color.black;
|
||||||
@@ -276,12 +276,12 @@ public class Application
|
|||||||
// parse and return our application config
|
// parse and return our application config
|
||||||
UpdateInterface ui = new UpdateInterface();
|
UpdateInterface ui = new UpdateInterface();
|
||||||
ui.name = (String)cdata.get("ui.name");
|
ui.name = (String)cdata.get("ui.name");
|
||||||
ui.progress = parseRect(cdata, "ui.progress");
|
ui.progress = parseRect(cdata, "ui.progress", ui.progress);
|
||||||
ui.progressText = parseColor(
|
ui.progressText = parseColor(
|
||||||
cdata, "ui.progress_text", ui.progressText);
|
cdata, "ui.progress_text", ui.progressText);
|
||||||
ui.progressBar = parseColor(
|
ui.progressBar = parseColor(
|
||||||
cdata, "ui.progress_bar", ui.progressBar);
|
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.statusText = parseColor(cdata, "ui.status_text", ui.statusText);
|
||||||
ui.textShadow = parseColor(cdata, "ui.text_shadow", ui.textShadow);
|
ui.textShadow = parseColor(cdata, "ui.text_shadow", ui.textShadow);
|
||||||
ui.background = (String)cdata.get("ui.background");
|
ui.background = (String)cdata.get("ui.background");
|
||||||
@@ -649,7 +649,7 @@ public class Application
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Used to parse rectangle specifications from the config file. */
|
/** 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);
|
String value = (String)cdata.get(name);
|
||||||
if (!StringUtil.blank(value)) {
|
if (!StringUtil.blank(value)) {
|
||||||
@@ -661,11 +661,11 @@ public class Application
|
|||||||
value + "'.");
|
value + "'.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return def;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Used to parse color specifications from the config file. */
|
/** 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);
|
String value = (String)cdata.get(name);
|
||||||
if (!StringUtil.blank(value)) {
|
if (!StringUtil.blank(value)) {
|
||||||
@@ -676,7 +676,7 @@ public class Application
|
|||||||
value + "'.");
|
value + "'.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return defcolor;
|
return def;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected File _appdir;
|
protected File _appdir;
|
||||||
|
|||||||
@@ -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;
|
package com.threerings.getdown.launcher;
|
||||||
|
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
import java.awt.EventQueue;
|
import java.awt.EventQueue;
|
||||||
import java.awt.Rectangle;
|
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
@@ -261,18 +260,12 @@ public class Getdown extends Thread
|
|||||||
return;
|
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
|
// if we have a background image, load it up
|
||||||
BufferedImage bgimg = null;
|
BufferedImage bgimg = null;
|
||||||
if (!StringUtil.blank(_ifc.background)) {
|
if (!StringUtil.blank(_ifc.background)) {
|
||||||
File bgpath = _app.getLocalPath(_ifc.background);
|
File bgpath = _app.getLocalPath(_ifc.background);
|
||||||
try {
|
try {
|
||||||
bgimg = ImageIO.read(bgpath);
|
bgimg = ImageIO.read(bgpath);
|
||||||
bounds.setRect(0, 0, bgimg.getWidth(), bgimg.getHeight());
|
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
Log.warning("Failed to read UI background [path=" + bgpath +
|
Log.warning("Failed to read UI background [path=" + bgpath +
|
||||||
", error=" + ioe + "].");
|
", error=" + ioe + "].");
|
||||||
@@ -288,7 +281,7 @@ public class Getdown extends Thread
|
|||||||
_frame.getContentPane().removeAll();
|
_frame.getContentPane().removeAll();
|
||||||
}
|
}
|
||||||
_frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
_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.getContentPane().add(_status, BorderLayout.CENTER);
|
||||||
_frame.pack();
|
_frame.pack();
|
||||||
SwingUtil.centerWindow(_frame);
|
SwingUtil.centerWindow(_frame);
|
||||||
@@ -373,9 +366,4 @@ public class Getdown extends Thread
|
|||||||
|
|
||||||
protected static final int MAX_LOOPS = 5;
|
protected static final int MAX_LOOPS = 5;
|
||||||
protected static final long MIN_EXIST_TIME = 5000L;
|
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);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
package com.threerings.getdown.launcher;
|
||||||
|
|
||||||
@@ -31,16 +31,19 @@ import com.threerings.getdown.data.Application.UpdateInterface;
|
|||||||
*/
|
*/
|
||||||
public class StatusPanel extends JComponent
|
public class StatusPanel extends JComponent
|
||||||
{
|
{
|
||||||
public StatusPanel (ResourceBundle msgs, Rectangle bounds,
|
public StatusPanel (ResourceBundle msgs, UpdateInterface ifc,
|
||||||
BufferedImage bgimg, Rectangle ppos, Rectangle spos,
|
BufferedImage bgimg)
|
||||||
UpdateInterface ifc)
|
|
||||||
{
|
{
|
||||||
_msgs = msgs;
|
_msgs = msgs;
|
||||||
_bgimg = bgimg;
|
|
||||||
_psize = new Dimension(bounds.width, bounds.height);
|
|
||||||
_ppos = ppos;
|
|
||||||
_spos = spos;
|
|
||||||
_ifc = ifc;
|
_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);
|
status = xlate(status);
|
||||||
_newlab = new Label(status, _ifc.statusText, _font);
|
_newlab = new Label(status, _ifc.statusText, _font);
|
||||||
_newlab.setTargetWidth(_spos.width);
|
_newlab.setTargetWidth(_ifc.status.width);
|
||||||
if (_ifc.textShadow != null) {
|
if (_ifc.textShadow != null) {
|
||||||
_newlab.setAlternateColor(_ifc.textShadow);
|
_newlab.setAlternateColor(_ifc.textShadow);
|
||||||
_newlab.setStyle(Label.SHADOW);
|
_newlab.setStyle(Label.SHADOW);
|
||||||
@@ -131,13 +134,15 @@ public class StatusPanel extends JComponent
|
|||||||
}
|
}
|
||||||
|
|
||||||
gfx.setColor(_ifc.progressBar);
|
gfx.setColor(_ifc.progressBar);
|
||||||
gfx.fillRect(_ppos.x, _ppos.y, _progress * _ppos.width / 100,
|
gfx.fillRect(_ifc.progress.x, _ifc.progress.y,
|
||||||
_ppos.height);
|
_progress * _ifc.progress.width / 100,
|
||||||
|
_ifc.progress.height);
|
||||||
|
|
||||||
if (_plabel != null) {
|
if (_plabel != null) {
|
||||||
int xmarg = (_ppos.width - _plabel.getSize().width)/2;
|
int xmarg = (_ifc.progress.width - _plabel.getSize().width)/2;
|
||||||
int ymarg = (_ppos.height - _plabel.getSize().height)/2;
|
int ymarg = (_ifc.progress.height - _plabel.getSize().height)/2;
|
||||||
_plabel.render(gfx, _ppos.x + xmarg, _ppos.y + ymarg);
|
_plabel.render(gfx, _ifc.progress.x + xmarg,
|
||||||
|
_ifc.progress.y + ymarg);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_label != null) {
|
if (_label != null) {
|
||||||
@@ -145,12 +150,14 @@ public class StatusPanel extends JComponent
|
|||||||
// want to align the label with the bottom of its region
|
// want to align the label with the bottom of its region
|
||||||
// rather than the top
|
// rather than the top
|
||||||
int ly;
|
int ly;
|
||||||
if (_spos.y > _ppos.y) {
|
if (_ifc.status.y > _ifc.progress.y) {
|
||||||
ly = _spos.y;
|
ly = _ifc.status.y;
|
||||||
} else {
|
} 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);
|
SwingUtil.restoreAntiAliasing(gfx, oalias);
|
||||||
@@ -224,7 +231,6 @@ public class StatusPanel extends JComponent
|
|||||||
|
|
||||||
protected BufferedImage _bgimg;
|
protected BufferedImage _bgimg;
|
||||||
protected Dimension _psize;
|
protected Dimension _psize;
|
||||||
protected Rectangle _ppos, _spos;
|
|
||||||
|
|
||||||
protected ResourceBundle _msgs;
|
protected ResourceBundle _msgs;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user