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);
}
}
}
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;
}
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;
}
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;
}
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;
}
Aggregations