Added per item highlighting/hiding to GroundItems (#96)
This commit is contained in:
@@ -58,10 +58,30 @@ public interface GroundItemsConfig
|
||||
@ConfigItem(
|
||||
keyName = "showHAValue",
|
||||
name = "Show High Alchemy Values",
|
||||
description = "Configure whether or not to draw High Alchemy values alongside ground items"
|
||||
description = "Configures whether or not to draw High Alchemy values alongside ground items"
|
||||
)
|
||||
default boolean showHAValue()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "hiddenItems",
|
||||
name = "Hidden Items",
|
||||
description = "Configures hidden ground items. Format: (item), (item)"
|
||||
)
|
||||
default String getHiddenItems()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "highlightedItems",
|
||||
name = "Highlighted Items",
|
||||
description = "Configures specifically highlighted ground items. Format: (item), (item)"
|
||||
)
|
||||
default String getHighlightItems()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Arrays;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.GameState;
|
||||
import net.runelite.api.Item;
|
||||
@@ -73,8 +74,12 @@ public class GroundItemsOverlay extends Overlay
|
||||
// Threshold for highlighting items as pink.
|
||||
private static final int INSANE_VALUE = 10_000_000;
|
||||
private static final Color FADED_PINK = new Color(255, 102, 178);
|
||||
// Color to use if an item is highlighted in the config.
|
||||
private static final Color PURPLE = new Color(170, 0, 255);
|
||||
// Used when getting High Alchemy value - multiplied by general store price.
|
||||
private static final float HIGH_ALCHEMY_CONSTANT = 0.6f;
|
||||
// Regex for splitting the hidden items in the config.
|
||||
private static final String DELIMITER_REGEX = "\\s*,\\s*";
|
||||
|
||||
private final Client client = RuneLite.getClient();
|
||||
private final GroundItemsConfig config;
|
||||
@@ -108,6 +113,13 @@ public class GroundItemsOverlay extends Overlay
|
||||
// return null;
|
||||
//}
|
||||
|
||||
// gets the hidden/highlighted items from the text box in the config
|
||||
String configItems = config.getHiddenItems();
|
||||
List<String> hiddenItems = Arrays.asList(configItems.split(DELIMITER_REGEX));
|
||||
// note: both of these lists are immutable
|
||||
configItems = config.getHighlightItems();
|
||||
List<String> highlightedItems = Arrays.asList(configItems.split(DELIMITER_REGEX));
|
||||
|
||||
Region region = client.getRegion();
|
||||
Tile[][][] tiles = region.getTiles();
|
||||
FontMetrics fm = graphics.getFontMetrics();
|
||||
@@ -149,15 +161,20 @@ public class GroundItemsOverlay extends Overlay
|
||||
Item item = (Item) current;
|
||||
int itemId = item.getId();
|
||||
int itemQuantity = item.getQuantity();
|
||||
// Item does not support getting the name, so we need to get the ItemComposition instead
|
||||
ItemComposition itemDefinition = client.getItemDefinition(itemId);
|
||||
|
||||
Integer currentQuantity = items.get(itemId);
|
||||
if (currentQuantity == null)
|
||||
if (!hiddenItems.contains(itemDefinition.getName()))
|
||||
{
|
||||
items.put(itemId, itemQuantity);
|
||||
}
|
||||
else
|
||||
{
|
||||
items.put(itemId, currentQuantity + itemQuantity);
|
||||
if (currentQuantity == null)
|
||||
{
|
||||
items.put(itemId, itemQuantity);
|
||||
}
|
||||
else
|
||||
{
|
||||
items.put(itemId, currentQuantity + itemQuantity);
|
||||
}
|
||||
}
|
||||
|
||||
current = current.getNext();
|
||||
@@ -232,6 +249,11 @@ public class GroundItemsOverlay extends Overlay
|
||||
.append(" gp)");
|
||||
}
|
||||
|
||||
if (highlightedItems.contains(item.getName()))
|
||||
{
|
||||
textColor = PURPLE;
|
||||
}
|
||||
|
||||
String itemString = itemStringBuilder.toString();
|
||||
itemStringBuilder.setLength(0);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user