Search in sources :

Example 11 with Inject

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

the class RSClientMixin method getWidgetRoots.

@Inject
@Override
public Widget[] getWidgetRoots() {
    int topGroup = getWidgetRoot();
    List<Widget> widgets = new ArrayList<Widget>();
    for (Widget widget : getWidgets()[topGroup]) {
        if (widget != null && widget.getParentId() == -1) {
            widgets.add(widget);
        }
    }
    return widgets.toArray(new Widget[widgets.size()]);
}
Also used : Widget(net.runelite.api.widgets.Widget) RSWidget(net.runelite.rs.api.RSWidget) ArrayList(java.util.ArrayList) LocalPoint(net.runelite.api.coords.LocalPoint) Point(net.runelite.api.Point) Inject(net.runelite.api.mixins.Inject)

Example 12 with Inject

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

the class RSClientMixin method createItemSprite.

@Inject
@Override
public SpritePixels createItemSprite(int itemId, int quantity, int border, int shadowColor, int stackable, boolean noted, int scale) {
    assert isClientThread();
    int zoom = get3dZoom();
    set3dZoom(scale);
    try {
        return createItemSprite(itemId, quantity, border, shadowColor, stackable, noted);
    } finally {
        set3dZoom(zoom);
    }
}
Also used : LocalPoint(net.runelite.api.coords.LocalPoint) Point(net.runelite.api.Point) Inject(net.runelite.api.mixins.Inject)

Example 13 with Inject

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

the class RSClientMixin method mapRegionsChanged.

@FieldHook("mapRegions")
@Inject
public static void mapRegionsChanged(int idx) {
    MapRegionChanged regionChanged = new MapRegionChanged();
    regionChanged.setIndex(idx);
    eventBus.post(regionChanged);
}
Also used : MapRegionChanged(net.runelite.api.events.MapRegionChanged) Inject(net.runelite.api.mixins.Inject) FieldHook(net.runelite.api.mixins.FieldHook)

Example 14 with Inject

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

the class RSClientMixin method playerOptionsChanged.

@FieldHook("playerOptions")
@Inject
public static void playerOptionsChanged(int idx) {
    // Reset the menu type
    MenuAction[] playerActions = { PLAYER_FIRST_OPTION, PLAYER_SECOND_OPTION, PLAYER_THIRD_OPTION, PLAYER_FOURTH_OPTION, PLAYER_FIFTH_OPTION, PLAYER_SIXTH_OPTION, PLAYER_SEVENTH_OPTION, PLAYER_EIGTH_OPTION };
    if (idx >= 0 && idx < playerActions.length) {
        MenuAction playerAction = playerActions[idx];
        client.getPlayerMenuTypes()[idx] = playerAction.getId();
    }
    PlayerMenuOptionsChanged optionsChanged = new PlayerMenuOptionsChanged();
    optionsChanged.setIndex(idx);
    eventBus.post(optionsChanged);
}
Also used : MenuAction(net.runelite.api.MenuAction) PlayerMenuOptionsChanged(net.runelite.api.events.PlayerMenuOptionsChanged) Inject(net.runelite.api.mixins.Inject) FieldHook(net.runelite.api.mixins.FieldHook)

Example 15 with Inject

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

the class RSTileMixin method gameObjectsChanged.

@FieldHook("objects")
@Inject
public void gameObjectsChanged(int idx) {
    if (// this happens from the field assignment
    idx == -1) {
        return;
    }
    if (previousGameObjects == null) {
        previousGameObjects = new GameObject[5];
    }
    // Previous game object
    GameObject previous = previousGameObjects[idx];
    // GameObject that was changed.
    RSGameObject current = (RSGameObject) getGameObjects()[idx];
    // Last game object
    GameObject last = lastGameObject;
    // Update last game object
    lastGameObject = current;
    // Update previous object to current
    previousGameObjects[idx] = current;
    // Duplicate event, return
    if (current != null && current.equals(last)) {
        return;
    }
    // Characters seem to generate a constant stream of new GameObjects
    if (current == null || !(current.getRenderable() instanceof Actor)) {
        if (current == null && previous != null) {
            GameObjectDespawned gameObjectDespawned = new GameObjectDespawned();
            gameObjectDespawned.setTile(this);
            gameObjectDespawned.setGameObject(previous);
            eventBus.post(gameObjectDespawned);
        } else if (current != null && previous == null) {
            GameObjectSpawned gameObjectSpawned = new GameObjectSpawned();
            gameObjectSpawned.setTile(this);
            gameObjectSpawned.setGameObject(current);
            eventBus.post(gameObjectSpawned);
        } else if (current != null && previous != null) {
            GameObjectChanged gameObjectsChanged = new GameObjectChanged();
            gameObjectsChanged.setTile(this);
            gameObjectsChanged.setPrevious(previous);
            gameObjectsChanged.setGameObject(current);
            eventBus.post(gameObjectsChanged);
        }
    }
}
Also used : GameObjectSpawned(net.runelite.api.events.GameObjectSpawned) RSGameObject(net.runelite.rs.api.RSGameObject) GameObject(net.runelite.api.GameObject) RSGameObject(net.runelite.rs.api.RSGameObject) Actor(net.runelite.api.Actor) GameObjectDespawned(net.runelite.api.events.GameObjectDespawned) GameObjectChanged(net.runelite.api.events.GameObjectChanged) 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