openrune: MenuOpcode -> MenuAction
This commit is contained in:
@@ -30,7 +30,7 @@ import java.util.Map;
|
|||||||
/**
|
/**
|
||||||
* An enumeration of right-click menu actions.
|
* An enumeration of right-click menu actions.
|
||||||
*/
|
*/
|
||||||
public enum MenuOpcode
|
public enum MenuAction
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Menu action for using an item in your inventory on a tile object (GameObject or GroundObject).
|
* Menu action for using an item in your inventory on a tile object (GameObject or GroundObject).
|
||||||
@@ -299,19 +299,19 @@ public enum MenuOpcode
|
|||||||
|
|
||||||
public static final int MENU_ACTION_DEPRIORITIZE_OFFSET = 2000;
|
public static final int MENU_ACTION_DEPRIORITIZE_OFFSET = 2000;
|
||||||
|
|
||||||
private static final Map<Integer, MenuOpcode> map = new HashMap<>();
|
private static final Map<Integer, MenuAction> map = new HashMap<>();
|
||||||
|
|
||||||
static
|
static
|
||||||
{
|
{
|
||||||
for (MenuOpcode menuOpcode : values())
|
for (MenuAction menuAction : values())
|
||||||
{
|
{
|
||||||
map.put(menuOpcode.getId(), menuOpcode);
|
map.put(menuAction.getId(), menuAction);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private final int id;
|
private final int id;
|
||||||
|
|
||||||
MenuOpcode(int id)
|
MenuAction(int id)
|
||||||
{
|
{
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
@@ -321,7 +321,7 @@ public enum MenuOpcode
|
|||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MenuOpcode of(int id)
|
public static MenuAction of(int id)
|
||||||
{
|
{
|
||||||
return map.getOrDefault(id, UNKNOWN);
|
return map.getOrDefault(id, UNKNOWN);
|
||||||
}
|
}
|
||||||
@@ -51,7 +51,7 @@ public class MenuEntry implements Cloneable
|
|||||||
private int identifier;
|
private int identifier;
|
||||||
/**
|
/**
|
||||||
* The action the entry will trigger.
|
* The action the entry will trigger.
|
||||||
* {@link net.runelite.api.MenuOpcode}
|
* {@link MenuAction}
|
||||||
*/
|
*/
|
||||||
private int opcode;
|
private int opcode;
|
||||||
/**
|
/**
|
||||||
@@ -97,8 +97,8 @@ public class MenuEntry implements Cloneable
|
|||||||
/**
|
/**
|
||||||
* Get opcode, but as it's enum counterpart
|
* Get opcode, but as it's enum counterpart
|
||||||
*/
|
*/
|
||||||
public MenuOpcode getMenuOpcode()
|
public MenuAction getMenuOpcode()
|
||||||
{
|
{
|
||||||
return MenuOpcode.of(getOpcode());
|
return MenuAction.of(getOpcode());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,8 +41,8 @@ public interface NPCDefinition
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The 5 menuops this NPC has when in world. Index 0 corresponds to
|
* The 5 menuops this NPC has when in world. Index 0 corresponds to
|
||||||
* {@link MenuOpcode#NPC_FIRST_OPTION}, Index 2 to
|
* {@link MenuAction#NPC_FIRST_OPTION}, Index 2 to
|
||||||
* {@link MenuOpcode#NPC_SECOND_OPTION} and so on.
|
* {@link MenuAction#NPC_SECOND_OPTION} and so on.
|
||||||
*/
|
*/
|
||||||
String[] getActions();
|
String[] getActions();
|
||||||
|
|
||||||
|
|||||||
@@ -53,15 +53,15 @@ import net.runelite.api.IntegerNode;
|
|||||||
import net.runelite.api.InventoryID;
|
import net.runelite.api.InventoryID;
|
||||||
import net.runelite.api.ItemDefinition;
|
import net.runelite.api.ItemDefinition;
|
||||||
import net.runelite.api.MenuEntry;
|
import net.runelite.api.MenuEntry;
|
||||||
import net.runelite.api.MenuOpcode;
|
import net.runelite.api.MenuAction;
|
||||||
import static net.runelite.api.MenuOpcode.PLAYER_EIGTH_OPTION;
|
import static net.runelite.api.MenuAction.PLAYER_EIGTH_OPTION;
|
||||||
import static net.runelite.api.MenuOpcode.PLAYER_FIFTH_OPTION;
|
import static net.runelite.api.MenuAction.PLAYER_FIFTH_OPTION;
|
||||||
import static net.runelite.api.MenuOpcode.PLAYER_FIRST_OPTION;
|
import static net.runelite.api.MenuAction.PLAYER_FIRST_OPTION;
|
||||||
import static net.runelite.api.MenuOpcode.PLAYER_FOURTH_OPTION;
|
import static net.runelite.api.MenuAction.PLAYER_FOURTH_OPTION;
|
||||||
import static net.runelite.api.MenuOpcode.PLAYER_SECOND_OPTION;
|
import static net.runelite.api.MenuAction.PLAYER_SECOND_OPTION;
|
||||||
import static net.runelite.api.MenuOpcode.PLAYER_SEVENTH_OPTION;
|
import static net.runelite.api.MenuAction.PLAYER_SEVENTH_OPTION;
|
||||||
import static net.runelite.api.MenuOpcode.PLAYER_SIXTH_OPTION;
|
import static net.runelite.api.MenuAction.PLAYER_SIXTH_OPTION;
|
||||||
import static net.runelite.api.MenuOpcode.PLAYER_THIRD_OPTION;
|
import static net.runelite.api.MenuAction.PLAYER_THIRD_OPTION;
|
||||||
import net.runelite.api.MessageNode;
|
import net.runelite.api.MessageNode;
|
||||||
import net.runelite.api.NPC;
|
import net.runelite.api.NPC;
|
||||||
import net.runelite.api.NPCDefinition;
|
import net.runelite.api.NPCDefinition;
|
||||||
@@ -1059,11 +1059,11 @@ public abstract class RSClientMixin implements RSClient
|
|||||||
public static void playerOptionsChanged(int idx)
|
public static void playerOptionsChanged(int idx)
|
||||||
{
|
{
|
||||||
// Reset the menu opcode
|
// Reset the menu opcode
|
||||||
MenuOpcode[] playerActions = {PLAYER_FIRST_OPTION, PLAYER_SECOND_OPTION, PLAYER_THIRD_OPTION, PLAYER_FOURTH_OPTION,
|
MenuAction[] playerActions = {PLAYER_FIRST_OPTION, PLAYER_SECOND_OPTION, PLAYER_THIRD_OPTION, PLAYER_FOURTH_OPTION,
|
||||||
PLAYER_FIFTH_OPTION, PLAYER_SIXTH_OPTION, PLAYER_SEVENTH_OPTION, PLAYER_EIGTH_OPTION};
|
PLAYER_FIFTH_OPTION, PLAYER_SIXTH_OPTION, PLAYER_SEVENTH_OPTION, PLAYER_EIGTH_OPTION};
|
||||||
if (idx >= 0 && idx < playerActions.length)
|
if (idx >= 0 && idx < playerActions.length)
|
||||||
{
|
{
|
||||||
MenuOpcode playerAction = playerActions[idx];
|
MenuAction playerAction = playerActions[idx];
|
||||||
client.getPlayerMenuTypes()[idx] = playerAction.getId();
|
client.getPlayerMenuTypes()[idx] = playerAction.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1720,7 +1720,7 @@ public abstract class RSClientMixin implements RSClient
|
|||||||
if (len > 0)
|
if (len > 0)
|
||||||
{
|
{
|
||||||
int type = getMenuOpcodes()[len - 1];
|
int type = getMenuOpcodes()[len - 1];
|
||||||
return type == MenuOpcode.RUNELITE_OVERLAY.getId();
|
return type == MenuAction.RUNELITE_OVERLAY.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package net.runelite.mixins;
|
package net.runelite.mixins;
|
||||||
|
|
||||||
import net.runelite.api.MenuOpcode;
|
import net.runelite.api.MenuAction;
|
||||||
import net.runelite.api.World;
|
import net.runelite.api.World;
|
||||||
import net.runelite.api.widgets.WidgetInfo;
|
import net.runelite.api.widgets.WidgetInfo;
|
||||||
import net.runelite.api.mixins.Inject;
|
import net.runelite.api.mixins.Inject;
|
||||||
@@ -15,7 +15,7 @@ public abstract class WorldHoppingMixin implements RSClient
|
|||||||
public void openWorldHopper()
|
public void openWorldHopper()
|
||||||
{
|
{
|
||||||
// The clicked x & y coordinates (the last arguments) are not processed in the game or sent to Jagex, so they don't have to be real.
|
// The clicked x & y coordinates (the last arguments) are not processed in the game or sent to Jagex, so they don't have to be real.
|
||||||
invokeMenuAction("World Switcher", "", 1, MenuOpcode.CC_OP.getId(), -1, WidgetInfo.WORLD_SWITCHER_BUTTON.getId());
|
invokeMenuAction("World Switcher", "", 1, MenuAction.CC_OP.getId(), -1, WidgetInfo.WORLD_SWITCHER_BUTTON.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@@ -23,6 +23,6 @@ public abstract class WorldHoppingMixin implements RSClient
|
|||||||
public void hopToWorld(World world)
|
public void hopToWorld(World world)
|
||||||
{
|
{
|
||||||
final int worldId = world.getId();
|
final int worldId = world.getId();
|
||||||
invokeMenuAction("Switch", "<col=ff9040>" + (worldId - 300) + "</col>", 1, MenuOpcode.CC_OP.getId(), worldId, WidgetInfo.WORLD_SWITCHER_LIST.getId());
|
invokeMenuAction("Switch", "<col=ff9040>" + (worldId - 300) + "</col>", 1, MenuAction.CC_OP.getId(), worldId, WidgetInfo.WORLD_SWITCHER_LIST.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user