Search in sources :

Example 6 with WidgetItem

use of net.runelite.api.widgets.WidgetItem 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 7 with WidgetItem

use of net.runelite.api.widgets.WidgetItem in project runelite by runelite.

the class BindNeckOverlay method render.

@Override
public Dimension render(Graphics2D graphics) {
    if (!config.showBindNeck()) {
        return null;
    }
    graphics.setFont(FontManager.getRunescapeSmallFont());
    for (WidgetItem necklace : getNecklaceWidgetItems()) {
        final Color color = bindingCharges == 1 ? Color.RED : Color.WHITE;
        final Rectangle bounds = necklace.getCanvasBounds();
        final String text = bindingCharges <= 0 ? "?" : bindingCharges + "";
        final TextComponent textComponent = new TextComponent();
        textComponent.setPosition(new Point(bounds.x, bounds.y + 16));
        textComponent.setText(text);
        textComponent.setColor(color);
        textComponent.render(graphics);
    }
    return null;
}
Also used : TextComponent(net.runelite.client.ui.overlay.components.TextComponent) Color(java.awt.Color) Rectangle(java.awt.Rectangle) WidgetItem(net.runelite.api.widgets.WidgetItem) Point(java.awt.Point)

Example 8 with WidgetItem

use of net.runelite.api.widgets.WidgetItem 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 9 with WidgetItem

use of net.runelite.api.widgets.WidgetItem in project runelite by runelite.

the class ShopItemQuery method getShopItems.

private Collection<WidgetItem> getShopItems(Client client) {
    Collection<WidgetItem> widgetItems = new ArrayList<>();
    Widget shop = client.getWidget(WidgetInfo.SHOP_ITEMS_CONTAINER);
    if (shop != null && !shop.isHidden()) {
        Widget[] children = shop.getDynamicChildren();
        for (int i = 1; i < children.length; i++) {
            // set bounds to same size as default inventory
            Rectangle bounds = children[i].getBounds();
            bounds.setBounds(bounds.x - 1, bounds.y - 1, 32, 32);
            widgetItems.add(new WidgetItem(children[i].getItemId(), children[i].getItemQuantity(), i - 1, bounds));
        }
    }
    return widgetItems;
}
Also used : ArrayList(java.util.ArrayList) Widget(net.runelite.api.widgets.Widget) Rectangle(java.awt.Rectangle) WidgetItem(net.runelite.api.widgets.WidgetItem)

Example 10 with WidgetItem

use of net.runelite.api.widgets.WidgetItem in project runelite by runelite.

the class JewelleryCountOverlay method render.

@Override
public Dimension render(Graphics2D graphics) {
    graphics.setFont(FontManager.getRunescapeSmallFont());
    for (WidgetItem item : getJewelleryWidgetItems()) {
        JewelleryCharges charges = JewelleryCharges.getCharges(item.getId());
        if (charges == null) {
            continue;
        }
        final Rectangle bounds = item.getCanvasBounds();
        final TextComponent textComponent = new TextComponent();
        textComponent.setPosition(new Point(bounds.x, bounds.y + 16));
        textComponent.setText(String.valueOf(charges.getCharges()));
        textComponent.render(graphics);
    }
    return null;
}
Also used : TextComponent(net.runelite.client.ui.overlay.components.TextComponent) Rectangle(java.awt.Rectangle) WidgetItem(net.runelite.api.widgets.WidgetItem) Point(java.awt.Point)

Aggregations

WidgetItem (net.runelite.api.widgets.WidgetItem)25 Rectangle (java.awt.Rectangle)13 Widget (net.runelite.api.widgets.Widget)10 Point (java.awt.Point)8 ArrayList (java.util.ArrayList)8 InventoryWidgetItemQuery (net.runelite.api.queries.InventoryWidgetItemQuery)7 Query (net.runelite.api.Query)6 TextComponent (net.runelite.client.ui.overlay.components.TextComponent)5 ItemComposition (net.runelite.api.ItemComposition)4 Point (net.runelite.api.Point)4 EquipmentItemQuery (net.runelite.api.queries.EquipmentItemQuery)3 Color (java.awt.Color)2 BufferedImage (java.awt.image.BufferedImage)2 HashMap (java.util.HashMap)2 Varbits (net.runelite.api.Varbits)2 LocalPoint (net.runelite.api.coords.LocalPoint)2 Inject (net.runelite.api.mixins.Inject)2 WidgetInfo (net.runelite.api.widgets.WidgetInfo)2 Tooltip (net.runelite.client.ui.overlay.tooltip.Tooltip)2 Font (java.awt.Font)1