project(mixins): Update
This commit is contained in:
@@ -949,6 +949,17 @@ public abstract class RSClientMixin implements RSClient
|
||||
@Override
|
||||
public void setMenuEntries(MenuEntry[] menuEntries)
|
||||
{
|
||||
boolean var2 = false;
|
||||
|
||||
if (client.getTempMenuAction() != null && client.getMenuOptionCount() > 0)
|
||||
{
|
||||
var2 = client.getTempMenuAction().getParam0() == client.getMenuArguments1()[client.getMenuOptionCount() - 1] &&
|
||||
client.getTempMenuAction().getParam1() == client.getMenuArguments2()[client.getMenuOptionCount() - 1] &&
|
||||
client.getTempMenuAction().getOption().equals(client.getMenuOptions()[client.getMenuOptionCount() - 1]) &&
|
||||
client.getTempMenuAction().getIdentifier() == client.getMenuIdentifiers()[client.getMenuOptionCount() - 1] &&
|
||||
client.getTempMenuAction().getOpcode() == client.getMenuOpcodes()[client.getMenuOptionCount() - 1];
|
||||
}
|
||||
|
||||
for (int i = 0; i < menuEntries.length; ++i)
|
||||
{
|
||||
RSRuneLiteMenuEntry menuEntry = (RSRuneLiteMenuEntry) menuEntries[i];
|
||||
@@ -960,6 +971,15 @@ public abstract class RSClientMixin implements RSClient
|
||||
|
||||
client.setMenuOptionCount(menuEntries.length);
|
||||
tmpMenuOptionsCount = menuEntries.length;
|
||||
|
||||
if (var2 && client.getMenuOptionCount() > 0)
|
||||
{
|
||||
client.getTempMenuAction().setParam0(client.getMenuArguments1()[client.getMenuOptionCount() - 1]);
|
||||
client.getTempMenuAction().setParam1(client.getMenuArguments2()[client.getMenuOptionCount() - 1]);
|
||||
client.getTempMenuAction().setOption(client.getMenuOptions()[client.getMenuOptionCount() - 1]);
|
||||
client.getTempMenuAction().setIdentifier(client.getMenuIdentifiers()[client.getMenuOptionCount() - 1]);
|
||||
client.getTempMenuAction().setOpcode(client.getMenuOpcodes()[client.getMenuOptionCount() - 1]);
|
||||
}
|
||||
}
|
||||
|
||||
@Inject
|
||||
@@ -1038,6 +1058,7 @@ public abstract class RSClientMixin implements RSClient
|
||||
int menuIdentifier = client.getMenuIdentifiers()[tmpOptionsCount];
|
||||
int menuArgument1 = client.getMenuArguments1()[tmpOptionsCount];
|
||||
int menuArgument2 = client.getMenuArguments2()[tmpOptionsCount];
|
||||
|
||||
if (rl$menuEntries[tmpOptionsCount] == null)
|
||||
{
|
||||
rl$menuEntries[tmpOptionsCount] = newRuneliteMenuEntry(tmpOptionsCount);
|
||||
@@ -1655,15 +1676,67 @@ public abstract class RSClientMixin implements RSClient
|
||||
{
|
||||
RSRuneLiteMenuEntry menuEntry = null;
|
||||
|
||||
for (int i = client.getMenuOptionCount() - 1; i >= 0; --i)
|
||||
int i;
|
||||
for (i = client.getMenuOptionCount() - 1; i >= 0; --i)
|
||||
{
|
||||
if (client.getMenuOptions()[i] == option && client.getMenuTargets()[i] == target && client.getMenuIdentifiers()[i] == id && client.getMenuOpcodes()[i] == opcode)
|
||||
if (client.getMenuOptions()[i].equals(option) && client.getMenuTargets()[i].equals(target) && client.getMenuIdentifiers()[i] == id && client.getMenuOpcodes()[i] == opcode)
|
||||
{
|
||||
menuEntry = rl$menuEntries[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (menuEntry == null && option.equals(target))
|
||||
{
|
||||
if (tmpMenuOptionsCount < 500)
|
||||
{
|
||||
int var10000 = tmpMenuOptionsCount;
|
||||
tmpMenuOptionsCount = (var10000 + 1);
|
||||
i = var10000;
|
||||
}
|
||||
else
|
||||
{
|
||||
i = 0;
|
||||
}
|
||||
|
||||
client.getMenuOpcodes()[i] = opcode;
|
||||
client.getMenuIdentifiers()[i] = id;
|
||||
client.getMenuOptions()[i] = option;
|
||||
client.getMenuTargets()[i] = target;
|
||||
client.getMenuArguments1()[i] = param0;
|
||||
client.getMenuArguments2()[i] = param1;
|
||||
client.getMenuForceLeftClick()[i] = false;
|
||||
menuEntry = rl$menuEntries[i];
|
||||
}
|
||||
|
||||
MenuOptionClicked menuOptionClicked = null;
|
||||
|
||||
if (menuEntry == null)
|
||||
{
|
||||
menuOptionClicked = new MenuOptionClicked(newBareRuneliteMenuEntry());
|
||||
|
||||
if (canvasX != -1 || canvasY != -1)
|
||||
{
|
||||
client.getLogger().warn("Unable to find clicked menu op {} targ {} action {} id {} p0 {} p1 {}", option, target, opcode, id, param0, param1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
menuOptionClicked = new MenuOptionClicked(menuEntry);
|
||||
|
||||
client.getCallbacks().post(menuOptionClicked);
|
||||
|
||||
if (menuEntry.getConsumer() != null)
|
||||
{
|
||||
menuEntry.getConsumer().accept(menuEntry);
|
||||
}
|
||||
|
||||
if (menuOptionClicked.isConsumed())
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* The RuneScape client may deprioritize an action in the menu by incrementing the opcode with 2000,
|
||||
* undo it here so we can get the correct opcode
|
||||
@@ -1675,27 +1748,6 @@ public abstract class RSClientMixin implements RSClient
|
||||
opcode -= 2000;
|
||||
}
|
||||
|
||||
final MenuOptionClicked menuOptionClicked = new MenuOptionClicked();
|
||||
menuOptionClicked.setParam0(param0);
|
||||
menuOptionClicked.setMenuOption(option);
|
||||
menuOptionClicked.setMenuTarget(target);
|
||||
menuOptionClicked.setMenuAction(MenuAction.of(opcode));
|
||||
menuOptionClicked.setId(id);
|
||||
menuOptionClicked.setParam1(param1);
|
||||
menuOptionClicked.setSelectedItemIndex(client.getSelectedItemSlot());
|
||||
|
||||
client.getCallbacks().post(menuOptionClicked);
|
||||
|
||||
if (menuEntry != null && menuEntry.getConsumer() != null)
|
||||
{
|
||||
menuEntry.getConsumer().accept(menuEntry);
|
||||
}
|
||||
|
||||
if (menuOptionClicked.isConsumed())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (printMenuActions)
|
||||
{
|
||||
client.getLogger().info(
|
||||
@@ -1704,6 +1756,14 @@ public abstract class RSClientMixin implements RSClient
|
||||
menuOptionClicked.getMenuAction(), opcode + (decremented ? 2000 : 0),
|
||||
menuOptionClicked.getParam0(), menuOptionClicked.getParam1(), canvasX, canvasY
|
||||
);
|
||||
|
||||
if (menuEntry != null)
|
||||
{
|
||||
client.getLogger().info(
|
||||
"|MenuEntry|: Idx={} MenuOption={} MenuTarget={} Id={} MenuAction={} Param0={} Param1={} Consumer={} IsItemOp={} ItemOp={} ItemID={} Widget={}",
|
||||
menuEntry.getIdx(), menuEntry.getOption(), menuEntry.getTarget(), menuEntry.getIdentifier(), menuEntry.getType(), menuEntry.getParam0(), menuEntry.getParam1(), menuEntry.getConsumer(), menuEntry.isItemOp(), menuEntry.getItemOp(), menuEntry.getItemId(), menuEntry.getWidget()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
copy$menuAction(menuOptionClicked.getParam0(), menuOptionClicked.getParam1(),
|
||||
@@ -2944,5 +3004,22 @@ public abstract class RSClientMixin implements RSClient
|
||||
client.setLowMemory(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Inject
|
||||
@Override
|
||||
public Widget getSelectedWidget()
|
||||
{
|
||||
int selectedSpellWidget = client.getSelectedSpellWidget();
|
||||
int selectedSpellChildIndex = client.getSelectedSpellChildIndex();
|
||||
|
||||
Widget widget = client.getWidget(selectedSpellWidget);
|
||||
|
||||
if (widget != null && selectedSpellChildIndex > -1)
|
||||
{
|
||||
return widget.getChild(selectedSpellChildIndex);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright (c) 2018, OpenOSRS
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.mixins;
|
||||
|
||||
import net.runelite.api.MenuAction;
|
||||
import net.runelite.api.mixins.Inject;
|
||||
import net.runelite.api.mixins.Mixin;
|
||||
import net.runelite.api.mixins.Shadow;
|
||||
import net.runelite.api.widgets.Widget;
|
||||
import net.runelite.rs.api.RSClient;
|
||||
import net.runelite.rs.api.RSRuneLiteMenuEntry;
|
||||
|
||||
@Mixin(RSRuneLiteMenuEntry.class)
|
||||
public abstract class RuneLiteMenuEntryMixin implements RSRuneLiteMenuEntry
|
||||
{
|
||||
@Shadow("client")
|
||||
private static RSClient client;
|
||||
|
||||
@Inject
|
||||
@Override
|
||||
public int getItemId()
|
||||
{
|
||||
MenuAction menuAction = this.getType();
|
||||
if (menuAction == MenuAction.CC_OP || menuAction == MenuAction.CC_OP_LOW_PRIORITY)
|
||||
{
|
||||
int param1 = this.getParam1();
|
||||
int param0 = this.getParam0();
|
||||
if (param1 == 9764864)
|
||||
{
|
||||
Widget widget = client.getWidget(param1);
|
||||
if (param0 != -1)
|
||||
{
|
||||
widget = widget.getChild(param0);
|
||||
return widget.getItemId();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Inject
|
||||
@Override
|
||||
public Widget getWidget()
|
||||
{
|
||||
MenuAction menuAction = this.getType();
|
||||
if (menuAction == MenuAction.CC_OP || menuAction == MenuAction.CC_OP_LOW_PRIORITY)
|
||||
{
|
||||
int param1 = this.getParam1();
|
||||
int param0 = this.getParam0();
|
||||
if (param1 == 9764864)
|
||||
{
|
||||
Widget widget = client.getWidget(param1);
|
||||
if (param0 != -1)
|
||||
{
|
||||
widget = widget.getChild(param0);
|
||||
}
|
||||
|
||||
return widget;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user