Merge pull request #1837 from Rheon-D/agility-mog-highlight
Add Mark of Grace highlighting to Agility plugin
This commit is contained in:
@@ -68,4 +68,27 @@ public interface AgilityConfig extends Config
|
|||||||
{
|
{
|
||||||
return Color.GREEN;
|
return Color.GREEN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ConfigItem(
|
||||||
|
keyName = "highlightMarks",
|
||||||
|
name = "Highlight Marks of Grace",
|
||||||
|
description = "Enable/disable the highlighting of retrievable Marks of Grace",
|
||||||
|
position = 4
|
||||||
|
)
|
||||||
|
default boolean highlightMarks()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ConfigItem(
|
||||||
|
keyName = "markHighlight",
|
||||||
|
name = "Mark highlight Color",
|
||||||
|
description = "Color of highlighted Marks of Grace",
|
||||||
|
position = 5
|
||||||
|
)
|
||||||
|
default Color getMarkColor()
|
||||||
|
{
|
||||||
|
return Color.ORANGE;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
package net.runelite.client.plugins.agilityplugin;
|
package net.runelite.client.plugins.agilityplugin;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
|
import static java.awt.Color.RED;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.geom.Area;
|
import java.awt.geom.Area;
|
||||||
@@ -33,10 +34,12 @@ import javax.inject.Inject;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
import net.runelite.api.Point;
|
import net.runelite.api.Point;
|
||||||
|
import net.runelite.api.Tile;
|
||||||
import net.runelite.api.coords.LocalPoint;
|
import net.runelite.api.coords.LocalPoint;
|
||||||
import net.runelite.client.ui.overlay.Overlay;
|
import net.runelite.client.ui.overlay.Overlay;
|
||||||
import net.runelite.client.ui.overlay.OverlayLayer;
|
import net.runelite.client.ui.overlay.OverlayLayer;
|
||||||
import net.runelite.client.ui.overlay.OverlayPosition;
|
import net.runelite.client.ui.overlay.OverlayPosition;
|
||||||
|
import net.runelite.client.ui.overlay.OverlayUtil;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class AgilityOverlay extends Overlay
|
public class AgilityOverlay extends Overlay
|
||||||
@@ -62,6 +65,7 @@ public class AgilityOverlay extends Overlay
|
|||||||
{
|
{
|
||||||
LocalPoint playerLocation = client.getLocalPlayer().getLocalLocation();
|
LocalPoint playerLocation = client.getLocalPlayer().getLocalLocation();
|
||||||
Point mousePosition = client.getMouseCanvasPosition();
|
Point mousePosition = client.getMouseCanvasPosition();
|
||||||
|
final Tile markOfGrace = plugin.getMarkOfGrace();
|
||||||
plugin.getObstacles().forEach((object, tile) ->
|
plugin.getObstacles().forEach((object, tile) ->
|
||||||
{
|
{
|
||||||
if (tile.getPlane() == client.getPlane()
|
if (tile.getPlane() == client.getPlane()
|
||||||
@@ -70,7 +74,7 @@ public class AgilityOverlay extends Overlay
|
|||||||
Area objectClickbox = object.getClickbox();
|
Area objectClickbox = object.getClickbox();
|
||||||
if (objectClickbox != null)
|
if (objectClickbox != null)
|
||||||
{
|
{
|
||||||
Color configColor = config.getOverlayColor();
|
Color configColor = markOfGrace != null ? RED : config.getOverlayColor();
|
||||||
if (objectClickbox.contains(mousePosition.getX(), mousePosition.getY()))
|
if (objectClickbox.contains(mousePosition.getX(), mousePosition.getY()))
|
||||||
{
|
{
|
||||||
graphics.setColor(configColor.darker());
|
graphics.setColor(configColor.darker());
|
||||||
@@ -87,6 +91,15 @@ public class AgilityOverlay extends Overlay
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (markOfGrace != null && config.highlightMarks())
|
||||||
|
{
|
||||||
|
if (markOfGrace.getPlane() == client.getPlane() && markOfGrace.getItemLayer() != null
|
||||||
|
&& markOfGrace.getLocalLocation().distanceTo(playerLocation) < MAX_DISTANCE)
|
||||||
|
{
|
||||||
|
OverlayUtil.renderTileOverlay(graphics, markOfGrace.getItemLayer(), "Mark of Grace", config.getMarkColor());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,6 +35,10 @@ import javax.inject.Inject;
|
|||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
|
import net.runelite.api.Item;
|
||||||
|
import net.runelite.api.ItemID;
|
||||||
|
import net.runelite.api.ItemLayer;
|
||||||
|
import net.runelite.api.Node;
|
||||||
import static net.runelite.api.Skill.AGILITY;
|
import static net.runelite.api.Skill.AGILITY;
|
||||||
import net.runelite.api.Tile;
|
import net.runelite.api.Tile;
|
||||||
import net.runelite.api.TileObject;
|
import net.runelite.api.TileObject;
|
||||||
@@ -49,6 +53,7 @@ import net.runelite.api.events.GameStateChanged;
|
|||||||
import net.runelite.api.events.GroundObjectChanged;
|
import net.runelite.api.events.GroundObjectChanged;
|
||||||
import net.runelite.api.events.GroundObjectDespawned;
|
import net.runelite.api.events.GroundObjectDespawned;
|
||||||
import net.runelite.api.events.GroundObjectSpawned;
|
import net.runelite.api.events.GroundObjectSpawned;
|
||||||
|
import net.runelite.api.events.ItemLayerChanged;
|
||||||
import net.runelite.api.events.WallObjectChanged;
|
import net.runelite.api.events.WallObjectChanged;
|
||||||
import net.runelite.api.events.WallObjectDespawned;
|
import net.runelite.api.events.WallObjectDespawned;
|
||||||
import net.runelite.api.events.WallObjectSpawned;
|
import net.runelite.api.events.WallObjectSpawned;
|
||||||
@@ -66,6 +71,9 @@ public class AgilityPlugin extends Plugin
|
|||||||
@Getter
|
@Getter
|
||||||
private final Map<TileObject, Tile> obstacles = new HashMap<>();
|
private final Map<TileObject, Tile> obstacles = new HashMap<>();
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private Tile markOfGrace;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@Getter
|
@Getter
|
||||||
private AgilityOverlay overlay;
|
private AgilityOverlay overlay;
|
||||||
@@ -99,6 +107,7 @@ public class AgilityPlugin extends Plugin
|
|||||||
@Override
|
@Override
|
||||||
protected void shutDown() throws Exception
|
protected void shutDown() throws Exception
|
||||||
{
|
{
|
||||||
|
markOfGrace = null;
|
||||||
obstacles.clear();
|
obstacles.clear();
|
||||||
session = null;
|
session = null;
|
||||||
}
|
}
|
||||||
@@ -113,6 +122,7 @@ public class AgilityPlugin extends Plugin
|
|||||||
session = null;
|
session = null;
|
||||||
break;
|
break;
|
||||||
case LOADING:
|
case LOADING:
|
||||||
|
markOfGrace = null;
|
||||||
obstacles.clear();
|
obstacles.clear();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -151,6 +161,48 @@ public class AgilityPlugin extends Plugin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void onItemLayerChanged(ItemLayerChanged event)
|
||||||
|
{
|
||||||
|
if (obstacles.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
Tile tile = event.getTile();
|
||||||
|
ItemLayer itemLayer = tile.getItemLayer();
|
||||||
|
boolean hasMark = tileHasMark(itemLayer);
|
||||||
|
|
||||||
|
if (markOfGrace != null && tile.getWorldLocation().equals(markOfGrace.getWorldLocation()) && !hasMark)
|
||||||
|
{
|
||||||
|
markOfGrace = null;
|
||||||
|
}
|
||||||
|
else if (hasMark)
|
||||||
|
{
|
||||||
|
markOfGrace = tile;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean tileHasMark(ItemLayer itemLayer)
|
||||||
|
{
|
||||||
|
if (itemLayer != null)
|
||||||
|
{
|
||||||
|
Node currentItem = itemLayer.getBottom();
|
||||||
|
|
||||||
|
while (currentItem instanceof Item)
|
||||||
|
{
|
||||||
|
final Item item = (Item) currentItem;
|
||||||
|
|
||||||
|
currentItem = currentItem.getNext();
|
||||||
|
|
||||||
|
if (item.getId() == ItemID.MARK_OF_GRACE)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// This code, brought to you, in part, by the letters C and V
|
// This code, brought to you, in part, by the letters C and V
|
||||||
// ... and the words "search" and "replace"
|
// ... and the words "search" and "replace"
|
||||||
@Subscribe
|
@Subscribe
|
||||||
|
|||||||
Reference in New Issue
Block a user