Skip to content

Commit

Permalink
lol
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam- committed May 1, 2024
1 parent ff4ed53 commit b60ea25
Showing 1 changed file with 10 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
import net.runelite.api.NPCComposition;
import net.runelite.api.ObjectComposition;
import net.runelite.api.ParamID;
import net.runelite.api.Varbits;
import net.runelite.api.annotations.Component;
import net.runelite.api.events.ClientTick;
import net.runelite.api.events.MenuEntryAdded;
Expand Down Expand Up @@ -166,6 +165,7 @@ public class MenuEntrySwapperPlugin extends Plugin
private final Multimap<String, Swap> swaps = LinkedHashMultimap.create();
private final ArrayListMultimap<String, Integer> optionIndexes = ArrayListMultimap.create();
private final Multimap<Integer, TeleportSwap> teleportSwaps = HashMultimap.create();
private boolean lastShift, curShift;

@Provides
MenuEntrySwapperConfig provideConfig(ConfigManager configManager)
Expand Down Expand Up @@ -1480,24 +1480,11 @@ private void swapMenuEntry(MenuEntry[] menuEntries, int index, MenuEntry menuEnt
final String target = Text.removeTags(menuEntry.getTarget()).toLowerCase();

final Widget w = menuEntry.getParent() != null ? menuEntry.getParent().getWidget() : menuEntry.getWidget();
final boolean shift = shiftModifier();
// Custom item swap
if (w != null && WidgetUtil.componentToInterface(w.getId()) == InterfaceID.INVENTORY
&& (shift ? config.shiftClickCustomization() : config.leftClickCustomization()))
&& (lastShift ? config.shiftClickCustomization() : config.leftClickCustomization()))
{
Integer swapIndex = getItemSwapConfig(shift, w.getItemId());
if (shift && swapIndex == null && client.getVarbitValue(Varbits.SHIFT_CLICK_DROP) == 1)
{
// Vanilla has 1 tick between the shift keypress and the menu being updated because [proc,inventory_setophelds]
// runs after the ui has been ticked. Work around this here to avoid both the left and shift click swaps
// from being applied.
int shiftOp = itemManager.getItemComposition(w.getItemId())
.getShiftClickActionIndex();
if (shiftOp > -1)
{
swapIndex = shiftOp;
}
}
Integer swapIndex = getItemSwapConfig(lastShift, w.getItemId());
if (swapIndex != null)
{
if (swapIndex == -1)
Expand All @@ -1520,7 +1507,7 @@ else if (swapIndex + 1 == menuEntry.getItemOp()
Widget child = w.getChild(1);
if (child != null && child.getItemId() > -1)
{
final Integer wornItemSwapConfig = getWornItemSwapConfig(shift, child.getItemId());
final Integer wornItemSwapConfig = getWornItemSwapConfig(shiftModifier(), child.getItemId());
if (wornItemSwapConfig != null)
{
if (wornItemSwapConfig == menuEntry.getIdentifier()
Expand All @@ -1545,7 +1532,7 @@ else if (swapIndex + 1 == menuEntry.getItemOp()
objectId = objectComposition.getId();
}

Integer customOption = getObjectSwapConfig(shift, objectId);
Integer customOption = getObjectSwapConfig(shiftModifier(), objectId);
if (customOption != null && customOption >= 0)
{
MenuAction swapAction = OBJECT_MENU_TYPES.get(customOption);
Expand All @@ -1564,7 +1551,7 @@ else if (swapIndex + 1 == menuEntry.getItemOp()
final NPCComposition composition = npc.getTransformedComposition();
assert composition != null;

Integer customOption = getNpcSwapConfig(shift, composition.getId());
Integer customOption = getNpcSwapConfig(shiftModifier(), composition.getId());
if (customOption != null && customOption >= 0)
{
MenuAction swapAction = NPC_MENU_TYPES.get(customOption);
Expand Down Expand Up @@ -1596,7 +1583,7 @@ else if (swapIndex + 1 == menuEntry.getItemOp()
{
final int componentId = w.getId(); // on dynamic components, this is the parent layer id
final int itemId = w.getIndex() == -1 ? -1 : ItemVariationMapping.map(w.getItemId());
final Integer op = getUiSwapConfig(shift, componentId, itemId);
final Integer op = getUiSwapConfig(shiftModifier(), componentId, itemId);
if (op != null && op == menuEntry.getIdentifier())
{
swap(optionIndexes, menuEntries, index, menuEntries.length - 1);
Expand Down Expand Up @@ -1637,6 +1624,9 @@ else if (swapIndex + 1 == menuEntry.getItemOp()
@Subscribe
public void onClientTick(ClientTick clientTick)
{
lastShift = curShift;
curShift = shiftModifier();

if (client.isMenuOpen())
{
return;
Expand Down

0 comments on commit b60ea25

Please sign in to comment.