Search in sources :

Example 11 with WidgetItem

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

the class ShiftClickInputListener method mouseClicked.

@Override
public MouseEvent mouseClicked(MouseEvent event) {
    if (!config.shiftClickCustomization() || !isValidInventoryClick(event.getPoint())) {
        return event;
    }
    final WidgetItem item = getClickedItem(event.getPoint());
    final int button = event.getButton();
    if (item != null) {
        clientThread.invokeLater(() -> plugin.cycleItemShiftClickAction(item, button));
        event.consume();
    }
    return event;
}
Also used : WidgetItem(net.runelite.api.widgets.WidgetItem) Point(java.awt.Point)

Example 12 with WidgetItem

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

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

the class SlayerOverlay method render.

@Override
public Dimension render(Graphics2D graphics) {
    if (!config.showItemOverlay()) {
        return null;
    }
    int amount = plugin.getAmount();
    if (amount <= 0) {
        return null;
    }
    graphics.setFont(FontManager.getRunescapeSmallFont());
    for (WidgetItem item : getSlayerWidgetItems()) {
        int itemId = item.getId();
        if (!slayerEquipment.contains(itemId) && !slayerJewelry.contains(itemId)) {
            continue;
        }
        final Rectangle bounds = item.getCanvasBounds();
        final TextComponent textComponent = new TextComponent();
        textComponent.setText(String.valueOf(amount));
        // Draw the counter in the bottom left for equipment, and top left for jewelry
        textComponent.setPosition(new Point(bounds.x, bounds.y + (slayerJewelry.contains(itemId) ? bounds.height : graphics.getFontMetrics().getHeight())));
        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) Point(java.awt.Point)

Example 14 with WidgetItem

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

Example 15 with WidgetItem

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

the class RSWidgetMixin method getWidgetItem.

@Inject
@Override
public WidgetItem getWidgetItem(int index) {
    int[] itemIds = getItemIds();
    int[] itemQuantities = getItemQuantities();
    if (itemIds == null || itemQuantities == null) {
        return null;
    }
    // the number of item slot columns is stored here
    int columns = getWidth();
    int paddingX = getPaddingX();
    int paddingY = getPaddingY();
    int itemId = itemIds[index];
    int itemQuantity = itemQuantities[index];
    Point widgetCanvasLocation = getCanvasLocation();
    if (itemId <= 0 || itemQuantity <= 0 || columns <= 0) {
        return null;
    }
    int row = index / columns;
    int col = index % columns;
    int itemX = widgetCanvasLocation.getX() + ((ITEM_SLOT_SIZE + paddingX) * col);
    int itemY = widgetCanvasLocation.getY() + ((ITEM_SLOT_SIZE + paddingY) * row);
    Rectangle bounds = new Rectangle(itemX - 1, itemY - 1, ITEM_SLOT_SIZE, ITEM_SLOT_SIZE);
    return new WidgetItem(itemId - 1, itemQuantity, index, bounds);
}
Also used : Rectangle(java.awt.Rectangle) WidgetItem(net.runelite.api.widgets.WidgetItem) Point(net.runelite.api.Point) Point(net.runelite.api.Point) Inject(net.runelite.api.mixins.Inject)

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