From 388acc4710c4073b4bbd6af76476f10c01dff864 Mon Sep 17 00:00:00 2001 From: Shaun Dreclin Date: Mon, 25 Nov 2019 01:22:07 -0500 Subject: [PATCH 01/10] menu entry swapper: Add 'help' swap to Arceuus library customers --- .../menuentryswapper/MenuEntrySwapperConfig.java | 10 ++++++++++ .../menuentryswapper/MenuEntrySwapperPlugin.java | 5 +++++ 2 files changed, 15 insertions(+) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperConfig.java index 5e1fc06a39..fd0c7c1554 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperConfig.java @@ -182,6 +182,16 @@ public interface MenuEntrySwapperConfig extends Config return false; } + @ConfigItem( + keyName = "swapHelp", + name = "Help", + description = "Swap Talk-to with Help on Arceuus library customers" + ) + default boolean swapHelp() + { + return true; + } + @ConfigItem( keyName = "swapHomePortal", name = "Home", diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperPlugin.java index e87dff09c3..55794752f3 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperPlugin.java @@ -396,6 +396,11 @@ public class MenuEntrySwapperPlugin extends Plugin swap("exchange", option, target, index); } + if (config.swapHelp()) + { + swap("help", option, target, index); + } + if (config.swapDarkMage()) { swap("repairs", option, target, index); From 1b3fe266bc9a7b15d044640213a7a0b3a5486730 Mon Sep 17 00:00:00 2001 From: dekvall Date: Wed, 27 Nov 2019 21:16:35 +0100 Subject: [PATCH 02/10] prayer-reorder: remove test The plugin has been removed. --- .../ReorderPrayersPluginTest.java | 72 ------------------- 1 file changed, 72 deletions(-) delete mode 100644 runelite-client/src/test/java/net/runelite/client/plugins/reorderprayers/ReorderPrayersPluginTest.java diff --git a/runelite-client/src/test/java/net/runelite/client/plugins/reorderprayers/ReorderPrayersPluginTest.java b/runelite-client/src/test/java/net/runelite/client/plugins/reorderprayers/ReorderPrayersPluginTest.java deleted file mode 100644 index 68caebae42..0000000000 --- a/runelite-client/src/test/java/net/runelite/client/plugins/reorderprayers/ReorderPrayersPluginTest.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2018, Adam - * 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.client.plugins.reorderprayers; - -import net.runelite.api.Prayer; -import static net.runelite.api.Prayer.*; -import static org.junit.Assert.*; -import org.junit.Test; - -public class ReorderPrayersPluginTest -{ - private static final Prayer[] PRAYER_ORDER = new Prayer[]{ - THICK_SKIN, - BURST_OF_STRENGTH, - CLARITY_OF_THOUGHT, - SHARP_EYE, - MYSTIC_WILL, - ROCK_SKIN, - SUPERHUMAN_STRENGTH, - IMPROVED_REFLEXES, - RAPID_RESTORE, - RAPID_HEAL, - PROTECT_ITEM, - HAWK_EYE, - MYSTIC_LORE, - STEEL_SKIN, - ULTIMATE_STRENGTH, - INCREDIBLE_REFLEXES, - PROTECT_FROM_MAGIC, - PROTECT_FROM_MISSILES, - PROTECT_FROM_MELEE, - EAGLE_EYE, - MYSTIC_MIGHT, - RETRIBUTION, - REDEMPTION, - SMITE, - CHIVALRY, - PIETY, - PRESERVE, - RIGOUR, - AUGURY - }; - - @Test - public void testPrayerOrder() - { - // the reorder prayers plugin depends on the Prayer enum order - assertArrayEquals(Prayer.values(), PRAYER_ORDER); - } -} \ No newline at end of file From 192fe54b7a902696c1694725d563bc49a89e08cb Mon Sep 17 00:00:00 2001 From: JZomerlei Date: Sun, 1 Dec 2019 15:35:17 -0500 Subject: [PATCH 03/10] chatcommands: Make chat clearing keybinds configurable (#10308) Closes #6929 --- .../chatcommands/ChatCommandsConfig.java | 24 +++++-- .../chatcommands/ChatKeyboardListener.java | 66 +++++++++---------- 2 files changed, 49 insertions(+), 41 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/chatcommands/ChatCommandsConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/chatcommands/ChatCommandsConfig.java index 5a08937345..9186a6106b 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/chatcommands/ChatCommandsConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/chatcommands/ChatCommandsConfig.java @@ -27,6 +27,9 @@ package net.runelite.client.plugins.chatcommands; import net.runelite.client.config.Config; import net.runelite.client.config.ConfigGroup; import net.runelite.client.config.ConfigItem; +import net.runelite.client.config.Keybind; +import java.awt.event.InputEvent; +import java.awt.event.KeyEvent; @ConfigGroup("chatcommands") public interface ChatCommandsConfig extends Config @@ -121,12 +124,23 @@ public interface ChatCommandsConfig extends Config @ConfigItem( position = 8, - keyName = "clearShortcuts", - name = "Clear shortcuts", - description = "Enable shortcuts (ctrl+w and backspace) for clearing the chatbox" + keyName = "clearSingleWord", + name = "Clear Single Word", + description = "Enable hot key to clear single word at a time" ) - default boolean clearShortcuts() + default Keybind clearSingleWord() { - return true; + return new Keybind(KeyEvent.VK_W, InputEvent.CTRL_DOWN_MASK); + } + + @ConfigItem( + position = 9, + keyName = "clearEntireChatBox", + name = "Clear Chat Box", + description = "Enable hotkey to clear entire chat box" + ) + default Keybind clearChatBox() + { + return new Keybind(KeyEvent.VK_BACK_SPACE, InputEvent.CTRL_DOWN_MASK); } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/chatcommands/ChatKeyboardListener.java b/runelite-client/src/main/java/net/runelite/client/plugins/chatcommands/ChatKeyboardListener.java index dc9c1fffe1..8472030fcb 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/chatcommands/ChatKeyboardListener.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/chatcommands/ChatKeyboardListener.java @@ -54,49 +54,43 @@ public class ChatKeyboardListener implements KeyListener @Override public void keyPressed(KeyEvent e) { - if (!e.isControlDown() || !chatCommandsConfig.clearShortcuts()) + if (chatCommandsConfig.clearSingleWord().matches(e)) { - return; - } - - switch (e.getKeyCode()) - { - case KeyEvent.VK_W: - String input = client.getVar(VarClientStr.CHATBOX_TYPED_TEXT); - if (input != null) + String input = client.getVar(VarClientStr.CHATBOX_TYPED_TEXT); + if (input != null) + { + // remove trailing space + while (input.endsWith(" ")) { - // remove trailing space - while (input.endsWith(" ")) - { - input = input.substring(0, input.length() - 1); - } - - // find next word - int idx = input.lastIndexOf(' '); - final String replacement; - if (idx != -1) - { - replacement = input.substring(0, idx); - } - else - { - replacement = ""; - } - - clientThread.invoke(() -> - { - client.setVar(VarClientStr.CHATBOX_TYPED_TEXT, replacement); - client.runScript(ScriptID.CHAT_PROMPT_INIT); - }); + input = input.substring(0, input.length() - 1); } - break; - case KeyEvent.VK_BACK_SPACE: + + // find next word + int idx = input.lastIndexOf(' '); + final String replacement; + if (idx != -1) + { + replacement = input.substring(0, idx); + } + else + { + replacement = ""; + } + clientThread.invoke(() -> { - client.setVar(VarClientStr.CHATBOX_TYPED_TEXT, ""); + client.setVar(VarClientStr.CHATBOX_TYPED_TEXT, replacement); client.runScript(ScriptID.CHAT_PROMPT_INIT); }); - break; + } + } + else if (chatCommandsConfig.clearChatBox().matches(e)) + { + clientThread.invoke(() -> + { + client.setVar(VarClientStr.CHATBOX_TYPED_TEXT, ""); + client.runScript(ScriptID.CHAT_PROMPT_INIT); + }); } } From 9a2872eacfd929cbed22bac1a6bc8835bde7175f Mon Sep 17 00:00:00 2001 From: Thomas <6449361+hsamoht@users.noreply.github.com> Date: Sun, 1 Dec 2019 23:51:36 +0100 Subject: [PATCH 04/10] chat message manager: deprioritize chat message hook This applies color after all plugins are done processing the event, which fixes the league chaticons plugin stripping color tags when trying to strip the ironman symbol --- .../main/java/net/runelite/client/chat/ChatMessageManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runelite-client/src/main/java/net/runelite/client/chat/ChatMessageManager.java b/runelite-client/src/main/java/net/runelite/client/chat/ChatMessageManager.java index 98df083680..ec4fc4aa91 100644 --- a/runelite-client/src/main/java/net/runelite/client/chat/ChatMessageManager.java +++ b/runelite-client/src/main/java/net/runelite/client/chat/ChatMessageManager.java @@ -107,7 +107,7 @@ public class ChatMessageManager } } - @Subscribe + @Subscribe(priority = 1) // run after all plugins public void onChatMessage(ChatMessage chatMessage) { MessageNode messageNode = chatMessage.getMessageNode(); From 327e3b17707d2918c71208da45c50061a23b6555 Mon Sep 17 00:00:00 2001 From: Thomas <6449361+hsamoht@users.noreply.github.com> Date: Sun, 1 Dec 2019 23:55:12 +0100 Subject: [PATCH 05/10] league chat icons: fix plugin name --- .../client/plugins/leaguechaticons/LeagueChatIconsPlugin.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/leaguechaticons/LeagueChatIconsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/leaguechaticons/LeagueChatIconsPlugin.java index 55a30bbeef..4001a7312f 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/leaguechaticons/LeagueChatIconsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/leaguechaticons/LeagueChatIconsPlugin.java @@ -58,7 +58,7 @@ import net.runelite.http.api.worlds.WorldResult; import net.runelite.http.api.worlds.WorldType; @PluginDescriptor( - name = "Chat League Icons", + name = "League Chat Icons", description = "Changes the chat icon for players on league worlds", enabledByDefault = false ) From d2ef3b16dcd4cfe31511db1ffd642eb9040e3423 Mon Sep 17 00:00:00 2001 From: KC Sparks Date: Sun, 1 Dec 2019 18:26:40 -0700 Subject: [PATCH 06/10] menu entry swapper: add captain khaled talk-to/task swap --- .../menuentryswapper/MenuEntrySwapperConfig.java | 10 ++++++++++ .../menuentryswapper/MenuEntrySwapperPlugin.java | 5 +++++ 2 files changed, 15 insertions(+) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperConfig.java index 5e1fc06a39..fc1acaffcb 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperConfig.java @@ -132,6 +132,16 @@ public interface MenuEntrySwapperConfig extends Config return true; } + @ConfigItem( + keyName = "swapCaptainKhaled", + name = "Task", + description = "Swap Talk-to with Task for Captain Khaled in Port Piscarilius" + ) + default boolean swapCaptainKhaled() + { + return false; + } + @ConfigItem( keyName = "swapDecant", name = "Decant", diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperPlugin.java index e87dff09c3..471e9826e2 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperPlugin.java @@ -381,6 +381,11 @@ public class MenuEntrySwapperPlugin extends Plugin swap("send-parcel", option, target, index); } + if (config.swapCaptainKhaled() && target.contains("captain khaled")) + { + swap("task", option, target, index); + } + if (config.swapBank()) { swap("bank", option, target, index); From 22b8c77fca3908b5db7b14d8c95f00b5a9514842 Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 1 Dec 2019 14:02:54 -0500 Subject: [PATCH 07/10] client: rename zoom plugin to camera plugin --- .../CameraConfig.java} | 6 ++-- .../CameraPlugin.java} | 36 +++++++++---------- .../{zoom => camera}/ControlFunction.java | 2 +- 3 files changed, 22 insertions(+), 22 deletions(-) rename runelite-client/src/main/java/net/runelite/client/plugins/{zoom/ZoomConfig.java => camera/CameraConfig.java} (95%) rename runelite-client/src/main/java/net/runelite/client/plugins/{zoom/ZoomPlugin.java => camera/CameraPlugin.java} (80%) rename runelite-client/src/main/java/net/runelite/client/plugins/{zoom => camera}/ControlFunction.java (97%) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/zoom/ZoomConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/camera/CameraConfig.java similarity index 95% rename from runelite-client/src/main/java/net/runelite/client/plugins/zoom/ZoomConfig.java rename to runelite-client/src/main/java/net/runelite/client/plugins/camera/CameraConfig.java index 781e105298..59d1d33466 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/zoom/ZoomConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/camera/CameraConfig.java @@ -22,15 +22,15 @@ * (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.client.plugins.zoom; +package net.runelite.client.plugins.camera; import net.runelite.client.config.Config; import net.runelite.client.config.ConfigGroup; import net.runelite.client.config.ConfigItem; import net.runelite.client.config.Range; -@ConfigGroup("zoom") -public interface ZoomConfig extends Config +@ConfigGroup("zoom") // using the old plugin's group name +public interface CameraConfig extends Config { int OUTER_LIMIT_MIN = -400; int OUTER_LIMIT_MAX = 400; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/zoom/ZoomPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/camera/CameraPlugin.java similarity index 80% rename from runelite-client/src/main/java/net/runelite/client/plugins/zoom/ZoomPlugin.java rename to runelite-client/src/main/java/net/runelite/client/plugins/camera/CameraPlugin.java index 44f60ebf7c..5f42b19321 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/zoom/ZoomPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/camera/CameraPlugin.java @@ -23,7 +23,7 @@ * (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.client.plugins.zoom; +package net.runelite.client.plugins.camera; import com.google.common.primitives.Ints; import com.google.inject.Inject; @@ -43,12 +43,12 @@ import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.PluginDescriptor; @PluginDescriptor( - name = "Camera Zoom", + name = "Camera", description = "Expand zoom limit and/or enable vertical camera", - tags = {"limit", "vertical"}, + tags = {"zoom", "limit", "vertical"}, enabledByDefault = false ) -public class ZoomPlugin extends Plugin implements KeyListener +public class CameraPlugin extends Plugin implements KeyListener { private static final int DEFAULT_ZOOM_INCREMENT = 25; @@ -61,15 +61,15 @@ public class ZoomPlugin extends Plugin implements KeyListener private ClientThread clientThread; @Inject - private ZoomConfig zoomConfig; + private CameraConfig config; @Inject private KeyManager keyManager; @Provides - ZoomConfig getConfig(ConfigManager configManager) + CameraConfig getConfig(ConfigManager configManager) { - return configManager.getConfig(ZoomConfig.class); + return configManager.getConfig(CameraConfig.class); } @Subscribe @@ -85,32 +85,32 @@ public class ZoomPlugin extends Plugin implements KeyListener int[] intStack = client.getIntStack(); int intStackSize = client.getIntStackSize(); - if (!controlDown && "scrollWheelZoom".equals(event.getEventName()) && zoomConfig.controlFunction() == ControlFunction.CONTROL_TO_ZOOM) + if (!controlDown && "scrollWheelZoom".equals(event.getEventName()) && config.controlFunction() == ControlFunction.CONTROL_TO_ZOOM) { intStack[intStackSize - 1] = 1; } - if ("innerZoomLimit".equals(event.getEventName()) && zoomConfig.innerLimit()) + if ("innerZoomLimit".equals(event.getEventName()) && config.innerLimit()) { - intStack[intStackSize - 1] = ZoomConfig.INNER_ZOOM_LIMIT; + intStack[intStackSize - 1] = CameraConfig.INNER_ZOOM_LIMIT; return; } if ("outerZoomLimit".equals(event.getEventName())) { - int outerLimit = Ints.constrainToRange(zoomConfig.outerLimit(), ZoomConfig.OUTER_LIMIT_MIN, ZoomConfig.OUTER_LIMIT_MAX); + int outerLimit = Ints.constrainToRange(config.outerLimit(), CameraConfig.OUTER_LIMIT_MIN, CameraConfig.OUTER_LIMIT_MAX); int outerZoomLimit = 128 - outerLimit; intStack[intStackSize - 1] = outerZoomLimit; return; } - if ("scrollWheelZoomIncrement".equals(event.getEventName()) && zoomConfig.zoomIncrement() != DEFAULT_ZOOM_INCREMENT) + if ("scrollWheelZoomIncrement".equals(event.getEventName()) && config.zoomIncrement() != DEFAULT_ZOOM_INCREMENT) { - intStack[intStackSize - 1] = zoomConfig.zoomIncrement(); + intStack[intStackSize - 1] = config.zoomIncrement(); return; } - if (zoomConfig.innerLimit()) + if (config.innerLimit()) { // This lets the options panel's slider have an exponential rate final double exponent = 2.d; @@ -148,7 +148,7 @@ public class ZoomPlugin extends Plugin implements KeyListener @Override protected void startUp() { - client.setCameraPitchRelaxerEnabled(zoomConfig.relaxCameraPitch()); + client.setCameraPitchRelaxerEnabled(config.relaxCameraPitch()); keyManager.registerKeyListener(this); } @@ -163,7 +163,7 @@ public class ZoomPlugin extends Plugin implements KeyListener @Subscribe public void onConfigChanged(ConfigChanged ev) { - client.setCameraPitchRelaxerEnabled(zoomConfig.relaxCameraPitch()); + client.setCameraPitchRelaxerEnabled(config.relaxCameraPitch()); } @Override @@ -187,9 +187,9 @@ public class ZoomPlugin extends Plugin implements KeyListener { controlDown = false; - if (zoomConfig.controlFunction() == ControlFunction.CONTROL_TO_RESET) + if (config.controlFunction() == ControlFunction.CONTROL_TO_RESET) { - final int zoomValue = Ints.constrainToRange(zoomConfig.ctrlZoomValue(), ZoomConfig.OUTER_LIMIT_MIN, ZoomConfig.INNER_ZOOM_LIMIT); + final int zoomValue = Ints.constrainToRange(config.ctrlZoomValue(), CameraConfig.OUTER_LIMIT_MIN, CameraConfig.INNER_ZOOM_LIMIT); clientThread.invokeLater(() -> client.runScript(ScriptID.CAMERA_DO_ZOOM, zoomValue, zoomValue)); } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/zoom/ControlFunction.java b/runelite-client/src/main/java/net/runelite/client/plugins/camera/ControlFunction.java similarity index 97% rename from runelite-client/src/main/java/net/runelite/client/plugins/zoom/ControlFunction.java rename to runelite-client/src/main/java/net/runelite/client/plugins/camera/ControlFunction.java index 1f3b431808..07fecfd5ba 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/zoom/ControlFunction.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/camera/ControlFunction.java @@ -23,7 +23,7 @@ * 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.client.plugins.zoom; +package net.runelite.client.plugins.camera; import lombok.AllArgsConstructor; import lombok.Getter; From d6198ff3116cfecb5e8f6d1987c31230047c6e56 Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 1 Dec 2019 15:20:15 -0500 Subject: [PATCH 08/10] camera plugin: add option to rotate camera with right click The camera rotation only takes effect when there are no menu entries. This also adds an option to make the middle button then open the menu. Co-authored-by: Wynadorn --- .../main/java/net/runelite/api/VarPlayer.java | 7 +- .../client/plugins/camera/CameraConfig.java | 32 +++ .../client/plugins/camera/CameraPlugin.java | 195 +++++++++++++++++- 3 files changed, 228 insertions(+), 6 deletions(-) diff --git a/runelite-api/src/main/java/net/runelite/api/VarPlayer.java b/runelite-api/src/main/java/net/runelite/api/VarPlayer.java index c4d5cb4fdf..3c6c616599 100644 --- a/runelite-api/src/main/java/net/runelite/api/VarPlayer.java +++ b/runelite-api/src/main/java/net/runelite/api/VarPlayer.java @@ -171,7 +171,12 @@ public enum VarPlayer MUSIC_VOLUME(168), SOUND_EFFECT_VOLUME(169), - AREA_EFFECT_VOLUME(872); + AREA_EFFECT_VOLUME(872), + + /** + * 0 = 2 buttons, 1 = 1 button + */ + MOUSE_BUTTONS(170); private final int id; } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/camera/CameraConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/camera/CameraConfig.java index 59d1d33466..c7856d938b 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/camera/CameraConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/camera/CameraConfig.java @@ -115,4 +115,36 @@ public interface CameraConfig extends Config return 25; } + @ConfigItem( + keyName = "rightClickMovesCamera", + name = "Right click moves camera", + description = "Remaps right click to middle mouse click if there are no menu options", + position = 7 + ) + default boolean rightClickMovesCamera() + { + return false; + } + + @ConfigItem( + keyName = "ignoreExamine", + name = "Ignore Examine", + description = "Ignore the Examine menu entry", + position = 8 + ) + default boolean ignoreExamine() + { + return false; + } + + @ConfigItem( + keyName = "middleClickMenu", + name = "Middle-button opens menu", + description = "Middle-mouse button always opens the menu", + position = 9 + ) + default boolean middleClickMenu() + { + return false; + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/camera/CameraPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/camera/CameraPlugin.java index 5f42b19321..044798c07a 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/camera/CameraPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/camera/CameraPlugin.java @@ -1,6 +1,7 @@ /* * Copyright (c) 2018 Abex * Copyright (c) 2018, Adam + * Copyright (c) 2019, Wynadorn * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -26,33 +27,48 @@ package net.runelite.client.plugins.camera; import com.google.common.primitives.Ints; -import com.google.inject.Inject; import com.google.inject.Provides; import java.awt.event.KeyEvent; +import java.awt.event.MouseEvent; +import javax.inject.Inject; +import javax.swing.SwingUtilities; import net.runelite.api.Client; +import net.runelite.api.MenuAction; +import net.runelite.api.MenuEntry; import net.runelite.api.ScriptID; -import net.runelite.client.events.ConfigChanged; +import net.runelite.api.VarPlayer; +import net.runelite.api.events.ClientTick; import net.runelite.api.events.FocusChanged; import net.runelite.api.events.ScriptCallbackEvent; import net.runelite.client.callback.ClientThread; import net.runelite.client.config.ConfigManager; import net.runelite.client.eventbus.Subscribe; +import net.runelite.client.events.ConfigChanged; import net.runelite.client.input.KeyListener; import net.runelite.client.input.KeyManager; +import net.runelite.client.input.MouseListener; +import net.runelite.client.input.MouseManager; import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.PluginDescriptor; @PluginDescriptor( name = "Camera", - description = "Expand zoom limit and/or enable vertical camera", - tags = {"zoom", "limit", "vertical"}, + description = "Expands zoom limit, provides vertical camera, and remaps mouse input keys", + tags = {"zoom", "limit", "vertical", "click", "mouse"}, enabledByDefault = false ) -public class CameraPlugin extends Plugin implements KeyListener +public class CameraPlugin extends Plugin implements KeyListener, MouseListener { private static final int DEFAULT_ZOOM_INCREMENT = 25; private boolean controlDown; + // flags used to store the mousedown states + private boolean rightClick; + private boolean middleClick; + /** + * Whether or not the current menu has any non-ignored menu entries + */ + private boolean menuHasEntries; @Inject private Client client; @@ -66,6 +82,9 @@ public class CameraPlugin extends Plugin implements KeyListener @Inject private KeyManager keyManager; + @Inject + private MouseManager mouseManager; + @Provides CameraConfig getConfig(ConfigManager configManager) { @@ -148,8 +167,12 @@ public class CameraPlugin extends Plugin implements KeyListener @Override protected void startUp() { + rightClick = false; + middleClick = false; + menuHasEntries = false; client.setCameraPitchRelaxerEnabled(config.relaxCameraPitch()); keyManager.registerKeyListener(this); + mouseManager.registerMouseListener(this); } @Override @@ -157,6 +180,7 @@ public class CameraPlugin extends Plugin implements KeyListener { client.setCameraPitchRelaxerEnabled(false); keyManager.unregisterKeyListener(this); + mouseManager.unregisterMouseListener(this); controlDown = false; } @@ -194,4 +218,165 @@ public class CameraPlugin extends Plugin implements KeyListener } } } + + /** + * Checks if the menu has any non-ignored entries + */ + private boolean hasMenuEntries(MenuEntry[] menuEntries) + { + for (MenuEntry menuEntry : menuEntries) + { + MenuAction action = MenuAction.of(menuEntry.getType()); + switch (action) + { + case CANCEL: + case WALK: + break; + case EXAMINE_OBJECT: + case EXAMINE_NPC: + case EXAMINE_ITEM_GROUND: + case EXAMINE_ITEM: + case EXAMINE_ITEM_BANK_EQ: + if (config.ignoreExamine()) + { + break; + } + default: + return true; + } + } + return false; + } + + /** + * Checks if the menu has any options, because menu entries are built each + * tick and the MouseListener runs on the awt thread + */ + @Subscribe + public void onClientTick(ClientTick event) + { + menuHasEntries = hasMenuEntries(client.getMenuEntries()); + } + + /** + * The event that is triggered when a mouse button is pressed + * In this method the right click is changed to a middle-click to enable rotating the camera + *

+ * This method also provides the config option to enable the middle-mouse button to always open the right click menu + */ + @Override + public MouseEvent mousePressed(MouseEvent mouseEvent) + { + if (SwingUtilities.isRightMouseButton(mouseEvent) && config.rightClickMovesCamera()) + { + boolean oneButton = client.getVar(VarPlayer.MOUSE_BUTTONS) == 1; + // Only move the camera if there is nothing at the menu, or if + // in one-button mode. In one-button mode, left and right click always do the same thing, + // so always treat it as the menu is empty + if (!menuHasEntries || oneButton) + { + // Set the rightClick flag to true so we can release the button in mouseReleased() later + rightClick = true; + // Change the mousePressed() MouseEvent to the middle mouse button + mouseEvent = new MouseEvent((java.awt.Component) mouseEvent.getSource(), + mouseEvent.getID(), + mouseEvent.getWhen(), + mouseEvent.getModifiersEx(), + mouseEvent.getX(), + mouseEvent.getY(), + mouseEvent.getClickCount(), + mouseEvent.isPopupTrigger(), + MouseEvent.BUTTON2); + } + } + else if (SwingUtilities.isMiddleMouseButton((mouseEvent)) && config.middleClickMenu()) + { + // Set the middleClick flag to true so we can release it later in mouseReleased() + middleClick = true; + // Chance the middle mouse button MouseEvent to a right-click + mouseEvent = new MouseEvent((java.awt.Component) mouseEvent.getSource(), + mouseEvent.getID(), + mouseEvent.getWhen(), + mouseEvent.getModifiersEx(), + mouseEvent.getX(), + mouseEvent.getY(), + mouseEvent.getClickCount(), + mouseEvent.isPopupTrigger(), + MouseEvent.BUTTON3); + } + return mouseEvent; + } + + /** + * Correct the MouseEvent to release the correct button + */ + @Override + public MouseEvent mouseReleased(MouseEvent mouseEvent) + { + if (rightClick) + { + rightClick = false; + // Change the MouseEvent to button 2 so the middle mouse button will be released + mouseEvent = new MouseEvent((java.awt.Component) mouseEvent.getSource(), + mouseEvent.getID(), + mouseEvent.getWhen(), + mouseEvent.getModifiersEx(), + mouseEvent.getX(), + mouseEvent.getY(), + mouseEvent.getClickCount(), + mouseEvent.isPopupTrigger(), + MouseEvent.BUTTON2); + + } + if (middleClick) + { + middleClick = false; + // Change the MouseEvent ot button 3 so the right mouse button will be released + mouseEvent = new MouseEvent((java.awt.Component) mouseEvent.getSource(), + mouseEvent.getID(), + mouseEvent.getWhen(), + mouseEvent.getModifiersEx(), + mouseEvent.getX(), + mouseEvent.getY(), + mouseEvent.getClickCount(), + mouseEvent.isPopupTrigger(), + MouseEvent.BUTTON3); + } + return mouseEvent; + } + + /* + * These methods are unused but required to be present in a MouseListener implementation + */ + // region Unused MouseListener methods + @Override + public MouseEvent mouseDragged(MouseEvent mouseEvent) + { + return mouseEvent; + } + + @Override + public MouseEvent mouseMoved(MouseEvent mouseEvent) + { + return mouseEvent; + } + + @Override + public MouseEvent mouseClicked(MouseEvent mouseEvent) + { + return mouseEvent; + } + + @Override + public MouseEvent mouseEntered(MouseEvent mouseEvent) + { + return mouseEvent; + } + + @Override + public MouseEvent mouseExited(MouseEvent mouseEvent) + { + return mouseEvent; + } + // endregion } From 883fd21cfd6fd307fead556ddee9b172457ea31d Mon Sep 17 00:00:00 2001 From: Adam Date: Mon, 2 Dec 2019 19:43:11 -0500 Subject: [PATCH 09/10] object indicators: fix unmarking objects matched by name --- .../ObjectIndicatorsPlugin.java | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/objectindicators/ObjectIndicatorsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/objectindicators/ObjectIndicatorsPlugin.java index dad5bd5c52..012c404b47 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/objectindicators/ObjectIndicatorsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/objectindicators/ObjectIndicatorsPlugin.java @@ -309,7 +309,7 @@ public class ObjectIndicatorsPlugin extends Plugin implements KeyListener return; } - markObject(name, object); + markObject(objectDefinition, name, object); } private void checkObjectPoints(TileObject object) @@ -406,13 +406,14 @@ public class ObjectIndicatorsPlugin extends Plugin implements KeyListener return false; } - private void markObject(String name, final TileObject object) + /** mark or unmark an object + * + * @param objectComposition transformed composition of object based on vars + * @param name name of objectComposition + * @param object tile object, for multilocs object.getId() is the base id + */ + private void markObject(ObjectComposition objectComposition, String name, final TileObject object) { - if (object == null) - { - return; - } - final WorldPoint worldPoint = WorldPoint.fromLocalInstance(client, object.getLocalLocation()); final int regionId = worldPoint.getRegionID(); final ObjectPoint point = new ObjectPoint( @@ -427,9 +428,11 @@ public class ObjectIndicatorsPlugin extends Plugin implements KeyListener if (objects.remove(object)) { - // Use object id instead of name to match the object point with this object due to the object name being - // able to change because of multilocs. - if (!objectPoints.removeIf(op -> (op.getId() == -1 || op.getId() == object.getId()) + // Find the object point that caused this object to be marked, there are two cases: + // 1) object is a multiloc, the name may have changed since marking - match from base id + // 2) not a multiloc, but an object has spawned with an identical name and a different + // id as what was originally marked + if (!objectPoints.removeIf(op -> ((op.getId() == -1 || op.getId() == object.getId()) || op.getName().equals(objectComposition.getName())) && op.getRegionX() == worldPoint.getRegionX() && op.getRegionY() == worldPoint.getRegionY() && op.getZ() == worldPoint.getPlane())) From 8eb1818846d74793b2bfed0470ed08d8c10b023a Mon Sep 17 00:00:00 2001 From: Adam Date: Mon, 2 Dec 2019 19:42:39 -0500 Subject: [PATCH 10/10] object indicators: fix checkObjectPoints to check plane --- .../plugins/objectindicators/ObjectIndicatorsPlugin.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/objectindicators/ObjectIndicatorsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/objectindicators/ObjectIndicatorsPlugin.java index 012c404b47..79bc678f3e 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/objectindicators/ObjectIndicatorsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/objectindicators/ObjectIndicatorsPlugin.java @@ -325,7 +325,8 @@ public class ObjectIndicatorsPlugin extends Plugin implements KeyListener for (ObjectPoint objectPoint : objectPoints) { if (worldPoint.getRegionX() == objectPoint.getRegionX() - && worldPoint.getRegionY() == objectPoint.getRegionY()) + && worldPoint.getRegionY() == objectPoint.getRegionY() + && object.getPlane() == objectPoint.getZ()) { // Transform object to get the name which matches against what we've stored if (objectPoint.getName().equals(getObjectComposition(object.getId()).getName()))