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);
|
WidgetItem widgetItem = widget.getWidgetItem(itemIndex);
|
||||||
if (widgetItem == null
|
if (widgetItem == null
|
||||||
|
|| widgetItem.getId() < 0
|
||||||
|| widgetItem.getId() == ITEM_EMPTY
|
|| widgetItem.getId() == ITEM_EMPTY
|
||||||
|| widgetItem.getId() == ITEM_FILLED)
|
|| widgetItem.getId() == ITEM_FILLED)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ public class ExaminePlugin extends Plugin
|
|||||||
int widgetChild = TO_CHILD(widgetId);
|
int widgetChild = TO_CHILD(widgetId);
|
||||||
Widget widget = client.getWidget(widgetGroup, widgetChild);
|
Widget widget = client.getWidget(widgetGroup, widgetChild);
|
||||||
WidgetItem widgetItem = widget.getWidgetItem(event.getActionParam());
|
WidgetItem widgetItem = widget.getWidgetItem(event.getActionParam());
|
||||||
quantity = widgetItem != null ? widgetItem.getQuantity() : 1;
|
quantity = widgetItem != null && widgetItem.getId() >= 0 ? widgetItem.getQuantity() : 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case EXAMINE_ITEM_BANK_EQ:
|
case EXAMINE_ITEM_BANK_EQ:
|
||||||
|
|||||||
@@ -258,6 +258,11 @@ public abstract class RSWidgetMixin implements RSWidget
|
|||||||
|
|
||||||
for (int i = 0; i < itemIds.length; ++i)
|
for (int i = 0; i < itemIds.length; ++i)
|
||||||
{
|
{
|
||||||
|
if (itemIds[i] <= 0)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
WidgetItem item = getWidgetItem(i);
|
WidgetItem item = getWidgetItem(i);
|
||||||
|
|
||||||
if (item != null)
|
if (item != null)
|
||||||
@@ -287,17 +292,15 @@ public abstract class RSWidgetMixin implements RSWidget
|
|||||||
int itemId = itemIds[index];
|
int itemId = itemIds[index];
|
||||||
int itemQuantity = itemQuantities[index];
|
int itemQuantity = itemQuantities[index];
|
||||||
|
|
||||||
Point widgetCanvasLocation = getCanvasLocation();
|
if (columns <= 0)
|
||||||
|
|
||||||
if (itemId <= 0 || itemQuantity <= 0 || columns <= 0)
|
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
int row = index / columns;
|
int row = index / columns;
|
||||||
int col = index % columns;
|
int col = index % columns;
|
||||||
int itemX = widgetCanvasLocation.getX() + ((ITEM_SLOT_SIZE + xPitch) * col);
|
int itemX = rl$x + ((ITEM_SLOT_SIZE + xPitch) * col);
|
||||||
int itemY = widgetCanvasLocation.getY() + ((ITEM_SLOT_SIZE + yPitch) * row);
|
int itemY = rl$y + ((ITEM_SLOT_SIZE + yPitch) * row);
|
||||||
|
|
||||||
Rectangle bounds = new Rectangle(itemX, itemY, ITEM_SLOT_SIZE, ITEM_SLOT_SIZE);
|
Rectangle bounds = new Rectangle(itemX, itemY, ITEM_SLOT_SIZE, ITEM_SLOT_SIZE);
|
||||||
return new WidgetItem(itemId - 1, itemQuantity, index, bounds, this);
|
return new WidgetItem(itemId - 1, itemQuantity, index, bounds, this);
|
||||||
|
|||||||
Reference in New Issue
Block a user