Java Code Examples for net.runelite.api.MenuEntry#getTarget()
The following examples show how to use
net.runelite.api.MenuEntry#getTarget() .
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 |
private boolean menuContainsCustomMenu(WidgetMenuOption customMenuOption) { for (MenuEntry menuEntry : client.getMenuEntries()) { String option = menuEntry.getOption(); String target = menuEntry.getTarget(); if (option.equals(customMenuOption.getMenuOption()) && target.equals(customMenuOption.getMenuTarget())) { return true; } } return false; }
Example 2
Source File: OpponentInfoPlugin.java From plugins with GNU General Public License v3.0 | 4 votes |
private boolean modify(MenuEntry entry) { if (isNotAttackEntry(entry)) { return false; } boolean changed = false; int index = entry.getIdentifier(); Actor actor = getActorFromIndex(index); if (actor == null) { return false; } if (actor instanceof Player) { index -= 32768; } String target = entry.getTarget(); if (showAttacking && client.getLocalPlayer().getRSInteracting() == index) { target = attackingColTag + target.substring(COLOR_TAG_LENGTH); changed = true; } if (showAttackers && actor.getRSInteracting() - 32768 == client.getLocalPlayerIndex()) { target = '*' + target; changed = true; } if (showHitpoints && actor.getHealthScale() > 0) { int lvlIndex = target.lastIndexOf("(level-"); if (lvlIndex != -1) { String levelReplacement = getHpString(actor, true); target = target.substring(0, lvlIndex) + levelReplacement; changed = true; } } if (changed) { entry.setTarget(target); return true; } return false; }
Example 3
Source File: OpponentInfoPlugin.java From plugins with GNU General Public License v3.0 | 4 votes |
private boolean fixup(MenuEntry entry) { if (isNotAttackEntry(entry)) { return false; } int index = entry.getIdentifier(); Actor actor = getActorFromIndex(index); if (actor == null) { return false; } if (actor instanceof Player) { index -= 32768; } String target = entry.getTarget(); boolean hasAggro = actor.getRSInteracting() - 32768 == client.getLocalPlayerIndex(); boolean hadAggro = target.charAt(0) == '*'; boolean isTarget = client.getLocalPlayer().getRSInteracting() == index; boolean hasHp = showHitpoints && actor instanceof NPC && actor.getHealthScale() > 0; boolean aggroChanged = showAttackers && hasAggro != hadAggro; boolean targetChanged = showAttacking && isTarget != target.startsWith(attackingColTag, aggroChanged ? 1 : 0); boolean hpChanged = showHitpoints && hasHp == target.contains("(level-"); if (!aggroChanged && !targetChanged && !hasHp && !hpChanged) { return false; } if (targetChanged) { boolean player = actor instanceof Player; final int start = hadAggro ? 1 + COLOR_TAG_LENGTH : COLOR_TAG_LENGTH; target = (hasAggro ? '*' : "") + (isTarget ? attackingColTag : player ? ColorUtil.colorStartTag(0xffffff) : ColorUtil.colorStartTag(0xffff00)) + target.substring(start); } else if (aggroChanged) { if (hasAggro) { target = '*' + target; } else { target = target.substring(1); } } if (hpChanged || hasHp) { final int braceIdx; if (!hasHp) { braceIdx = target.lastIndexOf("<col=ff0000>("); if (braceIdx != -1) { target = target.substring(0, braceIdx - 1) + "(level-" + actor.getCombatLevel() + ")"; } } else if ((braceIdx = target.lastIndexOf('(')) != -1) { final String hpString = getHpString(actor, hpChanged); target = target.substring(0, braceIdx) + hpString; } } entry.setTarget(target); return true; }
Example 4
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 5
Source File: PlayerIndicatorsPlugin.java From runelite with BSD 2-Clause "Simplified" License | 4 votes |
@Subscribe public void onClientTick(ClientTick clientTick) { if (client.isMenuOpen()) { return; } MenuEntry[] menuEntries = client.getMenuEntries(); boolean modified = false; for (MenuEntry entry : menuEntries) { int type = entry.getType(); if (type >= MENU_ACTION_DEPRIORITIZE_OFFSET) { type -= MENU_ACTION_DEPRIORITIZE_OFFSET; } if (type == WALK.getId() || type == SPELL_CAST_ON_PLAYER.getId() || type == ITEM_USE_ON_PLAYER.getId() || type == PLAYER_FIRST_OPTION.getId() || type == PLAYER_SECOND_OPTION.getId() || type == PLAYER_THIRD_OPTION.getId() || type == PLAYER_FOURTH_OPTION.getId() || type == PLAYER_FIFTH_OPTION.getId() || type == PLAYER_SIXTH_OPTION.getId() || type == PLAYER_SEVENTH_OPTION.getId() || type == PLAYER_EIGTH_OPTION.getId() || type == RUNELITE_PLAYER.getId()) { Player[] players = client.getCachedPlayers(); Player player = null; int identifier = entry.getIdentifier(); // 'Walk here' identifiers are offset by 1 because the default // identifier for this option is 0, which is also a player index. if (type == WALK.getId()) { identifier--; } if (identifier >= 0 && identifier < players.length) { player = players[identifier]; } if (player == null) { continue; } Decorations decorations = getDecorations(player); if (decorations == null) { continue; } String oldTarget = entry.getTarget(); String newTarget = decorateTarget(oldTarget, decorations); entry.setTarget(newTarget); modified = true; } } if (modified) { client.setMenuEntries(menuEntries); } }
Example 6
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 7
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); } }