use of net.runelite.api.Varbits in project runelite by runelite.
the class RunecraftOverlay method render.
@Override
public Dimension render(Graphics2D graphics) {
if (!config.showPouch()) {
return null;
}
Query query = new InventoryWidgetItemQuery();
WidgetItem[] widgetItems = queryRunner.runQuery(query);
graphics.setFont(FontManager.getRunescapeSmallFont());
for (WidgetItem item : widgetItems) {
Varbits varbits;
switch(item.getId()) {
case ItemID.SMALL_POUCH:
varbits = Varbits.POUCH_SMALL;
break;
case ItemID.MEDIUM_POUCH:
case MEDIUM_POUCH_DAMAGED:
varbits = Varbits.POUCH_MEDIUM;
break;
case ItemID.LARGE_POUCH:
case LARGE_POUCH_DAMAGED:
varbits = Varbits.POUCH_LARGE;
break;
case ItemID.GIANT_POUCH:
case GIANT_POUCH_DAMAGED:
varbits = Varbits.POUCH_GIANT;
break;
default:
continue;
}
final Rectangle bounds = item.getCanvasBounds();
final TextComponent textComponent = new TextComponent();
textComponent.setPosition(new Point(bounds.x, bounds.y + 16));
textComponent.setText(String.valueOf(client.getSetting(varbits)));
textComponent.render(graphics);
}
return null;
}
use of net.runelite.api.Varbits in project runelite by runelite.
the class RunepouchOverlay method render.
@Override
public Dimension render(Graphics2D graphics) {
Query query = new InventoryWidgetItemQuery().idEquals(ItemID.RUNE_POUCH);
WidgetItem[] items = queryRunner.runQuery(query);
if (items.length == 0) {
return null;
}
WidgetItem runePouch = items[0];
Point location = runePouch.getCanvasLocation();
if (location == null) {
return null;
}
assert AMOUNT_VARBITS.length == RUNE_VARBITS.length;
graphics.setFont(FontManager.getRunescapeSmallFont());
StringBuilder tooltipBuilder = new StringBuilder();
for (int i = 0; i < AMOUNT_VARBITS.length; i++) {
Varbits amountVarbit = AMOUNT_VARBITS[i];
int amount = client.getSetting(amountVarbit);
if (amount <= 0) {
continue;
}
Varbits runeVarbit = RUNE_VARBITS[i];
int runeId = client.getSetting(runeVarbit);
Runes rune = Runes.getRune(runeId);
if (rune == null) {
continue;
}
tooltipBuilder.append(amount).append(" <col=ffff00>").append(rune.getName()).append("</col></br>");
if (config.showOnlyOnHover()) {
continue;
}
graphics.setColor(Color.black);
graphics.drawString("" + formatNumber(amount), location.getX() + (config.showIcons() ? 13 : 6), location.getY() + 14 + (graphics.getFontMetrics().getHeight() - 1) * i);
graphics.setColor(config.fontColor());
graphics.drawString("" + formatNumber(amount), location.getX() + (config.showIcons() ? 12 : 5), location.getY() + 13 + (graphics.getFontMetrics().getHeight() - 1) * i);
if (!config.showIcons()) {
continue;
}
BufferedImage image = getRuneImage(rune);
if (image != null) {
OverlayUtil.renderImageLocation(graphics, new Point(location.getX(), location.getY() + graphics.getFontMetrics().getHeight() * i), image);
}
}
String tooltip = tooltipBuilder.toString();
if (!tooltip.isEmpty() && runePouch.getCanvasBounds().contains(client.getMouseCanvasPosition().getX(), client.getMouseCanvasPosition().getY())) {
tooltipManager.add(new Tooltip(tooltip));
}
return null;
}
Aggregations