Updated player indicators (#70)

This commit is contained in:
James
2019-04-23 00:58:13 -07:00
committed by Kyleeld
parent b97f3296a5
commit 0c35d18711
4 changed files with 74 additions and 1 deletions

View File

@@ -0,0 +1,64 @@
/*
* Copyright (c) 2018, Seth <http://github.com/sethtroll>
* 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);
}
}

View File

@@ -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())
{

View File

@@ -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

View File

@@ -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());