Change MenuEntry type to int
We don't have all of the types in MenuAction and it causes them to get mapped to UNKNOWN when translated back and forth with the API
This commit is contained in:
@@ -24,6 +24,9 @@
|
||||
*/
|
||||
package net.runelite.api;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public enum MenuAction
|
||||
{
|
||||
/**
|
||||
@@ -257,12 +260,22 @@ public enum MenuAction
|
||||
|
||||
FOLLOW(2046),
|
||||
TRADE(2047),
|
||||
|
||||
|
||||
/**
|
||||
* Menu action triggered when the id is not defined in this class.
|
||||
*/
|
||||
UNKNOWN(-1);
|
||||
|
||||
private static final Map<Integer, MenuAction> map = new HashMap<>();
|
||||
|
||||
static
|
||||
{
|
||||
for (MenuAction menuAction : values())
|
||||
{
|
||||
map.put(menuAction.getId(), menuAction);
|
||||
}
|
||||
}
|
||||
|
||||
private final int id;
|
||||
|
||||
MenuAction(int id)
|
||||
@@ -277,13 +290,6 @@ public enum MenuAction
|
||||
|
||||
public static MenuAction of(int id)
|
||||
{
|
||||
for (MenuAction action : values())
|
||||
{
|
||||
if (action.id == id)
|
||||
{
|
||||
return action;
|
||||
}
|
||||
}
|
||||
return UNKNOWN;
|
||||
return map.getOrDefault(id, UNKNOWN);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,12 +24,15 @@
|
||||
*/
|
||||
package net.runelite.api;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class MenuEntry
|
||||
{
|
||||
private String option;
|
||||
private String target;
|
||||
private int identifier;
|
||||
private MenuAction type;
|
||||
private int type;
|
||||
private int param0;
|
||||
private int param1;
|
||||
|
||||
@@ -39,64 +42,4 @@ public class MenuEntry
|
||||
return "MenuEntry{" + "option=" + option + ", target=" + target + ", identifier=" + identifier + ", type=" + type + ", param0=" + param0 + ", param1=" + param1 + '}';
|
||||
}
|
||||
|
||||
public String getOption()
|
||||
{
|
||||
return option;
|
||||
}
|
||||
|
||||
public void setOption(String option)
|
||||
{
|
||||
this.option = option;
|
||||
}
|
||||
|
||||
public String getTarget()
|
||||
{
|
||||
return target;
|
||||
}
|
||||
|
||||
public void setTarget(String target)
|
||||
{
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
public int getIdentifier()
|
||||
{
|
||||
return identifier;
|
||||
}
|
||||
|
||||
public void setIdentifier(int identifier)
|
||||
{
|
||||
this.identifier = identifier;
|
||||
}
|
||||
|
||||
public MenuAction getType()
|
||||
{
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(MenuAction type)
|
||||
{
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public int getParam0()
|
||||
{
|
||||
return param0;
|
||||
}
|
||||
|
||||
public void setParam0(int param0)
|
||||
{
|
||||
this.param0 = param0;
|
||||
}
|
||||
|
||||
public int getParam1()
|
||||
{
|
||||
return param1;
|
||||
}
|
||||
|
||||
public void setParam1(int param1)
|
||||
{
|
||||
this.param1 = param1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -183,7 +183,7 @@ public class MenuManager
|
||||
menuEntry.setOption(currentMenu.getMenuOption());
|
||||
menuEntry.setParam1(widgetId);
|
||||
menuEntry.setTarget(currentMenu.getMenuTarget());
|
||||
menuEntry.setType(MenuAction.RUNELITE);
|
||||
menuEntry.setType(MenuAction.RUNELITE.getId());
|
||||
|
||||
client.setMenuEntries(menuEntries);
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ class ItemPricesOverlay extends Overlay
|
||||
}
|
||||
|
||||
final MenuEntry menuEntry = menuEntries[last];
|
||||
final MenuAction action = menuEntry.getType();
|
||||
final MenuAction action = MenuAction.of(menuEntry.getType());
|
||||
final int widgetId = menuEntry.getParam1();
|
||||
final int groupId = WidgetInfo.TO_GROUP(widgetId);
|
||||
|
||||
|
||||
@@ -327,7 +327,7 @@ public abstract class RSClientMixin implements RSClient
|
||||
entry.setOption(menuOptions[i]);
|
||||
entry.setTarget(menuTargets[i]);
|
||||
entry.setIdentifier(menuIdentifiers[i]);
|
||||
entry.setType(MenuAction.of(menuTypes[i]));
|
||||
entry.setType(menuTypes[i]);
|
||||
entry.setParam0(params0[i]);
|
||||
entry.setParam1(params1[i]);
|
||||
}
|
||||
@@ -351,7 +351,7 @@ public abstract class RSClientMixin implements RSClient
|
||||
menuOptions[count] = entry.getOption();
|
||||
menuTargets[count] = entry.getTarget();
|
||||
menuIdentifiers[count] = entry.getIdentifier();
|
||||
menuTypes[count] = entry.getType().getId();
|
||||
menuTypes[count] = entry.getType();
|
||||
params0[count] = entry.getParam0();
|
||||
params1[count] = entry.getParam1();
|
||||
++count;
|
||||
|
||||
Reference in New Issue
Block a user