Java Code Examples for net.runelite.api.events.MenuEntryAdded#getActionParam1()
The following examples show how to use
net.runelite.api.events.MenuEntryAdded#getActionParam1() .
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: MenuManager.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
@Subscribe public void onMenuEntryAdded(MenuEntryAdded event) { if (client.getSpellSelected()) { return; } int widgetId = event.getActionParam1(); Collection<WidgetMenuOption> options = managedMenuOptions.get(widgetId); for (WidgetMenuOption currentMenu : options) { if (!menuContainsCustomMenu(currentMenu))//Don't add if we have already added it to this widget { MenuEntry[] menuEntries = client.getMenuEntries(); menuEntries = Arrays.copyOf(menuEntries, menuEntries.length + 1); MenuEntry menuEntry = menuEntries[menuEntries.length - 1] = new MenuEntry(); menuEntry.setOption(currentMenu.getMenuOption()); menuEntry.setParam1(widgetId); menuEntry.setTarget(currentMenu.getMenuTarget()); menuEntry.setType(MenuAction.RUNELITE.getId()); client.setMenuEntries(menuEntries); } } }
Example 2
Source File: BankTagsPlugin.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
@Subscribe public void onMenuEntryAdded(MenuEntryAdded event) { MenuEntry[] entries = client.getMenuEntries(); if (event.getActionParam1() == WidgetInfo.BANK_ITEM_CONTAINER.getId() && event.getOption().equals("Examine")) { Widget container = client.getWidget(WidgetInfo.BANK_ITEM_CONTAINER); Widget item = container.getChild(event.getActionParam0()); int itemID = item.getItemId(); String text = EDIT_TAGS_MENU_OPTION; int tagCount = tagManager.getTags(itemID, false).size() + tagManager.getTags(itemID, true).size(); if (tagCount > 0) { text += " (" + tagCount + ")"; } MenuEntry editTags = new MenuEntry(); editTags.setParam0(event.getActionParam0()); editTags.setParam1(event.getActionParam1()); editTags.setTarget(event.getTarget()); editTags.setOption(text); editTags.setType(MenuAction.RUNELITE.getId()); editTags.setIdentifier(event.getIdentifier()); entries = Arrays.copyOf(entries, entries.length + 1); entries[entries.length - 1] = editTags; client.setMenuEntries(entries); } tabInterface.handleAdd(event); }
Example 3
Source File: ObjectIndicatorsPlugin.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
@Subscribe public void onMenuEntryAdded(MenuEntryAdded event) { if (event.getType() != MenuAction.EXAMINE_OBJECT.getId() || !client.isKeyPressed(KeyCode.KC_SHIFT)) { return; } final Tile tile = client.getScene().getTiles()[client.getPlane()][event.getActionParam0()][event.getActionParam1()]; final TileObject tileObject = findTileObject(tile, event.getIdentifier()); if (tileObject == null) { return; } MenuEntry[] menuEntries = client.getMenuEntries(); menuEntries = Arrays.copyOf(menuEntries, menuEntries.length + 1); MenuEntry menuEntry = menuEntries[menuEntries.length - 1] = new MenuEntry(); menuEntry.setOption(objects.stream().anyMatch(o -> o.getTileObject() == tileObject) ? UNMARK : MARK); menuEntry.setTarget(event.getTarget()); menuEntry.setParam0(event.getActionParam0()); menuEntry.setParam1(event.getActionParam1()); menuEntry.setIdentifier(event.getIdentifier()); menuEntry.setType(MenuAction.RUNELITE.getId()); client.setMenuEntries(menuEntries); }
Example 4
Source File: XpTrackerPlugin.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
@Subscribe public void onMenuEntryAdded(final MenuEntryAdded event) { int widgetID = event.getActionParam1(); if (TO_GROUP(widgetID) != WidgetID.SKILLS_GROUP_ID || !event.getOption().startsWith("View") || !xpTrackerConfig.skillTabOverlayMenuOptions()) { return; } // Get skill from menu option, eg. "View <col=ff981f>Attack</col> guide" final String skillText = event.getOption().split(" ")[1]; final Skill skill = Skill.valueOf(Text.removeTags(skillText).toUpperCase()); MenuEntry[] menuEntries = client.getMenuEntries(); menuEntries = Arrays.copyOf(menuEntries, menuEntries.length + 1); MenuEntry menuEntry = menuEntries[menuEntries.length - 1] = new MenuEntry(); menuEntry.setTarget(skillText); menuEntry.setOption(hasOverlay(skill) ? MENUOP_REMOVE_CANVAS_TRACKER : MENUOP_ADD_CANVAS_TRACKER); menuEntry.setParam0(event.getActionParam0()); menuEntry.setParam1(widgetID); menuEntry.setType(MenuAction.RUNELITE.getId()); client.setMenuEntries(menuEntries); }
Example 5
Source File: TabInterface.java From runelite with BSD 2-Clause "Simplified" License | 4 votes |
public void handleAdd(MenuEntryAdded event) { if (isHidden()) { return; } MenuEntry[] entries = client.getMenuEntries(); if (activeTab != null && event.getActionParam1() == WidgetInfo.BANK_ITEM_CONTAINER.getId() && event.getOption().equals("Examine")) { entries = createMenuEntry(event, REMOVE_TAG + " (" + activeTab.getTag() + ")", event.getTarget(), entries); client.setMenuEntries(entries); } else if (event.getActionParam1() == WidgetInfo.BANK_DEPOSIT_INVENTORY.getId() && event.getOption().equals("Deposit inventory")) { entries = createMenuEntry(event, TAG_INVENTORY, event.getTarget(), entries); if (activeTab != null) { entries = createMenuEntry(event, TAG_INVENTORY, ColorUtil.wrapWithColorTag(activeTab.getTag(), HILIGHT_COLOR), entries); } client.setMenuEntries(entries); } else if (event.getActionParam1() == WidgetInfo.BANK_DEPOSIT_EQUIPMENT.getId() && event.getOption().equals("Deposit worn items")) { entries = createMenuEntry(event, TAG_GEAR, event.getTarget(), entries); if (activeTab != null) { entries = createMenuEntry(event, TAG_GEAR, ColorUtil.wrapWithColorTag(activeTab.getTag(), HILIGHT_COLOR), entries); } client.setMenuEntries(entries); } }
Example 6
Source File: GroundItemsPlugin.java From runelite with BSD 2-Clause "Simplified" License | 4 votes |
@Subscribe public void onMenuEntryAdded(MenuEntryAdded event) { if (config.itemHighlightMode() != OVERLAY) { final boolean telegrabEntry = event.getOption().equals("Cast") && event.getTarget().startsWith(TELEGRAB_TEXT) && event.getType() == CAST_ON_ITEM; if (!(event.getOption().equals("Take") && event.getType() == THIRD_OPTION) && !telegrabEntry) { return; } final int itemId = event.getIdentifier(); final int sceneX = event.getActionParam0(); final int sceneY = event.getActionParam1(); MenuEntry[] menuEntries = client.getMenuEntries(); MenuEntry lastEntry = menuEntries[menuEntries.length - 1]; final WorldPoint worldPoint = WorldPoint.fromScene(client, sceneX, sceneY, client.getPlane()); GroundItem.GroundItemKey groundItemKey = new GroundItem.GroundItemKey(itemId, worldPoint); GroundItem groundItem = collectedGroundItems.get(groundItemKey); int quantity = groundItem.getQuantity(); final int gePrice = groundItem.getGePrice(); final int haPrice = groundItem.getHaPrice(); final Color hidden = getHidden(new NamedQuantity(groundItem.getName(), quantity), gePrice, haPrice, groundItem.isTradeable()); final Color highlighted = getHighlighted(new NamedQuantity(groundItem.getName(), quantity), gePrice, haPrice); final Color color = getItemColor(highlighted, hidden); final boolean canBeRecolored = highlighted != null || (hidden != null && config.recolorMenuHiddenItems()); if (color != null && canBeRecolored && !color.equals(config.defaultColor())) { final MenuHighlightMode mode = config.menuHighlightMode(); if (mode == BOTH || mode == OPTION) { final String optionText = telegrabEntry ? "Cast" : "Take"; lastEntry.setOption(ColorUtil.prependColorTag(optionText, color)); } if (mode == BOTH || mode == NAME) { String target = lastEntry.getTarget(); if (telegrabEntry) { target = target.substring(TELEGRAB_TEXT.length()); } target = ColorUtil.prependColorTag(target.substring(target.indexOf('>') + 1), color); if (telegrabEntry) { target = TELEGRAB_TEXT + target; } lastEntry.setTarget(target); } } if (config.showMenuItemQuantities() && groundItem.isStackable() && quantity > 1) { lastEntry.setTarget(lastEntry.getTarget() + " (" + quantity + ")"); } client.setMenuEntries(menuEntries); } }