From 0c35d18711ce9abbfa3eca96f8773e77ac1bd01a Mon Sep 17 00:00:00 2001 From: James <38226001+james-munson@users.noreply.github.com> Date: Tue, 23 Apr 2019 00:58:13 -0700 Subject: [PATCH] Updated player indicators (#70) --- .../FriendMinimapOverlay.java | 64 +++++++++++++++++++ .../PlayerIndicatorsOverlay.java | 4 ++ .../PlayerIndicatorsPlugin.java | 5 ++ .../PlayerIndicatorsService.java | 2 +- 4 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/FriendMinimapOverlay.java diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/FriendMinimapOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/FriendMinimapOverlay.java new file mode 100644 index 0000000000..6786d24ba6 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/FriendMinimapOverlay.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2018, Seth + * 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.playerindicators; + +import net.runelite.api.Player; +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; +import net.runelite.client.ui.overlay.OverlayUtil; + +import javax.inject.Inject; +import java.awt.*; + +public class FriendMinimapOverlay extends Overlay +{ + private final PlayerIndicatorsConfig config; + private final PlayerIndicatorsService playerIndicatorsService; + + @Inject + private FriendMinimapOverlay(PlayerIndicatorsConfig config, PlayerIndicatorsService playerIndicatorsService) + { + setPosition(OverlayPosition.DYNAMIC); + setLayer(OverlayLayer.ABOVE_WIDGETS); + this.config = config; + this.playerIndicatorsService = playerIndicatorsService; + } + + @Override + public Dimension render(Graphics2D graphics) + { + playerIndicatorsService.forEachPlayer((player, color) -> renderPlayerMinimapOverlay(graphics, player, color)); + return null; + } + + private void renderPlayerMinimapOverlay(Graphics2D graphics, Player actor, Color color) { + Point minimapLocation = actor.getMinimapLocation(); + if (!config.highlightFriends() || minimapLocation == null || color == null || actor.isClanMember()) + return; + OverlayUtil.renderMinimapLocation(graphics, minimapLocation, color); + } +} \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsOverlay.java index e582694a9f..2a30494bf4 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsOverlay.java @@ -78,6 +78,10 @@ public class PlayerIndicatorsOverlay extends Overlay String namee = actor.getName().replace('\u00A0', ' '); String combatLevel = Integer.toString(actor.getCombatLevel()); String playerInfo = ""; + Point minimapLocation = actor.getMinimapLocation(); + + graphics.fillOval(minimapLocation.getX() - 1, minimapLocation.getY() - 1, 2, 2); + if (config.drawOverheadPlayerNames()) { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsPlugin.java index e270351e14..00f38ab475 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsPlugin.java @@ -76,6 +76,9 @@ public class PlayerIndicatorsPlugin extends Plugin @Inject private PlayerIndicatorsTileOverlay playerIndicatorsTileOverlay; + @Inject + private FriendMinimapOverlay friendMinimapOverlay; + @Inject private PlayerIndicatorsMinimapOverlay playerIndicatorsMinimapOverlay; @@ -99,6 +102,7 @@ public class PlayerIndicatorsPlugin extends Plugin overlayManager.add(playerIndicatorsOverlay); overlayManager.add(playerIndicatorsTileOverlay); overlayManager.add(playerIndicatorsMinimapOverlay); + overlayManager.add(friendMinimapOverlay); updateHighlightList(); } @@ -108,6 +112,7 @@ public class PlayerIndicatorsPlugin extends Plugin overlayManager.remove(playerIndicatorsOverlay); overlayManager.remove(playerIndicatorsTileOverlay); overlayManager.remove(playerIndicatorsMinimapOverlay); + overlayManager.remove(friendMinimapOverlay); } @Subscribe diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsService.java b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsService.java index 74b1c5a58b..e8aff835bd 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsService.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsService.java @@ -74,7 +74,7 @@ public class PlayerIndicatorsService { if (config.highlightOwnPlayer()) { consumer.accept(player, config.getOwnPlayerColor()); } - } else if (config.highlightFriends() && player.isFriend()) { + } else if (config.highlightFriends() && (player.isFriend() || client.isFriended(player.getName(), false))) { consumer.accept(player, config.getFriendColor()); } else if (config.drawClanMemberNames() && isClanMember) { consumer.accept(player, config.getClanMemberColor());