opponent info: hide overlay if hp hud is active
This commit is contained in:
@@ -624,7 +624,14 @@ public enum Varbits
|
||||
* 2 = popup notification only
|
||||
* 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.
|
||||
|
||||
@@ -33,9 +33,12 @@ import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import javax.inject.Inject;
|
||||
import net.runelite.api.Actor;
|
||||
import net.runelite.api.Client;
|
||||
import static net.runelite.api.MenuAction.RUNELITE_OVERLAY_CONFIG;
|
||||
import net.runelite.api.NPC;
|
||||
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.NPCManager;
|
||||
import static net.runelite.client.ui.overlay.OverlayManager.OPTION_CONFIGURE;
|
||||
@@ -54,6 +57,7 @@ class OpponentInfoOverlay extends OverlayPanel
|
||||
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 final Client client;
|
||||
private final OpponentInfoPlugin opponentInfoPlugin;
|
||||
private final OpponentInfoConfig opponentInfoConfig;
|
||||
private final HiscoreManager hiscoreManager;
|
||||
@@ -66,12 +70,14 @@ class OpponentInfoOverlay extends OverlayPanel
|
||||
|
||||
@Inject
|
||||
private OpponentInfoOverlay(
|
||||
Client client,
|
||||
OpponentInfoPlugin opponentInfoPlugin,
|
||||
OpponentInfoConfig opponentInfoConfig,
|
||||
HiscoreManager hiscoreManager,
|
||||
NPCManager npcManager)
|
||||
{
|
||||
super(opponentInfoPlugin);
|
||||
this.client = client;
|
||||
this.opponentInfoPlugin = opponentInfoPlugin;
|
||||
this.opponentInfoConfig = opponentInfoConfig;
|
||||
this.hiscoreManager = hiscoreManager;
|
||||
@@ -121,7 +127,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;
|
||||
}
|
||||
@@ -198,4 +206,20 @@ class OpponentInfoOverlay extends OverlayPanel
|
||||
|
||||
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