Merge remote-tracking branch 'runelite/master'
This commit is contained in:
@@ -29,6 +29,10 @@ package net.runelite.api;
|
|||||||
*/
|
*/
|
||||||
public final class ParamID
|
public final class ParamID
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Long name for NPCs used in the HP hud
|
||||||
|
*/
|
||||||
|
public static final int NPC_HP_NAME = 510;
|
||||||
/**
|
/**
|
||||||
* @see SettingID
|
* @see SettingID
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -650,7 +650,14 @@ public enum Varbits
|
|||||||
* 2 = popup notification only
|
* 2 = popup notification only
|
||||||
* 3 = chat and popup
|
* 3 = chat and popup
|
||||||
*/
|
*/
|
||||||
COLLECTION_LOG_NOTIFICATION(11959);
|
COLLECTION_LOG_NOTIFICATION(11959),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show boss health overlay setting
|
||||||
|
* 0 = on
|
||||||
|
* 1 = off
|
||||||
|
*/
|
||||||
|
BOSS_HEALTH_OVERLAY(12389);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The raw varbit ID.
|
* The raw varbit ID.
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
*/
|
*/
|
||||||
package net.runelite.client.plugins.opponentinfo;
|
package net.runelite.client.plugins.opponentinfo;
|
||||||
|
|
||||||
|
import com.google.common.base.Strings;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.FontMetrics;
|
import java.awt.FontMetrics;
|
||||||
@@ -33,9 +34,14 @@ import java.awt.Point;
|
|||||||
import java.awt.Rectangle;
|
import java.awt.Rectangle;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import net.runelite.api.Actor;
|
import net.runelite.api.Actor;
|
||||||
|
import net.runelite.api.Client;
|
||||||
import static net.runelite.api.MenuAction.RUNELITE_OVERLAY_CONFIG;
|
import static net.runelite.api.MenuAction.RUNELITE_OVERLAY_CONFIG;
|
||||||
import net.runelite.api.NPC;
|
import net.runelite.api.NPC;
|
||||||
|
import net.runelite.api.NPCComposition;
|
||||||
|
import net.runelite.api.ParamID;
|
||||||
import net.runelite.api.Player;
|
import net.runelite.api.Player;
|
||||||
|
import net.runelite.api.VarPlayer;
|
||||||
|
import net.runelite.api.Varbits;
|
||||||
import net.runelite.client.game.HiscoreManager;
|
import net.runelite.client.game.HiscoreManager;
|
||||||
import net.runelite.client.game.NPCManager;
|
import net.runelite.client.game.NPCManager;
|
||||||
import static net.runelite.client.ui.overlay.OverlayManager.OPTION_CONFIGURE;
|
import static net.runelite.client.ui.overlay.OverlayManager.OPTION_CONFIGURE;
|
||||||
@@ -54,6 +60,7 @@ class OpponentInfoOverlay extends OverlayPanel
|
|||||||
private static final Color HP_GREEN = new Color(0, 146, 54, 230);
|
private static final Color HP_GREEN = new Color(0, 146, 54, 230);
|
||||||
private static final Color HP_RED = new Color(102, 15, 16, 230);
|
private static final Color HP_RED = new Color(102, 15, 16, 230);
|
||||||
|
|
||||||
|
private final Client client;
|
||||||
private final OpponentInfoPlugin opponentInfoPlugin;
|
private final OpponentInfoPlugin opponentInfoPlugin;
|
||||||
private final OpponentInfoConfig opponentInfoConfig;
|
private final OpponentInfoConfig opponentInfoConfig;
|
||||||
private final HiscoreManager hiscoreManager;
|
private final HiscoreManager hiscoreManager;
|
||||||
@@ -66,12 +73,14 @@ class OpponentInfoOverlay extends OverlayPanel
|
|||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private OpponentInfoOverlay(
|
private OpponentInfoOverlay(
|
||||||
|
Client client,
|
||||||
OpponentInfoPlugin opponentInfoPlugin,
|
OpponentInfoPlugin opponentInfoPlugin,
|
||||||
OpponentInfoConfig opponentInfoConfig,
|
OpponentInfoConfig opponentInfoConfig,
|
||||||
HiscoreManager hiscoreManager,
|
HiscoreManager hiscoreManager,
|
||||||
NPCManager npcManager)
|
NPCManager npcManager)
|
||||||
{
|
{
|
||||||
super(opponentInfoPlugin);
|
super(opponentInfoPlugin);
|
||||||
|
this.client = client;
|
||||||
this.opponentInfoPlugin = opponentInfoPlugin;
|
this.opponentInfoPlugin = opponentInfoPlugin;
|
||||||
this.opponentInfoConfig = opponentInfoConfig;
|
this.opponentInfoConfig = opponentInfoConfig;
|
||||||
this.hiscoreManager = hiscoreManager;
|
this.hiscoreManager = hiscoreManager;
|
||||||
@@ -105,6 +114,15 @@ class OpponentInfoOverlay extends OverlayPanel
|
|||||||
lastMaxHealth = null;
|
lastMaxHealth = null;
|
||||||
if (opponent instanceof NPC)
|
if (opponent instanceof NPC)
|
||||||
{
|
{
|
||||||
|
NPCComposition composition = ((NPC) opponent).getTransformedComposition();
|
||||||
|
if (composition != null)
|
||||||
|
{
|
||||||
|
String longName = composition.getStringValue(ParamID.NPC_HP_NAME);
|
||||||
|
if (!Strings.isNullOrEmpty(longName))
|
||||||
|
{
|
||||||
|
opponentName = longName;
|
||||||
|
}
|
||||||
|
}
|
||||||
lastMaxHealth = npcManager.getHealth(((NPC) opponent).getId());
|
lastMaxHealth = npcManager.getHealth(((NPC) opponent).getId());
|
||||||
}
|
}
|
||||||
else if (opponent instanceof Player)
|
else if (opponent instanceof Player)
|
||||||
@@ -121,7 +139,9 @@ class OpponentInfoOverlay extends OverlayPanel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (opponentName == null)
|
// The in-game hp hud is more accurate than our overlay and duplicates all of the information on it,
|
||||||
|
// so hide ours if it is visible.
|
||||||
|
if (opponentName == null || hasHpHud(opponent))
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -198,4 +218,20 @@ class OpponentInfoOverlay extends OverlayPanel
|
|||||||
|
|
||||||
return super.render(graphics);
|
return super.render(graphics);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the hp hud is active for an opponent
|
||||||
|
* @param opponent
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private boolean hasHpHud(Actor opponent)
|
||||||
|
{
|
||||||
|
boolean settingEnabled = client.getVar(Varbits.BOSS_HEALTH_OVERLAY) == 0;
|
||||||
|
if (settingEnabled && opponent instanceof NPC)
|
||||||
|
{
|
||||||
|
int opponentId = client.getVar(VarPlayer.HP_HUD_NPC_ID);
|
||||||
|
return opponentId != -1 && opponentId == ((NPC) opponent).getId();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user