inventory tags: add fill tag option
This changes the display mode selector to be several separate options so that users can select multiple, such as outline and fill. Co-authored-by: Jordan <Nightfirecat@users.noreply.github.com> Co-authored-by: 1jz <philipgolovin@gmail.com>
This commit is contained in:
@@ -28,20 +28,74 @@ import java.awt.Color;
|
||||
import net.runelite.client.config.Config;
|
||||
import net.runelite.client.config.ConfigGroup;
|
||||
import net.runelite.client.config.ConfigItem;
|
||||
import net.runelite.client.config.ConfigSection;
|
||||
import net.runelite.client.config.Range;
|
||||
|
||||
@ConfigGroup("inventorytags")
|
||||
@ConfigGroup(InventoryTagsConfig.GROUP)
|
||||
public interface InventoryTagsConfig extends Config
|
||||
{
|
||||
enum DisplayMode
|
||||
{
|
||||
OUTLINE,
|
||||
UNDERLINE
|
||||
}
|
||||
|
||||
String GROUP = "inventorytags";
|
||||
|
||||
@ConfigSection(
|
||||
name = "Tag display mode",
|
||||
description = "How tags are displayed in the inventory",
|
||||
position = 0
|
||||
)
|
||||
String tagStyleSection = "tagStyleSection";
|
||||
|
||||
@ConfigItem(
|
||||
position = 0,
|
||||
keyName = "showTagOutline",
|
||||
name = "Outline",
|
||||
description = "Configures whether or not item tags show be outlined",
|
||||
section = tagStyleSection
|
||||
)
|
||||
default boolean showTagOutline()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 1,
|
||||
keyName = "tagUnderline",
|
||||
name = "Underline",
|
||||
description = "Configures whether or not item tags should be underlined",
|
||||
section = tagStyleSection
|
||||
)
|
||||
default boolean showTagUnderline()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 2,
|
||||
keyName = "tagFill",
|
||||
name = "Fill",
|
||||
description = "Configures whether or not item tags should be filled",
|
||||
section = tagStyleSection
|
||||
)
|
||||
default boolean showTagFill()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Range(
|
||||
max = 255
|
||||
)
|
||||
@ConfigItem(
|
||||
position = 3,
|
||||
keyName = "fillOpacity",
|
||||
name = "Fill opacity",
|
||||
description = "Configures the opacity of the tag \"Fill\"",
|
||||
section = tagStyleSection
|
||||
)
|
||||
default int fillOpacity()
|
||||
{
|
||||
return 50;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 1,
|
||||
keyName = "groupColor1",
|
||||
name = "Group 1 Color",
|
||||
description = "Color of the Tag"
|
||||
@@ -52,7 +106,7 @@ public interface InventoryTagsConfig extends Config
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 1,
|
||||
position = 2,
|
||||
keyName = "groupColor2",
|
||||
name = "Group 2 Color",
|
||||
description = "Color of the Tag"
|
||||
@@ -63,7 +117,7 @@ public interface InventoryTagsConfig extends Config
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 2,
|
||||
position = 3,
|
||||
keyName = "groupColor3",
|
||||
name = "Group 3 Color",
|
||||
description = "Color of the Tag"
|
||||
@@ -74,7 +128,7 @@ public interface InventoryTagsConfig extends Config
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 3,
|
||||
position = 4,
|
||||
keyName = "groupColor4",
|
||||
name = "Group 4 Color",
|
||||
description = "Color of the Tag"
|
||||
@@ -85,7 +139,7 @@ public interface InventoryTagsConfig extends Config
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 4,
|
||||
position = 5,
|
||||
keyName = "groupColor5",
|
||||
name = "Group 5 Color",
|
||||
description = "Color of the Tag"
|
||||
@@ -96,7 +150,7 @@ public interface InventoryTagsConfig extends Config
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 5,
|
||||
position = 6,
|
||||
keyName = "groupColor6",
|
||||
name = "Group 6 Color",
|
||||
description = "Color of the Tag"
|
||||
@@ -105,15 +159,4 @@ public interface InventoryTagsConfig extends Config
|
||||
{
|
||||
return new Color(0, 255, 255);
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 6,
|
||||
keyName = "displayMode",
|
||||
name = "Display mode",
|
||||
description = "How tags are displayed in the inventory"
|
||||
)
|
||||
default DisplayMode getDisplayMode()
|
||||
{
|
||||
return DisplayMode.OUTLINE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,21 +24,26 @@
|
||||
*/
|
||||
package net.runelite.client.plugins.inventorytags;
|
||||
|
||||
import com.google.common.cache.Cache;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Image;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.image.BufferedImage;
|
||||
import javax.inject.Inject;
|
||||
import net.runelite.api.widgets.WidgetItem;
|
||||
import net.runelite.client.game.ItemManager;
|
||||
import net.runelite.client.plugins.inventorytags.InventoryTagsConfig.DisplayMode;
|
||||
import net.runelite.client.ui.overlay.WidgetItemOverlay;
|
||||
import net.runelite.client.util.ColorUtil;
|
||||
import net.runelite.client.util.ImageUtil;
|
||||
|
||||
public class InventoryTagsOverlay extends WidgetItemOverlay
|
||||
{
|
||||
private final ItemManager itemManager;
|
||||
private final InventoryTagsPlugin plugin;
|
||||
private final InventoryTagsConfig config;
|
||||
private final Cache<Long, Image> fillCache;
|
||||
|
||||
@Inject
|
||||
private InventoryTagsOverlay(ItemManager itemManager, InventoryTagsPlugin plugin, InventoryTagsConfig config)
|
||||
@@ -48,6 +53,10 @@ public class InventoryTagsOverlay extends WidgetItemOverlay
|
||||
this.config = config;
|
||||
showOnEquipment();
|
||||
showOnInventory();
|
||||
fillCache = CacheBuilder.newBuilder()
|
||||
.concurrencyLevel(1)
|
||||
.maximumSize(32)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -57,16 +66,22 @@ public class InventoryTagsOverlay extends WidgetItemOverlay
|
||||
if (group != null)
|
||||
{
|
||||
final Color color = plugin.getGroupNameColor(group);
|
||||
final DisplayMode displayMode = config.getDisplayMode();
|
||||
if (color != null)
|
||||
{
|
||||
Rectangle bounds = widgetItem.getCanvasBounds();
|
||||
if (displayMode == DisplayMode.OUTLINE)
|
||||
if (config.showTagOutline())
|
||||
{
|
||||
final BufferedImage outline = itemManager.getItemOutline(itemId, widgetItem.getQuantity(), color);
|
||||
graphics.drawImage(outline, (int) bounds.getX(), (int) bounds.getY(), null);
|
||||
}
|
||||
else
|
||||
|
||||
if (config.showTagFill())
|
||||
{
|
||||
final Image image = getFillImage(color, widgetItem.getId(), widgetItem.getQuantity());
|
||||
graphics.drawImage(image, (int) bounds.getX(), (int) bounds.getY(), null);
|
||||
}
|
||||
|
||||
if (config.showTagUnderline())
|
||||
{
|
||||
int heightOffSet = (int) bounds.getY() + (int) bounds.getHeight() + 2;
|
||||
graphics.setColor(color);
|
||||
@@ -75,4 +90,22 @@ public class InventoryTagsOverlay extends WidgetItemOverlay
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Image getFillImage(Color color, int itemId, int qty)
|
||||
{
|
||||
long key = (((long) itemId) << 32) | qty;
|
||||
Image image = fillCache.getIfPresent(key);
|
||||
if (image == null)
|
||||
{
|
||||
final Color fillColor = ColorUtil.colorWithAlpha(color, config.fillOpacity());
|
||||
image = ImageUtil.fillImage(itemManager.getImage(itemId, qty, false), fillColor);
|
||||
fillCache.put(key, image);
|
||||
}
|
||||
return image;
|
||||
}
|
||||
|
||||
void invalidateCache()
|
||||
{
|
||||
fillCache.invalidateAll();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ import net.runelite.api.events.WidgetMenuOptionClicked;
|
||||
import net.runelite.api.widgets.WidgetInfo;
|
||||
import net.runelite.client.config.ConfigManager;
|
||||
import net.runelite.client.eventbus.Subscribe;
|
||||
import net.runelite.client.events.ConfigChanged;
|
||||
import net.runelite.client.menus.MenuManager;
|
||||
import net.runelite.client.menus.WidgetMenuOption;
|
||||
import net.runelite.client.plugins.Plugin;
|
||||
@@ -147,6 +148,15 @@ public class InventoryTagsPlugin extends Plugin
|
||||
editorMode = false;
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onConfigChanged(ConfigChanged configChanged)
|
||||
{
|
||||
if (configChanged.getGroup().equals(InventoryTagsConfig.GROUP))
|
||||
{
|
||||
overlay.invalidateCache();
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onWidgetMenuOptionClicked(final WidgetMenuOptionClicked event)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user