mouse highlight: fix interface tooltips option
Use the menu type instead of assuming if the param1 is a valid widget then the menu is for a widget. The params are free form data which is specific to the menu type, so it is possible for it to unintentionally be a valid widget id even when it is something else.
This commit is contained in:
@@ -25,14 +25,15 @@
|
||||
package net.runelite.client.plugins.mousehighlight;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics2D;
|
||||
import java.util.Set;
|
||||
import javax.inject.Inject;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.MenuAction;
|
||||
import net.runelite.api.MenuEntry;
|
||||
import net.runelite.api.VarClientInt;
|
||||
import net.runelite.api.widgets.Widget;
|
||||
import net.runelite.api.widgets.WidgetID;
|
||||
import net.runelite.api.widgets.WidgetInfo;
|
||||
import net.runelite.client.ui.overlay.Overlay;
|
||||
@@ -42,6 +43,35 @@ import net.runelite.client.ui.overlay.tooltip.TooltipManager;
|
||||
|
||||
class MouseHighlightOverlay extends Overlay
|
||||
{
|
||||
/**
|
||||
* Menu types which are on widgets.
|
||||
*/
|
||||
private static final Set<MenuAction> WIDGET_MENU_ACTIONS = ImmutableSet.of(
|
||||
MenuAction.WIDGET_TYPE_1,
|
||||
MenuAction.WIDGET_TYPE_2,
|
||||
MenuAction.WIDGET_TYPE_3,
|
||||
MenuAction.WIDGET_TYPE_4,
|
||||
MenuAction.WIDGET_TYPE_5,
|
||||
MenuAction.WIDGET_TYPE_6,
|
||||
MenuAction.ITEM_USE_ON_WIDGET_ITEM,
|
||||
MenuAction.ITEM_USE_ON_WIDGET,
|
||||
MenuAction.ITEM_FIRST_OPTION,
|
||||
MenuAction.ITEM_SECOND_OPTION,
|
||||
MenuAction.ITEM_THIRD_OPTION,
|
||||
MenuAction.ITEM_FOURTH_OPTION,
|
||||
MenuAction.ITEM_FIFTH_OPTION,
|
||||
MenuAction.ITEM_USE,
|
||||
MenuAction.WIDGET_FIRST_OPTION,
|
||||
MenuAction.WIDGET_SECOND_OPTION,
|
||||
MenuAction.WIDGET_THIRD_OPTION,
|
||||
MenuAction.WIDGET_FOURTH_OPTION,
|
||||
MenuAction.WIDGET_FIFTH_OPTION,
|
||||
MenuAction.EXAMINE_ITEM,
|
||||
MenuAction.SPELL_CAST_ON_WIDGET,
|
||||
MenuAction.CC_OP_LOW_PRIORITY,
|
||||
MenuAction.CC_OP
|
||||
);
|
||||
|
||||
private final TooltipManager tooltipManager;
|
||||
private final Client client;
|
||||
private final MouseHighlightConfig config;
|
||||
@@ -74,9 +104,9 @@ class MouseHighlightOverlay extends Overlay
|
||||
MenuEntry menuEntry = menuEntries[last];
|
||||
String target = menuEntry.getTarget();
|
||||
String option = menuEntry.getOption();
|
||||
int type = menuEntry.getType();
|
||||
MenuAction type = MenuAction.of(menuEntry.getType());
|
||||
|
||||
if (type == MenuAction.RUNELITE_OVERLAY.getId() || type == MenuAction.CC_OP_LOW_PRIORITY.getId())
|
||||
if (type == MenuAction.RUNELITE_OVERLAY || type == MenuAction.CC_OP_LOW_PRIORITY)
|
||||
{
|
||||
// These are always right click only
|
||||
return null;
|
||||
@@ -102,34 +132,32 @@ class MouseHighlightOverlay extends Overlay
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
if (WIDGET_MENU_ACTIONS.contains(type))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
final int widgetId = menuEntry.getParam1();
|
||||
final int groupId = WidgetInfo.TO_GROUP(widgetId);
|
||||
|
||||
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())
|
||||
if (!config.uiTooltip())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!config.chatboxTooltip() && groupId == WidgetInfo.CHATBOX.getGroupId())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (config.disableSpellbooktooltip() && groupId == WidgetID.SPELLBOOK_GROUP_ID)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// If this varc is set, a tooltip will be displayed soon
|
||||
int tooltipTimeout = client.getVar(VarClientInt.TOOLTIP_TIMEOUT);
|
||||
if (tooltipTimeout > client.getGameCycle())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// If this varc is set, a tooltip is already being displayed
|
||||
|
||||
Reference in New Issue
Block a user