Adds a configuration option to make the inventory anti-drag enabled by default (#795)
Signed-off-by: PKLite <stonewall@pklite.xyz>
This commit is contained in:
@@ -118,4 +118,15 @@ public interface AntiDragConfig extends Config
|
|||||||
{
|
{
|
||||||
return CustomCursor.DRAGON_SCIMITAR;
|
return CustomCursor.DRAGON_SCIMITAR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ConfigItem(
|
||||||
|
keyName = "alwaysOn",
|
||||||
|
name = "Always On",
|
||||||
|
description = "Makes the anti-drag always active and disables the hotkey toggle",
|
||||||
|
position = 8
|
||||||
|
)
|
||||||
|
default boolean alwaysOn()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ package net.runelite.client.plugins.antidrag;
|
|||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
|
import net.runelite.api.events.ConfigChanged;
|
||||||
import net.runelite.api.events.FocusChanged;
|
import net.runelite.api.events.FocusChanged;
|
||||||
import net.runelite.client.config.ConfigManager;
|
import net.runelite.client.config.ConfigManager;
|
||||||
import net.runelite.client.eventbus.Subscribe;
|
import net.runelite.client.eventbus.Subscribe;
|
||||||
@@ -51,6 +52,7 @@ import net.runelite.client.util.HotkeyListener;
|
|||||||
public class AntiDragPlugin extends Plugin
|
public class AntiDragPlugin extends Plugin
|
||||||
{
|
{
|
||||||
private static final int DEFAULT_DELAY = 5;
|
private static final int DEFAULT_DELAY = 5;
|
||||||
|
private static final String CONFIG_GROUP_NAME = "antiDrag";
|
||||||
private boolean toggleDrag;
|
private boolean toggleDrag;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@@ -84,7 +86,8 @@ public class AntiDragPlugin extends Plugin
|
|||||||
protected void startUp() throws Exception
|
protected void startUp() throws Exception
|
||||||
{
|
{
|
||||||
keyManager.registerKeyListener(hotkeyListener);
|
keyManager.registerKeyListener(hotkeyListener);
|
||||||
toggleDrag = false;
|
toggleDrag = config.alwaysOn();
|
||||||
|
enableAntiDrag();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,46 +100,76 @@ public class AntiDragPlugin extends Plugin
|
|||||||
overlayManager.remove(overlay);
|
overlayManager.remove(overlay);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void onConfigChanged(ConfigChanged event)
|
||||||
|
{
|
||||||
|
if (event.getGroup().equals(CONFIG_GROUP_NAME))
|
||||||
|
{
|
||||||
|
toggleDrag = config.alwaysOn();
|
||||||
|
enableAntiDrag();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void onFocusChanged(FocusChanged focusChanged)
|
||||||
|
{
|
||||||
|
if (!config.alwaysOn())
|
||||||
|
{
|
||||||
|
if (!focusChanged.isFocused() && config.reqfocus())
|
||||||
|
{
|
||||||
|
client.setInventoryDragDelay(DEFAULT_DELAY);
|
||||||
|
overlayManager.remove(overlay);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void enableAntiDrag()
|
||||||
|
{
|
||||||
|
if (toggleDrag)
|
||||||
|
{
|
||||||
|
client.setInventoryDragDelay(config.dragDelay());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
client.setInventoryDragDelay(DEFAULT_DELAY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private final HotkeyListener hotkeyListener = new HotkeyListener(() -> config.key())
|
private final HotkeyListener hotkeyListener = new HotkeyListener(() -> config.key())
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void hotkeyPressed()
|
public void hotkeyPressed()
|
||||||
{
|
{
|
||||||
toggleDrag = !toggleDrag;
|
if (!config.alwaysOn())
|
||||||
if (toggleDrag)
|
|
||||||
{
|
{
|
||||||
if (config.overlay())
|
toggleDrag = !toggleDrag;
|
||||||
|
if (toggleDrag)
|
||||||
{
|
{
|
||||||
overlayManager.add(overlay);
|
if (config.overlay())
|
||||||
}
|
{
|
||||||
if (config.changeCursor())
|
overlayManager.add(overlay);
|
||||||
{
|
}
|
||||||
CustomCursor selectedCursor = config.selectedCursor();
|
if (config.changeCursor())
|
||||||
clientUI.setCursor(selectedCursor.getCursorImage(), selectedCursor.toString());
|
{
|
||||||
}
|
CustomCursor selectedCursor = config.selectedCursor();
|
||||||
|
clientUI.setCursor(selectedCursor.getCursorImage(), selectedCursor.toString());
|
||||||
|
}
|
||||||
|
|
||||||
client.setInventoryDragDelay(config.dragDelay());
|
client.setInventoryDragDelay(config.dragDelay());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
overlayManager.remove(overlay);
|
|
||||||
client.setInventoryDragDelay(DEFAULT_DELAY);
|
|
||||||
if (config.changeCursor())
|
|
||||||
{
|
{
|
||||||
net.runelite.client.plugins.customcursor.CustomCursor selectedCursor = configManager.getConfig(CustomCursorConfig.class).selectedCursor();
|
overlayManager.remove(overlay);
|
||||||
clientUI.setCursor(selectedCursor.getCursorImage(), selectedCursor.toString());
|
client.setInventoryDragDelay(DEFAULT_DELAY);
|
||||||
|
if (config.changeCursor())
|
||||||
|
{
|
||||||
|
net.runelite.client.plugins.customcursor.CustomCursor selectedCursor = configManager.getConfig(CustomCursorConfig.class).selectedCursor();
|
||||||
|
clientUI.setCursor(selectedCursor.getCursorImage(), selectedCursor.toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onFocusChanged(FocusChanged focusChanged)
|
|
||||||
{
|
|
||||||
if (!focusChanged.isFocused() && config.reqfocus())
|
|
||||||
{
|
|
||||||
client.setInventoryDragDelay(DEFAULT_DELAY);
|
|
||||||
overlayManager.remove(overlay);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user