widget overlay: Don't draw empty wilderness K/D box

The Wilderness and PVP kill-death information box is created while in
these areas regardless of whether the setting (configured via the notice
board at the Edgeville bank) is enabled to show the text, meaning the
widget contains only empty text widgets when the setting is disabled
rather than being null, causing a bounding box to still be drawn and
affecting other snapped widget layout. This commit adds a child class of
WidgetOverlay specific to this widget and prevents it from being drawn
when the setting to show this information is disabled.
This commit is contained in:
Jordan Atwood
2021-08-24 10:43:37 -07:00
committed by Adam
parent aff5d53ddb
commit e4edddffbe
2 changed files with 31 additions and 2 deletions

View File

@@ -56,7 +56,7 @@ public class WidgetOverlay extends Overlay
new WidgetOverlay(client, WidgetInfo.PEST_CONTROL_KNIGHT_INFO_CONTAINER, OverlayPosition.TOP_LEFT),
new WidgetOverlay(client, WidgetInfo.PEST_CONTROL_ACTIVITY_SHIELD_INFO_CONTAINER, OverlayPosition.TOP_RIGHT),
new WidgetOverlay(client, WidgetInfo.ZEAH_MESS_HALL_COOKING_DISPLAY, OverlayPosition.TOP_LEFT),
new WidgetOverlay(client, WidgetInfo.PVP_KILLDEATH_COUNTER, OverlayPosition.TOP_LEFT),
new PvpKDRWidgetOverlay(client, WidgetInfo.PVP_KILLDEATH_COUNTER, OverlayPosition.TOP_LEFT),
new WidgetOverlay(client, WidgetInfo.SKOTIZO_CONTAINER, OverlayPosition.TOP_LEFT),
new WidgetOverlay(client, WidgetInfo.KOUREND_FAVOUR_OVERLAY, OverlayPosition.TOP_CENTER),
new WidgetOverlay(client, WidgetInfo.PYRAMID_PLUNDER_DATA, OverlayPosition.TOP_CENTER),
@@ -257,4 +257,24 @@ public class WidgetOverlay extends Overlay
return position;
}
}
private static class PvpKDRWidgetOverlay extends WidgetOverlay
{
private PvpKDRWidgetOverlay(Client client, WidgetInfo widgetInfo, OverlayPosition overlayPosition)
{
super(client, widgetInfo, overlayPosition);
}
@Override
public Dimension render(Graphics2D graphics)
{
// Don't draw widget overlay if the PVP KDR stats text will be empty
if (client.getVar(Varbits.SHOW_PVP_KDR_STATS) == 1)
{
return super.render(graphics);
}
return null;
}
}
}