From 8ec430486d39568d72b813fcebb473f4a1be7d66 Mon Sep 17 00:00:00 2001 From: Owain van Brakel Date: Wed, 19 Feb 2020 17:44:35 +0100 Subject: [PATCH 1/3] config: Fix button state --- .../runelite/client/plugins/config/ConfigPanel.java | 7 +++++-- .../client/plugins/config/PluginListPanel.java | 12 +++--------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/config/ConfigPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/config/ConfigPanel.java index 6fb3fda61e..1fefb6f44f 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/config/ConfigPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/config/ConfigPanel.java @@ -90,7 +90,7 @@ import net.runelite.client.config.Keybind; import net.runelite.client.config.ModifierlessKeybind; import net.runelite.client.config.Range; import net.runelite.client.config.Units; -import net.runelite.client.eventbus.Subscribe; +import net.runelite.client.eventbus.EventBus; import net.runelite.client.events.PluginChanged; import net.runelite.client.plugins.PluginManager; import net.runelite.client.ui.ColorScheme; @@ -136,6 +136,9 @@ class ConfigPanel extends PluginPanel @Inject private ColorPickerManager colorPickerManager; + @Inject + private EventBus eventBus; + private PluginConfigurationDescriptor pluginConfig = null; private final Map sectionWidgets = new HashMap<>(); private final Map titleSectionWidgets = new HashMap<>(); @@ -230,6 +233,7 @@ class ConfigPanel extends PluginPanel } rebuild(false); + eventBus.subscribe(PluginChanged.class, this, this::onPluginChanged); } private void getSections(ConfigDescriptor cd) @@ -1169,7 +1173,6 @@ class ConfigPanel extends PluginPanel return new Dimension(PANEL_WIDTH + SCROLLBAR_WIDTH, super.getPreferredSize().height); } - @Subscribe public void onPluginChanged(PluginChanged event) { if (event.getPlugin() == this.pluginConfig.getPlugin()) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/config/PluginListPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/config/PluginListPanel.java index e44d0625a7..ec5a0b94b7 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/config/PluginListPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/config/PluginListPanel.java @@ -43,7 +43,6 @@ import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; -import java.util.concurrent.ScheduledExecutorService; import java.util.stream.Collectors; import java.util.stream.Stream; import javax.inject.Inject; @@ -70,7 +69,6 @@ import net.runelite.client.config.ConfigManager; import net.runelite.client.config.OpenOSRSConfig; import net.runelite.client.config.RuneLiteConfig; import net.runelite.client.eventbus.EventBus; -import net.runelite.client.eventbus.Subscribe; import net.runelite.client.events.ConfigChanged; import net.runelite.client.events.ExternalPluginChanged; import net.runelite.client.events.ExternalPluginsLoaded; @@ -110,7 +108,6 @@ public class PluginListPanel extends PluginPanel private final ConfigManager configManager; private final PluginManager pluginManager; - private final ScheduledExecutorService executorService; private final Provider configPanelProvider; private final OpenOSRSConfig openOSRSConfig; private final List fakePlugins = new ArrayList<>(); @@ -142,7 +139,6 @@ public class PluginListPanel extends PluginPanel public PluginListPanel( ConfigManager configManager, PluginManager pluginManager, - ScheduledExecutorService executorService, Provider configPanelProvider, OpenOSRSConfig openOSRSConfig, EventBus eventBus) @@ -151,7 +147,6 @@ public class PluginListPanel extends PluginPanel this.configManager = configManager; this.pluginManager = pluginManager; - this.executorService = executorService; this.configPanelProvider = configPanelProvider; this.openOSRSConfig = openOSRSConfig; @@ -186,13 +181,13 @@ public class PluginListPanel extends PluginPanel }); eventBus.subscribe(ExternalPluginsLoaded.class, this, ignored -> { - eventBus.subscribe(ExternalPluginChanged.class, this, ev -> { - SwingUtilities.invokeLater(this::rebuildPluginList); - }); + eventBus.subscribe(ExternalPluginChanged.class, this, ev -> SwingUtilities.invokeLater(this::rebuildPluginList)); SwingUtilities.invokeLater(this::rebuildPluginList); }); + eventBus.subscribe(PluginChanged.class, this, this::onPluginChanged); + muxer = new MultiplexingPluginPanel(this); searchBar = new IconTextField(); @@ -475,7 +470,6 @@ public class PluginListPanel extends PluginPanel configManager.setConfiguration(RUNELITE_GROUP_NAME, PINNED_PLUGINS_CONFIG_KEY, value); } - @Subscribe public void onPluginChanged(PluginChanged event) { SwingUtilities.invokeLater(this::refresh); From 677fc4fdc6aae4fc5adc5fa23e90454604bf29d5 Mon Sep 17 00:00:00 2001 From: Owain van Brakel Date: Wed, 19 Feb 2020 17:45:32 +0100 Subject: [PATCH 2/3] client: Configurable side panel shortcuts --- .../client/config/RuneLiteConfig.java | 94 ++++++++++++++----- .../java/net/runelite/client/ui/ClientUI.java | 43 +++++++-- 2 files changed, 108 insertions(+), 29 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/config/RuneLiteConfig.java b/runelite-client/src/main/java/net/runelite/client/config/RuneLiteConfig.java index ac1e09ceb8..c0ca0bf929 100644 --- a/runelite-client/src/main/java/net/runelite/client/config/RuneLiteConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/config/RuneLiteConfig.java @@ -25,6 +25,8 @@ package net.runelite.client.config; import java.awt.Dimension; +import java.awt.event.InputEvent; +import java.awt.event.KeyEvent; import net.runelite.api.Constants; import net.runelite.client.Notifier; import net.runelite.client.ui.ContainableFrame; @@ -181,11 +183,23 @@ public interface RuneLiteConfig extends Config return 100; } + @ConfigItem( + keyName = "tooltipPosition", + name = "Tooltip Position", + description = "Configures whether to show the tooltip above or under the cursor", + position = 13, + titleSection = "miscTitle" + ) + default TooltipPositionType tooltipPosition() + { + return TooltipPositionType.UNDER_CURSOR; + } + @ConfigTitleSection( keyName = "notificationsTitle", name = "Notifications", description = "", - position = 13 + position = 14 ) default Title notificationsTitle() { @@ -196,7 +210,7 @@ public interface RuneLiteConfig extends Config keyName = "notificationTray", name = "Enable tray notifications", description = "Enables tray notifications", - position = 14, + position = 15, titleSection = "notificationsTitle" ) default boolean enableTrayNotifications() @@ -208,7 +222,7 @@ public interface RuneLiteConfig extends Config keyName = "notificationRequestFocus", name = "Request focus on notification", description = "Toggles window focus request", - position = 15, + position = 16, titleSection = "notificationsTitle" ) default boolean requestFocusOnNotification() @@ -220,7 +234,7 @@ public interface RuneLiteConfig extends Config keyName = "notificationSound", name = "Notification sound", description = "Enables the playing of a beep sound when notifications are displayed", - position = 16, + position = 17, titleSection = "notificationsTitle" ) default Notifier.NativeCustomOff notificationSound() @@ -232,7 +246,7 @@ public interface RuneLiteConfig extends Config keyName = "notificationGameMessage", name = "Enable game message notifications", description = "Puts a notification message in the chatbox", - position = 17, + position = 18, titleSection = "notificationsTitle" ) default boolean enableGameMessageNotification() @@ -244,7 +258,7 @@ public interface RuneLiteConfig extends Config keyName = "notificationFlash", name = "Enable flash notification", description = "Flashes the game frame as a notification", - position = 18, + position = 19, titleSection = "notificationsTitle" ) default FlashNotification flashNotification() @@ -256,7 +270,7 @@ public interface RuneLiteConfig extends Config keyName = "notificationFocused", name = "Send notifications when focused", description = "Toggles all notifications for when the client is focused", - position = 19, + position = 20, titleSection = "notificationsTitle" ) default boolean sendNotificationsWhenFocused() @@ -268,7 +282,7 @@ public interface RuneLiteConfig extends Config keyName = "fontTitle", name = "Font", description = "", - position = 20 + position = 21 ) default Title fontTitle() { @@ -279,7 +293,7 @@ public interface RuneLiteConfig extends Config keyName = "fontType", name = "Dynamic Overlay Font", description = "Configures what font type is used for in-game overlays such as player name, ground items, etc.", - position = 21, + position = 22, titleSection = "fontTitle" ) default FontType fontType() @@ -291,7 +305,7 @@ public interface RuneLiteConfig extends Config keyName = "tooltipFontType", name = "Tooltip Font", description = "Configures what font type is used for in-game tooltips such as food stats, NPC names, etc.", - position = 22, + position = 23, titleSection = "fontTitle" ) default FontType tooltipFontType() @@ -303,7 +317,7 @@ public interface RuneLiteConfig extends Config keyName = "interfaceFontType", name = "Interface Overlay Font", description = "Configures what font type is used for in-game interface overlays such as panels, opponent info, clue scrolls etc.", - position = 23, + position = 24, titleSection = "fontTitle" ) default FontType interfaceFontType() @@ -315,7 +329,7 @@ public interface RuneLiteConfig extends Config keyName = "overlayTitle", name = "Overlays", description = "", - position = 24 + position = 25 ) default Title overlayTitle() { @@ -326,7 +340,7 @@ public interface RuneLiteConfig extends Config keyName = "menuEntryShift", name = "Require Shift for overlay menu", description = "Overlay right-click menu will require shift to be added", - position = 25, + position = 26, titleSection = "overlayTitle" ) default boolean menuEntryShift() @@ -334,22 +348,22 @@ public interface RuneLiteConfig extends Config return true; } - @ConfigItem( - keyName = "tooltipPosition", - name = "Tooltip Position", - description = "Configures whether to show the tooltip above or under the cursor", - position = 35 + @ConfigTitleSection( + keyName = "infoboxTitle", + name = "Infoboxes", + description = "", + position = 27 ) - default TooltipPositionType tooltipPosition() + default Title infoboxTitle() { - return TooltipPositionType.UNDER_CURSOR; + return new Title(); } @ConfigItem( keyName = "infoBoxVertical", name = "Display infoboxes vertically", description = "Toggles the infoboxes to display vertically", - position = 26, + position = 28, titleSection = "infoboxTitle" ) default boolean infoBoxVertical() @@ -361,7 +375,7 @@ public interface RuneLiteConfig extends Config keyName = "infoBoxWrap", name = "Infobox wrap count", description = "Configures the amount of infoboxes shown before wrapping", - position = 27, + position = 29, titleSection = "infoboxTitle" ) default int infoBoxWrap() @@ -373,7 +387,7 @@ public interface RuneLiteConfig extends Config keyName = "infoBoxSize", name = "Infobox size", description = "Configures the size of each infobox in pixels", - position = 28, + position = 30, titleSection = "infoboxTitle" ) @Units(Units.PIXELS) @@ -382,4 +396,38 @@ public interface RuneLiteConfig extends Config return 35; } + @ConfigTitleSection( + keyName = "keybindsTitle", + name = "Key binds", + description = "", + position = 31 + ) + default Title keybindsTitle() + { + return new Title(); + } + + @ConfigItem( + keyName = "sidebarToggleKey", + name = "Sidebar Toggle Key", + description = "The key that will toggle the sidebar (accepts modifiers)", + position = 32, + titleSection = "keybindsTitle" + ) + default Keybind sidebarToggleKey() + { + return new Keybind(KeyEvent.VK_F11, InputEvent.CTRL_DOWN_MASK); + } + + @ConfigItem( + keyName = "panelToggleKey", + name = "Plugin Panel Toggle Key", + description = "The key that will toggle the current or last opened plugin panel (accepts modifiers)", + position = 33, + titleSection = "keybindsTitle" + ) + default Keybind panelToggleKey() + { + return new Keybind(KeyEvent.VK_F12, InputEvent.CTRL_DOWN_MASK); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/ui/ClientUI.java b/runelite-client/src/main/java/net/runelite/client/ui/ClientUI.java index 3e020f0293..de4d89ce35 100644 --- a/runelite-client/src/main/java/net/runelite/client/ui/ClientUI.java +++ b/runelite-client/src/main/java/net/runelite/client/ui/ClientUI.java @@ -43,8 +43,6 @@ import java.awt.Rectangle; import java.awt.Toolkit; import java.awt.TrayIcon; import java.awt.Window; -import java.awt.event.InputEvent; -import java.awt.event.KeyEvent; import java.awt.event.MouseEvent; import java.awt.image.BufferedImage; import java.lang.reflect.Field; @@ -79,7 +77,6 @@ import net.runelite.client.RuneLiteProperties; import net.runelite.client.callback.ClientThread; import net.runelite.client.config.ConfigManager; import net.runelite.client.config.ExpandResizeType; -import net.runelite.client.config.Keybind; import net.runelite.client.config.RuneLiteConfig; import net.runelite.client.config.WarningOnExit; import net.runelite.client.eventbus.EventBus; @@ -366,8 +363,7 @@ public class ClientUI frame.add(container); // Add key listener - final HotkeyListener sidebarListener = new HotkeyListener(() -> - new Keybind(KeyEvent.VK_F11, InputEvent.CTRL_DOWN_MASK)) + final HotkeyListener sidebarListener = new HotkeyListener(config::sidebarToggleKey) { @Override public void hotkeyPressed() @@ -378,6 +374,17 @@ public class ClientUI keyManager.registerKeyListener(sidebarListener); + final HotkeyListener pluginPanelListener = new HotkeyListener(config::panelToggleKey) + { + @Override + public void hotkeyPressed() + { + togglePluginPanel(); + } + }; + + keyManager.registerKeyListener(pluginPanelListener); + // Add mouse listener final MouseListener mouseListener = new MouseAdapter() { @@ -612,7 +619,7 @@ public class ClientUI { OSXUtil.requestFocus(); } - + // The workaround for Windows is to minimise and then un-minimise the client to bring // it to the front because java.awt.Window#toFront doesn't work reliably. // See https://stackoverflow.com/questions/309023/how-to-bring-a-window-to-the-front/7435722#7435722 @@ -795,6 +802,30 @@ public class ClientUI } } + private void togglePluginPanel() + { + // Toggle sidebar open + boolean isPanelOpen = sidebarOpen; + sidebarOpen = !sidebarOpen; + + if (isPanelOpen) + { + contract(); + } + else + { + // Try to restore last panel + expand(currentNavButton); + + //Checks if the toolbar was previously closed by toggleSidebar + if (!container.isAncestorOf(pluginToolbar)) + { + container.add(pluginToolbar); + frame.expandBy(pluginToolbar.getWidth()); + } + } + } + private void expand(@Nullable NavigationButton button) { if (button == null) From a8c0259c1ca786300e3f72682d79fd3c38351923 Mon Sep 17 00:00:00 2001 From: Owain van Brakel Date: Wed, 19 Feb 2020 17:45:46 +0100 Subject: [PATCH 3/3] plugins: Misc --- runelite-api/src/main/java/net/runelite/api/GameShell.java | 2 ++ .../src/main/java/net/runelite/api/widgets/WidgetID.java | 4 ++++ .../src/main/java/net/runelite/api/widgets/WidgetInfo.java | 4 ++++ .../java/net/runelite/client/ui/overlay/OverlayMenuEntry.java | 2 ++ 4 files changed, 12 insertions(+) diff --git a/runelite-api/src/main/java/net/runelite/api/GameShell.java b/runelite-api/src/main/java/net/runelite/api/GameShell.java index 02802e3b76..4d54ec61cb 100644 --- a/runelite-api/src/main/java/net/runelite/api/GameShell.java +++ b/runelite-api/src/main/java/net/runelite/api/GameShell.java @@ -57,4 +57,6 @@ public interface GameShell DrawCallbacks getDrawCallbacks(); void resizeCanvas(); + + void setReplaceCanvasNextFrame(boolean replace); } diff --git a/runelite-api/src/main/java/net/runelite/api/widgets/WidgetID.java b/runelite-api/src/main/java/net/runelite/api/widgets/WidgetID.java index db032d7df8..8c1612c799 100644 --- a/runelite-api/src/main/java/net/runelite/api/widgets/WidgetID.java +++ b/runelite-api/src/main/java/net/runelite/api/widgets/WidgetID.java @@ -265,6 +265,9 @@ public class WidgetID static final int BANK_CONTAINER = 1; static final int INVENTORY_ITEM_CONTAINER = 3; static final int BANK_TITLE_BAR = 3; + static final int ITEM_COUNT_TOP = 4; + static final int ITEM_COUNT_BAR = 5; + static final int ITEM_COUNT_BOTTOM = 6; static final int CONTENT_CONTAINER = 8; static final int TAB_CONTAINER = 9; static final int ITEM_CONTAINER = 11; @@ -273,6 +276,7 @@ public class WidgetID static final int DEPOSIT_EQUIPMENT = 42; static final int INCINERATOR = 44; static final int INCINERATOR_CONFIRM = 45; + static final int EQUIPMENT_BUTTON = 107; } static class GrandExchange diff --git a/runelite-api/src/main/java/net/runelite/api/widgets/WidgetInfo.java b/runelite-api/src/main/java/net/runelite/api/widgets/WidgetInfo.java index 9883ef0402..9269964aaf 100644 --- a/runelite-api/src/main/java/net/runelite/api/widgets/WidgetInfo.java +++ b/runelite-api/src/main/java/net/runelite/api/widgets/WidgetInfo.java @@ -144,6 +144,10 @@ public enum WidgetInfo BANK_DEPOSIT_EQUIPMENT(WidgetID.BANK_GROUP_ID, WidgetID.Bank.DEPOSIT_EQUIPMENT), BANK_DEPOSIT_INVENTORY(WidgetID.BANK_GROUP_ID, WidgetID.Bank.DEPOSIT_INVENTORY), BANK_TAB_CONTAINER(WidgetID.BANK_GROUP_ID, WidgetID.Bank.TAB_CONTAINER), + BANK_EQUIPMENT_BUTTON(WidgetID.BANK_GROUP_ID, WidgetID.Bank.EQUIPMENT_BUTTON), + BANK_ITEM_COUNT_TOP(WidgetID.BANK_GROUP_ID, WidgetID.Bank.ITEM_COUNT_TOP), + BANK_ITEM_COUNT_BAR(WidgetID.BANK_GROUP_ID, WidgetID.Bank.ITEM_COUNT_BAR), + BANK_ITEM_COUNT_BOTTOM(WidgetID.BANK_GROUP_ID, WidgetID.Bank.ITEM_COUNT_BOTTOM), GRAND_EXCHANGE_WINDOW_CONTAINER(WidgetID.GRAND_EXCHANGE_GROUP_ID, WidgetID.GrandExchange.WINDOW_CONTAINER), GRAND_EXCHANGE_OFFER_CONTAINER(WidgetID.GRAND_EXCHANGE_GROUP_ID, WidgetID.GrandExchange.OFFER_CONTAINER), diff --git a/runelite-client/src/main/java/net/runelite/client/ui/overlay/OverlayMenuEntry.java b/runelite-client/src/main/java/net/runelite/client/ui/overlay/OverlayMenuEntry.java index b4e5714eeb..9dd7f856c2 100644 --- a/runelite-client/src/main/java/net/runelite/client/ui/overlay/OverlayMenuEntry.java +++ b/runelite-client/src/main/java/net/runelite/client/ui/overlay/OverlayMenuEntry.java @@ -25,9 +25,11 @@ package net.runelite.client.ui.overlay; import lombok.Value; +import lombok.experimental.NonFinal; import net.runelite.api.MenuOpcode; @Value +@NonFinal public class OverlayMenuEntry { private MenuOpcode menuOpcode;