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;
|
package net.runelite.api;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public enum MenuAction
|
public enum MenuAction
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@@ -263,6 +266,16 @@ public enum MenuAction
|
|||||||
*/
|
*/
|
||||||
UNKNOWN(-1);
|
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;
|
private final int id;
|
||||||
|
|
||||||
MenuAction(int id)
|
MenuAction(int id)
|
||||||
@@ -277,13 +290,6 @@ public enum MenuAction
|
|||||||
|
|
||||||
public static MenuAction of(int id)
|
public static MenuAction of(int id)
|
||||||
{
|
{
|
||||||
for (MenuAction action : values())
|
return map.getOrDefault(id, UNKNOWN);
|
||||||
{
|
|
||||||
if (action.id == id)
|
|
||||||
{
|
|
||||||
return action;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return UNKNOWN;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,12 +24,15 @@
|
|||||||
*/
|
*/
|
||||||
package net.runelite.api;
|
package net.runelite.api;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
public class MenuEntry
|
public class MenuEntry
|
||||||
{
|
{
|
||||||
private String option;
|
private String option;
|
||||||
private String target;
|
private String target;
|
||||||
private int identifier;
|
private int identifier;
|
||||||
private MenuAction type;
|
private int type;
|
||||||
private int param0;
|
private int param0;
|
||||||
private int param1;
|
private int param1;
|
||||||
|
|
||||||
@@ -39,64 +42,4 @@ public class MenuEntry
|
|||||||
return "MenuEntry{" + "option=" + option + ", target=" + target + ", identifier=" + identifier + ", type=" + type + ", param0=" + param0 + ", param1=" + param1 + '}';
|
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.setOption(currentMenu.getMenuOption());
|
||||||
menuEntry.setParam1(widgetId);
|
menuEntry.setParam1(widgetId);
|
||||||
menuEntry.setTarget(currentMenu.getMenuTarget());
|
menuEntry.setTarget(currentMenu.getMenuTarget());
|
||||||
menuEntry.setType(MenuAction.RUNELITE);
|
menuEntry.setType(MenuAction.RUNELITE.getId());
|
||||||
|
|
||||||
client.setMenuEntries(menuEntries);
|
client.setMenuEntries(menuEntries);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ class ItemPricesOverlay extends Overlay
|
|||||||
}
|
}
|
||||||
|
|
||||||
final MenuEntry menuEntry = menuEntries[last];
|
final MenuEntry menuEntry = menuEntries[last];
|
||||||
final MenuAction action = menuEntry.getType();
|
final MenuAction action = MenuAction.of(menuEntry.getType());
|
||||||
final int widgetId = menuEntry.getParam1();
|
final int widgetId = menuEntry.getParam1();
|
||||||
final int groupId = WidgetInfo.TO_GROUP(widgetId);
|
final int groupId = WidgetInfo.TO_GROUP(widgetId);
|
||||||
|
|
||||||
|
|||||||
@@ -327,7 +327,7 @@ public abstract class RSClientMixin implements RSClient
|
|||||||
entry.setOption(menuOptions[i]);
|
entry.setOption(menuOptions[i]);
|
||||||
entry.setTarget(menuTargets[i]);
|
entry.setTarget(menuTargets[i]);
|
||||||
entry.setIdentifier(menuIdentifiers[i]);
|
entry.setIdentifier(menuIdentifiers[i]);
|
||||||
entry.setType(MenuAction.of(menuTypes[i]));
|
entry.setType(menuTypes[i]);
|
||||||
entry.setParam0(params0[i]);
|
entry.setParam0(params0[i]);
|
||||||
entry.setParam1(params1[i]);
|
entry.setParam1(params1[i]);
|
||||||
}
|
}
|
||||||
@@ -351,7 +351,7 @@ public abstract class RSClientMixin implements RSClient
|
|||||||
menuOptions[count] = entry.getOption();
|
menuOptions[count] = entry.getOption();
|
||||||
menuTargets[count] = entry.getTarget();
|
menuTargets[count] = entry.getTarget();
|
||||||
menuIdentifiers[count] = entry.getIdentifier();
|
menuIdentifiers[count] = entry.getIdentifier();
|
||||||
menuTypes[count] = entry.getType().getId();
|
menuTypes[count] = entry.getType();
|
||||||
params0[count] = entry.getParam0();
|
params0[count] = entry.getParam0();
|
||||||
params1[count] = entry.getParam1();
|
params1[count] = entry.getParam1();
|
||||||
++count;
|
++count;
|
||||||
|
|||||||
Reference in New Issue
Block a user