Search in sources :

Example 21 with WidgetItem

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

the class JewelleryCountOverlay method getJewelleryWidgetItems.

private Collection<WidgetItem> getJewelleryWidgetItems() {
    Query inventoryQuery = new InventoryWidgetItemQuery();
    WidgetItem[] inventoryWidgetItems = queryRunner.runQuery(inventoryQuery);
    Query equipmentQuery = new EquipmentItemQuery().slotEquals(WidgetInfo.EQUIPMENT_AMULET, WidgetInfo.EQUIPMENT_RING, WidgetInfo.EQUIPMENT_GLOVES, WidgetInfo.EQUIPMENT_WEAPON);
    WidgetItem[] equipmentWidgetItems = queryRunner.runQuery(equipmentQuery);
    Collection<WidgetItem> jewellery = new ArrayList<>();
    jewellery.addAll(Arrays.asList(inventoryWidgetItems));
    jewellery.addAll(Arrays.asList(equipmentWidgetItems));
    return jewellery;
}
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)

Example 22 with WidgetItem

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

the class ItemStatOverlay method render.

@Override
public Dimension render(Graphics2D graphics) {
    if (client.isMenuOpen() || (!config.relative() && !config.absolute() && !config.theoretical())) {
        return null;
    }
    WidgetItem[] inventory = queryRunner.runQuery(new InventoryWidgetItemQuery());
    Point mousePos = new Point(client.getMouseCanvasPosition().getX(), client.getMouseCanvasPosition().getY());
    for (WidgetItem item : inventory) {
        if (item.getCanvasBounds().contains(mousePos)) {
            Effect change = statChanges.get(item.getId());
            if (change != null) {
                StringBuilder b = new StringBuilder();
                StatsChanges statsChanges = change.calculate(client);
                for (StatChange c : statsChanges.getStatChanges()) {
                    b.append(buildStatChangeString(c));
                }
                tooltipManager.add(new Tooltip(b.toString()));
            }
        }
    }
    return null;
}
Also used : InventoryWidgetItemQuery(net.runelite.api.queries.InventoryWidgetItemQuery) Tooltip(net.runelite.client.ui.overlay.tooltip.Tooltip) WidgetItem(net.runelite.api.widgets.WidgetItem) Point(java.awt.Point)

Example 23 with WidgetItem

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

the class DevToolsOverlay method renderInventory.

private void renderInventory(Graphics2D graphics) {
    Widget inventoryWidget = client.getWidget(WidgetInfo.INVENTORY);
    if (inventoryWidget == null || inventoryWidget.isHidden()) {
        return;
    }
    for (WidgetItem item : inventoryWidget.getWidgetItems()) {
        Rectangle slotBounds = item.getCanvasBounds();
        String idText = "" + item.getId();
        FontMetrics fm = graphics.getFontMetrics();
        Rectangle2D textBounds = fm.getStringBounds(idText, graphics);
        int textX = (int) (slotBounds.getX() + (slotBounds.getWidth() / 2) - (textBounds.getWidth() / 2));
        int textY = (int) (slotBounds.getY() + (slotBounds.getHeight() / 2) + (textBounds.getHeight() / 2));
        graphics.setColor(new Color(255, 255, 255, 65));
        graphics.fill(slotBounds);
        graphics.setColor(Color.BLACK);
        graphics.drawString(idText, textX + 1, textY + 1);
        graphics.setColor(YELLOW);
        graphics.drawString(idText, textX, textY);
    }
}
Also used : FontMetrics(java.awt.FontMetrics) Color(java.awt.Color) Widget(net.runelite.api.widgets.Widget) Rectangle(java.awt.Rectangle) Rectangle2D(java.awt.geom.Rectangle2D) WidgetItem(net.runelite.api.widgets.WidgetItem) LocalPoint(net.runelite.api.coords.LocalPoint)

Example 24 with WidgetItem

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

the class GrandExchangePlugin method startUp.

@Override
protected void startUp() throws IOException {
    panel = injector.getInstance(GrandExchangePanel.class);
    BufferedImage icon;
    synchronized (ImageIO.class) {
        icon = ImageIO.read(getClass().getResourceAsStream("ge_icon.png"));
    }
    button = NavigationButton.builder().name("GE Offers").icon(icon).panel(panel).build();
    pluginToolbar.addNavigation(button);
    itemClick = new MouseListener() {

        @Override
        public MouseEvent mouseClicked(MouseEvent e) {
            // Check if left click + alt
            if (e.getButton() == MouseEvent.BUTTON1 && e.isAltDown()) {
                Point mousePosition = client.getMouseCanvasPosition();
                Widget inventoryWidget = client.getWidget(WidgetInfo.INVENTORY);
                if (inventoryWidget != null && !inventoryWidget.isHidden()) {
                    for (WidgetItem item : inventoryWidget.getWidgetItems()) {
                        if (item.getCanvasBounds().contains(mousePosition.getX(), mousePosition.getY())) {
                            ItemComposition itemComp = client.getItemDefinition(item.getId());
                            if (itemComp != null) {
                                e.consume();
                                SwingUtilities.invokeLater(() -> {
                                    panel.showSearch();
                                    if (!button.isSelected()) {
                                        button.getOnSelect().run();
                                    }
                                    panel.getSearchPanel().priceLookup(itemComp.getName());
                                });
                            }
                            break;
                        }
                    }
                }
            }
            return super.mouseClicked(e);
        }
    };
    if (config.quickLookup()) {
        mouseManager.registerMouseListener(itemClick);
    }
}
Also used : MouseListener(net.runelite.client.input.MouseListener) MouseEvent(java.awt.event.MouseEvent) Widget(net.runelite.api.widgets.Widget) ItemComposition(net.runelite.api.ItemComposition) WidgetItem(net.runelite.api.widgets.WidgetItem) Point(net.runelite.api.Point) BufferedImage(java.awt.image.BufferedImage) ImageIO(javax.imageio.ImageIO)

Example 25 with WidgetItem

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

the class ExaminePlugin method findExamineItem.

private void findExamineItem(PendingExamine pendingExamine) {
    int quantity = 1;
    int itemId = -1;
    // Get widget
    int widgetId = pendingExamine.getWidgetId();
    int widgetGroup = TO_GROUP(widgetId);
    int widgetChild = TO_CHILD(widgetId);
    Widget widget = client.getWidget(widgetGroup, widgetChild);
    if (widget == null) {
        return;
    }
    if (pendingExamine.getType() == ExamineType.ITEM) {
        WidgetItem widgetItem = widget.getWidgetItem(pendingExamine.getActionParam());
        quantity = widgetItem != null ? widgetItem.getQuantity() : 1;
        itemId = pendingExamine.getId();
    } else if (pendingExamine.getType() == ExamineType.ITEM_BANK_EQ) {
        if (WidgetInfo.EQUIPMENT.getGroupId() == widgetGroup) {
            Widget widgetItem = widget.getChild(1);
            if (widgetItem != null) {
                quantity = widgetItem.getItemQuantity();
                itemId = widgetItem.getItemId();
            }
        } else if (WidgetInfo.BANK_INVENTORY_ITEMS_CONTAINER.getGroupId() == widgetGroup || WidgetInfo.RUNE_POUCH_ITEM_CONTAINER.getGroupId() == widgetGroup) {
            Widget widgetItem = widget.getChild(pendingExamine.getActionParam());
            if (widgetItem != null) {
                quantity = widgetItem.getItemQuantity();
                itemId = widgetItem.getItemId();
            }
        } else if (WidgetInfo.BANK_ITEM_CONTAINER.getGroupId() == widgetGroup) {
            Widget[] children = widget.getDynamicChildren();
            if (pendingExamine.getActionParam() < children.length) {
                Widget widgetItem = children[pendingExamine.getActionParam()];
                quantity = widgetItem.getItemQuantity();
                itemId = widgetItem.getItemId();
            }
        }
    }
    if (itemId == -1) {
        return;
    }
    final int itemQuantity = quantity;
    final ItemComposition itemComposition = itemManager.getItemComposition(itemId);
    if (itemComposition != null) {
        executor.submit(() -> getItemPrice(itemComposition, itemQuantity));
    }
}
Also used : Widget(net.runelite.api.widgets.Widget) ItemComposition(net.runelite.api.ItemComposition) WidgetItem(net.runelite.api.widgets.WidgetItem)

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