Merge pull request #7574 from Abextm/fix-overlay-menus

Force RUNELITE_OVERLAY menuops to not be left click
This commit is contained in:
Adam
2019-01-28 18:00:50 -05:00
committed by GitHub
4 changed files with 46 additions and 1 deletions

View File

@@ -59,5 +59,11 @@ public class MenuEntry
* A second additional parameter for the action. * A second additional parameter for the action.
*/ */
private int param1; private int param1;
/**
* If this field is true and you have single mouse button on and this entry is
* the top entry the right click menu will not be opened when you left click
*
* This is used for shift click
*/
private boolean forceLeftClick;
} }

View File

@@ -29,6 +29,7 @@ import java.awt.Dimension;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import javax.inject.Inject; import javax.inject.Inject;
import net.runelite.api.Client; import net.runelite.api.Client;
import net.runelite.api.MenuAction;
import net.runelite.api.MenuEntry; import net.runelite.api.MenuEntry;
import net.runelite.api.VarClientInt; import net.runelite.api.VarClientInt;
import net.runelite.api.widgets.Widget; import net.runelite.api.widgets.Widget;
@@ -72,6 +73,13 @@ class MouseHighlightOverlay extends Overlay
MenuEntry menuEntry = menuEntries[last]; MenuEntry menuEntry = menuEntries[last];
String target = menuEntry.getTarget(); String target = menuEntry.getTarget();
String option = menuEntry.getOption(); String option = menuEntry.getOption();
int type = menuEntry.getType();
if (type == MenuAction.RUNELITE_OVERLAY.getId() || type == MenuAction.EXAMINE_ITEM_BANK_EQ.getId())
{
// These are always right click only
return null;
}
if (Strings.isNullOrEmpty(option)) if (Strings.isNullOrEmpty(option))
{ {

View File

@@ -546,6 +546,7 @@ public abstract class RSClientMixin implements RSClient
int[] menuTypes = getMenuTypes(); int[] menuTypes = getMenuTypes();
int[] params0 = getMenuActionParams0(); int[] params0 = getMenuActionParams0();
int[] params1 = getMenuActionParams1(); int[] params1 = getMenuActionParams1();
boolean[] leftClick = getMenuForceLeftClick();
MenuEntry[] entries = new MenuEntry[count]; MenuEntry[] entries = new MenuEntry[count];
for (int i = 0; i < count; ++i) for (int i = 0; i < count; ++i)
@@ -557,6 +558,7 @@ public abstract class RSClientMixin implements RSClient
entry.setType(menuTypes[i]); entry.setType(menuTypes[i]);
entry.setParam0(params0[i]); entry.setParam0(params0[i]);
entry.setParam1(params1[i]); entry.setParam1(params1[i]);
entry.setForceLeftClick(leftClick[i]);
} }
return entries; return entries;
} }
@@ -572,6 +574,7 @@ public abstract class RSClientMixin implements RSClient
int[] menuTypes = getMenuTypes(); int[] menuTypes = getMenuTypes();
int[] params0 = getMenuActionParams0(); int[] params0 = getMenuActionParams0();
int[] params1 = getMenuActionParams1(); int[] params1 = getMenuActionParams1();
boolean[] leftClick = getMenuForceLeftClick();
for (MenuEntry entry : entries) for (MenuEntry entry : entries)
{ {
@@ -581,6 +584,7 @@ public abstract class RSClientMixin implements RSClient
menuTypes[count] = entry.getType(); menuTypes[count] = entry.getType();
params0[count] = entry.getParam0(); params0[count] = entry.getParam0();
params1[count] = entry.getParam1(); params1[count] = entry.getParam1();
leftClick[count] = entry.isForceLeftClick();
++count; ++count;
} }
@@ -1406,4 +1410,28 @@ public abstract class RSClientMixin implements RSClient
{ {
client.getCallbacks().post(new ClientTick()); client.getCallbacks().post(new ClientTick());
} }
@Copy("shouldLeftClickOpenMenu")
boolean rs$shouldLeftClickOpenMenu()
{
throw new RuntimeException();
}
@Replace("shouldLeftClickOpenMenu")
boolean rl$shouldLeftClickOpenMenu()
{
if (rs$shouldLeftClickOpenMenu())
{
return true;
}
int len = getMenuOptionCount();
if (len > 0)
{
int type = getMenuTypes()[len - 1];
return type == MenuAction.RUNELITE_OVERLAY.getId();
}
return false;
}
} }

View File

@@ -307,6 +307,9 @@ public interface RSClient extends RSGameEngine, Client
@Import("menuActionParams1") @Import("menuActionParams1")
int[] getMenuActionParams1(); int[] getMenuActionParams1();
@Import("menuForceLeftClick")
boolean[] getMenuForceLeftClick();
@Import("worldList") @Import("worldList")
@Override @Override
RSWorld[] getWorldList(); RSWorld[] getWorldList();