Skip to content

Commit

Permalink
overlay renderer: bound overlays position to viewport at render time …
Browse files Browse the repository at this point in the history
…instead of at config load time

Fixes overlays being reset when temporarly off screen during loading. Fixes runelite#3571
  • Loading branch information
Adam- committed Jun 12, 2018
1 parent 2d3766e commit 4792e61
Showing 1 changed file with 9 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -220,25 +220,10 @@ public void rebuildOverlays()
for (final Overlay overlay : overlays)
{
final Point location = loadOverlayLocation(overlay);

if (location != null
&& client.getCanvas() != null
&& !client.getCanvas().contains(location))
{
overlay.setPreferredLocation(null);
saveOverlayLocation(overlay);
}
else if (location != null)
{
overlay.setPreferredLocation(location);
}
overlay.setPreferredLocation(location);

final Dimension size = loadOverlaySize(overlay);

if (size != null)
{
overlay.setPreferredSize(size);
}
overlay.setPreferredSize(size);

final OverlayPosition position = loadOverlayPosition(overlay);
overlay.setPreferredPosition(position);
Expand Down Expand Up @@ -379,9 +364,14 @@ public void render(Graphics2D graphics, final OverlayLayer layer)
}
else
{
if (overlay.getPreferredLocation() != null)
final Point preferredLocation = overlay.getPreferredLocation();

if (preferredLocation != null)
{
location.setLocation(overlay.getPreferredLocation());
final Dimension realDimensions = client.getRealDimensions();
final int x = Math.min(realDimensions.width - 5, preferredLocation.x);
final int y = Math.min(realDimensions.height - 5, preferredLocation.y);
location.setLocation(x, y);
}
}

Expand Down

0 comments on commit 4792e61

Please sign in to comment.