Java Code Examples for net.runelite.api.events.MenuEntryAdded#getParam1()
The following examples show how to use
net.runelite.api.events.MenuEntryAdded#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: GrandExchangePlugin.java From plugins with GNU General Public License v3.0 | 5 votes |
@Subscribe private void onMenuEntryAdded(MenuEntryAdded menuEntry) { // 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 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.setOpcode(MenuOpcode.RUNELITE.getId()); menuEntry.setModified(); } }
Example 2
Source File: TabInterface.java From plugins with GNU General Public License v3.0 | 5 votes |
public void handleAdd(MenuEntryAdded event) { if (isHidden()) { return; } MenuEntry[] entries = client.getMenuEntries(); if (activeTab != null && event.getParam1() == WidgetInfo.BANK_ITEM_CONTAINER.getId() && event.getOption().equals("Examine")) { insertMenuEntry(event, REMOVE_TAG + " (" + activeTab.getTag() + ")", event.getTarget()); } else if (event.getParam1() == WidgetInfo.BANK_DEPOSIT_INVENTORY.getId() && event.getOption().equals("Deposit inventory")) { insertMenuEntry(event, TAG_INVENTORY, event.getTarget()); if (activeTab != null) { insertMenuEntry(event, TAG_INVENTORY, ColorUtil.wrapWithColorTag(activeTab.getTag(), HILIGHT_COLOR)); } } else if (event.getParam1() == WidgetInfo.BANK_DEPOSIT_EQUIPMENT.getId() && event.getOption().equals("Deposit worn items")) { insertMenuEntry(event, TAG_GEAR, event.getTarget()); if (activeTab != null) { insertMenuEntry(event, TAG_GEAR, ColorUtil.wrapWithColorTag(activeTab.getTag(), HILIGHT_COLOR)); } } }
Example 3
Source File: BankTagsPlugin.java From plugins with GNU General Public License v3.0 | 5 votes |
@Subscribe private void onMenuEntryAdded(MenuEntryAdded event) { if (event.getParam1() == WidgetInfo.BANK_ITEM_CONTAINER.getId() && event.getOption().equals("Examine")) { Widget container = client.getWidget(WidgetInfo.BANK_ITEM_CONTAINER); Widget item = container.getChild(event.getParam0()); 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 + ")"; } client.insertMenuItem( text, event.getTarget(), MenuOpcode.RUNELITE.getId(), event.getIdentifier(), event.getParam0(), event.getParam1(), false ); } tabInterface.handleAdd(event); }
Example 4
Source File: ObjectIndicatorsPlugin.java From plugins with GNU General Public License v3.0 | 5 votes |
@Subscribe private void onMenuEntryAdded(MenuEntryAdded event) { if (event.getOpcode() != MenuOpcode.EXAMINE_OBJECT.getId() || !client.isKeyPressed(KeyCode.KC_SHIFT)) { return; } final Tile tile = client.getScene().getTiles()[client.getPlane()][event.getParam0()][event.getParam1()]; 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.getParam0()); menuEntry.setParam1(event.getParam1()); menuEntry.setIdentifier(event.getIdentifier()); menuEntry.setOpcode(MenuOpcode.RUNELITE.getId()); client.setMenuEntries(menuEntries); }
Example 5
Source File: SlayermusiqPlugin.java From plugins with GNU General Public License v3.0 | 5 votes |
@Subscribe private void onMenuEntryAdded(MenuEntryAdded event) { int widgetID = event.getParam1(); if (Ints.contains(QUESTLIST_WIDGET_IDS, widgetID) && "Read Journal:".equals(event.getOption())) { MenuEntry[] menuEntries = client.getMenuEntries(); MenuEntry newMenuEntry = createSlayermusiqOptionMenuEntry(event); menuEntries = Arrays.copyOf(menuEntries, menuEntries.length + 1); menuEntries[menuEntries.length - 1] = newMenuEntry; client.setMenuEntries(menuEntries); } }
Example 6
Source File: SlayermusiqPlugin.java From plugins with GNU General Public License v3.0 | 5 votes |
private MenuEntry createSlayermusiqOptionMenuEntry(MenuEntryAdded event) { int widgetIndex = event.getParam0(); int widgetID = event.getParam1(); MenuEntry menuEntry = new MenuEntry(); menuEntry.setTarget(event.getTarget()); menuEntry.setOption(MENUOP_SLAYERMUSIQ); menuEntry.setParam0(widgetIndex); menuEntry.setParam1(widgetID); menuEntry.setOpcode(MenuOpcode.RUNELITE.getId()); return menuEntry; }
Example 7
Source File: XpTrackerPlugin.java From plugins with GNU General Public License v3.0 | 5 votes |
@Subscribe private void onMenuEntryAdded(final MenuEntryAdded event) { int widgetID = event.getParam1(); 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.getParam0()); menuEntry.setParam1(widgetID); menuEntry.setOpcode(MenuOpcode.RUNELITE.getId()); client.setMenuEntries(menuEntries); }
Example 8
Source File: GroundItemsPlugin.java From plugins with GNU General Public License v3.0 | 4 votes |
@Subscribe private void onMenuEntryAdded(MenuEntryAdded lastEntry) { if (config.itemHighlightMode() != OVERLAY) { final boolean telegrabEntry = lastEntry.getOption().equals("Cast") && lastEntry.getTarget().startsWith(TELEGRAB_TEXT) && lastEntry.getOpcode() == CAST_ON_ITEM; if (!(lastEntry.getOption().equals("Take") && lastEntry.getOpcode() == THIRD_OPTION) && !telegrabEntry) { return; } final int itemId = lastEntry.getIdentifier(); final int sceneX = lastEntry.getParam0(); final int sceneY = lastEntry.getParam1(); 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)); lastEntry.setModified(); } 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); lastEntry.setModified(); } } if (config.showMenuItemQuantities() && groundItem.isStackable() && quantity > 1) { lastEntry.setTarget(lastEntry.getTarget() + " (" + quantity + ")"); lastEntry.setModified(); } if (config.removeIgnored() && lastEntry.getOption().equals("Take") && hiddenItemList.contains(Text.removeTags(lastEntry.getTarget()))) { client.setMenuOptionCount(client.getMenuOptionCount() - 1); } } }