use of net.runelite.api.mixins.Inject in project runelite by runelite.
the class RSSpritePixelsMixin method toBufferedImage.
@Inject
@Override
public BufferedImage toBufferedImage() {
int width = getWidth();
int height = getHeight();
int[] pixels = getPixels();
int[] transPixels = new int[pixels.length];
BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
for (int i = 0; i < pixels.length; i++) {
if (pixels[i] != 0) {
transPixels[i] = pixels[i] | 0xff000000;
}
}
img.setRGB(0, 0, width, height, transPixels, 0, width);
return img;
}
use of net.runelite.api.mixins.Inject 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.api.mixins.Inject 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.api.mixins.Inject 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()]);
}
use of net.runelite.api.mixins.Inject in project runelite by runelite.
the class RSWidgetMixin method onHiddenChanged.
@FieldHook("isHidden")
@Inject
public void onHiddenChanged(int idx) {
int id = getId();
if (id == -1) {
return;
}
Widget parent = getParent();
// so ignore them
if (parent != null) {
if (parent.isHidden()) {
return;
}
} else if (TO_GROUP(id) != client.getWidgetRoot()) {
return;
}
broadcastHidden(isSelfHidden());
}
Aggregations