Rework MenuManager to only swap the top entry, once per client tick (#749)

* Rework MenuManager to only swap the top entry, once per client tick
This commit is contained in:
Lucwousin
2019-06-25 18:20:21 +02:00
committed by Kyleeld
parent d084c0578e
commit 6630f5b4dd
39 changed files with 425 additions and 354 deletions

View File

@@ -1669,4 +1669,10 @@ public interface Client extends GameShell
String getSelectedSpellName();
boolean getIsSpellSelected();
/**
* Sorts the current menu entries in the same way the client does this.
* The last entry will be the left click one after this.
*/
void sortMenuEntries();
}

View File

@@ -26,6 +26,7 @@ package net.runelite.api.events;
import lombok.Data;
import net.runelite.api.MenuAction;
import net.runelite.api.MenuEntry;
/**
* An event where a menu option has been clicked.
@@ -42,31 +43,71 @@ import net.runelite.api.MenuAction;
public class MenuOptionClicked
{
/**
* The action parameter used in the click.
* The actual MenuEntry object representing what was clicked
*/
private int actionParam;
private final MenuEntry menuEntry;
/**
* The option text added to the menu.
*/
private String menuOption;
public String getOption()
{
return menuEntry.getOption();
}
/**
* The target of the action.
*/
private String menuTarget;
public String getTarget()
{
return menuEntry.getTarget();
}
/**
* The action performed.
* MenuAction but int-ish
*/
private MenuAction menuAction;
public int getType()
{
return menuEntry.getType();
}
/**
* The ID of the object, actor, or item that the interaction targets.
*/
private int id;
public int getIdentifier()
{
return menuEntry.getIdentifier();
}
/**
* The ID of the widget where the menu was clicked.
*
* @see net.runelite.api.WidgetID
* The action parameter used in the click.
*/
private int widgetId;
public int getActionParam0()
{
return menuEntry.getParam0();
}
/**
* shit docs
*/
public int getActionParam1()
{
return menuEntry.getParam1();
}
public boolean isForceLeftClick()
{
return menuEntry.isForceLeftClick();
}
/**
* The action performed.
*/
public MenuAction getMenuAction()
{
return MenuAction.of(getType());
}
/**
* Whether or not the event has been consumed by a subscriber.
*/