Merge pull request #10298 from Hydrox6/inventory-grid-preview-quantity

inventory grid: use correct item quantities for drag previews
This commit is contained in:
Tomas Slusny
2019-11-22 12:11:04 +01:00
committed by GitHub

View File

@@ -85,7 +85,6 @@ class InventoryGridOverlay extends Overlay
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 if1DraggedItemIndex = client.getIf1DraggedItemIndex();
final WidgetItem draggedItem = inventoryWidget.getWidgetItem(if1DraggedItemIndex); final WidgetItem draggedItem = inventoryWidget.getWidgetItem(if1DraggedItemIndex);
final int itemId = draggedItem.getId();
final Rectangle initialBounds = draggedItem.getCanvasBounds(); final Rectangle initialBounds = draggedItem.getCanvasBounds();
if (initialMousePoint == null) if (initialMousePoint == null)
@@ -93,7 +92,7 @@ class InventoryGridOverlay extends Overlay
initialMousePoint = mousePoint; initialMousePoint = mousePoint;
} }
if (itemId == -1 || !hoverActive && initialMousePoint.distance(mousePoint) < DISTANCE_TO_ACTIVATE_HOVER) if (draggedItem.getId() == -1 || !hoverActive && initialMousePoint.distance(mousePoint) < DISTANCE_TO_ACTIVATE_HOVER)
{ {
return null; return null;
} }
@@ -102,16 +101,15 @@ class InventoryGridOverlay extends Overlay
for (int i = 0; i < INVENTORY_SIZE; ++i) for (int i = 0; i < INVENTORY_SIZE; ++i)
{ {
WidgetItem widgetItem = inventoryWidget.getWidgetItem(i); WidgetItem targetWidgetItem = inventoryWidget.getWidgetItem(i);
final int targetItemId = widgetItem.getId();
final Rectangle bounds = widgetItem.getCanvasBounds(); final Rectangle bounds = targetWidgetItem.getCanvasBounds();
boolean inBounds = bounds.contains(mousePoint); boolean inBounds = bounds.contains(mousePoint);
if (config.showItem() && inBounds) if (config.showItem() && inBounds)
{ {
drawItem(graphics, bounds, itemId); drawItem(graphics, bounds, draggedItem);
drawItem(graphics, initialBounds, targetItemId); drawItem(graphics, initialBounds, targetWidgetItem);
} }
if (config.showHighlight() && inBounds) if (config.showHighlight() && inBounds)
@@ -129,14 +127,14 @@ class InventoryGridOverlay extends Overlay
return null; return null;
} }
private void drawItem(Graphics2D graphics, Rectangle bounds, int itemId) private void drawItem(Graphics2D graphics, Rectangle bounds, WidgetItem item)
{ {
if (itemId == -1) if (item.getId() == -1)
{ {
return; return;
} }
final BufferedImage draggedItemImage = itemManager.getImage(itemId); final BufferedImage draggedItemImage = itemManager.getImage(item.getId(), item.getQuantity(), false);
final int x = (int) bounds.getX(); final int x = (int) bounds.getX();
final int y = (int) bounds.getY(); final int y = (int) bounds.getY();