Parse a background color from getdown.txt, or figure out a sensible one.
Always fill the component with that, in case there's trouble with the background image.
This commit is contained in:
@@ -137,6 +137,9 @@ public class Application
|
||||
/** The human readable name of this application. */
|
||||
public String name;
|
||||
|
||||
/** A background color, just in case. */
|
||||
public Color background;
|
||||
|
||||
/** Background image specifiers for {@link RotatingBackgrounds}. */
|
||||
public String[] rotatingBackgrounds;
|
||||
|
||||
@@ -188,10 +191,10 @@ public class Application
|
||||
@Override
|
||||
public String toString ()
|
||||
{
|
||||
return "[name=" + name + ", bg=" + backgroundImage + ", pi=" + progressImage +
|
||||
", prect=" + progress + ", pt=" + progressText + ", pb=" + progressBar +
|
||||
", srect=" + status + ", st=" + statusText + ", shadow=" + textShadow +
|
||||
", err=" + installError + ", nrect=" + patchNotes +
|
||||
return "[name=" + name + ", bg=" + background + ", bg=" + backgroundImage +
|
||||
", pi=" + progressImage + ", prect=" + progress + ", pt=" + progressText +
|
||||
", pb=" + progressBar + ", srect=" + status + ", st=" + statusText +
|
||||
", shadow=" + textShadow + ", err=" + installError + ", nrect=" + patchNotes +
|
||||
", notes=" + patchNotesUrl + ", stepPercentages=" + stepPercentages + "]";
|
||||
}
|
||||
|
||||
@@ -656,6 +659,14 @@ public class Application
|
||||
if (ui.backgroundImage == null) { // support legacy format
|
||||
ui.backgroundImage = (String)cdata.get("ui.background");
|
||||
}
|
||||
// and now ui.background can refer to the background color, but fall back to black
|
||||
// or white, depending on the brightness of the progressText
|
||||
Color defaultBackground = (.5f < Color.RGBtoHSB(
|
||||
ui.progressText.getRed(), ui.progressText.getGreen(), ui.progressText.getBlue(),
|
||||
null)[2])
|
||||
? Color.BLACK
|
||||
: Color.WHITE;
|
||||
ui.background = parseColor(cdata, "ui.background", defaultBackground);
|
||||
ui.progressImage = (String)cdata.get("ui.progress_image");
|
||||
ui.rotatingBackgrounds = ConfigUtil.getMultiValue(cdata, "ui.rotating_background");
|
||||
ui.iconImages = ConfigUtil.getMultiValue(cdata, "ui.icon");
|
||||
|
||||
@@ -184,6 +184,10 @@ public class StatusPanel extends JComponent
|
||||
super.paintComponent(g);
|
||||
Graphics2D gfx = (Graphics2D)g;
|
||||
|
||||
// always draw a background in case our image isn't ready yet
|
||||
gfx.setColor(_ifc.background);
|
||||
gfx.fillRect(0, 0, getWidth(), getHeight());
|
||||
// then attempt to draw a background image...
|
||||
Image img;
|
||||
if (_displayError) {
|
||||
img = _bg.getErrorImage();
|
||||
@@ -192,9 +196,6 @@ public class StatusPanel extends JComponent
|
||||
}
|
||||
if (img != null) {
|
||||
gfx.drawImage(img, 0, 0, this);
|
||||
} else {
|
||||
gfx.setColor(getBackground());
|
||||
gfx.fillRect(0, 0, getWidth(), getHeight());
|
||||
}
|
||||
|
||||
Object oalias = SwingUtil.activateAntiAliasing(gfx);
|
||||
|
||||
Reference in New Issue
Block a user