From 39fd5f6bacf2e926fc1746ec280cf99bb8b98b44 Mon Sep 17 00:00:00 2001 From: Chris Johnson Date: Fri, 26 Jul 2019 15:01:38 -0400 Subject: [PATCH] Show agility level overhead (either as icons or text) (#1100) As well as some general player indicator improvements around multiple conflicting options --- .../PlayerIndicatorsConfig.java | 68 ++++++++++++++--- .../PlayerIndicatorsOverlay.java | 71 ++++++++++++++++-- .../PlayerIndicatorsPlugin.java | 18 +++++ .../plugins/playerindicators/agility.png | Bin 0 -> 232 bytes .../plugins/playerindicators/no-agility.png | Bin 0 -> 299 bytes 5 files changed, 143 insertions(+), 14 deletions(-) create mode 100644 runelite-client/src/main/resources/net/runelite/client/plugins/playerindicators/agility.png create mode 100644 runelite-client/src/main/resources/net/runelite/client/plugins/playerindicators/no-agility.png diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsConfig.java index 06a868e032..a752ca8c62 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsConfig.java @@ -277,6 +277,54 @@ public interface PlayerIndicatorsConfig extends Config @ConfigItem( position = 19, + keyName = "showAgility", + name = "Show Agility Levels", + description = "Show the agility level of attackable players next to their name while in the wilderness.", + group = "Target Indicator" + ) + default boolean showAgilityLevel() + { + return false; + } + + @ConfigItem( + position = 20, + keyName = "agilityFormat", + name = "Format", + description = "Whether to show the agility level as text, or as icons (1 skull >= 1st threshold, 2 skulls >= 2nd threshold).", + group = "Target Indicator" + ) + default PlayerIndicatorsPlugin.AgilityFormats agilityFormat() + { + return PlayerIndicatorsPlugin.AgilityFormats.TEXT; + } + + @ConfigItem( + position = 21, + keyName = "agilityFirstThreshold", + name = "Format", + description = "When showing agility as icons, show one icon for agility >= this level.", + group = "Target Indicator" + ) + default int agilityFirstThreshold() + { + return 70; + } + + @ConfigItem( + position = 22, + keyName = "agilitySecondThreshold", + name = "Format", + description = "When showing agility as icons, show two icons for agility >= this level.", + group = "Target Indicator" + ) + default int agilitySecondThreshold() + { + return 84; + } + + @ConfigItem( + position = 23, keyName = "playerSkull", name = "Show Skull Information", description = "Indicate of the player is skulled.", @@ -288,7 +336,7 @@ public interface PlayerIndicatorsConfig extends Config } @ConfigItem( - position = 19, + position = 24, keyName = "minimapSkullLocation", name = "Skull Icon Location", description = "The location of the skull icon for skulled players", @@ -300,7 +348,7 @@ public interface PlayerIndicatorsConfig extends Config } @ConfigItem( - position = 19, + position = 25, keyName = "skulledTargetsOnly", name = "Tag Skulls Only", description = "Only indicate skulled targets (which are also attackable)", @@ -312,7 +360,7 @@ public interface PlayerIndicatorsConfig extends Config } @ConfigItem( - position = 19, + position = 26, keyName = "targetRisk", name = "Indicate Target Risk", description = "Indicates the risk (in K GP) of the target", @@ -335,11 +383,11 @@ public interface PlayerIndicatorsConfig extends Config }*/ @ConfigItem( + position = 27, keyName = "useClanchatRanks", name = "Use Ranks as Callers", description = "Uses clanchat ranks as the list of callers", - group = "Callers", - position = 24 + group = "Callers" ) default boolean useClanchatRanks() { @@ -347,11 +395,11 @@ public interface PlayerIndicatorsConfig extends Config } @ConfigItem( + position = 28, keyName = "callerRank", name = "Minimum rank for Clan Caller", description = "Chooses the minimum rank to use as clanchat callers.", - group = "Callers", - position = 25 + group = "Callers" ) default ClanMemberRank callerRank() { @@ -359,6 +407,7 @@ public interface PlayerIndicatorsConfig extends Config } @ConfigItem( + position = 29, keyName = "callers", name = "List of callers to highlight", description = "Highlights callers, only highlights one at a time. Separate each entry with a comma and enter" + @@ -371,6 +420,7 @@ public interface PlayerIndicatorsConfig extends Config } @ConfigItem( + position = 30, keyName = "highlightCallers", name = "Highlight Callers", description = "Highlights Callers Onscreen", @@ -382,7 +432,7 @@ public interface PlayerIndicatorsConfig extends Config } @ConfigItem( - position = 26, + position = 31, keyName = "callerColor", name = "Caller Color", description = "Color of Indicated Callers", @@ -394,7 +444,7 @@ public interface PlayerIndicatorsConfig extends Config } @ConfigItem( - position = 27, + position = 32, keyName = "unchargedGlory", name = "Uncharged Glory Indication", description = "Indicates if players have an uncharged glory" 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 2cb8b1db71..ee1e42c3bc 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 @@ -37,8 +37,11 @@ import net.runelite.api.ItemDefinition; import net.runelite.api.Player; import net.runelite.api.Point; import net.runelite.api.SkullIcon; +import net.runelite.api.Varbits; +import net.runelite.api.WorldType; import net.runelite.api.kit.KitType; import net.runelite.client.game.ClanManager; +import net.runelite.client.game.HiscoreManager; import net.runelite.client.game.ItemManager; import net.runelite.client.plugins.friendtagging.FriendTaggingPlugin; import net.runelite.client.ui.overlay.Overlay; @@ -47,6 +50,9 @@ import net.runelite.client.ui.overlay.OverlayPriority; import net.runelite.client.ui.overlay.OverlayUtil; import net.runelite.client.util.ImageUtil; import net.runelite.client.util.PvPUtil; +import net.runelite.http.api.hiscore.HiscoreResult; +import net.runelite.http.api.hiscore.HiscoreSkill; +import net.runelite.http.api.hiscore.HiscoreEndpoint; import static net.runelite.client.util.StackFormatter.formatNumber; import net.runelite.client.util.Text; @@ -58,7 +64,12 @@ public class PlayerIndicatorsOverlay extends Overlay private final PlayerIndicatorsService playerIndicatorsService; private final ClanManager clanManager; + private final HiscoreManager hiscoreManager; private final PlayerIndicatorsPlugin plugin; + private final BufferedImage agilityIcon = ImageUtil.getResourceStreamFromClass(PlayerIndicatorsPlugin.class, + "agility.png"); + private final BufferedImage noAgilityIcon = ImageUtil.getResourceStreamFromClass(PlayerIndicatorsPlugin.class, + "no-agility.png"); private final BufferedImage skullIcon = ImageUtil.getResourceStreamFromClass(PlayerIndicatorsPlugin.class, "skull.png"); @Inject @@ -70,11 +81,12 @@ public class PlayerIndicatorsOverlay extends Overlay @Inject private PlayerIndicatorsOverlay(final PlayerIndicatorsPlugin plugin, final PlayerIndicatorsService playerIndicatorsService, - final ClanManager clanManager) + final ClanManager clanManager, final HiscoreManager hiscoreManager) { this.plugin = plugin; this.playerIndicatorsService = playerIndicatorsService; this.clanManager = clanManager; + this.hiscoreManager = hiscoreManager; setPosition(OverlayPosition.DYNAMIC); setPriority(OverlayPriority.MED); } @@ -174,10 +186,7 @@ public class PlayerIndicatorsOverlay extends Overlay } if (plugin.isShowCombatLevel()) { - - OverlayUtil.renderTextLocation(graphics, textLocation, name + " (" + actor.getCombatLevel() + ")", - color); - + name += " (" + actor.getCombatLevel() + ")"; } if (plugin.isTargetRisk() && PvPUtil.isAttackable(client, actor) && actor.getPlayerAppearance() != null) { @@ -232,6 +241,58 @@ public class PlayerIndicatorsOverlay extends Overlay textLocation.getY()); } } + + if (plugin.isShowAgilityLevel() && checkWildy()) + { + final HiscoreResult hiscoreResult = hiscoreManager.lookupAsync(actor.getName(), HiscoreEndpoint.NORMAL); + if (hiscoreResult != null) + { + int level = hiscoreResult.getSkill(HiscoreSkill.AGILITY).getLevel(); + if (plugin.getAgilityFormat() == PlayerIndicatorsPlugin.AgilityFormats.ICONS) + { + int width = graphics.getFontMetrics().stringWidth(name); + int height = graphics.getFontMetrics().getHeight(); + if (level >= plugin.getAgilityFirstThreshold()) + { + OverlayUtil.renderImageLocation(graphics, + new Point(textLocation.getX() + 5 + width, + textLocation.getY() - height), + ImageUtil.resizeImage(agilityIcon, height, height)); + } + if (level >= plugin.getAgilitySecondThreshold()) + { + OverlayUtil.renderImageLocation(graphics, + new Point(textLocation.getX() + agilityIcon.getWidth() + width, + textLocation.getY() - height), + ImageUtil.resizeImage(agilityIcon, height, height)); + } + if (level < plugin.getAgilityFirstThreshold()) + { + OverlayUtil.renderImageLocation(graphics, + new Point(textLocation.getX() + 5 + width, + textLocation.getY() - height), + ImageUtil.resizeImage(noAgilityIcon, height, height)); + } + } + else + { + name += " " + level; + + int width = graphics.getFontMetrics().stringWidth(name); + int height = graphics.getFontMetrics().getHeight(); + OverlayUtil.renderImageLocation(graphics, + new Point(textLocation.getX() + 5 + width, + textLocation.getY() - height), + ImageUtil.resizeImage(agilityIcon, height, height)); + } + } + } + OverlayUtil.renderTextLocation(graphics, textLocation, name, color); } + + private boolean checkWildy() + { + return client.getVar(Varbits.IN_WILDERNESS) == 1 || WorldType.isAllPvpWorld(client.getWorldType()); + } } 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 82c5e42bfa..8b01fa3530 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 @@ -135,6 +135,14 @@ public class PlayerIndicatorsPlugin extends Plugin @Getter(AccessLevel.PACKAGE) private Color getTargetColor; @Getter(AccessLevel.PACKAGE) + private boolean showAgilityLevel; + @Getter(AccessLevel.PACKAGE) + private int agilityFirstThreshold; + @Getter(AccessLevel.PACKAGE) + private int agilitySecondThreshold; + @Getter(AccessLevel.PACKAGE) + private PlayerIndicatorsPlugin.AgilityFormats agilityFormat; + @Getter(AccessLevel.PACKAGE) private boolean showCombatLevel; @Getter(AccessLevel.PACKAGE) private boolean playerSkull; @@ -404,6 +412,12 @@ public class PlayerIndicatorsPlugin extends Plugin BEFORE_NAME, AFTER_NAME } + + public enum AgilityFormats + { + TEXT, + ICONS + } private void updateConfig() { @@ -427,6 +441,10 @@ public class PlayerIndicatorsPlugin extends Plugin this.highlightTargets = config.highlightTargets(); this.getTargetColor = config.getTargetColor(); this.showCombatLevel = config.showCombatLevel(); + this.showAgilityLevel = config.showAgilityLevel(); + this.agilityFirstThreshold = config.agilityFirstThreshold(); + this.agilitySecondThreshold = config.agilitySecondThreshold(); + this.agilityFormat = config.agilityFormat(); this.playerSkull = config.playerSkull(); this.skullLocation = config.skullLocation(); this.skulledTargetsOnly = config.skulledTargetsOnly(); diff --git a/runelite-client/src/main/resources/net/runelite/client/plugins/playerindicators/agility.png b/runelite-client/src/main/resources/net/runelite/client/plugins/playerindicators/agility.png new file mode 100644 index 0000000000000000000000000000000000000000..42d1d93d074282da1c3207917fc83bf80856d281 GIT binary patch literal 232 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`oCO|{#S9GG!XV7ZFl&wkP;i!~ zi(`mIZ)>n4-vI>luxbM|IdH4I!zNdZ?2d_=kDGulgNPA#*X*;J(7uT1ti_xJE zGq3wUeRDrANpi`md*@Hzd8R8fxj4sm`kR!gcaA>`l6c{=sH;MH@ph~Gbz=MtE1DQ3 zx@42YKgs1RSemY77`wz~g|Md@N5fWG*G)nfVt33p*I1IbK~=s@GH2C-N&h`+U%gUK d5}WdiA#A?q3mvXH6QC;@JYD@<);T3K0RRD*SdIVy literal 0 HcmV?d00001 diff --git a/runelite-client/src/main/resources/net/runelite/client/plugins/playerindicators/no-agility.png b/runelite-client/src/main/resources/net/runelite/client/plugins/playerindicators/no-agility.png new file mode 100644 index 0000000000000000000000000000000000000000..3f4915d0419444a5b2307d16643b4a5e36cf62f9 GIT binary patch literal 299 zcmeAS@N?(olHy`uVBq!ia0vp^d?3uh1|;P@bT0xa&H|6fVg?3oVGw3ym^DWND0tV? z#W6%<;@pddUPl51*dFM==Q$)Mz3qk*cfNp9({zDtQ70Daq-+${ey`AW=b+m()o2d6 zgNM?>l0SJo)P8=}oaevD?oBqwW%Fk5`)~5OEVZ&NJxBOmVRKpdv~I~Q4&B-|DmeuQ zSa-?vMTy(8=LB8;?jBNc-0DM7!?eb07lTb}>vfERuN!XdTF#g4uk{=e4e6hER(3JY@|k;E?cvG% uC&Da&s~4rW9&b@wcGc44kZIh;zidH`nZ;AQ*G>R>l)=;0&t;ucLK6UgICIPZ literal 0 HcmV?d00001