Search in sources :

Example 46 with Inject

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

the class RSTileMixin method itemLayerChanged.

@FieldHook("itemLayer")
@Inject
public void itemLayerChanged(int idx) {
    ItemLayerChanged itemLayerChanged = new ItemLayerChanged(this);
    eventBus.post(itemLayerChanged);
}
Also used : ItemLayerChanged(net.runelite.api.events.ItemLayerChanged) Inject(net.runelite.api.mixins.Inject) FieldHook(net.runelite.api.mixins.FieldHook)

Example 47 with Inject

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

the class RSWallObjectMixin method getClickbox.

@Inject
@Override
public Area getClickbox() {
    Area clickbox = new Area();
    Area clickboxA = Perspective.getClickbox(client, getModelA(), getOrientationA(), getX(), getY());
    Area clickboxB = Perspective.getClickbox(client, getModelB(), getOrientationB(), getX(), getY());
    if (clickboxA == null && clickboxB == null) {
        return null;
    }
    if (clickboxA != null) {
        clickbox.add(clickboxA);
    }
    if (clickboxB != null) {
        clickbox.add(clickboxB);
    }
    return clickbox;
}
Also used : Area(java.awt.geom.Area) Inject(net.runelite.api.mixins.Inject)

Example 48 with Inject

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

the class StretchedFixedModeMixin method getStretchedDimensions.

@Inject
@Override
public Dimension getStretchedDimensions() {
    Canvas canvas = getCanvas();
    int width = canvas.getWidth();
    int height = canvas.getHeight();
    if (cachedStretchedDimensions == null || width != lastCanvasDimensions.width || height != lastCanvasDimensions.height) {
        if (stretchedKeepAspectRatio) {
            int tempNewWidth = (int) (height * Constants.GAME_FIXED_ASPECT_RATIO);
            if (tempNewWidth > canvas.getWidth()) {
                height = (int) (width / Constants.GAME_FIXED_ASPECT_RATIO);
            } else {
                width = tempNewWidth;
            }
        }
        cachedStretchedDimensions = new Dimension(width, height);
        lastCanvasDimensions = new Dimension(width, height);
    }
    return cachedStretchedDimensions;
}
Also used : Canvas(java.awt.Canvas) Dimension(java.awt.Dimension) Inject(net.runelite.api.mixins.Inject)

Example 49 with Inject

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

the class RSWidgetMixin method getWidgetItem.

@Inject
@Override
public WidgetItem getWidgetItem(int index) {
    int[] itemIds = getItemIds();
    int[] itemQuantities = getItemQuantities();
    if (itemIds == null || itemQuantities == null) {
        return null;
    }
    // the number of item slot columns is stored here
    int columns = getWidth();
    int paddingX = getPaddingX();
    int paddingY = getPaddingY();
    int itemId = itemIds[index];
    int itemQuantity = itemQuantities[index];
    Point widgetCanvasLocation = getCanvasLocation();
    if (itemId <= 0 || itemQuantity <= 0 || columns <= 0) {
        return null;
    }
    int row = index / columns;
    int col = index % columns;
    int itemX = widgetCanvasLocation.getX() + ((ITEM_SLOT_SIZE + paddingX) * col);
    int itemY = widgetCanvasLocation.getY() + ((ITEM_SLOT_SIZE + paddingY) * row);
    Rectangle bounds = new Rectangle(itemX - 1, itemY - 1, ITEM_SLOT_SIZE, ITEM_SLOT_SIZE);
    return new WidgetItem(itemId - 1, itemQuantity, index, bounds);
}
Also used : Rectangle(java.awt.Rectangle) WidgetItem(net.runelite.api.widgets.WidgetItem) Point(net.runelite.api.Point) Point(net.runelite.api.Point) Inject(net.runelite.api.mixins.Inject)

Example 50 with Inject

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

the class RSWidgetMixin method getWidgetItems.

@Inject
@Override
public Collection<WidgetItem> getWidgetItems() {
    int[] itemIds = getItemIds();
    if (itemIds == null) {
        return null;
    }
    List<WidgetItem> items = new ArrayList<WidgetItem>(itemIds.length);
    for (int i = 0; i < itemIds.length; ++i) {
        WidgetItem item = getWidgetItem(i);
        if (item != null) {
            items.add(item);
        }
    }
    return items;
}
Also used : ArrayList(java.util.ArrayList) WidgetItem(net.runelite.api.widgets.WidgetItem) Point(net.runelite.api.Point) Inject(net.runelite.api.mixins.Inject)

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