Merge pull request #7965 from deathbeam/fix-text

Do not try to draw infobox caption if text is null or empty
This commit is contained in:
Adam
2019-02-21 11:11:52 -05:00
committed by GitHub
2 changed files with 10 additions and 9 deletions

View File

@@ -24,6 +24,7 @@
*/ */
package net.runelite.client.ui.overlay.components; package net.runelite.client.ui.overlay.components;
import com.google.common.base.Strings;
import java.awt.Color; import java.awt.Color;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.FontMetrics; import java.awt.FontMetrics;
@@ -86,11 +87,14 @@ public class InfoBoxComponent implements LayoutableRenderableEntity
null); null);
// Render caption // Render caption
final TextComponent textComponent = new TextComponent(); if (!Strings.isNullOrEmpty(text))
textComponent.setColor(color); {
textComponent.setText(text); final TextComponent textComponent = new TextComponent();
textComponent.setPosition(new Point(baseX + ((size - metrics.stringWidth(text)) / 2), baseY + size - SEPARATOR)); textComponent.setColor(color);
textComponent.render(graphics); textComponent.setText(text);
textComponent.setPosition(new Point(baseX + ((size - metrics.stringWidth(text)) / 2), baseY + size - SEPARATOR));
textComponent.render(graphics);
}
this.bounds.setBounds(bounds); this.bounds.setBounds(bounds);
return bounds.getSize(); return bounds.getSize();

View File

@@ -99,10 +99,7 @@ public class InfoBoxOverlay extends Overlay
final Color color = box.getTextColor(); final Color color = box.getTextColor();
final InfoBoxComponent infoBoxComponent = new InfoBoxComponent(); final InfoBoxComponent infoBoxComponent = new InfoBoxComponent();
if (!Strings.isNullOrEmpty(text)) infoBoxComponent.setText(text);
{
infoBoxComponent.setText(text);
}
if (color != null) if (color != null)
{ {
infoBoxComponent.setColor(color); infoBoxComponent.setColor(color);