diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/runepouch/Runepouch.java b/runelite-client/src/main/java/net/runelite/client/plugins/runepouch/Runepouch.java index cf16213a53..1aff03a0ef 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/runepouch/Runepouch.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/runepouch/Runepouch.java @@ -24,11 +24,13 @@ */ package net.runelite.client.plugins.runepouch; +import net.runelite.client.RuneLite; import net.runelite.client.plugins.Plugin; import net.runelite.client.ui.overlay.Overlay; public class Runepouch extends Plugin { + private final RunepouchConfig config = RuneLite.getRunelite().getConfigManager().getConfig(RunepouchConfig.class); private final RunepouchOverlay overlay = new RunepouchOverlay(this); @Override @@ -46,4 +48,9 @@ public class Runepouch extends Plugin protected void shutDown() throws Exception { } + + public RunepouchConfig getConfig() + { + return config; + } } \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/runepouch/RunepouchConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/runepouch/RunepouchConfig.java new file mode 100644 index 0000000000..07d47e449d --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/runepouch/RunepouchConfig.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2017, Tyler + * 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.runepouch; + +import java.awt.Color; +import net.runelite.client.config.ConfigGroup; +import net.runelite.client.config.ConfigItem; + +@ConfigGroup( + keyName = "runepouch", + name = "Runepouch", + description = "Configuration for the Runepouch plugin" +) +public interface RunepouchConfig +{ + @ConfigItem( + keyName = "enabled", + name = "Enabled", + description = "Configures whether or not Runepouch information is displayed" + ) + default boolean enabled() + { + return true; + } + + @ConfigItem( + keyName = "fontcolor", + name = "Font Color", + description = "Color of the font for the number of runes in pouch" + ) + default Color fontColor() + { + return Color.yellow; + } + + @ConfigItem( + keyName = "runeicons", + name = "Show Rune Icons", + description = "Show the rune icons next to the number of runes in pouch" + ) + default boolean showIcons() + { + return true; + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/runepouch/RunepouchOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/runepouch/RunepouchOverlay.java index 2f0c0e6412..40f0371434 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/runepouch/RunepouchOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/runepouch/RunepouchOverlay.java @@ -59,16 +59,21 @@ public class RunepouchOverlay extends Overlay private final Client client = RuneLite.getClient(); private final RuneImageCache runeImageCache = new RuneImageCache(); + private final Runepouch plugin; + private final RunepouchConfig config; public RunepouchOverlay(Runepouch plugin) { super(OverlayPosition.DYNAMIC); + this.plugin = plugin; + this.config = plugin.getConfig(); } @Override public Dimension render(Graphics2D graphics) { - if (client.getGameState() != GameState.LOGGED_IN + if (!config.enabled() + || client.getGameState() != GameState.LOGGED_IN || client.getWidget(WidgetInfo.LOGIN_CLICK_TO_PLAY_SCREEN) != null) { return null; @@ -109,30 +114,35 @@ public class RunepouchOverlay extends Overlay continue; } + graphics.setColor(Color.black); + graphics.drawString("" + formatNumber(amount), location.getX() + (config.showIcons() ? 13 : 1), + location.getY() + 14 + graphics.getFontMetrics().getHeight() * i); + + graphics.setColor(config.fontColor()); + graphics.drawString("" + formatNumber(amount), location.getX() + (config.showIcons() ? 12 : 0), + location.getY() + 13 + graphics.getFontMetrics().getHeight() * i); + + if (!config.showIcons()) + { + continue; + } + int runeId = client.getSetting(runeVarbit); BufferedImage runeImg = runeImageCache.getImage(runeId); if (runeImg != null) { OverlayUtil.renderImageLocation(graphics, - new Point(location.getX(), location.getY() + 2 + (graphics.getFontMetrics().getHeight() - 2) * i), + new Point(location.getX(), location.getY() + 2 + (graphics.getFontMetrics().getHeight()) * i), runeImg); } - - graphics.setColor(Color.black); - graphics.drawString("" + formatNumber(amount), location.getX() + 13, - location.getY() + (graphics.getFontMetrics().getHeight() - 2) * i + 11); - - graphics.setColor(Color.white); - graphics.drawString("" + formatNumber(amount), location.getX() + 12, - location.getY() + (graphics.getFontMetrics().getHeight() - 2) * i + 10); } } return null; } - private static String formatNumber(int var0) + private static String formatNumber(int amount) { - return var0 < 10000 ? String.valueOf(var0) : var0 / 1000 + "K"; + return amount < 1000 ? String.valueOf(amount) : amount / 1000 + "K"; } }