net.runelite.api.widgets.WidgetItem Java Examples

The following examples show how to use net.runelite.api.widgets.WidgetItem. 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 vote down vote up
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: OneClickPlugin.java    From ExternalPlugins with GNU General Public License v3.0 6 votes vote down vote up
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 #3
Source File: OneClickPlugin.java    From ExternalPlugins with GNU General Public License v3.0 6 votes vote down vote up
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 #4
Source File: PouchOverlay.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void renderItemOverlay(Graphics2D graphics, int itemId, WidgetItem itemWidget)
{
	switch (itemId)
	{
		case ItemID.MEDIUM_POUCH_5511:
		case ItemID.LARGE_POUCH_5513:
		case ItemID.GIANT_POUCH_5515:
			final Rectangle bounds = itemWidget.getCanvasBounds();
			final BufferedImage outline = itemManager.getItemOutline(itemId, itemWidget.getQuantity(), Color.RED);
			graphics.drawImage(outline, (int) bounds.getX(), (int) bounds.getY(), null);
			break;
		case ItemID.MEDIUM_POUCH:
			OverlayUtil.renderTextLocation(graphics, itemWidget.getCanvasLocation(), "~" + plugin.getMediumCharges(), Color.WHITE);
			break;
		case ItemID.LARGE_POUCH:
			OverlayUtil.renderTextLocation(graphics, itemWidget.getCanvasLocation(), "~" + plugin.getLargeCharges(), Color.WHITE);
			break;
		case ItemID.GIANT_POUCH:
			OverlayUtil.renderTextLocation(graphics, itemWidget.getCanvasLocation(), "~" + plugin.getGiantCharges(), Color.WHITE);
			break;
	}
}
 
Example #5
Source File: AlchemyRoom.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
@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 #6
Source File: AlchemyRoom.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@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 #7
Source File: WidgetInspector.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
private void onMenuOptionClicked(MenuOptionClicked ev)
{
	if (!pickerSelected)
	{
		return;
	}

	onPickerDeselect();
	client.setSpellSelected(false);
	ev.consume();

	Object target = getWidgetOrWidgetItemForMenuOption(ev.getMenuOpcode().getId(), ev.getParam0(), ev.getParam1());
	if (target == null)
	{
		return;
	}
	if (target instanceof WidgetItem)
	{
		WidgetItem iw = (WidgetItem) target;
		setSelectedWidget(iw.getWidget(), iw.getIndex(), true);
	}
	else
	{
		setSelectedWidget((Widget) target, -1, true);
	}
}
 
Example #8
Source File: InventoryTagsOverlay.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void renderItemOverlay(Graphics2D graphics, int itemId, WidgetItem itemWidget)
{
	final String group = plugin.getTag(itemId);
	if (group != null)
	{
		final Color color = plugin.getGroupNameColor(group);
		if (color != null)
		{
			Rectangle bounds = itemWidget.getCanvasBounds();
			final BufferedImage outline = itemManager.getItemOutline(itemId, itemWidget.getQuantity(), color);
			graphics.drawImage(outline, (int) bounds.getX(), (int) bounds.getY(), null);
		}
	}
}
 
Example #9
Source File: WidgetInspectorOverlay.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void renderWiw(Graphics2D g, Object wiw, Color color)
{
	g.setColor(color);

	if (wiw instanceof WidgetItem)
	{
		WidgetItem wi = (WidgetItem) wiw;
		Rectangle bounds = wi.getCanvasBounds();
		g.draw(bounds);

		String text = wi.getId() + "";
		FontMetrics fm = g.getFontMetrics();
		Rectangle2D textBounds = fm.getStringBounds(text, g);

		int textX = (int) (bounds.getX() + (bounds.getWidth() / 2) - (textBounds.getWidth() / 2));
		int textY = (int) (bounds.getY() + (bounds.getHeight() / 2) + (textBounds.getHeight() / 2));

		g.setColor(Color.BLACK);
		g.drawString(text, textX + 1, textY + 1);
		g.setColor(Color.ORANGE);
		g.drawString(text, textX, textY);
	}
	else
	{
		Widget w = (Widget) wiw;
		g.draw(w.getBounds());
	}
}
 
Example #10
Source File: WidgetInspector.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Subscribe
private void onMenuOptionClicked(MenuOptionClicked ev)
{
	if (!pickerSelected)
	{
		return;
	}

	onPickerDeselect();
	client.setSpellSelected(false);
	ev.consume();

	Object target = getWidgetOrWidgetItemForMenuOption(ev.getMenuAction().getId(), ev.getActionParam(), ev.getWidgetId());
	if (target == null)
	{
		return;
	}
	if (target instanceof WidgetItem)
	{
		WidgetItem iw = (WidgetItem) target;
		setSelectedWidget(iw.getWidget(), iw.getIndex(), true);
	}
	else
	{
		setSelectedWidget((Widget) target, -1, true);
	}
}
 
Example #11
Source File: DevToolsOverlay.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 #12
Source File: Hooks.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void drawItem(int itemId, WidgetItem widgetItem)
{
	// Empty bank item
	if (widgetItem.getId() != NullItemID.NULL_6512)
	{
		overlayManager.getItemWidgets().add(widgetItem);
	}
}
 
Example #13
Source File: ExtUtils.java    From ExternalPlugins with GNU General Public License v3.0 5 votes vote down vote up
public List<WidgetItem> getItems(int... itemIDs)
{
	assert client.isClientThread();

	return new InventoryWidgetItemQuery()
		.idEquals(itemIDs)
		.result(client)
		.list;
}
 
Example #14
Source File: ItemDropper.java    From ExternalPlugins with GNU General Public License v3.0 5 votes vote down vote up
private void dropItems(List<WidgetItem> dropList)
{
	iterating = true;

	for (String name : names)
	{
		menuManager.addPriorityEntry("drop", name);
		menuManager.addPriorityEntry("release", name);
		menuManager.addPriorityEntry("destroy", name);
	}

	List<Rectangle> rects = new ArrayList<>();

	for (WidgetItem item : dropList)
	{
		rects.add(item.getCanvasBounds());
	}

	executorService.submit(() ->
	{
		for (Rectangle rect : rects)
		{
			utils.click(rect);

			try
			{
				Thread.sleep((int) getMillis());
			}
			catch (InterruptedException e)
			{
				e.printStackTrace();
			}
		}
	});
}
 
Example #15
Source File: ItemDropper.java    From ExternalPlugins with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void hotkeyPressed()
{
	List<WidgetItem> list = new InventoryWidgetItemQuery()
		.idEquals(ids)
		.result(client)
		.list;

	items.addAll(list);
}
 
Example #16
Source File: SlayerOverlay.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void renderItemOverlay(Graphics2D graphics, int itemId, WidgetItem itemWidget)
{
	if (!ALL_SLAYER_ITEMS.contains(itemId))
	{
		return;
	}

	if (!config.showItemOverlay())
	{
		return;
	}

	if (plugin.getCurrentTask() == null)
	{
		return;
	}

	int amount = plugin.getCurrentTask().getAmount();
	if (amount <= 0)
	{
		return;
	}

	final Rectangle bounds = itemWidget.getCanvasBounds();
	final TextComponent textComponent = new TextComponent();

	textComponent.setText(String.valueOf(amount));

	// Draw the counter in the bottom left for equipment, and top left for jewelry
	textComponent.setPosition(new Point(bounds.x - 1, bounds.y - 1 + (SLAYER_JEWELRY.contains(itemId)
		? bounds.height
		: graphics.getFontMetrics().getHeight())));
	textComponent.render(graphics);
}
 
Example #17
Source File: CustomSwapper.java    From ExternalPlugins with GNU General Public License v3.0 5 votes vote down vote up
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 #18
Source File: InventoryGridOverlay.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void drawItem(Graphics2D graphics, Rectangle bounds, WidgetItem item)
{
	if (item.getId() == -1)
	{
		return;
	}

	final BufferedImage draggedItemImage = itemManager.getImage(item.getId(), item.getQuantity(), false);
	final int x = (int) bounds.getX();
	final int y = (int) bounds.getY();

	graphics.setComposite(AlphaComposite.SrcOver.derive(0.3f));
	graphics.drawImage(draggedItemImage, x, y, null);
	graphics.setComposite(AlphaComposite.SrcOver);
}
 
Example #19
Source File: CustomSwapper.java    From ExternalPlugins with GNU General Public License v3.0 5 votes vote down vote up
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 #20
Source File: InventoryGridOverlay.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
private void drawItem(Graphics2D graphics, Rectangle bounds, WidgetItem item)
{
	if (item.getId() == -1)
	{
		return;
	}

	final BufferedImage draggedItemImage = itemManager.getImage(item.getId(), item.getQuantity(), false);
	final int x = (int) bounds.getX();
	final int y = (int) bounds.getY();

	graphics.setComposite(AlphaComposite.SrcOver.derive(0.3f));
	graphics.drawImage(draggedItemImage, x, y, null);
	graphics.setComposite(AlphaComposite.SrcOver);
}
 
Example #21
Source File: DevToolsOverlay.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
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 #22
Source File: MiningCoalBagOverlay.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void renderItemOverlay(Graphics2D graphics, int itemId, WidgetItem itemWidget)
{
	if (!config.showCoalBagOverlay() || (itemId != ItemID.COAL_BAG && itemId != ItemID.COAL_BAG_12019))
	{
		return;
	}

	graphics.setFont(FontManager.getRunescapeSmallFont());
	graphics.setColor(Color.WHITE);
	Point location = itemWidget.getCanvasLocation();

	graphics.drawString(config.amountOfCoalInCoalBag() + "", location.getX(), location.getY() + 14);
}
 
Example #23
Source File: HighAlchemyOverlay.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void renderItemOverlay(Graphics2D graphics, int itemId, WidgetItem itemWidget)
{
	Widget widget = itemWidget.getWidget();
	int interfaceGroup = TO_GROUP(widget.getId());

	if (!plugin.getInterfaceGroups().contains(interfaceGroup))
	{
		return;
	}

	final int natPrice = itemManager.getItemPrice(ItemID.NATURE_RUNE, true);
	final int alchPriceNoStaff = natPrice + 5 * itemManager.getItemPrice(ItemID.FIRE_RUNE, true);

	final int id = getNotedId(itemId);
	final int gePrice = getGEPrice(id);
	final int haPrice = getHAPrice(id);
	final int materialCost = config.usingFireRunes() ? alchPriceNoStaff : natPrice;
	final int desiredProfit = config.minProfit();
	final int haProfit = getHAProfit(haPrice, gePrice, materialCost);

	if (gePrice > 0 && haPrice > 0 && haProfit >= desiredProfit)
	{
		final Color color = config.getHighlightColor();

		if (color != null)
		{
			Rectangle bounds = itemWidget.getCanvasBounds();
			final BufferedImage outline = itemManager.getItemOutline(itemId, itemWidget.getQuantity(), color);
			graphics.drawImage(outline, (int) bounds.getX() + 1, (int) bounds.getY() + 1, null);
		}
	}
}
 
Example #24
Source File: WidgetInspectorOverlay.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
private void renderWiw(Graphics2D g, Object wiw, Color color)
{
	g.setColor(color);

	if (wiw instanceof WidgetItem)
	{
		WidgetItem wi = (WidgetItem) wiw;
		Rectangle bounds = wi.getCanvasBounds();
		g.draw(bounds);

		String text = wi.getId() + "";
		FontMetrics fm = g.getFontMetrics();
		Rectangle2D textBounds = fm.getStringBounds(text, g);

		int textX = (int) (bounds.getX() + (bounds.getWidth() / 2) - (textBounds.getWidth() / 2));
		int textY = (int) (bounds.getY() + (bounds.getHeight() / 2) + (textBounds.getHeight() / 2));

		g.setColor(Color.BLACK);
		g.drawString(text, textX + 1, textY + 1);
		g.setColor(Color.ORANGE);
		g.drawString(text, textX, textY);
	}
	else
	{
		Widget w = (Widget) wiw;
		g.draw(w.getBounds());
	}
}
 
Example #25
Source File: ZalcanoUtil.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
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 #26
Source File: InventoryTagsOverlay.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void renderItemOverlay(Graphics2D graphics, int itemId, WidgetItem itemWidget)
{
	final String group = plugin.getTag(itemId);
	if (group != null)
	{
		final Color color = plugin.getGroupNameColor(group);
		if (color != null)
		{
			Rectangle bounds = itemWidget.getCanvasBounds();
			final BufferedImage outline = itemManager.getItemOutline(itemId, itemWidget.getQuantity(), color);
			graphics.drawImage(outline, (int) bounds.getX(), (int) bounds.getY(), null);
		}
	}
}
 
Example #27
Source File: InventoryGridOverlay.java    From plugins with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Dimension render(Graphics2D graphics)
{
	final Widget if1DraggingWidget = client.getIf1DraggedWidget();
	final Widget inventoryWidget = client.getWidget(WidgetInfo.INVENTORY);

	if (if1DraggingWidget == null || if1DraggingWidget != inventoryWidget
		|| client.getItemPressedDuration() < config.dragDelay() / Constants.CLIENT_TICK_LENGTH)
	{
		initialMousePoint = null;
		hoverActive = false;
		return null;
	}

	final net.runelite.api.Point mouse = client.getMouseCanvasPosition();
	final Point mousePoint = new Point(mouse.getX(), mouse.getY());
	final int if1DraggedItemIndex = client.getIf1DraggedItemIndex();
	final WidgetItem draggedItem = inventoryWidget.getWidgetItem(if1DraggedItemIndex);
	final Rectangle initialBounds = draggedItem.getCanvasBounds(false);

	if (initialMousePoint == null)
	{
		initialMousePoint = mousePoint;
	}

	if (draggedItem.getId() == -1 || !hoverActive && initialMousePoint.distance(mousePoint) < DISTANCE_TO_ACTIVATE_HOVER)
	{
		return null;
	}

	hoverActive = true;

	for (int i = 0; i < INVENTORY_SIZE; ++i)
	{
		WidgetItem targetWidgetItem = inventoryWidget.getWidgetItem(i);

		final Rectangle bounds = targetWidgetItem.getCanvasBounds(false);
		boolean inBounds = bounds.contains(mousePoint);

		if (config.showItem() && inBounds)
		{
			drawItem(graphics, bounds, draggedItem);
			drawItem(graphics, initialBounds, targetWidgetItem);
		}

		if (config.showHighlight() && inBounds)
		{
			graphics.setColor(config.highlightColor());
			graphics.fill(bounds);
		}
		else if (config.showInventoryGrid())
		{
			graphics.setColor(config.gridColor());
			graphics.fill(bounds);
		}
	}

	return null;
}
 
Example #28
Source File: InventoryGridOverlay.java    From runelite with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public Dimension render(Graphics2D graphics)
{
	final Widget if1DraggingWidget = client.getIf1DraggedWidget();
	final Widget inventoryWidget = client.getWidget(WidgetInfo.INVENTORY);

	if (if1DraggingWidget == null || if1DraggingWidget != inventoryWidget)
	{
		initialMousePoint = null;
		hoverActive = false;
		return null;
	}

	final net.runelite.api.Point mouse = client.getMouseCanvasPosition();
	final Point mousePoint = new Point(mouse.getX(), mouse.getY());
	final int if1DraggedItemIndex = client.getIf1DraggedItemIndex();
	final WidgetItem draggedItem = inventoryWidget.getWidgetItem(if1DraggedItemIndex);
	final Rectangle initialBounds = draggedItem.getCanvasBounds(false);

	if (initialMousePoint == null)
	{
		initialMousePoint = mousePoint;
	}

	if (draggedItem.getId() == -1
		|| client.getItemPressedDuration() < config.dragDelay() / Constants.CLIENT_TICK_LENGTH
		|| !hoverActive && initialMousePoint.distance(mousePoint) < DISTANCE_TO_ACTIVATE_HOVER)
	{
		return null;
	}

	hoverActive = true;

	for (int i = 0; i < INVENTORY_SIZE; ++i)
	{
		WidgetItem targetWidgetItem = inventoryWidget.getWidgetItem(i);

		final Rectangle bounds = targetWidgetItem.getCanvasBounds(false);
		boolean inBounds = bounds.contains(mousePoint);

		if (config.showItem() && inBounds)
		{
			drawItem(graphics, bounds, draggedItem);
			drawItem(graphics, initialBounds, targetWidgetItem);
		}

		if (config.showHighlight() && inBounds)
		{
			graphics.setColor(HIGHLIGHT);
			graphics.fill(bounds);
		}
		else if (config.showGrid())
		{
			graphics.setColor(GRID);
			graphics.fill(bounds);
		}
	}

	return null;
}
 
Example #29
Source File: ScreenMarkerWidgetHighlightOverlay.java    From runelite with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public Dimension render(Graphics2D graphics)
{
	if (!plugin.isCreatingScreenMarker() || plugin.isDrawingScreenMarker())
	{
		return null;
	}

	final MenuEntry[] menuEntries = client.getMenuEntries();
	if (client.isMenuOpen() || menuEntries.length == 0)
	{
		plugin.setSelectedWidgetBounds(null);
		return null;
	}

	final MenuEntry menuEntry = menuEntries[menuEntries.length - 1];
	final int childIdx = menuEntry.getParam0();
	final int widgetId = menuEntry.getParam1();
	final int groupId = WidgetInfo.TO_GROUP(widgetId);
	final int componentId = WidgetInfo.TO_CHILD(widgetId);

	final Widget widget = client.getWidget(groupId, componentId);
	if (widget == null)
	{
		plugin.setSelectedWidgetBounds(null);
		return null;
	}

	Rectangle bounds = null;
	if (childIdx > -1)
	{
		if (widget.getType() == WidgetType.INVENTORY)
		{
			final WidgetItem widgetItem = widget.getWidgetItem(childIdx);
			if (widgetItem != null)
			{
				bounds = widgetItem.getCanvasBounds();
			}
		}
		else
		{
			final Widget child = widget.getChild(childIdx);
			if (child != null)
			{
				bounds = child.getBounds();
			}
		}
	}
	else
	{
		bounds = widget.getBounds();
	}

	if (bounds == null)
	{
		plugin.setSelectedWidgetBounds(null);
		return null;
	}

	drawHighlight(graphics, bounds);
	plugin.setSelectedWidgetBounds(bounds);

	return null;
}
 
Example #30
Source File: ItemIdentificationOverlay.java    From runelite with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public void renderItemOverlay(Graphics2D graphics, int itemId, WidgetItem itemWidget)
{
	ItemIdentification iden = findItemIdentification(itemId);
	if (iden == null)
	{
		return;
	}

	switch (iden.type)
	{
		case SEED:
			if (!config.showSeeds())
			{
				return;
			}
			break;
		case HERB:
			if (!config.showHerbs())
			{
				return;
			}
			break;
		case SAPLING:
			if (!config.showSaplings())
			{
				return;
			}
			break;
		case ORE:
			if (!config.showOres())
			{
				return;
			}
			break;
		case GEM:
			if (!config.showGems())
			{
				return;
			}
			break;
		case POTION:
			if (!config.showPotions())
			{
				return;
			}
			break;
		case IMPLING_JAR:
			if (!config.showImplingJars())
			{
				return;
			}
			break;
	}

	graphics.setFont(FontManager.getRunescapeSmallFont());
	renderText(graphics, itemWidget.getCanvasBounds(), iden);
}