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. */
|
/** The human readable name of this application. */
|
||||||
public String name;
|
public String name;
|
||||||
|
|
||||||
|
/** A background color, just in case. */
|
||||||
|
public Color background;
|
||||||
|
|
||||||
/** Background image specifiers for {@link RotatingBackgrounds}. */
|
/** Background image specifiers for {@link RotatingBackgrounds}. */
|
||||||
public String[] rotatingBackgrounds;
|
public String[] rotatingBackgrounds;
|
||||||
|
|
||||||
@@ -188,10 +191,10 @@ public class Application
|
|||||||
@Override
|
@Override
|
||||||
public String toString ()
|
public String toString ()
|
||||||
{
|
{
|
||||||
return "[name=" + name + ", bg=" + backgroundImage + ", pi=" + progressImage +
|
return "[name=" + name + ", bg=" + background + ", bg=" + backgroundImage +
|
||||||
", prect=" + progress + ", pt=" + progressText + ", pb=" + progressBar +
|
", pi=" + progressImage + ", prect=" + progress + ", pt=" + progressText +
|
||||||
", srect=" + status + ", st=" + statusText + ", shadow=" + textShadow +
|
", pb=" + progressBar + ", srect=" + status + ", st=" + statusText +
|
||||||
", err=" + installError + ", nrect=" + patchNotes +
|
", shadow=" + textShadow + ", err=" + installError + ", nrect=" + patchNotes +
|
||||||
", notes=" + patchNotesUrl + ", stepPercentages=" + stepPercentages + "]";
|
", notes=" + patchNotesUrl + ", stepPercentages=" + stepPercentages + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -656,6 +659,14 @@ public class Application
|
|||||||
if (ui.backgroundImage == null) { // support legacy format
|
if (ui.backgroundImage == null) { // support legacy format
|
||||||
ui.backgroundImage = (String)cdata.get("ui.background");
|
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.progressImage = (String)cdata.get("ui.progress_image");
|
||||||
ui.rotatingBackgrounds = ConfigUtil.getMultiValue(cdata, "ui.rotating_background");
|
ui.rotatingBackgrounds = ConfigUtil.getMultiValue(cdata, "ui.rotating_background");
|
||||||
ui.iconImages = ConfigUtil.getMultiValue(cdata, "ui.icon");
|
ui.iconImages = ConfigUtil.getMultiValue(cdata, "ui.icon");
|
||||||
|
|||||||
@@ -184,6 +184,10 @@ public class StatusPanel extends JComponent
|
|||||||
super.paintComponent(g);
|
super.paintComponent(g);
|
||||||
Graphics2D gfx = (Graphics2D)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;
|
Image img;
|
||||||
if (_displayError) {
|
if (_displayError) {
|
||||||
img = _bg.getErrorImage();
|
img = _bg.getErrorImage();
|
||||||
@@ -192,9 +196,6 @@ public class StatusPanel extends JComponent
|
|||||||
}
|
}
|
||||||
if (img != null) {
|
if (img != null) {
|
||||||
gfx.drawImage(img, 0, 0, this);
|
gfx.drawImage(img, 0, 0, this);
|
||||||
} else {
|
|
||||||
gfx.setColor(getBackground());
|
|
||||||
gfx.fillRect(0, 0, getWidth(), getHeight());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Object oalias = SwingUtil.activateAntiAliasing(gfx);
|
Object oalias = SwingUtil.activateAntiAliasing(gfx);
|
||||||
|
|||||||
Reference in New Issue
Block a user