Merge pull request #3094 from open-osrs/menu-entry
This commit is contained in:
@@ -38,12 +38,13 @@ public class RuneliteMenuEntry extends AbstractInjector
|
||||
|
||||
public void inject()
|
||||
{
|
||||
addInvoke();
|
||||
addInvoke("newRuneliteMenuEntry", true);
|
||||
addInvoke("newBareRuneliteMenuEntry", false);
|
||||
addSwap(InjectUtil.findMethod(inject, "incrementMenuEntries"));
|
||||
addSwap(InjectUtil.findMethod(inject, "decrementMenuEntries"));
|
||||
}
|
||||
|
||||
private void addInvoke()
|
||||
private void addInvoke(String methodName, boolean iload)
|
||||
{
|
||||
ClassFile runeliteMenuEntryVanilla = inject.vanilla.findClass(RUNELITE_MENU_ENTRY);
|
||||
|
||||
@@ -52,8 +53,7 @@ public class RuneliteMenuEntry extends AbstractInjector
|
||||
.findClass("Client")
|
||||
);
|
||||
|
||||
Method copy = clientVanilla.findMethod("newRuneliteMenuEntry");
|
||||
copy.setPublic();
|
||||
Method copy = clientVanilla.findMethod(methodName);
|
||||
|
||||
final Code code = new Code(copy);
|
||||
code.setMaxStack(3);
|
||||
@@ -64,8 +64,15 @@ public class RuneliteMenuEntry extends AbstractInjector
|
||||
|
||||
ins.add(new New(instructions, runeliteMenuEntryVanilla.getPoolClass()));
|
||||
ins.add(new Dup(instructions));
|
||||
ins.add(new ILoad(instructions, 0));
|
||||
ins.add(new InvokeSpecial(instructions, new net.runelite.asm.pool.Method(runeliteMenuEntryVanilla.getPoolClass(), "<init>", new Signature("(I)V"))));
|
||||
if (iload)
|
||||
{
|
||||
ins.add(new ILoad(instructions, 0));
|
||||
ins.add(new InvokeSpecial(instructions, new net.runelite.asm.pool.Method(runeliteMenuEntryVanilla.getPoolClass(), "<init>", new Signature("(I)V"))));
|
||||
}
|
||||
else
|
||||
{
|
||||
ins.add(new InvokeSpecial(instructions, new net.runelite.asm.pool.Method(runeliteMenuEntryVanilla.getPoolClass(), "<init>", new Signature("()V"))));
|
||||
}
|
||||
ins.add(new Return(instructions, InstructionType.ARETURN));
|
||||
}
|
||||
|
||||
|
||||
@@ -643,6 +643,12 @@ public interface Client extends GameEngine
|
||||
*/
|
||||
MenuEntry createMenuEntry(int idx);
|
||||
|
||||
/**
|
||||
* Create a new menu entry
|
||||
* @return the newly created menu entry
|
||||
*/
|
||||
MenuEntry createMenuEntry(String option, String target, int identifier, int opcode, int param1, int param2, boolean forceLeftClick);
|
||||
|
||||
/**
|
||||
* Gets an array of currently open right-click menu entries that can be
|
||||
* clicked and activated.
|
||||
|
||||
@@ -168,6 +168,7 @@ import net.runelite.rs.api.RSWidget;
|
||||
import net.runelite.rs.api.RSWorld;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
|
||||
|
||||
@Mixin(RSClient.class)
|
||||
public abstract class RSClientMixin implements RSClient
|
||||
@@ -796,10 +797,34 @@ public abstract class RSClientMixin implements RSClient
|
||||
setChatCycle(getCycleCntr());
|
||||
}
|
||||
|
||||
@Inject
|
||||
public static RSRuneLiteMenuEntry newBareRuneliteMenuEntry()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@Inject
|
||||
public static RSRuneLiteMenuEntry newRuneliteMenuEntry(int idx)
|
||||
{
|
||||
return null;
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@Inject
|
||||
@Override
|
||||
public MenuEntry createMenuEntry(String option, String target, int identifier, int opcode, int param1, int param2, boolean forceLeftClick)
|
||||
{
|
||||
RSRuneLiteMenuEntry menuEntry = newBareRuneliteMenuEntry();
|
||||
|
||||
menuEntry.setOption(option);
|
||||
menuEntry.setTarget(target);
|
||||
menuEntry.setIdentifier(identifier);
|
||||
menuEntry.setType(MenuAction.of(opcode));
|
||||
menuEntry.setParam0(param1);
|
||||
menuEntry.setParam1(param2);
|
||||
menuEntry.setConsumer(null);
|
||||
menuEntry.setForceLeftClick(forceLeftClick);
|
||||
|
||||
return menuEntry;
|
||||
}
|
||||
|
||||
@Inject
|
||||
|
||||
@@ -7,6 +7,10 @@ public class RuneLiteMenuEntry implements MenuEntry
|
||||
public Consumer consumer;
|
||||
public int idx;
|
||||
|
||||
public RuneLiteMenuEntry()
|
||||
{
|
||||
}
|
||||
|
||||
public RuneLiteMenuEntry(int idx)
|
||||
{
|
||||
this.idx = idx;
|
||||
|
||||
Reference in New Issue
Block a user