Search in sources :

Example 1 with RSHashTable

use of net.runelite.rs.api.RSHashTable in project runelite by runelite.

the class RSWidgetMixin method getNestedChildren.

@Inject
@Override
public Widget[] getNestedChildren() {
    RSHashTable componentTable = client.getComponentTable();
    int group = -1;
    // iteration here...
    for (Node node : componentTable.getNodes()) {
        WidgetNode wn = (WidgetNode) node;
        if (wn.getHash() == getId()) {
            group = wn.getId();
            break;
        }
    }
    if (group == -1) {
        return new Widget[0];
    }
    List<Widget> widgets = new ArrayList<Widget>();
    for (Widget widget : client.getGroup(group)) {
        if (widget != null && widget.getParentId() == getId()) {
            widgets.add(widget);
        }
    }
    return widgets.toArray(new Widget[widgets.size()]);
}
Also used : RSNode(net.runelite.rs.api.RSNode) Node(net.runelite.api.Node) WidgetNode(net.runelite.api.WidgetNode) Widget(net.runelite.api.widgets.Widget) RSWidget(net.runelite.rs.api.RSWidget) ArrayList(java.util.ArrayList) WidgetNode(net.runelite.api.WidgetNode) RSHashTable(net.runelite.rs.api.RSHashTable) Point(net.runelite.api.Point) Inject(net.runelite.api.mixins.Inject)

Example 2 with RSHashTable

use of net.runelite.rs.api.RSHashTable in project runelite by runelite.

the class RSWidgetMixin method getParentId.

@Inject
@Override
public int getParentId() {
    int parentId = getRSParentId();
    if (parentId != -1) {
        return parentId;
    }
    int groupId = TO_GROUP(getId());
    RSHashTable componentTable = client.getComponentTable();
    RSNode[] buckets = componentTable.getBuckets();
    for (int i = 0; i < buckets.length; ++i) {
        Node node = buckets[i];
        // It looks like the first node in the bucket is always
        // a sentinel
        Node cur = node.getNext();
        while (cur != node) {
            WidgetNode wn = (WidgetNode) cur;
            if (groupId == wn.getId()) {
                return (int) wn.getHash();
            }
            cur = cur.getNext();
        }
    }
    return -1;
}
Also used : RSNode(net.runelite.rs.api.RSNode) RSNode(net.runelite.rs.api.RSNode) Node(net.runelite.api.Node) WidgetNode(net.runelite.api.WidgetNode) WidgetNode(net.runelite.api.WidgetNode) RSHashTable(net.runelite.rs.api.RSHashTable) Point(net.runelite.api.Point) Inject(net.runelite.api.mixins.Inject)

Aggregations

Node (net.runelite.api.Node)2 Point (net.runelite.api.Point)2 WidgetNode (net.runelite.api.WidgetNode)2 Inject (net.runelite.api.mixins.Inject)2 RSHashTable (net.runelite.rs.api.RSHashTable)2 RSNode (net.runelite.rs.api.RSNode)2 ArrayList (java.util.ArrayList)1 Widget (net.runelite.api.widgets.Widget)1 RSWidget (net.runelite.rs.api.RSWidget)1