Merge pull request #6445 from deathbeam/barrows-respect-client

Make barrows minimap respect client minimap colors, show players
This commit is contained in:
Tomas Slusny
2018-11-13 11:18:35 +01:00
committed by GitHub

View File

@@ -50,7 +50,7 @@ class BarrowsOverlay extends Overlay
private final BarrowsConfig config; private final BarrowsConfig config;
@Inject @Inject
BarrowsOverlay(Client client, BarrowsPlugin plugin, BarrowsConfig config) private BarrowsOverlay(Client client, BarrowsPlugin plugin, BarrowsConfig config)
{ {
setPosition(OverlayPosition.DYNAMIC); setPosition(OverlayPosition.DYNAMIC);
setLayer(OverlayLayer.ABOVE_WIDGETS); setLayer(OverlayLayer.ABOVE_WIDGETS);
@@ -63,27 +63,41 @@ class BarrowsOverlay extends Overlay
public Dimension render(Graphics2D graphics) public Dimension render(Graphics2D graphics)
{ {
Player local = client.getLocalPlayer(); Player local = client.getLocalPlayer();
final Color npcColor = getMinimapDotColor(1);
final Color playerColor = getMinimapDotColor(2);
// tunnels are only on z=0 // tunnels are only on z=0
if (!plugin.getWalls().isEmpty() && client.getPlane() == 0 && config.showMinimap()) if (!plugin.getWalls().isEmpty() && client.getPlane() == 0 && config.showMinimap())
{ {
//NPC yellow dot // NPC dots
List<NPC> npcs = client.getNpcs(); graphics.setColor(npcColor);
final List<NPC> npcs = client.getNpcs();
for (NPC npc : npcs) for (NPC npc : npcs)
{ {
net.runelite.api.Point minimapLocation = npc.getMinimapLocation(); net.runelite.api.Point minimapLocation = npc.getMinimapLocation();
if (minimapLocation != null) if (minimapLocation != null)
{ {
graphics.setColor(Color.yellow);
graphics.fillOval(minimapLocation.getX(), minimapLocation.getY(), 4, 4); graphics.fillOval(minimapLocation.getX(), minimapLocation.getY(), 4, 4);
} }
} }
//Render barrows walls/doors // Player dots
graphics.setColor(npcColor);
final List<Player> players = client.getPlayers();
for (Player player : players)
{
net.runelite.api.Point minimapLocation = player.getMinimapLocation();
if (minimapLocation != null)
{
graphics.fillOval(minimapLocation.getX(), minimapLocation.getY(), 4, 4);
}
}
// Render barrows walls/doors
renderObjects(graphics, local); renderObjects(graphics, local);
//Player white dot // Local player square
graphics.setColor(Color.white); graphics.setColor(playerColor);
graphics.fillRect(local.getMinimapLocation().getX(), local.getMinimapLocation().getY(), 3, 3); graphics.fillRect(local.getMinimapLocation().getX(), local.getMinimapLocation().getY(), 3, 3);
} }
else if (config.showBrotherLoc()) else if (config.showBrotherLoc())
@@ -140,6 +154,17 @@ class BarrowsOverlay extends Overlay
graphics.fillRect(minimapLocation.getX(), minimapLocation.getY(), 3, 3); graphics.fillRect(minimapLocation.getX(), minimapLocation.getY(), 3, 3);
} }
/**
* Get minimap dot color from client
* @param typeIndex index of minimap dot type (1 npcs, 2 players)
* @return color
*/
private Color getMinimapDotColor(int typeIndex)
{
final int pixel = client.getMapDots()[typeIndex].getPixels()[1];
return new Color(pixel);
}
private void renderLadders(Graphics2D graphics, GameObject ladder) private void renderLadders(Graphics2D graphics, GameObject ladder)
{ {
net.runelite.api.Point minimapLocation = ladder.getMinimapLocation(); net.runelite.api.Point minimapLocation = ladder.getMinimapLocation();