client: update for if3 inventory
This commit is contained in:
@@ -34,6 +34,7 @@ import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import javax.inject.Inject;
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.AnimationID;
|
||||
import net.runelite.api.ChatMessageType;
|
||||
import net.runelite.api.Client;
|
||||
@@ -58,6 +59,8 @@ import net.runelite.api.events.GameTick;
|
||||
import net.runelite.api.events.ItemContainerChanged;
|
||||
import net.runelite.api.events.MenuOptionClicked;
|
||||
import net.runelite.api.events.ProjectileMoved;
|
||||
import net.runelite.api.widgets.Widget;
|
||||
import net.runelite.api.widgets.WidgetInfo;
|
||||
import net.runelite.client.Notifier;
|
||||
import net.runelite.client.callback.ClientThread;
|
||||
import net.runelite.client.config.ConfigManager;
|
||||
@@ -74,6 +77,7 @@ import net.runelite.client.ui.overlay.infobox.InfoBoxManager;
|
||||
description = "Show information about cannon placement and/or amount of cannonballs",
|
||||
tags = {"combat", "notifications", "ranged", "overlay"}
|
||||
)
|
||||
@Slf4j
|
||||
public class CannonPlugin extends Plugin
|
||||
{
|
||||
private static final Pattern NUMBER_PATTERN = Pattern.compile("([0-9]+)");
|
||||
@@ -284,16 +288,11 @@ public class CannonPlugin extends Plugin
|
||||
}
|
||||
|
||||
// Check if cannonballs are being used on the cannon
|
||||
if (event.getMenuAction() == MenuAction.ITEM_USE_ON_GAME_OBJECT)
|
||||
if (event.getMenuAction() == MenuAction.WIDGET_TARGET_ON_GAME_OBJECT && client.getSelectedWidget().getId() == WidgetInfo.INVENTORY.getId())
|
||||
{
|
||||
final int idx = client.getSelectedItemIndex();
|
||||
final ItemContainer items = client.getItemContainer(InventoryID.INVENTORY);
|
||||
if (items == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
final Item item = items.getItem(idx);
|
||||
if (item == null || (item.getId() != ItemID.CANNONBALL && item.getId() != ItemID.GRANITE_CANNONBALL))
|
||||
final Widget selected = client.getSelectedWidget();
|
||||
final int itemId = selected.getItemId();
|
||||
if (itemId != ItemID.CANNONBALL && itemId != ItemID.GRANITE_CANNONBALL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -306,6 +305,7 @@ public class CannonPlugin extends Plugin
|
||||
|
||||
// Store the click location as a WorldPoint to avoid issues with scene loads
|
||||
clickedCannonLocation = WorldPoint.fromScene(client, event.getParam0(), event.getParam1(), client.getPlane());
|
||||
log.debug("Updated cannon location: {}", clickedCannonLocation);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
|
||||
@@ -325,14 +325,8 @@ public class ClueScrollPlugin extends Plugin
|
||||
return;
|
||||
}
|
||||
|
||||
final boolean itemClicked = event.getMenuAction() == MenuAction.ITEM_FIRST_OPTION
|
||||
|| event.getMenuAction() == MenuAction.ITEM_SECOND_OPTION
|
||||
|| event.getMenuAction() == MenuAction.ITEM_THIRD_OPTION
|
||||
|| event.getMenuAction() == MenuAction.ITEM_FOURTH_OPTION
|
||||
|| event.getMenuAction() == MenuAction.ITEM_FIFTH_OPTION;
|
||||
final boolean isXMarksTheSpotOrb = event.getId() == ItemID.MYSTERIOUS_ORB_23069;
|
||||
|
||||
if (itemClicked && (isXMarksTheSpotOrb || event.getMenuOption().equals("Read")))
|
||||
final boolean isXMarksTheSpotOrb = event.getItemId() == ItemID.MYSTERIOUS_ORB_23069;
|
||||
if (isXMarksTheSpotOrb || event.getMenuOption().equals("Read"))
|
||||
{
|
||||
final ItemComposition itemComposition = itemManager.getItemComposition(event.getId());
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ import net.runelite.api.Skill;
|
||||
import net.runelite.api.Varbits;
|
||||
import net.runelite.api.events.ChatMessage;
|
||||
import net.runelite.api.events.MenuOptionClicked;
|
||||
import net.runelite.api.widgets.WidgetInfo;
|
||||
import net.runelite.client.eventbus.Subscribe;
|
||||
import net.runelite.client.plugins.crowdsourcing.CrowdsourcingManager;
|
||||
|
||||
@@ -114,7 +115,8 @@ public class CrowdsourcingCooking
|
||||
|| action == MenuAction.GAME_OBJECT_SECOND_OPTION
|
||||
|| action == MenuAction.GAME_OBJECT_THIRD_OPTION
|
||||
|| action == MenuAction.GAME_OBJECT_FOURTH_OPTION
|
||||
|| action == MenuAction.GAME_OBJECT_FIFTH_OPTION)
|
||||
|| action == MenuAction.GAME_OBJECT_FIFTH_OPTION
|
||||
|| action == MenuAction.WIDGET_TARGET_ON_GAME_OBJECT && client.getSelectedWidget().getId() == WidgetInfo.INVENTORY.getId())
|
||||
{
|
||||
lastGameObjectClicked = menuOptionClicked.getId();
|
||||
}
|
||||
|
||||
@@ -77,7 +77,11 @@ public class CrowdsourcingZMI
|
||||
public void onMenuOptionClicked(MenuOptionClicked menuOptionClicked)
|
||||
{
|
||||
MenuAction action = menuOptionClicked.getMenuAction();
|
||||
|
||||
if (menuOptionClicked.isItemOp())
|
||||
{
|
||||
illegalActionTick = client.getTickCount();
|
||||
return;
|
||||
}
|
||||
switch (action)
|
||||
{
|
||||
case ITEM_FIRST_OPTION:
|
||||
|
||||
@@ -54,10 +54,7 @@ import lombok.Setter;
|
||||
import lombok.Value;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.GameState;
|
||||
import net.runelite.api.InventoryID;
|
||||
import net.runelite.api.Item;
|
||||
import net.runelite.api.ItemComposition;
|
||||
import net.runelite.api.ItemContainer;
|
||||
import net.runelite.api.ItemID;
|
||||
import net.runelite.api.MenuAction;
|
||||
import net.runelite.api.MenuEntry;
|
||||
@@ -72,6 +69,7 @@ import net.runelite.api.events.ItemQuantityChanged;
|
||||
import net.runelite.api.events.ItemSpawned;
|
||||
import net.runelite.api.events.MenuEntryAdded;
|
||||
import net.runelite.api.events.MenuOptionClicked;
|
||||
import net.runelite.api.widgets.WidgetInfo;
|
||||
import net.runelite.client.Notifier;
|
||||
import net.runelite.client.callback.ClientThread;
|
||||
import net.runelite.client.config.ConfigManager;
|
||||
@@ -688,28 +686,16 @@ public class GroundItemsPlugin extends Plugin
|
||||
@Subscribe
|
||||
public void onMenuOptionClicked(MenuOptionClicked menuOptionClicked)
|
||||
{
|
||||
if (menuOptionClicked.getMenuAction() == MenuAction.ITEM_FIFTH_OPTION)
|
||||
if (menuOptionClicked.isItemOp() && menuOptionClicked.getMenuOption().equals("Drop"))
|
||||
{
|
||||
int itemId = menuOptionClicked.getId();
|
||||
int itemId = menuOptionClicked.getItemId();
|
||||
// Keep a queue of recently dropped items to better detect
|
||||
// item spawns that are drops
|
||||
droppedItemQueue.add(itemId);
|
||||
}
|
||||
else if (menuOptionClicked.getMenuAction() == MenuAction.ITEM_USE_ON_GAME_OBJECT)
|
||||
else if (menuOptionClicked.getMenuAction() == MenuAction.WIDGET_TARGET_ON_GAME_OBJECT && client.getSelectedWidget().getId() == WidgetInfo.INVENTORY.getId())
|
||||
{
|
||||
final ItemContainer inventory = client.getItemContainer(InventoryID.INVENTORY);
|
||||
if (inventory == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final Item clickedItem = inventory.getItem(client.getSelectedItemIndex());
|
||||
if (clickedItem == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
lastUsedItem = clickedItem.getId();
|
||||
lastUsedItem = client.getSelectedWidget().getItemId();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -176,8 +176,11 @@ public class InteractHighlightPlugin extends Plugin
|
||||
// Any menu click which clears an interaction
|
||||
case WALK:
|
||||
case ITEM_USE:
|
||||
case WIDGET_TARGET_ON_WIDGET:
|
||||
case ITEM_USE_ON_GROUND_ITEM:
|
||||
case WIDGET_TARGET_ON_GROUND_ITEM:
|
||||
case ITEM_USE_ON_PLAYER:
|
||||
case WIDGET_TARGET_ON_PLAYER:
|
||||
case ITEM_FIRST_OPTION:
|
||||
case ITEM_SECOND_OPTION:
|
||||
case ITEM_THIRD_OPTION:
|
||||
@@ -190,6 +193,13 @@ public class InteractHighlightPlugin extends Plugin
|
||||
case GROUND_ITEM_FIFTH_OPTION:
|
||||
interactedObject = null;
|
||||
interactedNpc = null;
|
||||
break;
|
||||
default:
|
||||
if (menuOptionClicked.isItemOp())
|
||||
{
|
||||
interactedObject = null;
|
||||
interactedNpc = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -164,42 +164,43 @@ public class InventoryTagsPlugin extends Plugin
|
||||
return;
|
||||
}
|
||||
|
||||
final int widgetId = firstEntry.getParam1();
|
||||
|
||||
// Inventory item menu
|
||||
if (widgetId == WidgetInfo.INVENTORY.getId())
|
||||
final int itemId;
|
||||
if (firstEntry.getType() == MenuAction.WIDGET_TARGET && firstEntry.getWidget().getId() == WidgetInfo.INVENTORY.getId())
|
||||
{
|
||||
int itemId = firstEntry.getIdentifier();
|
||||
itemId = firstEntry.getWidget().getItemId();
|
||||
}
|
||||
else if (firstEntry.isItemOp())
|
||||
{
|
||||
itemId = firstEntry.getItemId();
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (itemId == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
// Set menu to only be Cancel
|
||||
client.setMenuEntries(Arrays.copyOf(client.getMenuEntries(), 1));
|
||||
|
||||
// Set menu to only be Cancel
|
||||
client.setMenuEntries(Arrays.copyOf(client.getMenuEntries(), 1));
|
||||
for (final String groupName : GROUPS)
|
||||
{
|
||||
final String group = getTag(itemId);
|
||||
final Color color = getGroupNameColor(groupName);
|
||||
|
||||
for (final String groupName : GROUPS)
|
||||
{
|
||||
final String group = getTag(itemId);
|
||||
final Color color = getGroupNameColor(groupName);
|
||||
|
||||
client.createMenuEntry(-1)
|
||||
.setOption(groupName.equals(group) ? MENU_REMOVE : MENU_SET)
|
||||
.setTarget(ColorUtil.prependColorTag(groupName, MoreObjects.firstNonNull(color, Color.WHITE)))
|
||||
.setType(MenuAction.RUNELITE)
|
||||
.onClick(e ->
|
||||
client.createMenuEntry(-1)
|
||||
.setOption(groupName.equals(group) ? MENU_REMOVE : MENU_SET)
|
||||
.setTarget(ColorUtil.prependColorTag(groupName, MoreObjects.firstNonNull(color, Color.WHITE)))
|
||||
.setType(MenuAction.RUNELITE)
|
||||
.onClick(e ->
|
||||
{
|
||||
if (e.getOption().equals(MENU_SET))
|
||||
{
|
||||
if (e.getOption().equals(MENU_SET))
|
||||
{
|
||||
setTag(itemId, groupName);
|
||||
}
|
||||
else
|
||||
{
|
||||
unsetTag(itemId);
|
||||
}
|
||||
});
|
||||
}
|
||||
setTag(itemId, groupName);
|
||||
}
|
||||
else
|
||||
{
|
||||
unsetTag(itemId);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -98,11 +98,20 @@ class ItemPricesOverlay extends Overlay
|
||||
// Tooltip action type handling
|
||||
switch (action)
|
||||
{
|
||||
case WIDGET_TARGET_ON_WIDGET:
|
||||
// Check target widget is the inventory
|
||||
if (menuEntry.getWidget().getId() != WidgetInfo.INVENTORY.getId())
|
||||
{
|
||||
break;
|
||||
}
|
||||
// FALLTHROUGH
|
||||
case WIDGET_USE_ON_ITEM:
|
||||
// Require showWhileAlching and Cast High Level Alchemy
|
||||
if (!config.showWhileAlching() || !isAlching)
|
||||
{
|
||||
break;
|
||||
}
|
||||
// FALLTHROUGH
|
||||
case CC_OP:
|
||||
case ITEM_USE:
|
||||
case ITEM_FIRST_OPTION:
|
||||
@@ -110,38 +119,49 @@ class ItemPricesOverlay extends Overlay
|
||||
case ITEM_THIRD_OPTION:
|
||||
case ITEM_FOURTH_OPTION:
|
||||
case ITEM_FIFTH_OPTION:
|
||||
// Item tooltip values
|
||||
switch (groupId)
|
||||
{
|
||||
case WidgetID.EXPLORERS_RING_ALCH_GROUP_ID:
|
||||
if (!config.showWhileAlching())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
case WidgetID.INVENTORY_GROUP_ID:
|
||||
case WidgetID.POH_TREASURE_CHEST_INVENTORY_GROUP_ID:
|
||||
if (config.hideInventory() && !(config.showWhileAlching() && isAlching))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
// intentional fallthrough
|
||||
case WidgetID.BANK_GROUP_ID:
|
||||
case WidgetID.BANK_INVENTORY_GROUP_ID:
|
||||
case WidgetID.SEED_VAULT_GROUP_ID:
|
||||
case WidgetID.SEED_VAULT_INVENTORY_GROUP_ID:
|
||||
// Make tooltip
|
||||
final String text = makeValueTooltip(menuEntry);
|
||||
if (text != null)
|
||||
{
|
||||
tooltipManager.add(new Tooltip(ColorUtil.prependColorTag(text, new Color(238, 238, 238))));
|
||||
}
|
||||
break;
|
||||
}
|
||||
addTooltip(menuEntry, isAlching, groupId);
|
||||
break;
|
||||
case WIDGET_TARGET:
|
||||
// Check that this is the inventory
|
||||
if (menuEntry.getWidget().getId() == WidgetInfo.INVENTORY.getId())
|
||||
{
|
||||
addTooltip(menuEntry, isAlching, groupId);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void addTooltip(MenuEntry menuEntry, boolean isAlching, int groupId)
|
||||
{
|
||||
// Item tooltip values
|
||||
switch (groupId)
|
||||
{
|
||||
case WidgetID.EXPLORERS_RING_ALCH_GROUP_ID:
|
||||
if (!config.showWhileAlching())
|
||||
{
|
||||
return;
|
||||
}
|
||||
case WidgetID.INVENTORY_GROUP_ID:
|
||||
case WidgetID.POH_TREASURE_CHEST_INVENTORY_GROUP_ID:
|
||||
if (config.hideInventory() && (!config.showWhileAlching() || !isAlching))
|
||||
{
|
||||
return;
|
||||
}
|
||||
// FALLTHROUGH
|
||||
case WidgetID.BANK_GROUP_ID:
|
||||
case WidgetID.BANK_INVENTORY_GROUP_ID:
|
||||
case WidgetID.SEED_VAULT_GROUP_ID:
|
||||
case WidgetID.SEED_VAULT_INVENTORY_GROUP_ID:
|
||||
// Make tooltip
|
||||
final String text = makeValueTooltip(menuEntry);
|
||||
if (text != null)
|
||||
{
|
||||
tooltipManager.add(new Tooltip(ColorUtil.prependColorTag(text, new Color(238, 238, 238))));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String makeValueTooltip(MenuEntry menuEntry)
|
||||
{
|
||||
// Disabling both disables all value tooltips
|
||||
|
||||
@@ -971,19 +971,19 @@ public class LootTrackerPlugin extends Plugin
|
||||
{
|
||||
onInvChange(collectInvAndGroundItems(LootRecordType.EVENT, SHADE_CHEST_OBJECTS.get(event.getId())));
|
||||
}
|
||||
else if (isItemOp(event.getMenuAction()))
|
||||
else if (event.isItemOp())
|
||||
{
|
||||
if (event.getMenuOption().equals("Take") && event.getId() == ItemID.SEED_PACK)
|
||||
if (event.getMenuOption().equals("Take") && event.getItemId() == ItemID.SEED_PACK)
|
||||
{
|
||||
onInvChange(collectInvItems(LootRecordType.EVENT, SEEDPACK_EVENT));
|
||||
}
|
||||
else if (event.getMenuOption().equals("Search") && BIRDNEST_IDS.contains(event.getId()))
|
||||
else if (event.getMenuOption().equals("Search") && BIRDNEST_IDS.contains(event.getItemId()))
|
||||
{
|
||||
onInvChange(collectInvItems(LootRecordType.EVENT, BIRDNEST_EVENT));
|
||||
}
|
||||
else if (event.getMenuOption().equals("Open"))
|
||||
{
|
||||
switch (event.getId())
|
||||
switch (event.getItemId())
|
||||
{
|
||||
case ItemID.CASKET:
|
||||
onInvChange(collectInvItems(LootRecordType.EVENT, CASKET_EVENT));
|
||||
@@ -1004,7 +1004,7 @@ public class LootTrackerPlugin extends Plugin
|
||||
case ItemID.SIMPLE_LOCKBOX_25647:
|
||||
case ItemID.ELABORATE_LOCKBOX_25649:
|
||||
case ItemID.ORNATE_LOCKBOX_25651:
|
||||
onInvChange(collectInvAndGroundItems(LootRecordType.EVENT, itemManager.getItemComposition(event.getId()).getName()));
|
||||
onInvChange(collectInvAndGroundItems(LootRecordType.EVENT, itemManager.getItemComposition(event.getItemId()).getName()));
|
||||
break;
|
||||
case ItemID.SUPPLY_CRATE_24884:
|
||||
onInvChange(collectInvItems(LootRecordType.EVENT, MAHOGANY_CRATE_EVENT, client.getBoostedSkillLevel(Skill.CONSTRUCTION)));
|
||||
@@ -1014,14 +1014,14 @@ public class LootTrackerPlugin extends Plugin
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (event.getMenuOption().equals("Loot") && IMPLING_JARS.contains(event.getId()))
|
||||
else if (event.getMenuOption().equals("Loot") && IMPLING_JARS.contains(event.getItemId()))
|
||||
{
|
||||
onInvChange(((invItems, groundItems, removedItems) ->
|
||||
{
|
||||
int cnt = removedItems.count(event.getId());
|
||||
int cnt = removedItems.count(event.getItemId());
|
||||
if (cnt > 0)
|
||||
{
|
||||
String name = itemManager.getItemComposition(event.getId()).getName();
|
||||
String name = itemManager.getItemComposition(event.getItemId()).getName();
|
||||
addLoot(name, -1, LootRecordType.EVENT, null, invItems, cnt);
|
||||
}
|
||||
}));
|
||||
@@ -1038,12 +1038,6 @@ public class LootTrackerPlugin extends Plugin
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isItemOp(MenuAction menuAction)
|
||||
{
|
||||
final int id = menuAction.getId();
|
||||
return id >= MenuAction.ITEM_FIRST_OPTION.getId() && id <= MenuAction.ITEM_FIFTH_OPTION.getId();
|
||||
}
|
||||
|
||||
private static boolean isNPCOp(MenuAction menuAction)
|
||||
{
|
||||
final int id = menuAction.getId();
|
||||
|
||||
@@ -132,15 +132,6 @@ public class MenuEntrySwapperPlugin extends Plugin
|
||||
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(
|
||||
MenuAction.ITEM_FIRST_OPTION,
|
||||
MenuAction.ITEM_SECOND_OPTION,
|
||||
MenuAction.ITEM_THIRD_OPTION,
|
||||
MenuAction.ITEM_FOURTH_OPTION,
|
||||
MenuAction.ITEM_FIFTH_OPTION,
|
||||
MenuAction.ITEM_USE
|
||||
);
|
||||
|
||||
private static final List<MenuAction> NPC_MENU_TYPES = ImmutableList.of(
|
||||
MenuAction.NPC_FIRST_OPTION,
|
||||
MenuAction.NPC_SECOND_OPTION,
|
||||
@@ -536,25 +527,27 @@ public class MenuEntrySwapperPlugin extends Plugin
|
||||
return;
|
||||
}
|
||||
|
||||
MenuEntry firstEntry = event.getFirstEntry();
|
||||
final MenuEntry firstEntry = event.getFirstEntry();
|
||||
if (firstEntry == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int widgetId = firstEntry.getParam1();
|
||||
if (widgetId != WidgetInfo.INVENTORY.getId())
|
||||
final int itemId;
|
||||
if (firstEntry.getType() == MenuAction.WIDGET_TARGET && firstEntry.getWidget().getId() == WidgetInfo.INVENTORY.getId())
|
||||
{
|
||||
itemId = firstEntry.getWidget().getItemId();
|
||||
}
|
||||
else if (firstEntry.isItemOp())
|
||||
{
|
||||
itemId = firstEntry.getItemId();
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int itemId = firstEntry.getIdentifier();
|
||||
if (itemId == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
MenuAction activeAction = null;
|
||||
int activeOp = 0;
|
||||
final ItemComposition itemComposition = itemManager.getItemComposition(itemId);
|
||||
|
||||
if (configuringShiftClick)
|
||||
@@ -565,7 +558,7 @@ public class MenuEntrySwapperPlugin extends Plugin
|
||||
|
||||
if (shiftClickActionIndex >= 0)
|
||||
{
|
||||
activeAction = MenuAction.of(MenuAction.ITEM_FIRST_OPTION.getId() + shiftClickActionIndex);
|
||||
activeOp = 1 + shiftClickActionIndex;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -573,7 +566,7 @@ public class MenuEntrySwapperPlugin extends Plugin
|
||||
Integer config = getItemSwapConfig(true, itemId);
|
||||
if (config != null && config == -1)
|
||||
{
|
||||
activeAction = MenuAction.ITEM_USE;
|
||||
activeOp = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -583,9 +576,9 @@ public class MenuEntrySwapperPlugin extends Plugin
|
||||
Integer config = getItemSwapConfig(false, itemId);
|
||||
if (config != null)
|
||||
{
|
||||
activeAction = config >= 0
|
||||
? MenuAction.of(MenuAction.ITEM_FIRST_OPTION.getId() + config)
|
||||
: MenuAction.ITEM_USE;
|
||||
activeOp = config >= 0
|
||||
? 1 + config
|
||||
: -1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -593,20 +586,31 @@ public class MenuEntrySwapperPlugin extends Plugin
|
||||
|
||||
for (MenuEntry entry : entries)
|
||||
{
|
||||
final MenuAction menuAction = entry.getType();
|
||||
|
||||
if (ITEM_MENU_TYPES.contains(menuAction) && entry.getIdentifier() == itemId)
|
||||
if (entry.getType() == MenuAction.WIDGET_TARGET && entry.getWidget().getId() == WidgetInfo.INVENTORY.getId() && entry.getWidget().getItemId() == itemId)
|
||||
{
|
||||
entry.setType(MenuAction.RUNELITE);
|
||||
entry.onClick(e ->
|
||||
{
|
||||
int index = menuAction == MenuAction.ITEM_USE
|
||||
? -1
|
||||
: menuAction.getId() - MenuAction.ITEM_FIRST_OPTION.getId();
|
||||
setItemSwapConfig(configuringShiftClick, itemId, index);
|
||||
log.debug("Set {} item swap for {} to USE", configuringShiftClick ? "shift" : "left", itemId);
|
||||
setItemSwapConfig(configuringShiftClick, itemId, -1);
|
||||
});
|
||||
|
||||
if (activeAction == menuAction)
|
||||
if (activeOp == -1)
|
||||
{
|
||||
entry.setOption("* " + entry.getOption());
|
||||
}
|
||||
}
|
||||
else if (entry.isItemOp() && entry.getItemId() == itemId)
|
||||
{
|
||||
final int itemOp = entry.getItemOp();
|
||||
entry.setType(MenuAction.RUNELITE);
|
||||
entry.onClick(e ->
|
||||
{
|
||||
log.debug("Set {} item swap config for {} to {}", configuringShiftClick ? "shift" : "left", itemId, itemOp - 1);
|
||||
setItemSwapConfig(configuringShiftClick, itemId, itemOp - 1);
|
||||
});
|
||||
|
||||
if (itemOp == activeOp)
|
||||
{
|
||||
entry.setOption("* " + entry.getOption());
|
||||
}
|
||||
@@ -885,19 +889,15 @@ public class MenuEntrySwapperPlugin extends Plugin
|
||||
return;
|
||||
}
|
||||
|
||||
final boolean itemOp = menuAction == MenuAction.ITEM_FIRST_OPTION
|
||||
|| menuAction == MenuAction.ITEM_SECOND_OPTION
|
||||
|| menuAction == MenuAction.ITEM_THIRD_OPTION
|
||||
|| menuAction == MenuAction.ITEM_FOURTH_OPTION
|
||||
|| menuAction == MenuAction.ITEM_FIFTH_OPTION
|
||||
|| menuAction == MenuAction.ITEM_USE;
|
||||
final boolean itemOp = menuEntry.isItemOp();
|
||||
// Custom shift-click item swap
|
||||
if (shiftModifier() && itemOp)
|
||||
{
|
||||
// Special case use shift click due to items not actually containing a "Use" option, making
|
||||
// the client unable to perform the swap itself.
|
||||
if (config.shiftClickCustomization() && !option.equals("use"))
|
||||
{
|
||||
Integer customOption = getItemSwapConfig(true, eventId);
|
||||
Integer customOption = getItemSwapConfig(true, menuEntry.getItemId());
|
||||
|
||||
if (customOption != null && customOption == -1)
|
||||
{
|
||||
@@ -913,14 +913,18 @@ public class MenuEntrySwapperPlugin extends Plugin
|
||||
// Custom left-click item swap
|
||||
if (itemOp)
|
||||
{
|
||||
Integer swapIndex = getItemSwapConfig(false, eventId);
|
||||
Integer swapIndex = getItemSwapConfig(false, menuEntry.getItemId());
|
||||
if (swapIndex != null)
|
||||
{
|
||||
MenuAction swapAction = swapIndex >= 0
|
||||
? MenuAction.of(MenuAction.ITEM_FIRST_OPTION.getId() + swapIndex)
|
||||
: MenuAction.ITEM_USE;
|
||||
final int swapAction = swapIndex >= 0
|
||||
? 1 + swapIndex
|
||||
: -1;
|
||||
|
||||
if (menuAction == swapAction)
|
||||
if (swapAction == -1)
|
||||
{
|
||||
swap(menuEntries, "use", target, index, true);
|
||||
}
|
||||
else if (swapAction == menuEntry.getItemOp())
|
||||
{
|
||||
swap(optionIndexes, menuEntries, index, menuEntries.length - 1);
|
||||
}
|
||||
|
||||
@@ -43,6 +43,10 @@ public class TestMenuEntry implements MenuEntry
|
||||
private int param1;
|
||||
private boolean forceLeftClick;
|
||||
@Setter
|
||||
private int itemOp = -1;
|
||||
@Setter
|
||||
private int itemId = -1;
|
||||
@Setter
|
||||
private Widget widget;
|
||||
|
||||
@Override
|
||||
@@ -169,6 +173,24 @@ public class TestMenuEntry implements MenuEntry
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemOp()
|
||||
{
|
||||
return itemOp != -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemOp()
|
||||
{
|
||||
return itemOp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemId()
|
||||
{
|
||||
return itemId;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Widget getWidget()
|
||||
|
||||
Reference in New Issue
Block a user