Search in sources :

Example 51 with Inject

use of net.runelite.api.mixins.Inject 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)

Example 52 with Inject

use of net.runelite.api.mixins.Inject 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)

Example 53 with Inject

use of net.runelite.api.mixins.Inject in project runelite by runelite.

the class RSModelMixin method getTriangles.

@Override
@Inject
public List<Triangle> getTriangles() {
    int[] trianglesX = getTrianglesX();
    int[] trianglesY = getTrianglesY();
    int[] trianglesZ = getTrianglesZ();
    List<Vertex> vertices = getVertices();
    List<Triangle> triangles = new ArrayList<Triangle>(getTrianglesCount());
    for (int i = 0; i < getTrianglesCount(); ++i) {
        int triangleX = trianglesX[i];
        int triangleY = trianglesY[i];
        int triangleZ = trianglesZ[i];
        Triangle triangle = new Triangle(vertices.get(triangleX), vertices.get(triangleY), vertices.get(triangleZ));
        triangles.add(triangle);
    }
    return triangles;
}
Also used : Vertex(net.runelite.api.model.Vertex) Triangle(net.runelite.api.model.Triangle) ArrayList(java.util.ArrayList) Point(net.runelite.api.Point) Inject(net.runelite.api.mixins.Inject)

Example 54 with Inject

use of net.runelite.api.mixins.Inject in project runelite by runelite.

the class RSModelMixin method getVertices.

@Override
@Inject
public List<Vertex> getVertices() {
    int[] verticesX = getVerticesX();
    int[] verticesY = getVerticesY();
    int[] verticesZ = getVerticesZ();
    List<Vertex> vertices = new ArrayList<Vertex>();
    for (int i = 0; i < getVerticesCount(); ++i) {
        Vertex v = new Vertex(verticesX[i], verticesY[i], verticesZ[i]);
        vertices.add(v);
    }
    return vertices;
}
Also used : Vertex(net.runelite.api.model.Vertex) ArrayList(java.util.ArrayList) Point(net.runelite.api.Point) Inject(net.runelite.api.mixins.Inject)

Example 55 with Inject

use of net.runelite.api.mixins.Inject in project runelite by runelite.

the class MenuEntryEventMixin method onMenuOptionsChanged.

@FieldHook("menuOptionCount")
@Inject
public static void onMenuOptionsChanged(int idx) {
    int newCount = client.getMenuOptionCount();
    if (newCount == oldMenuEntryCount + 1) {
        MenuEntryAdded event = new MenuEntryAdded(client.getMenuOptions()[newCount - 1], client.getMenuTargets()[newCount - 1], client.getMenuTypes()[newCount - 1], client.getMenuIdentifiers()[newCount - 1], client.getMenuActionParams0()[newCount - 1], client.getMenuActionParams1()[newCount - 1]);
        eventBus.post(event);
    }
    oldMenuEntryCount = newCount;
}
Also used : MenuEntryAdded(net.runelite.api.events.MenuEntryAdded) Inject(net.runelite.api.mixins.Inject) FieldHook(net.runelite.api.mixins.FieldHook)

Aggregations

Inject (net.runelite.api.mixins.Inject)57 Point (net.runelite.api.Point)20 FieldHook (net.runelite.api.mixins.FieldHook)20 ArrayList (java.util.ArrayList)14 LocalPoint (net.runelite.api.coords.LocalPoint)10 RSWidget (net.runelite.rs.api.RSWidget)6 Vertex (net.runelite.api.model.Vertex)5 Widget (net.runelite.api.widgets.Widget)5 Node (net.runelite.api.Node)4 RSNode (net.runelite.rs.api.RSNode)4 WidgetNode (net.runelite.api.WidgetNode)3 Triangle (net.runelite.api.model.Triangle)3 Polygon (java.awt.Polygon)2 MenuEntry (net.runelite.api.MenuEntry)2 Model (net.runelite.api.Model)2 NPC (net.runelite.api.NPC)2 Player (net.runelite.api.Player)2 Skill (net.runelite.api.Skill)2 WidgetItem (net.runelite.api.widgets.WidgetItem)2 RSCombatInfoList (net.runelite.rs.api.RSCombatInfoList)2