mes: add left click customization
This commit is contained in:
@@ -113,6 +113,18 @@ public interface MenuEntrySwapperConfig extends Config
|
|||||||
KALPHITE_CAVE,
|
KALPHITE_CAVE,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ConfigItem(
|
||||||
|
position = -3,
|
||||||
|
keyName = "leftClickCustomization",
|
||||||
|
name = "Customizable left-click",
|
||||||
|
description = "Allows customization of left-clicks on items",
|
||||||
|
section = itemSection
|
||||||
|
)
|
||||||
|
default boolean leftClickCustomization()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@ConfigItem(
|
@ConfigItem(
|
||||||
position = -2,
|
position = -2,
|
||||||
keyName = "shiftClickCustomization",
|
keyName = "shiftClickCustomization",
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ package net.runelite.client.plugins.menuentryswapper;
|
|||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
import static com.google.common.base.Predicates.alwaysTrue;
|
import static com.google.common.base.Predicates.alwaysTrue;
|
||||||
import static com.google.common.base.Predicates.equalTo;
|
import static com.google.common.base.Predicates.equalTo;
|
||||||
|
import com.google.common.base.Strings;
|
||||||
import com.google.common.collect.ArrayListMultimap;
|
import com.google.common.collect.ArrayListMultimap;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.LinkedHashMultimap;
|
import com.google.common.collect.LinkedHashMultimap;
|
||||||
@@ -42,7 +43,6 @@ import java.util.Set;
|
|||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import lombok.Getter;
|
|
||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
import net.runelite.api.GameState;
|
import net.runelite.api.GameState;
|
||||||
import net.runelite.api.ItemComposition;
|
import net.runelite.api.ItemComposition;
|
||||||
@@ -87,28 +87,43 @@ public class MenuEntrySwapperPlugin extends Plugin
|
|||||||
private static final String CONFIGURE = "Configure";
|
private static final String CONFIGURE = "Configure";
|
||||||
private static final String SAVE = "Save";
|
private static final String SAVE = "Save";
|
||||||
private static final String RESET = "Reset";
|
private static final String RESET = "Reset";
|
||||||
private static final String MENU_TARGET = "Shift-click";
|
private static final String LEFT_CLICK_MENU_TARGET = "Left-click";
|
||||||
|
private static final String SHIFT_CLICK_MENU_TARGET = "Shift-click";
|
||||||
|
|
||||||
private static final String SHIFTCLICK_CONFIG_GROUP = "shiftclick";
|
private static final String SHIFTCLICK_CONFIG_GROUP = "shiftclick";
|
||||||
private static final String ITEM_KEY_PREFIX = "item_";
|
private static final String ITEM_KEY_PREFIX = "item_";
|
||||||
|
|
||||||
private static final WidgetMenuOption FIXED_INVENTORY_TAB_CONFIGURE = new WidgetMenuOption(CONFIGURE,
|
// Shift click
|
||||||
MENU_TARGET, WidgetInfo.FIXED_VIEWPORT_INVENTORY_TAB);
|
private static final WidgetMenuOption FIXED_INVENTORY_TAB_CONFIGURE_SC = new WidgetMenuOption(CONFIGURE,
|
||||||
|
SHIFT_CLICK_MENU_TARGET, WidgetInfo.FIXED_VIEWPORT_INVENTORY_TAB);
|
||||||
|
private static final WidgetMenuOption FIXED_INVENTORY_TAB_SAVE_SC = new WidgetMenuOption(SAVE,
|
||||||
|
SHIFT_CLICK_MENU_TARGET, WidgetInfo.FIXED_VIEWPORT_INVENTORY_TAB);
|
||||||
|
|
||||||
private static final WidgetMenuOption FIXED_INVENTORY_TAB_SAVE = new WidgetMenuOption(SAVE,
|
private static final WidgetMenuOption RESIZABLE_INVENTORY_TAB_CONFIGURE_SC = new WidgetMenuOption(CONFIGURE,
|
||||||
MENU_TARGET, WidgetInfo.FIXED_VIEWPORT_INVENTORY_TAB);
|
SHIFT_CLICK_MENU_TARGET, WidgetInfo.RESIZABLE_VIEWPORT_INVENTORY_TAB);
|
||||||
|
private static final WidgetMenuOption RESIZABLE_INVENTORY_TAB_SAVE_SC = new WidgetMenuOption(SAVE,
|
||||||
|
SHIFT_CLICK_MENU_TARGET, WidgetInfo.RESIZABLE_VIEWPORT_INVENTORY_TAB);
|
||||||
|
|
||||||
private static final WidgetMenuOption RESIZABLE_INVENTORY_TAB_CONFIGURE = new WidgetMenuOption(CONFIGURE,
|
private static final WidgetMenuOption RESIZABLE_BOTTOM_LINE_INVENTORY_TAB_CONFIGURE_SC = new WidgetMenuOption(CONFIGURE,
|
||||||
MENU_TARGET, WidgetInfo.RESIZABLE_VIEWPORT_INVENTORY_TAB);
|
SHIFT_CLICK_MENU_TARGET, WidgetInfo.RESIZABLE_VIEWPORT_BOTTOM_LINE_INVENTORY_TAB);
|
||||||
|
private static final WidgetMenuOption RESIZABLE_BOTTOM_LINE_INVENTORY_TAB_SAVE_SC = new WidgetMenuOption(SAVE,
|
||||||
|
SHIFT_CLICK_MENU_TARGET, WidgetInfo.RESIZABLE_VIEWPORT_BOTTOM_LINE_INVENTORY_TAB);
|
||||||
|
|
||||||
private static final WidgetMenuOption RESIZABLE_INVENTORY_TAB_SAVE = new WidgetMenuOption(SAVE,
|
// Left click
|
||||||
MENU_TARGET, WidgetInfo.RESIZABLE_VIEWPORT_INVENTORY_TAB);
|
private static final WidgetMenuOption FIXED_INVENTORY_TAB_CONFIGURE_LC = new WidgetMenuOption(CONFIGURE,
|
||||||
|
LEFT_CLICK_MENU_TARGET, WidgetInfo.FIXED_VIEWPORT_INVENTORY_TAB);
|
||||||
|
private static final WidgetMenuOption FIXED_INVENTORY_TAB_SAVE_LC = new WidgetMenuOption(SAVE,
|
||||||
|
LEFT_CLICK_MENU_TARGET, WidgetInfo.FIXED_VIEWPORT_INVENTORY_TAB);
|
||||||
|
|
||||||
private static final WidgetMenuOption RESIZABLE_BOTTOM_LINE_INVENTORY_TAB_CONFIGURE = new WidgetMenuOption(CONFIGURE,
|
private static final WidgetMenuOption RESIZABLE_INVENTORY_TAB_CONFIGURE_LC = new WidgetMenuOption(CONFIGURE,
|
||||||
MENU_TARGET, WidgetInfo.RESIZABLE_VIEWPORT_BOTTOM_LINE_INVENTORY_TAB);
|
LEFT_CLICK_MENU_TARGET, WidgetInfo.RESIZABLE_VIEWPORT_INVENTORY_TAB);
|
||||||
|
private static final WidgetMenuOption RESIZABLE_INVENTORY_TAB_SAVE_LC = new WidgetMenuOption(SAVE,
|
||||||
|
LEFT_CLICK_MENU_TARGET, WidgetInfo.RESIZABLE_VIEWPORT_INVENTORY_TAB);
|
||||||
|
|
||||||
private static final WidgetMenuOption RESIZABLE_BOTTOM_LINE_INVENTORY_TAB_SAVE = new WidgetMenuOption(SAVE,
|
private static final WidgetMenuOption RESIZABLE_BOTTOM_LINE_INVENTORY_TAB_CONFIGURE_LC = new WidgetMenuOption(CONFIGURE,
|
||||||
MENU_TARGET, WidgetInfo.RESIZABLE_VIEWPORT_BOTTOM_LINE_INVENTORY_TAB);
|
LEFT_CLICK_MENU_TARGET, WidgetInfo.RESIZABLE_VIEWPORT_BOTTOM_LINE_INVENTORY_TAB);
|
||||||
|
private static final WidgetMenuOption RESIZABLE_BOTTOM_LINE_INVENTORY_TAB_SAVE_LC = new WidgetMenuOption(SAVE,
|
||||||
|
LEFT_CLICK_MENU_TARGET, WidgetInfo.RESIZABLE_VIEWPORT_BOTTOM_LINE_INVENTORY_TAB);
|
||||||
|
|
||||||
private static final Set<MenuAction> ITEM_MENU_TYPES = ImmutableSet.of(
|
private static final Set<MenuAction> ITEM_MENU_TYPES = ImmutableSet.of(
|
||||||
MenuAction.ITEM_FIRST_OPTION,
|
MenuAction.ITEM_FIRST_OPTION,
|
||||||
@@ -161,8 +176,8 @@ public class MenuEntrySwapperPlugin extends Plugin
|
|||||||
@Inject
|
@Inject
|
||||||
private ItemManager itemManager;
|
private ItemManager itemManager;
|
||||||
|
|
||||||
@Getter
|
|
||||||
private boolean configuringShiftClick = false;
|
private boolean configuringShiftClick = false;
|
||||||
|
private boolean configuringLeftClick = false;
|
||||||
|
|
||||||
private final Multimap<String, Swap> swaps = LinkedHashMultimap.create();
|
private final Multimap<String, Swap> swaps = LinkedHashMultimap.create();
|
||||||
private final ArrayListMultimap<String, Integer> optionIndexes = ArrayListMultimap.create();
|
private final ArrayListMultimap<String, Integer> optionIndexes = ArrayListMultimap.create();
|
||||||
@@ -176,11 +191,7 @@ public class MenuEntrySwapperPlugin extends Plugin
|
|||||||
@Override
|
@Override
|
||||||
public void startUp()
|
public void startUp()
|
||||||
{
|
{
|
||||||
if (config.shiftClickCustomization())
|
enableCustomization();
|
||||||
{
|
|
||||||
enableCustomization();
|
|
||||||
}
|
|
||||||
|
|
||||||
setupSwaps();
|
setupSwaps();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -440,16 +451,10 @@ public class MenuEntrySwapperPlugin extends Plugin
|
|||||||
@Subscribe
|
@Subscribe
|
||||||
public void onConfigChanged(ConfigChanged event)
|
public void onConfigChanged(ConfigChanged event)
|
||||||
{
|
{
|
||||||
if (event.getGroup().equals(MenuEntrySwapperConfig.GROUP) && event.getKey().equals("shiftClickCustomization"))
|
if (event.getGroup().equals(MenuEntrySwapperConfig.GROUP)
|
||||||
|
&& (event.getKey().equals("shiftClickCustomization") || event.getKey().equals("leftClickCustomization")))
|
||||||
{
|
{
|
||||||
if (config.shiftClickCustomization())
|
enableCustomization();
|
||||||
{
|
|
||||||
enableCustomization();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
disableCustomization();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (event.getGroup().equals(SHIFTCLICK_CONFIG_GROUP) && event.getKey().startsWith(ITEM_KEY_PREFIX))
|
else if (event.getGroup().equals(SHIFTCLICK_CONFIG_GROUP) && event.getKey().startsWith(ITEM_KEY_PREFIX))
|
||||||
{
|
{
|
||||||
@@ -462,10 +467,10 @@ public class MenuEntrySwapperPlugin extends Plugin
|
|||||||
client.getItemCompositionCache().reset();
|
client.getItemCompositionCache().reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Integer getSwapConfig(int itemId)
|
private Integer getSwapConfig(boolean shift, int itemId)
|
||||||
{
|
{
|
||||||
itemId = ItemVariationMapping.map(itemId);
|
itemId = ItemVariationMapping.map(itemId);
|
||||||
String config = configManager.getConfiguration(SHIFTCLICK_CONFIG_GROUP, ITEM_KEY_PREFIX + itemId);
|
String config = configManager.getConfiguration(shift ? SHIFTCLICK_CONFIG_GROUP : MenuEntrySwapperConfig.GROUP, ITEM_KEY_PREFIX + itemId);
|
||||||
if (config == null || config.isEmpty())
|
if (config == null || config.isEmpty())
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
@@ -474,29 +479,29 @@ public class MenuEntrySwapperPlugin extends Plugin
|
|||||||
return Integer.parseInt(config);
|
return Integer.parseInt(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setSwapConfig(int itemId, int index)
|
private void setSwapConfig(boolean shift, int itemId, int index)
|
||||||
{
|
{
|
||||||
itemId = ItemVariationMapping.map(itemId);
|
itemId = ItemVariationMapping.map(itemId);
|
||||||
configManager.setConfiguration(SHIFTCLICK_CONFIG_GROUP, ITEM_KEY_PREFIX + itemId, index);
|
configManager.setConfiguration(shift ? SHIFTCLICK_CONFIG_GROUP : MenuEntrySwapperConfig.GROUP, ITEM_KEY_PREFIX + itemId, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void unsetSwapConfig(int itemId)
|
private void unsetSwapConfig(boolean shift, int itemId)
|
||||||
{
|
{
|
||||||
itemId = ItemVariationMapping.map(itemId);
|
itemId = ItemVariationMapping.map(itemId);
|
||||||
configManager.unsetConfiguration(SHIFTCLICK_CONFIG_GROUP, ITEM_KEY_PREFIX + itemId);
|
configManager.unsetConfiguration(shift ? SHIFTCLICK_CONFIG_GROUP : MenuEntrySwapperConfig.GROUP, ITEM_KEY_PREFIX + itemId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void enableCustomization()
|
private void enableCustomization()
|
||||||
{
|
{
|
||||||
refreshShiftClickCustomizationMenus();
|
rebuildCustomizationMenus();
|
||||||
// set shift click action index on the item compositions
|
// set shift click action index on the item compositions
|
||||||
clientThread.invoke(this::resetItemCompositionCache);
|
clientThread.invoke(this::resetItemCompositionCache);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void disableCustomization()
|
private void disableCustomization()
|
||||||
{
|
{
|
||||||
removeShiftClickCustomizationMenus();
|
removeCusomizationMenus();
|
||||||
configuringShiftClick = false;
|
configuringShiftClick = configuringLeftClick = false;
|
||||||
// flush item compositions to reset the shift click action index
|
// flush item compositions to reset the shift click action index
|
||||||
clientThread.invoke(this::resetItemCompositionCache);
|
clientThread.invoke(this::resetItemCompositionCache);
|
||||||
}
|
}
|
||||||
@@ -508,15 +513,21 @@ public class MenuEntrySwapperPlugin extends Plugin
|
|||||||
|| event.getWidget() == WidgetInfo.RESIZABLE_VIEWPORT_INVENTORY_TAB
|
|| event.getWidget() == WidgetInfo.RESIZABLE_VIEWPORT_INVENTORY_TAB
|
||||||
|| event.getWidget() == WidgetInfo.RESIZABLE_VIEWPORT_BOTTOM_LINE_INVENTORY_TAB)
|
|| event.getWidget() == WidgetInfo.RESIZABLE_VIEWPORT_BOTTOM_LINE_INVENTORY_TAB)
|
||||||
{
|
{
|
||||||
configuringShiftClick = event.getMenuOption().equals(CONFIGURE) && Text.removeTags(event.getMenuTarget()).equals(MENU_TARGET);
|
String option = event.getMenuOption();
|
||||||
refreshShiftClickCustomizationMenus();
|
String target = Text.removeTags(event.getMenuTarget());
|
||||||
|
if ((option.equals(CONFIGURE) || option.equals(SAVE)) && (target.equals(LEFT_CLICK_MENU_TARGET) || target.equals(SHIFT_CLICK_MENU_TARGET)))
|
||||||
|
{
|
||||||
|
configuringShiftClick = option.equals(CONFIGURE) && target.equals(SHIFT_CLICK_MENU_TARGET);
|
||||||
|
configuringLeftClick = option.equals(CONFIGURE) && target.equals(LEFT_CLICK_MENU_TARGET);
|
||||||
|
rebuildCustomizationMenus();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onMenuOpened(MenuOpened event)
|
public void onMenuOpened(MenuOpened event)
|
||||||
{
|
{
|
||||||
if (!configuringShiftClick)
|
if (!configuringShiftClick && !configuringLeftClick)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -539,13 +550,41 @@ public class MenuEntrySwapperPlugin extends Plugin
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemComposition itemComposition = itemManager.getItemComposition(itemId);
|
MenuAction activeAction = MenuAction.ITEM_USE;
|
||||||
MenuAction shiftClickAction = MenuAction.ITEM_USE;
|
final ItemComposition itemComposition = itemManager.getItemComposition(itemId);
|
||||||
final int shiftClickActionIndex = itemComposition.getShiftClickActionIndex();
|
|
||||||
|
|
||||||
if (shiftClickActionIndex >= 0)
|
if (configuringShiftClick)
|
||||||
{
|
{
|
||||||
shiftClickAction = MenuAction.of(MenuAction.ITEM_FIRST_OPTION.getId() + shiftClickActionIndex);
|
// For shift-click read the active action off of the item composition, since it may be set by
|
||||||
|
// that even if we have no existing config for it
|
||||||
|
final int shiftClickActionIndex = itemComposition.getShiftClickActionIndex();
|
||||||
|
|
||||||
|
if (shiftClickActionIndex >= 0)
|
||||||
|
{
|
||||||
|
activeAction = MenuAction.of(MenuAction.ITEM_FIRST_OPTION.getId() + shiftClickActionIndex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// The default left click on items is the highest priority action 0-2, and otherwise is use.
|
||||||
|
final String[] actions = itemComposition.getInventoryActions();
|
||||||
|
for (int i = 0; i <= 2; ++i)
|
||||||
|
{
|
||||||
|
if (!Strings.isNullOrEmpty(actions[i]))
|
||||||
|
{
|
||||||
|
activeAction = MenuAction.of(MenuAction.ITEM_FIRST_OPTION.getId() + i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply left click action from configuration
|
||||||
|
Integer config = getSwapConfig(false, itemId);
|
||||||
|
if (config != null)
|
||||||
|
{
|
||||||
|
activeAction = config >= 0
|
||||||
|
? MenuAction.of(MenuAction.ITEM_FIRST_OPTION.getId() + config)
|
||||||
|
: MenuAction.ITEM_USE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MenuEntry[] entries = event.getMenuEntries();
|
MenuEntry[] entries = event.getMenuEntries();
|
||||||
@@ -558,7 +597,7 @@ public class MenuEntrySwapperPlugin extends Plugin
|
|||||||
{
|
{
|
||||||
entry.setType(MenuAction.RUNELITE.getId());
|
entry.setType(MenuAction.RUNELITE.getId());
|
||||||
|
|
||||||
if (shiftClickAction == menuAction)
|
if (activeAction == menuAction)
|
||||||
{
|
{
|
||||||
entry.setOption("* " + entry.getOption());
|
entry.setOption("* " + entry.getOption());
|
||||||
}
|
}
|
||||||
@@ -567,7 +606,7 @@ public class MenuEntrySwapperPlugin extends Plugin
|
|||||||
|
|
||||||
final MenuEntry resetShiftClickEntry = new MenuEntry();
|
final MenuEntry resetShiftClickEntry = new MenuEntry();
|
||||||
resetShiftClickEntry.setOption(RESET);
|
resetShiftClickEntry.setOption(RESET);
|
||||||
resetShiftClickEntry.setTarget(MENU_TARGET);
|
resetShiftClickEntry.setTarget(configuringShiftClick ? SHIFT_CLICK_MENU_TARGET : LEFT_CLICK_MENU_TARGET);
|
||||||
resetShiftClickEntry.setIdentifier(itemId);
|
resetShiftClickEntry.setIdentifier(itemId);
|
||||||
resetShiftClickEntry.setParam1(widgetId);
|
resetShiftClickEntry.setParam1(widgetId);
|
||||||
resetShiftClickEntry.setType(MenuAction.RUNELITE.getId());
|
resetShiftClickEntry.setType(MenuAction.RUNELITE.getId());
|
||||||
@@ -664,9 +703,14 @@ public class MenuEntrySwapperPlugin extends Plugin
|
|||||||
String target = event.getMenuTarget();
|
String target = event.getMenuTarget();
|
||||||
ItemComposition itemComposition = itemManager.getItemComposition(itemId);
|
ItemComposition itemComposition = itemManager.getItemComposition(itemId);
|
||||||
|
|
||||||
if (option.equals(RESET) && target.equals(MENU_TARGET))
|
if (option.equals(RESET) && target.equals(SHIFT_CLICK_MENU_TARGET))
|
||||||
{
|
{
|
||||||
unsetSwapConfig(itemId);
|
unsetSwapConfig(true, itemId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (option.equals(RESET) && target.equals(LEFT_CLICK_MENU_TARGET))
|
||||||
|
{
|
||||||
|
unsetSwapConfig(false, itemId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -677,7 +721,7 @@ public class MenuEntrySwapperPlugin extends Plugin
|
|||||||
|
|
||||||
if (option.equals("Use")) //because "Use" is not in inventoryActions
|
if (option.equals("Use")) //because "Use" is not in inventoryActions
|
||||||
{
|
{
|
||||||
setSwapConfig(itemId, -1);
|
setSwapConfig(configuringShiftClick, itemId, -1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -687,14 +731,14 @@ public class MenuEntrySwapperPlugin extends Plugin
|
|||||||
{
|
{
|
||||||
if (option.equals(inventoryActions[index]))
|
if (option.equals(inventoryActions[index]))
|
||||||
{
|
{
|
||||||
setSwapConfig(itemId, index);
|
setSwapConfig(configuringShiftClick, itemId, index);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void swapMenuEntry(int index, MenuEntry menuEntry)
|
private void swapMenuEntry(MenuEntry[] menuEntries, int index, MenuEntry menuEntry)
|
||||||
{
|
{
|
||||||
final int eventId = menuEntry.getIdentifier();
|
final int eventId = menuEntry.getIdentifier();
|
||||||
final MenuAction menuAction = MenuAction.of(menuEntry.getType());
|
final MenuAction menuAction = MenuAction.of(menuEntry.getType());
|
||||||
@@ -702,6 +746,7 @@ public class MenuEntrySwapperPlugin extends Plugin
|
|||||||
final String target = Text.removeTags(menuEntry.getTarget()).toLowerCase();
|
final String target = Text.removeTags(menuEntry.getTarget()).toLowerCase();
|
||||||
final NPC hintArrowNpc = client.getHintArrowNpc();
|
final NPC hintArrowNpc = client.getHintArrowNpc();
|
||||||
|
|
||||||
|
// Don't swap on hint arrow npcs, usually they need "Talk-to" for clues.
|
||||||
if (hintArrowNpc != null
|
if (hintArrowNpc != null
|
||||||
&& hintArrowNpc.getIndex() == eventId
|
&& hintArrowNpc.getIndex() == eventId
|
||||||
&& NPC_MENU_TYPES.contains(menuAction))
|
&& NPC_MENU_TYPES.contains(menuAction))
|
||||||
@@ -709,22 +754,23 @@ public class MenuEntrySwapperPlugin extends Plugin
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shiftModifier() && (menuAction == MenuAction.ITEM_FIRST_OPTION
|
final boolean itemOp = menuAction == MenuAction.ITEM_FIRST_OPTION
|
||||||
|| menuAction == MenuAction.ITEM_SECOND_OPTION
|
|| menuAction == MenuAction.ITEM_SECOND_OPTION
|
||||||
|| menuAction == MenuAction.ITEM_THIRD_OPTION
|
|| menuAction == MenuAction.ITEM_THIRD_OPTION
|
||||||
|| menuAction == MenuAction.ITEM_FOURTH_OPTION
|
|| menuAction == MenuAction.ITEM_FOURTH_OPTION
|
||||||
|| menuAction == MenuAction.ITEM_FIFTH_OPTION
|
|| menuAction == MenuAction.ITEM_FIFTH_OPTION
|
||||||
|| menuAction == MenuAction.ITEM_USE))
|
|| menuAction == MenuAction.ITEM_USE;
|
||||||
|
if (shiftModifier() && itemOp)
|
||||||
{
|
{
|
||||||
// Special case use shift click due to items not actually containing a "Use" option, making
|
// Special case use shift click due to items not actually containing a "Use" option, making
|
||||||
// the client unable to perform the swap itself.
|
// the client unable to perform the swap itself.
|
||||||
if (config.shiftClickCustomization() && !option.equals("use"))
|
if (config.shiftClickCustomization() && !option.equals("use"))
|
||||||
{
|
{
|
||||||
Integer customOption = getSwapConfig(eventId);
|
Integer customOption = getSwapConfig(true, eventId);
|
||||||
|
|
||||||
if (customOption != null && customOption == -1)
|
if (customOption != null && customOption == -1)
|
||||||
{
|
{
|
||||||
swap("use", target, index, true);
|
swap(menuEntries, "use", target, index, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -733,12 +779,31 @@ public class MenuEntrySwapperPlugin extends Plugin
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Custom left-click item swap
|
||||||
|
if (itemOp)
|
||||||
|
{
|
||||||
|
Integer swapIndex = getSwapConfig(false, eventId);
|
||||||
|
if (swapIndex != null && index < menuEntries.length - 1)
|
||||||
|
{
|
||||||
|
MenuAction swapAction = swapIndex >= 0
|
||||||
|
? MenuAction.of(MenuAction.ITEM_FIRST_OPTION.getId() + swapIndex)
|
||||||
|
: MenuAction.ITEM_USE;
|
||||||
|
|
||||||
|
if (menuAction == swapAction)
|
||||||
|
{
|
||||||
|
swap(optionIndexes, menuEntries, index, menuEntries.length - 1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Built-in swaps
|
||||||
Collection<Swap> swaps = this.swaps.get(option);
|
Collection<Swap> swaps = this.swaps.get(option);
|
||||||
for (Swap swap : swaps)
|
for (Swap swap : swaps)
|
||||||
{
|
{
|
||||||
if (swap.getTargetPredicate().test(target) && swap.getEnabled().get())
|
if (swap.getTargetPredicate().test(target) && swap.getEnabled().get())
|
||||||
{
|
{
|
||||||
if (swap(swap.getSwappedOption(), target, index, swap.isStrict()))
|
if (swap(menuEntries, swap.getSwappedOption(), target, index, swap.isStrict()))
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -771,7 +836,7 @@ public class MenuEntrySwapperPlugin extends Plugin
|
|||||||
idx = 0;
|
idx = 0;
|
||||||
for (MenuEntry entry : menuEntries)
|
for (MenuEntry entry : menuEntries)
|
||||||
{
|
{
|
||||||
swapMenuEntry(idx++, entry);
|
swapMenuEntry(menuEntries, idx++, entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -786,7 +851,7 @@ public class MenuEntrySwapperPlugin extends Plugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
ItemComposition itemComposition = event.getItemComposition();
|
ItemComposition itemComposition = event.getItemComposition();
|
||||||
Integer option = getSwapConfig(itemComposition.getId());
|
Integer option = getSwapConfig(true, itemComposition.getId());
|
||||||
|
|
||||||
if (option != null)
|
if (option != null)
|
||||||
{
|
{
|
||||||
@@ -794,10 +859,8 @@ public class MenuEntrySwapperPlugin extends Plugin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean swap(String option, String target, int index, boolean strict)
|
private boolean swap(MenuEntry[] menuEntries, String option, String target, int index, boolean strict)
|
||||||
{
|
{
|
||||||
MenuEntry[] menuEntries = client.getMenuEntries();
|
|
||||||
|
|
||||||
// find option to swap with
|
// find option to swap with
|
||||||
int optionIdx = findIndex(menuEntries, index, option, target, strict);
|
int optionIdx = findIndex(menuEntries, index, option, target, strict);
|
||||||
|
|
||||||
@@ -882,30 +945,55 @@ public class MenuEntrySwapperPlugin extends Plugin
|
|||||||
list.add(idx < 0 ? -idx - 1 : idx, value);
|
list.add(idx < 0 ? -idx - 1 : idx, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeShiftClickCustomizationMenus()
|
private void removeCusomizationMenus()
|
||||||
{
|
{
|
||||||
menuManager.removeManagedCustomMenu(FIXED_INVENTORY_TAB_CONFIGURE);
|
// Shift click
|
||||||
menuManager.removeManagedCustomMenu(FIXED_INVENTORY_TAB_SAVE);
|
menuManager.removeManagedCustomMenu(FIXED_INVENTORY_TAB_CONFIGURE_SC);
|
||||||
menuManager.removeManagedCustomMenu(RESIZABLE_BOTTOM_LINE_INVENTORY_TAB_CONFIGURE);
|
menuManager.removeManagedCustomMenu(FIXED_INVENTORY_TAB_SAVE_SC);
|
||||||
menuManager.removeManagedCustomMenu(RESIZABLE_BOTTOM_LINE_INVENTORY_TAB_SAVE);
|
menuManager.removeManagedCustomMenu(RESIZABLE_BOTTOM_LINE_INVENTORY_TAB_CONFIGURE_SC);
|
||||||
menuManager.removeManagedCustomMenu(RESIZABLE_INVENTORY_TAB_CONFIGURE);
|
menuManager.removeManagedCustomMenu(RESIZABLE_BOTTOM_LINE_INVENTORY_TAB_SAVE_SC);
|
||||||
menuManager.removeManagedCustomMenu(RESIZABLE_INVENTORY_TAB_SAVE);
|
menuManager.removeManagedCustomMenu(RESIZABLE_INVENTORY_TAB_CONFIGURE_SC);
|
||||||
|
menuManager.removeManagedCustomMenu(RESIZABLE_INVENTORY_TAB_SAVE_SC);
|
||||||
|
// Left click
|
||||||
|
menuManager.removeManagedCustomMenu(FIXED_INVENTORY_TAB_CONFIGURE_LC);
|
||||||
|
menuManager.removeManagedCustomMenu(FIXED_INVENTORY_TAB_SAVE_LC);
|
||||||
|
menuManager.removeManagedCustomMenu(RESIZABLE_BOTTOM_LINE_INVENTORY_TAB_CONFIGURE_LC);
|
||||||
|
menuManager.removeManagedCustomMenu(RESIZABLE_BOTTOM_LINE_INVENTORY_TAB_SAVE_LC);
|
||||||
|
menuManager.removeManagedCustomMenu(RESIZABLE_INVENTORY_TAB_CONFIGURE_LC);
|
||||||
|
menuManager.removeManagedCustomMenu(RESIZABLE_INVENTORY_TAB_SAVE_LC);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void refreshShiftClickCustomizationMenus()
|
private void rebuildCustomizationMenus()
|
||||||
{
|
{
|
||||||
removeShiftClickCustomizationMenus();
|
removeCusomizationMenus();
|
||||||
if (configuringShiftClick)
|
if (configuringLeftClick)
|
||||||
{
|
{
|
||||||
menuManager.addManagedCustomMenu(FIXED_INVENTORY_TAB_SAVE);
|
menuManager.addManagedCustomMenu(FIXED_INVENTORY_TAB_SAVE_LC);
|
||||||
menuManager.addManagedCustomMenu(RESIZABLE_BOTTOM_LINE_INVENTORY_TAB_SAVE);
|
menuManager.addManagedCustomMenu(RESIZABLE_BOTTOM_LINE_INVENTORY_TAB_SAVE_LC);
|
||||||
menuManager.addManagedCustomMenu(RESIZABLE_INVENTORY_TAB_SAVE);
|
menuManager.addManagedCustomMenu(RESIZABLE_INVENTORY_TAB_SAVE_LC);
|
||||||
|
}
|
||||||
|
else if (configuringShiftClick)
|
||||||
|
{
|
||||||
|
menuManager.addManagedCustomMenu(FIXED_INVENTORY_TAB_SAVE_SC);
|
||||||
|
menuManager.addManagedCustomMenu(RESIZABLE_BOTTOM_LINE_INVENTORY_TAB_SAVE_SC);
|
||||||
|
menuManager.addManagedCustomMenu(RESIZABLE_INVENTORY_TAB_SAVE_SC);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
menuManager.addManagedCustomMenu(FIXED_INVENTORY_TAB_CONFIGURE);
|
// Left click
|
||||||
menuManager.addManagedCustomMenu(RESIZABLE_BOTTOM_LINE_INVENTORY_TAB_CONFIGURE);
|
if (config.leftClickCustomization())
|
||||||
menuManager.addManagedCustomMenu(RESIZABLE_INVENTORY_TAB_CONFIGURE);
|
{
|
||||||
|
menuManager.addManagedCustomMenu(FIXED_INVENTORY_TAB_CONFIGURE_LC);
|
||||||
|
menuManager.addManagedCustomMenu(RESIZABLE_BOTTOM_LINE_INVENTORY_TAB_CONFIGURE_LC);
|
||||||
|
menuManager.addManagedCustomMenu(RESIZABLE_INVENTORY_TAB_CONFIGURE_LC);
|
||||||
|
}
|
||||||
|
// Shift click
|
||||||
|
if (config.shiftClickCustomization())
|
||||||
|
{
|
||||||
|
menuManager.addManagedCustomMenu(FIXED_INVENTORY_TAB_CONFIGURE_SC);
|
||||||
|
menuManager.addManagedCustomMenu(RESIZABLE_BOTTOM_LINE_INVENTORY_TAB_CONFIGURE_SC);
|
||||||
|
menuManager.addManagedCustomMenu(RESIZABLE_INVENTORY_TAB_CONFIGURE_SC);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user