Search in sources :

Example 11 with Widget

use of org.powerbot.bot.rt6.client.Widget in project powerbot by powerbot.

the class Component method components.

public Component[] components() {
    final Widget component = getInternalComponent();
    final Object[] interfaces;
    if (component != null && (interfaces = component.getComponents()) != null) {
        final Component[] components = new Component[interfaces.length];
        for (int i = 0; i < interfaces.length; i++) {
            components[i] = new Component(ctx, widget, this, i);
        }
        return components;
    }
    return new Component[0];
}
Also used : Widget(org.powerbot.bot.rt6.client.Widget) Point(java.awt.Point)

Example 12 with Widget

use of org.powerbot.bot.rt6.client.Widget in project powerbot by powerbot.

the class Component method parentId.

public int parentId() {
    final Client client = ctx.client();
    final Widget component = getInternalComponent();
    if (client == null || component == null) {
        return -1;
    }
    final int pId = component.getParentId();
    if (pId != -1) {
        return pId;
    }
    final int uid = id() >>> 16;
    int i = 0;
    for (final ComponentNode node : new HashTable<ComponentNode>(client.getWidgetTable(), ComponentNode.class)) {
        if (uid == node.getUid()) {
            return (int) node.getId();
        }
        if (i++ >= 1500) {
            System.out.printf("WARNING: parentId operation killed -- beyond depth of %d.%n", 1500);
            break;
        }
    }
    return -1;
}
Also used : HashTable(org.powerbot.bot.rt6.HashTable) Widget(org.powerbot.bot.rt6.client.Widget) Client(org.powerbot.bot.rt6.client.Client) ComponentNode(org.powerbot.bot.rt6.client.ComponentNode) Point(java.awt.Point)

Aggregations

Widget (org.powerbot.bot.rt6.client.Widget)11 Point (java.awt.Point)5 Client (org.powerbot.bot.rt6.client.Client)4 Rectangle (java.awt.Rectangle)1 ArrayList (java.util.ArrayList)1 HashTable (org.powerbot.bot.rt6.HashTable)1 ComponentNode (org.powerbot.bot.rt6.client.ComponentNode)1