use of net.runelite.api.Varcs 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;
}