Add configs for runepouch (color, icons, enabling)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Tyler <https://github.com/tylerthardy>
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
@@ -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,23 +114,28 @@ 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;
|
||||
|
||||
Reference in New Issue
Block a user