Search in sources :

Example 1 with InventoryWidgetItemQuery

use of net.runelite.api.queries.InventoryWidgetItemQuery in project runelite by runelite.

the class SlayerOverlay method getSlayerWidgetItems.

private Collection<WidgetItem> getSlayerWidgetItems() {
    Query inventoryQuery = new InventoryWidgetItemQuery();
    WidgetItem[] inventoryWidgetItems = queryRunner.runQuery(inventoryQuery);
    Query equipmentQuery = new EquipmentItemQuery().slotEquals(WidgetInfo.EQUIPMENT_HELMET, WidgetInfo.EQUIPMENT_RING);
    WidgetItem[] equipmentWidgetItems = queryRunner.runQuery(equipmentQuery);
    WidgetItem[] items = concat(inventoryWidgetItems, equipmentWidgetItems, WidgetItem.class);
    return ImmutableList.copyOf(items);
}
Also used : InventoryWidgetItemQuery(net.runelite.api.queries.InventoryWidgetItemQuery) EquipmentItemQuery(net.runelite.api.queries.EquipmentItemQuery) Query(net.runelite.api.Query) EquipmentItemQuery(net.runelite.api.queries.EquipmentItemQuery) InventoryWidgetItemQuery(net.runelite.api.queries.InventoryWidgetItemQuery) WidgetItem(net.runelite.api.widgets.WidgetItem)

Example 2 with InventoryWidgetItemQuery

use of net.runelite.api.queries.InventoryWidgetItemQuery in project runelite by runelite.

the class TitheFarmInventoryOverlay method render.

@Override
public Dimension render(Graphics2D graphics) {
    if (!config.showWateringCanOverlay()) {
        return null;
    }
    graphics.setFont(FontManager.getRunescapeSmallFont());
    Query inventoryQuery = new InventoryWidgetItemQuery();
    WidgetItem[] inventoryItems = queryRunner.runQuery(inventoryQuery);
    for (WidgetItem item : inventoryItems) {
        WateringCan wateringCan = WateringCan.getWateringCan(item.getId());
        if (wateringCan == null) {
            continue;
        }
        final Rectangle bounds = item.getCanvasBounds();
        textComponent.setPosition(new Point(bounds.x, bounds.y + 16));
        textComponent.setColor(wateringCan.getColor());
        textComponent.setText(String.valueOf(wateringCan.getCharges()));
        textComponent.render(graphics);
    }
    return null;
}
Also used : InventoryWidgetItemQuery(net.runelite.api.queries.InventoryWidgetItemQuery) Query(net.runelite.api.Query) InventoryWidgetItemQuery(net.runelite.api.queries.InventoryWidgetItemQuery) Rectangle(java.awt.Rectangle) WidgetItem(net.runelite.api.widgets.WidgetItem) Point(java.awt.Point)

Example 3 with InventoryWidgetItemQuery

use of net.runelite.api.queries.InventoryWidgetItemQuery 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;
}
Also used : InventoryWidgetItemQuery(net.runelite.api.queries.InventoryWidgetItemQuery) TextComponent(net.runelite.client.ui.overlay.components.TextComponent) Query(net.runelite.api.Query) InventoryWidgetItemQuery(net.runelite.api.queries.InventoryWidgetItemQuery) Rectangle(java.awt.Rectangle) WidgetItem(net.runelite.api.widgets.WidgetItem) Point(java.awt.Point) Varbits(net.runelite.api.Varbits)

Example 4 with InventoryWidgetItemQuery

use of net.runelite.api.queries.InventoryWidgetItemQuery 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;
}
Also used : InventoryWidgetItemQuery(net.runelite.api.queries.InventoryWidgetItemQuery) Query(net.runelite.api.Query) InventoryWidgetItemQuery(net.runelite.api.queries.InventoryWidgetItemQuery) Tooltip(net.runelite.client.ui.overlay.tooltip.Tooltip) WidgetItem(net.runelite.api.widgets.WidgetItem) Point(net.runelite.api.Point) Point(net.runelite.api.Point) BufferedImage(java.awt.image.BufferedImage) Varbits(net.runelite.api.Varbits)

Example 5 with InventoryWidgetItemQuery

use of net.runelite.api.queries.InventoryWidgetItemQuery in project runelite by runelite.

the class BindNeckOverlay method getNecklaceWidgetItems.

private Collection<WidgetItem> getNecklaceWidgetItems() {
    Query inventoryQuery = new InventoryWidgetItemQuery().idEquals(BINDING_NECKLACE);
    WidgetItem[] inventoryWidgetItems = queryRunner.runQuery(inventoryQuery);
    Query equipmentQuery = new EquipmentItemQuery().slotEquals(WidgetInfo.EQUIPMENT_AMULET).idEquals(BINDING_NECKLACE);
    WidgetItem[] equipmentWidgetItems = queryRunner.runQuery(equipmentQuery);
    Collection<WidgetItem> necklaces = new ArrayList<>();
    necklaces.addAll(Arrays.asList(inventoryWidgetItems));
    necklaces.addAll(Arrays.asList(equipmentWidgetItems));
    return necklaces;
}
Also used : InventoryWidgetItemQuery(net.runelite.api.queries.InventoryWidgetItemQuery) EquipmentItemQuery(net.runelite.api.queries.EquipmentItemQuery) Query(net.runelite.api.Query) EquipmentItemQuery(net.runelite.api.queries.EquipmentItemQuery) InventoryWidgetItemQuery(net.runelite.api.queries.InventoryWidgetItemQuery) ArrayList(java.util.ArrayList) WidgetItem(net.runelite.api.widgets.WidgetItem)

Aggregations

InventoryWidgetItemQuery (net.runelite.api.queries.InventoryWidgetItemQuery)7 WidgetItem (net.runelite.api.widgets.WidgetItem)7 Query (net.runelite.api.Query)6 Point (java.awt.Point)3 EquipmentItemQuery (net.runelite.api.queries.EquipmentItemQuery)3 Rectangle (java.awt.Rectangle)2 ArrayList (java.util.ArrayList)2 Varbits (net.runelite.api.Varbits)2 Tooltip (net.runelite.client.ui.overlay.tooltip.Tooltip)2 BufferedImage (java.awt.image.BufferedImage)1 Point (net.runelite.api.Point)1 TextComponent (net.runelite.client.ui.overlay.components.TextComponent)1