From 006900d1b53a134fce5a130dd724e9c753a845d7 Mon Sep 17 00:00:00 2001 From: Kyle <48519776+xKylee@users.noreply.github.com> Date: Fri, 20 Dec 2019 09:51:25 +0000 Subject: [PATCH] Info: new info (#2129) * Info: new info new info added: 1) Launcher download 2) Runelite DIR 3) Plugins DIR 4) Screenshots DIR physical path details: 1) Runelite Directory 2) Log Directory 3) Plugins Directory 4) Screenshot Directory added config options to turn on/off: 1) Show the Github info. 2) Show the Launcher info. 3) show the Log Directory. 4) Show the Runelite Directory. 5) Show the Plugins Directory. 6) Show the Screenshot Directory. 6) Show the Physical Directory information. --- .../java/net/runelite/client/RuneLite.java | 30 +++-- .../client/plugins/info/InfoConfig.java | 87 ++++++++++++++ .../client/plugins/info/InfoPanel.java | 106 ++++++++++++++---- .../client/plugins/info/InfoPlugin.java | 57 +++++++++- 4 files changed, 237 insertions(+), 43 deletions(-) create mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/info/InfoConfig.java diff --git a/runelite-client/src/main/java/net/runelite/client/RuneLite.java b/runelite-client/src/main/java/net/runelite/client/RuneLite.java index 86de7943c7..ad72c932a5 100644 --- a/runelite-client/src/main/java/net/runelite/client/RuneLite.java +++ b/runelite-client/src/main/java/net/runelite/client/RuneLite.java @@ -93,24 +93,20 @@ public class RuneLite public static final File PLUGIN_DIR = new File(RUNELITE_DIR, "plugins"); public static final File SCREENSHOT_DIR = new File(RUNELITE_DIR, "screenshots"); public static final File LOGS_DIR = new File(RUNELITE_DIR, "logs"); + public static final File PLUGINS_DIR = new File(RUNELITE_DIR, "plugins"); public static final Locale SYSTEM_LOCALE = Locale.getDefault(); public static boolean allowPrivateServer = false; @Getter private static Injector injector; - - @Inject - private PluginManager pluginManager; - - @Inject - private ConfigManager configManager; - - @Inject - private SessionManager sessionManager; - @Inject public DiscordService discordService; - + @Inject + private PluginManager pluginManager; + @Inject + private ConfigManager configManager; + @Inject + private SessionManager sessionManager; @Inject private ClientSessionManager clientSessionManager; @@ -310,6 +306,12 @@ public class RuneLite log.info("Client initialization took {}ms. Uptime: {}ms", end - start, uptime); } + @VisibleForTesting + public static void setInjector(Injector injector) + { + RuneLite.injector = injector; + } + private void start() throws Exception { // Load RuneLite or Vanilla client @@ -405,10 +407,4 @@ public class RuneLite clientSessionManager.shutdown(); discordService.close(); } - - @VisibleForTesting - public static void setInjector(Injector injector) - { - RuneLite.injector = injector; - } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/info/InfoConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/info/InfoConfig.java new file mode 100644 index 0000000000..d36967a555 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/info/InfoConfig.java @@ -0,0 +1,87 @@ +package net.runelite.client.plugins.info; + +import net.runelite.client.config.Config; +import net.runelite.client.config.ConfigGroup; +import net.runelite.client.config.ConfigItem; + +@ConfigGroup("info") +public interface InfoConfig extends Config +{ + @ConfigItem( + keyName = "showGithub", + name = "Show the OpenOSRS Github", + description = "Configures if you want to show the OpenOSRS Github or not.", + position = 0 + ) + default boolean showGithub() + { + return true; + } + + @ConfigItem( + keyName = "showLauncher", + name = "Show the Launcher download", + description = "Configures if you want to show the OpenOSRS Launcher download or not.", + position = 1 + ) + default boolean showLauncher() + { + return true; + } + + @ConfigItem( + keyName = "showLogDir", + name = "Show Log Directory", + description = "Configures if you want to show the Log Directory or not.", + position = 2 + ) + default boolean showLogDir() + { + return true; + } + + @ConfigItem( + keyName = "showRuneliteDir", + name = "Show Runelite Directory", + description = "Configures if you want to show the Runelite directory or not.", + position = 3 + ) + default boolean showRuneliteDir() + { + return true; + } + + @ConfigItem( + keyName = "showPluginsDir", + name = "Show Plugins Directory", + description = "Configures if you want to show the Plugins Directory or not.", + position = 4 + ) + default boolean showPluginsDir() + { + return true; + } + + @ConfigItem( + keyName = "showScreenshotsDir", + name = "Show Screenshots Directory", + description = "Configures if you want to show the Screenshots Directory or not.", + position = 5 + ) + default boolean showScreenshotsDir() + { + return true; + } + + @ConfigItem( + keyName = "showPhysicalDir", + name = "Show Physical Locations", + description = "Configures if you want to show the Physical Directory Locations or not.", + position = 6 + ) + default boolean showPhysicalDir() + { + return true; + } + +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/info/InfoPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/info/InfoPanel.java index 5b36fb0afa..1fa4377e32 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/info/InfoPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/info/InfoPanel.java @@ -43,6 +43,9 @@ import javax.swing.JPanel; import javax.swing.border.EmptyBorder; import net.runelite.api.Client; import static net.runelite.client.RuneLite.LOGS_DIR; +import static net.runelite.client.RuneLite.PLUGINS_DIR; +import static net.runelite.client.RuneLite.RUNELITE_DIR; +import static net.runelite.client.RuneLite.SCREENSHOT_DIR; import net.runelite.client.RuneLiteProperties; import net.runelite.client.config.ConfigManager; import net.runelite.client.ui.ColorScheme; @@ -60,15 +63,10 @@ class InfoPanel extends PluginPanel private static final ImageIcon DISCORD_ICON; private static final ImageIcon PATREON_ICON; private static final ImageIcon IMPORT_ICON; - - private JPanel syncPanel; - - @Inject - @Nullable - private Client client; - - @Inject - private ConfigManager configManager; + private static final String RUNELITE_DIRECTORY = System.getProperty("user.home") + "\\.runelite"; + private static final String LOG_DIRECTORY = RUNELITE_DIRECTORY + "\\logs"; + private static final String PLUGINS_DIRECTORY = RUNELITE_DIRECTORY + "\\plugins"; + private static final String SCREENSHOT_DIRECTORY = RUNELITE_DIRECTORY + "\\screenshots"; static { @@ -80,8 +78,19 @@ class InfoPanel extends PluginPanel IMPORT_ICON = new ImageIcon(ImageUtil.getResourceStreamFromClass(InfoPanel.class, "import_icon.png")); } - void init() + private JPanel syncPanel; + @Inject + @Nullable + private Client client; + @Inject + private ConfigManager configManager; + @Inject + private InfoPlugin plugin; + + @Inject + public InfoPanel(final InfoPlugin plugin, final Client client) { + setLayout(new BorderLayout()); setBackground(ColorScheme.DARK_GRAY_COLOR); setBorder(new EmptyBorder(10, 10, 10, 10)); @@ -115,8 +124,8 @@ class InfoPanel extends PluginPanel versionPanel.add(revision); JPanel actionsContainer = new JPanel(); - actionsContainer.setBorder(new EmptyBorder(10, 0, 0, 0)); - actionsContainer.setLayout(new GridLayout(5, 1, 0, 10)); + actionsContainer.setBorder(new EmptyBorder(10, 0, 10, 0)); + actionsContainer.setLayout(new GridLayout(9, 1, 0, 10)); syncPanel = buildLinkPanel(IMPORT_ICON, "Import local settings", "to remote RuneLite account", () -> { @@ -131,22 +140,63 @@ class InfoPanel extends PluginPanel } }); - actionsContainer.add(buildLinkPanel(GITHUB_ICON, "License info", "for distribution", "https://github.com/runelite-extended/runelite/blob/master/LICENSE")); - actionsContainer.add(buildLinkPanel(FOLDER_ICON, "Open logs directory", "(for bug reports)", LOGS_DIR)); - actionsContainer.add(buildLinkPanel(DISCORD_ICON, "Talk to us on our", "discord server", "https://discord.gg/HN5gf3m")); - actionsContainer.add(buildLinkPanel(PATREON_ICON, "Patreon to support", "the OpenOSRS devs", RuneLiteProperties.getPatreonLink())); - /* actionsContainer.add(buildLinkPanel(WIKI_ICON, "Information about", "RuneLite and plugins", runeLiteProperties.getWikiLink()));*/ + actionsContainer.add(buildLinkPanel(GITHUB_ICON, "License info", "for distribution", "https://github.com/open-osrs/runelite/blob/master/LICENSE")); + actionsContainer.add(buildLinkPanel(PATREON_ICON, "Patreon to support", "the OpenOSRS Devs", RuneLiteProperties.getPatreonLink())); + actionsContainer.add(buildLinkPanel(DISCORD_ICON, "Talk to us on our", "Discord Server", "https://discord.gg/OpenOSRS")); + if (plugin.isShowGithub()) + { + actionsContainer.add(buildLinkPanel(GITHUB_ICON, "OpenOSRS Github", "", "https://github.com/open-osrs")); + } + if (plugin.isShowLauncher()) + { + actionsContainer.add(buildLinkPanel(IMPORT_ICON, "Launcher Download", "for the latest launcher", "https://github.com/open-osrs/launcher/releases")); + } + if (plugin.isShowRuneliteDir()) + { + actionsContainer.add(buildLinkPanel(FOLDER_ICON, "Open Runelite Directory", "for your .properties file", RUNELITE_DIR)); + } + if (plugin.isShowLogDir()) + { + actionsContainer.add(buildLinkPanel(FOLDER_ICON, "Open Logs Directory", "for bug reports", LOGS_DIR)); + } + if (plugin.isShowPluginsDir()) + { + actionsContainer.add(buildLinkPanel(FOLDER_ICON, "Open Plugins Directory", "for external plugins", PLUGINS_DIR)); + } + if (plugin.isShowScreenshotsDir()) + { + actionsContainer.add(buildLinkPanel(FOLDER_ICON, "Open Screenshots Directory", "for your screenshots", SCREENSHOT_DIR)); + } + if (plugin.isShowPhysicalDir()) + { + JPanel pathPanel = new JPanel(); + pathPanel.setBackground(ColorScheme.DARKER_GRAY_COLOR); + pathPanel.setBorder(new EmptyBorder(10, 10, 10, 10)); + pathPanel.setLayout(new GridLayout(0, 1)); + + JLabel rldirectory = new JLabel(htmlLabel("Runelite Directory: ", RUNELITE_DIRECTORY)); + rldirectory.setFont(smallFont); + + JLabel logdirectory = new JLabel(htmlLabel("Log Directory: ", LOG_DIRECTORY)); + logdirectory.setFont(smallFont); + + JLabel pluginsdirectory = new JLabel(htmlLabel("Plugins Directory: ", PLUGINS_DIRECTORY)); + pluginsdirectory.setFont(smallFont); + + JLabel screenshotsdirectory = new JLabel(htmlLabel("Screenshot Directory: ", SCREENSHOT_DIRECTORY)); + screenshotsdirectory.setFont(smallFont); + + pathPanel.add(rldirectory); + pathPanel.add(logdirectory); + pathPanel.add(pluginsdirectory); + pathPanel.add(screenshotsdirectory); + + add(pathPanel, BorderLayout.SOUTH); + } add(versionPanel, BorderLayout.NORTH); add(actionsContainer, BorderLayout.CENTER); - } - /** - * Builds a link panel with a given icon, text and directory to open. - */ - private JPanel buildLinkPanel(ImageIcon icon, String topText, String bottomText, File dir) - { - return buildLinkPanel(icon, topText, bottomText, () -> LinkBrowser.openLocalFile(dir)); } /** @@ -235,4 +285,12 @@ class InfoPanel extends PluginPanel { return "" + key + "" + value + ""; } + + /** + * Builds a link panel with a given icon, text and directory to open. + */ + private JPanel buildLinkPanel(ImageIcon icon, String topText, String bottomText, File dir) + { + return buildLinkPanel(icon, topText, bottomText, () -> LinkBrowser.openLocalFile(dir)); + } } \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/info/InfoPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/info/InfoPlugin.java index 9a51598f43..adb8db9f09 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/info/InfoPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/info/InfoPlugin.java @@ -24,9 +24,15 @@ */ package net.runelite.client.plugins.info; +import com.google.inject.Provides; import java.awt.image.BufferedImage; import javax.inject.Inject; import javax.inject.Singleton; +import lombok.AccessLevel; +import lombok.Getter; +import net.runelite.client.config.ConfigManager; +import net.runelite.client.eventbus.Subscribe; +import net.runelite.client.events.ConfigChanged; import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.ui.ClientToolbar; @@ -36,22 +42,58 @@ import net.runelite.client.util.ImageUtil; @PluginDescriptor( name = "Info Panel", description = "Enable the Info panel", + tags = {"info", "github", "patreon", "dir", "discord"}, loadWhenOutdated = true ) @Singleton public class InfoPlugin extends Plugin { + @Getter(AccessLevel.PACKAGE) + private boolean showLogDir; + @Getter(AccessLevel.PACKAGE) + private boolean showRuneliteDir; + @Getter(AccessLevel.PACKAGE) + private boolean showPluginsDir; + @Getter(AccessLevel.PACKAGE) + private boolean showScreenshotsDir; + @Getter(AccessLevel.PACKAGE) + private boolean showGithub; + @Getter(AccessLevel.PACKAGE) + private boolean showLauncher; + @Getter(AccessLevel.PACKAGE) + private boolean showPhysicalDir; + @Inject private ClientToolbar clientToolbar; + @Inject + private InfoConfig config; + private NavigationButton navButton; + @Provides + InfoConfig provideConfig(ConfigManager configManager) + { + return configManager.getConfig(InfoConfig.class); + } + + @Subscribe + private void onConfigChanged(ConfigChanged event) + { + if (!event.getGroup().equals("info")) + { + return; + } + + updateConfig(); + } @Override protected void startUp() { + updateConfig(); + InfoPanel panel = injector.getInstance(InfoPanel.class); - panel.init(); final BufferedImage icon = ImageUtil.getResourceStreamFromClass(getClass(), "info_icon.png"); @@ -70,4 +112,15 @@ public class InfoPlugin extends Plugin { clientToolbar.removeNavigation(navButton); } -} + + private void updateConfig() + { + this.showGithub = config.showGithub(); + this.showLauncher = config.showLauncher(); + this.showLogDir = config.showLogDir(); + this.showRuneliteDir = config.showRuneliteDir(); + this.showPluginsDir = config.showPluginsDir(); + this.showScreenshotsDir = config.showScreenshotsDir(); + this.showPhysicalDir = config.showPhysicalDir(); + } +} \ No newline at end of file