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;
import com.google.common.base.Strings;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FontMetrics;
@@ -86,11 +87,14 @@ public class InfoBoxComponent implements LayoutableRenderableEntity
null);
// Render caption
final TextComponent textComponent = new TextComponent();
textComponent.setColor(color);
textComponent.setText(text);
textComponent.setPosition(new Point(baseX + ((size - metrics.stringWidth(text)) / 2), baseY + size - SEPARATOR));
textComponent.render(graphics);
if (!Strings.isNullOrEmpty(text))
{
final TextComponent textComponent = new TextComponent();
textComponent.setColor(color);
textComponent.setText(text);
textComponent.setPosition(new Point(baseX + ((size - metrics.stringWidth(text)) / 2), baseY + size - SEPARATOR));
textComponent.render(graphics);
}
this.bounds.setBounds(bounds);
return bounds.getSize();

View File

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