widgetitem: associate Widget with WidgetItem
This commit is contained in:
@@ -26,6 +26,7 @@ package net.runelite.api.widgets;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.ToString;
|
||||
import net.runelite.api.Point;
|
||||
|
||||
@@ -34,55 +35,34 @@ import net.runelite.api.Point;
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@ToString
|
||||
@Getter
|
||||
public class WidgetItem
|
||||
{
|
||||
private final int id;
|
||||
private final int quantity;
|
||||
private final int index;
|
||||
private final Rectangle canvasBounds;
|
||||
|
||||
/**
|
||||
* Gets the ID of the item represented.
|
||||
* The ID of the item represented.
|
||||
*
|
||||
* @return the items ID
|
||||
* @see net.runelite.api.ItemID
|
||||
*/
|
||||
public int getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
private final int id;
|
||||
/**
|
||||
* Gets the quantity of the represented item.
|
||||
*
|
||||
* @return the items quantity
|
||||
* The quantity of the represented item.
|
||||
*/
|
||||
public int getQuantity()
|
||||
{
|
||||
return quantity;
|
||||
}
|
||||
|
||||
private final int quantity;
|
||||
/**
|
||||
* Gets the index position of this WidgetItem inside its parents
|
||||
* The index position of this WidgetItem inside its parents
|
||||
* WidgetItem array.
|
||||
*
|
||||
* @return the index in the parent widget
|
||||
* @see Widget#getWidgetItems()
|
||||
*/
|
||||
public int getIndex()
|
||||
{
|
||||
return index;
|
||||
}
|
||||
|
||||
private final int index;
|
||||
/**
|
||||
* Gets the area where the widget is drawn on the canvas.
|
||||
*
|
||||
* @return the occupied area of the widget
|
||||
* The area where the widget is drawn on the canvas.
|
||||
*/
|
||||
public Rectangle getCanvasBounds()
|
||||
{
|
||||
return canvasBounds;
|
||||
}
|
||||
private final Rectangle canvasBounds;
|
||||
/**
|
||||
* The widget which contains this item.
|
||||
*/
|
||||
private final Widget widget;
|
||||
|
||||
/**
|
||||
* Gets the upper-left coordinate of where the widget is being drawn
|
||||
|
||||
@@ -1355,7 +1355,7 @@ public abstract class RSClientMixin implements RSClient
|
||||
{
|
||||
if (renderX >= minX && renderX <= maxX && renderY >= minY && renderY <= maxY)
|
||||
{
|
||||
WidgetItem widgetItem = new WidgetItem(widget.getItemId(), widget.getItemQuantity(), -1, widget.getBounds());
|
||||
WidgetItem widgetItem = new WidgetItem(widget.getItemId(), widget.getItemQuantity(), -1, widget.getBounds(), widget);
|
||||
callbacks.drawItem(widget.getItemId(), widgetItem);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -300,7 +300,7 @@ public abstract class RSWidgetMixin implements RSWidget
|
||||
int itemY = widgetCanvasLocation.getY() + ((ITEM_SLOT_SIZE + yPitch) * row);
|
||||
|
||||
Rectangle bounds = new Rectangle(itemX - 1, itemY - 1, ITEM_SLOT_SIZE, ITEM_SLOT_SIZE);
|
||||
return new WidgetItem(itemId - 1, itemQuantity, index, bounds);
|
||||
return new WidgetItem(itemId - 1, itemQuantity, index, bounds, this);
|
||||
}
|
||||
|
||||
@Inject
|
||||
|
||||
Reference in New Issue
Block a user