Add ability to hide all ground items on double tap of hotkey(ALT) (#6712)

Closes #1781
This commit is contained in:
Sam Beresford
2018-12-17 10:26:58 +01:00
committed by Tomas Slusny
parent 2a7219a482
commit a771a49ab2
4 changed files with 40 additions and 3 deletions

View File

@@ -27,6 +27,8 @@ package net.runelite.client.plugins.grounditems;
import java.awt.Point;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.time.Duration;
import java.time.Instant;
import javax.inject.Inject;
import javax.swing.SwingUtilities;
import net.runelite.client.input.KeyListener;
@@ -36,9 +38,14 @@ public class GroundItemInputListener extends MouseAdapter implements KeyListener
{
private static final int HOTKEY = KeyEvent.VK_ALT;
private Instant lastPress;
@Inject
private GroundItemsPlugin plugin;
@Inject
private GroundItemsConfig config;
@Override
public void keyTyped(KeyEvent e)
{
@@ -50,7 +57,22 @@ public class GroundItemInputListener extends MouseAdapter implements KeyListener
{
if (e.getKeyCode() == HOTKEY)
{
plugin.setHotKeyPressed(true);
if (plugin.isHideAll())
{
plugin.setHideAll(false);
plugin.setHotKeyPressed(true);
lastPress = null;
}
else if (lastPress != null && !plugin.isHotKeyPressed() && config.doubleTapDelay() > 0 && Duration.between(lastPress, Instant.now()).compareTo(Duration.ofMillis(config.doubleTapDelay())) < 0)
{
plugin.setHideAll(true);
lastPress = null;
}
else
{
plugin.setHotKeyPressed(true);
lastPress = Instant.now();
}
}
}

View File

@@ -302,7 +302,6 @@ public interface GroundItemsConfig extends Config
{
return Color.decode("#FF66B2");
}
@ConfigItem(
keyName = "insaneValuePrice",
name = "Insane value price",
@@ -324,4 +323,16 @@ public interface GroundItemsConfig extends Config
{
return false;
}
@ConfigItem(
keyName = "doubleTapDelay",
name = "Delay for double-tap ALT to hide",
description = "Decrease this number if you accidentally hide ground items often. (0 = Disabled)",
position = 25
)
default int doubleTapDelay()
{
return 250;
}
}

View File

@@ -88,7 +88,7 @@ public class GroundItemsOverlay extends Overlay
@Override
public Dimension render(Graphics2D graphics)
{
final boolean dontShowOverlay = config.itemHighlightMode() == MENU && !plugin.isHotKeyPressed();
final boolean dontShowOverlay = (config.itemHighlightMode() == MENU || plugin.isHideAll()) && !plugin.isHotKeyPressed();
if (dontShowOverlay && !config.highlightTiles())
{

View File

@@ -119,6 +119,10 @@ public class GroundItemsPlugin extends Plugin
@Setter(AccessLevel.PACKAGE)
private boolean hotKeyPressed;
@Getter(AccessLevel.PACKAGE)
@Setter(AccessLevel.PACKAGE)
private boolean hideAll;
private List<String> hiddenItemList = new CopyOnWriteArrayList<>();
private List<String> highlightedItemsList = new CopyOnWriteArrayList<>();