Java Code Examples for net.runelite.api.MenuEntry#setType()
The following examples show how to use
net.runelite.api.MenuEntry#setType() .
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: MenuEntrySwapperPlugin.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
private void bankModeSwap(int entryTypeId, int entryIdentifier) { MenuEntry[] menuEntries = client.getMenuEntries(); for (int i = menuEntries.length - 1; i >= 0; --i) { MenuEntry entry = menuEntries[i]; if (entry.getType() == entryTypeId && entry.getIdentifier() == entryIdentifier) { // Raise the priority of the op so it doesn't get sorted later entry.setType(MenuAction.CC_OP.getId()); menuEntries[i] = menuEntries[menuEntries.length - 1]; menuEntries[menuEntries.length - 1] = entry; client.setMenuEntries(menuEntries); break; } } }
Example 2
Source File: OverlayRenderer.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
private MenuEntry[] createRightClickMenuEntries(Overlay overlay) { List<OverlayMenuEntry> menuEntries = overlay.getMenuEntries(); if (menuEntries.isEmpty()) { return null; } final MenuEntry[] entries = new MenuEntry[menuEntries.size()]; // Add in reverse order so they display correctly in the right-click menu for (int i = menuEntries.size() - 1; i >= 0; --i) { OverlayMenuEntry overlayMenuEntry = menuEntries.get(i); final MenuEntry entry = new MenuEntry(); entry.setOption(overlayMenuEntry.getOption()); entry.setTarget(ColorUtil.wrapWithColorTag(overlayMenuEntry.getTarget(), JagexColors.MENU_TARGET)); entry.setType(overlayMenuEntry.getMenuAction().getId()); entry.setIdentifier(overlayManager.getOverlays().indexOf(overlay)); // overlay id entries[i] = entry; } return entries; }
Example 3
Source File: FriendNotesPlugin.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
@Subscribe public void onMenuEntryAdded(MenuEntryAdded event) { final int groupId = WidgetInfo.TO_GROUP(event.getActionParam1()); // Look for "Message" on friends list if ((groupId == WidgetInfo.FRIENDS_LIST.getGroupId() && event.getOption().equals("Message")) || (groupId == WidgetInfo.IGNORE_LIST.getGroupId() && event.getOption().equals("Delete"))) { // Friends have color tags setHoveredFriend(Text.toJagexName(Text.removeTags(event.getTarget()))); // Build "Add Note" or "Edit Note" menu entry final MenuEntry addNote = new MenuEntry(); addNote.setOption(hoveredFriend == null || hoveredFriend.getNote() == null ? ADD_NOTE : EDIT_NOTE); addNote.setType(MenuAction.RUNELITE.getId()); addNote.setTarget(event.getTarget()); //Preserve color codes here addNote.setParam0(event.getActionParam0()); addNote.setParam1(event.getActionParam1()); // Add menu entry final MenuEntry[] menuEntries = ObjectArrays.concat(client.getMenuEntries(), addNote); client.setMenuEntries(menuEntries); } else if (hoveredFriend != null) { hoveredFriend = null; } }
Example 4
Source File: MenuEntrySwapperPluginTest.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
private static MenuEntry menu(String option, String target, MenuAction menuAction, int identifier) { MenuEntry menuEntry = new MenuEntry(); menuEntry.setOption(option); menuEntry.setTarget(target); menuEntry.setType(menuAction.getId()); menuEntry.setIdentifier(identifier); return menuEntry; }
Example 5
Source File: ChatHistoryPlugin.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
@Subscribe public void onMenuEntryAdded(MenuEntryAdded entry) { final ChatboxTab tab = ChatboxTab.of(entry.getActionParam1()); if (tab == null || !config.clearHistory() || !Text.removeTags(entry.getOption()).equals(tab.getAfter())) { return; } final MenuEntry clearEntry = new MenuEntry(); clearEntry.setTarget(""); clearEntry.setType(MenuAction.RUNELITE.getId()); clearEntry.setParam0(entry.getActionParam0()); clearEntry.setParam1(entry.getActionParam1()); if (tab == ChatboxTab.GAME) { // keep type as the original CC_OP to correctly group "Game: Clear history" with // other tab "Game: *" options. clearEntry.setType(entry.getType()); } final StringBuilder messageBuilder = new StringBuilder(); if (tab != ChatboxTab.ALL) { messageBuilder.append(ColorUtil.wrapWithColorTag(tab.getName() + ": ", Color.YELLOW)); } messageBuilder.append(CLEAR_HISTORY); clearEntry.setOption(messageBuilder.toString()); final MenuEntry[] menuEntries = client.getMenuEntries(); client.setMenuEntries(ArrayUtils.insert(menuEntries.length - 1, menuEntries, clearEntry)); }
Example 6
Source File: HiscorePlugin.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
@Subscribe public void onMenuEntryAdded(MenuEntryAdded event) { if (!config.menuOption()) { return; } int groupId = WidgetInfo.TO_GROUP(event.getActionParam1()); String option = event.getOption(); if (groupId == WidgetInfo.FRIENDS_LIST.getGroupId() || groupId == WidgetInfo.FRIENDS_CHAT.getGroupId() || groupId == WidgetInfo.CHATBOX.getGroupId() && !KICK_OPTION.equals(option) || //prevent from adding for Kick option (interferes with the raiding party one) groupId == WidgetInfo.RAIDING_PARTY.getGroupId() || groupId == WidgetInfo.PRIVATE_CHAT_MESSAGE.getGroupId() || groupId == WidgetInfo.IGNORE_LIST.getGroupId()) { if (!AFTER_OPTIONS.contains(option) || (option.equals("Delete") && groupId != WidgetInfo.IGNORE_LIST.getGroupId())) { return; } final MenuEntry lookup = new MenuEntry(); lookup.setOption(LOOKUP); lookup.setTarget(event.getTarget()); lookup.setType(MenuAction.RUNELITE.getId()); lookup.setParam0(event.getActionParam0()); lookup.setParam1(event.getActionParam1()); lookup.setIdentifier(event.getIdentifier()); insertMenuEntry(lookup, client.getMenuEntries()); } }
Example 7
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 8
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 9
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 10
Source File: TabInterface.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
private static MenuEntry[] createMenuEntry(MenuEntryAdded event, String option, String target, MenuEntry[] entries) { final MenuEntry entry = new MenuEntry(); entry.setParam0(event.getActionParam0()); entry.setParam1(event.getActionParam1()); entry.setTarget(target); entry.setOption(option); entry.setType(MenuAction.RUNELITE.getId()); entry.setIdentifier(event.getIdentifier()); entries = Arrays.copyOf(entries, entries.length + 1); entries[entries.length - 1] = entry; return entries; }
Example 11
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 12
Source File: GroundMarkerPlugin.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
@Subscribe public void onMenuEntryAdded(MenuEntryAdded event) { final boolean hotKeyPressed = client.isKeyPressed(KeyCode.KC_SHIFT); if (hotKeyPressed && event.getOption().equals(WALK_HERE)) { final Tile selectedSceneTile = client.getSelectedSceneTile(); if (selectedSceneTile == null) { return; } MenuEntry[] menuEntries = client.getMenuEntries(); menuEntries = Arrays.copyOf(menuEntries, menuEntries.length + 1); MenuEntry menuEntry = menuEntries[menuEntries.length - 1] = new MenuEntry(); final WorldPoint worldPoint = WorldPoint.fromLocalInstance(client, selectedSceneTile.getLocalLocation()); final int regionId = worldPoint.getRegionID(); final GroundMarkerPoint point = new GroundMarkerPoint(regionId, worldPoint.getRegionX(), worldPoint.getRegionY(), client.getPlane(), config.markerColor()); menuEntry.setOption(getPoints(regionId).contains(point) ? UNMARK : MARK); menuEntry.setTarget(event.getTarget()); menuEntry.setType(MenuAction.RUNELITE.getId()); client.setMenuEntries(menuEntries); } }
Example 13
Source File: CameraPlugin.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
private MenuEntry createCameraLookEntry(MenuEntryAdded lookNorth, int identifier, String option) { MenuEntry m = new MenuEntry(); m.setOption(option); m.setTarget(lookNorth.getTarget()); m.setIdentifier(identifier); m.setType(MenuAction.CC_OP.getId()); m.setParam0(lookNorth.getActionParam0()); m.setParam1(lookNorth.getActionParam1()); return m; }
Example 14
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 15
Source File: WorldHopperPlugin.java From runelite with BSD 2-Clause "Simplified" License | 4 votes |
@Subscribe public void onMenuEntryAdded(MenuEntryAdded event) { if (!config.menuOption()) { return; } int groupId = WidgetInfo.TO_GROUP(event.getActionParam1()); String option = event.getOption(); if (groupId == WidgetInfo.FRIENDS_LIST.getGroupId() || groupId == WidgetInfo.FRIENDS_CHAT.getGroupId()) { boolean after; if (AFTER_OPTIONS.contains(option)) { after = true; } else if (BEFORE_OPTIONS.contains(option)) { after = false; } else { return; } // Don't add entry if user is offline ChatPlayer player = getChatPlayerFromName(event.getTarget()); WorldResult worldResult = worldService.getWorlds(); if (player == null || player.getWorld() == 0 || player.getWorld() == client.getWorld() || worldResult == null) { return; } World currentWorld = worldResult.findWorld(client.getWorld()); World targetWorld = worldResult.findWorld(player.getWorld()); if (targetWorld == null || currentWorld == null || (!currentWorld.getTypes().contains(WorldType.PVP) && targetWorld.getTypes().contains(WorldType.PVP))) { // Disable Hop-to a PVP world from a regular world return; } final MenuEntry hopTo = new MenuEntry(); hopTo.setOption(HOP_TO); hopTo.setTarget(event.getTarget()); hopTo.setType(MenuAction.RUNELITE.getId()); hopTo.setParam0(event.getActionParam0()); hopTo.setParam1(event.getActionParam1()); insertMenuEntry(hopTo, client.getMenuEntries(), after); } }
Example 16
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)); }
Example 17
Source File: ChatHistoryPlugin.java From runelite with BSD 2-Clause "Simplified" License | 4 votes |
@Subscribe public void onMenuOpened(MenuOpened event) { if (event.getMenuEntries().length < 2 || !config.copyToClipboard()) { return; } // Use second entry as first one can be walk here with transparent chatbox final MenuEntry entry = event.getMenuEntries()[event.getMenuEntries().length - 2]; if (entry.getType() != MenuAction.CC_OP_LOW_PRIORITY.getId() && entry.getType() != MenuAction.RUNELITE.getId()) { return; } final int groupId = TO_GROUP(entry.getParam1()); final int childId = TO_CHILD(entry.getParam1()); if (groupId != WidgetInfo.CHATBOX.getGroupId()) { return; } final Widget widget = client.getWidget(groupId, childId); final Widget parent = widget.getParent(); if (WidgetInfo.CHATBOX_MESSAGE_LINES.getId() != parent.getId()) { return; } // Get child id of first chat message static child so we can substract this offset to link to dynamic child // later final int first = WidgetInfo.CHATBOX_FIRST_MESSAGE.getChildId(); // Convert current message static widget id to dynamic widget id of message node with message contents // When message is right clicked, we are actually right clicking static widget that contains only sender. // The actual message contents are stored in dynamic widgets that follow same order as static widgets. // Every first dynamic widget is message sender and every second one is message contents. final int dynamicChildId = (childId - first) * 2 + 1; // Extract and store message contents when menu is opened because dynamic children can change while right click // menu is open and dynamicChildId will be outdated final Widget messageContents = parent.getChild(dynamicChildId); if (messageContents == null) { return; } currentMessage = messageContents.getText(); final MenuEntry menuEntry = new MenuEntry(); menuEntry.setOption(COPY_TO_CLIPBOARD); menuEntry.setTarget(entry.getTarget()); menuEntry.setType(MenuAction.RUNELITE.getId()); menuEntry.setParam0(entry.getParam0()); menuEntry.setParam1(entry.getParam1()); menuEntry.setIdentifier(entry.getIdentifier()); client.setMenuEntries(ArrayUtils.insert(1, client.getMenuEntries(), menuEntry)); }
Example 18
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); } }