Java Code Examples for net.runelite.api.widgets.Widget#getWidgetItems()
The following examples show how to use
net.runelite.api.widgets.Widget#getWidgetItems() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AboveWidgetsOverlay.java From plugins with GNU General Public License v3.0 | 6 votes |
private void renderInventoryHighlights(Graphics2D graphics, int itemID, Color color) { Widget inventory = client.getWidget(WidgetInfo.INVENTORY); if (inventory == null || inventory.isHidden() || itemID == -1) { return; } Color highlight = new Color(color.getRed(), color.getGreen(), color.getBlue(), 150); BufferedImage image = ImageUtil.fillImage(client.createItemSprite(itemID, 300, 2, 0, 0, true, 710).toBufferedImage(), highlight); for (WidgetItem item : inventory.getWidgetItems()) { if (item.getId() == itemID) { OverlayUtil.renderImageLocation(graphics, item.getCanvasLocation(), image); //The item's text quantity is rendered after the sprite's image is rendered so that the text appears on top if (item.getQuantity() > 1) { OverlayUtil.renderTextLocation(graphics, new Point(item.getCanvasLocation().getX() + OFFSET_X_TEXT_QUANTITY, item.getCanvasLocation().getY() + OFFSET_Y_TEXT_QUANTITY), String.valueOf(item.getQuantity()), Color.YELLOW); } } } }
Example 2
Source File: AlchemyRoom.java From plugins with GNU General Public License v3.0 | 6 votes |
@Override public void over(Graphics2D graphics) { if (!inside() || !config.alchemy() || best == null) { return; } Widget inventory = client.getWidget(WidgetInfo.INVENTORY); if (inventory.isHidden()) { return; } for (WidgetItem item : inventory.getWidgetItems()) { if (item.getId() != best.getId()) { continue; } drawItem(graphics, item); } }
Example 3
Source File: OneClickPlugin.java From ExternalPlugins with GNU General Public License v3.0 | 6 votes |
public Pair<Integer, Integer> findItem(int id) { final Widget inventoryWidget = client.getWidget(WidgetInfo.INVENTORY); final List<WidgetItem> itemList = (List<WidgetItem>) inventoryWidget.getWidgetItems(); for (int i = itemList.size() - 1; i >= 0; i--) { final WidgetItem item = itemList.get(i); if (item.getId() == id) { return Pair.of(item.getId(), item.getIndex()); } } return Pair.of(-1, -1); }
Example 4
Source File: OneClickPlugin.java From ExternalPlugins with GNU General Public License v3.0 | 6 votes |
public Pair<Integer, Integer> findItem(Collection<Integer> ids) { final Widget inventoryWidget = client.getWidget(WidgetInfo.INVENTORY); final List<WidgetItem> itemList = (List<WidgetItem>) inventoryWidget.getWidgetItems(); for (int i = itemList.size() - 1; i >= 0; i--) { final WidgetItem item = itemList.get(i); if (ids.contains(item.getId())) { return Pair.of(item.getId(), item.getIndex()); } } return Pair.of(-1, -1); }
Example 5
Source File: AlchemyRoom.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
@Override public void over(Graphics2D graphics) { if (!inside() || !config.alchemy() || best == null) { return; } Widget inventory = client.getWidget(WidgetInfo.INVENTORY); if (inventory.isHidden()) { return; } for (WidgetItem item : inventory.getWidgetItems()) { if (item.getId() != best.getId()) { continue; } drawItem(graphics, item, Color.GREEN); } }
Example 6
Source File: DevToolsOverlay.java From plugins with GNU General Public License v3.0 | 5 votes |
private void renderInventory(Graphics2D graphics) { Widget inventoryWidget = client.getWidget(WidgetInfo.INVENTORY); if (inventoryWidget == null || inventoryWidget.isHidden()) { return; } for (WidgetItem item : inventoryWidget.getWidgetItems()) { Rectangle slotBounds = item.getCanvasBounds(); String idText = "" + item.getId(); FontMetrics fm = graphics.getFontMetrics(); Rectangle2D textBounds = fm.getStringBounds(idText, graphics); int textX = (int) (slotBounds.getX() + (slotBounds.getWidth() / 2) - (textBounds.getWidth() / 2)); int textY = (int) (slotBounds.getY() + (slotBounds.getHeight() / 2) + (textBounds.getHeight() / 2)); graphics.setColor(new Color(255, 255, 255, 65)); graphics.fill(slotBounds); graphics.setColor(Color.BLACK); graphics.drawString(idText, textX + 1, textY + 1); graphics.setColor(YELLOW); graphics.drawString(idText, textX, textY); } }
Example 7
Source File: ZalcanoUtil.java From plugins with GNU General Public License v3.0 | 5 votes |
int countItemInInventory(int itemID) { int i = 0; Widget widget = client.getWidget(WidgetInfo.INVENTORY); for (WidgetItem widgetItem : widget.getWidgetItems()) { if (widgetItem.getId() == itemID) { i++; } } return i; }
Example 8
Source File: CustomSwapper.java From ExternalPlugins with GNU General Public License v3.0 | 5 votes |
private Rectangle invBounds(int id) { final Widget inventoryWidget = client.getWidget(WidgetInfo.INVENTORY); for (WidgetItem item : inventoryWidget.getWidgetItems()) { if (item.getId() == id) { return item.getCanvasBounds(); } } return null; }
Example 9
Source File: CustomSwapper.java From ExternalPlugins with GNU General Public License v3.0 | 5 votes |
private List<Rectangle> listOfBounds(int id) { final Widget inventoryWidget = client.getWidget(WidgetInfo.INVENTORY); final List<Rectangle> bounds = new ArrayList<>(); for (WidgetItem item : inventoryWidget.getWidgetItems()) { if (item.getId() == id) { bounds.add(item.getCanvasBounds()); } } return bounds; }
Example 10
Source File: DevToolsOverlay.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
private void renderInventory(Graphics2D graphics) { Widget inventoryWidget = client.getWidget(WidgetInfo.INVENTORY); if (inventoryWidget == null || inventoryWidget.isHidden()) { return; } for (WidgetItem item : inventoryWidget.getWidgetItems()) { Rectangle slotBounds = item.getCanvasBounds(); String idText = "" + item.getId(); FontMetrics fm = graphics.getFontMetrics(); Rectangle2D textBounds = fm.getStringBounds(idText, graphics); int textX = (int) (slotBounds.getX() + (slotBounds.getWidth() / 2) - (textBounds.getWidth() / 2)); int textY = (int) (slotBounds.getY() + (slotBounds.getHeight() / 2) + (textBounds.getHeight() / 2)); graphics.setColor(new Color(255, 255, 255, 65)); graphics.fill(slotBounds); graphics.setColor(Color.BLACK); graphics.drawString(idText, textX + 1, textY + 1); graphics.setColor(YELLOW); graphics.drawString(idText, textX, textY); } }