Merge pull request #3161 from open-osrs/upstream-2004

This commit is contained in:
Owain van Brakel
2022-04-20 20:25:26 +02:00
committed by GitHub
48 changed files with 1039 additions and 580 deletions

View File

@@ -25,9 +25,9 @@
object ProjectVersions { object ProjectVersions {
const val launcherVersion = "2.2.0" const val launcherVersion = "2.2.0"
const val rlVersion = "1.8.17" const val rlVersion = "1.8.18"
const val openosrsVersion = "4.23.0" const val openosrsVersion = "4.24.0"
const val rsversion = 204 const val rsversion = 204
const val cacheversion = 165 const val cacheversion = 165

View File

@@ -54,7 +54,7 @@ public class CopyRuneLiteClasses extends AbstractInjector
{ {
ClassFile runeliteObjectVanilla = inject.vanilla.findClass(className); ClassFile runeliteObjectVanilla = inject.vanilla.findClass(className);
final ClassFile runeLiteObjectDeob = inject.getDeobfuscated() final ClassFile runeLiteDeob = inject.getDeobfuscated()
.findClass(className); .findClass(className);
if (runeliteObjectVanilla == null) if (runeliteObjectVanilla == null)
@@ -62,11 +62,11 @@ public class CopyRuneLiteClasses extends AbstractInjector
runeliteObjectVanilla = new ClassFile(inject.vanilla); runeliteObjectVanilla = new ClassFile(inject.vanilla);
runeliteObjectVanilla.setVersion(Opcodes.V1_8); runeliteObjectVanilla.setVersion(Opcodes.V1_8);
runeliteObjectVanilla.setName(className); runeliteObjectVanilla.setName(className);
runeliteObjectVanilla.setAccess(runeLiteObjectDeob.getAccess()); runeliteObjectVanilla.setAccess(runeLiteDeob.getAccess());
if (runeLiteObjectDeob.getParentClass() != null) if (runeLiteDeob.getParentClass() != null)
{ {
ClassFile deobClass = inject.getDeobfuscated().findClass(runeLiteObjectDeob.getParentClass().getName()); ClassFile deobClass = inject.getDeobfuscated().findClass(runeLiteDeob.getParentClass().getName());
if (deobClass != null) if (deobClass != null)
{ {
@@ -74,25 +74,30 @@ public class CopyRuneLiteClasses extends AbstractInjector
} }
else else
{ {
runeliteObjectVanilla.setParentClass(runeLiteObjectDeob.getParentClass()); runeliteObjectVanilla.setParentClass(runeLiteDeob.getParentClass());
} }
} }
inject.toVanilla.put(runeLiteObjectDeob, runeliteObjectVanilla); inject.toVanilla.put(runeLiteDeob, runeliteObjectVanilla);
for (Class interfaze : runeLiteObjectDeob.getInterfaces()) for (Class interfaze : runeLiteDeob.getInterfaces())
{ {
runeliteObjectVanilla.getInterfaces().addInterface(interfaze); runeliteObjectVanilla.getInterfaces().addInterface(interfaze);
} }
for (Field field : runeLiteObjectDeob.getFields()) for (Field field : runeLiteDeob.getFields())
{ {
field.setType(InjectUtil.deobToVanilla(inject, field.getType())); field.setType(InjectUtil.deobToVanilla(inject, field.getType()));
runeliteObjectVanilla.addField(field); runeliteObjectVanilla.addField(field);
} }
for (Method method : runeLiteObjectDeob.getMethods()) for (Method method : runeLiteDeob.getMethods())
{ {
if (className.equals("RuneLiteMenuEntry") && (method.getName().equals("getItemId") || method.getName().equals("getWidget")))
{
continue;
}
transformMethod(method); transformMethod(method);
runeliteObjectVanilla.addMethod(method); runeliteObjectVanilla.addMethod(method);
} }

View File

@@ -573,6 +573,14 @@ public interface Client extends OAuthApi, GameEngine
*/ */
void setDraggedOnWidget(Widget widget); void setDraggedOnWidget(Widget widget);
/**
* Get the number of client cycles the current dragged widget
* has been dragged for.
*
* @return
*/
int getDragTime();
/** /**
* Gets Interface ID of the root widget * Gets Interface ID of the root widget
*/ */
@@ -2084,6 +2092,13 @@ public interface Client extends OAuthApi, GameEngine
*/ */
int getSelectedItemIndex(); int getSelectedItemIndex();
/**
* Get the selected widget, such as a selected spell or selected item (eg. "Use")
* @return the selected widget
*/
@Nullable
Widget getSelectedWidget();
/** /**
* Returns client item composition cache * Returns client item composition cache
*/ */

View File

@@ -37,9 +37,9 @@ public enum MenuAction
*/ */
ITEM_USE_ON_GAME_OBJECT(1), ITEM_USE_ON_GAME_OBJECT(1),
/** /**
* Menu action for casting a spell on a tile object (GameObject or GroundObject). * Menu action for using a widget on a tile object (GameObject or GroundObject).
*/ */
SPELL_CAST_ON_GAME_OBJECT(2), WIDGET_TARGET_ON_GAME_OBJECT(2),
/** /**
* First menu action for a game object. * First menu action for a game object.
*/ */
@@ -66,9 +66,9 @@ public enum MenuAction
*/ */
ITEM_USE_ON_NPC(7), ITEM_USE_ON_NPC(7),
/** /**
* Menu action for casting a spell on an NPC. * Menu action for using a widget on an NPC.
*/ */
SPELL_CAST_ON_NPC(8), WIDGET_TARGET_ON_NPC(8),
/** /**
* First menu action for an NPC. * First menu action for an NPC.
*/ */
@@ -95,18 +95,18 @@ public enum MenuAction
*/ */
ITEM_USE_ON_PLAYER(14), ITEM_USE_ON_PLAYER(14),
/** /**
* Menu action for casting a spell on a player. * Menu action for using a widget on a player.
*/ */
SPELL_CAST_ON_PLAYER(15), WIDGET_TARGET_ON_PLAYER(15),
/** /**
* Menu action for using an item on an item on the ground. * Menu action for using an item on an item on the ground.
*/ */
ITEM_USE_ON_GROUND_ITEM(16), ITEM_USE_ON_GROUND_ITEM(16),
/** /**
* Menu action for casting a spell on an item on the ground. * Menu action for using a widget on an item on the ground.
*/ */
SPELL_CAST_ON_GROUND_ITEM(17), WIDGET_TARGET_ON_GROUND_ITEM(17),
/** /**
* First menu action for an item on the ground. * First menu action for an item on the ground.
*/ */
@@ -138,13 +138,14 @@ public enum MenuAction
*/ */
WIDGET_TYPE_1(24), WIDGET_TYPE_1(24),
/** /**
* Interaction with widget (type 2). * Select the widget for targeting other widgets/entites etc.
* @see Client#getSelectedWidget()
*/ */
WIDGET_TYPE_2(25), WIDGET_TARGET(25),
/** /**
* Interaction with widget (type 3). * Performs an ifclose.
*/ */
WIDGET_TYPE_3(26), WIDGET_CLOSE(26),
/** /**
* Interaction with widget (type 4). * Interaction with widget (type 4).
*/ */
@@ -154,19 +155,17 @@ public enum MenuAction
*/ */
WIDGET_TYPE_5(29), WIDGET_TYPE_5(29),
/** /**
* Interaction with widget (type 6). * Performs a Continue
*
* This is the continue button on message boxes
*/ */
WIDGET_TYPE_6(30), WIDGET_CONTINUE(30),
/** /**
* Menu action when using an item on another item inside a widget (inventory). * Menu action when using an item on another item
*/ */
ITEM_USE_ON_WIDGET_ITEM(31), ITEM_USE_ON_ITEM(31),
/** /**
* Menu action when using an item on a widget. * Menu action when using a component on an item
*/ */
ITEM_USE_ON_WIDGET(32), WIDGET_USE_ON_ITEM(32),
/** /**
* First menu action for an item. * First menu action for an item.
@@ -229,20 +228,15 @@ public enum MenuAction
CC_OP(57), CC_OP(57),
/** /**
* Casting a spell / op target on a widget * Using a widget on another widget
*/ */
SPELL_CAST_ON_WIDGET(58), WIDGET_TARGET_ON_WIDGET(58),
/** /**
* Menu action for high priority runelite options * Menu action for high priority runelite options
*/ */
RUNELITE_HIGH_PRIORITY(999), RUNELITE_HIGH_PRIORITY(999),
/**
* Sub 1000 so it doesn't get sorted down in the list
*/
PRIO_RUNELITE(666),
/** /**
* Menu action triggered by examining an object. * Menu action triggered by examining an object.
*/ */
@@ -289,8 +283,13 @@ public enum MenuAction
* Menu action for InfoBox menu entries * Menu action for InfoBox menu entries
*/ */
RUNELITE_INFOBOX(1504), RUNELITE_INFOBOX(1504),
/**
* Menu action triggered by following a player.
*/
FOLLOW(2046), FOLLOW(2046),
/**
* Menu action triggered by sending a trade offer to a player.
*/
TRADE(2047), TRADE(2047),
/** /**
@@ -326,4 +325,4 @@ public enum MenuAction
{ {
return map.getOrDefault(id, UNKNOWN); return map.getOrDefault(id, UNKNOWN);
} }
} }

View File

@@ -25,6 +25,8 @@
package net.runelite.api; package net.runelite.api;
import java.util.function.Consumer; import java.util.function.Consumer;
import javax.annotation.Nullable;
import net.runelite.api.widgets.Widget;
/** /**
* A menu entry in a right-click menu. * A menu entry in a right-click menu.
@@ -93,6 +95,34 @@ public interface MenuEntry
*/ */
MenuEntry onClick(Consumer<MenuEntry> callback); MenuEntry onClick(Consumer<MenuEntry> callback);
/**
* Test if this menu entry is an item op. "Use" and "Examine" are not considered item ops.
* @return
*/
boolean isItemOp();
/**
* If this menu entry is an item op, get the item op id
* @return 1-5
*/
int getItemOp();
/**
* If this menu entry is an item op, get the item id
* @return
* @see ItemID
* @see NullItemID
*/
int getItemId();
/**
* Get the widget this menu entry is on, if this is a menu entry
* with an associated widget. Such as eg, CC_OP.
* @return
*/
@Nullable
Widget getWidget();
@Deprecated @Deprecated
int getOpcode(); int getOpcode();
@Deprecated @Deprecated

View File

@@ -449,4 +449,7 @@ public final class ScriptID
@ScriptArguments(integer = 7) @ScriptArguments(integer = 7)
public static final int GROUP_IRONMAN_STORAGE_BUILD = 5269; public static final int GROUP_IRONMAN_STORAGE_BUILD = 5269;
@ScriptArguments(integer = 6)
public static final int INVENTORY_DRAWITEM = 6011;
} }

View File

@@ -24,9 +24,12 @@
*/ */
package net.runelite.api.events; package net.runelite.api.events;
import lombok.Data; import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import net.runelite.api.MenuAction; import net.runelite.api.MenuAction;
import net.runelite.api.MenuEntry; import net.runelite.api.MenuEntry;
import net.runelite.api.widgets.Widget;
/** /**
* An event where a menu option has been clicked. * An event where a menu option has been clicked.
@@ -39,42 +42,137 @@ import net.runelite.api.MenuEntry;
* By default, when there is no action performed when left-clicking, * By default, when there is no action performed when left-clicking,
* it seems that this event still triggers with the "Cancel" action. * it seems that this event still triggers with the "Cancel" action.
*/ */
@Data @RequiredArgsConstructor
public class MenuOptionClicked public class MenuOptionClicked
{ {
/** /**
* Action parameter 0. Its value depends on the menuAction. * The clicked menu entry
*/ */
private int param0; private final MenuEntry menuEntry;
/**
* Action parameter 1. Its value depends on the menuAction.
*/
private int param1;
/**
* The option text added to the menu.
*/
private String menuOption;
/**
* The target of the action.
*/
private String menuTarget;
/**
* The action performed.
*/
private MenuAction menuAction;
/**
* The ID of the object, actor, or item that the interaction targets.
*/
private int id;
/**
* The selected item index at the time of the option click.
*/
private int selectedItemIndex;
/** /**
* Whether or not the event has been consumed by a subscriber. * Whether or not the event has been consumed by a subscriber.
*/ */
@Getter
@Setter
private boolean consumed; private boolean consumed;
/**
* Action parameter 0. Its value depends on the menuAction.
*/
public int getParam0()
{
return menuEntry.getParam0();
}
public void setParam0(int param0)
{
menuEntry.setParam0(param0);
}
/**
* Action parameter 1. Its value depends on the menuAction.
*/
public int getParam1()
{
return menuEntry.getParam1();
}
public void setParam1(int param1)
{
menuEntry.setParam1(param1);
}
/**
* The option text added to the menu.
*/
public String getMenuOption()
{
return menuEntry.getOption();
}
public void setMenuOption(String menuOption)
{
menuEntry.setOption(menuOption);
}
/**
* The target of the action.
*/
public String getMenuTarget()
{
return menuEntry.getTarget();
}
public void setMenuTarget(String menuTarget)
{
menuEntry.setOption(menuTarget);
}
/**
* The action performed.
*/
public MenuAction getMenuAction()
{
return menuEntry.getType();
}
public void setMenuAction(MenuAction menuAction)
{
menuEntry.setType(menuAction);
}
/**
* The ID of the object, actor, or item that the interaction targets.
*/
public int getId()
{
return menuEntry.getIdentifier();
}
public void setId(int id)
{
menuEntry.setIdentifier(id);
}
/**
* Test if this menu entry is an item op. "Use" and "Examine" are not considered item ops.
* @return
*/
public boolean isItemOp()
{
return menuEntry.isItemOp();
}
/**
* If this menu entry is an item op, get the item op id
* @return 1-5
*/
public int getItemOp()
{
return menuEntry.getItemOp();
}
/**
* If this menu entry is an item op, get the item id
* @return
* @see net.runelite.api.ItemID
* @see net.runelite.api.NullItemID
*/
public int getItemId()
{
return menuEntry.getItemId();
}
/**
* Get the widget this menu entry is on, if this is a menu entry
* with an associated widget. Such as eg, CC_OP.
* @return
*/
public Widget getWidget()
{
return menuEntry.getWidget();
}
/** /**
* Marks the event as having been consumed. * Marks the event as having been consumed.
* <p> * <p>
@@ -87,6 +185,32 @@ public class MenuOptionClicked
this.consumed = true; this.consumed = true;
} }
@Deprecated
public int getActionParam()
{
return menuEntry.getParam0();
}
@Deprecated
public void setActionParam(int actionParam)
{
menuEntry.setParam0(actionParam);
}
@Deprecated
public int getWidgetId()
{
return menuEntry.getParam1();
}
@Deprecated
public void setWidgetId(int widgetId)
{
menuEntry.setParam1(widgetId);
}
@Deprecated
public void setMenuEntry(MenuEntry entry) public void setMenuEntry(MenuEntry entry)
{ {
this.setMenuOption(entry.getOption()); this.setMenuOption(entry.getOption());
@@ -96,28 +220,4 @@ public class MenuOptionClicked
this.setParam0(entry.getParam0()); this.setParam0(entry.getParam0());
this.setParam1(entry.getParam1()); this.setParam1(entry.getParam1());
} }
}
@Deprecated
public int getActionParam()
{
return param0;
}
@Deprecated
public void setActionParam(int i)
{
param0 = i;
}
@Deprecated
public int getWidgetId()
{
return param1;
}
@Deprecated
public void setWidgetId(int i)
{
param1 = i;
}
}

View File

@@ -45,8 +45,7 @@ public class InventoryWidgetItemQuery extends WidgetItemQuery
WidgetInfo.SHOP_INVENTORY_ITEMS_CONTAINER, WidgetInfo.SHOP_INVENTORY_ITEMS_CONTAINER,
WidgetInfo.GRAND_EXCHANGE_INVENTORY_ITEMS_CONTAINER, WidgetInfo.GRAND_EXCHANGE_INVENTORY_ITEMS_CONTAINER,
WidgetInfo.GUIDE_PRICES_INVENTORY_ITEMS_CONTAINER, WidgetInfo.GUIDE_PRICES_INVENTORY_ITEMS_CONTAINER,
WidgetInfo.EQUIPMENT_INVENTORY_ITEMS_CONTAINER, WidgetInfo.EQUIPMENT_INVENTORY_ITEMS_CONTAINER
WidgetInfo.INVENTORY
}; };
@Override @Override
@@ -69,36 +68,29 @@ public class InventoryWidgetItemQuery extends WidgetItemQuery
{ {
continue; continue;
} }
if (widgetInfo == WidgetInfo.INVENTORY)
{
widgetItems.addAll(inventory.getWidgetItems());
break;
}
else
{
Widget[] children = inventory.getDynamicChildren();
for (int i = 0; i < children.length; i++)
{
Widget child = children[i];
boolean isDragged = child.isWidgetItemDragged(child.getItemId());
int dragOffsetX = 0;
int dragOffsetY = 0;
if (isDragged) Widget[] children = inventory.getDynamicChildren();
{ for (int i = 0; i < children.length; i++)
Point p = child.getWidgetItemDragOffsets(); {
dragOffsetX = p.getX(); Widget child = children[i];
dragOffsetY = p.getY(); boolean isDragged = child.isWidgetItemDragged(child.getItemId());
} int dragOffsetX = 0;
// set bounds to same size as default inventory int dragOffsetY = 0;
Rectangle bounds = child.getBounds();
bounds.setBounds(bounds.x - 1, bounds.y - 1, 32, 32); if (isDragged)
Rectangle dragBounds = child.getBounds(); {
dragBounds.setBounds(bounds.x + dragOffsetX, bounds.y + dragOffsetY, 32, 32); Point p = child.getWidgetItemDragOffsets();
widgetItems.add(new WidgetItem(child.getItemId(), child.getItemQuantity(), i, bounds, child, dragBounds)); dragOffsetX = p.getX();
dragOffsetY = p.getY();
} }
break; // set bounds to same size as default inventory
Rectangle bounds = child.getBounds();
bounds.setBounds(bounds.x - 1, bounds.y - 1, 32, 32);
Rectangle dragBounds = child.getBounds();
dragBounds.setBounds(bounds.x + dragOffsetX, bounds.y + dragOffsetY, 32, 32);
widgetItems.add(new WidgetItem(child.getItemId(), child.getItemQuantity(), i, bounds, child, dragBounds));
} }
break;
} }
return widgetItems; return widgetItems;
} }

View File

@@ -112,7 +112,7 @@ public class PvPUtil
{ {
wildernessLevel += 15; wildernessLevel += 15;
} }
if (client.getVar(Varbits.IN_WILDERNESS) == 1) if (client.getVarbitValue(Varbits.IN_WILDERNESS) == 1)
{ {
wildernessLevel += getWildernessLevelFrom(client.getLocalPlayer().getWorldLocation()); wildernessLevel += getWildernessLevelFrom(client.getLocalPlayer().getWorldLocation());
} }

View File

@@ -137,7 +137,7 @@ public class RuneLiteProperties
public static HttpUrl getPluginHubBase() public static HttpUrl getPluginHubBase()
{ {
String version = System.getProperty(PLUGINHUB_VERSION, properties.getProperty(PLUGINHUB_VERSION)); String version = System.getProperty(PLUGINHUB_VERSION, properties.getProperty(PLUGINHUB_VERSION));
return HttpUrl.parse(properties.get(PLUGINHUB_BASE) + "/" + version); return HttpUrl.get(properties.get(PLUGINHUB_BASE) + "/" + version);
} }
public static String getApiBase() public static String getApiBase()

View File

@@ -50,7 +50,7 @@ import okhttp3.Response;
@Slf4j @Slf4j
public class ConfigClient public class ConfigClient
{ {
private static final MediaType TEXT_PLAIN = MediaType.parse("text/plain"); private static final MediaType TEXT_PLAIN = MediaType.get("text/plain");
private static final Gson GSON = RuneLiteAPI.GSON; private static final Gson GSON = RuneLiteAPI.GSON;
private final OkHttpClient client; private final OkHttpClient client;

View File

@@ -111,7 +111,7 @@ public class ExternalPluginClient
} }
catch (NoSuchAlgorithmException | InvalidKeyException | SignatureException e) catch (NoSuchAlgorithmException | InvalidKeyException | SignatureException e)
{ {
throw new RuntimeException(e); throw new VerificationException(e);
} }
} }

View File

@@ -27,9 +27,12 @@ package net.runelite.client.plugins.antidrag;
import com.google.inject.Provides; import com.google.inject.Provides;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
import javax.inject.Inject; import javax.inject.Inject;
import lombok.extern.slf4j.Slf4j;
import net.runelite.api.Client; import net.runelite.api.Client;
import net.runelite.api.GameState; import net.runelite.api.GameState;
import net.runelite.api.ScriptID;
import net.runelite.api.events.FocusChanged; import net.runelite.api.events.FocusChanged;
import net.runelite.api.events.ScriptPostFired;
import net.runelite.api.events.WidgetLoaded; import net.runelite.api.events.WidgetLoaded;
import net.runelite.api.widgets.Widget; import net.runelite.api.widgets.Widget;
import net.runelite.api.widgets.WidgetID; import net.runelite.api.widgets.WidgetID;
@@ -49,6 +52,7 @@ import net.runelite.client.plugins.PluginDescriptor;
tags = {"antidrag", "delay", "inventory", "items"}, tags = {"antidrag", "delay", "inventory", "items"},
enabledByDefault = false enabledByDefault = false
) )
@Slf4j
public class AntiDragPlugin extends Plugin implements KeyListener public class AntiDragPlugin extends Plugin implements KeyListener
{ {
static final String CONFIG_GROUP = "antiDrag"; static final String CONFIG_GROUP = "antiDrag";
@@ -136,6 +140,11 @@ public class AntiDragPlugin extends Plugin implements KeyListener
} }
} }
private boolean isOverriding()
{
return (!config.onShiftOnly() || shiftHeld) && !ctrlHeld;
}
@Subscribe @Subscribe
public void onConfigChanged(ConfigChanged event) public void onConfigChanged(ConfigChanged event)
{ {
@@ -176,12 +185,52 @@ public class AntiDragPlugin extends Plugin implements KeyListener
@Subscribe @Subscribe
public void onWidgetLoaded(WidgetLoaded widgetLoaded) public void onWidgetLoaded(WidgetLoaded widgetLoaded)
{ {
if ((widgetLoaded.getGroupId() == WidgetID.BANK_GROUP_ID || if (!isOverriding())
{
return;
}
if (widgetLoaded.getGroupId() == WidgetID.BANK_GROUP_ID ||
widgetLoaded.getGroupId() == WidgetID.BANK_INVENTORY_GROUP_ID || widgetLoaded.getGroupId() == WidgetID.BANK_INVENTORY_GROUP_ID ||
widgetLoaded.getGroupId() == WidgetID.DEPOSIT_BOX_GROUP_ID) && (!config.onShiftOnly() || shiftHeld) && !ctrlHeld) widgetLoaded.getGroupId() == WidgetID.DEPOSIT_BOX_GROUP_ID)
{ {
setBankDragDelay(config.dragDelay()); setBankDragDelay(config.dragDelay());
} }
else if (widgetLoaded.getGroupId() == WidgetID.INVENTORY_GROUP_ID)
{
setInvDragDelay(config.dragDelay());
}
}
@Subscribe
private void onScriptPostFired(ScriptPostFired ev)
{
if (ev.getScriptId() == ScriptID.INVENTORY_DRAWITEM)
{
Widget inv = client.getWidget(WidgetInfo.INVENTORY);
final int delay = config.dragDelay();
boolean overriding = isOverriding();
for (Widget child : inv.getDynamicChildren())
{
// disable [clientscript,inventory_antidrag_update] listener
child.setOnMouseRepeatListener((Object[]) null);
if (overriding)
{
child.setDragDeadTime(delay);
}
}
}
}
private static void applyDragDelay(Widget widget, int delay)
{
if (widget != null)
{
for (Widget item : widget.getDynamicChildren())
{
item.setDragDeadTime(delay);
}
}
} }
private void setBankDragDelay(int delay) private void setBankDragDelay(int delay)
@@ -189,41 +238,32 @@ public class AntiDragPlugin extends Plugin implements KeyListener
final Widget bankItemContainer = client.getWidget(WidgetInfo.BANK_ITEM_CONTAINER); final Widget bankItemContainer = client.getWidget(WidgetInfo.BANK_ITEM_CONTAINER);
final Widget bankInventoryItemsContainer = client.getWidget(WidgetInfo.BANK_INVENTORY_ITEMS_CONTAINER); final Widget bankInventoryItemsContainer = client.getWidget(WidgetInfo.BANK_INVENTORY_ITEMS_CONTAINER);
final Widget bankDepositContainer = client.getWidget(WidgetInfo.DEPOSIT_BOX_INVENTORY_ITEMS_CONTAINER); final Widget bankDepositContainer = client.getWidget(WidgetInfo.DEPOSIT_BOX_INVENTORY_ITEMS_CONTAINER);
if (bankItemContainer != null)
{ applyDragDelay(bankItemContainer, delay);
Widget[] items = bankItemContainer.getDynamicChildren(); applyDragDelay(bankInventoryItemsContainer, delay);
for (Widget item : items) applyDragDelay(bankDepositContainer, delay);
{ }
item.setDragDeadTime(delay);
} private void setInvDragDelay(int delay)
} {
if (bankInventoryItemsContainer != null) final Widget inventory = client.getWidget(WidgetInfo.INVENTORY);
{ applyDragDelay(inventory, delay);
Widget[] items = bankInventoryItemsContainer.getDynamicChildren();
for (Widget item : items)
{
item.setDragDeadTime(delay);
}
}
if (bankDepositContainer != null)
{
Widget[] items = bankDepositContainer.getDynamicChildren();
for (Widget item : items)
{
item.setDragDeadTime(delay);
}
}
} }
private void setDragDelay() private void setDragDelay()
{ {
client.setInventoryDragDelay(config.dragDelay()); final int delay = config.dragDelay();
setBankDragDelay(config.dragDelay()); log.debug("Set delay to {}", delay);
client.setInventoryDragDelay(delay);
setInvDragDelay(delay);
setBankDragDelay(delay);
} }
private void resetDragDelay() private void resetDragDelay()
{ {
log.debug("Reset delay to {}", DEFAULT_DELAY);
client.setInventoryDragDelay(DEFAULT_DELAY); client.setInventoryDragDelay(DEFAULT_DELAY);
setInvDragDelay(DEFAULT_DELAY);
setBankDragDelay(DEFAULT_DELAY); setBankDragDelay(DEFAULT_DELAY);
} }

View File

@@ -34,6 +34,7 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import javax.inject.Inject; import javax.inject.Inject;
import lombok.Getter; import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import net.runelite.api.AnimationID; import net.runelite.api.AnimationID;
import net.runelite.api.ChatMessageType; import net.runelite.api.ChatMessageType;
import net.runelite.api.Client; 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.ItemContainerChanged;
import net.runelite.api.events.MenuOptionClicked; import net.runelite.api.events.MenuOptionClicked;
import net.runelite.api.events.ProjectileMoved; 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.Notifier;
import net.runelite.client.callback.ClientThread; import net.runelite.client.callback.ClientThread;
import net.runelite.client.config.ConfigManager; 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", description = "Show information about cannon placement and/or amount of cannonballs",
tags = {"combat", "notifications", "ranged", "overlay"} tags = {"combat", "notifications", "ranged", "overlay"}
) )
@Slf4j
public class CannonPlugin extends Plugin public class CannonPlugin extends Plugin
{ {
private static final Pattern NUMBER_PATTERN = Pattern.compile("([0-9]+)"); 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 // 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 = event.getSelectedItemIndex(); final Widget selected = client.getSelectedWidget();
final ItemContainer items = client.getItemContainer(InventoryID.INVENTORY); final int itemId = selected.getItemId();
if (items == null) if (itemId != ItemID.CANNONBALL && itemId != ItemID.GRANITE_CANNONBALL)
{
return;
}
final Item item = items.getItem(idx);
if (item == null || (item.getId() != ItemID.CANNONBALL && item.getId() != ItemID.GRANITE_CANNONBALL))
{ {
return; return;
} }
@@ -306,6 +305,7 @@ public class CannonPlugin extends Plugin
// Store the click location as a WorldPoint to avoid issues with scene loads // Store the click location as a WorldPoint to avoid issues with scene loads
clickedCannonLocation = WorldPoint.fromScene(client, event.getParam0(), event.getParam1(), client.getPlane()); clickedCannonLocation = WorldPoint.fromScene(client, event.getParam0(), event.getParam1(), client.getPlane());
log.debug("Updated cannon location: {}", clickedCannonLocation);
} }
@Subscribe @Subscribe

View File

@@ -325,14 +325,8 @@ public class ClueScrollPlugin extends Plugin
return; return;
} }
final boolean itemClicked = event.getMenuAction() == MenuAction.ITEM_FIRST_OPTION final boolean isXMarksTheSpotOrb = event.getItemId() == ItemID.MYSTERIOUS_ORB_23069;
|| event.getMenuAction() == MenuAction.ITEM_SECOND_OPTION if (isXMarksTheSpotOrb || event.getMenuOption().equals("Read"))
|| 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 ItemComposition itemComposition = itemManager.getItemComposition(event.getId()); final ItemComposition itemComposition = itemManager.getItemComposition(event.getId());

View File

@@ -45,7 +45,7 @@ import okhttp3.Response;
public class CrowdsourcingManager public class CrowdsourcingManager
{ {
private static final String CROWDSOURCING_BASE = "https://crowdsource.runescape.wiki/runelite"; private static final String CROWDSOURCING_BASE = "https://crowdsource.runescape.wiki/runelite";
private static final MediaType JSON = MediaType.parse("application/json; charset=utf-8"); private static final MediaType JSON = MediaType.get("application/json; charset=utf-8");
@Inject @Inject
private OkHttpClient okHttpClient; private OkHttpClient okHttpClient;

View File

@@ -37,6 +37,7 @@ import net.runelite.api.Skill;
import net.runelite.api.Varbits; import net.runelite.api.Varbits;
import net.runelite.api.events.ChatMessage; import net.runelite.api.events.ChatMessage;
import net.runelite.api.events.MenuOptionClicked; import net.runelite.api.events.MenuOptionClicked;
import net.runelite.api.widgets.WidgetInfo;
import net.runelite.client.eventbus.Subscribe; import net.runelite.client.eventbus.Subscribe;
import net.runelite.client.plugins.crowdsourcing.CrowdsourcingManager; import net.runelite.client.plugins.crowdsourcing.CrowdsourcingManager;
@@ -114,7 +115,8 @@ public class CrowdsourcingCooking
|| action == MenuAction.GAME_OBJECT_SECOND_OPTION || action == MenuAction.GAME_OBJECT_SECOND_OPTION
|| action == MenuAction.GAME_OBJECT_THIRD_OPTION || action == MenuAction.GAME_OBJECT_THIRD_OPTION
|| action == MenuAction.GAME_OBJECT_FOURTH_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(); lastGameObjectClicked = menuOptionClicked.getId();
} }

View File

@@ -77,7 +77,11 @@ public class CrowdsourcingZMI
public void onMenuOptionClicked(MenuOptionClicked menuOptionClicked) public void onMenuOptionClicked(MenuOptionClicked menuOptionClicked)
{ {
MenuAction action = menuOptionClicked.getMenuAction(); MenuAction action = menuOptionClicked.getMenuAction();
if (menuOptionClicked.isItemOp())
{
illegalActionTick = client.getTickCount();
return;
}
switch (action) switch (action)
{ {
case ITEM_FIRST_OPTION: case ITEM_FIRST_OPTION:

View File

@@ -61,7 +61,6 @@ import net.runelite.api.coords.LocalPoint;
import net.runelite.api.coords.WorldPoint; import net.runelite.api.coords.WorldPoint;
import net.runelite.api.widgets.Widget; import net.runelite.api.widgets.Widget;
import net.runelite.api.widgets.WidgetInfo; import net.runelite.api.widgets.WidgetInfo;
import net.runelite.api.widgets.WidgetItem;
import net.runelite.client.ui.FontManager; import net.runelite.client.ui.FontManager;
import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.Overlay;
import net.runelite.client.ui.overlay.OverlayLayer; import net.runelite.client.ui.overlay.OverlayLayer;
@@ -420,11 +419,18 @@ class DevToolsOverlay extends Overlay
return; return;
} }
for (WidgetItem item : inventoryWidget.getWidgetItems()) for (Widget item : inventoryWidget.getDynamicChildren())
{ {
Rectangle slotBounds = item.getCanvasBounds(); Rectangle slotBounds = item.getBounds();
int itemId = item.getItemId();
if (itemId == 6512)
{
continue;
}
String idText = "" + itemId;
String idText = "" + item.getId();
FontMetrics fm = graphics.getFontMetrics(); FontMetrics fm = graphics.getFontMetrics();
Rectangle2D textBounds = fm.getStringBounds(idText, graphics); Rectangle2D textBounds = fm.getStringBounds(idText, graphics);

View File

@@ -516,8 +516,8 @@ class WidgetInspector extends DevToolsFrame
for (int i = 0; i < menuEntries.length; i++) for (int i = 0; i < menuEntries.length; i++)
{ {
MenuEntry entry = menuEntries[i]; MenuEntry entry = menuEntries[i];
if (entry.getType() != MenuAction.ITEM_USE_ON_WIDGET if (entry.getType() != MenuAction.WIDGET_USE_ON_ITEM
&& entry.getType() != MenuAction.SPELL_CAST_ON_WIDGET) && entry.getType() != MenuAction.WIDGET_TARGET_ON_WIDGET)
{ {
continue; continue;
} }
@@ -543,7 +543,7 @@ class WidgetInspector extends DevToolsFrame
Object getWidgetOrWidgetItemForMenuOption(MenuAction type, int param0, int param1) Object getWidgetOrWidgetItemForMenuOption(MenuAction type, int param0, int param1)
{ {
if (type == MenuAction.SPELL_CAST_ON_WIDGET) if (type == MenuAction.WIDGET_TARGET_ON_WIDGET)
{ {
Widget w = client.getWidget(param1); Widget w = client.getWidget(param1);
if (param0 != -1) if (param0 != -1)
@@ -553,7 +553,7 @@ class WidgetInspector extends DevToolsFrame
return w; return w;
} }
else if (type == MenuAction.ITEM_USE_ON_WIDGET) else if (type == MenuAction.WIDGET_USE_ON_ITEM)
{ {
Widget w = client.getWidget(param1); Widget w = client.getWidget(param1);
return w.getWidgetItem(param0); return w.getWidgetItem(param0);

View File

@@ -54,10 +54,7 @@ import lombok.Setter;
import lombok.Value; import lombok.Value;
import net.runelite.api.Client; import net.runelite.api.Client;
import net.runelite.api.GameState; import net.runelite.api.GameState;
import net.runelite.api.InventoryID;
import net.runelite.api.Item;
import net.runelite.api.ItemComposition; import net.runelite.api.ItemComposition;
import net.runelite.api.ItemContainer;
import net.runelite.api.ItemID; import net.runelite.api.ItemID;
import net.runelite.api.MenuAction; import net.runelite.api.MenuAction;
import net.runelite.api.MenuEntry; 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.ItemSpawned;
import net.runelite.api.events.MenuEntryAdded; import net.runelite.api.events.MenuEntryAdded;
import net.runelite.api.events.MenuOptionClicked; import net.runelite.api.events.MenuOptionClicked;
import net.runelite.api.widgets.WidgetInfo;
import net.runelite.client.Notifier; import net.runelite.client.Notifier;
import net.runelite.client.callback.ClientThread; import net.runelite.client.callback.ClientThread;
import net.runelite.client.config.ConfigManager; import net.runelite.client.config.ConfigManager;
@@ -485,7 +483,7 @@ public class GroundItemsPlugin extends Plugin
MenuAction type = MenuAction.of(event.getType()); MenuAction type = MenuAction.of(event.getType());
if (type == MenuAction.GROUND_ITEM_FIRST_OPTION || type == MenuAction.GROUND_ITEM_SECOND_OPTION || if (type == MenuAction.GROUND_ITEM_FIRST_OPTION || type == MenuAction.GROUND_ITEM_SECOND_OPTION ||
type == MenuAction.GROUND_ITEM_THIRD_OPTION || type == MenuAction.GROUND_ITEM_FOURTH_OPTION || type == MenuAction.GROUND_ITEM_THIRD_OPTION || type == MenuAction.GROUND_ITEM_FOURTH_OPTION ||
type == MenuAction.GROUND_ITEM_FIFTH_OPTION || type == MenuAction.SPELL_CAST_ON_GROUND_ITEM) type == MenuAction.GROUND_ITEM_FIFTH_OPTION || type == MenuAction.WIDGET_TARGET_ON_GROUND_ITEM)
{ {
final int itemId = event.getIdentifier(); final int itemId = event.getIdentifier();
final int sceneX = event.getActionParam0(); final int sceneX = event.getActionParam0();
@@ -688,28 +686,16 @@ public class GroundItemsPlugin extends Plugin
@Subscribe @Subscribe
public void onMenuOptionClicked(MenuOptionClicked menuOptionClicked) 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 // Keep a queue of recently dropped items to better detect
// item spawns that are drops // item spawns that are drops
droppedItemQueue.add(itemId); 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); lastUsedItem = client.getSelectedWidget().getItemId();
if (inventory == null)
{
return;
}
final Item clickedItem = inventory.getItem(menuOptionClicked.getSelectedItemIndex());
if (clickedItem == null)
{
return;
}
lastUsedItem = clickedItem.getId();
} }
} }

View File

@@ -85,7 +85,7 @@ class InteractHighlightOverlay extends Overlay
switch (menuAction) switch (menuAction)
{ {
case ITEM_USE_ON_GAME_OBJECT: case ITEM_USE_ON_GAME_OBJECT:
case SPELL_CAST_ON_GAME_OBJECT: case WIDGET_TARGET_ON_GAME_OBJECT:
case GAME_OBJECT_FIRST_OPTION: case GAME_OBJECT_FIRST_OPTION:
case GAME_OBJECT_SECOND_OPTION: case GAME_OBJECT_SECOND_OPTION:
case GAME_OBJECT_THIRD_OPTION: case GAME_OBJECT_THIRD_OPTION:
@@ -104,7 +104,7 @@ class InteractHighlightOverlay extends Overlay
break; break;
} }
case ITEM_USE_ON_NPC: case ITEM_USE_ON_NPC:
case SPELL_CAST_ON_NPC: case WIDGET_TARGET_ON_NPC:
case NPC_FIRST_OPTION: case NPC_FIRST_OPTION:
case NPC_SECOND_OPTION: case NPC_SECOND_OPTION:
case NPC_THIRD_OPTION: case NPC_THIRD_OPTION:
@@ -116,7 +116,7 @@ class InteractHighlightOverlay extends Overlay
NPC npc = plugin.findNpc(id); NPC npc = plugin.findNpc(id);
if (npc != null && config.npcShowHover() && (npc != plugin.getInteractedTarget() || !config.npcShowInteract())) if (npc != null && config.npcShowHover() && (npc != plugin.getInteractedTarget() || !config.npcShowInteract()))
{ {
Color highlightColor = menuAction == MenuAction.NPC_SECOND_OPTION || menuAction == MenuAction.SPELL_CAST_ON_NPC Color highlightColor = menuAction == MenuAction.NPC_SECOND_OPTION || menuAction == MenuAction.WIDGET_TARGET_ON_NPC
? config.npcAttackHoverHighlightColor() : config.npcHoverHighlightColor(); ? config.npcAttackHoverHighlightColor() : config.npcHoverHighlightColor();
modelOutlineRenderer.drawOutline(npc, config.borderWidth(), highlightColor, config.outlineFeather()); modelOutlineRenderer.drawOutline(npc, config.borderWidth(), highlightColor, config.outlineFeather());
} }

View File

@@ -141,7 +141,7 @@ public class InteractHighlightPlugin extends Plugin
switch (menuOptionClicked.getMenuAction()) switch (menuOptionClicked.getMenuAction())
{ {
case ITEM_USE_ON_GAME_OBJECT: case ITEM_USE_ON_GAME_OBJECT:
case SPELL_CAST_ON_GAME_OBJECT: case WIDGET_TARGET_ON_GAME_OBJECT:
case GAME_OBJECT_FIRST_OPTION: case GAME_OBJECT_FIRST_OPTION:
case GAME_OBJECT_SECOND_OPTION: case GAME_OBJECT_SECOND_OPTION:
case GAME_OBJECT_THIRD_OPTION: case GAME_OBJECT_THIRD_OPTION:
@@ -158,7 +158,7 @@ public class InteractHighlightPlugin extends Plugin
break; break;
} }
case ITEM_USE_ON_NPC: case ITEM_USE_ON_NPC:
case SPELL_CAST_ON_NPC: case WIDGET_TARGET_ON_NPC:
case NPC_FIRST_OPTION: case NPC_FIRST_OPTION:
case NPC_SECOND_OPTION: case NPC_SECOND_OPTION:
case NPC_THIRD_OPTION: case NPC_THIRD_OPTION:
@@ -168,7 +168,7 @@ public class InteractHighlightPlugin extends Plugin
int id = menuOptionClicked.getId(); int id = menuOptionClicked.getId();
interactedObject = null; interactedObject = null;
interactedNpc = findNpc(id); interactedNpc = findNpc(id);
attacked = menuOptionClicked.getMenuAction() == MenuAction.NPC_SECOND_OPTION || menuOptionClicked.getMenuAction() == MenuAction.SPELL_CAST_ON_NPC; attacked = menuOptionClicked.getMenuAction() == MenuAction.NPC_SECOND_OPTION || menuOptionClicked.getMenuAction() == MenuAction.WIDGET_TARGET_ON_NPC;
clickTick = client.getTickCount(); clickTick = client.getTickCount();
gameCycle = client.getGameCycle(); gameCycle = client.getGameCycle();
break; break;
@@ -176,8 +176,11 @@ public class InteractHighlightPlugin extends Plugin
// Any menu click which clears an interaction // Any menu click which clears an interaction
case WALK: case WALK:
case ITEM_USE: case ITEM_USE:
case WIDGET_TARGET_ON_WIDGET:
case ITEM_USE_ON_GROUND_ITEM: case ITEM_USE_ON_GROUND_ITEM:
case WIDGET_TARGET_ON_GROUND_ITEM:
case ITEM_USE_ON_PLAYER: case ITEM_USE_ON_PLAYER:
case WIDGET_TARGET_ON_PLAYER:
case ITEM_FIRST_OPTION: case ITEM_FIRST_OPTION:
case ITEM_SECOND_OPTION: case ITEM_SECOND_OPTION:
case ITEM_THIRD_OPTION: case ITEM_THIRD_OPTION:
@@ -190,6 +193,13 @@ public class InteractHighlightPlugin extends Plugin
case GROUND_ITEM_FIFTH_OPTION: case GROUND_ITEM_FIFTH_OPTION:
interactedObject = null; interactedObject = null;
interactedNpc = null; interactedNpc = null;
break;
default:
if (menuOptionClicked.isItemOp())
{
interactedObject = null;
interactedNpc = null;
}
} }
} }

View File

@@ -78,16 +78,13 @@ class InventoryGridOverlay extends Overlay
} }
// grid is only supported on bank inventory and inventory // grid is only supported on bank inventory and inventory
Widget inventoryWidget = draggingWidget.isIf3() ? if (draggingWidget.getId() != WidgetInfo.BANK_INVENTORY_ITEMS_CONTAINER.getId()
client.getWidget(WidgetInfo.BANK_INVENTORY_ITEMS_CONTAINER) : && draggingWidget.getId() != WidgetInfo.INVENTORY.getId())
client.getWidget(WidgetInfo.INVENTORY);
// with if3 the dragged widget is a child of the inventory, with if1 it is an item of the inventory (and the same widget)
if (inventoryWidget == null || (draggingWidget.isIf3() ? draggingWidget.getParent() != inventoryWidget : draggingWidget != inventoryWidget))
{ {
return null; return null;
} }
final Widget inventoryWidget = draggingWidget.getParent();
final net.runelite.api.Point mouse = client.getMouseCanvasPosition(); final net.runelite.api.Point mouse = client.getMouseCanvasPosition();
final Point mousePoint = new Point(mouse.getX(), mouse.getY()); final Point mousePoint = new Point(mouse.getX(), mouse.getY());
final int draggedItemIndex = draggingWidget.isIf3() ? draggingWidget.getIndex() : client.getIf1DraggedItemIndex(); final int draggedItemIndex = draggingWidget.isIf3() ? draggingWidget.getIndex() : client.getIf1DraggedItemIndex();
@@ -100,7 +97,7 @@ class InventoryGridOverlay extends Overlay
} }
if (draggedItem.getId() == -1 if (draggedItem.getId() == -1
|| client.getItemPressedDuration() < config.dragDelay() / Constants.CLIENT_TICK_LENGTH || (draggingWidget.isIf3() ? client.getDragTime() : client.getItemPressedDuration()) < config.dragDelay() / Constants.CLIENT_TICK_LENGTH
|| !hoverActive && initialMousePoint.distance(mousePoint) < DISTANCE_TO_ACTIVATE_HOVER) || !hoverActive && initialMousePoint.distance(mousePoint) < DISTANCE_TO_ACTIVATE_HOVER)
{ {
return null; return null;

View File

@@ -164,42 +164,43 @@ public class InventoryTagsPlugin extends Plugin
return; return;
} }
final int widgetId = firstEntry.getParam1(); final int itemId;
if (firstEntry.getType() == MenuAction.WIDGET_TARGET && firstEntry.getWidget().getId() == WidgetInfo.INVENTORY.getId())
// Inventory item menu
if (widgetId == WidgetInfo.INVENTORY.getId())
{ {
int itemId = firstEntry.getIdentifier(); itemId = firstEntry.getWidget().getItemId();
}
else if (firstEntry.isItemOp())
{
itemId = firstEntry.getItemId();
}
else
{
return;
}
if (itemId == -1) // Set menu to only be Cancel
{ client.setMenuEntries(Arrays.copyOf(client.getMenuEntries(), 1));
return;
}
// Set menu to only be Cancel for (final String groupName : GROUPS)
client.setMenuEntries(Arrays.copyOf(client.getMenuEntries(), 1)); {
final String group = getTag(itemId);
final Color color = getGroupNameColor(groupName);
for (final String groupName : GROUPS) client.createMenuEntry(-1)
{ .setOption(groupName.equals(group) ? MENU_REMOVE : MENU_SET)
final String group = getTag(itemId); .setTarget(ColorUtil.prependColorTag(groupName, MoreObjects.firstNonNull(color, Color.WHITE)))
final Color color = getGroupNameColor(groupName); .setType(MenuAction.RUNELITE)
.onClick(e ->
client.createMenuEntry(-1) {
.setOption(groupName.equals(group) ? MENU_REMOVE : MENU_SET) if (e.getOption().equals(MENU_SET))
.setTarget(ColorUtil.prependColorTag(groupName, MoreObjects.firstNonNull(color, Color.WHITE)))
.setType(MenuAction.RUNELITE)
.onClick(e ->
{ {
if (e.getOption().equals(MENU_SET)) setTag(itemId, groupName);
{ }
setTag(itemId, groupName); else
} {
else unsetTag(itemId);
{ }
unsetTag(itemId); });
}
});
}
} }
} }

View File

@@ -98,11 +98,20 @@ class ItemPricesOverlay extends Overlay
// Tooltip action type handling // Tooltip action type handling
switch (action) switch (action)
{ {
case ITEM_USE_ON_WIDGET: 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) if (!config.showWhileAlching() || !isAlching)
{ {
break; break;
} }
// FALLTHROUGH
case CC_OP: case CC_OP:
case ITEM_USE: case ITEM_USE:
case ITEM_FIRST_OPTION: case ITEM_FIRST_OPTION:
@@ -110,38 +119,49 @@ class ItemPricesOverlay extends Overlay
case ITEM_THIRD_OPTION: case ITEM_THIRD_OPTION:
case ITEM_FOURTH_OPTION: case ITEM_FOURTH_OPTION:
case ITEM_FIFTH_OPTION: case ITEM_FIFTH_OPTION:
// Item tooltip values addTooltip(menuEntry, isAlching, groupId);
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;
}
break; break;
case WIDGET_TARGET:
// Check that this is the inventory
if (menuEntry.getWidget().getId() == WidgetInfo.INVENTORY.getId())
{
addTooltip(menuEntry, isAlching, groupId);
}
} }
return null; 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) private String makeValueTooltip(MenuEntry menuEntry)
{ {
// Disabling both disables all value tooltips // Disabling both disables all value tooltips

View File

@@ -85,29 +85,20 @@ public class ItemStatOverlay extends Overlay
final MenuEntry[] menu = client.getMenuEntries(); final MenuEntry[] menu = client.getMenuEntries();
final int menuSize = menu.length; final int menuSize = menu.length;
if (menuSize <= 0) if (menuSize <= 0)
{ {
return null; return null;
} }
final MenuEntry entry = menu[menuSize - 1]; final MenuEntry entry = menu[menuSize - 1];
final int group = WidgetInfo.TO_GROUP(entry.getParam1()); final Widget widget = entry.getWidget();
final int child = WidgetInfo.TO_CHILD(entry.getParam1()); if (widget == null)
final Widget widget = client.getWidget(group, child);
if (widget == null
|| !(group == WidgetInfo.INVENTORY.getGroupId()
|| group == WidgetInfo.EQUIPMENT.getGroupId()
|| group == WidgetInfo.EQUIPMENT_INVENTORY_ITEMS_CONTAINER.getGroupId()
|| (config.showStatsInBank()
&& ((group == WidgetInfo.BANK_ITEM_CONTAINER.getGroupId() && child == WidgetInfo.BANK_ITEM_CONTAINER.getChildId())
|| group == WidgetInfo.BANK_INVENTORY_ITEMS_CONTAINER.getGroupId()))))
{ {
return null; return null;
} }
int itemId = entry.getIdentifier(); final int group = WidgetInfo.TO_GROUP(widget.getId());
int itemId = -1;
if (group == WidgetInfo.EQUIPMENT.getGroupId() || if (group == WidgetInfo.EQUIPMENT.getGroupId() ||
// For bank worn equipment, check widget parent to differentiate from normal bank items // For bank worn equipment, check widget parent to differentiate from normal bank items
@@ -119,19 +110,17 @@ public class ItemStatOverlay extends Overlay
itemId = widgetItem.getItemId(); itemId = widgetItem.getItemId();
} }
} }
else if (group == WidgetInfo.EQUIPMENT_INVENTORY_ITEMS_CONTAINER.getGroupId() else if (widget.getId() == WidgetInfo.INVENTORY.getId()
|| group == WidgetInfo.BANK_ITEM_CONTAINER.getGroupId() || group == WidgetInfo.EQUIPMENT_INVENTORY_ITEMS_CONTAINER.getGroupId()
|| group == WidgetInfo.BANK_INVENTORY_ITEMS_CONTAINER.getGroupId()) || widget.getId() == WidgetInfo.BANK_ITEM_CONTAINER.getId() && config.showStatsInBank()
|| group == WidgetInfo.BANK_INVENTORY_ITEMS_CONTAINER.getGroupId() && config.showStatsInBank())
{ {
int index = entry.getParam0(); itemId = widget.getItemId();
if (index > -1) }
{
final Widget widgetItem = widget.getChild(index); if (itemId == -1)
if (widgetItem != null) {
{ return null;
itemId = widgetItem.getItemId();
}
}
} }
if (config.consumableStats()) if (config.consumableStats())

View File

@@ -971,19 +971,19 @@ public class LootTrackerPlugin extends Plugin
{ {
onInvChange(collectInvAndGroundItems(LootRecordType.EVENT, SHADE_CHEST_OBJECTS.get(event.getId()))); 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)); 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)); onInvChange(collectInvItems(LootRecordType.EVENT, BIRDNEST_EVENT));
} }
else if (event.getMenuOption().equals("Open")) else if (event.getMenuOption().equals("Open"))
{ {
switch (event.getId()) switch (event.getItemId())
{ {
case ItemID.CASKET: case ItemID.CASKET:
onInvChange(collectInvItems(LootRecordType.EVENT, CASKET_EVENT)); onInvChange(collectInvItems(LootRecordType.EVENT, CASKET_EVENT));
@@ -1004,7 +1004,7 @@ public class LootTrackerPlugin extends Plugin
case ItemID.SIMPLE_LOCKBOX_25647: case ItemID.SIMPLE_LOCKBOX_25647:
case ItemID.ELABORATE_LOCKBOX_25649: case ItemID.ELABORATE_LOCKBOX_25649:
case ItemID.ORNATE_LOCKBOX_25651: case ItemID.ORNATE_LOCKBOX_25651:
onInvChange(collectInvAndGroundItems(LootRecordType.EVENT, itemManager.getItemComposition(event.getId()).getName())); onInvChange(collectInvAndGroundItems(LootRecordType.EVENT, itemManager.getItemComposition(event.getItemId()).getName()));
break; break;
case ItemID.SUPPLY_CRATE_24884: case ItemID.SUPPLY_CRATE_24884:
onInvChange(collectInvItems(LootRecordType.EVENT, MAHOGANY_CRATE_EVENT, client.getBoostedSkillLevel(Skill.CONSTRUCTION))); onInvChange(collectInvItems(LootRecordType.EVENT, MAHOGANY_CRATE_EVENT, client.getBoostedSkillLevel(Skill.CONSTRUCTION)));
@@ -1014,14 +1014,14 @@ public class LootTrackerPlugin extends Plugin
break; 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) -> onInvChange(((invItems, groundItems, removedItems) ->
{ {
int cnt = removedItems.count(event.getId()); int cnt = removedItems.count(event.getItemId());
if (cnt > 0) 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); 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) private static boolean isNPCOp(MenuAction menuAction)
{ {
final int id = menuAction.getId(); final int id = menuAction.getId();

View File

@@ -57,7 +57,6 @@ import net.runelite.api.NPC;
import net.runelite.api.NPCComposition; import net.runelite.api.NPCComposition;
import net.runelite.api.ObjectComposition; import net.runelite.api.ObjectComposition;
import net.runelite.api.events.ClientTick; import net.runelite.api.events.ClientTick;
import net.runelite.api.events.MenuEntryAdded;
import net.runelite.api.events.MenuOpened; import net.runelite.api.events.MenuOpened;
import net.runelite.api.events.PostItemComposition; import net.runelite.api.events.PostItemComposition;
import net.runelite.api.widgets.WidgetID; import net.runelite.api.widgets.WidgetID;
@@ -134,15 +133,6 @@ public class MenuEntrySwapperPlugin extends Plugin
private static final WidgetMenuOption RESIZABLE_BOTTOM_LINE_INVENTORY_TAB_SAVE_LC = new WidgetMenuOption(SAVE, 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); 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( private static final List<MenuAction> NPC_MENU_TYPES = ImmutableList.of(
MenuAction.NPC_FIRST_OPTION, MenuAction.NPC_FIRST_OPTION,
MenuAction.NPC_SECOND_OPTION, MenuAction.NPC_SECOND_OPTION,
@@ -547,25 +537,27 @@ public class MenuEntrySwapperPlugin extends Plugin
return; return;
} }
MenuEntry firstEntry = event.getFirstEntry(); final MenuEntry firstEntry = event.getFirstEntry();
if (firstEntry == null) if (firstEntry == null)
{ {
return; return;
} }
int widgetId = firstEntry.getParam1(); final int itemId;
if (widgetId != WidgetInfo.INVENTORY.getId()) 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; return;
} }
int itemId = firstEntry.getIdentifier(); int activeOp = 0;
if (itemId == -1)
{
return;
}
MenuAction activeAction = null;
final ItemComposition itemComposition = itemManager.getItemComposition(itemId); final ItemComposition itemComposition = itemManager.getItemComposition(itemId);
if (configuringShiftClick) if (configuringShiftClick)
@@ -576,7 +568,7 @@ public class MenuEntrySwapperPlugin extends Plugin
if (shiftClickActionIndex >= 0) if (shiftClickActionIndex >= 0)
{ {
activeAction = MenuAction.of(MenuAction.ITEM_FIRST_OPTION.getId() + shiftClickActionIndex); activeOp = 1 + shiftClickActionIndex;
} }
else else
{ {
@@ -584,7 +576,7 @@ public class MenuEntrySwapperPlugin extends Plugin
Integer config = getItemSwapConfig(true, itemId); Integer config = getItemSwapConfig(true, itemId);
if (config != null && config == -1) if (config != null && config == -1)
{ {
activeAction = MenuAction.ITEM_USE; activeOp = -1;
} }
} }
} }
@@ -594,9 +586,9 @@ public class MenuEntrySwapperPlugin extends Plugin
Integer config = getItemSwapConfig(false, itemId); Integer config = getItemSwapConfig(false, itemId);
if (config != null) if (config != null)
{ {
activeAction = config >= 0 activeOp = config >= 0
? MenuAction.of(MenuAction.ITEM_FIRST_OPTION.getId() + config) ? 1 + config
: MenuAction.ITEM_USE; : -1;
} }
} }
@@ -604,20 +596,31 @@ public class MenuEntrySwapperPlugin extends Plugin
for (MenuEntry entry : entries) for (MenuEntry entry : entries)
{ {
final MenuAction menuAction = entry.getType(); if (entry.getType() == MenuAction.WIDGET_TARGET && entry.getWidget().getId() == WidgetInfo.INVENTORY.getId() && entry.getWidget().getItemId() == itemId)
if (ITEM_MENU_TYPES.contains(menuAction) && entry.getIdentifier() == itemId)
{ {
entry.setType(MenuAction.RUNELITE); entry.setType(MenuAction.RUNELITE);
entry.onClick(e -> entry.onClick(e ->
{ {
int index = menuAction == MenuAction.ITEM_USE log.debug("Set {} item swap for {} to USE", configuringShiftClick ? "shift" : "left", itemId);
? -1 setItemSwapConfig(configuringShiftClick, itemId, -1);
: menuAction.getId() - MenuAction.ITEM_FIRST_OPTION.getId();
setItemSwapConfig(configuringShiftClick, itemId, index);
}); });
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()); entry.setOption("* " + entry.getOption());
} }
@@ -803,15 +806,14 @@ public class MenuEntrySwapperPlugin extends Plugin
} }
} }
@Subscribe private boolean swapBank(MenuEntry menuEntry, MenuAction type)
public void onMenuEntryAdded(MenuEntryAdded menuEntryAdded)
{ {
// This swap needs to happen prior to drag start on click, which happens during if (type != MenuAction.CC_OP && type != MenuAction.CC_OP_LOW_PRIORITY)
// widget ticking and prior to our client tick event. This is because drag start {
// is what builds the context menu row which is what the eventual click will use return false;
}
final int widgetGroupId = WidgetInfo.TO_GROUP(menuEntryAdded.getActionParam1());
final int widgetGroupId = WidgetInfo.TO_GROUP(menuEntry.getParam1());
final boolean isDepositBoxPlayerInventory = widgetGroupId == WidgetID.DEPOSIT_BOX_GROUP_ID; final boolean isDepositBoxPlayerInventory = widgetGroupId == WidgetID.DEPOSIT_BOX_GROUP_ID;
final boolean isChambersOfXericStorageUnitPlayerInventory = widgetGroupId == WidgetID.CHAMBERS_OF_XERIC_STORAGE_UNIT_INVENTORY_GROUP_ID; final boolean isChambersOfXericStorageUnitPlayerInventory = widgetGroupId == WidgetID.CHAMBERS_OF_XERIC_STORAGE_UNIT_INVENTORY_GROUP_ID;
final boolean isGroupStoragePlayerInventory = widgetGroupId == WidgetID.GROUP_STORAGE_INVENTORY_GROUP_ID; final boolean isGroupStoragePlayerInventory = widgetGroupId == WidgetID.GROUP_STORAGE_INVENTORY_GROUP_ID;
@@ -819,9 +821,9 @@ public class MenuEntrySwapperPlugin extends Plugin
// Deposit- op 1 is the current withdraw amount 1/5/10/x for deposit box interface and chambers of xeric storage unit. // Deposit- op 1 is the current withdraw amount 1/5/10/x for deposit box interface and chambers of xeric storage unit.
// Deposit- op 2 is the current withdraw amount 1/5/10/x for bank interface // Deposit- op 2 is the current withdraw amount 1/5/10/x for bank interface
if (shiftModifier() && config.bankDepositShiftClick() != ShiftDepositMode.OFF if (shiftModifier() && config.bankDepositShiftClick() != ShiftDepositMode.OFF
&& menuEntryAdded.getType() == MenuAction.CC_OP.getId() && type == MenuAction.CC_OP
&& menuEntryAdded.getIdentifier() == (isDepositBoxPlayerInventory || isGroupStoragePlayerInventory || isChambersOfXericStorageUnitPlayerInventory ? 1 : 2) && menuEntry.getIdentifier() == (isDepositBoxPlayerInventory || isGroupStoragePlayerInventory || isChambersOfXericStorageUnitPlayerInventory ? 1 : 2)
&& (menuEntryAdded.getOption().startsWith("Deposit-") || menuEntryAdded.getOption().startsWith("Store") || menuEntryAdded.getOption().startsWith("Donate"))) && (menuEntry.getOption().startsWith("Deposit-") || menuEntry.getOption().startsWith("Store") || menuEntry.getOption().startsWith("Donate")))
{ {
ShiftDepositMode shiftDepositMode = config.bankDepositShiftClick(); ShiftDepositMode shiftDepositMode = config.bankDepositShiftClick();
final int opId = isDepositBoxPlayerInventory ? shiftDepositMode.getIdentifierDepositBox() final int opId = isDepositBoxPlayerInventory ? shiftDepositMode.getIdentifierDepositBox()
@@ -830,13 +832,14 @@ public class MenuEntrySwapperPlugin extends Plugin
: shiftDepositMode.getIdentifier(); : shiftDepositMode.getIdentifier();
final MenuAction action = opId >= 6 ? MenuAction.CC_OP_LOW_PRIORITY : MenuAction.CC_OP; final MenuAction action = opId >= 6 ? MenuAction.CC_OP_LOW_PRIORITY : MenuAction.CC_OP;
bankModeSwap(action, opId); bankModeSwap(action, opId);
return true;
} }
// Swap to shift-click withdraw behavior // Swap to shift-click withdraw behavior
// Deposit- op 1 is the current withdraw amount 1/5/10/x // Deposit- op 1 is the current withdraw amount 1/5/10/x
if (shiftModifier() && config.bankWithdrawShiftClick() != ShiftWithdrawMode.OFF if (shiftModifier() && config.bankWithdrawShiftClick() != ShiftWithdrawMode.OFF
&& menuEntryAdded.getType() == MenuAction.CC_OP.getId() && menuEntryAdded.getIdentifier() == 1 && type == MenuAction.CC_OP && menuEntry.getIdentifier() == 1
&& menuEntryAdded.getOption().startsWith("Withdraw")) && menuEntry.getOption().startsWith("Withdraw"))
{ {
ShiftWithdrawMode shiftWithdrawMode = config.bankWithdrawShiftClick(); ShiftWithdrawMode shiftWithdrawMode = config.bankWithdrawShiftClick();
final MenuAction action; final MenuAction action;
@@ -852,7 +855,10 @@ public class MenuEntrySwapperPlugin extends Plugin
opId = shiftWithdrawMode.getIdentifier(); opId = shiftWithdrawMode.getIdentifier();
} }
bankModeSwap(action, opId); bankModeSwap(action, opId);
return true;
} }
return false;
} }
private void bankModeSwap(MenuAction entryType, int entryIdentifier) private void bankModeSwap(MenuAction entryType, int entryIdentifier)
@@ -893,19 +899,15 @@ public class MenuEntrySwapperPlugin extends Plugin
return; return;
} }
final boolean itemOp = menuAction == MenuAction.ITEM_FIRST_OPTION final boolean itemOp = menuEntry.isItemOp();
|| menuAction == MenuAction.ITEM_SECOND_OPTION // Custom shift-click item swap
|| menuAction == MenuAction.ITEM_THIRD_OPTION
|| menuAction == MenuAction.ITEM_FOURTH_OPTION
|| menuAction == MenuAction.ITEM_FIFTH_OPTION
|| menuAction == MenuAction.ITEM_USE;
if (shiftModifier() && itemOp) 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 = getItemSwapConfig(true, eventId); Integer customOption = getItemSwapConfig(true, menuEntry.getItemId());
if (customOption != null && customOption == -1) if (customOption != null && customOption == -1)
{ {
@@ -921,14 +923,18 @@ public class MenuEntrySwapperPlugin extends Plugin
// Custom left-click item swap // Custom left-click item swap
if (itemOp) if (itemOp)
{ {
Integer swapIndex = getItemSwapConfig(false, eventId); Integer swapIndex = getItemSwapConfig(false, menuEntry.getItemId());
if (swapIndex != null) if (swapIndex != null)
{ {
MenuAction swapAction = swapIndex >= 0 final int swapAction = swapIndex >= 0
? MenuAction.of(MenuAction.ITEM_FIRST_OPTION.getId() + swapIndex) ? 1 + swapIndex
: MenuAction.ITEM_USE; : -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); swap(optionIndexes, menuEntries, index, menuEntries.length - 1);
} }
@@ -986,6 +992,11 @@ public class MenuEntrySwapperPlugin extends Plugin
} }
} }
if (swapBank(menuEntry, menuAction))
{
return;
}
// Built-in swaps // 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)

View File

@@ -49,13 +49,13 @@ class MouseHighlightOverlay extends Overlay
*/ */
private static final Set<MenuAction> WIDGET_MENU_ACTIONS = ImmutableSet.of( private static final Set<MenuAction> WIDGET_MENU_ACTIONS = ImmutableSet.of(
MenuAction.WIDGET_TYPE_1, MenuAction.WIDGET_TYPE_1,
MenuAction.WIDGET_TYPE_2, MenuAction.WIDGET_TARGET,
MenuAction.WIDGET_TYPE_3, MenuAction.WIDGET_CLOSE,
MenuAction.WIDGET_TYPE_4, MenuAction.WIDGET_TYPE_4,
MenuAction.WIDGET_TYPE_5, MenuAction.WIDGET_TYPE_5,
MenuAction.WIDGET_TYPE_6, MenuAction.WIDGET_CONTINUE,
MenuAction.ITEM_USE_ON_WIDGET_ITEM, MenuAction.ITEM_USE_ON_ITEM,
MenuAction.ITEM_USE_ON_WIDGET, MenuAction.WIDGET_USE_ON_ITEM,
MenuAction.ITEM_FIRST_OPTION, MenuAction.ITEM_FIRST_OPTION,
MenuAction.ITEM_SECOND_OPTION, MenuAction.ITEM_SECOND_OPTION,
MenuAction.ITEM_THIRD_OPTION, MenuAction.ITEM_THIRD_OPTION,
@@ -68,7 +68,7 @@ class MouseHighlightOverlay extends Overlay
MenuAction.WIDGET_FOURTH_OPTION, MenuAction.WIDGET_FOURTH_OPTION,
MenuAction.WIDGET_FIFTH_OPTION, MenuAction.WIDGET_FIFTH_OPTION,
MenuAction.EXAMINE_ITEM, MenuAction.EXAMINE_ITEM,
MenuAction.SPELL_CAST_ON_WIDGET, MenuAction.WIDGET_TARGET_ON_WIDGET,
MenuAction.CC_OP_LOW_PRIORITY, MenuAction.CC_OP_LOW_PRIORITY,
MenuAction.CC_OP MenuAction.CC_OP
); );

View File

@@ -90,7 +90,7 @@ public class NpcIndicatorsPlugin extends Plugin
private static final String UNTAG_ALL = "Un-tag-All"; private static final String UNTAG_ALL = "Un-tag-All";
private static final Set<MenuAction> NPC_MENU_ACTIONS = ImmutableSet.of(MenuAction.NPC_FIRST_OPTION, MenuAction.NPC_SECOND_OPTION, private static final Set<MenuAction> NPC_MENU_ACTIONS = ImmutableSet.of(MenuAction.NPC_FIRST_OPTION, MenuAction.NPC_SECOND_OPTION,
MenuAction.NPC_THIRD_OPTION, MenuAction.NPC_FOURTH_OPTION, MenuAction.NPC_FIFTH_OPTION, MenuAction.SPELL_CAST_ON_NPC, MenuAction.NPC_THIRD_OPTION, MenuAction.NPC_FOURTH_OPTION, MenuAction.NPC_FIFTH_OPTION, MenuAction.WIDGET_TARGET_ON_NPC,
MenuAction.ITEM_USE_ON_NPC); MenuAction.ITEM_USE_ON_NPC);
@Inject @Inject

View File

@@ -42,7 +42,7 @@ import static net.runelite.api.MenuAction.PLAYER_SEVENTH_OPTION;
import static net.runelite.api.MenuAction.PLAYER_SIXTH_OPTION; import static net.runelite.api.MenuAction.PLAYER_SIXTH_OPTION;
import static net.runelite.api.MenuAction.PLAYER_THIRD_OPTION; import static net.runelite.api.MenuAction.PLAYER_THIRD_OPTION;
import static net.runelite.api.MenuAction.RUNELITE_PLAYER; import static net.runelite.api.MenuAction.RUNELITE_PLAYER;
import static net.runelite.api.MenuAction.SPELL_CAST_ON_PLAYER; import static net.runelite.api.MenuAction.WIDGET_TARGET_ON_PLAYER;
import static net.runelite.api.MenuAction.WALK; import static net.runelite.api.MenuAction.WALK;
import net.runelite.api.MenuEntry; import net.runelite.api.MenuEntry;
import net.runelite.api.Player; import net.runelite.api.Player;
@@ -124,7 +124,7 @@ public class PlayerIndicatorsPlugin extends Plugin
MenuAction type = entry.getType(); MenuAction type = entry.getType();
if (type == WALK if (type == WALK
|| type == SPELL_CAST_ON_PLAYER || type == WIDGET_TARGET_ON_PLAYER
|| type == ITEM_USE_ON_PLAYER || type == ITEM_USE_ON_PLAYER
|| type == PLAYER_FIRST_OPTION || type == PLAYER_FIRST_OPTION
|| type == PLAYER_SECOND_OPTION || type == PLAYER_SECOND_OPTION

View File

@@ -35,6 +35,7 @@ import net.runelite.api.MenuAction;
import net.runelite.api.MenuEntry; import net.runelite.api.MenuEntry;
import net.runelite.api.NPC; import net.runelite.api.NPC;
import net.runelite.api.NPCComposition; import net.runelite.api.NPCComposition;
import net.runelite.api.NullItemID;
import net.runelite.api.ObjectComposition; import net.runelite.api.ObjectComposition;
import net.runelite.api.ScriptID; import net.runelite.api.ScriptID;
import net.runelite.api.SpriteID; import net.runelite.api.SpriteID;
@@ -266,8 +267,8 @@ public class WikiPlugin extends Plugin
break optarget; break optarget;
case CANCEL: case CANCEL:
return; return;
case ITEM_USE_ON_WIDGET: case WIDGET_USE_ON_ITEM:
case SPELL_CAST_ON_GROUND_ITEM: case WIDGET_TARGET_ON_GROUND_ITEM:
{ {
type = "item"; type = "item";
id = itemManager.canonicalize(ev.getId()); id = itemManager.canonicalize(ev.getId());
@@ -275,7 +276,7 @@ public class WikiPlugin extends Plugin
location = null; location = null;
break; break;
} }
case SPELL_CAST_ON_NPC: case WIDGET_TARGET_ON_NPC:
{ {
type = "npc"; type = "npc";
NPC npc = client.getCachedNPCs()[ev.getId()]; NPC npc = client.getCachedNPCs()[ev.getId()];
@@ -285,7 +286,7 @@ public class WikiPlugin extends Plugin
location = npc.getWorldLocation(); location = npc.getWorldLocation();
break; break;
} }
case SPELL_CAST_ON_GAME_OBJECT: case WIDGET_TARGET_ON_GAME_OBJECT:
{ {
type = "object"; type = "object";
ObjectComposition lc = client.getObjectDefinition(ev.getId()); ObjectComposition lc = client.getObjectDefinition(ev.getId());
@@ -298,7 +299,7 @@ public class WikiPlugin extends Plugin
location = WorldPoint.fromScene(client, ev.getParam0(), ev.getParam1(), client.getPlane()); location = WorldPoint.fromScene(client, ev.getParam0(), ev.getParam1(), client.getPlane());
break; break;
} }
case SPELL_CAST_ON_WIDGET: case WIDGET_TARGET_ON_WIDGET:
Widget w = getWidget(ev.getParam1(), ev.getParam0()); Widget w = getWidget(ev.getParam1(), ev.getParam0());
if (w.getType() == WidgetType.GRAPHIC && w.getItemId() != -1) if (w.getType() == WidgetType.GRAPHIC && w.getItemId() != -1)
@@ -359,16 +360,16 @@ public class WikiPlugin extends Plugin
int widgetIndex = event.getActionParam0(); int widgetIndex = event.getActionParam0();
int widgetID = event.getActionParam1(); int widgetID = event.getActionParam1();
if (wikiSelected && event.getType() == MenuAction.SPELL_CAST_ON_WIDGET.getId()) if (wikiSelected && event.getType() == MenuAction.WIDGET_TARGET_ON_WIDGET.getId())
{ {
MenuEntry[] menuEntries = client.getMenuEntries(); MenuEntry[] menuEntries = client.getMenuEntries();
Widget w = getWidget(widgetID, widgetIndex); Widget w = getWidget(widgetID, widgetIndex);
if (w.getType() == WidgetType.GRAPHIC && w.getItemId() != -1) if (w.getType() == WidgetType.GRAPHIC && w.getItemId() != -1 && w.getItemId() != NullItemID.NULL_6512)
{ {
for (int ourEntry = menuEntries.length - 1;ourEntry >= 0; ourEntry--) for (int ourEntry = menuEntries.length - 1;ourEntry >= 0; ourEntry--)
{ {
MenuEntry entry = menuEntries[ourEntry]; MenuEntry entry = menuEntries[ourEntry];
if (entry.getType() == MenuAction.SPELL_CAST_ON_WIDGET) if (entry.getType() == MenuAction.WIDGET_TARGET_ON_WIDGET)
{ {
int id = itemManager.canonicalize(w.getItemId()); int id = itemManager.canonicalize(w.getItemId());
String name = itemManager.getItemComposition(id).getName(); String name = itemManager.getItemComposition(id).getName();
@@ -385,7 +386,7 @@ public class WikiPlugin extends Plugin
MenuEntry[] oldEntries = menuEntries; MenuEntry[] oldEntries = menuEntries;
menuEntries = Arrays.copyOf(menuEntries, menuEntries.length - 1); menuEntries = Arrays.copyOf(menuEntries, menuEntries.length - 1);
for (int ourEntry = oldEntries.length - 1; for (int ourEntry = oldEntries.length - 1;
ourEntry >= 2 && oldEntries[oldEntries.length - 1].getType() != MenuAction.SPELL_CAST_ON_WIDGET; ourEntry >= 2 && oldEntries[oldEntries.length - 1].getType() != MenuAction.WIDGET_TARGET_ON_WIDGET;
ourEntry--) ourEntry--)
{ {
menuEntries[ourEntry - 1] = oldEntries[ourEntry]; menuEntries[ourEntry - 1] = oldEntries[ourEntry];

View File

@@ -206,7 +206,7 @@ public class ClientLoader implements Supplier<Applet>
private RSConfig downloadConfig() throws IOException private RSConfig downloadConfig() throws IOException
{ {
HttpUrl url = HttpUrl.parse(javConfigUrl); HttpUrl url = HttpUrl.get(javConfigUrl);
IOException err = null; IOException err = null;
for (int attempt = 0; attempt < NUM_ATTEMPTS; attempt++) for (int attempt = 0; attempt < NUM_ATTEMPTS; attempt++)
{ {
@@ -256,7 +256,7 @@ public class ClientLoader implements Supplier<Applet>
@Nonnull @Nonnull
private RSConfig downloadFallbackConfig() throws IOException private RSConfig downloadFallbackConfig() throws IOException
{ {
RSConfig backupConfig = clientConfigLoader.fetch(HttpUrl.parse(RuneLiteProperties.getJavConfigBackup())); RSConfig backupConfig = clientConfigLoader.fetch(HttpUrl.get(RuneLiteProperties.getJavConfigBackup()));
if (Strings.isNullOrEmpty(backupConfig.getCodeBase()) || Strings.isNullOrEmpty(backupConfig.getInitialJar()) || Strings.isNullOrEmpty(backupConfig.getInitialClass())) if (Strings.isNullOrEmpty(backupConfig.getCodeBase()) || Strings.isNullOrEmpty(backupConfig.getInitialJar()) || Strings.isNullOrEmpty(backupConfig.getInitialClass()))
{ {
@@ -326,13 +326,13 @@ public class ClientLoader implements Supplier<Applet>
if (config.isFallback()) if (config.isFallback())
{ {
// If we are using the backup config, use our own gamepack and ignore the codebase // If we are using the backup config, use our own gamepack and ignore the codebase
url = HttpUrl.parse(config.getRuneLiteGamepack()); url = HttpUrl.get(config.getRuneLiteGamepack());
} }
else else
{ {
String codebase = config.getCodeBase(); String codebase = config.getCodeBase();
String initialJar = config.getInitialJar(); String initialJar = config.getInitialJar();
url = HttpUrl.parse(codebase + initialJar); url = HttpUrl.get(codebase + initialJar);
} }
for (int attempt = 0; ; attempt++) for (int attempt = 0; ; attempt++)

View File

@@ -27,7 +27,6 @@ package net.runelite.client.ui;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Color; import java.awt.Color;
import java.awt.Component; import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Font; import java.awt.Font;
import java.awt.event.WindowAdapter; import java.awt.event.WindowAdapter;
@@ -45,7 +44,6 @@ import javax.swing.JDialog;
import javax.swing.JLabel; import javax.swing.JLabel;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.JTextArea; import javax.swing.JTextArea;
import javax.swing.UIManager;
import javax.swing.border.EmptyBorder; import javax.swing.border.EmptyBorder;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.runelite.client.RuneLite; import net.runelite.client.RuneLite;
@@ -53,6 +51,7 @@ import net.runelite.client.RuneLiteProperties;
import net.runelite.client.util.ImageUtil; import net.runelite.client.util.ImageUtil;
import net.runelite.client.util.LinkBrowser; import net.runelite.client.util.LinkBrowser;
import net.runelite.client.util.VerificationException; import net.runelite.client.util.VerificationException;
import org.pushingpixels.substance.internal.SubstanceSynapse;
@Slf4j @Slf4j
public class FatalErrorDialog extends JDialog public class FatalErrorDialog extends JDialog
@@ -70,16 +69,6 @@ public class FatalErrorDialog extends JDialog
throw new IllegalStateException("Fatal error during fatal error: " + message); throw new IllegalStateException("Fatal error during fatal error: " + message);
} }
try
{
UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
}
catch (Exception e)
{
}
UIManager.put("Button.select", ColorScheme.DARKER_GRAY_COLOR);
try try
{ {
BufferedImage logo = ImageUtil.loadImageResource(FatalErrorDialog.class, "openosrs_transparent.png"); BufferedImage logo = ImageUtil.loadImageResource(FatalErrorDialog.class, "openosrs_transparent.png");
@@ -108,8 +97,9 @@ public class FatalErrorDialog extends JDialog
setTitle("Fatal error starting OpenOSRS"); setTitle("Fatal error starting OpenOSRS");
setLayout(new BorderLayout()); setLayout(new BorderLayout());
Container pane = getContentPane(); JPanel pane = (JPanel) getContentPane();
pane.setBackground(ColorScheme.DARKER_GRAY_COLOR); pane.setBackground(ColorScheme.DARKER_GRAY_COLOR);
pane.putClientProperty(SubstanceSynapse.COLORIZATION_FACTOR, 1.0);
JPanel leftPane = new JPanel(); JPanel leftPane = new JPanel();
leftPane.setBackground(ColorScheme.DARKER_GRAY_COLOR); leftPane.setBackground(ColorScheme.DARKER_GRAY_COLOR);
@@ -130,6 +120,7 @@ public class FatalErrorDialog extends JDialog
textArea.setWrapStyleWord(true); textArea.setWrapStyleWord(true);
textArea.setBorder(new EmptyBorder(10, 10, 10, 10)); textArea.setBorder(new EmptyBorder(10, 10, 10, 10));
textArea.setEditable(false); textArea.setEditable(false);
textArea.setOpaque(false);
leftPane.add(textArea, BorderLayout.CENTER); leftPane.add(textArea, BorderLayout.CENTER);
pane.add(leftPane, BorderLayout.CENTER); pane.add(leftPane, BorderLayout.CENTER);

View File

@@ -68,8 +68,8 @@ import okhttp3.Response;
public class ImageCapture public class ImageCapture
{ {
private static final DateFormat TIME_FORMAT = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss"); private static final DateFormat TIME_FORMAT = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss");
private static final HttpUrl IMGUR_IMAGE_UPLOAD_URL = HttpUrl.parse("https://api.imgur.com/3/image"); private static final HttpUrl IMGUR_IMAGE_UPLOAD_URL = HttpUrl.get("https://api.imgur.com/3/image");
private static final MediaType JSON = MediaType.parse("application/json"); private static final MediaType JSON = MediaType.get("application/json");
private final Client client; private final Client client;
private final Notifier notifier; private final Notifier notifier;

View File

@@ -31,6 +31,11 @@ public class VerificationException extends Exception
super(message); super(message);
} }
public VerificationException(Throwable cause)
{
super(cause);
}
public VerificationException(String message, Throwable cause) public VerificationException(String message, Throwable cause)
{ {
super(message, cause); super(message, cause);

View File

@@ -1,19 +1,30 @@
-----BEGIN CERTIFICATE----- -----BEGIN CERTIFICATE-----
MIIDDDCCAfSgAwIBAgIJAK8uBanmNQZaMA0GCSqGSIb3DQEBCwUAMBsxGTAXBgNV MIIFFTCCAv2gAwIBAgIUHZQhtTfY+I19Gz+JKYfvT6IM55QwDQYJKoZIhvcNAQEL
BAMMEHJ1bmVsaXRlLXBsdWdpbnMwHhcNMTkxMjEyMjEwNzUxWhcNMjUxMjEwMjEw BQAwGjEYMBYGA1UEAwwPcnVuZWxpdGUtcGx1Z2luMB4XDTIyMDQxOTAxMjIzNFoX
NzUxWjAbMRkwFwYDVQQDDBBydW5lbGl0ZS1wbHVnaW5zMIIBIjANBgkqhkiG9w0B DTMyMDQxNjAxMjIzNFowGjEYMBYGA1UEAwwPcnVuZWxpdGUtcGx1Z2luMIICIjAN
AQEFAAOCAQ8AMIIBCgKCAQEApu11OVANSU+pHaXRxB7fIZapucJ6BT46neicEixs BgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAw4Dkg5UBgD3X8UtChrnxCYaoe68J
NVPuK/QRVjO/G8F++MXFD/tlZUOEDllDN8uaHBIVwxilqEVYL7oX65Esl7qqC1TZ uuY+lESNROWb27EAEcLHo/DBbW0q0n6zL4vKjHs4Acsq+Z9kblyXN572851b8hur
WGdjiMyYoK3CXWEWB4w+CdB31T7JG2HqH45ZsVs+U9OVWBkNkL5nNQNPOmZFd+3A 5CbHq0Uc4r1dUiMCYHjSJ/BkvGKMPs6Yo1CmzXqc9IPV/zoHC+yJH7R6hmIkLWu4
yCb9nGlO7SxduiHpwh3CV19jY47y8tevyo5qpaBuQeWtu3vbpeer0kbDarwD3xoF CytXvmkIGEvOJoJ+LZyWcifBzX7Aua6IuWHHhTAxEcAxkrBFImfC9wgWD8sL/r2F
yUMPRK518gxRUSmOpsSG5viQ731mKVCUUfIXz91d3s+kJYAjORHS4zJe9s+1dljp Xyzo3jkv1LognWFbuMGQYgG+PvO8Ia+p8cko9YZnH3+SQmtr+VPbLD+VOAyDxhH1
oLYNLkaP6m3CmNtC84OxkmognvZTNMbiQ3GQm/BK4sdjPQIDAQABo1MwUTAdBgNV jX46SsSoB2sIIfCB3oNTERM1Wmy0xL5GYBj8PWOanWQY+rKku07SS8DBirkWRTVB
HQ4EFgQUxrkiRXNd0OHPMkqgl9UgV1//OuQwHwYDVR0jBBgwFoAUxrkiRXNd0OHP lboNt60Di6FhrPnxTGA8DcxdYAJVZEQOS6ed540Bl40JMEdeMG66PGRDJJlIMyrc
Mkqgl9UgV1//OuQwDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEA 3xa8Z6XoKMV0QCv5ETBQwnED3lXsViFDoeC6wCww1ZjOFMwHfk5O6N5CsyJOEoGC
StPyblz3aqOM5z2KqHX1B7Z3Q8B58g55YSefpcfwWEc6LT4HCztszcZDteWpV3W2 Y9LiUwzLkf2po6LGLRrUsiDf/a+nsMUam5Zhmdt6a77wii+cH7oaAAieLk11u1qr
ERfemkGKgsDhQ0qkzIt7tS5eNN3PPj7RZZm7vl5HquQ1vC/33ri/Z3CEKzbW7knt Gc43gJtrzBY0thF5QiGtWlGHo7VY32Zlf9GnHkFSTTMdQX66VkWan6y080gr+HVn
i1iEpx8E9DKb9J9DjdKwNxSomOyCOFUt9YoQJs80xc1mwPDd6aWR3xwvnEUimkm+ aP1oN9cxBrfWc0XMBGp+uZf60p7D9gbPQG0bJUF7GDtgcZt+b8NK9u8hnJZVi8oX
Dbj7HMOXLeyN810wkeWcT8nC5GhxH3ZAmVExBHsaIOB876RntzshBehjY8s8JQhw AmLfUvCZ4Uv/sjMCAwEAAaNTMFEwHQYDVR0OBBYEFEFHyDZIF4aE3o+ChP3/Y6eO
R+fT1e8EhYMM9ylYDk1KIWFWrAujjU04lS9tXZ5C2e7fr9R953XN6Y0PNM/taNTU VsOQMB8GA1UdIwQYMBaAFEFHyDZIF4aE3o+ChP3/Y6eOVsOQMA8GA1UdEwEB/wQF
GzwGroJZI02V+1ADO14rRA== MAMBAf8wDQYJKoZIhvcNAQELBQADggIBAH3Wm63s7ifC7cIeBLgM4LJxU9Qx1YA4
-----END CERTIFICATE----- 7U2WEoChoeDj4iBs5cAKCBXU9hbw2/Ij8JqYG1sjZGNZjdqzYtjh36K4j+vgTmK5
vufXlzC+MUwWt853QIrgWs4c2HO4HnQgsss7UJm3aofVeqEVH9MeHcmKiL/3uQFT
DiR31+MxLaQZw0JcmVMGR0WU6eXyi4lkZL82BGwponjaOgB4oxrHRqqrV7I93Y/v
GRiRwfcgP0QXORdfDmhtzaY6ay4TX1qzcXH/a78EGk3Bzgg20kh+6r8YRoBpbtM4
O4hZKhKtwGDDRHrVHy5gVh3hjAUdb2kdlxjxPocnkIiOWCrX2P5GA5NF6+deRE+B
NZO+3VAD40meNlaoVqSnXW2hmeqShWEclNkdyTieSLFTLpsPGIlC7+NYAgc6j9Jc
oFdcmdChavHv7UVbgg8Kp1ypfQLThNG9gWf+PByqRrEcCSKG3J1JrKwh8tqOXkNh
N5o3ON56H1WFPwkXji3amhkNCVHq13qgCXtPXTRSVcFTtPVrCKB5DSFqHErb73/5
WDkj4GYAVeL0+znFYktj/cxD0J8QRgNCVZeFCmxWpuN1WekHzy3C2TjO4We/x1yP
9HGVWLvJL8U8tgEO3c3g1OH9Z5SwHhgjNFw1VMfpKngFWp96o/OAJTX9K++5gKwm
Y5Hm2HkwTow+
-----END CERTIFICATE-----

View File

@@ -1 +1 @@
9B38CB6BF195C49B10D856C5F571AFDEC7BBEF96A4E3532F5B23E9341066144C 3218E18002C110E4D44C9CB0C006BD5C052AC1CA8D07B32F2C67CBD866570F06

View File

@@ -90,13 +90,13 @@ LABEL60:
iload 0 iload 0
iconst 84 iconst 84
if_icmpeq LABEL76 if_icmpeq LABEL76
jump LABEL822 jump LABEL809
LABEL76: LABEL76:
invoke 1984 invoke 1984
iload 2 iload 2
iconst 0 iconst 0
if_icmpgt LABEL81 if_icmpgt LABEL81
jump LABEL821 jump LABEL808
LABEL81: LABEL81:
iload 3 iload 3
iconst 1 iconst 1
@@ -699,7 +699,7 @@ LABEL587:
sconst "You are not chatting as a guest in a clan channel at the moment." sconst "You are not chatting as a guest in a clan channel at the moment."
mes mes
LABEL589: LABEL589:
jump LABEL817 jump LABEL804
LABEL590: LABEL590:
iload 5 iload 5
iconst 41 iconst 41
@@ -782,7 +782,7 @@ LABEL655:
sconst "You are not chatting in the channel of your Clan at the moment." sconst "You are not chatting in the channel of your Clan at the moment."
mes mes
LABEL657: LABEL657:
jump LABEL817 jump LABEL804
LABEL658: LABEL658:
iload 5 iload 5
iconst 9 iconst 9
@@ -842,7 +842,7 @@ LABEL699:
iconst -1 iconst -1
invoke 5517 invoke 5517
LABEL705: LABEL705:
jump LABEL817 jump LABEL804
LABEL706: LABEL706:
iload 5 iload 5
iconst 2 iconst 2
@@ -858,17 +858,17 @@ LABEL710:
iconst 0 iconst 0
iload 9 iload 9
invoke 5517 invoke 5517
jump LABEL817 jump LABEL804
LABEL720: LABEL720:
iload 4 iload 4
iconst 1 iconst 1
if_icmpeq LABEL724 if_icmpeq LABEL724
jump LABEL811 jump LABEL798
LABEL724: LABEL724:
iload 2 iload 2
iconst 2 iconst 2
if_icmpgt LABEL728 if_icmpgt LABEL728
jump LABEL804 jump LABEL791
LABEL728: LABEL728:
get_varc_string 335 get_varc_string 335
sconst "::toggleroof" sconst "::toggleroof"
@@ -876,80 +876,62 @@ LABEL728:
string_indexof_string string_indexof_string
iconst 0 iconst 0
if_icmpeq LABEL735 if_icmpeq LABEL735
jump LABEL763
LABEL735:
getremoveroofs
iconst 1
if_icmpeq LABEL739
jump LABEL751
LABEL739:
iconst 0
setremoveroofs
get_varbit 12378
iconst 0
if_icmpeq LABEL745
jump LABEL748
LABEL745:
sconst "Roofs will only be removed selectively."
mes
jump LABEL750 jump LABEL750
LABEL748: LABEL735:
iconst 1
3215
iconst 1
if_icmpeq LABEL740
jump LABEL745
LABEL740:
iconst 0
invoke 4583
sconst "Roofs will only be removed selectively. This setting will not be saved." sconst "Roofs will only be removed selectively. This setting will not be saved."
mes mes
LABEL750: jump LABEL749
jump LABEL762 LABEL745:
LABEL751:
iconst 1 iconst 1
setremoveroofs invoke 4583
get_varbit 12378
iconst 1
if_icmpeq LABEL757
jump LABEL760
LABEL757:
sconst "Roofs are now all hidden."
mes
jump LABEL762
LABEL760:
sconst "Roofs are now all hidden. This setting will not be saved." sconst "Roofs are now all hidden. This setting will not be saved."
mes mes
LABEL762: LABEL749:
jump LABEL803 jump LABEL790
LABEL763: LABEL750:
get_varc_string 335 get_varc_string 335
sconst "::wiki " sconst "::wiki "
iconst 0 iconst 0
string_indexof_string string_indexof_string
iconst 0 iconst 0
if_icmpeq LABEL775 if_icmpeq LABEL762
get_varc_string 335 get_varc_string 335
sconst "::wiki" sconst "::wiki"
compare compare
iconst 0 iconst 0
if_icmpeq LABEL775 if_icmpeq LABEL762
sconst "runeliteCommand" ; load callback name sconst "runeliteCommand" ; load callback name
runelite_callback ; invoke callback runelite_callback ; invoke callback
jump LABEL778 jump LABEL765
LABEL775: LABEL762:
get_varc_string 335 get_varc_string 335
invoke 3299 invoke 3299
jump LABEL803 jump LABEL790
LABEL778: LABEL765:
get_varc_string 335 get_varc_string 335
sconst "::bank" sconst "::bank"
iconst 0 iconst 0
string_indexof_string string_indexof_string
iconst 0 iconst 0
if_icmpeq LABEL785 if_icmpeq LABEL772
jump LABEL792 jump LABEL779
LABEL785: LABEL772:
sconst "Hey, everyone, I just tried to do something very silly!" sconst "Hey, everyone, I just tried to do something very silly!"
iconst 0 iconst 0
iconst -1 iconst -1
iconst 0 iconst 0
iconst -1 iconst -1
invoke 5517 invoke 5517
jump LABEL803 jump LABEL790
LABEL792: LABEL779:
get_varc_string 335 get_varc_string 335
invoke 224 invoke 224
set_varc_string 335 set_varc_string 335
@@ -961,97 +943,97 @@ LABEL792:
iload 2 iload 2
substring substring
docheat docheat
LABEL803: LABEL790:
jump LABEL810 jump LABEL797
LABEL804: LABEL791:
get_varc_string 335 get_varc_string 335
iconst 0 iconst 0
iconst -1 iconst -1
iconst 0 iconst 0
iconst -1 iconst -1
invoke 5517 invoke 5517
LABEL810: LABEL797:
jump LABEL817 jump LABEL804
LABEL811: LABEL798:
get_varc_string 335 get_varc_string 335
iconst 0 iconst 0
iconst -1 iconst -1
iconst 1 iconst 1
iload 9 iload 9
invoke 5517 invoke 5517
LABEL817: LABEL804:
get_varc_string 335 get_varc_string 335
invoke 77 invoke 77
sconst "" sconst ""
set_varc_string 335 set_varc_string 335
LABEL821: LABEL808:
jump LABEL897 jump LABEL884
LABEL822: LABEL809:
iload 0 iload 0
iconst 104 iconst 104
if_icmpeq LABEL826 if_icmpeq LABEL813
jump LABEL832 jump LABEL819
LABEL826: LABEL813:
iload 3 iload 3
iconst 1 iconst 1
if_icmpeq LABEL830 if_icmpeq LABEL817
jump LABEL831 jump LABEL818
LABEL830: LABEL817:
invoke 75 invoke 75
LABEL831: LABEL818:
jump LABEL897 jump LABEL884
LABEL832: LABEL819:
iload 0 iload 0
iconst 105 iconst 105
if_icmpeq LABEL836 if_icmpeq LABEL823
jump LABEL842 jump LABEL829
LABEL836: LABEL823:
iload 3 iload 3
iconst 1 iconst 1
if_icmpeq LABEL840 if_icmpeq LABEL827
jump LABEL841 jump LABEL828
LABEL840: LABEL827:
invoke 76 invoke 76
LABEL841: LABEL828:
jump LABEL897 jump LABEL884
LABEL842: LABEL829:
iload 0 iload 0
iconst 80 iconst 80
if_icmpeq LABEL846 if_icmpeq LABEL833
jump LABEL891 jump LABEL878
LABEL846: LABEL833:
iconst 40697936 iconst 40697936
iconst 1 iconst 1
cc_find cc_find
iconst 1 iconst 1
if_icmpeq LABEL852 if_icmpeq LABEL839
jump LABEL853 jump LABEL840
LABEL852: LABEL839:
return return
LABEL853: LABEL840:
get_varc_string 356 get_varc_string 356
string_length string_length
iconst 0 iconst 0
if_icmpgt LABEL858 if_icmpgt LABEL845
jump LABEL878 jump LABEL865
LABEL858: LABEL845:
get_varc_string 356 get_varc_string 356
friend_test friend_test
iconst 1 iconst 1
if_icmpeq LABEL863 if_icmpeq LABEL850
jump LABEL866 jump LABEL853
LABEL863: LABEL850:
get_varc_string 356 get_varc_string 356
invoke 107 invoke 107
return return
LABEL866: LABEL853:
get_varc_int 60 get_varc_int 60
clientclock clientclock
if_icmpgt LABEL870 if_icmpgt LABEL857
jump LABEL871 jump LABEL858
LABEL870: LABEL857:
return return
LABEL871: LABEL858:
clientclock clientclock
iconst 50 iconst 50
add add
@@ -1059,14 +1041,14 @@ LABEL871:
sconst "That player was not found on your Friends list." sconst "That player was not found on your Friends list."
mes mes
return return
LABEL878: LABEL865:
get_varc_int 60 get_varc_int 60
clientclock clientclock
if_icmpgt LABEL882 if_icmpgt LABEL869
jump LABEL883 jump LABEL870
LABEL882: LABEL869:
return return
LABEL883: LABEL870:
clientclock clientclock
iconst 50 iconst 50
add add
@@ -1074,8 +1056,8 @@ LABEL883:
sconst "You haven't received any messages to which you can reply." sconst "You haven't received any messages to which you can reply."
mes mes
return return
jump LABEL897 jump LABEL884
LABEL891: LABEL878:
get_varc_string 335 get_varc_string 335
iconst 0 iconst 0
iload 0 iload 0
@@ -1087,9 +1069,9 @@ LABEL891:
runelite_callback ; runelite_callback ;
if_icmpeq SKIPSETVARC ; skip setting varc with input if_icmpeq SKIPSETVARC ; skip setting varc with input
set_varc_string 335 set_varc_string 335
jump LABEL897 ; jump over SKIPSETVARC jump LABEL884 ; jump over SKIPSETVARC
SKIPSETVARC: SKIPSETVARC:
pop_string ; pop message pop_string ; pop message
LABEL897: LABEL884:
invoke 223 invoke 223
return return

View File

@@ -25,9 +25,12 @@
package net.runelite.client.menus; package net.runelite.client.menus;
import java.util.function.Consumer; import java.util.function.Consumer;
import javax.annotation.Nullable;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.Setter;
import net.runelite.api.MenuAction; import net.runelite.api.MenuAction;
import net.runelite.api.MenuEntry; import net.runelite.api.MenuEntry;
import net.runelite.api.widgets.Widget;
@EqualsAndHashCode(callSuper = false) @EqualsAndHashCode(callSuper = false)
public class TestMenuEntry implements MenuEntry public class TestMenuEntry implements MenuEntry
@@ -39,6 +42,12 @@ public class TestMenuEntry implements MenuEntry
private int param0; private int param0;
private int param1; private int param1;
private boolean forceLeftClick; private boolean forceLeftClick;
@Setter
private int itemOp = -1;
@Setter
private int itemId = -1;
@Setter
private Widget widget;
@Override @Override
public String getOption() public String getOption()
@@ -205,4 +214,29 @@ public class TestMenuEntry implements MenuEntry
{ {
return MenuAction.of(this.type); return MenuAction.of(this.type);
} }
@Override
public boolean isItemOp()
{
return itemOp != -1;
}
@Override
public int getItemOp()
{
return itemOp;
}
@Override
public int getItemId()
{
return itemId;
}
@Nullable
@Override
public Widget getWidget()
{
return widget;
}
} }

View File

@@ -63,6 +63,7 @@ import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any;
import org.mockito.Mock; import org.mockito.Mock;
import static org.mockito.Mockito.lenient;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times; import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
@@ -164,10 +165,10 @@ public class ClueScrollPluginTest
plugin.onGameTick(new GameTick()); plugin.onGameTick(new GameTick());
// Simulate clicking on the STASH // Simulate clicking on the STASH
MenuOptionClicked menuOptionClicked = new MenuOptionClicked(); MenuOptionClicked menuOptionClicked = mock(MenuOptionClicked.class);
menuOptionClicked.setMenuOption("Search"); when(menuOptionClicked.getMenuOption()).thenReturn("Search");
menuOptionClicked.setMenuTarget("<col=ffff>STASH unit (easy)"); lenient().when(menuOptionClicked.getMenuTarget()).thenReturn("<col=ffff>STASH unit (easy)");
menuOptionClicked.setId(NullObjectID.NULL_28983); when(menuOptionClicked.getId()).thenReturn(NullObjectID.NULL_28983);
plugin.onMenuOptionClicked(menuOptionClicked); plugin.onMenuOptionClicked(menuOptionClicked);
// Check that the STASH is stored after withdrawing // Check that the STASH is stored after withdrawing

View File

@@ -38,7 +38,6 @@ import net.runelite.api.NPC;
import net.runelite.api.NPCComposition; import net.runelite.api.NPCComposition;
import net.runelite.api.ObjectComposition; import net.runelite.api.ObjectComposition;
import net.runelite.api.events.ClientTick; import net.runelite.api.events.ClientTick;
import net.runelite.api.events.MenuEntryAdded;
import net.runelite.client.chat.ChatMessageManager; import net.runelite.client.chat.ChatMessageManager;
import net.runelite.client.config.ConfigManager; import net.runelite.client.config.ConfigManager;
import net.runelite.client.game.ItemManager; import net.runelite.client.game.ItemManager;
@@ -332,14 +331,7 @@ public class MenuEntrySwapperPluginTest
menu("Deposit-1", "Abyssal whip", MenuAction.CC_OP, 2), menu("Deposit-1", "Abyssal whip", MenuAction.CC_OP, 2),
}; };
menuEntrySwapperPlugin.onMenuEntryAdded(new MenuEntryAdded( menuEntrySwapperPlugin.onClientTick(new ClientTick());
"Deposit-1",
"Abyssal whip",
MenuAction.CC_OP.getId(),
2,
-1,
-1
));
ArgumentCaptor<MenuEntry[]> argumentCaptor = ArgumentCaptor.forClass(MenuEntry[].class); ArgumentCaptor<MenuEntry[]> argumentCaptor = ArgumentCaptor.forClass(MenuEntry[].class);
verify(client).setMenuEntries(argumentCaptor.capture()); verify(client).setMenuEntries(argumentCaptor.capture());
@@ -364,14 +356,7 @@ public class MenuEntrySwapperPluginTest
menu("Deposit-1", "Rune arrow", MenuAction.CC_OP, 2), menu("Deposit-1", "Rune arrow", MenuAction.CC_OP, 2),
}; };
menuEntrySwapperPlugin.onMenuEntryAdded(new MenuEntryAdded( menuEntrySwapperPlugin.onClientTick(new ClientTick());
"Deposit-1",
"Rune arrow",
MenuAction.CC_OP.getId(),
2,
-1,
-1
));
ArgumentCaptor<MenuEntry[]> argumentCaptor = ArgumentCaptor.forClass(MenuEntry[].class); ArgumentCaptor<MenuEntry[]> argumentCaptor = ArgumentCaptor.forClass(MenuEntry[].class);
verify(client).setMenuEntries(argumentCaptor.capture()); verify(client).setMenuEntries(argumentCaptor.capture());

View File

@@ -492,7 +492,7 @@ public abstract class RSClientMixin implements RSClient
@Override @Override
public AccountType getAccountType() public AccountType getAccountType()
{ {
int varbit = getVar(Varbits.ACCOUNT_TYPE); int varbit = getVarbitValue(Varbits.ACCOUNT_TYPE);
switch (varbit) switch (varbit)
{ {
@@ -771,7 +771,7 @@ public abstract class RSClientMixin implements RSClient
@Override @Override
public boolean isPrayerActive(Prayer prayer) public boolean isPrayerActive(Prayer prayer)
{ {
return getVar(prayer.getVarbit()) == 1; return getVarbitValue(prayer.getVarbit()) == 1;
} }
/** /**
@@ -949,6 +949,17 @@ public abstract class RSClientMixin implements RSClient
@Override @Override
public void setMenuEntries(MenuEntry[] menuEntries) 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) for (int i = 0; i < menuEntries.length; ++i)
{ {
RSRuneLiteMenuEntry menuEntry = (RSRuneLiteMenuEntry) menuEntries[i]; RSRuneLiteMenuEntry menuEntry = (RSRuneLiteMenuEntry) menuEntries[i];
@@ -960,6 +971,15 @@ public abstract class RSClientMixin implements RSClient
client.setMenuOptionCount(menuEntries.length); client.setMenuOptionCount(menuEntries.length);
tmpMenuOptionsCount = 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 @Inject
@@ -1038,6 +1058,7 @@ public abstract class RSClientMixin implements RSClient
int menuIdentifier = client.getMenuIdentifiers()[tmpOptionsCount]; int menuIdentifier = client.getMenuIdentifiers()[tmpOptionsCount];
int menuArgument1 = client.getMenuArguments1()[tmpOptionsCount]; int menuArgument1 = client.getMenuArguments1()[tmpOptionsCount];
int menuArgument2 = client.getMenuArguments2()[tmpOptionsCount]; int menuArgument2 = client.getMenuArguments2()[tmpOptionsCount];
if (rl$menuEntries[tmpOptionsCount] == null) if (rl$menuEntries[tmpOptionsCount] == null)
{ {
rl$menuEntries[tmpOptionsCount] = newRuneliteMenuEntry(tmpOptionsCount); rl$menuEntries[tmpOptionsCount] = newRuneliteMenuEntry(tmpOptionsCount);
@@ -1655,15 +1676,67 @@ public abstract class RSClientMixin implements RSClient
{ {
RSRuneLiteMenuEntry menuEntry = null; 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]; menuEntry = rl$menuEntries[i];
break; 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, * 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 * undo it here so we can get the correct opcode
@@ -1675,27 +1748,6 @@ public abstract class RSClientMixin implements RSClient
opcode -= 2000; 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) if (printMenuActions)
{ {
client.getLogger().info( client.getLogger().info(
@@ -1704,6 +1756,14 @@ public abstract class RSClientMixin implements RSClient
menuOptionClicked.getMenuAction(), opcode + (decremented ? 2000 : 0), menuOptionClicked.getMenuAction(), opcode + (decremented ? 2000 : 0),
menuOptionClicked.getParam0(), menuOptionClicked.getParam1(), canvasX, canvasY 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(), copy$menuAction(menuOptionClicked.getParam0(), menuOptionClicked.getParam1(),
@@ -2944,5 +3004,22 @@ public abstract class RSClientMixin implements RSClient
client.setLowMemory(true); 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;
}
} }

View File

@@ -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;
}
}

View File

@@ -194,6 +194,10 @@ public interface RSClient extends RSGameEngine, Client
@Override @Override
void setDraggedOnWidget(Widget widget); void setDraggedOnWidget(Widget widget);
@Import("widgetDragDuration")
@Override
int getDragTime();
@Import("Widget_interfaceComponents") @Import("Widget_interfaceComponents")
RSWidget[][] getWidgets(); RSWidget[][] getWidgets();
@@ -329,6 +333,9 @@ public interface RSClient extends RSGameEngine, Client
@Override @Override
void setMenuOptionCount(int menuOptionCount); void setMenuOptionCount(int menuOptionCount);
@Import("tempMenuAction")
RSMenuAction getTempMenuAction();
@Import("menuActions") @Import("menuActions")
String[] getMenuOptions(); String[] getMenuOptions();

View File

@@ -28,18 +28,33 @@ import net.runelite.mapping.Import;
public interface RSMenuAction public interface RSMenuAction
{ {
@Import("action")
String getOption();
@Import("action") @Import("action")
void setOption(String yes); void setOption(String yes);
@Import("opcode")
int getOpcode();
@Import("opcode") @Import("opcode")
void setOpcode(int yes); void setOpcode(int yes);
@Import("identifier")
int getIdentifier();
@Import("identifier") @Import("identifier")
void setIdentifier(int yes); void setIdentifier(int yes);
@Import("param0")
int getParam0();
@Import("param0") @Import("param0")
void setParam0(int yes); void setParam0(int yes);
@Import("param1")
int getParam1();
@Import("param1") @Import("param1")
void setParam1(int yes); void setParam1(int yes);
} }

View File

@@ -1,6 +1,8 @@
import java.util.function.Consumer; import java.util.function.Consumer;
import net.runelite.api.MenuAction; import net.runelite.api.MenuAction;
import net.runelite.api.MenuEntry; import net.runelite.api.MenuEntry;
import net.runelite.api.widgets.Widget;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
public class RuneLiteMenuEntry implements MenuEntry public class RuneLiteMenuEntry implements MenuEntry
{ {
@@ -322,6 +324,70 @@ public class RuneLiteMenuEntry implements MenuEntry
} }
} }
@Override
public boolean isItemOp()
{
MenuAction var1 = this.getType();
if (var1 == MenuAction.CC_OP || var1 == MenuAction.CC_OP_LOW_PRIORITY) {
int var2 = this.getIdentifier();
int var3 = this.getParam1();
if (var3 == 9764864) {
switch(var2) {
case 2:
case 3:
case 4:
case 6:
case 7:
return true;
case 5:
}
}
}
return false;
}
@Override
public int getItemOp()
{
MenuAction var1 = this.getType();
if (var1 == MenuAction.CC_OP || var1 == MenuAction.CC_OP_LOW_PRIORITY) {
int var2 = this.getIdentifier();
int var3 = this.getParam1();
if (var3 == 9764864) {
switch(var2) {
case 2:
return 1;
case 3:
return 2;
case 4:
return 3;
case 5:
default:
break;
case 6:
return 4;
case 7:
return 5;
}
}
}
return -1;
}
@Override
public int getItemId()
{
throw new NotImplementedException();
}
@Override
public Widget getWidget()
{
throw new NotImplementedException();
}
@Override @Override
public int hashCode() public int hashCode()
{ {
@@ -346,6 +412,5 @@ public class RuneLiteMenuEntry implements MenuEntry
public String toString() public String toString()
{ {
return "MenuEntryImpl(getOption=" + this.getOption() + ", getTarget=" + this.getTarget() + ", getIdentifier=" + this.getIdentifier() + ", getType=" + this.getType() + ", getParam0=" + this.getParam0() + ", getParam1=" + this.getParam1() + ", isForceLeftClick=" + this.isForceLeftClick() + ", isDeprioritized=" + this.isDeprioritized() + ")"; return "MenuEntryImpl(getOption=" + this.getOption() + ", getTarget=" + this.getTarget() + ", getIdentifier=" + this.getIdentifier() + ", getType=" + this.getType() + ", getParam0=" + this.getParam0() + ", getParam1=" + this.getParam1() + ", isForceLeftClick=" + this.isForceLeftClick() + ", isDeprioritized=" + this.isDeprioritized() + ")";
} }
} }