api: modify Widget.getWidgetItem to return widget items when no item exists
This allows plugins to get the canvas bounds of where items would be if they existed. Update existing usages to account for the new behavior.
This commit is contained in:
@@ -457,6 +457,7 @@ class DevToolsOverlay extends Overlay
|
||||
|
||||
WidgetItem widgetItem = widget.getWidgetItem(itemIndex);
|
||||
if (widgetItem == null
|
||||
|| widgetItem.getId() < 0
|
||||
|| widgetItem.getId() == ITEM_EMPTY
|
||||
|| widgetItem.getId() == ITEM_FILLED)
|
||||
{
|
||||
|
||||
@@ -120,7 +120,7 @@ public class ExaminePlugin extends Plugin
|
||||
int widgetChild = TO_CHILD(widgetId);
|
||||
Widget widget = client.getWidget(widgetGroup, widgetChild);
|
||||
WidgetItem widgetItem = widget.getWidgetItem(event.getActionParam());
|
||||
quantity = widgetItem != null ? widgetItem.getQuantity() : 1;
|
||||
quantity = widgetItem != null && widgetItem.getId() >= 0 ? widgetItem.getQuantity() : 1;
|
||||
break;
|
||||
}
|
||||
case EXAMINE_ITEM_BANK_EQ:
|
||||
|
||||
@@ -258,6 +258,11 @@ public abstract class RSWidgetMixin implements RSWidget
|
||||
|
||||
for (int i = 0; i < itemIds.length; ++i)
|
||||
{
|
||||
if (itemIds[i] <= 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
WidgetItem item = getWidgetItem(i);
|
||||
|
||||
if (item != null)
|
||||
@@ -287,17 +292,15 @@ public abstract class RSWidgetMixin implements RSWidget
|
||||
int itemId = itemIds[index];
|
||||
int itemQuantity = itemQuantities[index];
|
||||
|
||||
Point widgetCanvasLocation = getCanvasLocation();
|
||||
|
||||
if (itemId <= 0 || itemQuantity <= 0 || columns <= 0)
|
||||
if (columns <= 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
int row = index / columns;
|
||||
int col = index % columns;
|
||||
int itemX = widgetCanvasLocation.getX() + ((ITEM_SLOT_SIZE + xPitch) * col);
|
||||
int itemY = widgetCanvasLocation.getY() + ((ITEM_SLOT_SIZE + yPitch) * row);
|
||||
int itemX = rl$x + ((ITEM_SLOT_SIZE + xPitch) * col);
|
||||
int itemY = rl$y + ((ITEM_SLOT_SIZE + yPitch) * row);
|
||||
|
||||
Rectangle bounds = new Rectangle(itemX, itemY, ITEM_SLOT_SIZE, ITEM_SLOT_SIZE);
|
||||
return new WidgetItem(itemId - 1, itemQuantity, index, bounds, this);
|
||||
|
||||
Reference in New Issue
Block a user