Search in sources :

Example 1 with WidgetInfo

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

the class MenuManager method removeManagedCustomMenu.

/**
 * Removes a CustomMenuOption from the list of managed menu options.
 *
 * @param customMenuOption The custom menu to add
 */
public void removeManagedCustomMenu(WidgetMenuOption customMenuOption) {
    WidgetInfo widget = customMenuOption.getWidget();
    managedMenuOptions.remove(widget.getId(), customMenuOption);
}
Also used : WidgetInfo(net.runelite.api.widgets.WidgetInfo)

Example 2 with WidgetInfo

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

the class MenuManager method addManagedCustomMenu.

/**
 * Adds a CustomMenuOption to the list of managed menu options.
 *
 * @param customMenuOption The custom menu to add
 */
public void addManagedCustomMenu(WidgetMenuOption customMenuOption) {
    WidgetInfo widget = customMenuOption.getWidget();
    managedMenuOptions.put(widget.getId(), customMenuOption);
}
Also used : WidgetInfo(net.runelite.api.widgets.WidgetInfo)

Example 3 with WidgetInfo

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

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

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

the class WidgetTreeNode method toString.

@Override
public String toString() {
    Widget widget = getWidget();
    int id = widget.getId();
    WidgetInfo info = WidgetInspector.getWidgetInfo(id);
    return type + " " + TO_GROUP(id) + "." + TO_CHILD(id) + ((info != null) ? " " + info.name() : "");
}
Also used : Widget(net.runelite.api.widgets.Widget) WidgetInfo(net.runelite.api.widgets.WidgetInfo)

Aggregations

WidgetInfo (net.runelite.api.widgets.WidgetInfo)5 Widget (net.runelite.api.widgets.Widget)3 Rectangle (java.awt.Rectangle)2 ArrayList (java.util.ArrayList)2 WidgetItem (net.runelite.api.widgets.WidgetItem)2