inventory-grid: show grid when viewing bank
Co-authored-by: while-loop <cvballa3g0@gmail.com>
This commit is contained in:
@@ -72,20 +72,30 @@ class InventoryGridOverlay extends Overlay
|
|||||||
@Override
|
@Override
|
||||||
public Dimension render(Graphics2D graphics)
|
public Dimension render(Graphics2D graphics)
|
||||||
{
|
{
|
||||||
final Widget if1DraggingWidget = client.getIf1DraggedWidget();
|
final Widget draggingWidget = getDraggedWidget();
|
||||||
final Widget inventoryWidget = client.getWidget(WidgetInfo.INVENTORY);
|
if (draggingWidget == null)
|
||||||
|
|
||||||
if (if1DraggingWidget == null || if1DraggingWidget != inventoryWidget)
|
|
||||||
{
|
{
|
||||||
initialMousePoint = null;
|
initialMousePoint = null;
|
||||||
hoverActive = false;
|
hoverActive = false;
|
||||||
|
// not dragging
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// grid is only supported on bank inventory and inventory
|
||||||
|
Widget inventoryWidget = draggingWidget.isIf3() ?
|
||||||
|
client.getWidget(WidgetInfo.BANK_INVENTORY_ITEMS_CONTAINER) :
|
||||||
|
client.getWidget(WidgetInfo.INVENTORY);
|
||||||
|
|
||||||
|
// with if3 the dragged widget is a child of the inventory, with if1 it is an item of the inventory (and the same widget)
|
||||||
|
if (inventoryWidget == null || (draggingWidget.isIf3() ? draggingWidget.getParent() != inventoryWidget : draggingWidget != inventoryWidget))
|
||||||
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
final net.runelite.api.Point mouse = client.getMouseCanvasPosition();
|
final net.runelite.api.Point mouse = client.getMouseCanvasPosition();
|
||||||
final Point mousePoint = new Point(mouse.getX(), mouse.getY());
|
final Point mousePoint = new Point(mouse.getX(), mouse.getY());
|
||||||
final int if1DraggedItemIndex = client.getIf1DraggedItemIndex();
|
final int draggedItemIndex = draggingWidget.isIf3() ? draggingWidget.getIndex() : client.getIf1DraggedItemIndex();
|
||||||
final WidgetItem draggedItem = inventoryWidget.getWidgetItem(if1DraggedItemIndex);
|
final WidgetItem draggedItem = getWidgetItem(inventoryWidget, draggedItemIndex);
|
||||||
final Rectangle initialBounds = draggedItem.getCanvasBounds(false);
|
final Rectangle initialBounds = draggedItem.getCanvasBounds(false);
|
||||||
|
|
||||||
if (initialMousePoint == null)
|
if (initialMousePoint == null)
|
||||||
@@ -104,8 +114,7 @@ class InventoryGridOverlay extends Overlay
|
|||||||
|
|
||||||
for (int i = 0; i < INVENTORY_SIZE; ++i)
|
for (int i = 0; i < INVENTORY_SIZE; ++i)
|
||||||
{
|
{
|
||||||
WidgetItem targetWidgetItem = inventoryWidget.getWidgetItem(i);
|
final WidgetItem targetWidgetItem = getWidgetItem(inventoryWidget, i);
|
||||||
|
|
||||||
final Rectangle bounds = targetWidgetItem.getCanvasBounds(false);
|
final Rectangle bounds = targetWidgetItem.getCanvasBounds(false);
|
||||||
boolean inBounds = bounds.contains(mousePoint);
|
boolean inBounds = bounds.contains(mousePoint);
|
||||||
|
|
||||||
@@ -130,6 +139,29 @@ class InventoryGridOverlay extends Overlay
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Widget getDraggedWidget()
|
||||||
|
{
|
||||||
|
Widget widget = client.getIf1DraggedWidget(); // if1 drag
|
||||||
|
if (widget != null)
|
||||||
|
{
|
||||||
|
return widget;
|
||||||
|
}
|
||||||
|
return client.getDraggedWidget(); // if3 drag
|
||||||
|
}
|
||||||
|
|
||||||
|
private static WidgetItem getWidgetItem(Widget parentWidget, int idx)
|
||||||
|
{
|
||||||
|
if (parentWidget.isIf3())
|
||||||
|
{
|
||||||
|
Widget wi = parentWidget.getChild(idx);
|
||||||
|
return new WidgetItem(wi.getItemId(), wi.getItemQuantity(), -1, wi.getBounds(), parentWidget, wi.getBounds());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return parentWidget.getWidgetItem(idx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void drawItem(Graphics2D graphics, Rectangle bounds, WidgetItem item)
|
private void drawItem(Graphics2D graphics, Rectangle bounds, WidgetItem item)
|
||||||
{
|
{
|
||||||
if (item.getId() == -1)
|
if (item.getId() == -1)
|
||||||
|
|||||||
Reference in New Issue
Block a user