Allowing the initial status location and color to be set in case an error occurs before getdown.txt has been read (as is the case when the user rejects our certificate).
This commit is contained in:
@@ -1258,31 +1258,51 @@ public class Application
|
||||
protected Rectangle parseRect (HashMap<String,Object> cdata, String name, Rectangle def)
|
||||
{
|
||||
String value = (String)cdata.get(name);
|
||||
Rectangle rect = parseRect(value);
|
||||
if (rect == null) {
|
||||
log.warning("Ignoring invalid '" + name + "' config '" + value + "'.");
|
||||
} else {
|
||||
return rect;
|
||||
}
|
||||
return def;
|
||||
}
|
||||
|
||||
public static Rectangle parseRect (String value)
|
||||
{
|
||||
if (!StringUtil.isBlank(value)) {
|
||||
int[] v = StringUtil.parseIntArray(value);
|
||||
if (v != null && v.length == 4) {
|
||||
return new Rectangle(v[0], v[1], v[2], v[3]);
|
||||
} else {
|
||||
log.warning("Ignoring invalid '" + name + "' config '" + value + "'.");
|
||||
}
|
||||
}
|
||||
return def;
|
||||
return null;
|
||||
}
|
||||
|
||||
/** Used to parse color specifications from the config file. */
|
||||
protected Color parseColor (HashMap<String,Object> cdata, String name, Color def)
|
||||
{
|
||||
String value = (String)cdata.get(name);
|
||||
if (!StringUtil.isBlank(value)) {
|
||||
try {
|
||||
return new Color(Integer.parseInt(value, 16));
|
||||
} catch (Exception e) {
|
||||
log.warning("Ignoring invalid '" + name + "' config '" + value + "'.");
|
||||
}
|
||||
Color color = parseColor(value);
|
||||
if (color == null) {
|
||||
log.warning("Ignoring invalid '" + name + "' config '" + value + "'.");
|
||||
} else {
|
||||
return color;
|
||||
}
|
||||
return def;
|
||||
}
|
||||
|
||||
public static Color parseColor (String hexValue)
|
||||
{
|
||||
if (!StringUtil.isBlank(hexValue)) {
|
||||
try {
|
||||
return new Color(Integer.parseInt(hexValue, 16));
|
||||
} catch (NumberFormatException e) {
|
||||
log.warning("Ignoring invalid color", "hexValue", hexValue, "exception", e);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/** Parses a list of strings from the config file. */
|
||||
protected String[] parseList (HashMap<String,Object> cdata, String name)
|
||||
{
|
||||
|
||||
@@ -23,8 +23,10 @@
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
package com.threerings.getdown.launcher;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Container;
|
||||
import java.awt.Image;
|
||||
import java.awt.Rectangle;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
@@ -34,15 +36,12 @@ import java.net.URL;
|
||||
import javax.swing.JApplet;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.PrintStream;
|
||||
import java.util.Map;
|
||||
|
||||
import com.samskivert.util.RunAnywhere;
|
||||
import com.samskivert.util.StringUtil;
|
||||
|
||||
import com.threerings.getdown.data.Application;
|
||||
import com.threerings.getdown.util.ConfigUtil;
|
||||
|
||||
import static com.threerings.getdown.Log.log;
|
||||
@@ -163,6 +162,17 @@ public class GetdownApplet extends JApplet
|
||||
}
|
||||
};
|
||||
|
||||
// configure the status/progress text in case something goes horribly wrong before we
|
||||
// get a chance to read getdown.txt (like when the user rejects write permissions)
|
||||
Rectangle statusBounds = Application.parseRect(getParameter("ui.status"));
|
||||
if (statusBounds != null) {
|
||||
_getdown._ifc.status = statusBounds;
|
||||
}
|
||||
Color statusColor = Application.parseColor(getParameter("ui.status_text"));
|
||||
if (statusColor != null) {
|
||||
_getdown._ifc.statusText = statusColor;
|
||||
}
|
||||
|
||||
// set up our user interface immediately
|
||||
_getdown.preInit();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user