Search in sources :

Example 1 with RSWidget

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

the class RSClientMixin method getGroup.

@Inject
@Override
public Widget[] getGroup(int groupId) {
    RSWidget[][] widgets = getWidgets();
    if (widgets == null || groupId < 0 || groupId >= widgets.length || widgets[groupId] == null) {
        return null;
    }
    List<Widget> w = new ArrayList<Widget>();
    for (Widget widget : widgets[groupId]) {
        if (widget != null) {
            w.add(widget);
        }
    }
    return w.toArray(new Widget[w.size()]);
}
Also used : Widget(net.runelite.api.widgets.Widget) RSWidget(net.runelite.rs.api.RSWidget) ArrayList(java.util.ArrayList) Inject(net.runelite.api.mixins.Inject)

Example 2 with RSWidget

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

the class RSWidgetMixin method getCanvasLocation.

@Inject
@Override
public Point getCanvasLocation() {
    int x = 0;
    int y = 0;
    RSWidget cur;
    for (cur = this; cur.getParent() != null; cur = (RSWidget) cur.getParent()) {
        x += cur.getRelativeX();
        y += cur.getRelativeY();
        x -= cur.getScrollX();
        y -= cur.getScrollY();
    }
    // cur is now the root
    int[] widgetBoundsWidth = client.getWidgetPositionsX();
    int[] widgetBoundsHeight = client.getWidgetPositionsY();
    int boundsIndex = cur.getBoundsIndex();
    if (boundsIndex != -1) {
        x += widgetBoundsWidth[boundsIndex];
        y += widgetBoundsHeight[boundsIndex];
        if (cur.getType() > 0) {
            x += cur.getRelativeX();
            y += cur.getRelativeY();
        }
    } else {
        x += cur.getRelativeX();
        y += cur.getRelativeY();
    }
    return new Point(x, y);
}
Also used : RSWidget(net.runelite.rs.api.RSWidget) Point(net.runelite.api.Point) Point(net.runelite.api.Point) Inject(net.runelite.api.mixins.Inject)

Example 3 with RSWidget

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

the class RSWidgetMixin method broadcastHidden.

@Inject
@Override
public void broadcastHidden(boolean hidden) {
    WidgetHiddenChanged event = new WidgetHiddenChanged();
    event.setWidget(this);
    event.setHidden(hidden);
    eventBus.post(event);
    RSWidget[] children = getChildren();
    if (children != null) {
        // recursive through children
        for (RSWidget child : children) {
            // if the widget is hidden it will not magically unhide from its parent changing
            if (child == null || child.isSelfHidden())
                continue;
            child.broadcastHidden(hidden);
        }
    }
    // make sure we iterate nested children as well
    // cannot be null
    Widget[] nestedChildren = getNestedChildren();
    for (Widget nestedChild : nestedChildren) {
        if (nestedChild == null || nestedChild.isSelfHidden())
            continue;
        ((RSWidget) nestedChild).broadcastHidden(hidden);
    }
}
Also used : RSWidget(net.runelite.rs.api.RSWidget) Widget(net.runelite.api.widgets.Widget) RSWidget(net.runelite.rs.api.RSWidget) WidgetHiddenChanged(net.runelite.api.events.WidgetHiddenChanged) Inject(net.runelite.api.mixins.Inject)

Example 4 with RSWidget

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

the class RSWidgetMixin method getDynamicChildren.

@Inject
@Override
public Widget[] getDynamicChildren() {
    RSWidget[] children = getChildren();
    if (children == null) {
        return new Widget[0];
    }
    List<Widget> widgets = new ArrayList<Widget>();
    for (Widget widget : children) {
        if (widget != null && widget.getParentId() == getId()) {
            widgets.add(widget);
        }
    }
    return widgets.toArray(new Widget[widgets.size()]);
}
Also used : RSWidget(net.runelite.rs.api.RSWidget) Widget(net.runelite.api.widgets.Widget) RSWidget(net.runelite.rs.api.RSWidget) ArrayList(java.util.ArrayList) Inject(net.runelite.api.mixins.Inject)

Aggregations

Inject (net.runelite.api.mixins.Inject)4 RSWidget (net.runelite.rs.api.RSWidget)4 Widget (net.runelite.api.widgets.Widget)3 ArrayList (java.util.ArrayList)2 Point (net.runelite.api.Point)1 WidgetHiddenChanged (net.runelite.api.events.WidgetHiddenChanged)1