From a07bb6066bfb2619b3afa4bac607f1045eef231f Mon Sep 17 00:00:00 2001 From: Ray Greenwell Date: Mon, 12 Mar 2012 22:17:41 +0000 Subject: [PATCH] A hopefully kosher edit. This little chunk of code has been tweaked and cargo'd forward for years with no documentation as to what's going on. What I object to is the blatent disregarding of the width specified in getdown.txt with something calculated internally. (width - x*2) GIGO; fix your fucking getdown.txt. - If we are not granted privileges, reading the metadata breaks, which is why the fallback was first added. - Later it was tweaked because getWidth() can sometimes report 0 and that would cause the fallback width to be negative. --- .../threerings/getdown/launcher/StatusPanel.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/threerings/getdown/launcher/StatusPanel.java b/src/main/java/com/threerings/getdown/launcher/StatusPanel.java index 0668e0b..3e685cd 100644 --- a/src/main/java/com/threerings/getdown/launcher/StatusPanel.java +++ b/src/main/java/com/threerings/getdown/launcher/StatusPanel.java @@ -259,9 +259,16 @@ public class StatusPanel extends JComponent } } _newlab = createLabel(status, _ifc.statusText); - int width = getWidth() - _ifc.status.x*2; - width = width > 0 ? Math.min(_ifc.status.width, width) : _ifc.status.width; - _newlab.setTargetWidth(width); + // set the width of the label to the width specified + int width = _ifc.status.width; + if (width == 0) { + // unless we had trouble reading that width, in which case use the entire window + width = getWidth(); + } + // but the window itself might not be initialized and have a width of 0 + if (width > 0) { + _newlab.setTargetWidth(width); + } repaint(); }