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(
|
@ConfigItem(
|
||||||
keyName = "hideUnderGeValue",
|
keyName = "highlightOverValue",
|
||||||
name = "Hide < GE Value",
|
name = "Highlight > Value",
|
||||||
description = "Configures hidden ground items under GE value",
|
description = "Configures highlighted ground items over either GE or HA value",
|
||||||
position = 8
|
position = 8
|
||||||
)
|
)
|
||||||
default int getHideUnderGeValue()
|
default int getHighlightOverValue()
|
||||||
{
|
{
|
||||||
return 0;
|
return 10000;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ConfigItem(
|
@ConfigItem(
|
||||||
keyName = "hideUnderHaValue",
|
keyName = "hideUnderValue",
|
||||||
name = "Hide < HA Value",
|
name = "Hide < Value",
|
||||||
description = "Configures hidden ground items under High Alch value",
|
description = "Configures hidden ground items under both GE and HA value",
|
||||||
position = 9
|
position = 9
|
||||||
)
|
)
|
||||||
default int getHideUnderHAValue()
|
default int getHideUnderValue()
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -170,24 +170,6 @@ public class GroundItemsOverlay extends Overlay
|
|||||||
continue;
|
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
|
// Update GE price for item
|
||||||
final ItemPrice itemPrice = itemManager.getItemPriceAsync(item.getItemId());
|
final ItemPrice itemPrice = itemManager.getItemPriceAsync(item.getItemId());
|
||||||
|
|
||||||
@@ -196,22 +178,25 @@ public class GroundItemsOverlay extends Overlay
|
|||||||
item.setGePrice(itemPrice.getPrice() * item.getQuantity());
|
item.setGePrice(itemPrice.getPrice() * item.getQuantity());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!plugin.isHotKeyPressed() && !highlighted)
|
final Color highlighted = plugin.getHighlighted(item.getName(), item.getGePrice(), item.getHaPrice());
|
||||||
{
|
final Color hidden = plugin.getHidden(item.getName(), item.getGePrice(), item.getHaPrice(), item.isTradeable());
|
||||||
// Check if item is under config threshold
|
|
||||||
final boolean underThreshold = item.getGePrice() < config.getHideUnderGeValue()
|
|
||||||
|| item.getHaPrice() < config.getHideUnderHAValue();
|
|
||||||
|
|
||||||
// If item is under threshold an we are either not always showing untradeables or item is tradeable
|
if (highlighted == null && !plugin.isHotKeyPressed())
|
||||||
// do not display item
|
{
|
||||||
if (underThreshold && (!config.dontHideUntradeables() || item.isTradeable()))
|
// Do not display hidden items
|
||||||
|
if (hidden != null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Do not display non-highlighted items
|
||||||
|
if (config.showHighlightedOnly())
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final Color color = getCostColor(item.getGePrice() > 0 ? item.getGePrice() : item.getHaPrice(),
|
final Color color = plugin.getItemColor(highlighted, hidden);
|
||||||
highlighted, hidden);
|
|
||||||
itemStringBuilder.append(item.getName());
|
itemStringBuilder.append(item.getName());
|
||||||
|
|
||||||
if (item.getQuantity() > 1)
|
if (item.getQuantity() > 1)
|
||||||
@@ -330,10 +315,10 @@ public class GroundItemsOverlay extends Overlay
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Draw hidden box
|
// 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
|
// 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);
|
textComponent.setText(itemString);
|
||||||
@@ -345,42 +330,6 @@ public class GroundItemsOverlay extends Overlay
|
|||||||
return null;
|
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)
|
private void drawRectangle(Graphics2D graphics, Rectangle rect, Color color, boolean inList, boolean hiddenBox)
|
||||||
{
|
{
|
||||||
graphics.setColor(Color.BLACK);
|
graphics.setColor(Color.BLACK);
|
||||||
|
|||||||
@@ -36,8 +36,8 @@ import java.awt.Color;
|
|||||||
import java.awt.Rectangle;
|
import java.awt.Rectangle;
|
||||||
import static java.lang.Boolean.TRUE;
|
import static java.lang.Boolean.TRUE;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -149,6 +149,7 @@ public class GroundItemsPlugin extends Plugin
|
|||||||
@Getter
|
@Getter
|
||||||
private final Map<GroundItem.GroundItemKey, GroundItem> collectedGroundItems = new LinkedHashMap<>();
|
private final Map<GroundItem.GroundItemKey, GroundItem> collectedGroundItems = new LinkedHashMap<>();
|
||||||
private final List<GroundItem> groundItems = new ArrayList<>();
|
private final List<GroundItem> groundItems = new ArrayList<>();
|
||||||
|
private final Map<Integer, Color> priceChecks = new LinkedHashMap<>();
|
||||||
private LoadingCache<String, Boolean> highlightedItems;
|
private LoadingCache<String, Boolean> highlightedItems;
|
||||||
private LoadingCache<String, Boolean> hiddenItems;
|
private LoadingCache<String, Boolean> hiddenItems;
|
||||||
|
|
||||||
@@ -339,18 +340,14 @@ public class GroundItemsPlugin extends Plugin
|
|||||||
.build(new WildcardMatchLoader(hiddenItemList));
|
.build(new WildcardMatchLoader(hiddenItemList));
|
||||||
|
|
||||||
dirty = true;
|
dirty = true;
|
||||||
}
|
|
||||||
|
|
||||||
private ItemPrice getItemPrice(ItemComposition itemComposition)
|
// Cache colors
|
||||||
{
|
priceChecks.clear();
|
||||||
if (itemComposition.getNote() != -1)
|
priceChecks.put(config.insaneValuePrice(), config.insaneValueColor());
|
||||||
{
|
priceChecks.put(config.highValuePrice(), config.highValueColor());
|
||||||
return itemManager.getItemPriceAsync(itemComposition.getLinkedNoteId());
|
priceChecks.put(config.mediumValuePrice(), config.mediumValueColor());
|
||||||
}
|
priceChecks.put(config.lowValuePrice(), config.lowValueColor());
|
||||||
else
|
priceChecks.put(config.getHighlightOverValue(), config.highlightedColor());
|
||||||
{
|
|
||||||
return itemManager.getItemPriceAsync(itemComposition.getId());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
@@ -361,16 +358,10 @@ public class GroundItemsPlugin extends Plugin
|
|||||||
&& event.getType() == MenuAction.GROUND_ITEM_THIRD_OPTION.getId())
|
&& event.getType() == MenuAction.GROUND_ITEM_THIRD_OPTION.getId())
|
||||||
{
|
{
|
||||||
int itemId = event.getIdentifier();
|
int itemId = event.getIdentifier();
|
||||||
ItemComposition itemComposition = client.getItemDefinition(itemId);
|
|
||||||
|
|
||||||
if (isHidden(itemComposition.getName()))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Region region = client.getRegion();
|
Region region = client.getRegion();
|
||||||
Tile tile = region.getTiles()[client.getPlane()][event.getActionParam0()][event.getActionParam1()];
|
Tile tile = region.getTiles()[client.getPlane()][event.getActionParam0()][event.getActionParam1()];
|
||||||
ItemLayer itemLayer = tile.getItemLayer();
|
ItemLayer itemLayer = tile.getItemLayer();
|
||||||
|
|
||||||
if (itemLayer == null)
|
if (itemLayer == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@@ -381,6 +372,7 @@ public class GroundItemsPlugin extends Plugin
|
|||||||
|
|
||||||
int quantity = 1;
|
int quantity = 1;
|
||||||
Node current = itemLayer.getBottom();
|
Node current = itemLayer.getBottom();
|
||||||
|
|
||||||
while (current instanceof Item)
|
while (current instanceof Item)
|
||||||
{
|
{
|
||||||
Item item = (Item) current;
|
Item item = (Item) current;
|
||||||
@@ -391,13 +383,17 @@ public class GroundItemsPlugin extends Plugin
|
|||||||
current = current.getNext();
|
current = current.getNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemPrice itemPrice = getItemPrice(itemComposition);
|
final ItemComposition itemComposition = itemManager.getItemComposition(itemId);
|
||||||
int price = itemPrice == null ? (int)Math.floor(itemComposition.getPrice() * HIGH_ALCHEMY_CONSTANT) : itemPrice.getPrice();
|
final int realItemId = itemComposition.getNote() != -1 ? itemComposition.getLinkedNoteId() : itemComposition.getId();
|
||||||
int cost = quantity * price;
|
final ItemPrice itemPrice = itemManager.getItemPriceAsync(realItemId);
|
||||||
Color color = overlay.getCostColor(cost, isHighlighted(itemComposition.getName()),
|
final int price = itemPrice == null ? itemComposition.getPrice() : itemPrice.getPrice();
|
||||||
isHidden(itemComposition.getName()));
|
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 hexColor = Integer.toHexString(color.getRGB() & 0xFFFFFF);
|
||||||
String colTag = "<col=" + hexColor + ">";
|
String colTag = "<col=" + hexColor + ">";
|
||||||
@@ -449,14 +445,57 @@ public class GroundItemsPlugin extends Plugin
|
|||||||
config.setHighlightedItem(COMMA_JOINER.join(highlightedItemSet));
|
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
|
@Subscribe
|
||||||
|
|||||||
Reference in New Issue
Block a user