Add potential reward to the barrows overlay

- Add potential reward to the barrows side overlay
- Fix checkboxes on the side for brothers slain

All credits to https://github.com/runelite/runelite/pull/1858
This commit is contained in:
unknown
2018-11-04 18:28:23 +10:30
committed by Tomas Slusny
parent 90fbf71859
commit d38c9b0684
2 changed files with 16 additions and 4 deletions

View File

@@ -323,6 +323,8 @@ public enum Varbits
BARROWS_KILLED_KARIL(460), BARROWS_KILLED_KARIL(460),
BARROWS_KILLED_TORAG(461), BARROWS_KILLED_TORAG(461),
BARROWS_KILLED_VERAC(462), BARROWS_KILLED_VERAC(462),
BARROWS_REWARD_POTENTIAL(463),
BARROWS_NPCS_SLAIN(464),
/** /**
* Spicy stew ingredients * Spicy stew ingredients

View File

@@ -29,6 +29,7 @@ import java.awt.Dimension;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import javax.inject.Inject; import javax.inject.Inject;
import net.runelite.api.Client; import net.runelite.api.Client;
import net.runelite.api.Varbits;
import net.runelite.api.widgets.Widget; import net.runelite.api.widgets.Widget;
import net.runelite.api.widgets.WidgetInfo; import net.runelite.api.widgets.WidgetInfo;
import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.Overlay;
@@ -54,31 +55,40 @@ public class BarrowsBrotherSlainOverlay extends Overlay
public Dimension render(Graphics2D graphics) public Dimension render(Graphics2D graphics)
{ {
// Do not display overlay if potential is null/hidden // Do not display overlay if potential is null/hidden
Widget potential = client.getWidget(WidgetInfo.BARROWS_POTENTIAL); final Widget potential = client.getWidget(WidgetInfo.BARROWS_POTENTIAL);
if (potential == null || potential.isHidden()) if (potential == null || potential.isHidden())
{ {
return null; return null;
} }
// Hide original overlay // Hide original overlay
Widget barrowsBrothers = client.getWidget(WidgetInfo.BARROWS_BROTHERS); final Widget barrowsBrothers = client.getWidget(WidgetInfo.BARROWS_BROTHERS);
if (barrowsBrothers != null) if (barrowsBrothers != null)
{ {
barrowsBrothers.setHidden(true); barrowsBrothers.setHidden(true);
potential.setHidden(true);
} }
panelComponent.getChildren().clear(); panelComponent.getChildren().clear();
for (BarrowsBrothers brother : BarrowsBrothers.values()) for (BarrowsBrothers brother : BarrowsBrothers.values())
{ {
String slain = client.getVar(brother.getKilledVarbit()) > 0 ? "" : ""; final boolean brotherSlain = client.getVar(brother.getKilledVarbit()) > 0;
String slain = brotherSlain ? "\u2713" : "\u2717";
panelComponent.getChildren().add(LineComponent.builder() panelComponent.getChildren().add(LineComponent.builder()
.left(brother.getName()) .left(brother.getName())
.right(slain) .right(slain)
.rightColor(slain.isEmpty() ? Color.WHITE : Color.GREEN) .rightColor(brotherSlain ? Color.GREEN : Color.RED)
.build()); .build());
} }
float rewardPercent = client.getVar(Varbits.BARROWS_REWARD_POTENTIAL) / 10.0f;
panelComponent.getChildren().add(LineComponent.builder()
.left("Potential")
.right(rewardPercent != 0 ? rewardPercent + "%" : "0%")
.rightColor(rewardPercent >= 73.0f && rewardPercent <= 88.0f ? Color.GREEN : rewardPercent < 65.6f ? Color.WHITE : Color.YELLOW)
.build());
return panelComponent.render(graphics); return panelComponent.render(graphics);
} }
} }