npcindicators: add Interacting functionality (#1076)
* Interacting functionality in NPC Indicators * Check Style fixes & various others. * Fix whitespace * Change function back to changing all overlay colors, not just text. * Make config description more sensible * Make config names more sensible
This commit is contained in:
@@ -34,33 +34,22 @@ import lombok.Setter;
|
||||
import net.runelite.api.NPC;
|
||||
import net.runelite.api.NPCDefinition;
|
||||
import net.runelite.api.coords.WorldPoint;
|
||||
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
class MemorizedNpc
|
||||
{
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
private int npcIndex;
|
||||
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
private Set<String> npcNames;
|
||||
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
private int npcSize;
|
||||
|
||||
/**
|
||||
* The time the npc died at, in game ticks, relative to the tick counter
|
||||
*/
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
@Setter(AccessLevel.PACKAGE)
|
||||
private int diedOnTick;
|
||||
|
||||
/**
|
||||
* The time it takes for the npc to respawn, in game ticks
|
||||
*/
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
@Setter(AccessLevel.PACKAGE)
|
||||
private int respawnTime;
|
||||
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
@Setter(AccessLevel.PACKAGE)
|
||||
private List<WorldPoint> possibleRespawnLocations;
|
||||
|
||||
|
||||
@@ -65,6 +65,17 @@ public interface NpcIndicatorsConfig extends Config
|
||||
return Color.CYAN;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 2,
|
||||
keyName = "interactingColor",
|
||||
name = "Interacting Color",
|
||||
description = "Color of the NPC highlight when targeting local player"
|
||||
)
|
||||
default Color getInteractingColor()
|
||||
{
|
||||
return Color.RED;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 3,
|
||||
keyName = "drawNames",
|
||||
@@ -78,6 +89,17 @@ public interface NpcIndicatorsConfig extends Config
|
||||
|
||||
@ConfigItem(
|
||||
position = 4,
|
||||
keyName = "drawInteracting",
|
||||
name = "Draw target name above NPC",
|
||||
description = "Configures whether the name of the NPC's target is drawn above it's head"
|
||||
)
|
||||
default boolean drawInteracting()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 5,
|
||||
keyName = "drawMinimapNames",
|
||||
name = "Draw names on minimap",
|
||||
description = "Configures whether or not NPC names should be drawn on the minimap"
|
||||
@@ -88,7 +110,7 @@ public interface NpcIndicatorsConfig extends Config
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 5,
|
||||
position = 6,
|
||||
keyName = "highlightMenuNames",
|
||||
name = "Highlight menu names",
|
||||
description = "Highlight NPC names in right click menu"
|
||||
@@ -99,7 +121,7 @@ public interface NpcIndicatorsConfig extends Config
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 6,
|
||||
position = 7,
|
||||
keyName = "showRespawnTimer",
|
||||
name = "Show respawn timer",
|
||||
description = "Show respawn timer of tagged NPCs")
|
||||
|
||||
@@ -192,8 +192,12 @@ public class NpcIndicatorsPlugin extends Plugin
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
private Color getHighlightColor;
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
private Color getInteractingColor;
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
private boolean drawNames;
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
private boolean drawInteracting;
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
private boolean drawMinimapNames;
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
private boolean highlightMenuNames;
|
||||
@@ -654,9 +658,11 @@ public class NpcIndicatorsPlugin extends Plugin
|
||||
this.renderStyle = config.renderStyle();
|
||||
this.getNpcToHighlight = config.getNpcToHighlight();
|
||||
this.getHighlightColor = config.getHighlightColor();
|
||||
this.getInteractingColor = config.getInteractingColor();
|
||||
this.drawNames = config.drawNames();
|
||||
this.drawInteracting = config.drawInteracting();
|
||||
this.drawMinimapNames = config.drawMinimapNames();
|
||||
this.highlightMenuNames = config.highlightMenuNames();
|
||||
this.showRespawnTimer = config.showRespawnTimer();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -63,7 +63,8 @@ public class NpcMinimapOverlay extends Overlay
|
||||
|
||||
private void renderNpcOverlay(Graphics2D graphics, NPC actor, String name, Color color)
|
||||
{
|
||||
Point minimapLocation = actor.getMinimapLocation();
|
||||
final Point minimapLocation = actor.getMinimapLocation();
|
||||
|
||||
if (minimapLocation != null)
|
||||
{
|
||||
OverlayUtil.renderMinimapLocation(graphics, minimapLocation, color.darker());
|
||||
|
||||
@@ -149,10 +149,16 @@ public class NpcSceneOverlay extends Overlay
|
||||
|
||||
private void renderNpcOverlay(Graphics2D graphics, NPC actor, Color color)
|
||||
{
|
||||
if (plugin.isDrawInteracting() && actor.getInteracting() != null
|
||||
&& actor.getInteracting() == client.getLocalPlayer())
|
||||
{
|
||||
color = plugin.getGetInteractingColor();
|
||||
}
|
||||
|
||||
switch (plugin.getRenderStyle())
|
||||
{
|
||||
case SOUTH_WEST_TILE:
|
||||
LocalPoint lp1 = LocalPoint.fromWorld(client, actor.getWorldLocation());
|
||||
final LocalPoint lp1 = LocalPoint.fromWorld(client, actor.getWorldLocation());
|
||||
Polygon tilePoly1 = null;
|
||||
if (lp1 != null)
|
||||
{
|
||||
@@ -161,38 +167,30 @@ public class NpcSceneOverlay extends Overlay
|
||||
|
||||
renderPoly(graphics, color, tilePoly1);
|
||||
break;
|
||||
|
||||
case TILE:
|
||||
int size = 1;
|
||||
NPCDefinition composition = actor.getTransformedDefinition();
|
||||
final NPCDefinition composition = actor.getTransformedDefinition();
|
||||
if (composition != null)
|
||||
{
|
||||
size = composition.getSize();
|
||||
}
|
||||
LocalPoint lp = actor.getLocalLocation();
|
||||
Polygon tilePoly = Perspective.getCanvasTileAreaPoly(client, lp, size);
|
||||
|
||||
final LocalPoint lp = actor.getLocalLocation();
|
||||
final Polygon tilePoly = Perspective.getCanvasTileAreaPoly(client, lp, size);
|
||||
renderPoly(graphics, color, tilePoly);
|
||||
break;
|
||||
|
||||
case HULL:
|
||||
Polygon objectClickbox = actor.getConvexHull();
|
||||
|
||||
final Polygon objectClickbox = actor.getConvexHull();
|
||||
renderPoly(graphics, color, objectClickbox);
|
||||
break;
|
||||
|
||||
case THIN_OUTLINE:
|
||||
modelOutliner.drawOutline(actor, 1, color);
|
||||
break;
|
||||
|
||||
case OUTLINE:
|
||||
modelOutliner.drawOutline(actor, 2, color);
|
||||
break;
|
||||
|
||||
case THIN_GLOW:
|
||||
modelOutliner.drawOutline(actor, 4, color, TRANSPARENT);
|
||||
break;
|
||||
|
||||
case GLOW:
|
||||
modelOutliner.drawOutline(actor, 8, color, TRANSPARENT);
|
||||
break;
|
||||
@@ -200,14 +198,26 @@ public class NpcSceneOverlay extends Overlay
|
||||
|
||||
if (plugin.isDrawNames() && actor.getName() != null)
|
||||
{
|
||||
String npcName = Text.removeTags(actor.getName());
|
||||
Point textLocation = actor.getCanvasTextLocation(graphics, npcName, actor.getLogicalHeight() + 40);
|
||||
final String npcName = Text.removeTags(actor.getName());
|
||||
final Point textLocation = actor.getCanvasTextLocation(graphics, npcName, actor.getLogicalHeight() + 40);
|
||||
|
||||
if (textLocation != null)
|
||||
{
|
||||
OverlayUtil.renderTextLocation(graphics, textLocation, npcName, color);
|
||||
}
|
||||
}
|
||||
|
||||
if (plugin.isDrawInteracting() && actor.getInteracting() != null)
|
||||
{
|
||||
final int drawHeight = plugin.isDrawNames() ? 80 : 40;
|
||||
final String targetName = Text.removeTags(actor.getInteracting().getName());
|
||||
final Point textLocation = actor.getCanvasTextLocation(graphics, targetName, actor.getLogicalHeight() + drawHeight);
|
||||
|
||||
if (textLocation != null)
|
||||
{
|
||||
OverlayUtil.renderTextLocation(graphics, textLocation, targetName, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void renderPoly(Graphics2D graphics, Color color, Polygon polygon)
|
||||
|
||||
Reference in New Issue
Block a user