Search in sources :

Example 46 with Widget

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

the class InventoryWidgetItemQuery method getInventoryItems.

private Collection<WidgetItem> getInventoryItems(Client client) {
    Collection<WidgetItem> widgetItems = new ArrayList<>();
    for (WidgetInfo widgetInfo : INVENTORY_WIDGET_INFOS) {
        Widget inventory = client.getWidget(widgetInfo);
        if (inventory == null || inventory.isHidden()) {
            continue;
        }
        if (widgetInfo == WidgetInfo.INVENTORY) {
            widgetItems.addAll(inventory.getWidgetItems());
            break;
        } else {
            Widget[] children = inventory.getDynamicChildren();
            for (int i = 0; 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, bounds));
            }
            break;
        }
    }
    return widgetItems;
}
Also used : ArrayList(java.util.ArrayList) Widget(net.runelite.api.widgets.Widget) Rectangle(java.awt.Rectangle) WidgetItem(net.runelite.api.widgets.WidgetItem) WidgetInfo(net.runelite.api.widgets.WidgetInfo)

Example 47 with Widget

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

the class BankItemQuery method getBankItems.

private Collection<WidgetItem> getBankItems(Client client) {
    Collection<WidgetItem> widgetItems = new ArrayList<>();
    Widget bank = client.getWidget(WidgetInfo.BANK_ITEM_CONTAINER);
    if (bank != null && !bank.isHidden()) {
        Widget[] children = bank.getDynamicChildren();
        for (int i = 0; i < children.length; i++) {
            if (children[i].getItemId() == ITEM_EMPTY || children[i].isHidden()) {
                continue;
            }
            // set bounds to same size as default inventory
            Rectangle bounds = children[i].getBounds();
            bounds.setBounds(bounds.x - 1, bounds.y - 1, 32, 32);
            // Index is set to 0 because the widget's index does not correlate to the order in the bank
            widgetItems.add(new WidgetItem(children[i].getItemId(), children[i].getItemQuantity(), 0, 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 48 with Widget

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

the class EquipmentItemQuery method getEquippedItems.

private Collection<WidgetItem> getEquippedItems(Client client) {
    Collection<WidgetItem> widgetItems = new ArrayList<>();
    Widget equipment = client.getWidget(WidgetInfo.EQUIPMENT);
    if (equipment != null && !equipment.isHidden()) {
        if (slots.isEmpty()) {
            slots.addAll(Arrays.asList(ALL_EQUIPMENT_WIDGET_INFOS));
        }
        for (WidgetInfo slot : slots) {
            Widget parentWidget = client.getWidget(slot);
            Widget itemWidget = parentWidget.getChild(1);
            // Check if background icon is hidden. if hidden, item is equipped.
            boolean equipped = parentWidget.getChild(2).isHidden();
            // set bounds to same size as default inventory
            Rectangle bounds = itemWidget.getBounds();
            bounds.setBounds(bounds.x - 1, bounds.y - 1, 32, 32);
            // Index is set to 0 because there is no set in stone order of equipment slots
            widgetItems.add(new WidgetItem(equipped ? itemWidget.getItemId() : -1, itemWidget.getItemQuantity(), 0, 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) WidgetInfo(net.runelite.api.widgets.WidgetInfo)

Example 49 with Widget

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

the class MinimapPlugin method startUp.

@Override
protected void startUp() throws Exception {
    Widget minimapWidget = client.getWidget(WidgetInfo.MINIMAP_WIDGET);
    if (minimapWidget != null) {
        minimapWidget.setHidden(config.hideMinimap());
    }
    storeOriginalDots();
    replaceMapDots();
}
Also used : Widget(net.runelite.api.widgets.Widget)

Example 50 with Widget

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

the class ClueScrollEmoteOverlay method render.

@Override
public Dimension render(Graphics2D graphics) {
    ClueScroll clue = plugin.getClue();
    if (clue == null || !(clue instanceof EmoteClue)) {
        return null;
    }
    EmoteClue emoteClue = (EmoteClue) clue;
    if (!emoteClue.getFirstEmote().hasSprite()) {
        return null;
    }
    Widget emoteContainer = client.getWidget(WidgetInfo.EMOTE_CONTAINER);
    if (emoteContainer == null || emoteContainer.isHidden()) {
        return null;
    }
    Widget emoteWindow = client.getWidget(WidgetInfo.EMOTE_WINDOW);
    if (emoteWindow == null) {
        return null;
    }
    for (Widget emoteWidget : emoteContainer.getDynamicChildren()) {
        if (emoteWidget.getSpriteId() == emoteClue.getFirstEmote().getSpriteId()) {
            highlightWidget(graphics, emoteWindow, emoteWidget, emoteClue.getSecondEmote() != null ? "1st" : "");
        } else if (emoteClue.getSecondEmote() != null && emoteWidget.getSpriteId() == emoteClue.getSecondEmote().getSpriteId()) {
            highlightWidget(graphics, emoteWindow, emoteWidget, "2nd");
        }
    }
    return null;
}
Also used : EmoteClue(net.runelite.client.plugins.cluescrolls.clues.EmoteClue) ClueScroll(net.runelite.client.plugins.cluescrolls.clues.ClueScroll) Widget(net.runelite.api.widgets.Widget)

Aggregations

Widget (net.runelite.api.widgets.Widget)56 Rectangle (java.awt.Rectangle)10 WidgetItem (net.runelite.api.widgets.WidgetItem)10 ArrayList (java.util.ArrayList)9 Subscribe (com.google.common.eventbus.Subscribe)7 Inject (net.runelite.api.mixins.Inject)6 RSWidget (net.runelite.rs.api.RSWidget)6 Point (net.runelite.api.Point)5 WidgetHiddenChanged (net.runelite.api.events.WidgetHiddenChanged)5 PanelComponent (net.runelite.client.ui.overlay.components.PanelComponent)5 Test (org.junit.Test)5 FontMetrics (java.awt.FontMetrics)4 Rectangle2D (java.awt.geom.Rectangle2D)4 Consumer (java.util.function.Consumer)4 LocalPoint (net.runelite.api.coords.LocalPoint)4 ItemComposition (net.runelite.api.ItemComposition)3 WidgetInfo (net.runelite.api.widgets.WidgetInfo)3 Color (java.awt.Color)2 BufferedImage (java.awt.image.BufferedImage)2 Matcher (java.util.regex.Matcher)2