Java Code Examples for net.runelite.api.MenuEntry#getParam0()

The following examples show how to use net.runelite.api.MenuEntry#getParam0() . 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: WidgetInspector.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
private void onMenuEntryAdded(MenuEntryAdded event)
{
	if (!pickerSelected)
	{
		return;
	}

	MenuEntry[] menuEntries = client.getMenuEntries();

	for (int i = 0; i < menuEntries.length; i++)
	{
		MenuEntry entry = menuEntries[i];
		if (entry.getOpcode() != MenuOpcode.ITEM_USE_ON_WIDGET.getId()
			&& entry.getOpcode() != MenuOpcode.SPELL_CAST_ON_WIDGET.getId())
		{
			continue;
		}
		String name = WidgetInfo.TO_GROUP(entry.getParam1()) + "." + WidgetInfo.TO_CHILD(entry.getParam1());

		if (entry.getParam0() != -1)
		{
			name += " [" + entry.getParam0() + "]";
		}

		Color color = colorForWidget(i, menuEntries.length);

		entry.setTarget(ColorUtil.wrapWithColorTag(name, color));
	}

	client.setMenuEntries(menuEntries);
}
 
Example 2
Source File: ItemPricesOverlay.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
private String makeValueTooltip(MenuEntry menuEntry)
{
	// Disabling both disables all value tooltips
	if (!config.showGEPrice() && !config.showHAValue())
	{
		return null;
	}

	final int widgetId = menuEntry.getParam1();
	ItemContainer container = null;

	// Inventory item
	if (widgetId == INVENTORY_ITEM_WIDGETID || widgetId == BANK_INVENTORY_ITEM_WIDGETID || widgetId == EXPLORERS_RING_ITEM_WIDGETID)
	{
		container = client.getItemContainer(InventoryID.INVENTORY);
	}
	// Bank item
	else if (widgetId == BANK_ITEM_WIDGETID)
	{
		container = client.getItemContainer(InventoryID.BANK);
	}

	if (container == null)
	{
		return null;
	}

	// Find the item in the container to get stack size
	final int index = menuEntry.getParam0();
	final Item item = container.getItem(index);
	if (item != null)
	{
		return getItemStackValueText(item);
	}

	return null;
}
 
Example 3
Source File: WidgetInspector.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Subscribe
private void onMenuEntryAdded(MenuEntryAdded event)
{
	if (!pickerSelected)
	{
		return;
	}

	MenuEntry[] menuEntries = client.getMenuEntries();

	for (int i = 0; i < menuEntries.length; i++)
	{
		MenuEntry entry = menuEntries[i];
		if (entry.getType() != MenuAction.ITEM_USE_ON_WIDGET.getId()
			&& entry.getType() != MenuAction.SPELL_CAST_ON_WIDGET.getId())
		{
			continue;
		}
		String name = WidgetInfo.TO_GROUP(entry.getParam1()) + "." + WidgetInfo.TO_CHILD(entry.getParam1());

		if (entry.getParam0() != -1)
		{
			name += " [" + entry.getParam0() + "]";
		}

		Color color = colorForWidget(i, menuEntries.length);

		entry.setTarget(ColorUtil.wrapWithColorTag(name, color));
	}

	client.setMenuEntries(menuEntries);
}
 
Example 4
Source File: ScreenMarkerWidgetHighlightOverlay.java    From plugins with GNU General Public License v3.0 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 5
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 6
Source File: ItemPricesOverlay.java    From runelite with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private String makeValueTooltip(MenuEntry menuEntry)
{
	// Disabling both disables all value tooltips
	if (!config.showGEPrice() && !config.showHAValue())
	{
		return null;
	}

	final int widgetId = menuEntry.getParam1();
	ItemContainer container = null;

	// Inventory item
	if (widgetId == INVENTORY_ITEM_WIDGETID ||
		widgetId == BANK_INVENTORY_ITEM_WIDGETID ||
		widgetId == EXPLORERS_RING_ITEM_WIDGETID ||
		widgetId == SEED_VAULT_INVENTORY_ITEM_WIDGETID)
	{
		container = client.getItemContainer(InventoryID.INVENTORY);
	}
	// Bank item
	else if (widgetId == BANK_ITEM_WIDGETID)
	{
		container = client.getItemContainer(InventoryID.BANK);
	}
	// Seed vault item
	else if (widgetId == SEED_VAULT_ITEM_WIDGETID)
	{
		container = client.getItemContainer(InventoryID.SEED_VAULT);
	}
	
	if (container == null)
	{
		return null;
	}

	// Find the item in the container to get stack size
	final int index = menuEntry.getParam0();
	final Item item = container.getItem(index);
	if (item != null)
	{
		return getItemStackValueText(item);
	}

	return null;
}