project: Implement the new menu entry handling
This commit is contained in:
@@ -27,6 +27,8 @@ group = "com.openosrs.rs"
|
||||
description = "RuneScape Client"
|
||||
|
||||
dependencies {
|
||||
api(project(":runelite-api"))
|
||||
|
||||
implementation(project(":injection-annotations"))
|
||||
implementation(group = "org.bouncycastle", name = "bcprov-jdk15on", version = "1.52")
|
||||
|
||||
|
||||
@@ -161,7 +161,7 @@ public class ChatChannel {
|
||||
Client.meslayerContinueWidget = null;
|
||||
}
|
||||
|
||||
FileSystem.method3084();
|
||||
FileSystem.decrementMenuEntries();
|
||||
class115.revalidateWidgetScroll(MouseRecorder.Widget_interfaceComponents[var0 >> 16], var4, false);
|
||||
class33.runWidgetOnLoadListener(var1);
|
||||
if (Client.rootInterface != -1) {
|
||||
|
||||
@@ -6401,7 +6401,7 @@ public final class Client extends GameEngine implements Usernamed, OAuthTokens {
|
||||
)
|
||||
@Export("menu")
|
||||
final void menu() {
|
||||
Message.method1115();
|
||||
Message.incrementMenuEntries();
|
||||
if (class143.dragInventoryWidget == null) {
|
||||
if (clickedWidget == null) {
|
||||
int var1 = MouseHandler.MouseHandler_lastButton;
|
||||
|
||||
@@ -30,7 +30,8 @@ public class FileSystem {
|
||||
descriptor = "(I)V",
|
||||
garbageValue = "497428397"
|
||||
)
|
||||
static void method3084() {
|
||||
@Export("decrementMenuEntries")
|
||||
static void decrementMenuEntries() {
|
||||
for (int var0 = 0; var0 < Client.menuOptionsCount; ++var0) {
|
||||
if (InvDefinition.method3157(Client.menuOpcodes[var0])) {
|
||||
if (var0 < Client.menuOptionsCount - 1) {
|
||||
|
||||
@@ -166,7 +166,8 @@ public class Message extends DualNode {
|
||||
descriptor = "(I)V",
|
||||
garbageValue = "1989735073"
|
||||
)
|
||||
static final void method1115() {
|
||||
@Export("incrementMenuEntries")
|
||||
static final void incrementMenuEntries() {
|
||||
boolean var0 = false;
|
||||
|
||||
while (!var0) {
|
||||
|
||||
285
runescape-client/src/main/java/RuneLiteMenuEntry.java
Normal file
285
runescape-client/src/main/java/RuneLiteMenuEntry.java
Normal file
@@ -0,0 +1,285 @@
|
||||
import java.util.function.Consumer;
|
||||
import net.runelite.api.MenuAction;
|
||||
import net.runelite.api.MenuEntry;
|
||||
|
||||
public class RuneLiteMenuEntry implements MenuEntry
|
||||
{
|
||||
public Consumer consumer;
|
||||
public int idx;
|
||||
|
||||
public RuneLiteMenuEntry(int idx)
|
||||
{
|
||||
this.idx = idx;
|
||||
}
|
||||
|
||||
public Consumer getConsumer()
|
||||
{
|
||||
return consumer;
|
||||
}
|
||||
|
||||
public void setConsumer(Consumer consumer)
|
||||
{
|
||||
this.consumer = consumer;
|
||||
}
|
||||
|
||||
public int getIdx()
|
||||
{
|
||||
return idx;
|
||||
}
|
||||
|
||||
public void setIdx(int idx)
|
||||
{
|
||||
this.idx = idx;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOption()
|
||||
{
|
||||
return Client.menuActions[this.idx];
|
||||
}
|
||||
|
||||
@Override
|
||||
public MenuEntry setOption(String option)
|
||||
{
|
||||
Client.menuActions[this.idx] = option;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTarget()
|
||||
{
|
||||
return Client.menuTargets[this.idx];
|
||||
}
|
||||
|
||||
@Override
|
||||
public MenuEntry setTarget(String target)
|
||||
{
|
||||
Client.menuTargets[this.idx] = target;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MenuAction getType()
|
||||
{
|
||||
int opcode = Client.menuOpcodes[this.idx];
|
||||
if (opcode >= 2000)
|
||||
{
|
||||
opcode -= 2000;
|
||||
}
|
||||
|
||||
return MenuAction.of(opcode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MenuEntry setType(MenuAction menuAction)
|
||||
{
|
||||
int opcode = Client.menuOpcodes[this.idx];
|
||||
short mod = 0;
|
||||
if (opcode >= 2000)
|
||||
{
|
||||
mod = 2000;
|
||||
}
|
||||
|
||||
Client.menuOpcodes[this.idx] = menuAction.getId() + mod;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIdentifier()
|
||||
{
|
||||
return Client.menuIdentifiers[this.idx];
|
||||
}
|
||||
|
||||
@Override
|
||||
public MenuEntry setIdentifier(int identifier)
|
||||
{
|
||||
Client.menuIdentifiers[this.idx] = identifier;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getParam0()
|
||||
{
|
||||
return Client.menuArguments1[this.idx];
|
||||
}
|
||||
|
||||
@Override
|
||||
public MenuEntry setParam0(int param0)
|
||||
{
|
||||
Client.menuArguments1[this.idx] = param0;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getParam1()
|
||||
{
|
||||
return Client.menuArguments2[this.idx];
|
||||
}
|
||||
|
||||
@Override
|
||||
public MenuEntry setParam1(int param1)
|
||||
{
|
||||
Client.menuArguments2[this.idx] = param1;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDeprioritized()
|
||||
{
|
||||
return Client.menuOpcodes[this.idx] >= 2000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MenuEntry setDeprioritized(boolean deprioritize)
|
||||
{
|
||||
int[] opcodes;
|
||||
|
||||
if (deprioritize)
|
||||
{
|
||||
if (Client.menuOpcodes[this.idx] < 2000)
|
||||
{
|
||||
opcodes = Client.menuOpcodes;
|
||||
opcodes[this.idx] += 2000;
|
||||
}
|
||||
}
|
||||
else if (Client.menuOpcodes[this.idx] >= 2000)
|
||||
{
|
||||
opcodes = Client.menuOpcodes;
|
||||
opcodes[this.idx] -= 2000;
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isForceLeftClick()
|
||||
{
|
||||
return Client.menuShiftClick[this.idx];
|
||||
}
|
||||
|
||||
@Override
|
||||
public MenuEntry setForceLeftClick(boolean forceLeftClick)
|
||||
{
|
||||
Client.menuShiftClick[this.idx] = forceLeftClick;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MenuEntry onClick(Consumer consumer)
|
||||
{
|
||||
this.consumer = consumer;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean instanceOf(Object o)
|
||||
{
|
||||
return o instanceof RuneLiteMenuEntry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
if (o == this)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (!(o instanceof RuneLiteMenuEntry))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
RuneLiteMenuEntry menuEntry = (RuneLiteMenuEntry) o;
|
||||
if (!menuEntry.instanceOf(this))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (this.getIdentifier() != menuEntry.getIdentifier())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (this.getParam0() != menuEntry.getParam0())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (this.getParam1() != menuEntry.getParam1())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (this.isForceLeftClick() != menuEntry.isForceLeftClick())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (this.isDeprioritized() != menuEntry.isDeprioritized())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
String option = this.getOption();
|
||||
String menuEntryOption = menuEntry.getOption();
|
||||
if (option == null)
|
||||
{
|
||||
if (menuEntryOption != null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (!option.equals(menuEntryOption))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
String target = this.getTarget();
|
||||
String menuEntryTarget = menuEntry.getTarget();
|
||||
if (target == null)
|
||||
{
|
||||
if (menuEntryTarget != null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (!target.equals(menuEntryTarget))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
MenuAction type = this.getType();
|
||||
MenuAction menuEntryType = menuEntry.getType();
|
||||
if (type == null)
|
||||
{
|
||||
if (menuEntryType == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (type.equals(menuEntryType))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
byte b = 1;
|
||||
|
||||
int hash = b * 59 + this.getIdentifier();
|
||||
hash = hash * 59 + this.getParam0();
|
||||
hash = hash * 59 + this.getParam1();
|
||||
hash = hash * 59 + (this.isForceLeftClick() ? 79 : 97);
|
||||
hash = hash * 59 + (this.isDeprioritized() ? 79 : 97);
|
||||
String option = this.getOption();
|
||||
hash = hash * 59 + (option == null ? 43 : option.hashCode());
|
||||
String target = this.getTarget();
|
||||
hash = hash * 59 + (target == null ? 43 : target.hashCode());
|
||||
MenuAction type = this.getType();
|
||||
hash = hash * 59 + (type == null ? 43 : type.hashCode());
|
||||
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
@@ -320,7 +320,7 @@ public class class10 {
|
||||
SecureRandomCallable.invalidateWidget(var4);
|
||||
}
|
||||
|
||||
FileSystem.method3084();
|
||||
FileSystem.decrementMenuEntries();
|
||||
if (Client.rootInterface != -1) {
|
||||
Message.runIntfCloseListeners(Client.rootInterface, 1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user