Search in sources :

Example 1 with MenuAction

use of net.runelite.api.MenuAction 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 2 with MenuAction

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

the class RSClientMixin method playerOptionsChanged.

@FieldHook("playerOptions")
@Inject
public static void playerOptionsChanged(int idx) {
    // Reset the menu type
    MenuAction[] playerActions = { PLAYER_FIRST_OPTION, PLAYER_SECOND_OPTION, PLAYER_THIRD_OPTION, PLAYER_FOURTH_OPTION, PLAYER_FIFTH_OPTION, PLAYER_SIXTH_OPTION, PLAYER_SEVENTH_OPTION, PLAYER_EIGTH_OPTION };
    if (idx >= 0 && idx < playerActions.length) {
        MenuAction playerAction = playerActions[idx];
        client.getPlayerMenuTypes()[idx] = playerAction.getId();
    }
    PlayerMenuOptionsChanged optionsChanged = new PlayerMenuOptionsChanged();
    optionsChanged.setIndex(idx);
    eventBus.post(optionsChanged);
}
Also used : MenuAction(net.runelite.api.MenuAction) PlayerMenuOptionsChanged(net.runelite.api.events.PlayerMenuOptionsChanged) Inject(net.runelite.api.mixins.Inject) FieldHook(net.runelite.api.mixins.FieldHook)

Aggregations

MenuAction (net.runelite.api.MenuAction)2 MenuEntry (net.runelite.api.MenuEntry)1 PlayerMenuOptionsChanged (net.runelite.api.events.PlayerMenuOptionsChanged)1 FieldHook (net.runelite.api.mixins.FieldHook)1 Inject (net.runelite.api.mixins.Inject)1 Tooltip (net.runelite.client.ui.overlay.tooltip.Tooltip)1