blast furnace: add coffer time remaining overlay

This commit is contained in:
Daniel
2020-02-23 17:14:02 -05:00
committed by GitHub
parent c9e487fc9e
commit d52fe009f5
2 changed files with 31 additions and 3 deletions

View File

@@ -34,6 +34,7 @@ import net.runelite.api.widgets.Widget;
import net.runelite.api.widgets.WidgetInfo;
import net.runelite.client.ui.overlay.Overlay;
import static net.runelite.client.ui.overlay.OverlayManager.OPTION_CONFIGURE;
import static org.apache.commons.lang3.time.DurationFormatUtils.formatDuration;
import net.runelite.client.ui.overlay.OverlayMenuEntry;
import net.runelite.client.ui.overlay.OverlayPosition;
import net.runelite.client.ui.overlay.components.LineComponent;
@@ -42,17 +43,21 @@ import net.runelite.client.util.QuantityFormatter;
class BlastFurnaceCofferOverlay extends Overlay
{
private static final float COST_PER_HOUR = 72000.0f;
private final Client client;
private final BlastFurnacePlugin plugin;
private final BlastFurnaceConfig config;
private final PanelComponent panelComponent = new PanelComponent();
@Inject
private BlastFurnaceCofferOverlay(Client client, BlastFurnacePlugin plugin)
private BlastFurnaceCofferOverlay(Client client, BlastFurnacePlugin plugin, BlastFurnaceConfig config)
{
super(plugin);
setPosition(OverlayPosition.TOP_LEFT);
this.client = client;
this.plugin = plugin;
this.config = config;
getMenuEntries().add(new OverlayMenuEntry(RUNELITE_OVERLAY_CONFIG, OPTION_CONFIGURE, "Coffer overlay"));
}
@@ -70,14 +75,26 @@ class BlastFurnaceCofferOverlay extends Overlay
if (sack != null)
{
final int coffer = client.getVar(BLAST_FURNACE_COFFER);
sack.setHidden(true);
panelComponent.getChildren().add(LineComponent.builder()
.left("Coffer:")
.right(QuantityFormatter.quantityToStackSize(client.getVar(BLAST_FURNACE_COFFER)) + " gp")
.right(QuantityFormatter.quantityToStackSize(coffer) + " gp")
.build());
if (config.showCofferTime())
{
final long millis = (long) (coffer / COST_PER_HOUR * 60 * 60 * 1000);
panelComponent.getChildren().add(LineComponent.builder()
.left("Time:")
.right(formatDuration(millis, "H'h' m'm' s's'", true))
.build());
}
}
return panelComponent.render(graphics);
}
}
}

View File

@@ -52,4 +52,15 @@ public interface BlastFurnaceConfig extends Config
{
return false;
}
@ConfigItem(
keyName = "showCofferTime",
name = "Show coffer time remaining",
description = "Configures whether or not the coffer time remaining is displayed",
position = 3
)
default boolean showCofferTime()
{
return true;
}
}