bank plugin: add option to input bankpin with keyboard
This commit is contained in:
@@ -108,4 +108,15 @@ public interface BankConfig extends Config
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "bankPinKeyboard",
|
||||
name = "Keyboard Bankpin",
|
||||
description = "Allows using the keyboard keys for bank pin input",
|
||||
position = 8
|
||||
)
|
||||
default boolean bankPinKeyboard()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import javax.inject.Inject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.Client;
|
||||
import static net.runelite.api.Constants.HIGH_ALCHEMY_MULTIPLIER;
|
||||
import net.runelite.api.InventoryID;
|
||||
@@ -54,9 +55,12 @@ import net.runelite.api.events.MenuShouldLeftClick;
|
||||
import net.runelite.api.events.ScriptCallbackEvent;
|
||||
import net.runelite.api.events.ScriptPostFired;
|
||||
import net.runelite.api.events.WidgetLoaded;
|
||||
import net.runelite.api.widgets.JavaScriptCallback;
|
||||
import net.runelite.api.widgets.Widget;
|
||||
import net.runelite.api.widgets.WidgetID;
|
||||
import net.runelite.api.widgets.WidgetInfo;
|
||||
import static net.runelite.api.widgets.WidgetInfo.TO_CHILD;
|
||||
import static net.runelite.api.widgets.WidgetInfo.TO_GROUP;
|
||||
import net.runelite.client.callback.ClientThread;
|
||||
import net.runelite.client.config.ConfigManager;
|
||||
import net.runelite.client.eventbus.Subscribe;
|
||||
@@ -71,6 +75,7 @@ import net.runelite.client.util.QuantityFormatter;
|
||||
description = "Modifications to the banking interface",
|
||||
tags = {"grand", "exchange", "high", "alchemy", "prices", "deposit"}
|
||||
)
|
||||
@Slf4j
|
||||
public class BankPlugin extends Plugin
|
||||
{
|
||||
private static final List<Varbits> TAB_VARBITS = ImmutableList.of(
|
||||
@@ -200,6 +205,41 @@ public class BankPlugin extends Plugin
|
||||
}
|
||||
|
||||
break;
|
||||
case "bankpinButtonSetup":
|
||||
{
|
||||
if (!config.bankPinKeyboard())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final int compId = intStack[intStackSize - 2];
|
||||
final int buttonId = intStack[intStackSize - 1];
|
||||
Widget button = client.getWidget(TO_GROUP(compId), TO_CHILD(compId));
|
||||
Widget buttonRect = button.getChild(0);
|
||||
|
||||
final Object[] onOpListener = buttonRect.getOnOpListener();
|
||||
buttonRect.setOnKeyListener((JavaScriptCallback) e ->
|
||||
{
|
||||
int typedChar = e.getTypedKeyChar() - '0';
|
||||
if (typedChar != buttonId)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
log.debug("Bank pin keypress");
|
||||
|
||||
final String input = client.getVar(VarClientStr.CHATBOX_TYPED_TEXT);
|
||||
clientThread.invokeLater(() ->
|
||||
{
|
||||
// reset chatbox input to avoid pin going to chatbox..
|
||||
client.setVar(VarClientStr.CHATBOX_TYPED_TEXT, input);
|
||||
client.runScript(ScriptID.CHAT_PROMPT_INIT);
|
||||
|
||||
client.runScript(onOpListener);
|
||||
});
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user