Merge remote-tracking branch 'runelite/master'
This commit is contained in:
@@ -573,6 +573,14 @@ public interface Client extends OAuthApi, GameEngine
|
||||
*/
|
||||
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
|
||||
*/
|
||||
|
||||
@@ -449,4 +449,7 @@ public final class ScriptID
|
||||
|
||||
@ScriptArguments(integer = 7)
|
||||
public static final int GROUP_IRONMAN_STORAGE_BUILD = 5269;
|
||||
|
||||
@ScriptArguments(integer = 6)
|
||||
public static final int INVENTORY_DRAWITEM = 6011;
|
||||
}
|
||||
@@ -27,9 +27,12 @@ package net.runelite.client.plugins.antidrag;
|
||||
import com.google.inject.Provides;
|
||||
import java.awt.event.KeyEvent;
|
||||
import javax.inject.Inject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.GameState;
|
||||
import net.runelite.api.ScriptID;
|
||||
import net.runelite.api.events.FocusChanged;
|
||||
import net.runelite.api.events.ScriptPostFired;
|
||||
import net.runelite.api.events.WidgetLoaded;
|
||||
import net.runelite.api.widgets.Widget;
|
||||
import net.runelite.api.widgets.WidgetID;
|
||||
@@ -49,6 +52,7 @@ import net.runelite.client.plugins.PluginDescriptor;
|
||||
tags = {"antidrag", "delay", "inventory", "items"},
|
||||
enabledByDefault = false
|
||||
)
|
||||
@Slf4j
|
||||
public class AntiDragPlugin extends Plugin implements KeyListener
|
||||
{
|
||||
static final String CONFIG_GROUP = "antiDrag";
|
||||
@@ -182,6 +186,37 @@ public class AntiDragPlugin extends Plugin implements KeyListener
|
||||
{
|
||||
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();
|
||||
for (Widget child : inv.getDynamicChildren())
|
||||
{
|
||||
// disable [clientscript,inventory_antidrag_update] listener
|
||||
child.setOnMouseRepeatListener((Object[]) null);
|
||||
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)
|
||||
@@ -189,41 +224,32 @@ public class AntiDragPlugin extends Plugin implements KeyListener
|
||||
final Widget bankItemContainer = client.getWidget(WidgetInfo.BANK_ITEM_CONTAINER);
|
||||
final Widget bankInventoryItemsContainer = client.getWidget(WidgetInfo.BANK_INVENTORY_ITEMS_CONTAINER);
|
||||
final Widget bankDepositContainer = client.getWidget(WidgetInfo.DEPOSIT_BOX_INVENTORY_ITEMS_CONTAINER);
|
||||
if (bankItemContainer != null)
|
||||
{
|
||||
Widget[] items = bankItemContainer.getDynamicChildren();
|
||||
for (Widget item : items)
|
||||
{
|
||||
item.setDragDeadTime(delay);
|
||||
|
||||
applyDragDelay(bankItemContainer, delay);
|
||||
applyDragDelay(bankInventoryItemsContainer, delay);
|
||||
applyDragDelay(bankDepositContainer, delay);
|
||||
}
|
||||
}
|
||||
if (bankInventoryItemsContainer != null)
|
||||
|
||||
private void setInvDragDelay(int 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);
|
||||
}
|
||||
}
|
||||
final Widget inventory = client.getWidget(WidgetInfo.INVENTORY);
|
||||
applyDragDelay(inventory, delay);
|
||||
}
|
||||
|
||||
private void setDragDelay()
|
||||
{
|
||||
client.setInventoryDragDelay(config.dragDelay());
|
||||
setBankDragDelay(config.dragDelay());
|
||||
final int delay = config.dragDelay();
|
||||
log.debug("Set delay to {}", delay);
|
||||
client.setInventoryDragDelay(delay);
|
||||
setInvDragDelay(delay);
|
||||
setBankDragDelay(delay);
|
||||
}
|
||||
|
||||
private void resetDragDelay()
|
||||
{
|
||||
log.debug("Reset delay to {}", DEFAULT_DELAY);
|
||||
client.setInventoryDragDelay(DEFAULT_DELAY);
|
||||
setInvDragDelay(DEFAULT_DELAY);
|
||||
setBankDragDelay(DEFAULT_DELAY);
|
||||
}
|
||||
|
||||
|
||||
@@ -78,16 +78,13 @@ class InventoryGridOverlay extends Overlay
|
||||
}
|
||||
|
||||
// grid is only supported on bank inventory and inventory
|
||||
Widget inventoryWidget = draggingWidget.isIf3() ?
|
||||
client.getWidget(WidgetInfo.BANK_INVENTORY_ITEMS_CONTAINER) :
|
||||
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))
|
||||
if (draggingWidget.getId() != WidgetInfo.BANK_INVENTORY_ITEMS_CONTAINER.getId()
|
||||
&& draggingWidget.getId() != WidgetInfo.INVENTORY.getId())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
final Widget inventoryWidget = draggingWidget.getParent();
|
||||
final net.runelite.api.Point mouse = client.getMouseCanvasPosition();
|
||||
final Point mousePoint = new Point(mouse.getX(), mouse.getY());
|
||||
final int draggedItemIndex = draggingWidget.isIf3() ? draggingWidget.getIndex() : client.getIf1DraggedItemIndex();
|
||||
@@ -100,7 +97,7 @@ class InventoryGridOverlay extends Overlay
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
return null;
|
||||
|
||||
@@ -35,6 +35,7 @@ import net.runelite.api.MenuAction;
|
||||
import net.runelite.api.MenuEntry;
|
||||
import net.runelite.api.NPC;
|
||||
import net.runelite.api.NPCComposition;
|
||||
import net.runelite.api.NullItemID;
|
||||
import net.runelite.api.ObjectComposition;
|
||||
import net.runelite.api.ScriptID;
|
||||
import net.runelite.api.SpriteID;
|
||||
@@ -363,7 +364,7 @@ public class WikiPlugin extends Plugin
|
||||
{
|
||||
MenuEntry[] menuEntries = client.getMenuEntries();
|
||||
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--)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user