Merge pull request #1388 from raqes/npc-hightlight-options
Add toggle to render either the tile or the canvas of the npc.
This commit is contained in:
@@ -35,6 +35,7 @@ import javax.inject.Inject;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.NPC;
|
||||
import net.runelite.api.NPCComposition;
|
||||
import net.runelite.api.Point;
|
||||
import net.runelite.client.ui.overlay.Overlay;
|
||||
import net.runelite.client.ui.overlay.OverlayLayer;
|
||||
import net.runelite.client.ui.overlay.OverlayPosition;
|
||||
@@ -68,6 +69,7 @@ public class NpcClickboxOverlay extends Overlay
|
||||
for (NPC npc : plugin.getTaggedNpcs())
|
||||
{
|
||||
NPCComposition composition = plugin.getComposition(npc);
|
||||
|
||||
if (composition == null || composition.getName() == null)
|
||||
continue;
|
||||
|
||||
@@ -80,21 +82,43 @@ public class NpcClickboxOverlay extends Overlay
|
||||
|
||||
private void renderNpcOverlay(Graphics2D graphics, NPC actor, String name, Color color)
|
||||
{
|
||||
Polygon objectClickbox = actor.getConvexHull();
|
||||
if (objectClickbox != null)
|
||||
switch (config.renderStyle())
|
||||
{
|
||||
graphics.setColor(color);
|
||||
graphics.setStroke(new BasicStroke(2));
|
||||
graphics.draw(objectClickbox);
|
||||
graphics.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), 20));
|
||||
graphics.fill(objectClickbox);
|
||||
case TILE:
|
||||
Polygon objectTile = actor.getCanvasTilePoly();
|
||||
|
||||
if (objectTile != null)
|
||||
{
|
||||
graphics.setColor(color);
|
||||
graphics.setStroke(new BasicStroke(2));
|
||||
graphics.draw(objectTile);
|
||||
graphics.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), 20));
|
||||
graphics.fill(objectTile);
|
||||
}
|
||||
break;
|
||||
|
||||
case HULL:
|
||||
Polygon objectClickbox = actor.getConvexHull();
|
||||
|
||||
if (objectClickbox != null)
|
||||
{
|
||||
graphics.setColor(color);
|
||||
graphics.setStroke(new BasicStroke(2));
|
||||
graphics.draw(objectClickbox);
|
||||
graphics.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), 20));
|
||||
graphics.fill(objectClickbox);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
net.runelite.api.Point textLocation = actor.getCanvasTextLocation(graphics, name, actor.getLogicalHeight() + 40);
|
||||
|
||||
if (textLocation != null)
|
||||
if (config.drawNames())
|
||||
{
|
||||
OverlayUtil.renderTextLocation(graphics, textLocation, name, color);
|
||||
Point textLocation = actor.getCanvasTextLocation(graphics, name, actor.getLogicalHeight() + 40);
|
||||
|
||||
if (textLocation != null)
|
||||
{
|
||||
OverlayUtil.renderTextLocation(graphics, textLocation, name, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,6 +38,17 @@ public interface NpcIndicatorsConfig extends Config
|
||||
{
|
||||
@ConfigItem(
|
||||
position = 0,
|
||||
keyName = "highlightStyle",
|
||||
name = "Highlight Style",
|
||||
description = "Highlight setting"
|
||||
)
|
||||
default RenderStyle renderStyle()
|
||||
{
|
||||
return RenderStyle.HULL;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 1,
|
||||
keyName = "npcToHighlight",
|
||||
name = "NPCs to Highlight",
|
||||
description = "List of NPC names to highlight"
|
||||
@@ -48,7 +59,7 @@ public interface NpcIndicatorsConfig extends Config
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 1,
|
||||
position = 2,
|
||||
keyName = "npcColor",
|
||||
name = "Highlight Color",
|
||||
description = "Color of the NPC highlight"
|
||||
@@ -59,7 +70,7 @@ public interface NpcIndicatorsConfig extends Config
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 2,
|
||||
position = 3,
|
||||
keyName = "enableTag",
|
||||
name = "Enable Tag Option",
|
||||
description = "Enable the NPC tag menu option"
|
||||
@@ -70,7 +81,7 @@ public interface NpcIndicatorsConfig extends Config
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 3,
|
||||
position = 4,
|
||||
keyName = "tagColor",
|
||||
name = "Tag Color",
|
||||
description = "Color of the NPC tag highlight"
|
||||
@@ -79,4 +90,26 @@ public interface NpcIndicatorsConfig extends Config
|
||||
{
|
||||
return Color.CYAN;
|
||||
}
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 5,
|
||||
keyName = "drawNames",
|
||||
name = "Draw names above NPC",
|
||||
description = "Configures whether or not NPC names should be drawn above the NPC"
|
||||
)
|
||||
default boolean drawNames()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 6,
|
||||
keyName = "drawMinimapNames",
|
||||
name = "Draw names on minimap",
|
||||
description = "Configures whether or not NPC names should be drawn on the minimap"
|
||||
)
|
||||
default boolean drawMinimapNames()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,7 @@ import java.awt.Graphics2D;
|
||||
import java.util.Map;
|
||||
import javax.inject.Inject;
|
||||
import net.runelite.api.NPC;
|
||||
import net.runelite.api.Point;
|
||||
import net.runelite.client.ui.overlay.Overlay;
|
||||
import net.runelite.client.ui.overlay.OverlayLayer;
|
||||
import net.runelite.client.ui.overlay.OverlayPosition;
|
||||
@@ -59,16 +60,25 @@ public class NpcMinimapOverlay extends Overlay
|
||||
renderNpcOverlay(graphics, npc, npcMap.get(npc), config.getNpcColor());
|
||||
}
|
||||
|
||||
for (NPC npc : plugin.getTaggedNpcs())
|
||||
{
|
||||
renderNpcOverlay(graphics, npc, npc.getName(), config.getTagColor());
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void renderNpcOverlay(Graphics2D graphics, NPC actor, String name, Color color)
|
||||
{
|
||||
net.runelite.api.Point minimapLocation = actor.getMinimapLocation();
|
||||
Point minimapLocation = actor.getMinimapLocation();
|
||||
if (minimapLocation != null)
|
||||
{
|
||||
OverlayUtil.renderMinimapLocation(graphics, minimapLocation, color.darker());
|
||||
OverlayUtil.renderTextLocation(graphics, minimapLocation, name, color);
|
||||
|
||||
if (config.drawMinimapNames())
|
||||
{
|
||||
OverlayUtil.renderTextLocation(graphics, minimapLocation, name, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Raqes <j.raqes@gmail.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client.plugins.npchighlight;
|
||||
|
||||
public enum RenderStyle
|
||||
{
|
||||
OFF("Off"),
|
||||
TILE("Tile"),
|
||||
HULL("Hull");
|
||||
|
||||
private final String name;
|
||||
|
||||
RenderStyle(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user