allow transparent splash screens
When defining a background color, it is now possible to define an alpha value as most significant byte. E.g. `80FF0000` would define a half transparent red background. This only works in combination with `ui.hide_decorations = true`. Closes #92
This commit is contained in:
@@ -1749,7 +1749,9 @@ public class Application
|
|||||||
{
|
{
|
||||||
if (!StringUtil.isBlank(hexValue)) {
|
if (!StringUtil.isBlank(hexValue)) {
|
||||||
try {
|
try {
|
||||||
return new Color(Integer.parseInt(hexValue, 16));
|
int rgba = Integer.parseInt(hexValue, 16);
|
||||||
|
boolean hasAlpha = hexValue.length() > 6;
|
||||||
|
return new Color(rgba, hasAlpha);
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
log.warning("Ignoring invalid color", "hexValue", hexValue, "exception", e);
|
log.warning("Ignoring invalid color", "hexValue", hexValue, "exception", e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,9 @@
|
|||||||
|
|
||||||
package com.threerings.getdown.launcher;
|
package com.threerings.getdown.launcher;
|
||||||
|
|
||||||
|
import java.awt.Color;
|
||||||
import java.awt.Container;
|
import java.awt.Container;
|
||||||
|
import java.awt.IllegalComponentStateException;
|
||||||
import java.awt.Image;
|
import java.awt.Image;
|
||||||
import java.awt.event.WindowAdapter;
|
import java.awt.event.WindowAdapter;
|
||||||
import java.awt.event.WindowEvent;
|
import java.awt.event.WindowEvent;
|
||||||
@@ -141,6 +143,13 @@ public class GetdownApp
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
_frame.setUndecorated(_ifc.hideDecorations);
|
_frame.setUndecorated(_ifc.hideDecorations);
|
||||||
|
try {
|
||||||
|
_frame.setBackground(_ifc.background);
|
||||||
|
} catch (UnsupportedOperationException e) {
|
||||||
|
log.warning("Failed to set background", e);
|
||||||
|
} catch (IllegalComponentStateException e) {
|
||||||
|
log.warning("Failed to set background", e);
|
||||||
|
}
|
||||||
_frame.setResizable(false);
|
_frame.setResizable(false);
|
||||||
} else {
|
} else {
|
||||||
_frame.setTitle(title);
|
_frame.setTitle(title);
|
||||||
@@ -226,6 +235,12 @@ public class GetdownApp
|
|||||||
// to allow the user to close the window
|
// to allow the user to close the window
|
||||||
if (_frame != null && _frame.isUndecorated()) {
|
if (_frame != null && _frame.isUndecorated()) {
|
||||||
_frame.dispose();
|
_frame.dispose();
|
||||||
|
Color background = _frame.getBackground();
|
||||||
|
if (background != null && background.getAlpha() < 255) {
|
||||||
|
// decorated windows do not allow alpha backgrounds
|
||||||
|
_frame.setBackground(
|
||||||
|
new Color(background.getRed(), background.getGreen(), background.getBlue()));
|
||||||
|
}
|
||||||
_frame.setUndecorated(false);
|
_frame.setUndecorated(false);
|
||||||
showContainer();
|
showContainer();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,6 +104,7 @@ public class GetdownApplet extends JApplet
|
|||||||
@Override
|
@Override
|
||||||
protected Container createContainer () {
|
protected Container createContainer () {
|
||||||
getContentPane().removeAll();
|
getContentPane().removeAll();
|
||||||
|
getContentPane().setBackground(_ifc.background);
|
||||||
return getContentPane();
|
return getContentPane();
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -189,10 +189,7 @@ 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
|
// attempt to draw a background image...
|
||||||
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();
|
||||||
|
|||||||
Reference in New Issue
Block a user