opponent info: add config opt to show health as percent

This commit is contained in:
Adam
2018-09-21 17:27:31 -04:00
parent 7000c252a0
commit 78eb357bbf
2 changed files with 18 additions and 3 deletions

View File

@@ -34,10 +34,22 @@ public interface OpponentInfoConfig extends Config
@ConfigItem(
keyName = "lookupOnInteraction",
name = "Lookup players on interaction",
description = "Display a combat stat comparison panel on player interaction. (follow, trade, challenge, attack, etc.)"
description = "Display a combat stat comparison panel on player interaction. (follow, trade, challenge, attack, etc.)",
position = 0
)
default boolean lookupOnInteraction()
{
return false;
}
@ConfigItem(
keyName = "showPercent",
name = "Show percent",
description = "Shows hitpoints as a percentage even if hitpoints are known",
position = 1
)
default boolean showPercent()
{
return false;
}
}

View File

@@ -55,6 +55,7 @@ class OpponentInfoOverlay extends Overlay
private final Client client;
private final OpponentInfoPlugin opponentInfoPlugin;
private final OpponentInfoConfig opponentInfoConfig;
private final HiscoreManager hiscoreManager;
private final PanelComponent panelComponent = new PanelComponent();
@@ -65,10 +66,12 @@ class OpponentInfoOverlay extends Overlay
private String opponentsOpponentName;
@Inject
private OpponentInfoOverlay(Client client, OpponentInfoPlugin opponentInfoPlugin, HiscoreManager hiscoreManager)
private OpponentInfoOverlay(Client client, OpponentInfoPlugin opponentInfoPlugin,
OpponentInfoConfig opponentInfoConfig, HiscoreManager hiscoreManager)
{
this.client = client;
this.opponentInfoPlugin = opponentInfoPlugin;
this.opponentInfoConfig = opponentInfoConfig;
this.hiscoreManager = hiscoreManager;
setPosition(OverlayPosition.TOP_LEFT);
@@ -147,7 +150,7 @@ class OpponentInfoOverlay extends Overlay
progressBarComponent.setBackgroundColor(HP_RED);
progressBarComponent.setForegroundColor(HP_GREEN);
if (lastMaxHealth != null)
if (lastMaxHealth != null && !opponentInfoConfig.showPercent())
{
progressBarComponent.setLabelDisplayMode(ProgressBarComponent.LabelDisplayMode.FULL);
progressBarComponent.setMaximum(lastMaxHealth);