Search in sources :

Example 1 with MenuEntry

use of net.runelite.api.MenuEntry in project runelite by runelite.

the class MenuManager method onMenuEntryAdded.

@Subscribe
public void onMenuEntryAdded(MenuEntryAdded event) {
    int widgetId = event.getActionParam1();
    Collection<WidgetMenuOption> options = managedMenuOptions.get(widgetId);
    Client client = clientProvider.get();
    if (client == null) {
        return;
    }
    for (WidgetMenuOption currentMenu : options) {
        if (// Don't add if we have already added it to this widget
        !menuContainsCustomMenu(currentMenu)) {
            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);
        }
    }
}
Also used : MenuEntry(net.runelite.api.MenuEntry) Client(net.runelite.api.Client) Subscribe(com.google.common.eventbus.Subscribe)

Example 2 with MenuEntry

use of net.runelite.api.MenuEntry in project runelite by runelite.

the class ItemPricesOverlay method render.

@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);
    // Tooltip action type handling
    switch(action) {
        case WIDGET_DEFAULT:
        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.INVENTORY_GROUP_ID:
                    if (config.hideInventory()) {
                        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("<col=eeeeee>" + text));
                    }
                    break;
            }
            break;
    }
    return null;
}
Also used : MenuAction(net.runelite.api.MenuAction) MenuEntry(net.runelite.api.MenuEntry) Tooltip(net.runelite.client.ui.overlay.tooltip.Tooltip)

Example 3 with MenuEntry

use of net.runelite.api.MenuEntry in project runelite by runelite.

the class RSClientMixin method getMenuEntries.

@Inject
@Override
public MenuEntry[] getMenuEntries() {
    int count = getMenuOptionCount();
    String[] menuOptions = getMenuOptions();
    String[] menuTargets = getMenuTargets();
    int[] menuIdentifiers = getMenuIdentifiers();
    int[] menuTypes = getMenuTypes();
    int[] params0 = getMenuActionParams0();
    int[] params1 = getMenuActionParams1();
    MenuEntry[] entries = new MenuEntry[count];
    for (int i = 0; i < count; ++i) {
        MenuEntry entry = entries[i] = new MenuEntry();
        entry.setOption(menuOptions[i]);
        entry.setTarget(menuTargets[i]);
        entry.setIdentifier(menuIdentifiers[i]);
        entry.setType(menuTypes[i]);
        entry.setParam0(params0[i]);
        entry.setParam1(params1[i]);
    }
    return entries;
}
Also used : MenuEntry(net.runelite.api.MenuEntry) LocalPoint(net.runelite.api.coords.LocalPoint) Point(net.runelite.api.Point) Inject(net.runelite.api.mixins.Inject)

Example 4 with MenuEntry

use of net.runelite.api.MenuEntry in project runelite by runelite.

the class MouseHighlightOverlay method render.

@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();
    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
        Varcs varcs = client.getVarcs();
        int tooltipTimeout = varcs.getIntVar(VarClient.TOOLTIP_TIMEOUT);
        if (tooltipTimeout > client.getGameCycle()) {
            return null;
        }
    }
    tooltipManager.addFront(new Tooltip(option + (Strings.isNullOrEmpty(target) ? "" : " " + target)));
    return null;
}
Also used : MenuEntry(net.runelite.api.MenuEntry) Tooltip(net.runelite.client.ui.overlay.tooltip.Tooltip) Widget(net.runelite.api.widgets.Widget) Varcs(net.runelite.api.Varcs)

Example 5 with MenuEntry

use of net.runelite.api.MenuEntry in project runelite by runelite.

the class MenuEntrySwapperPlugin method searchIndex.

private int searchIndex(MenuEntry[] entries, String option, String target, boolean strict) {
    for (int i = entries.length - 1; i >= 0; i--) {
        MenuEntry entry = entries[i];
        String entryOption = Text.removeTags(entry.getOption()).toLowerCase();
        String entryTarget = Text.removeTags(entry.getTarget()).toLowerCase();
        if (strict) {
            if (entryOption.equals(option) && entryTarget.equals(target)) {
                return i;
            }
        } else {
            if (entryOption.contains(option.toLowerCase()) && entryTarget.equals(target)) {
                return i;
            }
        }
    }
    return -1;
}
Also used : MenuEntry(net.runelite.api.MenuEntry)

Aggregations

MenuEntry (net.runelite.api.MenuEntry)10 Subscribe (com.google.common.eventbus.Subscribe)3 LocalPoint (net.runelite.api.coords.LocalPoint)3 Color (java.awt.Color)2 Client (net.runelite.api.Client)2 Point (net.runelite.api.Point)2 Inject (net.runelite.api.mixins.Inject)2 Tooltip (net.runelite.client.ui.overlay.tooltip.Tooltip)2 ClanMemberRank (net.runelite.api.ClanMemberRank)1 Item (net.runelite.api.Item)1 ItemComposition (net.runelite.api.ItemComposition)1 ItemLayer (net.runelite.api.ItemLayer)1 MenuAction (net.runelite.api.MenuAction)1 Node (net.runelite.api.Node)1 Player (net.runelite.api.Player)1 Region (net.runelite.api.Region)1 Tile (net.runelite.api.Tile)1 Varcs (net.runelite.api.Varcs)1 Widget (net.runelite.api.widgets.Widget)1 ItemPrice (net.runelite.http.api.item.ItemPrice)1