Java Code Examples for net.runelite.api.MenuEntry#getParam1()
The following examples show how to use
net.runelite.api.MenuEntry#getParam1() .
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: ItemPricesOverlay.java From plugins with GNU General Public License v3.0 | 5 votes |
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 2
Source File: GrandExchangePlugin.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
@Subscribe public void onMenuEntryAdded(MenuEntryAdded event) { // At the moment, if the user disables quick lookup, the input listener gets disabled. Thus, isHotKeyPressed() // should always return false when quick lookup is disabled. // Replace the default option with "Search ..." when holding alt if (client.getGameState() != GameState.LOGGED_IN || !hotKeyPressed) { return; } final MenuEntry[] entries = client.getMenuEntries(); final MenuEntry menuEntry = entries[entries.length - 1]; final int widgetId = menuEntry.getParam1(); final int groupId = WidgetInfo.TO_GROUP(widgetId); switch (groupId) { case WidgetID.BANK_GROUP_ID: // Don't show for view tabs and such if (WidgetInfo.TO_CHILD(widgetId) != WidgetInfo.BANK_ITEM_CONTAINER.getChildId()) { break; } case WidgetID.INVENTORY_GROUP_ID: case WidgetID.BANK_INVENTORY_GROUP_ID: case WidgetID.GRAND_EXCHANGE_INVENTORY_GROUP_ID: case WidgetID.SHOP_INVENTORY_GROUP_ID: menuEntry.setOption(SEARCH_GRAND_EXCHANGE); menuEntry.setType(MenuAction.RUNELITE.getId()); client.setMenuEntries(entries); } }
Example 3
Source File: InventoryTagsPlugin.java From plugins with GNU General Public License v3.0 | 4 votes |
@Subscribe private void onMenuOpened(final MenuOpened event) { final MenuEntry firstEntry = event.getFirstEntry(); if (firstEntry == null) { return; } final int widgetId = firstEntry.getParam1(); // Inventory item menu if (widgetId == WidgetInfo.INVENTORY.getId() && editorMode) { int itemId = firstEntry.getIdentifier(); if (itemId == -1) { return; } MenuEntry[] menuList = new MenuEntry[config.getAmount().toInt() + 1]; int num = 0; // preserve the 'Cancel' option as the client will reuse the first entry for Cancel and only resets option/action menuList[num++] = event.getMenuEntries()[0]; List<String> groups = GROUPS.subList(Math.max(GROUPS.size() - config.getAmount().toInt(), 0), GROUPS.size()); for (final String groupName : groups) { final String group = getTag(itemId); final MenuEntry newMenu = new MenuEntry(); final Color color = getGroupNameColor(groupName); newMenu.setOption(groupName.equals(group) ? MENU_REMOVE : MENU_SET); newMenu.setTarget(ColorUtil.prependColorTag(groupName, Objects.requireNonNullElse(color, Color.WHITE))); newMenu.setIdentifier(itemId); newMenu.setParam1(widgetId); newMenu.setOpcode(MenuOpcode.RUNELITE.getId()); menuList[num++] = newMenu; } // Need to set the event entries to prevent conflicts event.setMenuEntries(menuList); event.setModified(); } }
Example 4
Source File: StatusBarsOverlay.java From plugins with GNU General Public License v3.0 | 4 votes |
public int getRestoreValue(String skill) { final MenuEntry[] menu = client.getMenuEntries(); final int menuSize = menu.length; final MenuEntry entry = menuSize > 0 ? menu[menuSize - 1] : null; int restoreValue = 0; if (entry != null && entry.getParam1() == WidgetInfo.INVENTORY.getId()) { final Effect change = itemStatService.getItemStatChanges(entry.getIdentifier()); if (change != null) { final StatsChanges statsChanges = change.calculate(client); for (final StatChange c : statsChanges.getStatChanges()) { //final String strVar = c.getTheoretical(); this was erroring final String strVar = String.valueOf(c.getTheoretical()); if (Strings.isNullOrEmpty(strVar)) { continue; } final Integer value = Ints.tryParse(strVar.startsWith("+") ? strVar.substring(1) : strVar); if (value == null) { continue; } if (c.getStat().getName().equals(skill)) { restoreValue = value; } if (restoreValue != 0) { break; } } } } return restoreValue; }
Example 5
Source File: MouseHighlightOverlay.java From plugins with GNU General Public License v3.0 | 4 votes |
@Override public Dimension render(Graphics2D graphics) { if (client.isMenuOpen()) { return null; } MenuEntry[] menuEntries = client.getMenuEntries(); int last = menuEntries.length - 1; if (last < 0) { return null; } MenuEntry menuEntry = menuEntries[last]; String target = menuEntry.getTarget(); String option = menuEntry.getOption(); int type = menuEntry.getOpcode(); if (shouldNotRenderMenuAction(type)) { return null; } if (Strings.isNullOrEmpty(option)) { return null; } // Trivial options that don't need to be highlighted, add more as they appear. switch (option) { case "Walk here": case "Cancel": case "Continue": return null; case "Move": // Hide overlay on sliding puzzle boxes if (target.contains("Sliding piece")) { return null; } } final int widgetId = menuEntry.getParam1(); final int groupId = WidgetInfo.TO_GROUP(widgetId); final int childId = WidgetInfo.TO_CHILD(widgetId); final Widget widget = client.getWidget(groupId, childId); if (!config.uiTooltip() && widget != null) { return null; } if (!config.chatboxTooltip() && groupId == WidgetInfo.CHATBOX.getGroupId()) { return null; } if (widget != null) { // If this varc is set, some CS is showing tooltip int tooltipTimeout = client.getVar(VarClientInt.TOOLTIP_TIMEOUT); if (tooltipTimeout > client.getGameCycle()) { return null; } } if (widget == null && !config.mainTooltip()) { return null; } // If this varc is set, a tooltip is already being displayed int tooltipDisplayed = client.getVar(VarClientInt.TOOLTIP_VISIBLE); if (tooltipDisplayed == 1) { return null; } tooltipManager.addFront(new Tooltip(option + (Strings.isNullOrEmpty(target) ? "" : " " + target))); return null; }
Example 6
Source File: ScreenMarkerWidgetHighlightOverlay.java From plugins with GNU General Public License v3.0 | 4 votes |
@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 7
Source File: ItemPricesOverlay.java From plugins with GNU General Public License v3.0 | 4 votes |
@Override public Dimension render(Graphics2D graphics) { if (client.isMenuOpen()) { return null; } final MenuEntry[] menuEntries = client.getMenuEntries(); final int last = menuEntries.length - 1; if (last < 0) { return null; } final MenuEntry menuEntry = menuEntries[last]; final MenuOpcode action = MenuOpcode.of(menuEntry.getOpcode()); final int widgetId = menuEntry.getParam1(); final int groupId = WidgetInfo.TO_GROUP(widgetId); final boolean isAlching = menuEntry.getOption().equals("Cast") && menuEntry.getTarget().contains("High Level Alchemy"); // Tooltip action type handling switch (action) { case ITEM_USE_ON_WIDGET: if (!config.showWhileAlching() || !isAlching) { break; } case CC_OP: case ITEM_USE: case ITEM_FIRST_OPTION: case ITEM_SECOND_OPTION: case ITEM_THIRD_OPTION: case ITEM_FOURTH_OPTION: case ITEM_FIFTH_OPTION: // Item tooltip values switch (groupId) { case WidgetID.EXPLORERS_RING_ALCH_GROUP_ID: if (!config.showWhileAlching()) { return null; } case WidgetID.INVENTORY_GROUP_ID: if (config.hideInventory() && !(config.showWhileAlching() && isAlching)) { return null; } // intentional fallthrough case WidgetID.BANK_GROUP_ID: case WidgetID.BANK_INVENTORY_GROUP_ID: // Make tooltip final String text = makeValueTooltip(menuEntry); if (text != null) { tooltipManager.add(new Tooltip(ColorUtil.prependColorTag(text, new Color(238, 238, 238)))); } break; } break; } return null; }
Example 8
Source File: InventoryTagsPlugin.java From runelite with BSD 2-Clause "Simplified" License | 4 votes |
@Subscribe public void onMenuOpened(final MenuOpened event) { final MenuEntry firstEntry = event.getFirstEntry(); if (firstEntry == null) { return; } final int widgetId = firstEntry.getParam1(); // Inventory item menu if (widgetId == WidgetInfo.INVENTORY.getId() && editorMode) { int itemId = firstEntry.getIdentifier(); if (itemId == -1) { return; } MenuEntry[] menuList = new MenuEntry[GROUPS.size() + 1]; int num = 0; // preserve the 'Cancel' option as the client will reuse the first entry for Cancel and only resets option/action menuList[num++] = event.getMenuEntries()[0]; for (final String groupName : GROUPS) { final String group = getTag(itemId); final MenuEntry newMenu = new MenuEntry(); final Color color = getGroupNameColor(groupName); newMenu.setOption(groupName.equals(group) ? MENU_REMOVE : MENU_SET); newMenu.setTarget(ColorUtil.prependColorTag(groupName, MoreObjects.firstNonNull(color, Color.WHITE))); newMenu.setIdentifier(itemId); newMenu.setParam1(widgetId); newMenu.setType(MenuAction.RUNELITE.getId()); menuList[num++] = newMenu; } client.setMenuEntries(menuList); } }
Example 9
Source File: MouseHighlightOverlay.java From runelite with BSD 2-Clause "Simplified" License | 4 votes |
@Override public Dimension render(Graphics2D graphics) { if (client.isMenuOpen()) { return null; } MenuEntry[] menuEntries = client.getMenuEntries(); int last = menuEntries.length - 1; if (last < 0) { return null; } MenuEntry menuEntry = menuEntries[last]; String target = menuEntry.getTarget(); String option = menuEntry.getOption(); int type = menuEntry.getType(); if (type == MenuAction.RUNELITE_OVERLAY.getId() || type == MenuAction.CC_OP_LOW_PRIORITY.getId()) { // These are always right click only return null; } if (Strings.isNullOrEmpty(option)) { return null; } // Trivial options that don't need to be highlighted, add more as they appear. switch (option) { case "Walk here": case "Cancel": case "Continue": return null; case "Move": // Hide overlay on sliding puzzle boxes if (target.contains("Sliding piece")) { return null; } } final int widgetId = menuEntry.getParam1(); final int groupId = WidgetInfo.TO_GROUP(widgetId); final int childId = WidgetInfo.TO_CHILD(widgetId); final Widget widget = client.getWidget(groupId, childId); if (!config.uiTooltip() && widget != null) { return null; } if (!config.chatboxTooltip() && groupId == WidgetInfo.CHATBOX.getGroupId()) { return null; } if (config.disableSpellbooktooltip() && groupId == WidgetID.SPELLBOOK_GROUP_ID) { return null; } if (widget != null) { // If this varc is set, some CS is showing tooltip int tooltipTimeout = client.getVar(VarClientInt.TOOLTIP_TIMEOUT); if (tooltipTimeout > client.getGameCycle()) { return null; } } // If this varc is set, a tooltip is already being displayed int tooltipDisplayed = client.getVar(VarClientInt.TOOLTIP_VISIBLE); if (tooltipDisplayed == 1) { return null; } tooltipManager.addFront(new Tooltip(option + (Strings.isNullOrEmpty(target) ? "" : " " + target))); return null; }
Example 10
Source File: ScreenMarkerWidgetHighlightOverlay.java From runelite with BSD 2-Clause "Simplified" License | 4 votes |
@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 11
Source File: ItemPricesOverlay.java From runelite with BSD 2-Clause "Simplified" License | 4 votes |
@Override public Dimension render(Graphics2D graphics) { if (client.isMenuOpen()) { return null; } final MenuEntry[] menuEntries = client.getMenuEntries(); final int last = menuEntries.length - 1; if (last < 0) { return null; } final MenuEntry menuEntry = menuEntries[last]; final MenuAction action = MenuAction.of(menuEntry.getType()); final int widgetId = menuEntry.getParam1(); final int groupId = WidgetInfo.TO_GROUP(widgetId); final boolean isAlching = menuEntry.getOption().equals("Cast") && menuEntry.getTarget().contains("High Level Alchemy"); // Tooltip action type handling switch (action) { case ITEM_USE_ON_WIDGET: if (!config.showWhileAlching() || !isAlching) { break; } case CC_OP: case ITEM_USE: case ITEM_FIRST_OPTION: case ITEM_SECOND_OPTION: case ITEM_THIRD_OPTION: case ITEM_FOURTH_OPTION: case ITEM_FIFTH_OPTION: // Item tooltip values switch (groupId) { case WidgetID.EXPLORERS_RING_ALCH_GROUP_ID: if (!config.showWhileAlching()) { return null; } case WidgetID.INVENTORY_GROUP_ID: if (config.hideInventory() && !(config.showWhileAlching() && isAlching)) { return null; } // intentional fallthrough case WidgetID.BANK_GROUP_ID: case WidgetID.BANK_INVENTORY_GROUP_ID: case WidgetID.SEED_VAULT_GROUP_ID: case WidgetID.SEED_VAULT_INVENTORY_GROUP_ID: // Make tooltip final String text = makeValueTooltip(menuEntry); if (text != null) { tooltipManager.add(new Tooltip(ColorUtil.prependColorTag(text, new Color(238, 238, 238)))); } break; } break; } return null; }
Example 12
Source File: ItemPricesOverlay.java From runelite with BSD 2-Clause "Simplified" License | 4 votes |
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; }
Example 13
Source File: MenuEntrySwapperPlugin.java From runelite with BSD 2-Clause "Simplified" License | 4 votes |
@Subscribe public void onMenuOpened(MenuOpened event) { if (!configuringShiftClick) { return; } MenuEntry firstEntry = event.getFirstEntry(); if (firstEntry == null) { return; } int widgetId = firstEntry.getParam1(); if (widgetId != WidgetInfo.INVENTORY.getId()) { return; } int itemId = firstEntry.getIdentifier(); if (itemId == -1) { return; } ItemComposition itemComposition = client.getItemDefinition(itemId); String itemName = itemComposition.getName(); String option = "Use"; int shiftClickActionIndex = itemComposition.getShiftClickActionIndex(); String[] inventoryActions = itemComposition.getInventoryActions(); if (shiftClickActionIndex >= 0 && shiftClickActionIndex < inventoryActions.length) { option = inventoryActions[shiftClickActionIndex]; } MenuEntry[] entries = event.getMenuEntries(); for (MenuEntry entry : entries) { if (itemName.equals(Text.removeTags(entry.getTarget()))) { entry.setType(MenuAction.RUNELITE.getId()); if (option.equals(entry.getOption())) { entry.setOption("* " + option); } } } final MenuEntry resetShiftClickEntry = new MenuEntry(); resetShiftClickEntry.setOption(RESET); resetShiftClickEntry.setTarget(MENU_TARGET); resetShiftClickEntry.setIdentifier(itemId); resetShiftClickEntry.setParam1(widgetId); resetShiftClickEntry.setType(MenuAction.RUNELITE.getId()); client.setMenuEntries(ArrayUtils.addAll(entries, resetShiftClickEntry)); }