Add highlight > value, merge hide < ge and ha
- Add highlight > value setting - Merge hide < GE and hide < HA value and always check for both - Change the color getting logic to use simple methods instead of checks spread around the code Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
This commit is contained in:
@@ -143,23 +143,23 @@ public interface GroundItemsConfig extends Config
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "hideUnderGeValue",
|
||||
name = "Hide < GE Value",
|
||||
description = "Configures hidden ground items under GE value",
|
||||
keyName = "highlightOverValue",
|
||||
name = "Highlight > Value",
|
||||
description = "Configures highlighted ground items over either GE or HA value",
|
||||
position = 8
|
||||
)
|
||||
default int getHideUnderGeValue()
|
||||
default int getHighlightOverValue()
|
||||
{
|
||||
return 0;
|
||||
return 10000;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "hideUnderHaValue",
|
||||
name = "Hide < HA Value",
|
||||
description = "Configures hidden ground items under High Alch value",
|
||||
keyName = "hideUnderValue",
|
||||
name = "Hide < Value",
|
||||
description = "Configures hidden ground items under both GE and HA value",
|
||||
position = 9
|
||||
)
|
||||
default int getHideUnderHAValue()
|
||||
default int getHideUnderValue()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -170,24 +170,6 @@ public class GroundItemsOverlay extends Overlay
|
||||
continue;
|
||||
}
|
||||
|
||||
final boolean highlighted = plugin.isHighlighted(item.getName());
|
||||
final boolean hidden = plugin.isHidden(item.getName());
|
||||
|
||||
if (!plugin.isHotKeyPressed())
|
||||
{
|
||||
// Do not display hidden items
|
||||
if (hidden)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Do not display non-highlighted items when only highlighted items should be shown
|
||||
if (config.showHighlightedOnly() && !highlighted)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// Update GE price for item
|
||||
final ItemPrice itemPrice = itemManager.getItemPriceAsync(item.getItemId());
|
||||
|
||||
@@ -196,22 +178,25 @@ public class GroundItemsOverlay extends Overlay
|
||||
item.setGePrice(itemPrice.getPrice() * item.getQuantity());
|
||||
}
|
||||
|
||||
if (!plugin.isHotKeyPressed() && !highlighted)
|
||||
{
|
||||
// Check if item is under config threshold
|
||||
final boolean underThreshold = item.getGePrice() < config.getHideUnderGeValue()
|
||||
|| item.getHaPrice() < config.getHideUnderHAValue();
|
||||
final Color highlighted = plugin.getHighlighted(item.getName(), item.getGePrice(), item.getHaPrice());
|
||||
final Color hidden = plugin.getHidden(item.getName(), item.getGePrice(), item.getHaPrice(), item.isTradeable());
|
||||
|
||||
// If item is under threshold an we are either not always showing untradeables or item is tradeable
|
||||
// do not display item
|
||||
if (underThreshold && (!config.dontHideUntradeables() || item.isTradeable()))
|
||||
if (highlighted == null && !plugin.isHotKeyPressed())
|
||||
{
|
||||
// Do not display hidden items
|
||||
if (hidden != null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Do not display non-highlighted items
|
||||
if (config.showHighlightedOnly())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
final Color color = getCostColor(item.getGePrice() > 0 ? item.getGePrice() : item.getHaPrice(),
|
||||
highlighted, hidden);
|
||||
final Color color = plugin.getItemColor(highlighted, hidden);
|
||||
itemStringBuilder.append(item.getName());
|
||||
|
||||
if (item.getQuantity() > 1)
|
||||
@@ -330,10 +315,10 @@ public class GroundItemsOverlay extends Overlay
|
||||
}
|
||||
|
||||
// Draw hidden box
|
||||
drawRectangle(graphics, itemHiddenBox, topItem && mouseInHiddenBox ? Color.RED : color, hidden, true);
|
||||
drawRectangle(graphics, itemHiddenBox, topItem && mouseInHiddenBox ? Color.RED : color, hidden != null, true);
|
||||
|
||||
// Draw highlight box
|
||||
drawRectangle(graphics, itemHighlightBox, topItem && mouseInHighlightBox ? Color.GREEN : color, highlighted, false);
|
||||
drawRectangle(graphics, itemHighlightBox, topItem && mouseInHighlightBox ? Color.GREEN : color, highlighted != null, false);
|
||||
}
|
||||
|
||||
textComponent.setText(itemString);
|
||||
@@ -345,42 +330,6 @@ public class GroundItemsOverlay extends Overlay
|
||||
return null;
|
||||
}
|
||||
|
||||
Color getCostColor(int cost, boolean highlighted, boolean hidden)
|
||||
{
|
||||
if (hidden)
|
||||
{
|
||||
return Color.GRAY;
|
||||
}
|
||||
|
||||
if (highlighted)
|
||||
{
|
||||
return config.highlightedColor();
|
||||
}
|
||||
|
||||
// set the color according to rarity, if possible
|
||||
if (cost >= config.insaneValuePrice())
|
||||
{
|
||||
return config.insaneValueColor();
|
||||
}
|
||||
|
||||
if (cost >= config.highValuePrice())
|
||||
{
|
||||
return config.highValueColor();
|
||||
}
|
||||
|
||||
if (cost >= config.mediumValuePrice())
|
||||
{
|
||||
return config.mediumValueColor();
|
||||
}
|
||||
|
||||
if (cost >= config.lowValuePrice())
|
||||
{
|
||||
return config.lowValueColor();
|
||||
}
|
||||
|
||||
return config.defaultColor();
|
||||
}
|
||||
|
||||
private void drawRectangle(Graphics2D graphics, Rectangle rect, Color color, boolean inList, boolean hiddenBox)
|
||||
{
|
||||
graphics.setColor(Color.BLACK);
|
||||
|
||||
@@ -36,8 +36,8 @@ import java.awt.Color;
|
||||
import java.awt.Rectangle;
|
||||
import static java.lang.Boolean.TRUE;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@@ -149,6 +149,7 @@ public class GroundItemsPlugin extends Plugin
|
||||
@Getter
|
||||
private final Map<GroundItem.GroundItemKey, GroundItem> collectedGroundItems = new LinkedHashMap<>();
|
||||
private final List<GroundItem> groundItems = new ArrayList<>();
|
||||
private final Map<Integer, Color> priceChecks = new LinkedHashMap<>();
|
||||
private LoadingCache<String, Boolean> highlightedItems;
|
||||
private LoadingCache<String, Boolean> hiddenItems;
|
||||
|
||||
@@ -339,18 +340,14 @@ public class GroundItemsPlugin extends Plugin
|
||||
.build(new WildcardMatchLoader(hiddenItemList));
|
||||
|
||||
dirty = true;
|
||||
}
|
||||
|
||||
private ItemPrice getItemPrice(ItemComposition itemComposition)
|
||||
{
|
||||
if (itemComposition.getNote() != -1)
|
||||
{
|
||||
return itemManager.getItemPriceAsync(itemComposition.getLinkedNoteId());
|
||||
}
|
||||
else
|
||||
{
|
||||
return itemManager.getItemPriceAsync(itemComposition.getId());
|
||||
}
|
||||
// Cache colors
|
||||
priceChecks.clear();
|
||||
priceChecks.put(config.insaneValuePrice(), config.insaneValueColor());
|
||||
priceChecks.put(config.highValuePrice(), config.highValueColor());
|
||||
priceChecks.put(config.mediumValuePrice(), config.mediumValueColor());
|
||||
priceChecks.put(config.lowValuePrice(), config.lowValueColor());
|
||||
priceChecks.put(config.getHighlightOverValue(), config.highlightedColor());
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
@@ -361,16 +358,10 @@ public class GroundItemsPlugin extends Plugin
|
||||
&& event.getType() == MenuAction.GROUND_ITEM_THIRD_OPTION.getId())
|
||||
{
|
||||
int itemId = event.getIdentifier();
|
||||
ItemComposition itemComposition = client.getItemDefinition(itemId);
|
||||
|
||||
if (isHidden(itemComposition.getName()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Region region = client.getRegion();
|
||||
Tile tile = region.getTiles()[client.getPlane()][event.getActionParam0()][event.getActionParam1()];
|
||||
ItemLayer itemLayer = tile.getItemLayer();
|
||||
|
||||
if (itemLayer == null)
|
||||
{
|
||||
return;
|
||||
@@ -381,6 +372,7 @@ public class GroundItemsPlugin extends Plugin
|
||||
|
||||
int quantity = 1;
|
||||
Node current = itemLayer.getBottom();
|
||||
|
||||
while (current instanceof Item)
|
||||
{
|
||||
Item item = (Item) current;
|
||||
@@ -391,13 +383,17 @@ public class GroundItemsPlugin extends Plugin
|
||||
current = current.getNext();
|
||||
}
|
||||
|
||||
ItemPrice itemPrice = getItemPrice(itemComposition);
|
||||
int price = itemPrice == null ? (int)Math.floor(itemComposition.getPrice() * HIGH_ALCHEMY_CONSTANT) : itemPrice.getPrice();
|
||||
int cost = quantity * price;
|
||||
Color color = overlay.getCostColor(cost, isHighlighted(itemComposition.getName()),
|
||||
isHidden(itemComposition.getName()));
|
||||
final ItemComposition itemComposition = itemManager.getItemComposition(itemId);
|
||||
final int realItemId = itemComposition.getNote() != -1 ? itemComposition.getLinkedNoteId() : itemComposition.getId();
|
||||
final ItemPrice itemPrice = itemManager.getItemPriceAsync(realItemId);
|
||||
final int price = itemPrice == null ? itemComposition.getPrice() : itemPrice.getPrice();
|
||||
final int haPrice = Math.round(itemComposition.getPrice() * HIGH_ALCHEMY_CONSTANT) * quantity;
|
||||
final int gePrice = quantity * price;
|
||||
final Color hidden = getHidden(itemComposition.getName(), haPrice, gePrice, itemComposition.isTradeable());
|
||||
final Color highlighted = getHighlighted(itemComposition.getName(), haPrice, gePrice);
|
||||
final Color color = getItemColor(highlighted, hidden);
|
||||
|
||||
if (!color.equals(config.defaultColor()))
|
||||
if (color != null && !color.equals(config.defaultColor()))
|
||||
{
|
||||
String hexColor = Integer.toHexString(color.getRGB() & 0xFFFFFF);
|
||||
String colTag = "<col=" + hexColor + ">";
|
||||
@@ -449,14 +445,57 @@ public class GroundItemsPlugin extends Plugin
|
||||
config.setHighlightedItem(COMMA_JOINER.join(highlightedItemSet));
|
||||
}
|
||||
|
||||
public boolean isHighlighted(String item)
|
||||
Color getHighlighted(String item, int gePrice, int haPrice)
|
||||
{
|
||||
return TRUE.equals(highlightedItems.getUnchecked(item));
|
||||
if (TRUE.equals(highlightedItems.getUnchecked(item)))
|
||||
{
|
||||
return config.highlightedColor();
|
||||
}
|
||||
|
||||
// Explicit hide takes priority over implicit highlight
|
||||
if (TRUE.equals(hiddenItems.getUnchecked(item)))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
for (Map.Entry<Integer, Color> entry : priceChecks.entrySet())
|
||||
{
|
||||
if (gePrice > entry.getKey() || haPrice > entry.getKey())
|
||||
{
|
||||
return entry.getValue();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isHidden(String item)
|
||||
Color getHidden(String item, int gePrice, int haPrice, boolean isTradeable)
|
||||
{
|
||||
return TRUE.equals(hiddenItems.getUnchecked(item));
|
||||
final boolean isExplicitHidden = TRUE.equals(hiddenItems.getUnchecked(item));
|
||||
final boolean isExplicitHighlight = TRUE.equals(highlightedItems.getUnchecked(item));
|
||||
final boolean canBeHidden = isTradeable || !config.dontHideUntradeables();
|
||||
final boolean underGe = gePrice < config.getHideUnderValue();
|
||||
final boolean underHa = haPrice < config.getHideUnderValue();
|
||||
|
||||
// Explicit highlight takes priority over implicit hide
|
||||
return isExplicitHidden || (!isExplicitHighlight && canBeHidden && underGe && underHa)
|
||||
? Color.GRAY
|
||||
: null;
|
||||
}
|
||||
|
||||
Color getItemColor(Color highlighted, Color hidden)
|
||||
{
|
||||
if (highlighted != null)
|
||||
{
|
||||
return highlighted;
|
||||
}
|
||||
|
||||
if (hidden != null)
|
||||
{
|
||||
return hidden;
|
||||
}
|
||||
|
||||
return config.defaultColor();
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
|
||||
Reference in New Issue
Block a user