Merge pull request #2360 from Owain94/misc

misc: Fix button state, Configurable side panel shortcuts
This commit is contained in:
Owain van Brakel
2020-02-19 19:16:56 +01:00
committed by GitHub
8 changed files with 128 additions and 40 deletions

View File

@@ -57,4 +57,6 @@ public interface GameShell
DrawCallbacks getDrawCallbacks(); DrawCallbacks getDrawCallbacks();
void resizeCanvas(); void resizeCanvas();
void setReplaceCanvasNextFrame(boolean replace);
} }

View File

@@ -265,6 +265,9 @@ public class WidgetID
static final int BANK_CONTAINER = 1; static final int BANK_CONTAINER = 1;
static final int INVENTORY_ITEM_CONTAINER = 3; static final int INVENTORY_ITEM_CONTAINER = 3;
static final int BANK_TITLE_BAR = 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 CONTENT_CONTAINER = 8;
static final int TAB_CONTAINER = 9; static final int TAB_CONTAINER = 9;
static final int ITEM_CONTAINER = 11; static final int ITEM_CONTAINER = 11;
@@ -273,6 +276,7 @@ public class WidgetID
static final int DEPOSIT_EQUIPMENT = 42; static final int DEPOSIT_EQUIPMENT = 42;
static final int INCINERATOR = 44; static final int INCINERATOR = 44;
static final int INCINERATOR_CONFIRM = 45; static final int INCINERATOR_CONFIRM = 45;
static final int EQUIPMENT_BUTTON = 107;
} }
static class GrandExchange static class GrandExchange

View File

@@ -144,6 +144,10 @@ public enum WidgetInfo
BANK_DEPOSIT_EQUIPMENT(WidgetID.BANK_GROUP_ID, WidgetID.Bank.DEPOSIT_EQUIPMENT), BANK_DEPOSIT_EQUIPMENT(WidgetID.BANK_GROUP_ID, WidgetID.Bank.DEPOSIT_EQUIPMENT),
BANK_DEPOSIT_INVENTORY(WidgetID.BANK_GROUP_ID, WidgetID.Bank.DEPOSIT_INVENTORY), BANK_DEPOSIT_INVENTORY(WidgetID.BANK_GROUP_ID, WidgetID.Bank.DEPOSIT_INVENTORY),
BANK_TAB_CONTAINER(WidgetID.BANK_GROUP_ID, WidgetID.Bank.TAB_CONTAINER), 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_WINDOW_CONTAINER(WidgetID.GRAND_EXCHANGE_GROUP_ID, WidgetID.GrandExchange.WINDOW_CONTAINER),
GRAND_EXCHANGE_OFFER_CONTAINER(WidgetID.GRAND_EXCHANGE_GROUP_ID, WidgetID.GrandExchange.OFFER_CONTAINER), GRAND_EXCHANGE_OFFER_CONTAINER(WidgetID.GRAND_EXCHANGE_GROUP_ID, WidgetID.GrandExchange.OFFER_CONTAINER),

View File

@@ -25,6 +25,8 @@
package net.runelite.client.config; package net.runelite.client.config;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import net.runelite.api.Constants; import net.runelite.api.Constants;
import net.runelite.client.Notifier; import net.runelite.client.Notifier;
import net.runelite.client.ui.ContainableFrame; import net.runelite.client.ui.ContainableFrame;
@@ -181,11 +183,23 @@ public interface RuneLiteConfig extends Config
return 100; 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( @ConfigTitleSection(
keyName = "notificationsTitle", keyName = "notificationsTitle",
name = "Notifications", name = "Notifications",
description = "", description = "",
position = 13 position = 14
) )
default Title notificationsTitle() default Title notificationsTitle()
{ {
@@ -196,7 +210,7 @@ public interface RuneLiteConfig extends Config
keyName = "notificationTray", keyName = "notificationTray",
name = "Enable tray notifications", name = "Enable tray notifications",
description = "Enables tray notifications", description = "Enables tray notifications",
position = 14, position = 15,
titleSection = "notificationsTitle" titleSection = "notificationsTitle"
) )
default boolean enableTrayNotifications() default boolean enableTrayNotifications()
@@ -208,7 +222,7 @@ public interface RuneLiteConfig extends Config
keyName = "notificationRequestFocus", keyName = "notificationRequestFocus",
name = "Request focus on notification", name = "Request focus on notification",
description = "Toggles window focus request", description = "Toggles window focus request",
position = 15, position = 16,
titleSection = "notificationsTitle" titleSection = "notificationsTitle"
) )
default boolean requestFocusOnNotification() default boolean requestFocusOnNotification()
@@ -220,7 +234,7 @@ public interface RuneLiteConfig extends Config
keyName = "notificationSound", keyName = "notificationSound",
name = "Notification sound", name = "Notification sound",
description = "Enables the playing of a beep sound when notifications are displayed", description = "Enables the playing of a beep sound when notifications are displayed",
position = 16, position = 17,
titleSection = "notificationsTitle" titleSection = "notificationsTitle"
) )
default Notifier.NativeCustomOff notificationSound() default Notifier.NativeCustomOff notificationSound()
@@ -232,7 +246,7 @@ public interface RuneLiteConfig extends Config
keyName = "notificationGameMessage", keyName = "notificationGameMessage",
name = "Enable game message notifications", name = "Enable game message notifications",
description = "Puts a notification message in the chatbox", description = "Puts a notification message in the chatbox",
position = 17, position = 18,
titleSection = "notificationsTitle" titleSection = "notificationsTitle"
) )
default boolean enableGameMessageNotification() default boolean enableGameMessageNotification()
@@ -244,7 +258,7 @@ public interface RuneLiteConfig extends Config
keyName = "notificationFlash", keyName = "notificationFlash",
name = "Enable flash notification", name = "Enable flash notification",
description = "Flashes the game frame as a notification", description = "Flashes the game frame as a notification",
position = 18, position = 19,
titleSection = "notificationsTitle" titleSection = "notificationsTitle"
) )
default FlashNotification flashNotification() default FlashNotification flashNotification()
@@ -256,7 +270,7 @@ public interface RuneLiteConfig extends Config
keyName = "notificationFocused", keyName = "notificationFocused",
name = "Send notifications when focused", name = "Send notifications when focused",
description = "Toggles all notifications for when the client is focused", description = "Toggles all notifications for when the client is focused",
position = 19, position = 20,
titleSection = "notificationsTitle" titleSection = "notificationsTitle"
) )
default boolean sendNotificationsWhenFocused() default boolean sendNotificationsWhenFocused()
@@ -268,7 +282,7 @@ public interface RuneLiteConfig extends Config
keyName = "fontTitle", keyName = "fontTitle",
name = "Font", name = "Font",
description = "", description = "",
position = 20 position = 21
) )
default Title fontTitle() default Title fontTitle()
{ {
@@ -279,7 +293,7 @@ public interface RuneLiteConfig extends Config
keyName = "fontType", keyName = "fontType",
name = "Dynamic Overlay Font", name = "Dynamic Overlay Font",
description = "Configures what font type is used for in-game overlays such as player name, ground items, etc.", description = "Configures what font type is used for in-game overlays such as player name, ground items, etc.",
position = 21, position = 22,
titleSection = "fontTitle" titleSection = "fontTitle"
) )
default FontType fontType() default FontType fontType()
@@ -291,7 +305,7 @@ public interface RuneLiteConfig extends Config
keyName = "tooltipFontType", keyName = "tooltipFontType",
name = "Tooltip Font", name = "Tooltip Font",
description = "Configures what font type is used for in-game tooltips such as food stats, NPC names, etc.", description = "Configures what font type is used for in-game tooltips such as food stats, NPC names, etc.",
position = 22, position = 23,
titleSection = "fontTitle" titleSection = "fontTitle"
) )
default FontType tooltipFontType() default FontType tooltipFontType()
@@ -303,7 +317,7 @@ public interface RuneLiteConfig extends Config
keyName = "interfaceFontType", keyName = "interfaceFontType",
name = "Interface Overlay Font", name = "Interface Overlay Font",
description = "Configures what font type is used for in-game interface overlays such as panels, opponent info, clue scrolls etc.", 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" titleSection = "fontTitle"
) )
default FontType interfaceFontType() default FontType interfaceFontType()
@@ -315,7 +329,7 @@ public interface RuneLiteConfig extends Config
keyName = "overlayTitle", keyName = "overlayTitle",
name = "Overlays", name = "Overlays",
description = "", description = "",
position = 24 position = 25
) )
default Title overlayTitle() default Title overlayTitle()
{ {
@@ -326,7 +340,7 @@ public interface RuneLiteConfig extends Config
keyName = "menuEntryShift", keyName = "menuEntryShift",
name = "Require Shift for overlay menu", name = "Require Shift for overlay menu",
description = "Overlay right-click menu will require shift to be added", description = "Overlay right-click menu will require shift to be added",
position = 25, position = 26,
titleSection = "overlayTitle" titleSection = "overlayTitle"
) )
default boolean menuEntryShift() default boolean menuEntryShift()
@@ -334,22 +348,22 @@ public interface RuneLiteConfig extends Config
return true; return true;
} }
@ConfigItem( @ConfigTitleSection(
keyName = "tooltipPosition", keyName = "infoboxTitle",
name = "Tooltip Position", name = "Infoboxes",
description = "Configures whether to show the tooltip above or under the cursor", description = "",
position = 35 position = 27
) )
default TooltipPositionType tooltipPosition() default Title infoboxTitle()
{ {
return TooltipPositionType.UNDER_CURSOR; return new Title();
} }
@ConfigItem( @ConfigItem(
keyName = "infoBoxVertical", keyName = "infoBoxVertical",
name = "Display infoboxes vertically", name = "Display infoboxes vertically",
description = "Toggles the infoboxes to display vertically", description = "Toggles the infoboxes to display vertically",
position = 26, position = 28,
titleSection = "infoboxTitle" titleSection = "infoboxTitle"
) )
default boolean infoBoxVertical() default boolean infoBoxVertical()
@@ -361,7 +375,7 @@ public interface RuneLiteConfig extends Config
keyName = "infoBoxWrap", keyName = "infoBoxWrap",
name = "Infobox wrap count", name = "Infobox wrap count",
description = "Configures the amount of infoboxes shown before wrapping", description = "Configures the amount of infoboxes shown before wrapping",
position = 27, position = 29,
titleSection = "infoboxTitle" titleSection = "infoboxTitle"
) )
default int infoBoxWrap() default int infoBoxWrap()
@@ -373,7 +387,7 @@ public interface RuneLiteConfig extends Config
keyName = "infoBoxSize", keyName = "infoBoxSize",
name = "Infobox size", name = "Infobox size",
description = "Configures the size of each infobox in pixels", description = "Configures the size of each infobox in pixels",
position = 28, position = 30,
titleSection = "infoboxTitle" titleSection = "infoboxTitle"
) )
@Units(Units.PIXELS) @Units(Units.PIXELS)
@@ -382,4 +396,38 @@ public interface RuneLiteConfig extends Config
return 35; 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);
}
} }

View File

@@ -90,7 +90,7 @@ import net.runelite.client.config.Keybind;
import net.runelite.client.config.ModifierlessKeybind; import net.runelite.client.config.ModifierlessKeybind;
import net.runelite.client.config.Range; import net.runelite.client.config.Range;
import net.runelite.client.config.Units; 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.events.PluginChanged;
import net.runelite.client.plugins.PluginManager; import net.runelite.client.plugins.PluginManager;
import net.runelite.client.ui.ColorScheme; import net.runelite.client.ui.ColorScheme;
@@ -136,6 +136,9 @@ class ConfigPanel extends PluginPanel
@Inject @Inject
private ColorPickerManager colorPickerManager; private ColorPickerManager colorPickerManager;
@Inject
private EventBus eventBus;
private PluginConfigurationDescriptor pluginConfig = null; private PluginConfigurationDescriptor pluginConfig = null;
private final Map<String, JPanel> sectionWidgets = new HashMap<>(); private final Map<String, JPanel> sectionWidgets = new HashMap<>();
private final Map<String, JPanel> titleSectionWidgets = new HashMap<>(); private final Map<String, JPanel> titleSectionWidgets = new HashMap<>();
@@ -230,6 +233,7 @@ class ConfigPanel extends PluginPanel
} }
rebuild(false); rebuild(false);
eventBus.subscribe(PluginChanged.class, this, this::onPluginChanged);
} }
private void getSections(ConfigDescriptor cd) private void getSections(ConfigDescriptor cd)
@@ -1169,7 +1173,6 @@ class ConfigPanel extends PluginPanel
return new Dimension(PANEL_WIDTH + SCROLLBAR_WIDTH, super.getPreferredSize().height); return new Dimension(PANEL_WIDTH + SCROLLBAR_WIDTH, super.getPreferredSize().height);
} }
@Subscribe
public void onPluginChanged(PluginChanged event) public void onPluginChanged(PluginChanged event)
{ {
if (event.getPlugin() == this.pluginConfig.getPlugin()) if (event.getPlugin() == this.pluginConfig.getPlugin())

View File

@@ -43,7 +43,6 @@ import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.concurrent.ScheduledExecutorService;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import javax.inject.Inject; 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.OpenOSRSConfig;
import net.runelite.client.config.RuneLiteConfig; import net.runelite.client.config.RuneLiteConfig;
import net.runelite.client.eventbus.EventBus; import net.runelite.client.eventbus.EventBus;
import net.runelite.client.eventbus.Subscribe;
import net.runelite.client.events.ConfigChanged; import net.runelite.client.events.ConfigChanged;
import net.runelite.client.events.ExternalPluginChanged; import net.runelite.client.events.ExternalPluginChanged;
import net.runelite.client.events.ExternalPluginsLoaded; import net.runelite.client.events.ExternalPluginsLoaded;
@@ -110,7 +108,6 @@ public class PluginListPanel extends PluginPanel
private final ConfigManager configManager; private final ConfigManager configManager;
private final PluginManager pluginManager; private final PluginManager pluginManager;
private final ScheduledExecutorService executorService;
private final Provider<ConfigPanel> configPanelProvider; private final Provider<ConfigPanel> configPanelProvider;
private final OpenOSRSConfig openOSRSConfig; private final OpenOSRSConfig openOSRSConfig;
private final List<PluginConfigurationDescriptor> fakePlugins = new ArrayList<>(); private final List<PluginConfigurationDescriptor> fakePlugins = new ArrayList<>();
@@ -142,7 +139,6 @@ public class PluginListPanel extends PluginPanel
public PluginListPanel( public PluginListPanel(
ConfigManager configManager, ConfigManager configManager,
PluginManager pluginManager, PluginManager pluginManager,
ScheduledExecutorService executorService,
Provider<ConfigPanel> configPanelProvider, Provider<ConfigPanel> configPanelProvider,
OpenOSRSConfig openOSRSConfig, OpenOSRSConfig openOSRSConfig,
EventBus eventBus) EventBus eventBus)
@@ -151,7 +147,6 @@ public class PluginListPanel extends PluginPanel
this.configManager = configManager; this.configManager = configManager;
this.pluginManager = pluginManager; this.pluginManager = pluginManager;
this.executorService = executorService;
this.configPanelProvider = configPanelProvider; this.configPanelProvider = configPanelProvider;
this.openOSRSConfig = openOSRSConfig; this.openOSRSConfig = openOSRSConfig;
@@ -186,13 +181,13 @@ public class PluginListPanel extends PluginPanel
}); });
eventBus.subscribe(ExternalPluginsLoaded.class, this, ignored -> { eventBus.subscribe(ExternalPluginsLoaded.class, this, ignored -> {
eventBus.subscribe(ExternalPluginChanged.class, this, ev -> { eventBus.subscribe(ExternalPluginChanged.class, this, ev -> SwingUtilities.invokeLater(this::rebuildPluginList));
SwingUtilities.invokeLater(this::rebuildPluginList);
});
SwingUtilities.invokeLater(this::rebuildPluginList); SwingUtilities.invokeLater(this::rebuildPluginList);
}); });
eventBus.subscribe(PluginChanged.class, this, this::onPluginChanged);
muxer = new MultiplexingPluginPanel(this); muxer = new MultiplexingPluginPanel(this);
searchBar = new IconTextField(); searchBar = new IconTextField();
@@ -475,7 +470,6 @@ public class PluginListPanel extends PluginPanel
configManager.setConfiguration(RUNELITE_GROUP_NAME, PINNED_PLUGINS_CONFIG_KEY, value); configManager.setConfiguration(RUNELITE_GROUP_NAME, PINNED_PLUGINS_CONFIG_KEY, value);
} }
@Subscribe
public void onPluginChanged(PluginChanged event) public void onPluginChanged(PluginChanged event)
{ {
SwingUtilities.invokeLater(this::refresh); SwingUtilities.invokeLater(this::refresh);

View File

@@ -43,8 +43,6 @@ import java.awt.Rectangle;
import java.awt.Toolkit; import java.awt.Toolkit;
import java.awt.TrayIcon; import java.awt.TrayIcon;
import java.awt.Window; import java.awt.Window;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.lang.reflect.Field; import java.lang.reflect.Field;
@@ -79,7 +77,6 @@ import net.runelite.client.RuneLiteProperties;
import net.runelite.client.callback.ClientThread; import net.runelite.client.callback.ClientThread;
import net.runelite.client.config.ConfigManager; import net.runelite.client.config.ConfigManager;
import net.runelite.client.config.ExpandResizeType; import net.runelite.client.config.ExpandResizeType;
import net.runelite.client.config.Keybind;
import net.runelite.client.config.RuneLiteConfig; import net.runelite.client.config.RuneLiteConfig;
import net.runelite.client.config.WarningOnExit; import net.runelite.client.config.WarningOnExit;
import net.runelite.client.eventbus.EventBus; import net.runelite.client.eventbus.EventBus;
@@ -366,8 +363,7 @@ public class ClientUI
frame.add(container); frame.add(container);
// Add key listener // Add key listener
final HotkeyListener sidebarListener = new HotkeyListener(() -> final HotkeyListener sidebarListener = new HotkeyListener(config::sidebarToggleKey)
new Keybind(KeyEvent.VK_F11, InputEvent.CTRL_DOWN_MASK))
{ {
@Override @Override
public void hotkeyPressed() public void hotkeyPressed()
@@ -378,6 +374,17 @@ public class ClientUI
keyManager.registerKeyListener(sidebarListener); keyManager.registerKeyListener(sidebarListener);
final HotkeyListener pluginPanelListener = new HotkeyListener(config::panelToggleKey)
{
@Override
public void hotkeyPressed()
{
togglePluginPanel();
}
};
keyManager.registerKeyListener(pluginPanelListener);
// Add mouse listener // Add mouse listener
final MouseListener mouseListener = new MouseAdapter() final MouseListener mouseListener = new MouseAdapter()
{ {
@@ -612,7 +619,7 @@ public class ClientUI
{ {
OSXUtil.requestFocus(); OSXUtil.requestFocus();
} }
// The workaround for Windows is to minimise and then un-minimise the client to bring // 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. // 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 // 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) private void expand(@Nullable NavigationButton button)
{ {
if (button == null) if (button == null)

View File

@@ -25,9 +25,11 @@
package net.runelite.client.ui.overlay; package net.runelite.client.ui.overlay;
import lombok.Value; import lombok.Value;
import lombok.experimental.NonFinal;
import net.runelite.api.MenuOpcode; import net.runelite.api.MenuOpcode;
@Value @Value
@NonFinal
public class OverlayMenuEntry public class OverlayMenuEntry
{ {
private MenuOpcode menuOpcode; private MenuOpcode menuOpcode;