From ddb4eee2ec7e917a2a37dd5157651f4c3a219450 Mon Sep 17 00:00:00 2001 From: Owain van Brakel Date: Thu, 11 Jul 2019 07:01:44 +0200 Subject: [PATCH] client: Event post fix, and save values in keyremapping --- .../keyremapping/KeyRemappingListener.java | 55 +++++++++---------- .../keyremapping/KeyRemappingPlugin.java | 39 +++++++++++++ .../runelite/mixins/RSItemContainerMixin.java | 11 +++- 3 files changed, 73 insertions(+), 32 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/keyremapping/KeyRemappingListener.java b/runelite-client/src/main/java/net/runelite/client/plugins/keyremapping/KeyRemappingListener.java index 185545ba27..cdff5fcd62 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/keyremapping/KeyRemappingListener.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/keyremapping/KeyRemappingListener.java @@ -45,9 +45,6 @@ class KeyRemappingListener extends MouseAdapter implements KeyListener @Inject private KeyRemappingPlugin plugin; - @Inject - private KeyRemappingConfig config; - @Inject private Client client; @@ -100,67 +97,67 @@ class KeyRemappingListener extends MouseAdapter implements KeyListener // to select options if (plugin.isFkeyRemap() && !plugin.isDialogOpen()) { - if (config.f1().matches(e)) + if (plugin.getF1().matches(e)) { modified.put(e.getKeyCode(), KeyEvent.VK_F1); e.setKeyCode(KeyEvent.VK_F1); } - else if (config.f2().matches(e)) + else if (plugin.getF2().matches(e)) { modified.put(e.getKeyCode(), KeyEvent.VK_F2); e.setKeyCode(KeyEvent.VK_F2); } - else if (config.f3().matches(e)) + else if (plugin.getF3().matches(e)) { modified.put(e.getKeyCode(), KeyEvent.VK_F3); e.setKeyCode(KeyEvent.VK_F3); } - else if (config.f4().matches(e)) + else if (plugin.getF4().matches(e)) { modified.put(e.getKeyCode(), KeyEvent.VK_F4); e.setKeyCode(KeyEvent.VK_F4); } - else if (config.f5().matches(e)) + else if (plugin.getF5().matches(e)) { modified.put(e.getKeyCode(), KeyEvent.VK_F5); e.setKeyCode(KeyEvent.VK_F5); } - else if (config.f6().matches(e)) + else if (plugin.getF6().matches(e)) { modified.put(e.getKeyCode(), KeyEvent.VK_F6); e.setKeyCode(KeyEvent.VK_F6); } - else if (config.f7().matches(e)) + else if (plugin.getF7().matches(e)) { modified.put(e.getKeyCode(), KeyEvent.VK_F7); e.setKeyCode(KeyEvent.VK_F7); } - else if (config.f8().matches(e)) + else if (plugin.getF8().matches(e)) { modified.put(e.getKeyCode(), KeyEvent.VK_F8); e.setKeyCode(KeyEvent.VK_F8); } - else if (config.f9().matches(e)) + else if (plugin.getF9().matches(e)) { modified.put(e.getKeyCode(), KeyEvent.VK_F9); e.setKeyCode(KeyEvent.VK_F9); } - else if (config.f10().matches(e)) + else if (plugin.getF10().matches(e)) { modified.put(e.getKeyCode(), KeyEvent.VK_F10); e.setKeyCode(KeyEvent.VK_F10); } - else if (config.f11().matches(e)) + else if (plugin.getF11().matches(e)) { modified.put(e.getKeyCode(), KeyEvent.VK_F11); e.setKeyCode(KeyEvent.VK_F11); } - else if (config.f12().matches(e)) + else if (plugin.getF12().matches(e)) { modified.put(e.getKeyCode(), KeyEvent.VK_F12); e.setKeyCode(KeyEvent.VK_F12); } - else if (config.esc().matches(e)) + else if (plugin.getEsc().matches(e)) { modified.put(e.getKeyCode(), KeyEvent.VK_ESCAPE); e.setKeyCode(KeyEvent.VK_ESCAPE); @@ -238,55 +235,55 @@ class KeyRemappingListener extends MouseAdapter implements KeyListener if (plugin.isFkeyRemap()) { - if (config.f1().matches(e)) + if (plugin.getF1().matches(e)) { e.setKeyCode(KeyEvent.VK_F1); } - else if (config.f2().matches(e)) + else if (plugin.getF2().matches(e)) { e.setKeyCode(KeyEvent.VK_F2); } - else if (config.f3().matches(e)) + else if (plugin.getF3().matches(e)) { e.setKeyCode(KeyEvent.VK_F3); } - else if (config.f4().matches(e)) + else if (plugin.getF4().matches(e)) { e.setKeyCode(KeyEvent.VK_F4); } - else if (config.f5().matches(e)) + else if (plugin.getF5().matches(e)) { e.setKeyCode(KeyEvent.VK_F5); } - else if (config.f6().matches(e)) + else if (plugin.getF6().matches(e)) { e.setKeyCode(KeyEvent.VK_F6); } - else if (config.f7().matches(e)) + else if (plugin.getF7().matches(e)) { e.setKeyCode(KeyEvent.VK_F7); } - else if (config.f8().matches(e)) + else if (plugin.getF8().matches(e)) { e.setKeyCode(KeyEvent.VK_F8); } - else if (config.f9().matches(e)) + else if (plugin.getF9().matches(e)) { e.setKeyCode(KeyEvent.VK_F9); } - else if (config.f10().matches(e)) + else if (plugin.getF10().matches(e)) { e.setKeyCode(KeyEvent.VK_F10); } - else if (config.f11().matches(e)) + else if (plugin.getF11().matches(e)) { e.setKeyCode(KeyEvent.VK_F11); } - else if (config.f12().matches(e)) + else if (plugin.getF12().matches(e)) { e.setKeyCode(KeyEvent.VK_F12); } - else if (config.esc().matches(e)) + else if (plugin.getEsc().matches(e)) { e.setKeyCode(KeyEvent.VK_ESCAPE); } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/keyremapping/KeyRemappingPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/keyremapping/KeyRemappingPlugin.java index a269a80c8f..55e2122ef1 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/keyremapping/KeyRemappingPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/keyremapping/KeyRemappingPlugin.java @@ -97,6 +97,32 @@ public class KeyRemappingPlugin extends Plugin private ModifierlessKeybind right; @Getter(AccessLevel.PACKAGE) private boolean fkeyRemap; + @Getter(AccessLevel.PACKAGE) + private ModifierlessKeybind f1; + @Getter(AccessLevel.PACKAGE) + private ModifierlessKeybind f2; + @Getter(AccessLevel.PACKAGE) + private ModifierlessKeybind f3; + @Getter(AccessLevel.PACKAGE) + private ModifierlessKeybind f4; + @Getter(AccessLevel.PACKAGE) + private ModifierlessKeybind f5; + @Getter(AccessLevel.PACKAGE) + private ModifierlessKeybind f6; + @Getter(AccessLevel.PACKAGE) + private ModifierlessKeybind f7; + @Getter(AccessLevel.PACKAGE) + private ModifierlessKeybind f8; + @Getter(AccessLevel.PACKAGE) + private ModifierlessKeybind f9; + @Getter(AccessLevel.PACKAGE) + private ModifierlessKeybind f10; + @Getter(AccessLevel.PACKAGE) + private ModifierlessKeybind f11; + @Getter(AccessLevel.PACKAGE) + private ModifierlessKeybind f12; + @Getter(AccessLevel.PACKAGE) + private ModifierlessKeybind esc; @Override protected void startUp() throws Exception @@ -276,5 +302,18 @@ public class KeyRemappingPlugin extends Plugin this.left = config.left(); this.right = config.right(); this.fkeyRemap = config.fkeyRemap(); + this.f1 = config.f1(); + this.f2 = config.f2(); + this.f3 = config.f3(); + this.f4 = config.f4(); + this.f5 = config.f5(); + this.f6 = config.f6(); + this.f7 = config.f7(); + this.f8 = config.f8(); + this.f9 = config.f9(); + this.f10 = config.f10(); + this.f11 = config.f11(); + this.f12 = config.f12(); + this.esc = config.esc(); } } diff --git a/runelite-mixins/src/main/java/net/runelite/mixins/RSItemContainerMixin.java b/runelite-mixins/src/main/java/net/runelite/mixins/RSItemContainerMixin.java index 25ddd7e681..3fa90478d2 100644 --- a/runelite-mixins/src/main/java/net/runelite/mixins/RSItemContainerMixin.java +++ b/runelite-mixins/src/main/java/net/runelite/mixins/RSItemContainerMixin.java @@ -45,6 +45,9 @@ public abstract class RSItemContainerMixin implements RSItemContainer @Inject static private int rl$lastCycle; + @Inject + static private int rl$lastContainer; + @Inject @Override public Item[] getItems() @@ -76,14 +79,16 @@ public abstract class RSItemContainerMixin implements RSItemContainer rs$itemContainerSetItem(itemContainerId, index, itemId, itemQuantity); int cycle = client.getGameCycle(); - if (rl$lastCycle == cycle) + + if (rl$lastCycle == cycle && rl$lastContainer == itemContainerId) { - // Limit item container updates to one per cycle - // No need to repeatedly update. The game just needs to know that containers changed once per cycle + // Limit item container updates to one per cycle per container return; } rl$lastCycle = cycle; + rl$lastContainer = itemContainerId; + ItemContainerChanged event = new ItemContainerChanged(itemContainerId, client.getItemContainer(InventoryID.getValue(itemContainerId))); client.getCallbacks().postDeferred(event); }