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()]);
}
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);
}
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);
}
}
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()]);
}