Add currently hovered tile to TileIndicators

- Add tile that is currently being hovered to tile indicators.

Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
This commit is contained in:
Tomas Slusny
2018-06-05 17:21:03 +02:00
parent 01628545df
commit cb38af069d
2 changed files with 54 additions and 8 deletions

View File

@@ -41,4 +41,24 @@ public interface TileIndicatorsConfig extends Config
{ {
return Color.GRAY; return Color.GRAY;
} }
@ConfigItem(
keyName = "highlightDestinationTile",
name = "Highlight destination tile",
description = "Highlights tile player is walking to"
)
default boolean highlightDestinationTile()
{
return true;
}
@ConfigItem(
keyName = "highlightHoveredTile",
name = "Highlight hovered tile",
description = "Highlights tile player is hovering with mouse"
)
default boolean highlightHoveredTile()
{
return false;
}
} }

View File

@@ -24,6 +24,7 @@
*/ */
package net.runelite.client.plugins.tileindicators; package net.runelite.client.plugins.tileindicators;
import java.awt.Color;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.Polygon; import java.awt.Polygon;
@@ -39,6 +40,7 @@ import net.runelite.client.ui.overlay.OverlayUtil;
public class TileIndicatorsOverlay extends Overlay public class TileIndicatorsOverlay extends Overlay
{ {
private static final Color EMPTY = new Color(0, 0, 0, 0);
private final Client client; private final Client client;
private final TileIndicatorsConfig config; private final TileIndicatorsConfig config;
@@ -55,20 +57,44 @@ public class TileIndicatorsOverlay extends Overlay
@Override @Override
public Dimension render(Graphics2D graphics) public Dimension render(Graphics2D graphics)
{ {
LocalPoint dest = client.getLocalDestinationLocation(); if (config.highlightHoveredTile())
if (dest == null)
{ {
return null; // Update selected scene tile
if (!client.isMenuOpen())
{
client.setCheckClick(true);
client.setMouseCanvasHoverPosition(client.getMouseCanvasPosition());
}
// If we have tile "selected" render it
if (client.getSelectedSceneTile() != null)
{
renderTile(graphics, client.getSelectedSceneTile().getLocalLocation(), EMPTY);
}
} }
Polygon poly = Perspective.getCanvasTilePoly(client, dest); if (config.highlightDestinationTile())
if (poly == null)
{ {
return null; renderTile(graphics, client.getLocalDestinationLocation(), config.highlightDestinationColor());
} }
OverlayUtil.renderPolygon(graphics, poly, config.highlightDestinationColor());
return null; return null;
} }
private void renderTile(final Graphics2D graphics, final LocalPoint dest, final Color color)
{
if (dest == null)
{
return;
}
final Polygon poly = Perspective.getCanvasTilePoly(client, dest);
if (poly == null)
{
return;
}
OverlayUtil.renderPolygon(graphics, poly, color);
}
} }