Search in sources :

Example 26 with Widget

use of net.runelite.api.widgets.Widget 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 27 with Widget

use of net.runelite.api.widgets.Widget 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 28 with Widget

use of net.runelite.api.widgets.Widget 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());
}
Also used : Widget(net.runelite.api.widgets.Widget) RSWidget(net.runelite.rs.api.RSWidget) Point(net.runelite.api.Point) Inject(net.runelite.api.mixins.Inject) FieldHook(net.runelite.api.mixins.FieldHook)

Example 29 with Widget

use of net.runelite.api.widgets.Widget in project runelite by runelite.

the class RegenMeterOverlay method renderRegen.

private void renderRegen(Graphics2D g, WidgetInfo widgetInfo, double percent, Color color) {
    Widget widget = client.getWidget(widgetInfo);
    if (widget == null) {
        return;
    }
    Rectangle bounds = widget.getBounds();
    Arc2D.Double arc = new Arc2D.Double(bounds.x + 26d, bounds.y + 3.d, 27d, 27d, 90.d, -360.d * percent, Arc2D.OPEN);
    final Stroke STROKE = new BasicStroke(2f);
    g.setStroke(STROKE);
    g.setColor(color);
    g.draw(arc);
}
Also used : BasicStroke(java.awt.BasicStroke) Stroke(java.awt.Stroke) BasicStroke(java.awt.BasicStroke) Widget(net.runelite.api.widgets.Widget) Rectangle(java.awt.Rectangle) Arc2D(java.awt.geom.Arc2D)

Example 30 with Widget

use of net.runelite.api.widgets.Widget in project runelite by runelite.

the class PyramidPlunderOverlay method render.

@Override
public Dimension render(Graphics2D graphics) {
    Widget pyramidPlunderInfo = client.getWidget(WidgetInfo.PYRAMID_PLUNDER_DATA);
    if (pyramidPlunderInfo == null) {
        timer = null;
        return null;
    }
    panelComponent.getLines().clear();
    pyramidPlunderInfo.setHidden(true);
    if (timer == null) {
        startTimer();
    }
    panelComponent.getLines().add(new PanelComponent.Line("Time left: ", Color.WHITE, timer.getText(), timer.getTextColor()));
    panelComponent.getLines().add(new PanelComponent.Line("Room: ", String.valueOf(client.getSetting(Varbits.PYRAMID_PLUNDER_ROOM)) + "/8"));
    return panelComponent.render(graphics);
}
Also used : Widget(net.runelite.api.widgets.Widget) PanelComponent(net.runelite.client.ui.overlay.components.PanelComponent)

Aggregations

Widget (net.runelite.api.widgets.Widget)56 Rectangle (java.awt.Rectangle)10 WidgetItem (net.runelite.api.widgets.WidgetItem)10 ArrayList (java.util.ArrayList)9 Subscribe (com.google.common.eventbus.Subscribe)7 Inject (net.runelite.api.mixins.Inject)6 RSWidget (net.runelite.rs.api.RSWidget)6 Point (net.runelite.api.Point)5 WidgetHiddenChanged (net.runelite.api.events.WidgetHiddenChanged)5 PanelComponent (net.runelite.client.ui.overlay.components.PanelComponent)5 Test (org.junit.Test)5 FontMetrics (java.awt.FontMetrics)4 Rectangle2D (java.awt.geom.Rectangle2D)4 Consumer (java.util.function.Consumer)4 LocalPoint (net.runelite.api.coords.LocalPoint)4 ItemComposition (net.runelite.api.ItemComposition)3 WidgetInfo (net.runelite.api.widgets.WidgetInfo)3 Color (java.awt.Color)2 BufferedImage (java.awt.image.BufferedImage)2 Matcher (java.util.regex.Matcher)2