Merge pull request #712 from gazivodag/pileindicators_fix
fixes #696 and adds the intended functionality
This commit is contained in:
@@ -190,24 +190,26 @@ public interface PileIndicatorsConfig extends Config
|
||||
|
||||
@ConfigItem(
|
||||
position = 13,
|
||||
keyName = "drawPileTile",
|
||||
name = "Draw Pile Tile",
|
||||
description = "Draws the tile of the pile for best visibility.",
|
||||
parent = "miscellaneousStub"
|
||||
)
|
||||
default boolean drawPileTile()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 14,
|
||||
keyName = "drawPileHull",
|
||||
name = "Draws the hull of the pile.",
|
||||
description = "Draws the hull of the pile for best visibility."
|
||||
name = "Draw Pile Convex Hull",
|
||||
description = "Draws the hull of the pile for best visibility.",
|
||||
parent = "miscellaneousStub"
|
||||
)
|
||||
default boolean drawPileHull()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 14,
|
||||
keyName = "highlightPile",
|
||||
name = "Highlight Pile",
|
||||
description = "Highlights Pile Onscreen"
|
||||
)
|
||||
default boolean highlightPile()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,12 +26,15 @@ package net.runelite.client.plugins.pileindicators;
|
||||
|
||||
import net.runelite.api.Actor;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.client.plugins.playerindicators.PlayerIndicatorsService;
|
||||
import net.runelite.client.ui.overlay.*;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import net.runelite.client.ui.overlay.Overlay;
|
||||
import net.runelite.client.ui.overlay.OverlayLayer;
|
||||
import net.runelite.client.ui.overlay.OverlayPosition;
|
||||
import net.runelite.client.ui.overlay.OverlayPriority;
|
||||
import net.runelite.client.ui.overlay.OverlayUtil;
|
||||
|
||||
public class PileIndicatorsOverlay extends Overlay
|
||||
{
|
||||
@@ -39,16 +42,14 @@ public class PileIndicatorsOverlay extends Overlay
|
||||
private final Client client;
|
||||
private final PileIndicatorsPlugin plugin;
|
||||
private final PileIndicatorsConfig config;
|
||||
private final PlayerIndicatorsService playerIndicatorsService;
|
||||
|
||||
@Inject
|
||||
PileIndicatorsOverlay(final Client client, final PileIndicatorsPlugin plugin, final PileIndicatorsConfig config, PlayerIndicatorsService playerIndicatorsService)
|
||||
PileIndicatorsOverlay(final Client client, final PileIndicatorsPlugin plugin, final PileIndicatorsConfig config)
|
||||
{
|
||||
super(plugin);
|
||||
this.client = client;
|
||||
this.plugin = plugin;
|
||||
this.config = config;
|
||||
this.playerIndicatorsService = playerIndicatorsService;
|
||||
|
||||
setLayer(OverlayLayer.ABOVE_SCENE);
|
||||
setPosition(OverlayPosition.DYNAMIC);
|
||||
@@ -60,18 +61,7 @@ public class PileIndicatorsOverlay extends Overlay
|
||||
public Dimension render(Graphics2D graphics)
|
||||
{
|
||||
ArrayList<ArrayList<Actor>> stackList = plugin.getStacks();
|
||||
if (config.drawPileHull())
|
||||
{
|
||||
playerIndicatorsService.forEachPlayer((player, color) ->
|
||||
{
|
||||
if (plugin.isPile(player))
|
||||
{
|
||||
Polygon objectClickbox = player.getConvexHull();
|
||||
|
||||
renderPoly(graphics, config.playerPileColor(), objectClickbox);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (stackList != null)
|
||||
{
|
||||
for (ArrayList<Actor> actorArrayList : stackList)
|
||||
@@ -82,17 +72,16 @@ public class PileIndicatorsOverlay extends Overlay
|
||||
try
|
||||
{
|
||||
Actor actorToRender = actorArrayList.get(0); //guaranteed to have at least two players
|
||||
final String text;
|
||||
if (config.numberOnly())
|
||||
final String pileTypeStr = pileType == PileType.PLAYER_PILE ? "PLAYER" : pileType == PileType.NPC_PILE ? "NPC" : pileType == PileType.MIXED_PILE ? "MIXED" : "";
|
||||
final String text = config.numberOnly() ? "" + actorArrayList.size() : (pileTypeStr + " PILE SIZE: " + actorArrayList.size());
|
||||
if (config.drawPileTile())
|
||||
{
|
||||
text = "" + actorArrayList.size();
|
||||
}
|
||||
else
|
||||
{
|
||||
text = "PILE SIZE: " + actorArrayList.size();
|
||||
}
|
||||
|
||||
OverlayUtil.renderPolygon(graphics, actorToRender.getCanvasTilePoly(), pileColor);
|
||||
}
|
||||
if (config.drawPileHull())
|
||||
{
|
||||
OverlayUtil.renderPolygon(graphics, actorToRender.getConvexHull(), pileColor);
|
||||
}
|
||||
OverlayUtil.renderTextLocation(graphics, actorToRender.getCanvasTextLocation(graphics, text, 40), text, pileColor);
|
||||
}
|
||||
catch (Exception ignored)
|
||||
@@ -104,16 +93,4 @@ public class PileIndicatorsOverlay extends Overlay
|
||||
return null;
|
||||
}
|
||||
|
||||
private void renderPoly(Graphics2D graphics, Color color, Polygon polygon)
|
||||
{
|
||||
if (polygon != null)
|
||||
{
|
||||
graphics.setColor(color);
|
||||
graphics.setStroke(new BasicStroke(2));
|
||||
graphics.draw(polygon);
|
||||
graphics.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), 20));
|
||||
graphics.fill(polygon);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -27,10 +27,12 @@ package net.runelite.client.plugins.pileindicators;
|
||||
import com.google.inject.Binder;
|
||||
import com.google.inject.Provides;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.*;
|
||||
import net.runelite.api.events.GameTick;
|
||||
import net.runelite.api.Actor;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.NPC;
|
||||
import net.runelite.api.Player;
|
||||
import net.runelite.api.Varbits;
|
||||
import net.runelite.client.config.ConfigManager;
|
||||
import net.runelite.client.eventbus.Subscribe;
|
||||
import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.client.plugins.PluginType;
|
||||
@@ -40,8 +42,6 @@ import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@PluginDescriptor(
|
||||
name = "Pile Indicators",
|
||||
@@ -68,9 +68,6 @@ public class PileIndicatorsPlugin extends Plugin
|
||||
@Inject
|
||||
private PileIndicatorsOverlay overlay;
|
||||
|
||||
private List<String> pileList;
|
||||
private ArrayList<String> callers = new ArrayList<>();
|
||||
|
||||
@Provides
|
||||
PileIndicatorsConfig provideConfig(ConfigManager configManager)
|
||||
{
|
||||
@@ -94,35 +91,6 @@ public class PileIndicatorsPlugin extends Plugin
|
||||
overlayManager.remove(overlay);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onGameTick(GameTick gameTick)
|
||||
{
|
||||
if (config.highlightPile() && callers != null)
|
||||
{
|
||||
for (Player p : client.getPlayers())
|
||||
{
|
||||
for (String name : callers)
|
||||
{
|
||||
Actor pile;
|
||||
String finalName = name.toLowerCase().replace("_", " ");
|
||||
if (p.getName().toLowerCase().replace("_", " ").equals(finalName))
|
||||
{
|
||||
pile = p.getInteracting();
|
||||
if (pile != null)
|
||||
{
|
||||
pileList.set(callers.indexOf(name), pile.getName());
|
||||
//pileList.add(pile.getName());
|
||||
}
|
||||
else
|
||||
{
|
||||
pileList.set(callers.indexOf(name), "");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected ArrayList<ArrayList<Actor>> getStacks()
|
||||
{
|
||||
ArrayList<ArrayList<Actor>> outerArrayList = new ArrayList<>();
|
||||
@@ -195,15 +163,6 @@ public class PileIndicatorsPlugin extends Plugin
|
||||
return null;
|
||||
}
|
||||
|
||||
boolean isPile(Player player)
|
||||
{
|
||||
if (Objects.nonNull(pileList) && pileList.size() > 0)
|
||||
{
|
||||
return pileList.contains(player.getName());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected PileType getPileType(ArrayList<Actor> pile)
|
||||
{
|
||||
PileType pileType = null;
|
||||
|
||||
Reference in New Issue
Block a user